From 37f861f1dbeda410c52d3b5f9f685e32a177211c Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Thu, 23 Nov 2023 20:21:31 -0300 Subject: [PATCH] ospfd: improve memory cleanup during shutdown * On ospf_terminate(), proceed to clear the ospfd global variables even when no OSPF instance is configured * Remove double call to route_map_finish() * Call ospf_opaque_term() to clear the opaque LSA infrastructure * Clear the `OspfRI.area_info` and `om->ospf` global lists. Signed-off-by: Renato Westphal --- ospfd/ospf_ri.c | 1 + ospfd/ospfd.c | 11 ++++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c index 725443f490..c6aaf3f5a0 100644 --- a/ospfd/ospf_ri.c +++ b/ospfd/ospf_ri.c @@ -153,6 +153,7 @@ static int ospf_router_info_unregister(void) void ospf_router_info_term(void) { + list_delete(&OspfRI.area_info); list_delete(&OspfRI.pce_info.pce_domain); list_delete(&OspfRI.pce_info.pce_neighbor); diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index d5cf9564ff..b3f4cad5c1 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -658,10 +658,6 @@ void ospf_terminate(void) SET_FLAG(om->options, OSPF_MASTER_SHUTDOWN); - /* Skip some steps if OSPF not actually running */ - if (listcount(om->ospf) == 0) - goto done; - for (ALL_LIST_ELEMENTS(om->ospf, node, nnode, ospf)) ospf_finish(ospf); @@ -679,9 +675,11 @@ void ospf_terminate(void) /* Cleanup vrf info */ ospf_vrf_terminate(); - route_map_finish(); - keychain_terminate(); + + ospf_opaque_term(); + list_delete(&om->ospf); + /* Deliberately go back up, hopefully to thread scheduler, as * One or more ospf_finish()'s may have deferred shutdown to a timer * thread @@ -691,7 +689,6 @@ void ospf_terminate(void) zclient_stop(zclient_sync); zclient_free(zclient_sync); -done: frr_fini(); } -- 2.39.5