From: Donald Sharp Date: Fri, 11 May 2018 17:46:59 +0000 (-0400) Subject: pimd: Cleanup the deletion event a tiny bit X-Git-Tag: frr-6.1-dev~443^2~5 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=172e45dc30bd5cc6fcada9cc72107cebf33b7b9e;p=mirror%2Ffrr.git pimd: Cleanup the deletion event a tiny bit The pim_upstream_free command was leaving slag by not deleting data associated with the upstream data structure. Modify the code to explicitly free all data associated with an upstream on a pim instance deletion event. Additionally the end result is that the pim_upstream_free command is not needed anymore Signed-off-by: Donald Sharp --- diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index b5f5f646d4..37dff2d058 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -140,12 +140,6 @@ static struct pim_upstream *pim_upstream_find_parent(struct pim_instance *pim, return NULL; } -void pim_upstream_free(struct pim_upstream *up) -{ - XFREE(MTYPE_PIM_UPSTREAM, up); - up = NULL; -} - static void upstream_channel_oil_detach(struct pim_upstream *up) { if (up->channel_oil) { @@ -209,11 +203,6 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim, list_delete_and_null(&up->ifchannels); - /* - notice that listnode_delete() can't be moved - into pim_upstream_free() because the later is - called by list_delete_all_node() - */ if (up->parent && up->parent->sources) listnode_delete(up->parent->sources, up); up->parent = NULL; @@ -237,7 +226,7 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim, } pim_delete_tracked_nexthop(pim, &nht_p, up, NULL); - pim_upstream_free(up); + XFREE(MTYPE_PIM_UPSTREAM, up); return NULL; } @@ -1545,8 +1534,15 @@ unsigned int pim_upstream_hash_key(void *arg) void pim_upstream_terminate(struct pim_instance *pim) { - if (pim->upstream_list) + struct listnode *node, *nnode; + struct pim_upstream *up; + + if (pim->upstream_list) { + for (ALL_LIST_ELEMENTS(pim->upstream_list, node, nnode, up)) + pim_upstream_del(pim, up, __PRETTY_FUNCTION__); + list_delete_and_null(&pim->upstream_list); + } if (pim->upstream_hash) hash_free(pim->upstream_hash); @@ -1773,6 +1769,5 @@ void pim_upstream_init(struct pim_instance *pim) pim_upstream_equal, hash_name); pim->upstream_list = list_new(); - pim->upstream_list->del = (void (*)(void *))pim_upstream_free; pim->upstream_list->cmp = pim_upstream_compare; } diff --git a/pimd/pim_upstream.h b/pimd/pim_upstream.h index b75a5b9df3..ba133b39dd 100644 --- a/pimd/pim_upstream.h +++ b/pimd/pim_upstream.h @@ -137,7 +137,6 @@ struct pim_upstream { int64_t state_transition; /* Record current state uptime */ }; -void pim_upstream_free(struct pim_upstream *up); struct pim_upstream *pim_upstream_find(struct pim_instance *pim, struct prefix_sg *sg); struct pim_upstream *pim_upstream_find_or_add(struct prefix_sg *sg,