diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c index 7819b20e8f31..fa1ce3007f8a 100644 --- a/isisd/isis_circuit.c +++ b/isisd/isis_circuit.c @@ -198,8 +198,8 @@ void isis_circuit_del(struct isis_circuit *circuit) ldp_sync_info_free(&circuit->ldp_sync_info); circuit_mt_finish(circuit); - isis_lfa_excluded_ifaces_clear(circuit, ISIS_LEVEL1); - isis_lfa_excluded_ifaces_clear(circuit, ISIS_LEVEL2); + isis_lfa_excluded_ifaces_delete(circuit, ISIS_LEVEL1); + isis_lfa_excluded_ifaces_delete(circuit, ISIS_LEVEL2); list_delete(&circuit->ip_addrs); list_delete(&circuit->ipv6_link); diff --git a/isisd/isis_lfa.c b/isisd/isis_lfa.c index dc8f0b96c028..887f27eec5d9 100644 --- a/isisd/isis_lfa.c +++ b/isisd/isis_lfa.c @@ -238,10 +238,10 @@ void isis_lfa_excluded_ifaces_init(struct isis_circuit *circuit, int level) * * @param nodes List of SPF nodes */ -void isis_lfa_excluded_ifaces_clear(struct isis_circuit *circuit, int level) +void isis_lfa_excluded_ifaces_delete(struct isis_circuit *circuit, int level) { - hash_clean(circuit->lfa_excluded_ifaces[level - 1], - lfa_excl_interface_hash_free); + hash_clean_and_free(&circuit->lfa_excluded_ifaces[level - 1], + lfa_excl_interface_hash_free); } /** diff --git a/isisd/isis_lfa.h b/isisd/isis_lfa.h index 0ba1c1cef5d5..58ff115b021d 100644 --- a/isisd/isis_lfa.h +++ b/isisd/isis_lfa.h @@ -133,7 +133,7 @@ struct lfa_tiebreaker *isis_lfa_tiebreaker_add(struct isis_area *area, void isis_lfa_tiebreaker_delete(struct isis_area *area, int level, struct lfa_tiebreaker *tie_b); void isis_lfa_excluded_ifaces_init(struct isis_circuit *circuit, int level); -void isis_lfa_excluded_ifaces_clear(struct isis_circuit *circuit, int level); +void isis_lfa_excluded_ifaces_delete(struct isis_circuit *circuit, int level); void isis_lfa_excluded_iface_add(struct isis_circuit *circuit, int level, const char *ifname); void isis_lfa_excluded_iface_delete(struct isis_circuit *circuit, int level, diff --git a/isisd/isis_main.c b/isisd/isis_main.c index 8dd3a97aa1fa..b7ed8f760586 100644 --- a/isisd/isis_main.c +++ b/isisd/isis_main.c @@ -103,6 +103,12 @@ static __attribute__((__noreturn__)) void terminate(int i) isis_sr_term(); isis_srv6_term(); isis_zebra_stop(); + + isis_master_terminate(); + route_map_finish(); + vrf_terminate(); + + frr_fini(); exit(i); } diff --git a/isisd/isis_snmp.c b/isisd/isis_snmp.c index f9e3780e29e3..83a06b69980b 100644 --- a/isisd/isis_snmp.c +++ b/isisd/isis_snmp.c @@ -2826,6 +2826,13 @@ static int isis_snmp_init(struct event_loop *tm) return 0; } +static int isis_snmp_terminate(void) +{ + smux_terminate(); + + return 0; +} + /* * ISIS notification functions: we have one function per notification */ @@ -3448,6 +3455,7 @@ static int isis_snmp_module_init(void) hook_register(isis_circuit_del_hook, isis_circuit_snmp_id_free); hook_register(frr_late_init, isis_snmp_init); + hook_register(frr_fini, isis_snmp_terminate); return 0; } diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c index ce4eb74ec66f..caf7d3ddfbfc 100644 --- a/isisd/isis_zebra.c +++ b/isisd/isis_zebra.c @@ -1628,5 +1628,4 @@ void isis_zebra_stop(void) zclient_free(zclient_sync); zclient_stop(zclient); zclient_free(zclient); - frr_fini(); } diff --git a/isisd/isisd.c b/isisd/isisd.c index e67f5fb1c867..2863fd913f8f 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -176,6 +176,11 @@ void isis_master_init(struct event_loop *master) im->master = master; } +void isis_master_terminate(void) +{ + list_delete(&im->isis); +} + struct isis *isis_new(const char *vrf_name) { struct vrf *vrf; diff --git a/isisd/isisd.h b/isisd/isisd.h index 2ed7dd0f1095..1ae39f0ae95a 100644 --- a/isisd/isisd.h +++ b/isisd/isisd.h @@ -268,6 +268,7 @@ DECLARE_HOOK(isis_area_overload_bit_update, (struct isis_area * area), (area)); void isis_terminate(void); void isis_master_init(struct event_loop *master); +void isis_master_terminate(void); void isis_vrf_link(struct isis *isis, struct vrf *vrf); void isis_vrf_unlink(struct isis *isis, struct vrf *vrf); struct isis *isis_lookup_by_vrfid(vrf_id_t vrf_id); diff --git a/lib/agentx.c b/lib/agentx.c index 19f2a6b7fce8..2e621d06a44d 100644 --- a/lib/agentx.c +++ b/lib/agentx.c @@ -377,4 +377,9 @@ void smux_events_update(void) agentx_events_update(); } +void smux_terminate(void) +{ + if (events) + list_delete(&events); +} #endif /* SNMP_AGENTX */ diff --git a/lib/libfrr.c b/lib/libfrr.c index 328c6ec8b21b..8ea38368b747 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -1267,6 +1267,8 @@ void frr_fini(void) /* frrmod_init -> nothing needed / hooks */ rcu_shutdown(); + frrmod_terminate(); + /* also log memstats to stderr when stderr goes to a file*/ if (debug_memstats_at_exit || !isatty(STDERR_FILENO)) have_leftovers = log_memstats(stderr, di->name); diff --git a/lib/module.c b/lib/module.c index af7d20c3da39..9d178bb0e4a6 100644 --- a/lib/module.c +++ b/lib/module.c @@ -202,3 +202,15 @@ void frrmod_unload(struct frrmod_runtime *module) { } #endif + +void frrmod_terminate(void) +{ + struct frrmod_runtime *rtinfo = frrmod_list; + + while (rtinfo) { + XFREE(MTYPE_MODULE_LOADNAME, rtinfo->load_name); + XFREE(MTYPE_MODULE_LOADARGS, rtinfo->load_args); + + rtinfo = rtinfo->next; + } +} diff --git a/lib/module.h b/lib/module.h index cd2be474e7f4..1810b335f6f6 100644 --- a/lib/module.h +++ b/lib/module.h @@ -79,6 +79,7 @@ extern union _frrmod_runtime_u _frrmod_this_module; extern struct frrmod_runtime *frrmod_list; extern void frrmod_init(struct frrmod_runtime *modinfo); +extern void frrmod_terminate(void); extern struct frrmod_runtime *frrmod_load(const char *spec, const char *dir, void (*pFerrlog)(const void *, const char *), diff --git a/lib/smux.h b/lib/smux.h index 8ec847afd01f..0ed41410f57b 100644 --- a/lib/smux.h +++ b/lib/smux.h @@ -101,6 +101,7 @@ extern bool smux_enabled(void); extern void libagentx_init(void); extern void smux_init(struct event_loop *tm); +extern void smux_terminate(void); extern void smux_agentx_enable(void); extern void smux_register_mib(const char *, struct variable *, size_t, int, oid[], size_t); diff --git a/sharpd/sharp_main.c b/sharpd/sharp_main.c index f4ce14797809..2e72a4b99095 100644 --- a/sharpd/sharp_main.c +++ b/sharpd/sharp_main.c @@ -65,9 +65,18 @@ static void sharp_global_init(void) sg.srv6_locators = list_new(); } +static void sharp_srv6_locators_list_delete(void *item) +{ + struct sharp_srv6_locator *loc = item; + + list_delete(&loc->chunks); +} + static void sharp_global_destroy(void) { list_delete(&sg.nhs); + + sg.srv6_locators->del = sharp_srv6_locators_list_delete; list_delete(&sg.srv6_locators); }