diff --git a/zebra/main.c b/zebra/main.c index 90d3dbc180..b54c36c109 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -407,10 +407,7 @@ 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_ns_init((const char *)vrf_default_name_configured); zebra_vty_init(); access_list_init(); prefix_list_init(); diff --git a/zebra/zebra_ns.c b/zebra/zebra_ns.c index 03987fcb5b..0c743d8678 100644 --- a/zebra/zebra_ns.c +++ b/zebra/zebra_ns.c @@ -183,7 +183,7 @@ int zebra_ns_final_shutdown(struct ns *ns) return 0; } -int zebra_ns_init(void) +int zebra_ns_init(const char *optional_default_name) { ns_id_t ns_id; ns_id_t ns_id_external; @@ -207,6 +207,10 @@ int zebra_ns_init(void) /* Default NS is activated */ zebra_ns_enable(ns_id_external, (void **)&dzns); + if (optional_default_name) + vrf_set_default_name(optional_default_name, + true); + if (vrf_is_backend_netns()) { ns_add_hook(NS_NEW_HOOK, zebra_ns_new); ns_add_hook(NS_ENABLE_HOOK, zebra_ns_enabled); diff --git a/zebra/zebra_ns.h b/zebra/zebra_ns.h index d3592f8f30..01af64c17b 100644 --- a/zebra/zebra_ns.h +++ b/zebra/zebra_ns.h @@ -60,7 +60,7 @@ struct zebra_ns { struct zebra_ns *zebra_ns_lookup(ns_id_t ns_id); -int zebra_ns_init(void); +int zebra_ns_init(const char *optional_default_name); int zebra_ns_enable(ns_id_t ns_id, void **info); int zebra_ns_disabled(struct ns *ns); int zebra_ns_early_shutdown(struct ns *ns);