diff options
Diffstat (limited to 'man7/netlink.7')
-rw-r--r-- | man7/netlink.7 | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/man7/netlink.7 b/man7/netlink.7 index 4d6cdbc..e0e14f4 100644 --- a/man7/netlink.7 +++ b/man7/netlink.7 @@ -6,7 +6,7 @@ .\" Based on the original comments from Alexey Kuznetsov .\" Modified 2005-12-27 by Hasso Tepper <hasso@estpak.ee> .\" $Id: netlink.7,v 1.8 2000/06/22 13:23:00 ak Exp $ -.TH netlink 7 2023-07-30 "Linux man-pages 6.05.01" +.TH netlink 7 2023-10-31 "Linux man-pages 6.7" .SH NAME netlink \- communication between kernel and user space (AF_NETLINK) .SH SYNOPSIS @@ -14,7 +14,7 @@ netlink \- communication between kernel and user space (AF_NETLINK) .B #include <asm/types.h> .B #include <sys/socket.h> .B #include <linux/netlink.h> -.PP +.P .BI "netlink_socket = socket(AF_NETLINK, " socket_type ", " netlink_family ); .fi .SH DESCRIPTION @@ -26,7 +26,7 @@ The internal kernel interface is not documented in this manual page. There is also an obsolete netlink interface via netlink character devices; this interface is not documented here and is provided only for backward compatibility. -.PP +.P Netlink is a datagram-oriented service. Both .B SOCK_RAW @@ -36,7 +36,7 @@ are valid values for .IR socket_type . However, the netlink protocol does not distinguish between datagram and raw sockets. -.PP +.P .I netlink_family selects the kernel module or netlink group to communicate with. The currently assigned netlink families are: @@ -144,7 +144,7 @@ Generic netlink family for simplified netlink usage. Netlink interface to request information about ciphers registered with the kernel crypto API as well as allow configuration of the kernel crypto API. -.PP +.P Netlink messages consist of a byte stream with one or multiple .I nlmsghdr headers and associated payload. @@ -154,7 +154,7 @@ macros. See .BR netlink (3) for further information. -.PP +.P In multipart messages (multiple .I nlmsghdr headers with associated payload in one byte stream) the first and all @@ -162,11 +162,11 @@ following headers have the .B NLM_F_MULTI flag set, except for the last header which has the type .BR NLMSG_DONE . -.PP +.P After each .I nlmsghdr the payload follows. -.PP +.P .in +4n .EX struct nlmsghdr { @@ -178,7 +178,7 @@ struct nlmsghdr { }; .EE .in -.PP +.P .I nlmsg_type can be one of the standard message types: .B NLMSG_NOOP @@ -192,7 +192,7 @@ message terminates a multipart message. Error messages get the original request appended, unless the user requests to cap the error message, and get extra error data if requested. -.PP +.P .in +4n .EX struct nlmsgerr { @@ -212,7 +212,7 @@ struct nlmsgerr { }; .EE .in -.PP +.P A netlink family usually specifies more message types, see the appropriate manual pages for that, for example, .BR rtnetlink (7) @@ -261,7 +261,7 @@ Convenience macro; equivalent to T} .TE .\" FIXME NLM_F_ATOMIC is not used anymore? -.PP +.P Note that .B NLM_F_ATOMIC requires the @@ -286,7 +286,7 @@ NLM_F_APPEND:T{ Add to the end of the object list. T} .TE -.PP +.P .I nlmsg_seq and .I nlmsg_pid @@ -300,14 +300,14 @@ socket. See the .B ADDRESS FORMATS section for further information. -.PP +.P Both .I nlmsg_seq and .I nlmsg_pid .\" FIXME Explain more about nlmsg_seq and nlmsg_pid. are opaque to netlink core. -.PP +.P Netlink is not a reliable protocol. It tries its best to deliver a message to its destination(s), but may drop messages when an out-of-memory condition or @@ -325,7 +325,7 @@ The kernel tries to send an .B NLMSG_ERROR message for every failed packet. A user process should follow this convention too. -.PP +.P However, reliable transmissions from kernel to user are impossible in any case. The kernel can't send a netlink message if the socket buffer is full: @@ -346,7 +346,7 @@ can be either unicast (only sent to one peer) or sent to netlink multicast groups .RI ( nl_groups not equal 0). -.PP +.P .in +4n .EX struct sockaddr_nl { @@ -357,7 +357,7 @@ struct sockaddr_nl { }; .EE .in -.PP +.P .I nl_pid is the unicast address of netlink socket. It's always 0 if the destination is in the kernel. @@ -386,7 +386,7 @@ The kernel assigns the process ID to the first netlink socket the process opens and assigns a unique .I nl_pid to every netlink socket that the process subsequently creates. -.PP +.P .I nl_groups is a bit mask with every bit representing a netlink group number. Each netlink family has a set of 32 multicast groups. @@ -443,7 +443,9 @@ Enable control messages for received packets to get the extended destination group number. .TP -.BR NETLINK_ADD_MEMBERSHIP ,\ NETLINK_DROP_MEMBERSHIP " (since Linux 2.6.14)" +.B NETLINK_ADD_MEMBERSHIP +.TQ +.BR NETLINK_DROP_MEMBERSHIP " (since Linux 2.6.14)" .\" commit 9a4595bc7e67962f13232ee55a64e063062c3a99 .\" Author: Patrick McHardy <kaber@trash.net> Join/leave a group specified by @@ -502,7 +504,7 @@ The netlink message header is still included, so the user can guess from the sequence number which message triggered the acknowledgement. .SH VERSIONS The socket interface to netlink first appeared Linux 2.2. -.PP +.P Linux 2.0 supported a more primitive device-based netlink interface (which is still available as a compatibility option). This obsolete interface is not described here. @@ -522,7 +524,7 @@ netlink socket which will listen to the (network interface create/delete/up/down events) and .B RTMGRP_IPV4_IFADDR (IPv4 addresses add/delete events) multicast groups. -.PP +.P .in +4n .EX struct sockaddr_nl sa; @@ -535,12 +537,12 @@ fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); bind(fd, (struct sockaddr *) &sa, sizeof(sa)); .EE .in -.PP +.P The next example demonstrates how to send a netlink message to the kernel (pid 0). Note that the application must take care of message sequence numbers in order to reliably track acknowledgements. -.PP +.P .in +4n .EX struct nlmsghdr *nh; /* The nlmsghdr with payload to send */ @@ -559,9 +561,9 @@ nh\->nlmsg_flags |= NLM_F_ACK; sendmsg(fd, &msg, 0); .EE .in -.PP +.P And the last example is about reading netlink message. -.PP +.P .in +4n .EX int len; @@ -597,13 +599,13 @@ for (nh = (struct nlmsghdr *) buf; NLMSG_OK (nh, len); .BR capabilities (7), .BR rtnetlink (7), .BR sock_diag (7) -.PP +.P .UR ftp://ftp.inr.ac.ru\:/ip\-routing\:/iproute2* information about libnetlink .UE -.PP +.P .UR http://www.infradead.org\:/\[ti]tgr\:/libnl/ information about libnl .UE -.PP +.P RFC 3549 "Linux Netlink as an IP Services Protocol" |