Copyright (C) 2000-2012 |
Manpages NETLINKSection: Linux Programmer's Manual (7)Updated: 1999-04-27 Index Return to Main Contents NAMEnetlink, PF_NETLINK - Communication between kernel and user.SYNOPSIS#include <asm/types.h> DESCRIPTIONNetlink 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 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.
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 FORMATSThe 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).
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.
BUGSThis man page is not complete.NOTESIt is often better to use netlink via libnetlink than via the low level kernel interface.VERSIONSThe socket interface to netlink is a new feature of Linux 2.2Linux 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 ALSOcmsg(3), rtnetlink(7), netlink(3)ftp://ftp.inr.ac.ru/ip-routing/iproute2* for libnetlink
IndexThis document was created by man2html, using the manual pages. Time: 02:08:22 GMT, December 13, 2024 |