From: Roy Marples Date: Tue, 2 Sep 2014 23:41:52 +0000 (+0000) Subject: Fix the number of interfaces we actually send X-Git-Tag: v6.4.4~46 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=41e9ebebbd528ba1b003b5d1089869410e961eb9;p=thirdparty%2Fdhcpcd.git Fix the number of interfaces we actually send --- diff --git a/dhcp.h b/dhcp.h index 5aebe898..fc8ed4bf 100644 --- a/dhcp.h +++ b/dhcp.h @@ -240,6 +240,8 @@ struct dhcp_state { ((struct dhcp_state *)(ifp)->if_data[IF_DATA_DHCP]) #define D_CSTATE(ifp) \ ((const struct dhcp_state *)(ifp)->if_data[IF_DATA_DHCP]) +#define D_STATE_RUNNING(ifp) \ + (D_CSTATE((ifp)) && D_CSTATE((ifp))->new && D_CSTATE((ifp))->reason) #include "dhcpcd.h" #include "if-options.h" diff --git a/dhcp6.h b/dhcp6.h index e2162764..3727fe15 100644 --- a/dhcp6.h +++ b/dhcp6.h @@ -207,7 +207,9 @@ struct dhcp6_state { ((struct dhcp6_state *)(ifp)->if_data[IF_DATA_DHCP6]) #define D6_CSTATE(ifp) \ ((const struct dhcp6_state *)(ifp)->if_data[IF_DATA_DHCP6]) -#define D6_STATE_RUNNING(ifp) (D6_STATE((ifp)) && D6_STATE((ifp))->new) +#define D6_STATE_RUNNING(ifp) \ + (D6_CSTATE((ifp)) && D6_CSTATE((ifp))->new && D6_CSTATE((ifp))->reason) + #define D6_FIRST_OPTION(m) \ ((struct dhcp6_option *) \ ((uint8_t *)(m) + sizeof(struct dhcp6_message))) diff --git a/dhcpcd.c b/dhcpcd.c index 76e8d5ff..8141b46a 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -1086,7 +1086,7 @@ dhcpcd_handleargs(struct dhcpcd_ctx *ctx, struct fd_list *fd, if (argc == 1) { TAILQ_FOREACH(ifp, ctx->ifaces, next) { len++; - if (D_STATE(ifp)) + if (D_STATE_RUNNING(ifp)) len++; if (D6_STATE_RUNNING(ifp)) len++; @@ -1109,7 +1109,7 @@ 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)) + if (D_STATE_RUNNING(ifp)) len++; if (D6_STATE_RUNNING(ifp)) len++; diff --git a/script.c b/script.c index 7165ce1e..82f8d280 100644 --- a/script.c +++ b/script.c @@ -544,10 +544,10 @@ send_interface(int fd, const struct interface *ifp) const char *reason; int retval = 0; #ifdef INET - const struct dhcp_state *d = D_CSTATE(ifp); + const struct dhcp_state *d; #endif #ifdef INET6 - const struct dhcp6_state *d6 = D6_CSTATE(ifp); + const struct dhcp6_state *d6; #endif switch (ifp->carrier) { @@ -564,9 +564,11 @@ send_interface(int fd, const struct interface *ifp) if (send_interface1(fd, ifp, reason) == -1) retval = -1; #ifdef INET - if (d && d->reason) + if (D_STATE_RUNNING(ifp)) { + d = D_CSTATE(ifp); if (send_interface1(fd, ifp, d->reason) == -1) retval = -1; + } #endif #ifdef INET6 @@ -574,7 +576,8 @@ send_interface(int fd, const struct interface *ifp) if (send_interface1(fd, ifp, "ROUTERADVERT") == -1) retval = -1; } - if (D6_STATE_RUNNING(ifp) && d6->reason) { + if (D6_STATE_RUNNING(ifp)) { + d6 = D6_CSTATE(ifp); if (send_interface1(fd, ifp, d6->reason) == -1) retval = -1; }