Skip to contentSkip to conversation

ipv6: keep the prefix route of an address with an infinite lifetime

PATCH Applied Kyuwon Cho 3 participants 3 messages Nov 24 – Nov 30

Subsystems (3)
lore
Share & tools
lore

Kyuwon Cho

author
#0 lore raw

PATCH 1/1 ipv6: keep the prefix route of an address with an infinite lifetime

When an address is deleted or gets IFA_F_NOPREFIXROUTE, check_cleanup_prefix_route() keeps the prefix route alive as long as another address on the same prefix needs it. For an address that is not IFA_F_PERMANENT it sets the route to expire with that address:

	lifetime = addrconf_timeout_fixup(ifa->valid_lft, HZ);
	if (time_before(*expires, ifa->tstamp + lifetime * HZ))
		*expires = ifa->tstamp + lifetime * HZ;

An autoconfigured address whose valid lifetime a Router Advertisement set to infinity is not IFA_F_PERMANENT, and addrconf_timeout_fixup() returns ~0UL for it. lifetime * HZ then wraps, *expires stays at jiffies, and the prefix route is removed at the next garbage collection while the address remains valid.

Treat an address with an infinite valid lifetime like a permanent one.

Fixes 5b84efecb7d9 ("ipv6 addrconf: don't cleanup prefix route for IFA_F_NOPREFIXROUTE")

---
The issue was found by an LLM-guided test generator that we are developing as a research prototype. A reproducer, which runs as any user; ra.py sends one Router Advertisement for 2001:db8:1::/64 with an infinite valid lifetime:

$ cat ra.py
import socket, struct, sys
s = socket.socket(socket.AF_INET6, socket.SOCK_RAW, socket.IPPROTO_ICMPV6)
s.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_MULTICAST_HOPS, 255)
ra = struct.pack('!BBHBBHII', 134, 0, 0, 64, 0, 1800, 0, 0)
pi = struct.pack('!BBBBIII16s', 3, 4, 64, 0xc0, 0xffffffff, 1800, 0,
                 socket.inet_pton(socket.AF_INET6, '2001:db8:1::'))
s.sendto(ra + pi, ('ff02::1', 0, 0, socket.if_nametoindex(sys.argv[1])))
$ unshare -Urn sh -e <<'END'
ip link add va type veth peer name vb
ip link set va up
ip link set vb up
sleep 3
python3 ra.py vb
sleep 1
ip -6 addr add 2001:db8:1::5/64 dev va
ip -6 addr del 2001:db8:1::5/64 dev va
sleep 70
ip -6 addr show dev va scope global
ip -6 route show 2001:db8:1::/64 dev va
END

Without the patch, the SLAAC address is still "valid_lft forever", but the last command prints nothing: the prefix route is gone. With it, the route stays. Our test also sets IFA_F_NOPREFIXROUTE instead of deleting the address, with the same result, and checks that a finite lifetime still expires the route as before.

The patch was written with LLM assistance; we reviewed and tested it.

 net/ipv6/addrconf.c | 4 ++++
 1 file changed, 4 insertions(+)
net/ipv6/addrconf.c +4 -0
index d9d13e78bf13..b8d2c4cd28fe 100644
@@ -1269,6 +1269,10 @@ check_cleanup_prefix_route(struct inet6_ifaddr *ifp, unsigned long *expires)
 		action = CLEANUP_PREFIX_RT_EXPIRE;
 
 		spin_lock(&ifa->lock);
+		if (ifa->valid_lft == INFINITY_LIFE_TIME) {
+			spin_unlock(&ifa->lock);
+			return CLEANUP_PREFIX_RT_NOP;
+		}
 
 		lifetime = addrconf_timeout_fixup(ifa->valid_lft, HZ);
 		/*
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Kyuwon Cho

When an address is deleted or gets IFA_F_NOPREFIXROUTE, check_cleanup_prefix_route() keeps the prefix route alive as long as another address on the same prefix needs it. For an address that is not IFA_F_PERMANENT it sets the route to expire with that address:

	lifetime = addrconf_timeout_fixup(ifa->valid_lft, HZ);
	if (time_before(*expires, ifa->tstamp + lifetime * HZ))
		*expires = ifa->tstamp + lifetime * HZ;

An autoconfigured address whose valid lifetime a Router Advertisement set to infinity is not IFA_F_PERMANENT, and addrconf_timeout_fixup() returns ~0UL for it. lifetime * HZ then wraps, *expires stays at jiffies, and the prefix route is removed at the next garbage collection while the address remains valid.

Quoted 4 lines

Treat an address with an infinite valid lifetime like a permanent one.

Fixes 5b84efecb7d9 ("ipv6 addrconf: don't cleanup prefix route for IFA_F_NOPREFIXROUTE")

FWIW, this doesn't look very interesting and can be routed via net-next (no need to repost).

#2 lore raw
In reply to Kyuwon Cho
This patch was applied to netdev/net-next.git (main) by Willem de Bruijn <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Willem de Bruijn <[email protected]>:

Quoted 10 lines · On Tue, 24 Nov 2026 22:04:10 +0900 you wrote:

When an address is deleted or gets IFA_F_NOPREFIXROUTE, check_cleanup_prefix_route() keeps the prefix route alive as long as another address on the same prefix needs it. For an address that is not IFA_F_PERMANENT it sets the route to expire with that address:

	lifetime = addrconf_timeout_fixup(ifa->valid_lft, HZ);
	if (time_before(*expires, ifa->tstamp + lifetime * HZ))
		*expires = ifa->tstamp + lifetime * HZ;

[...]

Here is the summary with links:
- [net] ipv6: keep the prefix route of an address with an infinite lifetime

    https://git.kernel.org/netdev/net-next/c/71fd3a0dd8ec

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html