Skip to content

net: Allow changing IPv4 address protocol

Petr Machata netdev 1 version Applied

Status from this message: This series was applied to netdev/net-next.git (main)

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 2 repliesApplied 3/3

Patches in v1 All 3 applied

#Subject and filesSizeRepliesApplied
1/3net: ipv4: Allow changing IPv4 address protocolnet/ipv4/devinet.c+3 -01 replyApplied
2/3selftests: rtnetlink: Make the set of tests to run configurabletools/testing/selftests/net/rtnetlink.sh+48 -420 repliesApplied
3/3selftests: rtnetlink: Add an address proto testtools/testing/selftests/net/rtnetlink.sh+91 -01 replyApplied

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchIdo SchimmelDavid Ahern
1/3R-b R-b
2/3R-b
3/3R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH net-next 0/3] net: Allow changing IPv4 address protocol

IPv4 and IPv6 addresses can be assigned a protocol value that indicates the provenance of the IP address. The attribute is modeled after ip route protocols, and essentially allows the administrator or userspace stack to tag addresses in some way that makes sense to the actor in question.

When IP address protocol field was added in commit 47f0bd503210 ("net: Add new protocol attribute to IP addresses"), the semantics included the ability to change the protocol for IPv6 addresses, but not for IPv4 addresses. It seems this was not deliberate, but rather by accident.

One particular use case is tagging the addresses differently depending on whether the routing stack should advertise them or not. Without support for protocol replacement, this can not be done.

In this patchset, extend IPv4 to allow changing the protocol defined at an address (in patch #1). Then in patches #2 and #3 add selftest coverage for ip address protocols.

Currently the kernel simply ignores the new value. Thus allowing the replacement changes the observable behavior. However, since IPv6 already behaves like this anyway, and since the feature as such is relatively new, it seems like the change is safe to make.

An example session with the feature in action:

	bash-5.2# ip address add dev d 192.0.2.1/28 proto 0xab
	bash-5.2# ip address show dev d
	4: d: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
	    link/ether 06:29:74:fd:1f:eb brd ff:ff:ff:ff:ff:ff
	    inet 192.0.2.1/28 scope global proto 0xab d
	       valid_lft forever preferred_lft forever

	bash-5.2# ip address replace dev d 192.0.2.1/28 proto 0x11
	bash-5.2# ip address show dev d
	4: d: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
	    link/ether 06:29:74:fd:1f:eb brd ff:ff:ff:ff:ff:ff
	    inet 192.0.2.1/28 scope global proto 0x11 d
	       valid_lft forever preferred_lft forever

Petr Machata (3):
net: ipv4: Allow changing IPv4 address protocol
selftests: rtnetlink: Make the set of tests to run configurable
selftests: rtnetlink: Add an address proto test

 net/ipv4/devinet.c                       |   3 +
 tools/testing/selftests/net/rtnetlink.sh | 181 +++++++++++++++++------
 2 files changed, 142 insertions(+), 42 deletions(-)
Signature · 1 line
2.39.0