*: Cleanup keychain on shutdown

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2023-11-15 14:36:24 -05:00
parent a3dfb08662
commit 88a54b123d
6 changed files with 24 additions and 0 deletions

View file

@ -96,6 +96,8 @@ static void sigint(void)
zlog_notice("Terminating on signal");
eigrp_terminate();
keychain_terminate();
exit(0);
}

View file

@ -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();

View file

@ -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 *);

View file

@ -104,7 +104,10 @@ static void __attribute__((noreturn)) ospf6_exit(int status)
}
ospf6_master_delete();
frr_fini();
keychain_terminate();
exit(status);
}

View file

@ -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

View file

@ -85,6 +85,8 @@ static void sigint(void)
rip_zclient_stop();
route_map_finish();
keychain_terminate();
frr_fini();
exit(0);