]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix a dropping leases when the ip address is removed by a 3rd party.
authorRoy Marples <roy@marples.name>
Thu, 1 Sep 2016 11:46:51 +0000 (11:46 +0000)
committerRoy Marples <roy@marples.name>
Thu, 1 Sep 2016 11:46:51 +0000 (11:46 +0000)
dhcp.c
ipv4.c

diff --git a/dhcp.c b/dhcp.c
index 3d3e1947d6d3a0549ac3c187a13824905918abb8..f3d9cadaac5de156f2e07e0253056b00518ddbdf 100644 (file)
--- 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 97246dbe500494c5f3bcc48b3b6f1c02ffc190aa..b78e6edad752410a85068fafb6c3b6078dc9ef14 100644 (file)
--- 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);