summaryrefslogtreecommitdiff
path: root/zebra/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/main.c')
-rw-r--r--zebra/main.c61
1 files changed, 52 insertions, 9 deletions
diff --git a/zebra/main.c b/zebra/main.c
index 148bcab7e4..b54c36c109 100644
--- a/zebra/main.c
+++ b/zebra/main.c
@@ -39,6 +39,7 @@
#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"
@@ -142,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);
@@ -163,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();
@@ -171,9 +180,33 @@ 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);
+ zebra_router_terminate();
+
frr_fini();
exit(0);
}
@@ -203,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,
@@ -212,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;
@@ -299,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;
@@ -350,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();
@@ -363,8 +407,7 @@ int main(int argc, char **argv)
/*
* Initialize NS( and implicitly the VRF module), and make kernel
* routing socket. */
- zebra_ns_init();
-
+ zebra_ns_init((const char *)vrf_default_name_configured);
zebra_vty_init();
access_list_init();
prefix_list_init();
@@ -407,8 +450,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);
@@ -418,7 +461,7 @@ int main(int argc, char **argv)
/* RNH init */
zebra_rnh_init();
-
+
/* Error init */
zebra_error_init();