mirror of https://github.com/mkerrisk/man-pages
remove trailing white space
This commit is contained in:
parent
cc9befa9ac
commit
e604b4fc73
124
man7/netlink.7
124
man7/netlink.7
|
@ -14,38 +14,38 @@ netlink \- Communication between kernel and userspace (PF_NETLINK)
|
|||
.br
|
||||
.B #include <sys/socket.h>
|
||||
.br
|
||||
.B #include <linux/netlink.h>
|
||||
.B #include <linux/netlink.h>
|
||||
.br
|
||||
.PP
|
||||
.BI "netlink_socket = socket(PF_NETLINK, " socket_type ", " netlink_family );
|
||||
.BI "netlink_socket = socket(PF_NETLINK, " socket_type ", " netlink_family );
|
||||
.SH DESCRIPTION
|
||||
Netlink is used to transfer information between kernel and
|
||||
Netlink is used to transfer information between kernel and
|
||||
userspace processes.
|
||||
It consists of a standard sockets-based interface for userspace
|
||||
processes and an internal kernel API for kernel modules.
|
||||
The internal kernel interface is not documented in this manual page.
|
||||
It consists of a standard sockets-based interface for userspace
|
||||
processes and an internal kernel API for kernel modules.
|
||||
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
|
||||
via netlink character devices; this interface is not documented here
|
||||
and is only provided for backwards compatibility.
|
||||
|
||||
Netlink is a datagram-oriented service. Both
|
||||
.B SOCK_RAW
|
||||
.B SOCK_RAW
|
||||
and
|
||||
.B SOCK_DGRAM
|
||||
are valid values for
|
||||
.IR socket_type .
|
||||
However, the netlink protocol does not distinguish between datagram
|
||||
However, the netlink protocol does not distinguish between datagram
|
||||
and raw sockets.
|
||||
|
||||
.I netlink_family
|
||||
selects the kernel module or netlink group to communicate with.
|
||||
selects the kernel module or netlink group to communicate with.
|
||||
The currently assigned netlink families are:
|
||||
.TP
|
||||
.B NETLINK_ROUTE
|
||||
Receives routing and link updates and may be used to modify the routing
|
||||
tables (both IPv4 and IPv6), IP addresses, link parameters,
|
||||
neighbour setups, queueing disciplines, traffic classes and
|
||||
packet classifiers (see
|
||||
tables (both IPv4 and IPv6), IP addresses, link parameters,
|
||||
neighbour setups, queueing disciplines, traffic classes and
|
||||
packet classifiers (see
|
||||
.BR rtnetlink (7)).
|
||||
.TP
|
||||
.B NETLINK_W1
|
||||
|
@ -54,9 +54,9 @@ Messages from 1-wire subsystem.
|
|||
.B NETLINK_USERSOCK
|
||||
Reserved for user-mode socket protocols.
|
||||
.TP
|
||||
.B NETLINK_FIREWALL
|
||||
Transport IPv4 packets from netfilter to userspace. Used by
|
||||
.I ip_queue
|
||||
.B NETLINK_FIREWALL
|
||||
Transport IPv4 packets from netfilter to userspace. Used by
|
||||
.I ip_queue
|
||||
kernel module.
|
||||
.TP
|
||||
.B NETLINK_INET_DIAG
|
||||
|
@ -95,8 +95,8 @@ in the kernel source for further information.
|
|||
Netfilter subsystem.
|
||||
.TP
|
||||
.B NETLINK_IP6_FW
|
||||
Transport IPv6 packets from netfilter to userspace. Used by
|
||||
.I ip6_queue
|
||||
Transport IPv6 packets from netfilter to userspace. Used by
|
||||
.I ip6_queue
|
||||
kernel module.
|
||||
.TP
|
||||
.B NETLINK_DNRTMSG
|
||||
|
@ -109,9 +109,9 @@ Kernel messages to userspace.
|
|||
.B NETLINK_GENERIC
|
||||
Generic netlink family for simplified netlink usage.
|
||||
.PP
|
||||
Netlink messages consist of a byte stream with one or multiple
|
||||
Netlink messages consist of a byte stream with one or multiple
|
||||
.I nlmsghdr
|
||||
headers and associated payload.
|
||||
headers and associated payload.
|
||||
The byte stream should only be accessed with the standard
|
||||
.B NLMSG_*
|
||||
macros. See
|
||||
|
@ -168,16 +168,16 @@ appropriate manual pages for that, e.g.
|
|||
for
|
||||
.BR NETLINK_ROUTE .
|
||||
|
||||
Standard flag bits in
|
||||
Standard flag bits in
|
||||
.I nlmsg_flags
|
||||
.br
|
||||
---------------------------------
|
||||
.TS
|
||||
tab(:);
|
||||
.TS
|
||||
tab(:);
|
||||
lB l.
|
||||
NLM_F_REQUEST:Must be set on all request messages.
|
||||
NLM_F_MULTI:T{
|
||||
The message is part of a multipart message terminated by
|
||||
The message is part of a multipart message terminated by
|
||||
.BR NLMSG_DONE .
|
||||
T}
|
||||
NLM_F_ACK:Request for an acknowledgment on success.
|
||||
|
@ -192,7 +192,7 @@ tab(:);
|
|||
lB l.
|
||||
NLM_F_ROOT:Return the complete table instead of a single entry.
|
||||
NLM_F_MATCH:T{
|
||||
Return all entries matching criteria passed in message content.
|
||||
Return all entries matching criteria passed in message content.
|
||||
Not implemented yet.
|
||||
T}
|
||||
.\" FIXME NLM_F_ATOMIC is not used any more?
|
||||
|
@ -203,7 +203,7 @@ NLM_F_DUMP:Convenience macro; equivalent to (NLM_F_ROOT|NLM_F_MATCH).
|
|||
Note that
|
||||
.B NLM_F_ATOMIC
|
||||
requires the
|
||||
.B CAP_NET_ADMIN
|
||||
.B CAP_NET_ADMIN
|
||||
capability or an effective UID of 0.
|
||||
|
||||
Additional flag bits for NEW requests
|
||||
|
@ -223,10 +223,10 @@ and
|
|||
.I nlmsg_pid
|
||||
are used to track messages.
|
||||
.I nlmsg_pid
|
||||
shows the origin of the message.
|
||||
shows the origin of the message.
|
||||
Note that there isn't a 1:1 relationship between
|
||||
.I nlmsg_pid
|
||||
and the PID of the process if the message originated from a netlink
|
||||
.I nlmsg_pid
|
||||
and the PID of the process if the message originated from a netlink
|
||||
socket.
|
||||
See the
|
||||
.B ADDRESS FORMATS
|
||||
|
@ -239,26 +239,26 @@ and
|
|||
.\" FIXME Explain more about nlmsg_seq and nlmsg_pid.
|
||||
are opaque to netlink core.
|
||||
|
||||
Netlink is not a reliable protocol.
|
||||
It tries its best to deliver a message to its destination(s),
|
||||
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
|
||||
other error occurs. For reliable transfer the sender can request an
|
||||
acknowledgement from the receiver by setting the
|
||||
.B NLM_F_ACK
|
||||
flag. An acknowledgment is an
|
||||
.B NLMSG_ERROR
|
||||
packet with the error field set to 0.
|
||||
packet with the error field set to 0.
|
||||
The application must generate acknowledgements for
|
||||
received messages itself. The kernel tries to send an
|
||||
.B NLMSG_ERROR
|
||||
message for every failed packet.
|
||||
message for every failed packet.
|
||||
A user process should follow this convention too.
|
||||
|
||||
However, reliable transmissions from kernel to user are impossible
|
||||
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:
|
||||
the message will be dropped and the kernel and the userspace process will
|
||||
no longer have the same view of kernel state.
|
||||
the message will be dropped and the kernel and the userspace process will
|
||||
no longer have the same view of kernel state.
|
||||
It is up to the application to detect when this happens (via the
|
||||
.B ENOBUFS
|
||||
error returned by
|
||||
|
@ -269,12 +269,12 @@ and resynchronise.
|
|||
The
|
||||
.I sockaddr_nl
|
||||
structure describes a netlink client in user space or in the kernel.
|
||||
A
|
||||
.I sockaddr_nl
|
||||
A
|
||||
.I sockaddr_nl
|
||||
can be either unicast (only sent to one peer) or sent to
|
||||
netlink multicast groups
|
||||
.RI ( nl_groups
|
||||
not equal 0).
|
||||
netlink multicast groups
|
||||
.RI ( nl_groups
|
||||
not equal 0).
|
||||
|
||||
.in +0.25i
|
||||
.nf
|
||||
|
@ -289,36 +289,36 @@ struct sockaddr_nl {
|
|||
|
||||
.I nl_pid
|
||||
is the unicast address of netlink socket.
|
||||
It's always 0 if the destination is in the kernel.
|
||||
It's always 0 if the destination is in the kernel.
|
||||
For a userspace process,
|
||||
.I nl_pid
|
||||
is usually the PID of the process owning the destination socket.
|
||||
is usually the PID of the process owning the destination socket.
|
||||
However,
|
||||
.I nl_pid
|
||||
identifies a netlink socket, not a process.
|
||||
identifies a netlink socket, not a process.
|
||||
If a process owns several netlink
|
||||
sockets, then
|
||||
.I nl_pid
|
||||
can only be equal to the process ID for at most one socket.
|
||||
.I nl_pid
|
||||
can only be equal to the process ID for at most one socket.
|
||||
There are two ways to assign
|
||||
.I nl_pid
|
||||
to a netlink socket.
|
||||
to a netlink socket.
|
||||
If the application sets
|
||||
.I nl_pid
|
||||
before calling
|
||||
.BR bind (2),
|
||||
then it is up to the application to make sure that
|
||||
.I nl_pid
|
||||
is unique.
|
||||
is unique.
|
||||
If the application sets it to 0, the kernel takes care of assigning it.
|
||||
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.
|
||||
|
||||
.I nl_groups
|
||||
.I nl_groups
|
||||
is a bitmask with every bit representing a netlink group number.
|
||||
Each netlink family has a set of 32 multicast groups.
|
||||
Each netlink family has a set of 32 multicast groups.
|
||||
When
|
||||
.BR bind (2)
|
||||
is called on the socket, the
|
||||
|
@ -337,16 +337,16 @@ or does a
|
|||
Only processes with an effective UID of 0 or the
|
||||
.B CAP_NET_ADMIN
|
||||
capability may send or listen to a netlink multicast group.
|
||||
Any replies to a message received for a multicast group should be
|
||||
Any replies to a message received for a multicast group should be
|
||||
sent back to the sending PID and the multicast group.
|
||||
|
||||
.SH EXAMPLES
|
||||
The following example creates a
|
||||
.B NETLINK_ROUTE
|
||||
.B NETLINK_ROUTE
|
||||
netlink socket which will listen to the
|
||||
.B RTMGRP_LINK
|
||||
.B RTMGRP_LINK
|
||||
(network interface create/delete/up/down events) and
|
||||
.B RTMGRP_IPV4_IFADDR
|
||||
.B RTMGRP_IPV4_IFADDR
|
||||
(IPv4 addresses add/delete events) multicast groups.
|
||||
|
||||
.in +0.25i
|
||||
|
@ -362,9 +362,9 @@ bind(fd, (struct sockaddr*)&sa, sizeof(sa));
|
|||
.fi
|
||||
.in -0.25i
|
||||
|
||||
The next example demonstrates how to send a netlink message to the
|
||||
kernel (pid 0).
|
||||
Note that application must take care of message sequence numbers
|
||||
The next example demonstrates how to send a netlink message to the
|
||||
kernel (pid 0).
|
||||
Note that application must take care of message sequence numbers
|
||||
in order to reliably track acknowledgements.
|
||||
|
||||
.in +0.25i
|
||||
|
@ -417,10 +417,10 @@ for (nh = (struct nlmsghdr *) buf; NLMSG_OK (nh, len);
|
|||
.in -0.25i
|
||||
|
||||
.SH BUGS
|
||||
This manual page is not complete.
|
||||
This manual page is not complete.
|
||||
|
||||
.SH NOTES
|
||||
It is often better to use netlink via
|
||||
It is often better to use netlink via
|
||||
.B libnetlink
|
||||
or
|
||||
.B libnl
|
||||
|
@ -429,8 +429,8 @@ than via the low level kernel interface.
|
|||
.SH VERSIONS
|
||||
The socket interface to netlink is a new feature of Linux 2.2.
|
||||
|
||||
Linux 2.0 supported a more primitive device based netlink interface
|
||||
(which is still available as a compatibility option).
|
||||
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.
|
||||
|
||||
NETLINK_SELINUX appeared in Linux 2.6.4.
|
||||
|
@ -452,7 +452,7 @@ NETLINK_GENERIC and NETLINK_ISCSI appeared in Linux 2.6.15.
|
|||
.BR capabilities (7),
|
||||
.BR rtnetlink (7)
|
||||
.PP
|
||||
ftp://ftp.inr.ac.ru/ip-routing/iproute2*
|
||||
ftp://ftp.inr.ac.ru/ip-routing/iproute2*
|
||||
for information about libnetlink.
|
||||
|
||||
http://people.suug.ch/~tgr/libnl/
|
||||
|
|
Loading…
Reference in New Issue