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>
}
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);
}
}
+/**
+ * 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
*
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();
+}
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,