]> 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 4eeba8549aa13c8c67a69e8c3536a27fee9748f6..90d3dbc180c4df90f91a37cf961f1f6b2ad352f5 100644 (file)
@@ -39,6 +39,8 @@
 #include "routemap.h"
 #include "frr_pthread.h"
 
+#include "zebra/zebra_router.h"
+#include "zebra/zebra_errors.h"
 #include "zebra/rib.h"
 #include "zebra/zserv.h"
 #include "zebra/debug.h"
@@ -98,6 +100,7 @@ struct option longopts[] = {
        {"ecmp", required_argument, NULL, 'e'},
        {"label_socket", no_argument, NULL, 'l'},
        {"retain", no_argument, NULL, 'r'},
+       {"vrfdefaultname", required_argument, NULL, 'o'},
 #ifdef HAVE_NETLINK
        {"vrfwnetns", no_argument, NULL, 'n'},
        {"nl-bufsize", required_argument, NULL, 's'},
@@ -140,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);
 
@@ -161,17 +172,41 @@ 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();
        prefix_list_reset();
        route_map_finish();
 
-       list_delete_and_null(&zebrad.client_list);
+       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);
 
+       zebra_router_terminate();
+
        frr_fini();
        exit(0);
 }
@@ -201,6 +236,10 @@ struct quagga_signal_t zebra_signals[] = {
        },
 };
 
+static const struct frr_yang_module_info *zebra_yang_modules[] = {
+       &frr_interface_info,
+};
+
 FRR_DAEMON_INFO(
        zebra, ZEBRA, .vty_port = ZEBRA_VTY_PORT, .flags = FRR_NO_ZCLIENT,
 
@@ -210,13 +249,17 @@ FRR_DAEMON_INFO(
 
        .signals = zebra_signals, .n_signals = array_size(zebra_signals),
 
-       .privs = &zserv_privs, )
+       .privs = &zserv_privs,
+
+       .yang_modules = zebra_yang_modules,
+       .n_yang_modules = array_size(zebra_yang_modules), )
 
 /* Main startup routine. */
 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;
@@ -234,7 +277,7 @@ int main(int argc, char **argv)
        frr_preinit(&zebra_di, argc, argv);
 
        frr_opt_add(
-               "bakz:e:l:r"
+               "bakz:e:l:o:r"
 #ifdef HAVE_NETLINK
                "s:n"
 #endif
@@ -253,6 +296,7 @@ int main(int argc, char **argv)
                "  -l, --label_socket    Socket to external label manager\n"
                "  -k, --keep_kernel     Don't delete old routes which were installed by zebra.\n"
                "  -r, --retain          When program terminates, retain added route by zebra.\n"
+               "  -o, --vrfdefaultname  Set default VRF name.\n"
 #ifdef HAVE_NETLINK
                "  -n, --vrfwnetns       Use NetNS as VRF backend\n"
                "  -s, --nl-bufsize      Set netlink receive buffer size\n"
@@ -288,12 +332,16 @@ int main(int argc, char **argv)
                        multipath_num = atoi(optarg);
                        if (multipath_num > MULTIPATH_NUM
                            || multipath_num <= 0) {
-                               zlog_err(
+                               flog_err(
+                                       EC_ZEBRA_BAD_MULTIPATH_NUM,
                                        "Multipath Number specified must be less than %d and greater than 0",
                                        MULTIPATH_NUM);
                                return 1;
                        }
                        break;
+               case 'o':
+                       vrf_default_name_configured = optarg;
+                       break;
                case 'z':
                        zserv_path = optarg;
                        if (!frr_zclient_addr(&dummy, &dummylen, optarg)) {
@@ -343,10 +391,13 @@ 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();
        rib_init();
        zebra_if_init();
@@ -357,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();
@@ -400,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);
@@ -412,6 +465,9 @@ int main(int argc, char **argv)
        /* RNH init */
        zebra_rnh_init();
 
+       /* Error init */
+       zebra_error_init();
+
 #if defined(HANDLE_ZAPI_FUZZING)
        if (zapi_fuzzing) {
                zserv_read_file(zapi_fuzzing);