summaryrefslogtreecommitdiffstats
path: root/src/ipv6.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2017-04-26 09:57:16 +0100
committerRoy Marples <roy@marples.name>2017-05-05 14:26:12 +0100
commit5fecef9ea5d76457e03ae8bd4657244b645b9671 (patch)
tree3872948e12f1727cf4805d75f7fee899f481ba39 /src/ipv6.c
parent24ddb6ae0fee14a715f586f739b56c58b938d1a3 (diff)
downloaddhcpcd-5fecef9ea5d76457e03ae8bd4657244b645b9671.tar.xz
IPv6: show actual address lifetimes being applied
Summary: For IPv6, the acquisition time of the address is stored. When adding the address during a refresh, the valid and preferred times are decreased by the difference between the acquisition time and the current time. This is not shown in the logs, but it should be otherwise you could be confused by a prefix adding an address, but it really came from a stale lease. While here, if vltime overflows then log an error and zero it. This effectively removes the address when it's added. Related to T114. Test Plan: Configure your DHCPv6 server to lease a Prefix from Pool A. Configure dhcpcd to request a Prefix Delegation and assign to a downstream interface. Start dhcpcd. Configure your DHCPv6 server to lease a Prefix from Pool B. Observe dhcpcd debug logs - it should note that addresses previously assigned from group A have decreasing valid times. Reviewers: Harri Reviewed By: Harri Differential Revision: https://dev.marples.name/D110
Diffstat (limited to 'src/ipv6.c')
-rw-r--r--src/ipv6.c65
1 files changed, 31 insertions, 34 deletions
diff --git a/src/ipv6.c b/src/ipv6.c
index 1ac191ef..b4214883 100644
--- a/src/ipv6.c
+++ b/src/ipv6.c
@@ -642,29 +642,6 @@ ipv6_addaddr1(struct ipv6_addr *ap, const struct timespec *now)
ipv6_iffindaddr(ap->iface, &ap->addr, IN6_IFF_NOTUSEABLE))
ap->flags |= IPV6_AF_DADCOMPLETED;
- logfunc = ap->flags & IPV6_AF_NEW ? loginfox : logdebugx;
- logfunc("%s: adding %saddress %s", ap->iface->name,
-#ifdef IPV6_AF_TEMPORARY
- ap->flags & IPV6_AF_TEMPORARY ? "temporary " : "",
-#else
- "",
-#endif
- ap->saddr);
- if (ap->prefix_pltime == ND6_INFINITE_LIFETIME &&
- ap->prefix_vltime == ND6_INFINITE_LIFETIME)
- logdebugx("%s: pltime infinity, vltime infinity",
- ap->iface->name);
- else if (ap->prefix_pltime == ND6_INFINITE_LIFETIME)
- logdebugx("%s: pltime infinity, vltime %"PRIu32" seconds",
- ap->iface->name, ap->prefix_vltime);
- else if (ap->prefix_vltime == ND6_INFINITE_LIFETIME)
- logdebugx("%s: pltime %"PRIu32"seconds, vltime infinity",
- ap->iface->name, ap->prefix_pltime);
- else
- logdebugx("%s: pltime %"PRIu32" seconds, vltime %"PRIu32
- " seconds",
- ap->iface->name, ap->prefix_pltime, ap->prefix_vltime);
-
/* Adjust plftime and vltime based on acquired time */
pltime = ap->prefix_pltime;
vltime = ap->prefix_vltime;
@@ -686,20 +663,40 @@ ipv6_addaddr1(struct ipv6_addr *ap, const struct timespec *now)
if (ap->prefix_pltime > pltime)
ap->prefix_pltime = 0;
}
- if (ap->prefix_vltime != ND6_INFINITE_LIFETIME)
+ if (ap->prefix_vltime != ND6_INFINITE_LIFETIME) {
ap->prefix_vltime -= (uint32_t)n.tv_sec;
+ /* This should never happen. */
+ if (ap->prefix_vltime > vltime) {
+ logerrx("%s: %s: lifetime overflow",
+ ifp->name, ap->saddr);
+ ap->prefix_vltime = ap->prefix_pltime = 0;
+ }
+ }
+ }
-#if 0
- logdebugx("%s: acquired %lld.%.9ld, now %lld.%.9ld, diff %lld.%.9ld",
- ap->iface->name,
- (long long)ap->acquired.tv_sec, ap->acquired.tv_nsec,
- (long long)now->tv_sec, now->tv_nsec,
- (long long)n.tv_sec, n.tv_nsec);
- logdebugx("%s: adj pltime %"PRIu32" seconds, "
- "vltime %"PRIu32" seconds",
- ap->iface->name, ap->prefix_pltime, ap->prefix_vltime);
+ logfunc = ap->flags & IPV6_AF_NEW ? loginfox : logdebugx;
+ logfunc("%s: adding %saddress %s", ap->iface->name,
+#ifdef IPV6_AF_TEMPORARY
+ ap->flags & IPV6_AF_TEMPORARY ? "temporary " : "",
+#else
+ "",
#endif
- }
+ ap->saddr);
+ if (ap->prefix_pltime == ND6_INFINITE_LIFETIME &&
+ ap->prefix_vltime == ND6_INFINITE_LIFETIME)
+ logdebugx("%s: pltime infinity, vltime infinity",
+ ap->iface->name);
+ else if (ap->prefix_pltime == ND6_INFINITE_LIFETIME)
+ logdebugx("%s: pltime infinity, vltime %"PRIu32" seconds",
+ ap->iface->name, ap->prefix_vltime);
+ else if (ap->prefix_vltime == ND6_INFINITE_LIFETIME)
+ logdebugx("%s: pltime %"PRIu32"seconds, vltime infinity",
+ ap->iface->name, ap->prefix_pltime);
+ else
+ logdebugx("%s: pltime %"PRIu32" seconds, vltime %"PRIu32
+ " seconds",
+ ap->iface->name, ap->prefix_pltime, ap->prefix_vltime);
+
if (if_address6(RTM_NEWADDR, ap) == -1) {
logerr(__func__);