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 <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2018-08-03 08:18:11 -04:00
parent 391b8b08a5
commit 8619629ada
6 changed files with 15 additions and 13 deletions

View File

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

View File

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

View File

@ -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. */

View File

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

View File

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

View File

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