]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ipv6: addrconf: fix temp address generation after prefix deprecation
authorFernando Fernandez Mancera <fmancera@suse.de>
Sat, 23 May 2026 10:38:10 +0000 (12:38 +0200)
committerJakub Kicinski <kuba@kernel.org>
Wed, 27 May 2026 00:45:24 +0000 (17:45 -0700)
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 the issue by resetting the regen_count check of the latest temp
address generated for the prefix updated by the incoming RA.

Reported-by: Ɓukasz Stelmach <steelman@post.pl>
Closes: https://lore.kernel.org/netdev/87340td30q.fsf%25steelman@post.pl/
Suggested-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20260523103811.3790-1-fmancera@suse.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv6/addrconf.c

index da0f07e21e3fd1623c7533108ef22670c0b5bff4..d7b03196725f24e2ff02a3065d7a5ebd9c2ab800 100644 (file)
@@ -1174,6 +1174,7 @@ ipv6_add_addr(struct inet6_dev *idev, struct ifa6_config *cfg,
        ipv6_link_dev_addr(idev, ifa);
 
        if (ifa->flags&IFA_F_TEMPORARY) {
+               /* manage_tempaddrs() relies on addresses being added to the head */
                list_add(&ifa->tmp_list, &idev->tempaddr_list);
                in6_ifa_hold(ifa);
        }
@@ -2602,8 +2603,10 @@ static void manage_tempaddrs(struct inet6_dev *idev,
                             __u32 valid_lft, __u32 prefered_lft,
                             bool create, unsigned long now)
 {
-       u32 flags;
+       u32 orig_prefered_lft = prefered_lft;
        struct inet6_ifaddr *ift;
+       bool reset_done = false;
+       u32 flags;
 
        read_lock_bh(&idev->lock);
        /* update all temporary addresses in the list */
@@ -2638,6 +2641,11 @@ static void manage_tempaddrs(struct inet6_dev *idev,
                        prefered_lft = max_prefered;
 
                spin_lock(&ift->lock);
+               /* the first match is the most recent temp address */
+               if (!reset_done && orig_prefered_lft > 0) {
+                       ift->regen_count = 0;
+                       reset_done = true;
+               }
                flags = ift->flags;
                ift->valid_lft = valid_lft;
                ift->prefered_lft = prefered_lft;