From 4793785b7f24474266d6a5ccd0a253bf54ca09db Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Thu, 1 Sep 2016 11:48:21 +0000 Subject: [PATCH] Clear LL callbacks when dropping or freeing addresses. --- ipv6.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ipv6.c b/ipv6.c index 3b8596dd..2cd45be4 100644 --- a/ipv6.c +++ b/ipv6.c @@ -1626,6 +1626,12 @@ ipv6_freedrop(struct interface *ifp, int drop) if ((state = IPV6_STATE(ifp)) == NULL) return; + /* If we got here, we can get rid of any LL callbacks. */ + while ((cb = TAILQ_FIRST(&state->ll_callbacks))) { + TAILQ_REMOVE(&state->ll_callbacks, cb, next); + free(cb); + } + ipv6_freedrop_addrs(&state->addrs, drop ? 2 : 0, NULL); if (drop) { if (ifp->ctx->ipv6 != NULL) { @@ -1635,10 +1641,6 @@ ipv6_freedrop(struct interface *ifp, int drop) } else { /* Because we need to cache the addresses we don't control, * we only free the state on when NOT dropping addresses. */ - while ((cb = TAILQ_FIRST(&state->ll_callbacks))) { - TAILQ_REMOVE(&state->ll_callbacks, cb, next); - free(cb); - } free(state); ifp->if_data[IF_DATA_IPV6] = NULL; eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); -- 2.47.2