Older families often define "null" attributes and commands with value
0 and named
unspec. This is supported (
but should be avoided in new families. The
unspec enum values are
not used in practice, so just set the value of the first attribute to
Use the same command IDs for requests and replies. This makes it easier
to match them up, and we have plenty of ID space.
Use separate command IDs for notifications. This makes it easier to
sort the notifications from replies (and present them to the user
application via a different API than replies).
Older families do not reply to all of the commands, especially NEW / ADD
commands. User only gets information whether the operation succeeded or
not via the ACK. Try to find useful data to return. Once the command is
added whether it replies with a full message or only an ACK is uAPI and
cannot be changed. It's better to err on the side of replying.
Specifically NEW and ADD commands should reply with information identifying
the created object such as the allocated object's ID (without having to
resort to using
Make sure to pass the request info to genl_notify() to allow
to take effect. This is useful for programs that need precise feedback
from the kernel (for example for logging purposes).
Support dump consistency
If iterating over objects during dump may skip over objects or repeat
them - make sure to report dump inconsistency with
This is usually implemented by maintaining a generation id for the
structure and recording it in the
seq member of struct netlink_callback.