]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: start the netns notification mechanism after ns initialisation
authorPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 21 Dec 2018 15:25:20 +0000 (16:25 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Wed, 16 Jan 2019 16:02:03 +0000 (17:02 +0100)
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>
zebra/main.c
zebra/zebra_ns.c
zebra/zebra_ns.h

index 90d3dbc180c4df90f91a37cf961f1f6b2ad352f5..b54c36c109eaea698141dc73e224aefe9b862d0b 100644 (file)
@@ -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();
index 03987fcb5bf735e0d8d1ee0dc48a484c733782c1..0c743d86784b1ab848ab45ee44f1bae82b3cc1f9 100644 (file)
@@ -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);
index d3592f8f305d9b942dfab015a72e80f7b48eeb1c..01af64c17bba2e7ca349adf921d3ccf41232e64c 100644 (file)
@@ -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);