From: Roy Marples Date: Mon, 24 Apr 2017 19:50:45 +0000 (+0100) Subject: DHCPv6: deprecate addresses on stale leases. X-Git-Tag: v7.0.0-rc1~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70b3759d1bcbab124ce831d5ebfe00081608f7af;p=thirdparty%2Fdhcpcd.git DHCPv6: deprecate addresses on stale leases. Summary: When a DHCPv6 Address or Prefix Delegation is leased, it may not be renewed as a different one could be assigned. In this situation, we should prompt the kernel to prefer this new one by deprecating the old one. This is achieved by setting it's pltime to zero. Related to T114. Test Plan: Configure your DHCPv6 server to assign a delegation from Pool A. Configure dhcpcd to lease a Prefix delegation and assign it to a downstream interface. Start dhcpcd. Configure your DHCPv6 server to asssign a delegation from Pool B. Down/Up the link dhcpcd is using. dhcpcd should assign the new delegation and depreate the old by marking it's pltime as zero. Reviewers: sthen, Harri Reviewed By: Harri Differential Revision: https://dev.marples.name/D108 --- diff --git a/src/dhcp6.c b/src/dhcp6.c index ee38fb05..264779ec 100644 --- a/src/dhcp6.c +++ b/src/dhcp6.c @@ -2163,15 +2163,25 @@ dhcp6_findia(struct interface *ifp, struct dhcp6_message *m, size_t l, } TAILQ_FOREACH_SAFE(ap, &state->addrs, next, nap) { - if (ap->flags & IPV6_AF_STALE) { - eloop_q_timeout_delete(ifp->ctx->eloop, 0, NULL, ap); - if (ap->flags & IPV6_AF_REQUEST) { - ap->prefix_vltime = ap->prefix_pltime = 0; - } else { - TAILQ_REMOVE(&state->addrs, ap, next); - free(ap); + if (!(ap->flags & IPV6_AF_STALE)) + continue; + if (ap->flags & IPV6_AF_REQUEST) { + ap->prefix_vltime = ap->prefix_pltime = 0; + eloop_q_timeout_delete(ifp->ctx->eloop, + 0, NULL, ap); + continue; + } + TAILQ_REMOVE(&state->addrs, ap, next); + if (ap->flags & IPV6_AF_DELEGATEDPFX) { + struct ipv6_addr *da; + + /* Deprecate delegated addresses. */ + TAILQ_FOREACH(da, &ap->pd_pfxs, pd_next) { + da->prefix_pltime = 0; } + ipv6_addaddrs(&ap->pd_pfxs); } + ipv6_freeaddr(ap); } if (i == 0 && e) return -1;