]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Free ARP state when the address is deleted.
authorRoy Marples <roy@marples.name>
Thu, 22 Mar 2018 18:20:06 +0000 (18:20 +0000)
committerRoy Marples <roy@marples.name>
Thu, 22 Mar 2018 18:20:06 +0000 (18:20 +0000)
src/arp.c

index a36c5ef095b905056d500c64b4a4bd5f49f0c4d8..3949ca4aac54b7d641dd4a603541f51b8f6bec9c 100644 (file)
--- a/src/arp.c
+++ b/src/arp.c
@@ -561,28 +561,28 @@ arp_drop(struct interface *ifp)
 void
 arp_handleifa(int cmd, struct ipv4_addr *addr)
 {
-#ifdef IN_IFF_DUPLICATED
        struct iarp_state *state;
        struct arp_state *astate, *asn;
 
-       /* If the address is deleted, the ARP state should be freed by the
-        * state owner, such as DHCP or IPv4LL. */
-       if (cmd != RTM_NEWADDR || (state = ARP_STATE(addr->iface)) == NULL)
+       state = ARP_STATE(addr->iface);
+       if (state == NULL)
                return;
 
        TAILQ_FOREACH_SAFE(astate, &state->arp_states, next, asn) {
-               if (astate->addr.s_addr == addr->addr.s_addr) {
-                       if (addr->addr_flags & IN_IFF_DUPLICATED) {
-                               if (astate->conflicted_cb)
-                                       astate->conflicted_cb(astate, NULL);
-                       } else if (!(addr->addr_flags & IN_IFF_NOTUSEABLE)) {
-                               if (astate->probed_cb)
-                                       astate->probed_cb(astate);
-                       }
+               if (astate->addr.s_addr != addr->addr.s_addr)
+                       continue;
+               if (cmd == RTM_DELADDR)
+                       arp_free(astate);
+#ifdef IN_IFF_DUPLICATED
+               if (cmd != RTM_NEWADDR)
+                       continue;
+               if (addr->addr_flags & IN_IFF_DUPLICATED) {
+                       if (astate->conflicted_cb)
+                               astate->conflicted_cb(astate, NULL);
+               } else if (!(addr->addr_flags & IN_IFF_NOTUSEABLE)) {
+                       if (astate->probed_cb)
+                               astate->probed_cb(astate);
                }
-       }
-#else
-       UNUSED(cmd);
-       UNUSED(addr);
 #endif
+       }
 }