From 4dfcfabfa99a613a8fe5d4d69f6e8550f2d9dbf6 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 9 Oct 2020 11:41:21 -0400 Subject: [PATCH] zebra: Push timer out if another route-map change comes in for zebra If we are running with a delayed timer to handle route-map changes in zebra, if another route-map change is made to the cli, push out the timer instead of not modifying the timer. This will allow a large set of route-maps to be possibly be read in by the system and we don't have a state where new route-map changes are being read in and having the timer pop in the middle of it. Additionally convert to use THREAD_OFF, preventing a possible use after free as well as aligning the thread api usage with what we consider correct. Signed-off-by: Donald Sharp --- zebra/zebra_routemap.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index 42d27b369b..f4b0fa2d23 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -1620,8 +1620,6 @@ static void zebra_route_map_process_update_cb(char *rmap_name) static int zebra_route_map_update_timer(struct thread *thread) { - zebra_t_rmap_update = NULL; - if (IS_ZEBRA_DEBUG_EVENT) zlog_debug("Event driven route-map update triggered"); @@ -1646,8 +1644,8 @@ static void zebra_route_map_set_delay_timer(uint32_t value) if (!value && zebra_t_rmap_update) { /* Event driven route map updates is being disabled */ /* But there's a pending timer. Fire it off now */ - thread_cancel(&zebra_t_rmap_update); - zebra_route_map_update_timer(zebra_t_rmap_update); + THREAD_OFF(zebra_t_rmap_update); + zebra_route_map_update_timer(NULL); } } @@ -1656,7 +1654,7 @@ void zebra_routemap_finish(void) /* Set zebra_rmap_update_timer to 0 so that it wont schedule again */ zebra_rmap_update_timer = 0; /* Thread off if any scheduled already */ - thread_cancel(&zebra_t_rmap_update); + THREAD_OFF(zebra_t_rmap_update); route_map_finish(); } @@ -1772,8 +1770,8 @@ route_map_result_t zebra_nht_route_map_check(afi_t afi, int client_proto, static void zebra_route_map_mark_update(const char *rmap_name) { /* rmap_update_timer of 0 means don't do route updates */ - if (zebra_rmap_update_timer && !zebra_t_rmap_update) { - zebra_t_rmap_update = NULL; + if (zebra_rmap_update_timer) { + THREAD_OFF(zebra_t_rmap_update); thread_add_timer(zrouter.master, zebra_route_map_update_timer, NULL, zebra_rmap_update_timer, &zebra_t_rmap_update); -- 2.39.5