Generated by GPT-5-mini| libnl | |
|---|---|
| Name | libnl |
| Title | libnl |
| Developer | Olivier Beaumont; contributors from Netfilter and Linux Kernel Mailing List |
| Released | 2003 |
| Latest release | 3.x series |
| Programming language | C (programming language) |
| Operating system | Linux kernel-based systems |
| Genre | Application programming interface |
| License | GNU Lesser General Public License |
libnl is a userspace library implementing the netlink protocol family for interaction with the Linux kernel networking stack. It provides a C-language API for constructing, parsing, and transmitting netlink messages to kernel subsystems such as netfilter, iproute2 components and NetworkManager. libnl is widely used in projects that require programmatic control of kernel networking facilities including systemd, ConnMan, and various distributions' network daemons.
libnl acts as a bridge between userspace applications and kernel services by encapsulating the Netlink (networking) socket semantics and message formats. It abstracts low-level details of the netlink families used by kernel subsystems such as nl80211 for wireless, rtnetlink for routing and link configuration, and netfilter for packet filtering. The library aims to simplify tasks performed by tools like iproute2 and iw and to serve as a foundation for daemons such as NetworkManager and systemd-networkd.
The library is organized into modular components corresponding to netlink families and helper layers. Core modules include the socket handling layer, message buffering, attribute parsing, and sequence/acknowledgement management, designed to interoperate with kernel subsystems like Traffic Control (tc), XFRM (IPsec), and conntrack. Components expose data structures mirroring kernel kernel headers such as if_link, rtnl_link, and genlmsghdr. The design separates generic netlink operations—used by nl80211 and cfg80211—from family-specific code, enabling reuse across projects like wpa_supplicant and hostapd. Ancillary utilities include asynchronous event loops adaptable to frameworks such as libevent and glib.
libnl provides synchronous and asynchronous APIs in C (programming language), with bindings available in higher-level languages through projects affiliated with GNOME and KDE. Typical usage involves creating a netlink socket, resolving the family identifier (for example via genl_ctrl commands), constructing messages with nested attributes, and sending requests that expect multipart responses similar to those produced by ip (Linux utility). The API exposes helpers for attribute policy validation, multicast group subscription for events emitted by udev-like systems, and error/ack handling compatible with POSIX conventions. Examples of invocation patterns appear in client code for NetworkManager, systemd-networkd, and utilities distributed with iproute2.
libnl supports multiple netlink families and kernel protocols, including rtnetlink for routing, netlink route, netfilter/nfnetlink for firewall and packet filtering, nl80211 for wireless configuration, genetlink for generic netlink families, and xfrm for IPsec. Feature-wise, it handles multipart messages, attribute nesting used by 802.11 and IEEE 802.1Q, multicast groups for kernel events, and sequence-ack models required by conntrack and tc operations. The library also implements utilities for TC classifier, qdisc, and filter manipulation compatible with the Traffic Control subsystem and integrates with kernel facilities used by Open vSwitch and Docker networking stacks.
The project originated in the early 2000s to support growing netlink usage in tools such as iproute2 and early wireless-tools replacements. Major milestones include the introduction of a stable 1.x API, a subsequent 3.x rework addressing API clarity and thread safety, and ongoing maintenance driven by contributions from communities around Debian, Ubuntu, and the Linux Kernel Mailing List. Releases have tracked kernel netlink advancements, adding support for families introduced in kernel versions associated with work from teams at Intel, Broadcom, and Qualcomm. The codebase is maintained in public version control with collaboration patterns similar to those of Git-hosted projects and follows licensing compatible with GPL ecosystem software.
libnl is used in a broad array of open-source projects and vendor products. Notable adopters include NetworkManager, systemd, ConnMan, wpa_supplicant, hostapd, Open vSwitch, and container networking stacks in Docker and Kubernetes environments. Distributions such as Debian, Fedora, Arch Linux, and Ubuntu package libnl for consumption by networking tools and daemons. Commercial networking products from vendors such as Cisco Systems, Juniper Networks, and Arista Networks that run on Linux-based platforms often depend on libnl indirectly via upstream utilities. Implementations and bindings have been created for higher-level environments including GNOME network applets and KDE networking modules, facilitating integration across desktop and server ecosystems.
Category:Computer libraries