]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/main.c
isisd: implement the 'lsp-too-large' notification
[mirror_frr.git] / zebra / main.c
index 5d200b6da98232aa8f1adc1baad2599df2c8232c..90d3dbc180c4df90f91a37cf961f1f6b2ad352f5 100644 (file)
@@ -143,11 +143,19 @@ static void sigint(void)
        struct zebra_vrf *zvrf;
        struct listnode *ln, *nn;
        struct zserv *client;
+       static bool sigint_done;
+
+       if (sigint_done)
+               return;
+
+       sigint_done = true;
 
        zlog_notice("Terminating on signal");
 
        frr_early_fini();
 
+       zebra_dplane_pre_finish();
+
        for (ALL_LIST_ELEMENTS(zebrad.client_list, ln, nn, client))
                zserv_close_client(client);
 
@@ -164,7 +172,7 @@ static void sigint(void)
                work_queue_free_and_null(&zebrad.lsp_process_q);
        vrf_terminate();
 
-       ns_walk_func(zebra_ns_disabled);
+       ns_walk_func(zebra_ns_early_shutdown);
        zebra_ns_notify_close();
 
        access_list_reset();
@@ -172,6 +180,28 @@ static void sigint(void)
        route_map_finish();
 
        list_delete(&zebrad.client_list);
+
+       /* Indicate that all new dplane work has been enqueued. When that
+        * work is complete, the dataplane will enqueue an event
+        * with the 'finalize' function.
+        */
+       zebra_dplane_finish();
+}
+
+/*
+ * Final shutdown step for the zebra main thread. This is run after all
+ * async update processing has completed.
+ */
+int zebra_finalize(struct thread *dummy)
+{
+       zlog_info("Zebra final shutdown");
+
+       /* Final shutdown of ns resources */
+       ns_walk_func(zebra_ns_final_shutdown);
+
+       /* Stop dplane thread and finish any cleanup */
+       zebra_dplane_shutdown();
+
        work_queue_free_and_null(&zebrad.ribq);
        meta_queue_free(zebrad.mq);
 
@@ -229,6 +259,7 @@ int main(int argc, char **argv)
 {
        // int batch_mode = 0;
        char *zserv_path = NULL;
+       char *vrf_default_name_configured = NULL;
        /* Socket to external label manager */
        char *lblmgr_path = NULL;
        struct sockaddr_storage dummy;
@@ -309,7 +340,7 @@ int main(int argc, char **argv)
                        }
                        break;
                case 'o':
-                       vrf_set_default_name(optarg);
+                       vrf_default_name_configured = optarg;
                        break;
                case 'z':
                        zserv_path = optarg;
@@ -360,9 +391,11 @@ int main(int argc, char **argv)
                }
        }
 
-       vty_config_lockless();
        zebrad.master = frr_init();
 
+       /* Initialize pthread library */
+       frr_pthread_init();
+
        /* Zebra related initialize. */
        zebra_router_init();
        zserv_init();
@@ -375,7 +408,9 @@ int main(int argc, char **argv)
         * Initialize NS( and implicitly the VRF module), and make kernel
         * routing socket. */
        zebra_ns_init();
-
+       if (vrf_default_name_configured)
+               vrf_set_default_name(vrf_default_name_configured,
+                                    true);
        zebra_vty_init();
        access_list_init();
        prefix_list_init();
@@ -418,8 +453,8 @@ int main(int argc, char **argv)
        /* Needed for BSD routing socket. */
        pid = getpid();
 
-       /* Intialize pthread library */
-       frr_pthread_init();
+       /* Start dataplane system */
+       zebra_dplane_start();
 
        /* Start Zebra API server */
        zserv_start(zserv_path);