From 8619629ada22ed19eb95d491799cc03a13d6d8aa Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 3 Aug 2018 08:18:11 -0400 Subject: [PATCH] lib, bgpd, ospf6d, ospfd, pimd: Allow finish to cleanup a bit more When calling route_map_finish, every place that we do we must first set the deletion event to NULL, or we will create an infinite loop, if we are using the delayed route-map application code. As such we might as well just make the route_map_finish code do this work, as that there is really no viable alternative here and route_map_finish should only be called on shutdown. This fixes an infinite loop in zebra on shutdown when there are route-maps. Signed-off-by: Donald Sharp --- bgpd/bgp_routemap.c | 4 ---- lib/routemap.c | 9 +++++++++ lib/routemap.h | 6 ++++++ ospf6d/ospf6_asbr.c | 3 --- ospfd/ospfd.c | 3 --- pimd/pim_routemap.c | 3 --- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 903018b2a2..bee4fca705 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -4810,9 +4810,5 @@ void bgp_route_map_init(void) void bgp_route_map_terminate(void) { /* ToDo: Cleanup all the used memory */ - - route_map_add_hook(NULL); - route_map_delete_hook(NULL); - route_map_event_hook(NULL); route_map_finish(); } diff --git a/lib/routemap.c b/lib/routemap.c index 6c4585365a..4e8682f312 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -2741,6 +2741,15 @@ void route_map_finish(void) vector_free(route_set_vec); route_set_vec = NULL; + /* + * All protocols are setting these to NULL + * by default on shutdown( route_map_finish ) + * Why are we making them do this work? + */ + route_map_master.add_hook = NULL; + route_map_master.delete_hook = NULL; + route_map_master.event_hook = NULL; + /* cleanup route_map */ while (route_map_master.head) { struct route_map *map = route_map_master.head; diff --git a/lib/routemap.h b/lib/routemap.h index 0f7c391f84..a193e32536 100644 --- a/lib/routemap.h +++ b/lib/routemap.h @@ -169,6 +169,12 @@ DECLARE_QOBJ_TYPE(route_map) /* Prototypes. */ extern void route_map_init(void); + +/* + * This should only be called on shutdown + * Additionally this function sets the hooks to NULL + * before any processing is done. + */ extern void route_map_finish(void); /* Add match statement to route map. */ diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index e6bd3faf40..5af88defeb 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -1861,9 +1861,6 @@ void ospf6_asbr_redistribute_reset(void) void ospf6_asbr_terminate(void) { /* Cleanup route maps */ - route_map_add_hook(NULL); - route_map_delete_hook(NULL); - route_map_event_hook(NULL); route_map_finish(); } diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index f315421843..2298c2261a 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -561,9 +561,6 @@ void ospf_terminate(void) ospf_finish(ospf); /* Cleanup route maps */ - route_map_add_hook(NULL); - route_map_delete_hook(NULL); - route_map_event_hook(NULL); route_map_finish(); /* reverse prefix_list_init */ diff --git a/pimd/pim_routemap.c b/pimd/pim_routemap.c index b41124376f..4230c127ad 100644 --- a/pimd/pim_routemap.c +++ b/pimd/pim_routemap.c @@ -52,8 +52,5 @@ void pim_route_map_init(void) void pim_route_map_terminate(void) { - route_map_add_hook(NULL); - route_map_delete_hook(NULL); - route_map_event_hook(NULL); route_map_finish(); }