---
name: "genetlink"
section: "4"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/genetlink"
---

# genetlink(4)

Generic Netlink

## 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)](/setsockopt/2.md).

  - 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

[snl(3)](/snl/3.md), [netlink(4)](/netlink/4.md)

## HISTORY

The NETLINK\_GENERIC protocol family appeared in FreeBSD 13.2.

## AUTHORS

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.
