diff options
| author | Philippe Guibert <philippe.guibert@6wind.com> | 2019-10-02 13:37:11 +0200 |
|---|---|---|
| committer | Anuradha Karuppiah <anuradhak@cumulusnetworks.com> | 2020-08-18 09:25:06 -0700 |
| commit | b1cc23b2cdaf70b279dfe53aa8ded6e2e6d3b1fd (patch) | |
| tree | ad7c4704c8c704cedf0480e3cc20f48e52b78469 /lib/netns_linux.c | |
| parent | 20f4b2b0719e68e1f78d8e1a8f73d5f3c2de2418 (diff) | |
zebra, lib: new API to get absolute netns val from relative netns val
when receiving a netlink API for an interface in a namespace, this
interface may come with LINK_NSID value, which means that the interface
has its link in an other namespace. Unfortunately, the link_nsid value
is self to that namespace, and there is a need to know what is its
associated nsid value from the default namespace point of view.
The information collected previously on each namespace, can then be
compared with that value to check if the link belongs to the default
namespace or not.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'lib/netns_linux.c')
| -rw-r--r-- | lib/netns_linux.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/netns_linux.c b/lib/netns_linux.c index bb66e8938f..0109b3db6a 100644 --- a/lib/netns_linux.c +++ b/lib/netns_linux.c @@ -584,6 +584,26 @@ int ns_socket(int domain, int type, int protocol, ns_id_t ns_id) return ret; } +/* if relative link_nsid matches default netns, + * then return default absolute netns value + * otherwise, return NS_UNKNOWN + */ +ns_id_t ns_id_get_absolute(ns_id_t ns_id_reference, ns_id_t link_nsid) +{ + struct ns *ns; + + ns = ns_lookup(ns_id_reference); + if (!ns) + return NS_UNKNOWN; + + if (ns->relative_default_ns != link_nsid) + return NS_UNKNOWN; + + ns = ns_get_default(); + assert(ns); + return ns->ns_id; +} + ns_id_t ns_get_default_id(void) { if (default_ns) |
