]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
When deactivating an interface, set the carrier to unknown as it's no longer being...
authorRoy Marples <roy@marples.name>
Thu, 28 Jul 2016 13:10:20 +0000 (13:10 +0000)
committerRoy Marples <roy@marples.name>
Thu, 28 Jul 2016 13:10:20 +0000 (13:10 +0000)
Thanks to Koichi Okamoto.

dhcpcd.c
if.c

index db9947654192acbbd6538a1a4328deb0e6f2dacb..1f3a9711b6d2794270e87149d4e61ad8c0fd2a6d 100644 (file)
--- 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 b79f01b1519f1c5f74e7ad3a1a94ad8e8a660c71..6a311ef8dcc4b73cbe07ad84190b5c70c996cf07 100644 (file)
--- 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);
        }