mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-21 08:19:28 +00:00
Merge branch 'net-ipv6-addrconf-ensure-that-temporary-addresses-preferred-lifetimes-are-in-the-valid-range'
Alex Henrie says: ==================== net: ipv6/addrconf: ensure that temporary addresses' preferred lifetimes are in the valid range No changes from v2, but there are only four patches now because the first patch has already been applied. https://lore.kernel.org/all/20230829054623.104293-1-alexhenrie24@gmail.com/ ==================== Link: https://lore.kernel.org/r/20231024212312.299370-1-alexhenrie24@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
df3bc66219
2 changed files with 22 additions and 7 deletions
|
@ -2502,12 +2502,18 @@ use_tempaddr - INTEGER
|
|||
* -1 (for point-to-point devices and loopback devices)
|
||||
|
||||
temp_valid_lft - INTEGER
|
||||
valid lifetime (in seconds) for temporary addresses.
|
||||
valid lifetime (in seconds) for temporary addresses. If less than the
|
||||
minimum required lifetime (typically 5 seconds), temporary addresses
|
||||
will not be created.
|
||||
|
||||
Default: 172800 (2 days)
|
||||
|
||||
temp_prefered_lft - INTEGER
|
||||
Preferred lifetime (in seconds) for temporary addresses.
|
||||
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
|
||||
temp_prefered_lft is greater than temp_valid_lft, the preferred lifetime
|
||||
is temp_valid_lft.
|
||||
|
||||
Default: 86400 (1 day)
|
||||
|
||||
|
|
|
@ -1399,6 +1399,7 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, bool block)
|
|||
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;
|
||||
|
@ -1406,15 +1407,23 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, bool block)
|
|||
|
||||
write_unlock_bh(&idev->lock);
|
||||
|
||||
/* 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.
|
||||
/* 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.
|
||||
*
|
||||
* 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) {
|
||||
if (cfg.preferred_lft <= regen_advance + age)
|
||||
cfg.preferred_lft = regen_advance + age + 1;
|
||||
if (cfg.preferred_lft > cfg.valid_lft) {
|
||||
in6_ifa_put(ifp);
|
||||
in6_dev_put(idev);
|
||||
ret = -1;
|
||||
|
|
Loading…
Reference in a new issue