]> git.baikalelectronics.ru Git - kernel.git/commit
net: Add new protocol attribute to IP addresses
authorJacques de Laval <Jacques.De.Laval@westermo.com>
Thu, 17 Feb 2022 15:02:02 +0000 (16:02 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sat, 19 Feb 2022 05:20:06 +0000 (21:20 -0800)
commit7f72bd7c4fe0f9942330fa2e0cf7fedcd74a7c82
treec2f27dd7b1072733b0abd260e4104870bc9ac365
parentba505c544343fd6ec06717fc3e35227edec97415
net: Add new protocol attribute to IP addresses

This patch adds a new protocol attribute to IPv4 and IPv6 addresses.
Inspiration was taken from the protocol attribute of routes. User space
applications like iproute2 can set/get the protocol with the Netlink API.

The attribute is stored as an 8-bit unsigned integer.

The protocol attribute is set by kernel for these categories:

- IPv4 and IPv6 loopback addresses
- IPv6 addresses generated from router announcements
- IPv6 link local addresses

User space may pass custom protocols, not defined by the kernel.

Grouping addresses on their origin is useful in scenarios where you want
to distinguish between addresses based on who added them, e.g. kernel
vs. user space.

Tagging addresses with a string label is an existing feature that could be
used as a solution. Unfortunately the max length of a label is
15 characters, and for compatibility reasons the label must be prefixed
with the name of the device followed by a colon. Since device names also
have a max length of 15 characters, only -1 characters is guaranteed to be
available for any origin tag, which is not that much.

A reference implementation of user space setting and getting protocols
is available for iproute2:

https://github.com/westermo/iproute2/commit/9a6ea18bd79f47f293e5edc7780f315ea42ff540

Signed-off-by: Jacques de Laval <Jacques.De.Laval@westermo.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20220217150202.80802-1-Jacques.De.Laval@westermo.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/inetdevice.h
include/net/addrconf.h
include/net/if_inet6.h
include/uapi/linux/if_addr.h
net/ipv4/devinet.c
net/ipv6/addrconf.c