]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Ensure we have an IPv4 state before starting DHCP.
authorRoy Marples <roy@marples.name>
Sat, 20 Jun 2015 12:09:55 +0000 (12:09 +0000)
committerRoy Marples <roy@marples.name>
Sat, 20 Jun 2015 12:09:55 +0000 (12:09 +0000)
dhcpcd.c
ipv4.c
ipv4.h

index f8827b8ec3746fcf0003117189b8fdeb52922e31..305eb2d8a0b4b4a32723d169d835a5bfd3569ad3 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -891,8 +891,11 @@ dhcpcd_startinterface(void *arg)
                }
        }
 
-       if (ifo->options & DHCPCD_IPV4)
-               dhcp_start(ifp);
+       if (ifo->options & DHCPCD_IPV4) {
+               /* Ensure we have an IPv4 state before starting DHCP */
+               if (ipv4_getstate(ifp) != NULL)
+                       dhcp_start(ifp);
+       }
 }
 
 static void
diff --git a/ipv4.c b/ipv4.c
index 49e0a3ced0b5393a54dddfe2387c248734625256..ae665db43632cd728466955201125f5a9c42acbf 100644 (file)
--- a/ipv4.c
+++ b/ipv4.c
@@ -787,7 +787,7 @@ delete_address(struct interface *ifp)
        return r;
 }
 
-static struct ipv4_state *
+struct ipv4_state *
 ipv4_getstate(struct interface *ifp)
 {
        struct ipv4_state *state;
diff --git a/ipv4.h b/ipv4.h
index 4fd9b326cc4611a65f4de31d6a4b4a5448e8431a..53e1b7187a6370a009ed783efe3968bdda300d1f 100644 (file)
--- a/ipv4.h
+++ b/ipv4.h
@@ -93,6 +93,7 @@ struct ipv4_state {
        ((const struct ipv4_state *)(ifp)->if_data[IF_DATA_IPV4])
 
 #ifdef INET
+struct ipv4_state *ipv4_getstate(struct interface *);
 int ipv4_init(struct dhcpcd_ctx *);
 int ipv4_protocol_fd(const struct interface *, uint16_t);
 int ipv4_ifcmp(const struct interface *, const struct interface *);