Commit 8cdafdd9 authored by Alex Henrie's avatar Alex Henrie Committed by Jakub Kicinski

Revert "net: ipv6/addrconf: clamp preferred_lft to the minimum required"

The commit had a bug and might not have been the right approach anyway.

Fixes: 629df670 ("net: ipv6/addrconf: clamp preferred_lft to the minimum required")
Fixes: ec575f88 ("Documentation: networking: explain what happens if temp_prefered_lft is too small or too large")
Reported-by: default avatarDan Moulding <dan@danm.net>
Closes: https://lore.kernel.org/netdev/20231221231115.12402-1-dan@danm.net/
Link: https://lore.kernel.org/netdev/CAMMLpeTdYhd=7hhPi2Y7pwdPCgnnW5JYh-bu3hSc7im39uxnEA@mail.gmail.com/Signed-off-by: default avatarAlex Henrie <alexhenrie24@gmail.com>
Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20231230043252.10530-1-alexhenrie24@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 61fa2493
......@@ -2511,7 +2511,7 @@ temp_valid_lft - INTEGER
temp_prefered_lft - INTEGER
Preferred lifetime (in seconds) for temporary addresses. If
temp_prefered_lft is less than the minimum required lifetime (typically
5 seconds), the preferred lifetime is the minimum required. If
5 seconds), temporary addresses will not be created. If
temp_prefered_lft is greater than temp_valid_lft, the preferred lifetime
is temp_valid_lft.
......
......@@ -1407,23 +1407,15 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, bool block)
write_unlock_bh(&idev->lock);
/* From RFC 4941:
*
* A temporary address is created only if this calculated Preferred
* Lifetime is greater than REGEN_ADVANCE time units. In
* particular, an implementation must not create a temporary address
* with a zero Preferred Lifetime.
*
* Clamp the preferred lifetime to a minimum of regen_advance, unless
* that would exceed valid_lft.
*
/* A temporary address is created only if this calculated Preferred
* Lifetime is greater than REGEN_ADVANCE time units. In particular,
* an implementation must not create a temporary address with a zero
* Preferred Lifetime.
* Use age calculation as in addrconf_verify to avoid unnecessary
* temporary addresses being generated.
*/
age = (now - tmp_tstamp + ADDRCONF_TIMER_FUZZ_MINUS) / HZ;
if (cfg.preferred_lft <= regen_advance + age)
cfg.preferred_lft = regen_advance + age + 1;
if (cfg.preferred_lft > cfg.valid_lft) {
if (cfg.preferred_lft <= regen_advance + age) {
in6_ifa_put(ifp);
in6_dev_put(idev);
ret = -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment