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
+ }
}