From 88a54b123d68e032f115bc086e0f33087a746254 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 15 Nov 2023 14:36:24 -0500 Subject: [PATCH] *: Cleanup keychain on shutdown Signed-off-by: Donald Sharp --- eigrpd/eigrp_main.c | 2 ++ lib/keychain.c | 14 ++++++++++++++ lib/keychain.h | 1 + ospf6d/ospf6_main.c | 3 +++ ospfd/ospfd.c | 2 ++ ripd/rip_main.c | 2 ++ 6 files changed, 24 insertions(+) diff --git a/eigrpd/eigrp_main.c b/eigrpd/eigrp_main.c index 6d7443b791..634bf1772e 100644 --- a/eigrpd/eigrp_main.c +++ b/eigrpd/eigrp_main.c @@ -96,6 +96,8 @@ static void sigint(void) zlog_notice("Terminating on signal"); eigrp_terminate(); + keychain_terminate(); + exit(0); } diff --git a/lib/keychain.c b/lib/keychain.c index 640746bb41..f4df71b7e9 100644 --- a/lib/keychain.c +++ b/lib/keychain.c @@ -1187,6 +1187,20 @@ static const struct cmd_variable_handler keychain_var_handlers[] = { {.completions = NULL} }; +void keychain_terminate(void) +{ + struct keychain *keychain; + + while (listcount(keychain_list)) { + keychain = listgetdata(listhead(keychain_list)); + + listnode_delete(keychain_list, keychain); + keychain_delete(keychain); + } + + list_delete(&keychain_list); +} + void keychain_init(void) { keychain_list = list_new(); diff --git a/lib/keychain.h b/lib/keychain.h index be93275a5d..c96b74ecce 100644 --- a/lib/keychain.h +++ b/lib/keychain.h @@ -82,6 +82,7 @@ struct key { DECLARE_QOBJ_TYPE(key); extern void keychain_init(void); +extern void keychain_terminate(void); extern struct keychain *keychain_lookup(const char *); extern struct key *key_lookup_for_accept(const struct keychain *, uint32_t); extern struct key *key_match_for_accept(const struct keychain *, const char *); diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index 2a189f1418..b61c8f9a5f 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -104,7 +104,10 @@ static void __attribute__((noreturn)) ospf6_exit(int status) } ospf6_master_delete(); + frr_fini(); + + keychain_terminate(); exit(status); } diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index c46d2e278e..fa7cbe6e95 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -680,6 +680,8 @@ void ospf_terminate(void) ospf_vrf_terminate(); route_map_finish(); + + keychain_terminate(); /* Deliberately go back up, hopefully to thread scheduler, as * One or more ospf_finish()'s may have deferred shutdown to a timer * thread diff --git a/ripd/rip_main.c b/ripd/rip_main.c index 3f52bebe95..cb23098a7e 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -85,6 +85,8 @@ static void sigint(void) rip_zclient_stop(); route_map_finish(); + + keychain_terminate(); frr_fini(); exit(0); -- 2.39.5