Re: dhcpcd 6.11.3 core dumps on FreeBSD with link disconnect/connect sequence
Roy Marples
Tue Aug 30 19:31:57 2016Hi Guy On Tuesday 30 August 2016 20:46:55 Guy Yur wrote: > dhcpcd with the patch no longer crashes on the above sequence. yay! > What should happen to the IPv4 address when the interface > goes down or when the link is lost? > > Before the patch, > 1. ifconfig lan0 down > ifconfig lan0 -> ipv4 address from dhcp was removed > 2. ifconfig lan0 up > ifconfig lan0 -> ipv4 address from dhcp was not restored (waited one minute) > > 1. link disconnected on lan0 > ifconfig lan0 -> ipv4 address from dhcp was removed > 2. link reconnected on lan0 > ifconfig lan0 -> ipv4 address from dhcp was added after a few seconds > > > After the patch, > 1. ifconfig lan0 down > ifconfig lan0 -> ipv4 address from dhcp was not removed > 2. ifconfig lan0 up > > 1. link disconnected on lan0 > ifconfig lan0 -> ipv4 address from dhcp was not removed > 2. link reconnected on lan0 In both cases the address should be restored at the last step. I will try and test more on BSD tomorrow. One potential problem is that ifa_msghdr does not carry the PID of the originating process which deleted the address and if there is a delay receiving it, dhcpcd can get confused. We may have to extend the kernel structure so it can carry the pid to make it a lot tighter. Attached is a new dhcpcd patch which may help. Let me know. Roy
Index: dhcp.c
==================================================================
--- dhcp.c
+++ dhcp.c
@@ -3651,13 +3651,16 @@
state = D_STATE(ifp);
if (state == NULL)
return;
if (cmd == RTM_DELADDR) {
- if (IPV4_BRD_EQ(state->addr, ia)) {
+ if (state->addr == ia) {
logger(ifp->ctx, LOG_INFO,
"%s: deleted IP address %s", ifp->name, ia->saddr);
+ state->addr = NULL;
+ /* Don't clear the added state as we need
+ * to drop the lease. */
dhcp_drop(ifp, "EXPIRE");
}
return;
}
Index: ipv4.c
==================================================================
--- ipv4.c
+++ ipv4.c
@@ -894,11 +894,14 @@
struct if_options *ifo;
struct dhcp_state *state;
state = D_STATE(ifp);
ifo = ifp->options;
- if (ifo->options & DHCPCD_INFORM ||
+ /* The lease could have been added, but the address deleted
+ * by a 3rd party. */
+ if (state->addr == NULL ||
+ ifo->options & DHCPCD_INFORM ||
(ifo->options & DHCPCD_STATIC && ifo->req_addr.s_addr == 0))
return 0;
r = ipv4_deladdr(state->addr, 0);
return r;
}
Archive administrator: postmaster@marples.name