From: Roy Marples Date: Thu, 28 Jul 2016 13:10:20 +0000 (+0000) Subject: When deactivating an interface, set the carrier to unknown as it's no longer being... X-Git-Tag: v6.11.2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95fae65a9aad74181edaf925f36f6cd18d302a71;p=thirdparty%2Fdhcpcd.git When deactivating an interface, set the carrier to unknown as it's no longer being tracked. Thanks to Koichi Okamoto. --- diff --git a/dhcpcd.c b/dhcpcd.c index db994765..1f3a9711 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -397,6 +397,8 @@ stop_interface(struct interface *ifp) /* De-activate the interface */ ifp->active = IF_INACTIVE; ifp->options->options &= ~DHCPCD_STOPPING; + /* Set the link state to unknown as we're no longer tracking it. */ + ifp->carrier = LINK_UNKNOWN; stop: if (!(ctx->options & (DHCPCD_MASTER | DHCPCD_TEST))) @@ -1047,8 +1049,10 @@ dhcpcd_handleinterface(void *arg, int action, const char *ifname) for (i = 0; i < ctx->ifc; i++) if (strcmp(ctx->ifv[i], ifname) == 0) break; - if (i >= ctx->ifc) + if (i >= ctx->ifc) { ifp->active = IF_INACTIVE; + ifp->carrier = LINK_UNKNOWN; + } } i = 0; diff --git a/if.c b/if.c index b79f01b1..6a311ef8 100644 --- a/if.c +++ b/if.c @@ -346,7 +346,6 @@ if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv) ifp->ctx = ctx; strlcpy(ifp->name, spec.devname, sizeof(ifp->name)); ifp->flags = ifa->ifa_flags; - ifp->carrier = if_carrier(ifp); if (ifa->ifa_addr != NULL) { #ifdef AF_LINK @@ -516,6 +515,10 @@ if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv) #endif ifp->active = active; + if (ifp->active) + ifp->carrier = if_carrier(ifp); + else + ifp->carrier = LINK_UNKNOWN; TAILQ_INSERT_TAIL(ifs, ifp, next); }