From: Roy Marples Date: Wed, 3 Aug 2016 20:38:31 +0000 (+0000) Subject: Expire IPv6 RA Prefix routes. X-Git-Tag: v6.11.3~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d189cb65f5fbc8898841baf86f5288ae41b70b5;p=thirdparty%2Fdhcpcd.git Expire IPv6 RA Prefix routes. --- diff --git a/ipv6.c b/ipv6.c index 57eaffd5..3b8596dd 100644 --- a/ipv6.c +++ b/ipv6.c @@ -2404,6 +2404,8 @@ ipv6_build_ra_routes(struct ipv6_ctx *ctx, struct rt6_head *dnr, int expired) continue; if (rap->iface->options->options & DHCPCD_IPV6RA_OWN) { TAILQ_FOREACH(addr, &rap->addrs, next) { + if (addr->prefix_vltime == 0) + continue; rt = make_prefix(rap->iface, rap, addr); if (rt) TAILQ_INSERT_TAIL(dnr, rt, next); diff --git a/ipv6nd.c b/ipv6nd.c index c839cecd..71075002 100644 --- a/ipv6nd.c +++ b/ipv6nd.c @@ -1329,6 +1329,7 @@ ipv6nd_expirera(void *arg) struct ra *rap, *ran; struct timespec now, lt, expire, next; uint8_t expired, valid, validone; + struct ipv6_addr *ia; ifp = arg; clock_gettime(CLOCK_MONOTONIC, &now); @@ -1362,6 +1363,39 @@ ipv6nd_expirera(void *arg) } } + /* Not every prefix is tied to an address which + * the kernel can expire, so we need to handle it ourself. + * Also, some OS don't support address lifetimes (Solaris). */ + TAILQ_FOREACH(ia, &rap->addrs, next) { + if (ia->prefix_vltime == ND6_INFINITE_LIFETIME || + ia->prefix_vltime == 0) + continue; + lt.tv_sec = (time_t)ia->prefix_vltime; + lt.tv_nsec = 0; + timespecadd(&ia->acquired, <, &expire); + if (timespeccmp(&now, &expire, >)) { + if (ia->flags & IPV6_AF_ADDED) { + logger(ia->iface->ctx, LOG_WARNING, + "%s: expired address %s", + ia->iface->name, ia->saddr); + if (if_address6(RTM_DELADDR, ia)== -1 && + errno != EADDRNOTAVAIL && + errno != ENXIO) + logger(ia->iface->ctx, LOG_ERR, + "if_address6: %m"); + } + ia->prefix_vltime = ia->prefix_pltime = 0; + ia->flags &= + ~(IPV6_AF_ADDED | IPV6_AF_DADCOMPLETED); + expired = 1; + } else { + timespecsub(&expire, &now, <); + if (!timespecisset(&next) || + timespeccmp(&next, <, >)) + next = lt; + } + } + /* XXX FixMe! * We need to extract the lifetime from each option and check * if that has expired or not.