]> git.proxmox.com Git - mirror_frr.git/commitdiff
zebra: Uninstall nexthops on shutdown
authorStephen Worley <sworley@cumulusnetworks.com>
Fri, 8 Mar 2019 15:35:38 +0000 (10:35 -0500)
committerStephen Worley <sworley@cumulusnetworks.com>
Fri, 25 Oct 2019 15:13:37 +0000 (11:13 -0400)
Add functionality to uninstall nexthops we created on shutdown.
To account for this, I added in a function for zebra_router
cleanup in a shutdown event.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
zebra/main.c
zebra/zebra_nhg.c
zebra/zebra_router.c
zebra/zebra_router.h

index f0225ac5e6b63797a43f4316ca178ec77dcf8fe7..e57b84c8f6f72d98cc73524b975678918beef58b 100644 (file)
@@ -165,6 +165,8 @@ static void sigint(void)
                }
        if (zrouter.lsp_process_q)
                work_queue_free_and_null(&zrouter.lsp_process_q);
+
+       zebra_router_cleanup();
        vrf_terminate();
 
        ns_walk_func(zebra_ns_early_shutdown);
index c663022caa7040de79b27421773c595ffc3f94c8..ece1e1ccd58a60dc9aaeaa709e6a68f2a9d45a2a 100644 (file)
@@ -897,6 +897,30 @@ void zebra_nhg_uninstall_kernel(struct nhg_hash_entry *nhe)
        }
 }
 
+/**
+ * zebra_nhg_uninstall_created() - Uninstall nexthops we created in the kernel
+ *
+ * @nhe:       Nexthop group hash entry
+ */
+static void zebra_nhg_uninstall_created(struct hash_bucket *bucket, void *arg)
+{
+       struct nhg_hash_entry *nhe = NULL;
+
+       nhe = (struct nhg_hash_entry *)bucket->data;
+
+       if (nhe && !nhe->is_kernel_nh)
+               zebra_nhg_uninstall_kernel(nhe);
+}
+
+/**
+ * zebra_nhg_cleanup_tables() - Iterate over our tables to uninstall nh's
+ *                             we created
+ */
+void zebra_nhg_cleanup_tables(void)
+{
+       hash_iterate(zrouter.nhgs, zebra_nhg_uninstall_created, NULL);
+}
+
 /**
  * zebra_nhg_dplane_result() - Process dplane result
  *
index 408fc16dd16f08ec0d396c5683a34a7da64fdb86..b85319df735af361983d20db83740065d2cc159f 100644 (file)
@@ -266,3 +266,14 @@ void zebra_router_init(void)
                hash_create_size(8, zebra_nhg_id_key, zebra_nhg_hash_id_equal,
                                 "Zebra Router Nexthop Groups ID index");
 }
+
+/**
+ * zebra_router_cleanup() - Perform any cleanup actions before termination
+ *
+ * Right now this is just being used to clear the nexthops we installed in
+ * the kernel on shutdown before the routes are cleaned via vrf_terminated().
+ */
+void zebra_router_cleanup(void)
+{
+       zebra_nhg_cleanup_tables();
+}
index 29f2efce7c0eb07b89f8ee62a8f2f4dd166522c4..5a2f0c9fa15484b37bdc66f548843f7e6d1e8ee4 100644 (file)
@@ -150,6 +150,7 @@ struct zebra_router {
 extern struct zebra_router zrouter;
 
 extern void zebra_router_init(void);
+extern void zebra_router_cleanup(void);
 extern void zebra_router_terminate(void);
 
 extern struct route_table *zebra_router_find_table(struct zebra_vrf *zvrf,