Mercurial > hg > dhcpcd
changeset 4534:003dc9907bba draft
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.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Fri, 14 Jun 2019 17:05:24 +0100 |
| parents | 33a7edb3a44a |
| children | f2ddefe6c69e ce9e8fb0e6a3 |
| files | src/dhcpcd.c src/ipv6nd.c src/ipv6nd.h |
| diffstat | 3 files changed, 21 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dhcpcd.c Fri Jun 14 17:03:55 2019 +0100 +++ b/src/dhcpcd.c Fri Jun 14 17:05:24 2019 +0100 @@ -782,7 +782,7 @@ /* 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);
--- a/src/ipv6nd.c Fri Jun 14 17:03:55 2019 +0100 +++ b/src/ipv6nd.c Fri Jun 14 17:05:24 2019 +0100 @@ -526,46 +526,34 @@ 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
--- a/src/ipv6nd.h Fri Jun 14 17:03:55 2019 +0100 +++ b/src/ipv6nd.h Fri Jun 14 17:05:24 2019 +0100 @@ -107,7 +107,7 @@ 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 */
