GENETLINK(4)
π GENETLINK β like, the generic Netlink page, bestie
okay so this is from the Kernel Interfaces Manual (section 4, iykyk), and it's literally all about genetlink β Generic Netlink. buckle up, it's cuter than it sounds π
β¨ NAME β¨
genetlink β Generic Netlink. that's it, that's the vibe π¦
β¨ SYNOPSIS β¨
#include <netlink/netlink.h>
#include <netlink/netlink_generic.h>
int
socket(AF_NETLINK, SOCK_DGRAM, NETLINK_GENERIC);
β¨ DESCRIPTION β¨
okay so NETLINK_GENERIC is a "container" family β think of it as the group chat that other families get added to π. it's used for dynamic registration of other families that belong to all the various subsystems.
here's the tea π: those subsystems hand over a string family name when they register, and in exchange they get a dynamically-allocated family id. then applications use those allocated family identifiers to actually get at the functions that subsystem provides over netlink. and yes, there are standard methods for turning a string family name into a family id β no cap. a similar mechanism works for the notification groups that those families provide, too β¨.
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, and the version field is the command version. slay π
β¨ METHODS β¨
the generic Netlink framework provides the base family, GENL_ID_CTRL ("nlctrl"), with a fixed family id. this family is literally the one you use to list the details of all the registered families π«Ά.
the framework supports the following messages:
πΈ CTRL_CMD_GETFAMILY πΈ
fetches a single family β or all registered families, depending on the NLM_F_DUMP flag. each family gets reported as a CTRL_CMD_NEWFAMILY message β.
the kernel recognises these filters:
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) the dynamically-assigned family identifier.CTRL_ATTR_FAMILY_NAMEβ (string) the family name.CTRL_ATTR_HDRSIZEβ (uint32_t) family mandatory header size (typically0).CTRL_ATTR_MAXATTRβ (uint32_t) maximum attribute number that's valid for the family.CTRL_ATTR_OPSβ (nested) the list of operations supported by the family. the attribute consists of a list of nested TLVs, with attribute values monotonically incremented, starting from0. each TLV contains the following attributes:CTRL_ATTR_OP_IDβ operation (message) number.CTRL_ATTR_OP_FLAGSβ operation flags. the following flags are supported:GENL_ADMIN_PERMβ requires elevated permissionsGENL_CMD_CAP_DOβ operation is a modification requestGENL_CMD_CAP_DUMPβ operation is a get/dump request
CTRL_ATTR_MCAST_GROUPSβ (nested) the list of notification groups supported by the family. this attribute consists of a list of nested TLVs, with attribute values monotonically incremented, starting from0. each TLV contains the following attributes:CTRL_ATTR_MCAST_GRP_IDβ group id that can be used inNETLINK_ADD_MEMBERSHIPsetsockopt(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.
so likeβ¦ "notify" tells you when families get registered or removed. main character energy honestly π
β¨ SEE ALSO β¨
β¨ 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. iconic behavior honestly π
ngl bestie, if you made it this far you deserve a little treat π β go read netlink(4) next, it's giving required reading π§
and that's the whole page, periodt π β this cutie came to you from Debian, dated November 1, 2022. bye bestie, go write some netlink code π¦β¨
π¦ where this page comes from
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (C) 2022 Alexander Chernikov <melifaro@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms