]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix the number of interfaces we actually send
authorRoy Marples <roy@marples.name>
Tue, 2 Sep 2014 23:41:52 +0000 (23:41 +0000)
committerRoy Marples <roy@marples.name>
Tue, 2 Sep 2014 23:41:52 +0000 (23:41 +0000)
dhcp.h
dhcp6.h
dhcpcd.c
script.c

diff --git a/dhcp.h b/dhcp.h
index 5aebe89822fbd46aaf0c42dbf259a9a84802cda9..fc8ed4bffdbdfa19c9319dc94ca48e385bd8ad3a 100644 (file)
--- 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 e216276433c7c04e23b8c8d3c99b51bc1005d85f..3727fe15efe9cde7ddad0bbb1b3abf630f3384ae 100644 (file)
--- 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)))
index 76e8d5ff44dd6b53526adfe99f63a6bac803b52a..8141b46a87b029f40ae54526b5d65204d80baab4 100644 (file)
--- 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++;
index 7165ce1ebd801c39c408e9d54139f00488dacc2b..82f8d280de426d6cb394cfca63e663731d841937 100644 (file)
--- 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;
        }