From 7692c5ae8215c4dc81027ce6c09939662a68fe1a Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 11 May 2018 14:07:53 -0400 Subject: [PATCH] pimd: Cleanup ifchannel deletion When we are being told to go away, cleanup ifchannel deletion a bit better. Signed-off-by: Donald Sharp --- pimd/pim_ifchannel.c | 7 +------ pimd/pim_ifchannel.h | 1 - pimd/pim_upstream.c | 12 ++++++++---- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c index bb56379c14..5e6b0f10cf 100644 --- a/pimd/pim_ifchannel.c +++ b/pimd/pim_ifchannel.c @@ -124,11 +124,6 @@ static void pim_ifchannel_find_new_children(struct pim_ifchannel *ch) } } -void pim_ifchannel_free(struct pim_ifchannel *ch) -{ - XFREE(MTYPE_PIM_IFCHANNEL, ch); -} - void pim_ifchannel_delete(struct pim_ifchannel *ch) { struct pim_interface *pim_ifp; @@ -198,7 +193,7 @@ void pim_ifchannel_delete(struct pim_ifchannel *ch) zlog_debug("%s: ifchannel entry %s is deleted ", __PRETTY_FUNCTION__, ch->sg_str); - pim_ifchannel_free(ch); + XFREE(MTYPE_PIM_IFCHANNEL, ch); } void pim_ifchannel_delete_all(struct interface *ifp) diff --git a/pimd/pim_ifchannel.h b/pimd/pim_ifchannel.h index 0af9ebf0be..b9d4d291d8 100644 --- a/pimd/pim_ifchannel.h +++ b/pimd/pim_ifchannel.h @@ -114,7 +114,6 @@ RB_HEAD(pim_ifchannel_rb, pim_ifchannel); RB_PROTOTYPE(pim_ifchannel_rb, pim_ifchannel, pim_ifp_rb, pim_ifchannel_compare); -void pim_ifchannel_free(struct pim_ifchannel *ch); void pim_ifchannel_delete(struct pim_ifchannel *ch); void pim_ifchannel_delete_all(struct interface *ifp); void pim_ifchannel_membership_clear(struct interface *ifp); diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index 37dff2d058..9329d72ce0 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -155,6 +155,8 @@ static void upstream_channel_oil_detach(struct pim_upstream *up) struct pim_upstream *pim_upstream_del(struct pim_instance *pim, struct pim_upstream *up, const char *name) { + struct listnode *node, *nnode; + struct pim_ifchannel *ch; bool notify_msdp = false; struct prefix nht_p; @@ -194,15 +196,17 @@ struct pim_upstream *pim_upstream_del(struct pim_instance *pim, notify_msdp = true; } - pim_upstream_remove_children(pim, up); - if (up->sources) - list_delete_and_null(&up->sources); - pim_mroute_del(up->channel_oil, __PRETTY_FUNCTION__); upstream_channel_oil_detach(up); + for (ALL_LIST_ELEMENTS(up->ifchannels, node, nnode, ch)) + pim_ifchannel_delete(ch); list_delete_and_null(&up->ifchannels); + pim_upstream_remove_children(pim, up); + if (up->sources) + list_delete_and_null(&up->sources); + if (up->parent && up->parent->sources) listnode_delete(up->parent->sources, up); up->parent = NULL; -- 2.39.5