From: Roy Marples Date: Thu, 1 Sep 2016 11:46:51 +0000 (+0000) Subject: Fix a dropping leases when the ip address is removed by a 3rd party. X-Git-Tag: v6.11.4~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6245ee8b7b46f30db4e2148ce0168ddb3ffcf16;p=thirdparty%2Fdhcpcd.git Fix a dropping leases when the ip address is removed by a 3rd party. --- diff --git a/dhcp.c b/dhcp.c index 3d3e1947..f3d9cada 100644 --- a/dhcp.c +++ b/dhcp.c @@ -3653,9 +3653,12 @@ dhcp_handleifa(int cmd, struct ipv4_addr *ia) 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; diff --git a/ipv4.c b/ipv4.c index 97246dbe..b78e6eda 100644 --- a/ipv4.c +++ b/ipv4.c @@ -896,7 +896,10 @@ delete_address(struct interface *ifp) 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);