Manual Page Search Parameters

GENETLINK(4) Device Drivers Manual GENETLINK(4)

genetlinkGeneric Netlink

#include <netlink/netlink.h>
#include <netlink/netlink_generic.h>

int
socket(AF_NETLINK, SOCK_DGRAM, NETLINK_GENERIC);

The NETLINK_GENERIC is a "container" family, used for dynamic registration of other families belonging to the various subsystems. These subsystems provide a string family name during registration and receive a dynamically-allocated family id. Allocated family identifiers are then used by applications to get access to functions provided by that subsystem via netlink. There are standard methods for resolving string family names to family identifiers. A similar mechanism works for the notification groups provided by those families.

All generic netlink families share a common header:

struct genlmsghdr {
	uint8_t		cmd;		/* command within the family */
	uint8_t		version;	/* ABI version for the cmd */
	uint16_t	reserved;	/* reserved: set to 0 */
};
The family id is encoded in the nlmsg_type of the base netlink header. The cmd field is the command identifier within the family. The version field is the command version.

The generic Netlink framework provides the base family, GENL_ID_CTRL ("nlctrl") with a fixed family id. This family is used to list the details of all registered families.

The following messages are supported by the framework:

Fetches a single family or all registered families, depending on the NLM_F_DUMP flag. Each family is reported as CTRL_CMD_NEWFAMILY message. The following filters are recognised by the kernel:

CTRL_ATTR_FAMILY_ID	(uint16_t) current family id assigned by kernel
CTRL_ATTR_FAMILY_NAME	(string) family name

(uint16_t) Dynamically-assigned family identifier.
(string) Family name.
(uint32_t) Family mandatory header size (typically 0).
(uint32_t) Maximum attribute number valid for the family.
(nested) List of the operations supported by the family. The attribute consists of a list of nested TLVs, with attribute values monotonically incremented, starting from 0. The following attributes are present in each TLV:
Operation (message) number.
Operation flags. The following flags are supported:
GENL_ADMIN_PERM		requires elevated permissions
GENL_CMD_CAP_DO		operation is a modification request
GENL_CMD_CAP_DUMP	operation is a get/dump request
(nested) List of the notification groups supported by the family. The attribute consists of a list of nested TLVs, with attribute values monotonically incremented, starting from 0. The following attributes are present in each TLV:
Group id that can be used in NETLINK_ADD_MEMBERSHIP setsockopt(2).
(string) Human-readable name of the group.

The following groups are defined:

"notify"	Notifies on family registrations/removal.

netlink(4)

The NETLINK_GENERIC protocol family appeared in FreeBSD 13.2.

The netlink was implemented by Alexander Chernikov <melifaro@FreeBSD.org>. It was derived from the Google Summer of Code 2021 project by Ng Peng Nam Sean.

November 1, 2022 dev