]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Always send a carrier as it's no longer encapsulated in the IPv4 stack.
authorRoy Marples <roy@marples.name>
Tue, 6 May 2014 14:42:24 +0000 (14:42 +0000)
committerRoy Marples <roy@marples.name>
Tue, 6 May 2014 14:42:24 +0000 (14:42 +0000)
When stopping and not departed, run with the STOPPED reason but do
not process it in hooks.

dhcpcd-run-hooks.in
dhcpcd.c
script.c

index 2fcd2ea204bb4c3c0351e0ee6355ee8cc4a1dd6f..057af9f498f5b35a64a7240f4fbd5558fa4bfc94 100644 (file)
@@ -7,6 +7,8 @@ case "$reason" in
                ifsuffix=":ra";;
        INFORM6|BOUND6|RENEW6|REBIND6|REBOOT6|EXPIRE6|RELEASE6|STOP6)
                ifsuffix=":dhcp6";;
+       STOPPED) # This reason should never be processed
+               exit 0;;
        *)
                ifsuffix=;;
 esac
index cc916ccf3e641a7c0231682c065ca8140877652c..27cebcfe0aa18a4e7b77fd7211aeaa23670980cf 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -309,6 +309,8 @@ stop_interface(struct interface *ifp)
        eloop_timeout_delete(ctx->eloop, NULL, ifp);
        if (ifp->options->options & DHCPCD_DEPARTED)
                script_runreason(ifp, "DEPARTED");
+       else
+               script_runreason(ifp, "STOPPED");
        if_free(ifp);
        if (!(ctx->options & (DHCPCD_MASTER | DHCPCD_TEST)))
                eloop_exit(ctx->eloop, EXIT_FAILURE);
@@ -993,6 +995,8 @@ dhcpcd_handleargs(struct dhcpcd_ctx *ctx, struct fd_list *fd,
                        if (argc == 1) {
                                TAILQ_FOREACH(ifp, ctx->ifaces, next) {
                                        len++;
+                                       if (D_STATE(ifp))
+                                               len++;
                                        if (D6_STATE_RUNNING(ifp))
                                                len++;
                                        if (ipv6nd_has_ra(ifp))
@@ -1014,6 +1018,8 @@ dhcpcd_handleargs(struct dhcpcd_ctx *ctx, struct fd_list *fd,
                                TAILQ_FOREACH(ifp, ctx->ifaces, next) {
                                        if (strcmp(argv[opt], ifp->name) == 0) {
                                                len++;
+                                               if (D_STATE(ifp))
+                                                       len++;
                                                if (D6_STATE_RUNNING(ifp))
                                                        len++;
                                                if (ipv6nd_has_ra(ifp))
index eb63808034f57351deb4d4f4157c93b63c7cf87c..d82e807f9278d5ef6b3c50d007feb262da9dbca3 100644 (file)
--- a/script.c
+++ b/script.c
@@ -523,7 +523,6 @@ send_interface(int fd, const struct interface *ifp)
 {
        const char *reason;
        int retval = 0;
-       int onestate = 0;
 #ifdef INET
        const struct dhcp_state *d = D_CSTATE(ifp);
 #endif
@@ -531,42 +530,36 @@ send_interface(int fd, const struct interface *ifp)
        const struct dhcp6_state *d6 = D6_CSTATE(ifp);
 #endif
 
+       switch (ifp->carrier) {
+       case LINK_UP:
+               reason = "CARRIER";
+               break;
+       case LINK_DOWN:
+               reason = "NOCARRIER";
+               break;
+       default:
+               reason = "UNKNOWN";
+               break;
+       }
+       if (send_interface1(fd, ifp, reason) == -1)
+                       retval = -1;
 #ifdef INET
-       if (d) {
-               onestate = 1;
+       if (d)
                if (send_interface1(fd, ifp, d->reason) == -1)
                        retval = -1;
-       }
 #endif
 
 #ifdef INET6
        if (ipv6nd_has_ra(ifp)) {
-               onestate = 1;
                if (send_interface1(fd, ifp, "ROUTERADVERT") == -1)
                        retval = -1;
        }
        if (D6_STATE_RUNNING(ifp)) {
-               onestate = 1;
                if (send_interface1(fd, ifp, d6->reason) == -1)
                        retval = -1;
        }
 #endif
 
-       if (!onestate) {
-               switch (ifp->carrier) {
-               case LINK_UP:
-                       reason = "CARRIER";
-                       break;
-               case LINK_DOWN:
-                       reason = "NOCARRIER";
-                       break;
-               default:
-                       reason = "UNKNOWN";
-                       break;
-               }
-               if (send_interface1(fd, ifp, reason) == -1)
-                       retval = -1;
-       }
        return retval;
 }