From: Roy Marples Date: Fri, 14 Jun 2019 16:05:24 +0000 (+0100) Subject: RA: expire whole RA on carrier up X-Git-Tag: v8.0.0~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf94e2dd151245353b747ef7edb5e599a289ebd5;p=thirdparty%2Fdhcpcd.git RA: expire whole RA on carrier up If preserving IP, we need to expire the whole RA now that we care about RDNSS and DNSSL lifetimes. Cheat by setting the aquired time to something very low so it all expires. --- diff --git a/src/dhcpcd.c b/src/dhcpcd.c index 981134b4..fc500353 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -782,7 +782,7 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx *ctx, int carrier, unsigned int flags, /* Set any IPv6 Routers we remembered to expire * faster than they would normally as we * maybe on a new network. */ - ipv6nd_expire(ifp, RTR_CARRIER_EXPIRE); + ipv6nd_startexpire(ifp); #endif /* RFC4941 Section 3.5 */ ipv6_gentempifid(ifp); diff --git a/src/ipv6nd.c b/src/ipv6nd.c index 1adb5e16..5ece711e 100644 --- a/src/ipv6nd.c +++ b/src/ipv6nd.c @@ -526,46 +526,34 @@ ipv6nd_advertise(struct ipv6_addr *ia) ipv6nd_sendadvertisement(iaf); } -void -ipv6nd_expire(struct interface *ifp, uint32_t seconds) +static void +ipv6nd_expire(void *arg) { + struct interface *ifp = arg; struct ra *rap; - struct timespec now; - uint32_t vltime = seconds; - uint32_t pltime = seconds / 2; + struct ipv6_addr *ia; + struct timespec now = { .tv_sec = 1 }; if (ifp->ctx->ra_routers == NULL) return; - clock_gettime(CLOCK_MONOTONIC, &now); - TAILQ_FOREACH(rap, ifp->ctx->ra_routers, next) { - if (rap->iface == ifp) { - rap->acquired = now; - rap->expired = seconds ? 0 : 1; - if (seconds) { - struct ipv6_addr *ia; - - rap->lifetime = seconds; - TAILQ_FOREACH(ia, &rap->addrs, next) { - if (ia->prefix_pltime > pltime || - ia->prefix_vltime > vltime) - { - ia->acquired = now; - if (ia->prefix_pltime != 0) - ia->prefix_pltime = - pltime; - ia->prefix_vltime = vltime; - } - } - ipv6_addaddrs(&rap->addrs); - } + if (rap->iface == ifp) + continue; + rap->acquired = now; + TAILQ_FOREACH(ia, &rap->addrs, next) { + ia->acquired = now; } } - if (seconds) - ipv6nd_expirera(ifp); - else - rt_build(ifp->ctx, AF_INET6); + ipv6nd_expirera(ifp); +} + +void +ipv6nd_startexpire(struct interface *ifp) +{ + + eloop_timeout_add_sec(ifp->ctx->eloop, RTR_CARRIER_EXPIRE, + ipv6nd_expire, ifp); } static void diff --git a/src/ipv6nd.h b/src/ipv6nd.h index 7b959814..2727e514 100644 --- a/src/ipv6nd.h +++ b/src/ipv6nd.h @@ -107,7 +107,7 @@ int ipv6nd_hasradhcp(const struct interface *); void ipv6nd_handleifa(int, struct ipv6_addr *, pid_t); int ipv6nd_dadcompleted(const struct interface *); void ipv6nd_advertise(struct ipv6_addr *); -void ipv6nd_expire(struct interface *, uint32_t); +void ipv6nd_startexpire(struct interface *); void ipv6nd_drop(struct interface *); void ipv6nd_neighbour(struct dhcpcd_ctx *, struct in6_addr *, int); #endif /* INET6 */