diff --git a/bgpd/bgp_bmp.c b/bgpd/bgp_bmp.c index fee02de720..6a55432e14 100644 --- a/bgpd/bgp_bmp.c +++ b/bgpd/bgp_bmp.c @@ -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) { @@ -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; } diff --git a/lib/resolver.c b/lib/resolver.c index 99bf356eb3..d8245e3816 100644 --- a/lib/resolver.c +++ b/lib/resolver.c @@ -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); +} diff --git a/lib/resolver.h b/lib/resolver.h index 87e8ecdc4a..882f960a45 100644 --- a/lib/resolver.h +++ b/lib/resolver.h @@ -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, diff --git a/nhrpd/nhrp_main.c b/nhrpd/nhrp_main.c index 73af78cbf0..983a03282b 100644 --- a/nhrpd/nhrp_main.c +++ b/nhrpd/nhrp_main.c @@ -92,6 +92,8 @@ static void nhrp_request_stop(void) nhrp_vc_terminate(); debugf(NHRP_DEBUG_COMMON, "Done."); + + resolver_terminate(); frr_fini(); exit(0);