]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: prevent from discovering a NS with same NSID as previous one 1711/head
authorPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 16 Feb 2018 17:22:34 +0000 (18:22 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 27 Feb 2018 10:11:24 +0000 (11:11 +0100)
This limitation ignores the creation of a new NS context, when an
already present NS is available with the same NSID. This limitation
removes confusion, so that only the first NS will be used for
configuration.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
zebra/zebra_netns_notify.c

index b28998acf8186b3e3cb06baae7a29e5be8132acc..b98d6ed7036f3f6542e5717c6db58eaf5bfb1423 100644 (file)
@@ -75,15 +75,22 @@ static void zebra_ns_notify_create_context_from_entry_name(const char *name)
        if (netnspath == NULL)
                return;
 
-       if (vrf_handler_create(NULL, name, &vrf) != CMD_SUCCESS) {
-               zlog_warn("NS notify : failed to create VRF %s", name);
-               return;
-       }
        if (zserv_privs.change(ZPRIVS_RAISE))
                zlog_err("Can't raise privileges");
        ns_id = zebra_ns_id_get(netnspath);
        if (zserv_privs.change(ZPRIVS_LOWER))
                zlog_err("Can't lower privileges");
+       /* if VRF with NS ID already present */
+       vrf = vrf_lookup_by_id((vrf_id_t)ns_id);
+       if (vrf) {
+               zlog_warn("NS notify : same NSID used by VRF %s. Ignore NS %s creation",
+                         vrf->name, netnspath);
+               return;
+       }
+       if (vrf_handler_create(NULL, name, &vrf) != CMD_SUCCESS) {
+               zlog_warn("NS notify : failed to create VRF %s", name);
+               return;
+       }
        ret = vrf_netns_handler_create(NULL, vrf, netnspath, ns_id);
        if (ret != CMD_SUCCESS) {
                zlog_warn("NS notify : failed to create NS %s", netnspath);