From: Roy Marples Date: Fri, 24 Oct 2014 19:30:24 +0000 (+0000) Subject: Free other ARP states in a better way. X-Git-Tag: v6.6.0~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=751f8fcba12713d0336ec0b8e37b62fde5830f07;p=thirdparty%2Fdhcpcd.git Free other ARP states in a better way. --- diff --git a/arp.c b/arp.c index f4f64479..fbc6a469 100644 --- a/arp.c +++ b/arp.c @@ -314,12 +314,26 @@ arp_free(struct arp_state *astate) struct dhcp_state *state; if (astate) { + eloop_timeout_delete(astate->iface->ctx->eloop, NULL, astate); state = D_STATE(astate->iface); TAILQ_REMOVE(&state->arp_states, astate, next); free(astate); } } +void +arp_free_but(struct arp_state *astate) +{ + struct arp_state *p, *n; + struct dhcp_state *state; + + state = D_STATE(astate->iface); + TAILQ_FOREACH_SAFE(p, &state->arp_states, next, n) { + if (p != astate) + arp_free(p); + } +} + void arp_close(struct interface *ifp) { @@ -336,8 +350,6 @@ arp_close(struct interface *ifp) } while ((astate = TAILQ_FIRST(&state->arp_states))) { - TAILQ_REMOVE(&state->arp_states, astate, next); - eloop_timeout_delete(ifp->ctx->eloop, NULL, astate); - free(astate); + arp_free(astate); } } diff --git a/arp.h b/arp.h index ccea3603..9666c47f 100644 --- a/arp.h +++ b/arp.h @@ -71,5 +71,6 @@ void arp_probe(struct arp_state *); struct arp_state *arp_new(struct interface *); void arp_cancel(struct arp_state *); void arp_free(struct arp_state *); +void arp_free_but(struct arp_state *); void arp_close(struct interface *); #endif diff --git a/dhcp.c b/dhcp.c index d2346108..aa1d0685 100644 --- a/dhcp.c +++ b/dhcp.c @@ -1972,10 +1972,7 @@ applyaddr: } if (astate) { arp_announce(astate); - if (astate != state->arp_ipv4ll) { - arp_free(state->arp_ipv4ll); - state->arp_ipv4ll = NULL; - } + arp_free_but(astate); } } else if (!ipv4ll) arp_close(ifp);