Mercurial > hg > dhcpcd
changeset 2931:3657d1698f11 draft
Only extend temporary addresses with pltime.
If the Prefix Information Option has zero pltime, set all temporary addresses
with a pltime to zero for the prefix.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Fri, 23 Jan 2015 11:00:17 +0000 |
| parents | 6f5caff960a8 |
| children | 1267cf1388e4 |
| files | ipv6.c |
| diffstat | 1 files changed, 21 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/ipv6.c Thu Jan 22 20:10:18 2015 +0000 +++ b/ipv6.c Fri Jan 23 11:00:17 2015 +0000 @@ -1567,22 +1567,18 @@ ipv6_settemptime(struct ipv6_addr *ia, int flags) { struct ipv6_state *state; - struct ipv6_addr *ap; + struct ipv6_addr *ap, *first; state = IPV6_STATE(ia->iface); + first = NULL; TAILQ_FOREACH_REVERSE(ap, &state->addrs, ipv6_addrhead, next) { if (ap->flags & IPV6_AF_TEMPORARY && + ap->prefix_pltime && IN6_ARE_ADDR_EQUAL(&ia->prefix, &ap->prefix)) { time_t max, ext; if (flags == 0) { - /* Don't try and extend an address which is - * deprecated */ - if (ap->prefix_pltime == 0 || - ap->prefix_pltime == ND6_INFINITE_LIFETIME) - continue; - if (ap->prefix_pltime - (uint32_t)(ia->acquired.tv_sec - ap->acquired.tv_sec) @@ -1596,6 +1592,13 @@ ap->flags |= IPV6_AF_NEW | IPV6_AF_AUTOCONF; ap->flags &= ~IPV6_AF_STALE; + /* RFC4941 Section 3.4 + * Deprecated prefix, deprecate the temporary address */ + if (ia->prefix_pltime == 0) { + ap->prefix_pltime = 0; + goto valid; + } + /* Ensure desync is still valid */ ipv6_regen_desync(ap->iface, 0); @@ -1612,6 +1615,7 @@ ap->prefix_pltime = (uint32_t)(max - ia->acquired.tv_sec); +valid: ext = ia->acquired.tv_sec + (time_t)ia->prefix_vltime; max = ap->created.tv_sec + ip6_temp_valid_lifetime(ap->iface->name); @@ -1623,10 +1627,18 @@ /* Just extend the latest matching prefix */ ap->acquired = ia->acquired; - return ap; + + /* If extending return the last match as + * it's the most current. + * If deprecating, deprecate any other addresses we + * may have, although this should not be needed */ + if (ia->prefix_pltime) + return ap; + if (first == NULL) + first = ap; } } - return NULL; + return first; } void
