diff options
author | Philippe Guibert <philippe.guibert@6wind.com> | 2020-01-06 17:39:17 +0100 |
---|---|---|
committer | Philippe Guibert <philippe.guibert@6wind.com> | 2020-09-11 18:26:23 +0200 |
commit | 289b0f0dfd7112a2832812db3e5def10e82098e6 (patch) | |
tree | 4c20b1b68efdb3c6724ff6c45addfa497f6102e9 /zebra/zebra_netns_notify.c | |
parent | bgpd: sanity check when updating nexthop from bgp to zebra (diff) | |
download | frr-289b0f0dfd7112a2832812db3e5def10e82098e6.tar.xz frr-289b0f0dfd7112a2832812db3e5def10e82098e6.zip |
zebra: dynamically detect vxlan link interfaces in other netns
this is used when parsing the newly network namespaces. actually, to
track the link of some interfaces like vxlan interfaces, both link index
and link nsid are necessary. if a vxlan interface is moved to a new
netns, the link information is in the default network namespace, then
LINK_NSID is the value of the netns by default in the new netns. That
value of the default netns in the new netns is not known, because the
system does not automatically assign an NSID of default network
namespace in the new netns. Now a new NSID of default netns, seen from
that new netns, is created. This permits to store at netns creation the
default netns relative value for further usage.
Because the default netns value is set from the new netns perspective,
it is not needed anymore to use the NETNSA_TARGET_NSID attribute only
available in recent kernels.
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 | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/zebra/zebra_netns_notify.c b/zebra/zebra_netns_notify.c index 521053484..995fa6fb5 100644 --- a/zebra/zebra_netns_notify.c +++ b/zebra/zebra_netns_notify.c @@ -79,19 +79,10 @@ static void zebra_ns_notify_create_context_from_entry_name(const char *name) return; frr_with_privs(&zserv_privs) { - ns_id = zebra_ns_id_get(netnspath); + ns_id = zebra_ns_id_get(netnspath, -1); } if (ns_id == NS_UNKNOWN) return; - default_ns = ns_get_default(); - if (default_ns && default_ns->internal_ns_id != ns_id) { - frr_with_privs(&zserv_privs) { - ns_id_relative = - zebra_ns_id_get_relative_value( - default_ns->internal_ns_id, - ns_id); - } - } ns_id_external = ns_map_nsid_with_external(ns_id, true); /* if VRF with NS ID already present */ vrf = vrf_lookup_by_id((vrf_id_t)ns_id_external); @@ -107,6 +98,16 @@ static void zebra_ns_notify_create_context_from_entry_name(const char *name) ns_map_nsid_with_external(ns_id, false); return; } + + default_ns = ns_get_default(); + + /* force kernel ns_id creation in that new vrf */ + frr_with_privs(&zserv_privs) { + ns_switch_to_netns(netnspath); + ns_id_relative = zebra_ns_id_get(NULL, default_ns->fd); + ns_switchback_to_initial(); + } + frr_with_privs(&zserv_privs) { ret = vrf_netns_handler_create(NULL, vrf, netnspath, ns_id_external, |