Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
netlink(7)
Edit
PageHistory
Diff
Info
LikePages
NETLINK !!!NETLINK NAME SYNOPSIS DESCRIPTION ADDRESS FORMATS BUGS NOTES VERSIONS SEE ALSO ---- !!NAME netlink, PF_NETLINK - Communication between kernel and user. !!SYNOPSIS __#include __ ''socket_type''__,__ ''netlink_family''__); __ !!DESCRIPTION Netlink is used to transfer information between kernel modules and user space processes. It consists of a standard sockets based interface for user processes and an internal kernel API for kernel modules. The internal kernel interface is not documented in this man page. Also there is an obsolete netlink interface via netlink character devices, this interface is not documented here and is only provided for backwards compatibility. Netlink is a datagram oriented service. Both __SOCK_RAW__ and __SOCK_DGRAM__ are valid values for ''socket_type''; however the netlink protocol does not distinguish between datagram and raw sockets. ''netlink_family'' selects the kernel module or netlink group to communicate with. The currently assigned netlink families are: __NETLINK_ROUTE__ Receives routing updates and may be used to modify the IPv4 routing table (see rtnetlink(7)). __NETLINK_FIREWALL__ Receives packets sent by the IPv4 firewall code. __NETLINK_ARPD__ For managing the arp table in user space. __NETLINK_ROUTE6__ Receives and sends IPv6 routing table updates. __NETLINK_IP6_FW__ to receive packets that failed the IPv6 firewall checks (currently not implemented). __NETLINK_TAPBASE__...__NETLINK_TAPBASE+15__ are the instances of the __ethertap__ device. Ethertap is a pseudo network tunnel device that allows an ethernet driver to be simulated from user space. __NETLINK_SKIP__ Reserved for ENskip. __NETLINK_USERSOCK__ is reserved for future user space protocols. Netlink messages consist of a byte stream with one or multiple __nlmsghdr__ headers and associated payload. For multipart messages the first and all following headers have the __NLM_F_MULTI__ flag set, except for the last header which has the type __NLMSG_DONE__. The byte stream should only be accessed with the standard __NLMSG_*__ macros, see netlink(3). 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 __NLM_F_ACK__ flag. An acknowledgment is an __NLMSG_ERROR__ packet with the error field set to 0. The application must generate acks for received messages itself. The kernel tries to send an __NLMSG_ERROR__ message for every failed packet. A user process should follow this convention too. Each netlink family has a set of 32 multicast groups. When bind(2) is called on the socket, the __nl_groups__ field in the __sockaddr_nl__ should be set to a bitmask of the groups which it wishes to listen to. The default value for this field is zero which means that no multicasts will be received. A socket may multicast messages to any of the multicast groups by setting __nl_groups__ to a bitmask of the groups it wishes to send to when it calls sendmsg(2) or does a connect(2). Only users with an effective uid of 0 or the __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 sent back to the sending pid and the multicast group. struct nlmsghdr { __u32 nlmsg_len; /* Length of message including header */ __u16 nlmsg_type; /* Message content */ __u16 nlmsg_flags;/* Additional flags */ __u32 nlmsg_seq; /* Sequence number */ __u32 nlmsg_pid; /* PID of the process that opened the socket */ }; struct nlmsgerr { int error; /* negative errno or 0 for acks. */ struct nlmsghdr msg; /* message header that caused the error */ }; After each __nlmsghdr__ the payload follows. __nlmsg_type__ can be one of the standard message types: __NLMSG_NOOP__ message is to be ignored, __NLMSG_ERROR__ the message signals an error and the payload contains a ''nlmsgerr'' structure, __NLMSG_DONE__ message terminates a multipart message, A netlink family usually specifies more message types, see the appropriate man pages for that, e.g. rtnetlink(7) for ''NETLINK_ROUTE''. Note that NLM_F_ATOMIC requires CAP_NET_ADMIN or super user rights. !!ADDRESS FORMATS The __sockaddr_nl__ structure describes a netlink client in user space or in the kernel. A sockaddr_nl can be either unicast (only send to one peer) or send to netlink groups (nl_groups not equal 0). struct sockaddr_nl { sa_family_t nl_family; /* AF_NETLINK */ unsigned short nl_pad; /* zero */ pid_t nl_pid; /* process pid */ __u32 nl_groups; /* multicast groups mask */ }; __nl_pid__ is the pid of the process owning the destination socket, or 0 if the destination is in the kernel. __nl_groups__ is a bitmask with every bit representing a netlink group number. !!BUGS This man page is not complete. !!NOTES It is often better to use netlink via __libnetlink__ than via the low level kernel interface. !!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). This obsolete interface is not described here. !!SEE ALSO cmsg(3), rtnetlink(7), netlink(3) ftp://ftp.inr.ac.ru/ip-routing/iproute2* for libnetlink ----
10 pages link to
netlink(7)
:
AddressFamily
LinuxNetlinkSockets
Man7n
arp(7)
netlink(3)
rtnetlink(3)
rtnetlink(7)
bind(2)
socket(2)
ip(7)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.