History log of /freebsd-current/sys/netlink/netlink_message_parser.h
Revision Date Author Comments
# dfed87b5 26-Feb-2024 Kristof Provost <kp@FreeBSD.org>

netlink: add bool type support

Reviewed by: melifaro
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D44089


# f92d9b1a 28-Nov-2023 Kristof Provost <kp@FreeBSD.org>

pflow: import from OpenBSD

pflow is a pseudo device to export flow accounting data over UDP.
It's compatible with netflow version 5 and IPFIX (10).

The data is extracted from the pf state table. States are exported once
they are removed.

Reviewed by: melifaro
Obtained from: OpenBSD
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D43106


# fad57349 14-Oct-2023 Kristof Provost <kp@FreeBSD.org>

netlink: descend into nested parsers when verifying

When we verify that the attributes are correctly sorted we should also
try to verify the nested attribute parsers.

Reviewed by: melifaro
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D42222


# 1c5c7e61 13-Oct-2023 Kristof Provost <kp@FreeBSD.org>

netlink: add attr parser utility functions

- nlattr_get_chara() to read a string into a char array, rather than to a char *
- nlattr_get_bytes() to read an arbitrary (fixed length) byte sequence
- nlattr_get_nested_ptr() to read a nested type to a struct foo *, rather than struct foo

Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D42221


# 9795f14e 10-Aug-2023 John Baldwin <jhb@FreeBSD.org>

netlink: Align allocations on __max_align_t, not uint64_t.

uint64_t is not sufficient alignment for allocators on all platforms.
On a CHERI platform pointers require 16 byte alignment, but also if a
type contained a uint128_t or long double it would not be aligned
correctly either. C11 added max_align_t precisely to provide a
portable type for allocators to use.

Reviewed by: melifaro
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D41301


# 3f6bf6a0 15-May-2023 Alexander V. Chernikov <melifaro@FreeBSD.org>

netlink: add an optional post-process hook to the message parsers.

It is primarily used for adding scopeid to the IPv6 link-local
sockaddrs. Having proper sockaddrs after parsing minimises the
possibility of human mistake when using the parsing.

MFC after: 2 weeks


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 70810dc8 25-Apr-2023 Alexander V. Chernikov <melifaro@FreeBSD.org>

netlink: add nlattr_get_uint8() function to pack u8 attributes.

MFC after: 2 weeks


# 13781800 15-Mar-2023 Kristof Provost <kp@FreeBSD.org>

carp: support unicast

Allow users to configure the address to send carp messages to. This
allows carp to be used in unicast mode, which is useful in certain
virtual configurations (e.g. AWS, VMWare ESXi, ...)

Reviewed by: melifaro
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D38940


# 25c2dd2f 09-Feb-2023 Alexander V. Chernikov <melifaro@FreeBSD.org>

netlink: return optional metadata with the operation result.

Some operations like interface creation may need to return metadata
- in this case, interface name - back to the caller if the operation
is successful.
This change implements attaching an `NLMSGERR_ATTR_COOKIE` nla to the
operation reply message via `nlmsg_report_cookie()`.
Additionally, on successful interface creation, interface index and
interface name are returned in the `IFLA_NEW_IFINDEX` and `IFLA_IFNAME
TLVs, encapsulated in the `NLMSGERR_ATTR_COOKIE`.

Reviewed By: pauamma
Differential Revision: https://reviews.freebsd.org/D38283
MFC after: 1 week


# 10f2a387 21-Jan-2023 Alexander V. Chernikov <melifaro@FreeBSD.org>

netlink: fix OOB write when creating attribute bitmask.

Fix wrong arithmetics by moving to the standard bitset(9) functions.

Reported by: markj, KASAN


# 228c632a 15-Jan-2023 Alexander V. Chernikov <melifaro@FreeBSD.org>

netlink: fix compatibility with older netlink applications.

Some apps try to provide only the non-zero part of the required message
header instead of the full one. It happens when fetching routes or
interface addresses, where the first header byte is the family.
This behavior is "illegal" under the "strict" Netlink socket option,
however there are many applications out there doing things in the
"old" way.

Support this usecase by copying the provided bytes into the temporary
zero-filled header and running the parser on this header instead.

Reported by: Goran Mekić <meka@tilda.center>


# 80f03e63 14-Dec-2022 Alexander V. Chernikov <melifaro@FreeBSD.org>

netlink: improve interface handling

* Separate interface creation from interface modification code
* Support setting some interface attributes (ifdescr, mtu, up/down, promisc)
* Improve interaction with the cloners requiring to parse/write custom
interface attributes
* Add bitmask-based way of checking if the attribute is present in the
message
* Don't use multipart RTM_GETLINK replies when searching for the
specific interface names
* Use ENODEV instead of ENOENT in case of failed RTM_GETLINK search
* Add python netlink test helpers
* Add some netlink interface tests

Differential Revision: https://reviews.freebsd.org/D37668


# 03994c24 01-Oct-2022 Alexander V. Chernikov <melifaro@FreeBSD.org>

netlink: fix build without INVARIANTS

Reported by: cy


# dddafa8d 01-Oct-2022 Alexander V. Chernikov <melifaro@FreeBSD.org>

netlink: make test-includes happy by hiding most of the header
contents under _KERNEL.


# 7e5bf684 20-Jan-2022 Alexander V. Chernikov <melifaro@FreeBSD.org>

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