From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Dichtel Subject: [PATCH net-next 3/4] netns: enable to specify a nsid for a get request Date: Wed, 21 Nov 2018 12:01:23 +0100 Message-ID: <20181121110124.5501-4-nicolas.dichtel@6wind.com> References: <20181121110124.5501-1-nicolas.dichtel@6wind.com> Cc: netdev@vger.kernel.org, Nicolas Dichtel To: davem@davemloft.net Return-path: Received: from host.76.145.23.62.rev.coltfrance.com ([62.23.145.76]:55071 "EHLO proxy.6wind.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729588AbeKUVfq (ORCPT ); Wed, 21 Nov 2018 16:35:46 -0500 In-Reply-To: <20181121110124.5501-1-nicolas.dichtel@6wind.com> Sender: netdev-owner@vger.kernel.org List-ID: Combined with NETNSA_TARGET_NSID, it enables to "translate" a nsid from one netns to a nsid of another netns. This is useful when using NETLINK_F_LISTEN_ALL_NSID because it helps the user to interpret a nsid received from an other netns. Signed-off-by: Nicolas Dichtel --- net/core/net_namespace.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index 3d02a742155f..92730905886c 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c @@ -783,6 +783,11 @@ static int rtnl_net_getid(struct sk_buff *skb, struct nlmsghdr *nlh, } else if (tb[NETNSA_FD]) { peer = get_net_ns_by_fd(nla_get_u32(tb[NETNSA_FD])); nla = tb[NETNSA_FD]; + } else if (tb[NETNSA_NSID]) { + peer = get_net_ns_by_id(net, nla_get_u32(tb[NETNSA_NSID])); + if (!peer) + peer = ERR_PTR(-ENOENT); + nla = tb[NETNSA_NSID]; } else { NL_SET_ERR_MSG(extack, "Peer netns reference is missing"); return -EINVAL; -- 2.18.0