From: Donald Sharp Date: Mon, 24 Oct 2016 17:28:35 +0000 (-0400) Subject: lib: Fix race condition in shutdown of routemap X-Git-Tag: frr-2.0-rc1~95 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=b09bceec68e9963b0bffc70c04f06d307d474adb;p=mirror%2Ffrr.git lib: Fix race condition in shutdown of routemap When shutting down a daemon that uses an update timer to handle route map processing, there exists a race condition where if you change a route map and then immediately shutdown quagga before the update timer for the routemap runs, you will be placed in a infinite loop. This condition happens because this commit introduces route map memory free'ing but never tests to see if the to_be_processed flag has happened or not before deleting: commit 289d25016b79ed7908a29af7ba35e18f1ec6ed0a Author: Lou Berger Date: Wed Apr 10 12:30:04 2013 -0700 bgpd, lib: memory cleanups for valgrind, plus debug changes Modify route_map_finish to explicitly turn off the to_be_processed field. As that we know we are going away if route_map_finish is called. Signed-off-by: Donald Sharp Reviewed-by: Daniel Walton --- diff --git a/lib/routemap.c b/lib/routemap.c index eec36d3717..7b07499533 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -1838,7 +1838,11 @@ route_map_finish (void) /* cleanup route_map */ while (route_map_master.head) - route_map_delete (route_map_master.head); + { + struct route_map *map = route_map_master.head; + map->to_be_processed = 0; + route_map_delete (map); + } for (i = 1; i < ROUTE_MAP_DEP_MAX; i++) hash_free(route_map_dep_hash[i]);