GENETLINK(4)

NAME
genetlink - Generic Netlink

SYNOPSIS
#include <netlink/netlink.h>
#include <netlink/netlink_generic.h>
int
socket(AF_NETLINK, SOCK_DGRAM, NETLINK_GENERIC);

DESCRIPTION
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.

METHODS
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:

  CTRL_CMD_GETFAMILY
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

  TLVs

CTRL_ATTR_FAMILY_ID
    (uint16_t) Dynamically-assigned family identifier.

CTRL_ATTR_FAMILY_NAME
    (string) Family name.

CTRL_ATTR_HDRSIZE
    (uint32_t) Family mandatory header size (typically 0).

CTRL_ATTR_MAXATTR
    (uint32_t) Maximum attribute number valid for the family.

CTRL_ATTR_OPS
    (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:

    CTRL_ATTR_OP_ID
        Operation (message) number.

    CTRL_ATTR_OP_FLAGS
        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

CTRL_ATTR_MCAST_GROUPS
    (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:

    CTRL_ATTR_MCAST_GRP_ID
        Group id that can be used in NETLINK_ADD_MEMBERSHIP setsockopt(2).

    CTRL_ATTR_MCAST_GRP_NAME
        (string) Human-readable name of the group.

  Groups
The following groups are defined:
    "notify"	Notifies on family registrations/removal.

SEE ALSO
netlink(4)

HISTORY
The NETLINK_GENERIC protocol family appeared in FreeBSD 13.2.

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