Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 629df6701c8a ("net: ipv6/addrconf: clamp preferred_lft to the minimum required")
Fixes: ec575f885e3e ("Documentation: networking: explain what happens if temp_prefered_lft is too small or too large")
Reported-by: Dan 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: Alex Henrie <alexhenrie24@gmail.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20231230043252.10530-1-alexhenrie24@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Alex Henrie and committed by
Jakub Kicinski
8cdafdd9 61fa2493

+6 -14
+1 -1
Documentation/networking/ip-sysctl.rst
··· 2511 2511 temp_prefered_lft - INTEGER 2512 2512 Preferred lifetime (in seconds) for temporary addresses. If 2513 2513 temp_prefered_lft is less than the minimum required lifetime (typically 2514 - 5 seconds), the preferred lifetime is the minimum required. If 2514 + 5 seconds), temporary addresses will not be created. If 2515 2515 temp_prefered_lft is greater than temp_valid_lft, the preferred lifetime 2516 2516 is temp_valid_lft. 2517 2517
+5 -13
net/ipv6/addrconf.c
··· 1407 1407 1408 1408 write_unlock_bh(&idev->lock); 1409 1409 1410 - /* From RFC 4941: 1411 - * 1412 - * A temporary address is created only if this calculated Preferred 1413 - * Lifetime is greater than REGEN_ADVANCE time units. In 1414 - * particular, an implementation must not create a temporary address 1415 - * with a zero Preferred Lifetime. 1416 - * 1417 - * Clamp the preferred lifetime to a minimum of regen_advance, unless 1418 - * that would exceed valid_lft. 1419 - * 1410 + /* A temporary address is created only if this calculated Preferred 1411 + * Lifetime is greater than REGEN_ADVANCE time units. In particular, 1412 + * an implementation must not create a temporary address with a zero 1413 + * Preferred Lifetime. 1420 1414 * Use age calculation as in addrconf_verify to avoid unnecessary 1421 1415 * temporary addresses being generated. 1422 1416 */ 1423 1417 age = (now - tmp_tstamp + ADDRCONF_TIMER_FUZZ_MINUS) / HZ; 1424 - if (cfg.preferred_lft <= regen_advance + age) 1425 - cfg.preferred_lft = regen_advance + age + 1; 1426 - if (cfg.preferred_lft > cfg.valid_lft) { 1418 + if (cfg.preferred_lft <= regen_advance + age) { 1427 1419 in6_ifa_put(ifp); 1428 1420 in6_dev_put(idev); 1429 1421 ret = -1;