From 69ccd63e57762dd45ed8fd81b76b94948b58b506 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 2 Aug 2017 13:16:51 -0400 Subject: [PATCH] pimd: Squash some more memory leaks When a interface is flapped we were leaking some memory associated with link lists. Especially in the jp_agg code. If your network was/is stable and you are not running at any scale you probably would not see this as impactful at all. Ticket: CM-16392 Signed-off-by: Donald Sharp --- pimd/pim_iface.c | 8 ++++++++ pimd/pim_igmp.c | 4 ++-- pimd/pim_instance.c | 2 +- pimd/pim_jp_agg.c | 1 + pimd/pim_msdp.c | 2 +- pimd/pim_oil.c | 2 +- pimd/pim_ssmpingd.c | 2 +- 7 files changed, 15 insertions(+), 6 deletions(-) diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index 221ca2f24d..9fdbf7b3e3 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -44,6 +44,7 @@ #include "pim_ssmpingd.h" #include "pim_rp.h" #include "pim_nht.h" +#include "pim_jp_agg.h" static void pim_if_igmp_join_del_all(struct interface *ifp); static int igmp_join_sock(const char *ifname, ifindex_t ifindex, @@ -83,6 +84,9 @@ static void *if_list_clean(struct pim_interface *pim_ifp) if (pim_ifp->upstream_switch_list) list_delete(pim_ifp->upstream_switch_list); + if (pim_ifp->sec_addr_list) + list_delete(pim_ifp->sec_addr_list); + while ((ch = RB_ROOT(pim_ifchannel_rb, &pim_ifp->ifchannel_rb)) != NULL) pim_ifchannel_delete(ch); @@ -163,6 +167,9 @@ struct pim_interface *pim_if_new(struct interface *ifp, int igmp, int pim) __FILE__, __PRETTY_FUNCTION__); return if_list_clean(pim_ifp); } + pim_ifp->upstream_switch_list->del = + (void (*)(void *))pim_jp_agg_group_list_free; + pim_ifp->upstream_switch_list->cmp = pim_jp_agg_group_list_cmp; RB_INIT(pim_ifchannel_rb, &pim_ifp->ifchannel_rb); @@ -198,6 +205,7 @@ void pim_if_delete(struct interface *ifp) list_delete(pim_ifp->igmp_socket_list); list_delete(pim_ifp->pim_neighbor_list); list_delete(pim_ifp->upstream_switch_list); + list_delete(pim_ifp->sec_addr_list); while ((ch = RB_ROOT(pim_ifchannel_rb, &pim_ifp->ifchannel_rb)) != NULL) diff --git a/pimd/pim_igmp.c b/pimd/pim_igmp.c index ea8eff4d59..3a870374c0 100644 --- a/pimd/pim_igmp.c +++ b/pimd/pim_igmp.c @@ -696,7 +696,7 @@ void igmp_startup_mode_on(struct igmp_sock *igmp) static void igmp_group_free(struct igmp_group *group) { - list_free(group->group_source_list); + list_delete(group->group_source_list); XFREE(MTYPE_PIM_IGMP_GROUP, group); } @@ -748,7 +748,7 @@ void igmp_sock_free(struct igmp_sock *igmp) zassert(igmp->igmp_group_list); zassert(!listcount(igmp->igmp_group_list)); - list_free(igmp->igmp_group_list); + list_delete(igmp->igmp_group_list); hash_free(igmp->igmp_group_hash); XFREE(MTYPE_PIM_IGMP_SOCKET, igmp); diff --git a/pimd/pim_instance.c b/pimd/pim_instance.c index 7bee75fae7..7fc77556ec 100644 --- a/pimd/pim_instance.c +++ b/pimd/pim_instance.c @@ -48,7 +48,7 @@ static void pim_instance_terminate(struct pim_instance *pim) } if (pim->static_routes) - list_free(pim->static_routes); + list_delete(pim->static_routes); pim_rp_free(pim); diff --git a/pimd/pim_jp_agg.c b/pimd/pim_jp_agg.c index a00bed064f..8e0b4ab5e8 100644 --- a/pimd/pim_jp_agg.c +++ b/pimd/pim_jp_agg.c @@ -108,6 +108,7 @@ void pim_jp_agg_clear_group(struct list *group) js->up = NULL; XFREE(MTYPE_PIM_JP_AGG_SOURCE, js); } + list_delete(jag->sources); jag->sources = NULL; listnode_delete(group, jag); XFREE(MTYPE_PIM_JP_AGG_GROUP, jag); diff --git a/pimd/pim_msdp.c b/pimd/pim_msdp.c index 39db34fc43..4b049d90ad 100644 --- a/pimd/pim_msdp.c +++ b/pimd/pim_msdp.c @@ -1261,7 +1261,7 @@ static void pim_msdp_mg_free(struct pim_instance *pim, struct pim_msdp_mg *mg) XFREE(MTYPE_PIM_MSDP_MG_NAME, mg->mesh_group_name); if (mg->mbr_list) - list_free(mg->mbr_list); + list_delete(mg->mbr_list); XFREE(MTYPE_PIM_MSDP_MG, mg); pim->msdp.mg = NULL; diff --git a/pimd/pim_oil.c b/pimd/pim_oil.c index b3bd94dc2a..9ab0709d3e 100644 --- a/pimd/pim_oil.c +++ b/pimd/pim_oil.c @@ -123,7 +123,7 @@ void pim_oil_init(struct pim_instance *pim) void pim_oil_terminate(struct pim_instance *pim) { if (pim->channel_oil_list) - list_free(pim->channel_oil_list); + list_delete(pim->channel_oil_list); pim->channel_oil_list = NULL; if (pim->channel_oil_hash) diff --git a/pimd/pim_ssmpingd.c b/pimd/pim_ssmpingd.c index f83a585a8d..9e90a34687 100644 --- a/pimd/pim_ssmpingd.c +++ b/pimd/pim_ssmpingd.c @@ -51,7 +51,7 @@ void pim_ssmpingd_init(struct pim_instance *pim) void pim_ssmpingd_destroy(struct pim_instance *pim) { if (pim->ssmpingd_list) { - list_free(pim->ssmpingd_list); + list_delete(pim->ssmpingd_list); pim->ssmpingd_list = 0; } } -- 2.39.5