From b8fdedc6b8ca7b8a75805b78aa6e7b48714ab3ec Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sat, 11 Nov 2023 22:58:16 -0500 Subject: [PATCH] ospf6d: Cleanup memory on shutdown some list data structures were never freed Signed-off-by: Donald Sharp --- ospf6d/ospf6_main.c | 1 + ospf6d/ospf6_top.c | 13 +++++++++++++ ospf6d/ospf6_top.h | 2 ++ 3 files changed, 16 insertions(+) diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index 932304578a..2a189f1418 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -103,6 +103,7 @@ static void __attribute__((noreturn)) ospf6_exit(int status) zclient_free(zclient); } + ospf6_master_delete(); frr_fini(); exit(status); } diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index aa0625814c..ef312cbe3a 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -486,6 +486,7 @@ void ospf6_delete(struct ospf6 *o) struct ospf6_area *oa; struct vrf *vrf; struct ospf6_external_aggr_rt *aggr; + uint32_t i; QOBJ_UNREG(o); @@ -532,6 +533,13 @@ void ospf6_delete(struct ospf6 *o) } route_table_finish(o->rt_aggr_tbl); + for (i = 0; i <= ZEBRA_ROUTE_MAX; i++) { + if (!o->redist[i]) + continue; + + list_delete(&o->redist[i]); + } + XFREE(MTYPE_OSPF6_TOP, o->name); XFREE(MTYPE_OSPF6_TOP, o); } @@ -576,6 +584,11 @@ void ospf6_master_init(struct event_loop *master) om6->master = master; } +void ospf6_master_delete(void) +{ + list_delete(&om6->ospf6); +} + static void ospf6_maxage_remover(struct event *thread) { struct ospf6 *o = (struct ospf6 *)EVENT_ARG(thread); diff --git a/ospf6d/ospf6_top.h b/ospf6d/ospf6_top.h index a38dad8fce..8288413c10 100644 --- a/ospf6d/ospf6_top.h +++ b/ospf6d/ospf6_top.h @@ -236,6 +236,8 @@ extern struct ospf6_master *om6; /* prototypes */ extern void ospf6_master_init(struct event_loop *master); +extern void ospf6_master_delete(void); + extern void install_element_ospf6_clear_process(void); extern void ospf6_top_init(void); extern void ospf6_delete(struct ospf6 *o); -- 2.39.5