From: Roy Marples Date: Thu, 22 Mar 2018 18:20:06 +0000 (+0000) Subject: Free ARP state when the address is deleted. X-Git-Tag: v7.0.2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87a7db6e61fc2801930a6fcae1a5673ebacf000a;p=thirdparty%2Fdhcpcd.git Free ARP state when the address is deleted. --- diff --git a/src/arp.c b/src/arp.c index a36c5ef0..3949ca4a 100644 --- 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 + } }