diff options
| author | Roy Marples <roy@marples.name> | 2020-04-29 15:32:15 +0100 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2020-04-29 15:32:15 +0100 |
| commit | 40bf76d4599abfb56798379227ec7fe5d070b712 (patch) | |
| tree | 94ac20b6d4176f9940bc6fea524ec10eb34589ed /src | |
| parent | ab2506ce66c6ac7bdc5a2b3f1c9bf3470583daa7 (diff) | |
| download | dhcpcd-40bf76d4599abfb56798379227ec7fe5d070b712.tar.xz | |
inet6: Apply the best RA which is still valid.
If there is no such RA, then apply some defaults.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ipv6nd.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/ipv6nd.c b/src/ipv6nd.c index 99e92aaf..fc84d3f5 100644 --- a/src/ipv6nd.c +++ b/src/ipv6nd.c @@ -634,18 +634,26 @@ ipv6nd_sortrouters(struct dhcpcd_ctx *ctx) } static void -ipv6nd_applyra(struct dhcpcd_ctx *ctx, struct interface *ifp) +ipv6nd_applyra(struct interface *ifp) { struct ra *rap; struct rs_state *state = RS_STATE(ifp); - TAILQ_FOREACH(rap, ctx->ra_routers, next) { - if (rap->iface == ifp) + struct ra defra = { + .iface = ifp, + .hoplimit = IPV6_DEFHLIM , + .reachable = REACHABLE_TIME, + .retrans = RETRANS_TIMER, + }; + + TAILQ_FOREACH(rap, ifp->ctx->ra_routers, next) { + if (rap->iface == ifp && rap->lifetime != 0) break; } + /* If we have no Router Advertisement, then set default values. */ if (rap == NULL) - return; + rap = &defra; state->retrans = rap->retrans; if (if_applyra(rap) == -1 && errno != ENOENT) @@ -687,7 +695,7 @@ ipv6nd_neighbour(struct dhcpcd_ctx *ctx, struct in6_addr *addr, bool reachable) /* See if we can install a reachable default router. */ ipv6nd_sortrouters(ctx); - ipv6nd_applyra(ctx, rap->iface); + ipv6nd_applyra(rap->iface); rt_build(ctx, AF_INET6); if (reachable) @@ -1441,7 +1449,7 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, script_runreason(ifp, "TEST"); goto handle_flag; } - ipv6nd_applyra(ifp->ctx, ifp); + ipv6nd_applyra(ifp); ipv6_addaddrs(&rap->addrs); #ifdef IPV6_MANAGETEMPADDR ipv6_addtempaddrs(ifp, &rap->acquired); @@ -1835,6 +1843,8 @@ ipv6nd_expirera(void *arg) if (expired) { logwarnx("%s: part of a Router Advertisement expired", ifp->name); + ipv6nd_sortrouters(ifp->ctx); + ipv6nd_applyra(ifp); rt_build(ifp->ctx, AF_INET6); script_runreason(ifp, "ROUTERADVERT"); } @@ -1857,6 +1867,7 @@ ipv6nd_drop(struct interface *ifp) } } if (expired) { + ipv6nd_applyra(ifp); rt_build(ifp->ctx, AF_INET6); if ((ifp->options->options & DHCPCD_NODROP) != DHCPCD_NODROP) script_runreason(ifp, "ROUTERADVERT"); |
