changeset 4238:4ee33042b66e draft

Free ARP state when the address is deleted.
author Roy Marples <roy@marples.name>
date Thu, 22 Mar 2018 18:20:06 +0000
parents db600851438a
children 1639427de312
files src/arp.c
diffstat 1 files changed, 16 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/arp.c	Mon Mar 19 20:56:42 2018 +0000
+++ b/src/arp.c	Thu Mar 22 18:20:06 2018 +0000
@@ -561,28 +561,28 @@
 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);
 		}
+#endif
 	}
-#else
-	UNUSED(cmd);
-	UNUSED(addr);
-#endif
 }