]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
netlink: add netlink support
authorAlexander V. Chernikov <melifaro@FreeBSD.org>
Thu, 20 Jan 2022 21:39:21 +0000 (21:39 +0000)
committerAlexander V. Chernikov <melifaro@FreeBSD.org>
Mon, 23 Jan 2023 19:18:08 +0000 (19:18 +0000)
commit6bbfbaa6ae46f732603c2a23c7ece6dfe39c1e03
tree3b115b49574f3c19a65d93aa580f70db4c0f8a3c
parent68efb54328a5affac0fd68970dbb890ba024dc43
netlink: add netlink support

Netlinks is a communication protocol currently used in Linux kernel to modify,
 read and subscribe for nearly all networking state. Interfaces, addresses, routes,
 firewall, fibs, vnets, etc are controlled via netlink.
It is async, TLV-based protocol, providing 1-1 and 1-many communications.

The current implementation supports the subset of NETLINK_ROUTE
family. To be more specific, the following is supported:
* Dumps:
 - routes
 - nexthops / nexthop groups
 - interfaces
 - interface addresses
 - neighbors (arp/ndp)
* Notifications:
 - interface arrival/departure
 - interface address arrival/departure
 - route addition/deletion
* Modifications:
 - adding/deleting routes
 - adding/deleting nexthops/nexthops groups
 - adding/deleting neghbors
 - adding/deleting interfaces (basic support only)
* Rtsock interaction
 - route events are bridged both ways

The implementation also supports the NETLINK_GENERIC family framework.

Implementation notes:
Netlink is implemented via loadable/unloadable kernel module,
 not touching many kernel parts.
Each netlink socket uses dedicated taskqueue to support async operations
 that can sleep, such as interface creation. All message processing is
 performed within these taskqueues.

Compatibility:
Most of the Netlink data models specified above maps to FreeBSD concepts
 nicely. Unmodified ip(8) binary correctly works with
interfaces, addresses, routes, nexthops and nexthop groups. Some
software such as net/bird require header-only modifications to compile
and work with FreeBSD netlink.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D36002
MFC after: 2 months

(cherry picked from commit 7e5bf68495cc0a8c9793a338a8a02009a7f6dbb6)
34 files changed:
etc/mtree/BSD.include.dist
sys/modules/Makefile
sys/modules/netlink/Makefile [new file with mode: 0644]
sys/net/route.c
sys/net/route/route_ctl.h
sys/net/rtsock.c
sys/netlink/netlink.h [new file with mode: 0644]
sys/netlink/netlink_ctl.h [new file with mode: 0644]
sys/netlink/netlink_debug.h [new file with mode: 0644]
sys/netlink/netlink_domain.c [new file with mode: 0644]
sys/netlink/netlink_generic.c [new file with mode: 0644]
sys/netlink/netlink_generic.h [new file with mode: 0644]
sys/netlink/netlink_io.c [new file with mode: 0644]
sys/netlink/netlink_linux.h [new file with mode: 0644]
sys/netlink/netlink_message_parser.c [new file with mode: 0644]
sys/netlink/netlink_message_parser.h [new file with mode: 0644]
sys/netlink/netlink_message_writer.c [new file with mode: 0644]
sys/netlink/netlink_message_writer.h [new file with mode: 0644]
sys/netlink/netlink_module.c [new file with mode: 0644]
sys/netlink/netlink_route.c [new file with mode: 0644]
sys/netlink/netlink_route.h [new file with mode: 0644]
sys/netlink/netlink_var.h [new file with mode: 0644]
sys/netlink/route/common.h [new file with mode: 0644]
sys/netlink/route/iface.c [new file with mode: 0644]
sys/netlink/route/iface_drivers.c [new file with mode: 0644]
sys/netlink/route/ifaddrs.h [new file with mode: 0644]
sys/netlink/route/interface.h [new file with mode: 0644]
sys/netlink/route/neigh.c [new file with mode: 0644]
sys/netlink/route/neigh.h [new file with mode: 0644]
sys/netlink/route/nexthop.c [new file with mode: 0644]
sys/netlink/route/nexthop.h [new file with mode: 0644]
sys/netlink/route/route.c [new file with mode: 0644]
sys/netlink/route/route.h [new file with mode: 0644]
sys/netlink/route/route_var.h [new file with mode: 0644]