FreeBSD The Power to Serve

Contact: Alexander Chernikov <melifaro@FreeBSD.org>

Netlink is a communication protocol defined in RFC 3549. It is an async, TLV-based protocol, providing 1-1 and 1-many communications between kernel and userland. Netlink is currently used in the Linux kernel to modify, read and subscribe for nearly all networking states. Interface state, addresses, routes, firewall, rules, fibs, etc, are controlled via Netlink.

POSIX defines an API for base functions/system calls. There is no such standard for the plethora of protocol/device-level/subsystem-level ioctls. Each subsystem/driver invents its own protocol, handling format and compatibility. Extendability is a notable problem in the networking control plane. For example, it is extremely hard to add properties to the routing socket messages without breaking compatibility.

Netlink offers unification by providing a standard communication layer and basic easily-extendable message formatting. It can serve as a "broker", automatically combining requested data from different sources in a single request (example: interface state dump). Netlink APIs lower the bar for application developers to support FreeBSD, while providing the desired extendability.

Current status

Netlink has been committed to HEAD. The code implements a subset of the NETLINK_ROUTE subsystem and NETLINK_GENERIC framework.

NETLINK_ROUTE supports add/delete/replace operations for routes, nexthops and link-level addresses. Partial support exists for the interface addresses and interfaces.

Linuxulator support for Netlink has been committed to HEAD. It is possible to use the unmodified ip from iproute2 with routes, nexthops, addresses and interfaces.

The simple userland library, snl(3), that provides convenient abstractions on the netlink socket, has been committed to HEAD.

The first third-party software, BIRD, added experimental FreeBSD Netlink support.

Next steps

  • Add Netlink to GENERIC

  • Make netstat/route/arp/ndp/ifconfig use Netlink interfaces (help is appreciated)

  • Add FreeBSD Netlink support to ports of FreeRangeRouting (FRRouting (FRR)).


Last modified on: January 23, 2023 by Lorenzo Salvadore