From: Roy Marples Date: Sat, 20 Jun 2015 12:09:55 +0000 (+0000) Subject: Ensure we have an IPv4 state before starting DHCP. X-Git-Tag: v6.9.1~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d821349e1e1ffdc107befed7b21539eaacc98aff;p=thirdparty%2Fdhcpcd.git Ensure we have an IPv4 state before starting DHCP. --- diff --git a/dhcpcd.c b/dhcpcd.c index f8827b8e..305eb2d8 100644 --- 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 49e0a3ce..ae665db4 100644 --- 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 4fd9b326..53e1b718 100644 --- 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 *);