Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Netlink

From Wikipedia, the free encyclopedia
Linux kernel interface for inter-process communication between processes
For the modem, seeSega Net Link. For the former Canadian computer retailer, whose name contained the word "netlink", seeNCIX.
Netlink
Stable release
6.19[1] Edit this on Wikidata / 8 February 2026; 4 days ago (8 February 2026)
Operating systemLinux
PlatformLinux kernel
TypeApplication programming interface
LicenseGNU General Public License
Websitewiki.linuxfoundation.org/networking/generic_netlink_howto

Netlink is asocket family used forinter-process communication (IPC) between both the kernel anduserspace processes, and between different userspace processes, in a way similar to theUnix domain sockets available on certain Unix-likeoperating systems, including its original incarnation as aLinux kernel interface, as well as in the form of a later implementation onFreeBSD.[2] Similarly to theUnix domain sockets, and unlikeINET sockets, Netlink communication cannot traverse host boundaries. However, while the Unix domain sockets use thefile system namespace, Netlink sockets are usually addressed byprocess identifiers (PIDs).[3]

Netlink is designed and used for transferring miscellaneous networking information between thekernel space and userspace processes. Networking utilities, such as theiproute2 family and the utilities used for configuringmac80211-based wireless drivers, use Netlink to communicate with theLinux kernel from userspace. Netlink provides a standardsocket-based interface for userspace processes, and a kernel-sideAPI for internal use bykernel modules. Originally, Netlink used theAF_NETLINK socket family.

Netlink is designed to be a more flexible successor toioctl;RFC 3549 describes the protocol in detail.

History

[edit]

Netlink was created by Alexey Kuznetsov[4] as a more flexible alternative to the sophisticated but awkwardioctl communication method used for setting and getting external socket options. The Linux kernel continues to supportioctl for backward compatibility.

Netlink was first provided in the 2.0 series of the Linux kernel, implemented as acharacter device. By 2013, this interface is obsolete, but still forms anioctl communication method; compare the use ofrtnetlink.[5] The Netlink socket interface appeared in 2.2 series of the Linux kernel.

In 2022, experimental support for the Netlink protocol was added to FreeBSD. Initially, only a subset of theNETLINK_ROUTE family andNETLINK_GENERIC is supported.[2]

Packet structure

[edit]
Bit offset0–1516–31
0Message length
32TypeFlags
64Sequence number
96PID
128+ 
Data
 

UnlikeBSD sockets using Internet protocols such asTCP, where the message headers are autogenerated, the Netlink message header (available asstruct nlmsghdr) must be prepared by the caller. The Netlink socket generally works in aSOCK_RAW-like mode, even ifSOCK_DGRAM was used to create it.

The data portion then contains a subsystem-specific message that may be further nested.

Netlink socket families

[edit]

TheAF_NETLINK family offers multiple protocol subsets. Each interfaces to a different kernel component and has a different messaging subset. The subset is referenced by the protocol field in the socket call:

int socket(AF_NETLINK, SOCK_DGRAMor SOCK_RAW,protocol)

Lacking a standard,SOCK_DGRAM andSOCK_RAW are not guaranteed to be implemented in a given Linux (or other OS) release. Some sources state that both options are legitimate, and the reference below fromRed Hat states thatSOCK_RAW is always the parameter. However, iproute2 uses both interchangeably.

Netlink protocols

[edit]

A non-exhaustive list of the supportedprotocol entries follows:

NETLINK_ROUTE

