net: ipv6/addrconf: clamp preferred_lft to the maximum allowed
authorAlex Henrie <alexhenrie24@gmail.com>
Tue, 24 Oct 2023 21:23:07 +0000 (15:23 -0600)
committerJakub Kicinski <kuba@kernel.org>
Thu, 26 Oct 2023 01:23:06 +0000 (18:23 -0700)
Without this patch, there is nothing to stop the preferred lifetime of a
temporary address from being greater than its valid lifetime. If that
was the case, the valid lifetime was effectively ignored.

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20231024212312.299370-2-alexhenrie24@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv6/addrconf.c

index c2d471ad7922cf466f0dd1c7307d5f329172f711..26aedaab36475bd37a7ae321c336ee226bf7d65c 100644 (file)
@@ -1399,6 +1399,7 @@ retry:
                              idev->cnf.temp_valid_lft + age);
        cfg.preferred_lft = cnf_temp_preferred_lft + age - idev->desync_factor;
        cfg.preferred_lft = min_t(__u32, ifp->prefered_lft, cfg.preferred_lft);
+       cfg.preferred_lft = min_t(__u32, cfg.valid_lft, cfg.preferred_lft);
 
        cfg.plen = ifp->prefix_len;
        tmp_tstamp = ifp->tstamp;