]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Kernel routes are flushed on shutdown by kernel scan, not by table scan
authorMaria Matejka <mq@ucw.cz>
Fri, 1 Oct 2021 12:11:13 +0000 (14:11 +0200)
committerMaria Matejka <mq@ucw.cz>
Tue, 9 Nov 2021 18:20:41 +0000 (19:20 +0100)
sysdep/unix/krt.c
sysdep/unix/krt.h

index b98e7ec0f7f1fcf1be3e4cb7b0f5e09aaa24af18..32bfe7fc94f738de9d22593b2f7ce1e423115e60 100644 (file)
@@ -542,23 +542,6 @@ krt_is_installed(struct krt_proto *p, net *n)
   return n->routes && bmap_test(&p->p.main_channel->export_map, n->routes->rte.id);
 }
 
-static void
-krt_flush_routes(struct krt_proto *p)
-{
-  struct rtable *t = p->p.main_channel->table;
-
-  KRT_TRACE(p, D_EVENTS, "Flushing kernel routes");
-  FIB_WALK(&t->fib, net, n)
-    {
-      if (krt_is_installed(p, n))
-       {
-         /* FIXME: this does not work if gw is changed in export filter */
-         krt_replace_rte(p, n->n.addr, NULL, &n->routes->rte);
-       }
-    }
-  FIB_WALK_END;
-}
-
 static struct rte *
 krt_export_net(struct krt_proto *p, net *net)
 {
@@ -637,6 +620,9 @@ krt_got_route(struct krt_proto *p, rte *e, s8 src)
 #endif
   /* The rest is for KRT_SRC_BIRD (or KRT_SRC_UNKNOWN) */
 
+  /* Deleting all routes if flush is requested */
+  if (p->flush_routes)
+    goto delete;
 
   /* We wait for the initial feed to have correct installed state */
   if (!p->ready)
@@ -729,6 +715,17 @@ krt_prune(struct krt_proto *p)
     p->initialized = 1;
 }
 
+static void
+krt_flush_routes(struct krt_proto *p)
+{
+  KRT_TRACE(p, D_EVENTS, "Flushing kernel routes");
+  p->flush_routes = 1;
+  krt_init_scan(p);
+  krt_do_scan(p);
+  /* No prune! */
+  p->flush_routes = 0;
+}
+
 void
 krt_got_route_async(struct krt_proto *p, rte *e, int new, s8 src)
 {
index cd4bd07d90c8e84863da3992bff2902d62635a89..f6ad6fdea84e075517e44df79854cfc5e181bdad 100644 (file)
@@ -66,6 +66,7 @@ struct krt_proto {
   byte ready;                  /* Initial feed has been finished */
   byte initialized;            /* First scan has been finished */
   byte reload;                 /* Next scan is doing reload */
+  byte flush_routes;           /* Scanning to flush */
 };
 
 extern pool *krt_pool;