NETLINK_ROUTE provides routing and link information. This information is used primarily for user-space routing daemons.Linux implements a large subset of messages:

  • Link layer:RTM_NEWLINK,RTM_DELLINK,RTM_GETLINK,RTM_SETLINK
  • Address settings:RTM_NEWADDR,RTM_DELADDR,RTM_GETADDR
  • Routing tables:RTM_NEWROUTE,RTM_DELROUTE,RTM_GETROUTE
  • Neighbor cache:RTM_NEWNEIGH,RTM_DELNEIGH,RTM_GETNEIGH
  • Routing rules:RTM_NEWRULE,RTM_DELRULE,RTM_GETRULE
  • Queuing discipline settings:RTM_NEWQDISC,RTM_DELQDISC,RTM_GETQDISC
  • Traffic classes used with queues:RTM_NEWTCLASS,RTM_DELTCLASS,RTM_GETTCLASS
  • Traffic filters:RTM_NEWTFILTER,RTM_DELTFILTER,RTM_GETTFILTER
  • Others:RTM_NEWACTION,RTM_DELACTION,RTM_GETACTION,RTM_NEWPREFIX,RTM_GETPREFIX,RTM_GETMULTICAST,RTM_GETANYCAST,RTM_NEWNEIGHTBL,RTM_GETNEIGHTBL,RTM_SETNEIGHTBL
NETLINK_FIREWALL

NETLINK_FIREWALL provides an interface for a user-space app to receive packets from thefirewall.

NETLINK_NFLOG

NETLINK_NFLOG provides an interface used to communicate betweenNetfilter andiptables.

NETLINK_ARPD

NETLINK_ARPD provides an interface to manage theARP table from user-space.

NETLINK_AUDIT

NETLINK_AUDIT provides an interface to the audit subsystem found in Linux kernel versions 2.6.6 and later.

NETLINK_IP6_FW

NETLINK_IP6_FW provides an interface to transport packets from netfilter to user-space.

NETLINK_ROUTE6
NETLINK_TAPBASE
NETLINK_NETFILTER
NETLINK_TCPDIAG
NETLINK_XFRM

NETLINK_XFRM provides an interface to manage theIPsecsecurity association and security policy databases - mostly used by key-manager daemons using theInternet Key Exchange protocol.

NETLINK_KOBJECT_UEVENT

NETLINK_KOBJECT_UEVENT provides the interface in which the kernel broadcasts uevents, typically consumed byudev.

NETLINK_GENERIC

One of the drawbacks of the Netlink protocol is that the number of protocol families is limited to 32 (MAX_LINKS). This is one of the main reasons that the generic Netlink family was created—to provide support for adding a higher number of families. It acts as a Netlink multiplexer and works with a single Netlink familyNETLINK_GENERIC. The generic Netlink protocol is based on the Netlink protocol and uses its API.

User-defined Netlink protocol

[edit]

Users can add a Netlink handler in their own kernel routines. This allows the development of additional Netlink protocols to address new kernel modules.[6]

See also

[edit]

References

[edit]
  1. ^Linus Torvalds (8 February 2026)."Linux 6.19". Retrieved8 February 2026.
  2. ^ab"netlink: add netlink support".
  3. ^"netlink(7) - Linux manual page".man7.org.
  4. ^"kernel/git/torvalds/linux.git: root/net/core/rtnetlink.c".Linux kernel source tree.kernel.org. Retrieved2014-05-27.
  5. ^Crowcroft, Jon; Phillips, Iain, eds. (2002).TCP/IP and Linux protocol implementation: systems code for the Linux Internet. Wiley Networking Council series.Wiley. p. 624.ISBN 9780471408826. Retrieved2013-05-21.All rtnetlink messages consist of a netlink message header and appended attributes.
  6. ^"Kernel Korner - Why and How to Use Netlink Socket | Linux Journal".www.linuxjournal.com.

External links

[edit]
Methods
Protocols
andstandards
Software libraries
andframeworks
Organization
Kernel
Support
People
Technical
Debugging
Startup
ABIs
APIs
Kernel
System Call
Interface
In-kernel
Userspace
Daemons,
File systems
Wrapper
libraries
Components
Variants
Virtualization
Adoption
Range
of use
Adopters
Retrieved from "https://en.wikipedia.org/w/index.php?title=Netlink&oldid=1319725479"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp