From cb9ab2a8041895fa937bc493fc8bdd38dd88bed3 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Mon, 5 Sep 2016 21:20:14 +0000 Subject: [PATCH] Re-check address flags when carrier goes down if we poll for address flags. --- if-bsd.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/if-bsd.c b/if-bsd.c index 7bc54e09..6276508a 100644 --- a/if-bsd.c +++ b/if-bsd.c @@ -1288,27 +1288,42 @@ static void if_ifinfo(struct dhcpcd_ctx *ctx, const struct if_msghdr *ifm) { struct interface *ifp; - int state; + int link; +#ifdef IPV6_POLLADDRFLAG + struct ipv6_state *state; + struct ipv6_addr *ia; + int flags; +#endif if ((ifp = if_findindex(ctx->ifaces, ifm->ifm_index)) == NULL) return; switch (ifm->ifm_data.ifi_link_state) { case LINK_STATE_DOWN: - state = LINK_DOWN; + link = LINK_DOWN; break; case LINK_STATE_UP: /* Some BSD's don't take the link down on downed interface. */ - state = ifm->ifm_flags & IFF_UP ? LINK_UP : LINK_DOWN; + link = ifm->ifm_flags & IFF_UP ? LINK_UP : LINK_DOWN; + +#ifdef IPV6_POLLADDRFLAG + /* We need to update the address flags incase they were + * marked tentative on down. */ + state = IPV6_STATE(ifp); + TAILQ_FOREACH(ia, &state->addrs, next) { + if ((flags = if_addrflags6(ia)) != -1) + ia->addr_flags = flags; + } +#endif break; default: /* handle_carrier will re-load the interface flags and check for * IFF_RUNNING as some drivers that don't handle link state also * don't set IFF_RUNNING when this routing message is generated. * As such, it is a race ...*/ - state = LINK_UNKNOWN; + link = LINK_UNKNOWN; break; } - dhcpcd_handlecarrier(ctx, state, + dhcpcd_handlecarrier(ctx, link, (unsigned int)ifm->ifm_flags, ifp->name); } -- 2.47.3