From: Roy Marples Date: Tue, 6 May 2014 14:42:24 +0000 (+0000) Subject: Always send a carrier as it's no longer encapsulated in the IPv4 stack. X-Git-Tag: v6.4.0~61 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b4304101ee88b8266593e3735a5bf3716a930ba4;p=thirdparty%2Fdhcpcd.git Always send a carrier as it's no longer encapsulated in the IPv4 stack. When stopping and not departed, run with the STOPPED reason but do not process it in hooks. --- diff --git a/dhcpcd-run-hooks.in b/dhcpcd-run-hooks.in index 2fcd2ea2..057af9f4 100644 --- a/dhcpcd-run-hooks.in +++ b/dhcpcd-run-hooks.in @@ -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 diff --git a/dhcpcd.c b/dhcpcd.c index cc916ccf..27cebcfe 100644 --- 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)) diff --git a/script.c b/script.c index eb638080..d82e807f 100644 --- 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; }