From: Roy Marples Date: Fri, 23 Jan 2015 11:00:17 +0000 (+0000) Subject: Only extend temporary addresses with pltime. X-Git-Tag: v6.7.0~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=182b3db0e8d08e3900b165c1a4aa5d7e70fe0a9a;p=thirdparty%2Fdhcpcd.git 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. --- diff --git a/ipv6.c b/ipv6.c index bf9de6b5..fcb79dd8 100644 --- a/ipv6.c +++ b/ipv6.c @@ -1567,22 +1567,18 @@ struct ipv6_addr * 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 @@ ipv6_settemptime(struct ipv6_addr *ia, int flags) 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 @@ ipv6_settemptime(struct ipv6_addr *ia, int flags) 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 @@ ipv6_settemptime(struct ipv6_addr *ia, int flags) /* 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