mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-21 04:53:46 -04:00
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:
9a6ea18bd7
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>
This commit is contained in:
committed by
Jakub Kicinski
parent
6e2e59eaee
commit
47f0bd5032
@@ -33,8 +33,9 @@ enum {
|
||||
IFA_CACHEINFO,
|
||||
IFA_MULTICAST,
|
||||
IFA_FLAGS,
|
||||
IFA_RT_PRIORITY, /* u32, priority/metric for prefix route */
|
||||
IFA_RT_PRIORITY, /* u32, priority/metric for prefix route */
|
||||
IFA_TARGET_NETNSID,
|
||||
IFA_PROTO, /* u8, address protocol */
|
||||
__IFA_MAX,
|
||||
};
|
||||
|
||||
@@ -69,4 +70,10 @@ struct ifa_cacheinfo {
|
||||
#define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))
|
||||
#endif
|
||||
|
||||
/* ifa_proto */
|
||||
#define IFAPROT_UNSPEC 0
|
||||
#define IFAPROT_KERNEL_LO 1 /* loopback */
|
||||
#define IFAPROT_KERNEL_RA 2 /* set by kernel from router announcement */
|
||||
#define IFAPROT_KERNEL_LL 3 /* link-local set by kernel */
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user