]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: Fix race condition in shutdown of routemap
authorDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 24 Oct 2016 17:28:35 +0000 (13:28 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 24 Oct 2016 17:40:08 +0000 (13:40 -0400)
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 <lberger@labn.net>
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 <sharpd@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
lib/routemap.c

index eec36d3717f80fbf278399e381e77e7a4e8fdedd..7b07499533549dc023826499216a8988c6c93f69 100644 (file)
@@ -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]);