ipv6: addrconf: fix temp address generation after prefix deprecation
Subsystems (4)
PATCH v4 1/2 ipv6: addrconf: fix temp address generation after prefix deprecation
When a router temporarily deprecates an IPv6 prefix (either by sending a Router Advertisement with Preferred Lifetime = 0 or by letting the lifetime expire) and later restores it, the kernel permanently loses its ability to generate temporary privacy addresses (RFC 8981) for that prefix.
This happens because the address worker attempts to generate a replacement temporary address when the current one nears expiration. As the base prefix is deprecated already, the generation fails after marking the temporary address as already having spawned a replacement (ifp->regen_count++).
When the router eventually restores the prefix, the temporary address becomes active again. However, once it naturally expires, the address worker sees this temporary address already tried to generate one and skips the regeneration.
Fix this by checking if all temporary addresses for a given prefix have already tried to spawn a replacement when processing a new RA. If so, spawn a new temporary address.
---
v2: adjusted commit message, adjusted the implementation to cover all race conditions
v3: regen now if ipv6_create_tempaddr failed due to timer to avoid an infinite loop as we restart the loop and we need to check now against prefered_lft again.
v4: change the proposed fix completely, now we address the problem when doing manage_tempaddrs().
--- net/ipv6/addrconf.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
net/ipv6/addrconf.c +8 -3
@@ -2595,8 +2595,9 @@ static void manage_tempaddrs(struct inet6_dev *idev, __u32 valid_lft, __u32 prefered_lft, bool create, unsigned long now) { - u32 flags; struct inet6_ifaddr *ift; +bool all_regen = true; +u32 flags;read_lock_bh (&idev->lock);/* update all temporary addresses in the list */
@@ -2637,6 +2638,8 @@ static void manage_tempaddrs(struct inet6_dev *idev, ift->tstamp = now;if (prefered_lft >0 ) ift->flags &= ~IFA_F_DEPRECATED ; +if (!ift->regen_count) + all_regen = false;spin_unlock (&ift->lock);if (!(flags&IFA_F_TENTATIVE ))
@@ -2644,12 +2647,14 @@ static void manage_tempaddrs(struct inet6_dev *idev, }/* Also create a temporary address if it's enabled but no temporary -* address currently exists. +* address currently exists or if all temporary addresses already +* generated an address. * However, we get called with valid_lft == 0, prefered_lft == 0, create == false * as part of cleanup (ie. deleting the mngtmpaddr). * We don't want that to result in creating a new temporary ip address. */ -if (list_empty (&idev->tempaddr_list) && (valid_lft || prefered_lft)) +if ((list_empty (&idev->tempaddr_list) || all_regen) && + (valid_lft || prefered_lft)) create = true;if (create &&READ_ONCE (idev->cnf.use_tempaddr) >0 ) {
Signature · 1 line
2.53.0
PATCH v4 2/2 selftests: fib_tests: add temporary IPv6 address renewal test
Add a test to check that temporary IPv6 address is regenerated properly after the base prefix is deprecated and restored.
Fib6 temporary address renewal test
TEST: IPv6 temporary address cleanly deprecated and regenerated [ OK ]
---
v2: adjusted the sleep so there is enough time for the issue to trigger, added cleanup at the end
v3: no changes
v4: no changes
--- tools/testing/selftests/net/fib_tests.sh | 59 +++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-)
tools/testing/selftests/net/fib_tests.sh +58 -1
@@ -12,7 +12,7 @@ TESTS="unregister down carrier nexthop suppress ipv6_notify ipv4_notify \ ipv4_route_metrics ipv4_route_v6_gw rp_filter ipv4_del_addr \ ipv6_del_addr ipv4_mangle ipv6_mangle ipv4_bcast_neigh fib6_gc_test \ ipv4_mpath_list ipv6_mpath_list ipv4_mpath_balance ipv6_mpath_balance \ - ipv4_mpath_balance_preferred fib6_ra_to_static" + ipv4_mpath_balance_preferred fib6_ra_to_static fib6_temp_addr_renewal" VERBOSE=0 PAUSE_ON_FAIL=no
@@ -1611,6 +1611,62 @@ fib6_ra_to_static() cleanup &> /dev/null } +fib6_temp_addr_renewal() { + setup + + echo + echo "Fib6 temporary address renewal test" + set -e + + # ra6 is required for the test. (ipv6toolkit) + if [ ! -x "$(command -v ra6)" ]; then + echo "SKIP: ra6 not found." + set +e + cleanup &> /dev/null + return + fi + + # Create a pair of veth devices to send a RA message from one + # device to another. + $IP link add veth1 type veth peer name veth2 + $IP link set dev veth1 up + $IP link set dev veth2 up + + # Make veth1 ready to receive RA messages. + $NS_EXEC sysctl -wq net.ipv6.conf.veth1.accept_ra=2 + $NS_EXEC sysctl -wq net.ipv6.conf.veth1.use_tempaddr=2 + $NS_EXEC sysctl -wq net.ipv6.conf.veth1.temp_prefered_lft=15 + $NS_EXEC sysctl -wq net.ipv6.conf.veth1.max_desync_factor=0 + + # Send a RA message with a prefix from veth2. + $NS_EXEC ra6 -i veth2 -s fe80::1 -d ff02::1 -P 2001:12::/64\#LA\#3600\#3600 -e + sleep 3 + + # Deprecate it + $NS_EXEC ra6 -i veth2 -s fe80::1 -d ff02::1 -P 2001:12::/64\#LA\#3600\#0 -e + sleep 3 + + # Restore it + $NS_EXEC ra6 -i veth2 -s fe80::1 -d ff02::1 -P 2001:12::/64\#LA\#3600\#3600 -e + + ret=1 + for i in $(seq 1 25); do + sleep 1 + num_dep="$($IP -6 addr | grep -c "temporary deprecated" || true)" + num_tot="$($IP -6 addr | grep -c "temporary" || true)" + + if [ "$num_dep" -eq 1 ] && [ "$num_tot" -ge 2 ]; then + ret=0 + break + fi + done + log_test "$ret" 0 "IPv6 temporary address cleanly deprecated and regenerated" + + set +e + + cleanup &> /dev/null +} + # add route for a prefix, flushing any existing routes first # expected to be the first step of a test add_route()
@@ -3002,6 +3058,7 @@ do ipv6_mpath_balance) ipv6_mpath_balance_test;; ipv4_mpath_balance_preferred) ipv4_mpath_balance_preferred_test;; fib6_ra_to_static) fib6_ra_to_static;; + fib6_temp_addr_renewal) fib6_temp_addr_renewal;; help) echo "Test names: $TESTS"; exit 0;; esac
Signature · 1 line
2.53.0
Re: [PATCH 2/2 net v4] selftests: fib_tests: add temporary IPv6 address renewal test
Quoted 37 lines · Fernando Fernandez Mancera
Add a test to check that temporary IPv6 address is regenerated properly after the base prefix is deprecated and restored.
Fib6 temporary address renewal test
TEST: IPv6 temporary address cleanly deprecated and regenerated [ OK ]Signed-off-by Fernando Fernandez Mancera <[email protected]>---
v2: adjusted the sleep so there is enough time for the issue to trigger, added cleanup at the end
v3: no changes
v4: no changes--- tools/testing/selftests/net/fib_tests.sh | 59 +++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-)tools/testing/selftests/net/fib_tests.sh +5
-1@@ -12,7 +12,7 @@ TESTS="unregister down carrier nexthop suppress ipv6_notify ipv4_notify \ ipv4_route_metrics ipv4_route_v6_gw rp_filter ipv4_del_addr \ ipv6_del_addr ipv4_mangle ipv6_mangle ipv4_bcast_neigh fib6_gc_test \ ipv4_mpath_list ipv6_mpath_list ipv4_mpath_balance ipv6_mpath_balance \ - ipv4_mpath_balance_preferred fib6_ra_to_static" + ipv4_mpath_balance_preferred fib6_ra_to_static fib6_temp_addr_renewal" VERBOSE=0 PAUSE_ON_FAIL=no@@ -1611,6 +1611,62 @@ fib6_ra_to_static() cleanup &> /dev/null } +fib6_temp_addr_renewal() { + setup + + echo
tools/testing/selftests/net/fib_tests.sh fib6_ra_to_static() · line 1627
Quoted 10 lines
tools/testing/selftests/net/fib_tests.sh +10
-0+ echo "Fib6 temporary address renewal test" + set -e + + # ra6 is required for the test. (ipv6toolkit) + if [ ! -x "$(command -v ra6)" ]; then + echo "SKIP: ra6 not found." + set +e + cleanup &> /dev/null + return + fi
Should you check for ra6 before the "setup" above?
Also, kselftest convention is to exit with $ksft_skip (4) rather than just return so that the framework reports SKIP rather than PASS with 0 tests.
A bare return here will make the test silently disappear from CI on hosts without ipv6toolkit.
Jakub Kicinski
maintainerRe: [PATCH 2/2 net v4] selftests: fib_tests: add temporary IPv6 address renewal test
Quoted 1 line · On Mon, 11 May 2026 10:01:00 -0700 Breno Leitao wrote:
Should you check for ra6 before the "setup" above?
Not really. AI bots love to complain about this. But "ra6 command not found" is as good of a message as the explicit skip, honestly. And we don't want writing tests to be too burdensome.
Re: [PATCH 2/2 net v4] selftests: fib_tests: add temporary IPv6 address renewal test
Quoted 5 lines · Jakub Kicinski
Quoted 1 line · On Mon, 11 May 2026 10:01:00 -0700 Breno Leitao wrote:
Should you check for ra6 before the "setup" above?
Not really. AI bots love to complain about this. But "ra6 command not found" is as good of a message as the explicit skip, honestly.
Right, but why call setup() before checking if ra6 is available?
Running setup() performs unnecessary work if the test will be skipped anyway. It would be cleaner to:
1) Check for required tools (ra6) and skip early if missing
2) Run setup() to create namespace and configure the environment
3) Proceed with the test
Rather than:
1) Run setup() to configure namespace and network interfaces
2) Check for tool availability
3) Clean up when tools are missing
If you look at netcons_basic.sh for instance, it has the following lines, which seems saner:
# Check for basic system dependency and exit if not found check_for_dependencies
# Remove the namespace, interfaces and netconsole target on exit trap cleanup EXIT
<Do the test>
Jakub Kicinski
maintainerRe: [PATCH 2/2 net v4] selftests: fib_tests: add temporary IPv6 address renewal test
Quoted 8 lines · On Tue, 12 May 2026 01:08:15 -0700 Breno Leitao wrote:
Quoted 5 lines · Jakub Kicinski
Quoted 1 line · On Mon, 11 May 2026 10:01:00 -0700 Breno Leitao wrote:
Should you check for ra6 before the "setup" above?
Not really. AI bots love to complain about this. But "ra6 command not found" is as good of a message as the explicit skip, honestly.
Right, but why call
setup()before checking if ra6 is available?
You cut off the sentence from my response which told you why.
Checking dependencies is not a priority for our tests.
Re: [PATCH 2/2 net v4] selftests: fib_tests: add temporary IPv6 address renewal test
Quoted 5 lines · Jakub Kicinski
Quoted 4 lines · On Tue, 12 May 2026 01:08:15 -0700 Breno Leitao wrote:
Quoted 3 lines · Jakub Kicinski
Quoted 1 line · On Mon, 11 May 2026 10:01:00 -0700 Breno Leitao wrote:
Should you check for ra6 before the "setup" above?
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Not really. AI bots love to complain about this. But "ra6 command not found" is as good of a message as the explicit skip, honestly.
Right, but why call
setup()before checking if ra6 is available?You cut off the sentence from my response which told you why.
Checking dependencies is not a priority for our tests.
Ack. Notes taken, sorry for the noise,
--breno
Quoted 26 lines · Fernando Fernandez Mancera
When a router temporarily deprecates an IPv6 prefix (either by sending a Router Advertisement with Preferred Lifetime = 0 or by letting the lifetime expire) and later restores it, the kernel permanently loses its ability to generate temporary privacy addresses (RFC 8981) for that prefix.
This happens because the address worker attempts to generate a replacement temporary address when the current one nears expiration. As the base prefix is deprecated already, the generation fails after marking the temporary address as already having spawned a replacement (ifp->regen_count++).
When the router eventually restores the prefix, the temporary address becomes active again. However, once it naturally expires, the address worker sees this temporary address already tried to generate one and skips the regeneration.
Fix this by checking if all temporary addresses for a given prefix have already tried to spawn a replacement when processing a new RA. If so, spawn a new temporary address.
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Reported-by Łukasz Stelmach <[email protected]>Suggested-by Ido Schimmel <[email protected]>Signed-off-by Fernando Fernandez Mancera <[email protected]>
Quoted 9 lines
---
v2: adjusted commit message, adjusted the implementation to cover all race conditions
v3: regen now ifipv6_create_tempaddrfailed due to timer to avoid an infinite loop as we restart the loop and we need to check now againstprefered_lftagain.
v4: change the proposed fix completely, now we address the problem when doingmanage_tempaddrs().
---
Sashiko feedback [1] is right about the DoS, that is a router that sends multiple 0-lft RA until it exhausts all spawn attempts, leaving temporary addresses disabled on the system.
About the leaked address, I do not think the feedback is right. If an ifp does not have any ift, it means something went wrong most likely. Either this address was removed manually (any RA would restore it, even with previous implementation) or for some reason that prefix didn't get an RA but we didn't try to generate one and we MUST do it.
I think we can cover it by avoiding to attempt create a new temporary address for a 0-lft RA, it makes sense to me. Something like this:
net/ipv6/addrconf.c +1 -1
@@ -2654,7 +2654,7 @@ static void manage_tempaddrs(struct inet6_dev *idev,* We don't want that to result in creating a new temporary ip address. */ if ((list_empty (&idev->tempaddr_list) || all_regen) && - (valid_lft || prefered_lft)) + (valid_lft && prefered_lft)) create = true;if (create &&READ_ONCE (idev->cnf.use_tempaddr) >0 ) {
Any thoughts?
[1] https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260511122645.6233-2-fmancera%40suse.de
Quoted 44 lines
net/ipv6/addrconf.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)net/ipv6/addrconf.c +8
-3@@ -2595,8 +2595,9 @@ static void manage_tempaddrs(struct inet6_dev *idev, __u32 valid_lft, __u32 prefered_lft, bool create, unsigned long now) { - u32 flags; struct inet6_ifaddr *ift; +bool all_regen = true; +u32 flags;read_lock_bh (&idev->lock);/* update all temporary addresses in the list */ @@ -2637,6 +2638,8 @@ static void manage_tempaddrs(struct inet6_dev *idev, ift->tstamp = now;if (prefered_lft >0 ) ift->flags &= ~IFA_F_DEPRECATED ; +if (!ift->regen_count) + all_regen = false;spin_unlock (&ift->lock);if (!(flags&IFA_F_TENTATIVE ))@@ -2644,12 +2647,14 @@ static void manage_tempaddrs(struct inet6_dev *idev, }/* Also create a temporary address if it's enabled but no temporary -* address currently exists. +* address currently exists or if all temporary addresses already +* generated an address. * However, we get called with valid_lft == 0, prefered_lft == 0, create == false * as part of cleanup (ie. deleting the mngtmpaddr). * We don't want that to result in creating a new temporary ip address. */ -if (list_empty (&idev->tempaddr_list) && (valid_lft || prefered_lft)) +if ((list_empty (&idev->tempaddr_list) || all_regen) && + (valid_lft || prefered_lft)) create = true;if (create &&READ_ONCE (idev->cnf.use_tempaddr) >0 ) {
Ido Schimmel
maintainerQuoted 27 lines · Fernando Fernandez Mancera
Sashiko feedback [1] is right about the DoS, that is a router that sends multiple 0-lft RA until it exhausts all spawn attempts, leaving temporary addresses disabled on the system.
About the leaked address, I do not think the feedback is right. If an ifp does not have any ift, it means something went wrong most likely. Either this address was removed manually (any RA would restore it, even with previous implementation) or for some reason that prefix didn't get an RA but we didn't try to generate one and we MUST do it.
I think we can cover it by avoiding to attempt create a new temporary address for a 0-lft RA, it makes sense to me. Something like this:
net/ipv6/addrconf.c +1
-1@@ -2654,7 +2654,7 @@ static void manage_tempaddrs(struct inet6_dev *idev,* We don't want that to result in creating a new temporary ip address. */ if ((list_empty (&idev->tempaddr_list) || all_regen) && - (valid_lft || prefered_lft)) + (valid_lft && prefered_lft)) create = true;if (create &&READ_ONCE (idev->cnf.use_tempaddr) >0 ) {
Quoted 1 line
Any thoughts?
This still leaves the case of RAs that alternate between prefered_lft > 0 and prefered_lft == 0. It will cause the kernel to create an unbounded amount of temporary addresses.
I think that a better fix would be to reset the regeneration counter of the newest temporary address whenever the associated public address becomes preferred. Something like [1].
If the newest temporary address has yet to spawn a new address, then its regeneration counter is 0 and nothing changes. However, if it was incremented and no new address was created, then this patch will reset its regeneration counter to reflect that. Before expiring, addrconf_verify_rtnl() will notice that this address has yet to spawn a new address and call ipv6_create_tempaddr().
The case of constant RAs with prefered_lft == 0 is not an issue because we only reset the regeneration counter when prefered_lft > 0.
Alternating RAs are also not an issue because we don't call ipv6_create_tempaddr() immediately and instead let addrconf_verify_rtnl() handle it when the address is about to expire.
[1]
net/ipv6/addrconf.c +11 -1
@@ -2595,8 +2595,9 @@ static void manage_tempaddrs(struct inet6_dev *idev, __u32 valid_lft, __u32 prefered_lft, bool create, unsigned long now) { + struct inet6_ifaddr *ift, *newest_ift = NULL; +u32 orig_prefered_lft = prefered_lft;u32 flags; -struct inet6_ifaddr *ift;read_lock_bh (&idev->lock);/* update all temporary addresses in the list */
@@ -2606,6 +2607,9 @@ static void manage_tempaddrs(struct inet6_dev *idev,if (ifp != ift->ifpub)continue ; +if (!newest_ift ||time_after (ift->cstamp, newest_ift->cstamp)) + newest_ift = ift; +/* RFC 4941 section 3.3: * If a received option will extend the lifetime of a public * address, the lifetimes of temporary addresses should
@@ -2643,6 +2647,12 @@ static void manage_tempaddrs(struct inet6_dev *idev,ipv6_ifa_notify (0 , ift); } +if (newest_ift && orig_prefered_lft >0 ) { +spin_lock (&newest_ift->lock); + newest_ift->regen_count =0 ; +spin_unlock (&newest_ift->lock); + } +/* Also create a temporary address if it's enabled but no temporary * address currently exists. * However, we get called with valid_lft == 0, prefered_lft == 0, create == false
Quoted 45 lines · Ido Schimmel
Quoted 27 lines · Fernando Fernandez Mancera
Sashiko feedback [1] is right about the DoS, that is a router that sends multiple 0-lft RA until it exhausts all spawn attempts, leaving temporary addresses disabled on the system.
About the leaked address, I do not think the feedback is right. If an ifp does not have any ift, it means something went wrong most likely. Either this address was removed manually (any RA would restore it, even with previous implementation) or for some reason that prefix didn't get an RA but we didn't try to generate one and we MUST do it.
I think we can cover it by avoiding to attempt create a new temporary address for a 0-lft RA, it makes sense to me. Something like this:
net/ipv6/addrconf.c +1
-1@@ -2654,7 +2654,7 @@ static void manage_tempaddrs(struct inet6_dev *idev,* We don't want that to result in creating a new temporary ip address. */ if ((list_empty (&idev->tempaddr_list) || all_regen) && - (valid_lft || prefered_lft)) + (valid_lft && prefered_lft)) create = true;if (create &&READ_ONCE (idev->cnf.use_tempaddr) >0 ) {Quoted 1 line
Any thoughts?
This still leaves the case of RAs that alternate between
prefered_lft> 0 andprefered_lft== 0. It will cause the kernel to create an unbounded amount of temporary addresses.I think that a better fix would be to reset the regeneration counter of the newest temporary address whenever the associated public address becomes preferred. Something like [1].
If the newest temporary address has yet to spawn a new address, then its regeneration counter is 0 and nothing changes. However, if it was incremented and no new address was created, then this patch will reset its regeneration counter to reflect that. Before expiring,
addrconf_verify_rtnl()will notice that this address has yet to spawn a new address and callipv6_create_tempaddr().
Quoted 7 lines
The case of constant RAs with
prefered_lft== 0 is not an issue because we only reset the regeneration counter whenprefered_lft> 0.Alternating RAs are also not an issue because we don't call
ipv6_create_tempaddr()immediately and instead letaddrconf_verify_rtnl()handle it when the address is about to expire.
Hi Ido, yes this looks good but I am afraid of using time_after(). Sure, a temporary address should never be older than 2 ~ 7 days. Yet, we allow configuring it up to 2147483647 (68~ years). And that might cause problems in 32-bit systems.
I think we either limit this configuration on sysctl directly or we need to support this nonsense.. another option would be to move inet6_ifaddr out of jiffies which is something that I recently added to my TODO list. But that is a bigger change I do not want to bundle with this one.
I noticed that ipv6_add_addr() do:
list_add(&ifa->tmp_list, &idev->tempaddr_list);
Doesn't it mean the first address that matches the base prefix is indeed the most recent one? I tried a bit and it seems we can use just the first match :)
In addition, I didn't check with Sashiko but it is likely going to complain about a race condition for a RA arriving right after we have spawned an address but it has not been added to the tempaddr list. Therefore we would have two addresses.. anyway, that race is quite unlikely. I also have planned work on that are to reduce the multiple race windows, currently there are plenty. I suggest to acknowledge such race condition for now and improve the code base for the reported scenario.
I propose this small change to your proposed diff, I acknowledge that it is a bit fragile tho (maybe a comment at ipv6_add_addr() is worth to avoid breaking this accidentally):
net/ipv6/addrconf.c +1 -1
@@ -2607,7 +2607,7 @@ static void manage_tempaddrs(struct inet6_dev *idev,if (ifp != ift->ifpub)continue ; -if (!newest_ift ||time_after (ift->cstamp, newest_ift->cstamp)) +if (!newest_ift) newest_ift = ift;/* RFC 4941 section 3.3:
Thanks!
Fernando.
Quoted 39 lines
[1]
net/ipv6/addrconf.c +11
-1@@ -2595,8 +2595,9 @@ static void manage_tempaddrs(struct inet6_dev *idev, __u32 valid_lft, __u32 prefered_lft, bool create, unsigned long now) { + struct inet6_ifaddr *ift, *newest_ift = NULL; +u32 orig_prefered_lft = prefered_lft;u32 flags; -struct inet6_ifaddr *ift;read_lock_bh (&idev->lock);/* update all temporary addresses in the list */ @@ -2606,6 +2607,9 @@ static void manage_tempaddrs(struct inet6_dev *idev,if (ifp != ift->ifpub)continue ; +if (!newest_ift ||time_after (ift->cstamp, newest_ift->cstamp)) + newest_ift = ift; +/* RFC 4941 section 3.3: * If a received option will extend the lifetime of a public * address, the lifetimes of temporary addresses should @@ -2643,6 +2647,12 @@ static void manage_tempaddrs(struct inet6_dev *idev,ipv6_ifa_notify (0 , ift); } +if (newest_ift && orig_prefered_lft >0 ) { +spin_lock (&newest_ift->lock); + newest_ift->regen_count =0 ; +spin_unlock (&newest_ift->lock); + } +/* Also create a temporary address if it's enabled but no temporary * address currently exists. * However, we get called with valid_lft == 0, prefered_lft == 0, create == false
Ido Schimmel
maintainerQuoted 10 lines · Fernando Fernandez Mancera
Hi Ido, yes this looks good but I am afraid of using
time_after(). Sure, a temporary address should never be older than 2 ~ 7 days. Yet, we allow configuring it up to 2147483647 (68~ years). And that might cause problems in 32-bit systems.I think we either limit this configuration on sysctl directly or we need to support this nonsense.. another option would be to move
inet6_ifaddrout of jiffies which is something that I recently added to my TODO list. But that is a bigger change I do not want to bundle with this one.
Quoted 7 lines
I noticed that
ipv6_add_addr()do:
list_add(&ifa->tmp_list, &idev->tempaddr_list);Doesn't it mean the first address that matches the base prefix is indeed the most recent one? I tried a bit and it seems we can use just the first match :)
It's very unlikely that jiffies is going to be a problem given that these are temporary addresses. A lifetime of months / years defeats the purpose...
I'm OK with relying on the list order, but lets add a comment in ipv6_add_addr() just before the address is added to the list.
Quoted 7 lines
In addition, I didn't check with Sashiko but it is likely going to complain about a race condition for a RA arriving right after we have spawned an address but it has not been added to the tempaddr list. Therefore we would have two addresses.. anyway, that race is quite unlikely. I also have planned work on that are to reduce the multiple race windows, currently there are plenty. I suggest to acknowledge such race condition for now and improve the code base for the reported scenario.
One possible solution is to encode the regeneration state in the regeneration counter of temporary addresses. Currently it's essentially a boolean. We can have:
0 - Pre-regeneration.
1 - Regeneration in progress.
2 - Regeneration done (might have failed).
And only reset the state if regeneration was already done.
Quoted 3 lines
I propose this small change to your proposed diff, I acknowledge that it is a bit fragile tho (maybe a comment at
ipv6_add_addr()is worth to avoid breaking this accidentally):
Yes, comments where we add to the list and where we derive the newest address based on the order should make this clear.
Jakub Kicinski
maintainerQuoted 17 lines · On Mon, 11 May 2026 14:26:45 +0200 Fernando Fernandez Mancera wrote:
When a router temporarily deprecates an IPv6 prefix (either by sending a Router Advertisement with Preferred Lifetime = 0 or by letting the lifetime expire) and later restores it, the kernel permanently loses its ability to generate temporary privacy addresses (RFC 8981) for that prefix.
This happens because the address worker attempts to generate a replacement temporary address when the current one nears expiration. As the base prefix is deprecated already, the generation fails after marking the temporary address as already having spawned a replacement (ifp->regen_count++).
When the router eventually restores the prefix, the temporary address becomes active again. However, once it naturally expires, the address worker sees this temporary address already tried to generate one and skips the regeneration.
Quoted 5 lines
Fix this by checking if all temporary addresses for a given prefix have already tried to spawn a replacement when processing a new RA. If so, spawn a new temporary address.
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
No feedback on the patch itself, but I wanted to check - Ido, do you think this is worth handling as a fix? Sounds like this scenario never worked.
Ido Schimmel
maintainerQuoted 22 lines · Jakub Kicinski
Quoted 21 lines · On Mon, 11 May 2026 14:26:45 +0200 Fernando Fernandez Mancera wrote:
When a router temporarily deprecates an IPv6 prefix (either by sending a Router Advertisement with Preferred Lifetime = 0 or by letting the lifetime expire) and later restores it, the kernel permanently loses its ability to generate temporary privacy addresses (RFC 8981) for that prefix.
This happens because the address worker attempts to generate a replacement temporary address when the current one nears expiration. As the base prefix is deprecated already, the generation fails after marking the temporary address as already having spawned a replacement (ifp->regen_count++).
When the router eventually restores the prefix, the temporary address becomes active again. However, once it naturally expires, the address worker sees this temporary address already tried to generate one and skips the regeneration.
Fix this by checking if all temporary addresses for a given prefix have already tried to spawn a replacement when processing a new RA. If so, spawn a new temporary address.
Quoted 5 lines
Quoted 1 line
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")No feedback on the patch itself, but I wanted to check - Ido, do you think this is worth handling as a fix? Sounds like this scenario never worked.
No, I think we should target net-next. The scenario never worked and the fix has the potential to cause other issues.
Fernando, please wait with the next version. I need some time to go over the Sashiko feedback.
Quoted 23 lines · Ido Schimmel
Quoted 22 lines · Jakub Kicinski
Quoted 21 lines · On Mon, 11 May 2026 14:26:45 +0200 Fernando Fernandez Mancera wrote:
When a router temporarily deprecates an IPv6 prefix (either by sending a Router Advertisement with Preferred Lifetime = 0 or by letting the lifetime expire) and later restores it, the kernel permanently loses its ability to generate temporary privacy addresses (RFC 8981) for that prefix.
This happens because the address worker attempts to generate a replacement temporary address when the current one nears expiration. As the base prefix is deprecated already, the generation fails after marking the temporary address as already having spawned a replacement (ifp->regen_count++).
When the router eventually restores the prefix, the temporary address becomes active again. However, once it naturally expires, the address worker sees this temporary address already tried to generate one and skips the regeneration.
Fix this by checking if all temporary addresses for a given prefix have already tried to spawn a replacement when processing a new RA. If so, spawn a new temporary address.
Quoted 9 lines
Quoted 5 lines
Quoted 1 line
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")No feedback on the patch itself, but I wanted to check - Ido, do you think this is worth handling as a fix? Sounds like this scenario never worked.
No, I think we should target net-next. The scenario never worked and the fix has the potential to cause other issues.
That is fine for me too.
Quoted 2 lines
Fernando, please wait with the next version. I need some time to go over the Sashiko feedback.
Sure thing, no need to rush it.
Thanks Ido!