when zebra is run, by using vrf netns backend mode, then the parser
detector of netns is run before forcing the default vrf to a possible
value. In that case, there is a possibility that the forced '-o' option
will create a second vrf with same name, whereas this option should be
there to uniquely have a default vrf with a value.
To make things consistent, the forced value will be priorised. Then, the
notifier will attempt to create vrf contexts. The expectation is that
the creation will fail, due to an already present vrf with same name.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
/*
* 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();
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;
/* 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);
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);