diff options
author | Philippe Guibert <philippe.guibert@6wind.com> | 2018-02-16 18:22:34 +0100 |
---|---|---|
committer | Philippe Guibert <philippe.guibert@6wind.com> | 2018-02-27 11:11:24 +0100 |
commit | b7b816df6bd8b110aedb0f047fa8e3105ce86d1d (patch) | |
tree | 5a5328a3c22ac693d5751adbbc3ea99a018489ba /zebra/zebra_netns_notify.c | |
parent | zebra: retrieve zns context from zvrf when netlink discovery (diff) | |
download | frr-b7b816df6bd8b110aedb0f047fa8e3105ce86d1d.tar.xz frr-b7b816df6bd8b110aedb0f047fa8e3105ce86d1d.zip |
zebra: prevent from discovering a NS with same NSID as previous one
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>
Diffstat (limited to 'zebra/zebra_netns_notify.c')
-rw-r--r-- | zebra/zebra_netns_notify.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/zebra/zebra_netns_notify.c b/zebra/zebra_netns_notify.c index b28998acf..b98d6ed70 100644 --- a/zebra/zebra_netns_notify.c +++ b/zebra/zebra_netns_notify.c @@ -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); |