summaryrefslogtreecommitdiffstats
path: root/ipv6.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2015-01-23 11:00:17 +0000
committerRoy Marples <roy@marples.name>2015-01-23 11:00:17 +0000
commit182b3db0e8d08e3900b165c1a4aa5d7e70fe0a9a (patch)
treefe152206e55c608ae5d8b7051c22da3f26de4334 /ipv6.c
parent16f1b54cd467ad25c67f44f137a1d6dd504be14a (diff)
downloaddhcpcd-182b3db0e8d08e3900b165c1a4aa5d7e70fe0a9a.tar.xz
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.
Diffstat (limited to 'ipv6.c')
-rw-r--r--ipv6.c30
1 files changed, 21 insertions, 9 deletions
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