🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
2 messages
2 total messages Started by Kyuwon Cho Tue, 24 Nov 2026 13:04
[PATCH net] ipv6: keep the prefix route of an address with an infinite lifetime
#21782
Author: Kyuwon Cho
Date: Tue, 24 Nov 2026 13:04
76 lines
13571 bytes
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")
Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
---
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(+)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index d9d13e78bf13..b8d2c4cd28fe 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -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);
 		/*
-- 
2.43.0
Re: [PATCH net] ipv6: keep the prefix route of an address with an infinite lifetime
#24382
Author: patchwork-bot+netdevbpf
Date: Mon, 30 Nov 2026 03:50
26 lines
8783 bytes
Hello:

This patch was applied to netdev/net-next.git (main)
by Willem de Bruijn <willemb@google.com>:

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads