Netlink
The Netlink socket, well described in RFC 3549, represents the preferred interface between user space and kernel for IP networking configuration. Netlink can also be used as an intrakernel messaging system as well as between multiple user-space processes.
With Netlink sockets you can use the standard socket APIs to open, close, transmit on,
and receive from a socket. Let's quickly review the prototype of the socket system call:
int socket(int domain, int type, int protocol)
For details on what the three arguments are initialized to with TCP/IP sockets (i.e.,
domain PF_INET), you can use the man socket command.
As with any other socket, when you open a Netlink socket, you need to provide the
domain, type, and
protocol arguments. Netlink uses the new PF_NETLINK protocol family (domain), supports only the
SOCK_DGRAM type, and defines several protocols, each
one used for a different component (or a set of components) of the networking stack. For
example, the NETLINK_ROUTE protocol is used for most
networking features, such as routing and neighboring protocols, and NETLINK_FIREWALL is used for the firewall (Netfilter). The
Netlink protocols are listed in the NETLINK_
XXX enumeration list in include/linux/netlink.h.
With Netlink sockets, endpoints are usually identified by the ID of the process that opened the sockets (PID), where the special value 0 identifies the kernel. Among Netlink's features is the ability to send both unicast and multicast messages: the destination endpoint ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access