Netdev List
 help / color / mirror / Atom feed
From: Kyuwon Cho <kyuwoncho18@gmail.com>
To: David Ahern <dsahern@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Ido Schimmel <idosch@nvidia.com>,
	Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>,
	Thomas Haller <thaller@redhat.com>,
	netdev@vger.kernel.org
Subject: [PATCH net] ipv6: keep the prefix route of an address with an infinite lifetime
Date: Tue, 24 Nov 2026 22:04:10 +0900	[thread overview]
Message-ID: <179552079832.1290967.7922979459179290523@gmail.com> (raw)

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


                 reply	other threads:[~2026-11-24 13:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179552079832.1290967.7922979459179290523@gmail.com \
    --to=kyuwoncho18@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=thaller@redhat.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox