From: Roy Marples Date: Thu, 25 Jun 2015 15:36:28 +0000 (+0000) Subject: Add an free callback to ARP states so that they can notify their parents they X-Git-Tag: v6.9.1~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c477e2458fa2d4e43493f8899c2020a1ea4193e5;p=thirdparty%2Fdhcpcd.git Add an free callback to ARP states so that they can notify their parents they are gone to avoid any double frees. Fixes [5fdd9b8d08]. --- diff --git a/arp.c b/arp.c index 70dd324a..f4369047 100644 --- a/arp.c +++ b/arp.c @@ -98,7 +98,7 @@ void arp_report_conflicted(const struct arp_state *astate, const struct arp_msg *amsg) { - if (amsg) { + if (amsg != NULL) { char buf[HWADDR_LEN * 3]; logger(astate->iface->ctx, LOG_ERR, @@ -362,6 +362,8 @@ arp_free(struct arp_state *astate) eloop_timeout_delete(ifp->ctx->eloop, NULL, astate); state = ARP_STATE(ifp); TAILQ_REMOVE(&state->arp_states, astate, next); + if (astate->free_cb) + astate->free_cb(astate); free(astate); /* If there are no more ARP states, close the socket. */ diff --git a/arp.h b/arp.h index ce0e91fd..6eb3808c 100644 --- a/arp.h +++ b/arp.h @@ -57,6 +57,7 @@ struct arp_state { void (*probed_cb)(struct arp_state *); void (*announced_cb)(struct arp_state *); void (*conflicted_cb)(struct arp_state *, const struct arp_msg *); + void (*free_cb)(struct arp_state *); struct in_addr addr; int probes; diff --git a/ipv4ll.c b/ipv4ll.c index fee857f6..e18bb5ef 100644 --- a/ipv4ll.c +++ b/ipv4ll.c @@ -243,6 +243,16 @@ ipv4ll_conflicted(struct arp_state *astate, const struct arp_msg *amsg) ipv4ll_probe, astate); } +static void +ipv4ll_arpfree(struct arp_state *astate) +{ + struct ipv4ll_state *state; + + state = IPV4LL_STATE(astate->iface); + if (state->arp == astate) + state->arp = NULL; +} + void ipv4ll_start(void *arg) { @@ -289,6 +299,7 @@ ipv4ll_start(void *arg) astate->probed_cb = ipv4ll_probed; astate->announced_cb = ipv4ll_announced; astate->conflicted_cb = ipv4ll_conflicted; + astate->free_cb = ipv4ll_arpfree; /* Find an existing IPv4LL address and ensure we can work with it. */ ia = ipv4_iffindlladdr(ifp);