Skip to content

Commit

Permalink
lib, bgpd, nhrpd: Cleanup memory in lib/resolver on shutdown
Browse files Browse the repository at this point in the history
This memory was not being cleaned up on shutdown.  Fix this.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
  • Loading branch information
donaldsharp committed Dec 16, 2023
1 parent a912f8f commit f38687b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bgpd/bgp_bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2884,6 +2884,12 @@ static int bmp_route_update(struct bgp *bgp, afi_t afi, safi_t safi,
return 0;
}

static int bgp_bmp_early_fini(void)
{
resolver_terminate();

return 0;
}

static int bgp_bmp_module_init(void)
{
Expand All @@ -2896,6 +2902,7 @@ static int bgp_bmp_module_init(void)
hook_register(bgp_inst_delete, bmp_bgp_del);
hook_register(frr_late_init, bgp_bmp_init);
hook_register(bgp_route_update, bmp_route_update);
hook_register(frr_early_fini, bgp_bmp_early_fini);
return 0;
}

Expand Down
5 changes: 5 additions & 0 deletions lib/resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,8 @@ void resolver_init(struct event_loop *tm)
install_element(CONFIG_NODE, &debug_resolver_cmd);
install_element(ENABLE_NODE, &debug_resolver_cmd);
}

void resolver_terminate(void)
{
ares_destroy(state.channel);
}
1 change: 1 addition & 0 deletions lib/resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct resolver_query {
};

void resolver_init(struct event_loop *tm);
void resolver_terminate(void);
void resolver_resolve(struct resolver_query *query, int af, vrf_id_t vrf_id,
const char *hostname,
void (*cb)(struct resolver_query *, const char *, int,
Expand Down
2 changes: 2 additions & 0 deletions nhrpd/nhrp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ static void nhrp_request_stop(void)
nhrp_vc_terminate();

debugf(NHRP_DEBUG_COMMON, "Done.");

resolver_terminate();
frr_fini();

exit(0);
Expand Down

0 comments on commit f38687b

Please sign in to comment.