]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_ns.c
bgpd: Allow 'no set community`
[mirror_frr.git] / zebra / zebra_ns.c
index e65f23dc8aa35874e57d1282230945fd6967f46d..9b86657f1b092d3a36ad97ec3b2d1c06c95f9325 100644 (file)
@@ -47,6 +47,7 @@ DEFINE_MTYPE(ZEBRA, ZEBRA_NS, "Zebra Name Space")
 static struct zebra_ns *dzns;
 
 static int logicalrouter_config_write(struct vty *vty);
+static int zebra_ns_disable_internal(struct zebra_ns *zns, bool complete);
 
 struct zebra_ns *zebra_ns_lookup(ns_id_t ns_id)
 {
@@ -75,7 +76,6 @@ static int zebra_ns_new(struct ns *ns)
 
        /* Do any needed per-NS data structure allocation. */
        zns->if_table = route_table_init();
-       zebra_vxlan_ns_init(zns);
 
        return 0;
 }
@@ -111,7 +111,7 @@ int zebra_ns_disabled(struct ns *ns)
                zlog_info("ZNS %s with id %u (disabled)", ns->name, ns->ns_id);
        if (!zns)
                return 0;
-       return zebra_ns_disable(ns->ns_id, (void **)&zns);
+       return zebra_ns_disable_internal(zns, true);
 }
 
 /* Do global enable actions - open sockets, read kernel config etc. */
@@ -135,17 +135,17 @@ int zebra_ns_enable(ns_id_t ns_id, void **info)
        return 0;
 }
 
-int zebra_ns_disable(ns_id_t ns_id, void **info)
+/* Common handler for ns disable - this can be called during ns config,
+ * or during zebra shutdown.
+ */
+static int zebra_ns_disable_internal(struct zebra_ns *zns, bool complete)
 {
-       struct zebra_ns *zns = (struct zebra_ns *)(*info);
-
        route_table_finish(zns->if_table);
-       zebra_vxlan_ns_disable(zns);
 #if defined(HAVE_RTADV)
        rtadv_terminate(zns);
 #endif
 
-       kernel_terminate(zns);
+       kernel_terminate(zns, complete);
 
        table_manager_disable(zns->ns_id);
 
@@ -154,6 +154,33 @@ int zebra_ns_disable(ns_id_t ns_id, void **info)
        return 0;
 }
 
+/* During zebra shutdown, do partial cleanup while the async dataplane
+ * is still running.
+ */
+int zebra_ns_early_shutdown(struct ns *ns)
+{
+       struct zebra_ns *zns = ns->info;
+
+       if (zns == NULL)
+               return 0;
+
+       return zebra_ns_disable_internal(zns, false);
+}
+
+/* During zebra shutdown, do final cleanup
+ * after all dataplane work is complete.
+ */
+int zebra_ns_final_shutdown(struct ns *ns)
+{
+       struct zebra_ns *zns = ns->info;
+
+       if (zns == NULL)
+               return 0;
+
+       kernel_terminate(zns, true);
+
+       return 0;
+}
 
 int zebra_ns_init(void)
 {
@@ -172,7 +199,6 @@ int zebra_ns_init(void)
 
        /* Do any needed per-NS data structure allocation. */
        dzns->if_table = route_table_init();
-       zebra_vxlan_ns_init(dzns);
 
        /* Register zebra VRF callbacks, create and activate default VRF. */
        zebra_vrf_init();