From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
To: netdev@vger.kernel.org, containers@lists.linux-foundation.org,
linux-kernel@vger.kernel.org, linux-api@vger.kernel.org
Cc: davem@davemloft.net, ebiederm@xmission.com,
stephen@networkplumber.org, akpm@linux-foundation.org,
luto@amacapital.net, cwang@twopensource.com,
Nicolas Dichtel <nicolas.dichtel@6wind.com>
Subject: [RFC PATCH net-next v3 2/4] rtnl: add link netns id to interface messages
Date: Thu, 2 Oct 2014 15:48:08 +0200 [thread overview]
Message-ID: <1412257690-31253-3-git-send-email-nicolas.dichtel@6wind.com> (raw)
In-Reply-To: <1412257690-31253-1-git-send-email-nicolas.dichtel@6wind.com>
This patch adds a new attribute (IFLA_LINK_NETNSID) which contains the 'link'
netns id when this netns is different from the netns where the interface
stands (for example for x-net interfaces like ip tunnels). When there is no id,
we put NETNSA_NSINDEX_UNKNOWN into this attribute to indicate to userland that
the link netns is different from the interface netns. Hence, userland knows that
some information like IFLA_LINK are not interpretable.
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
include/net/rtnetlink.h | 2 ++
include/uapi/linux/if_link.h | 1 +
net/core/rtnetlink.c | 13 +++++++++++++
3 files changed, 16 insertions(+)
diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
index e21b9f9653c0..6c6d5393fc34 100644
--- a/include/net/rtnetlink.h
+++ b/include/net/rtnetlink.h
@@ -46,6 +46,7 @@ static inline int rtnl_msg_family(const struct nlmsghdr *nlh)
* to create when creating a new device.
* @get_num_rx_queues: Function to determine number of receive queues
* to create when creating a new device.
+ * @get_link_net: Function to get the i/o netns of the device
*/
struct rtnl_link_ops {
struct list_head list;
@@ -93,6 +94,7 @@ struct rtnl_link_ops {
int (*fill_slave_info)(struct sk_buff *skb,
const struct net_device *dev,
const struct net_device *slave_dev);
+ struct net *(*get_link_net)(const struct net_device *dev);
};
int __rtnl_link_register(struct rtnl_link_ops *ops);
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index 0bdb77e16875..938c0c02ed2e 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -145,6 +145,7 @@ enum {
IFLA_CARRIER,
IFLA_PHYS_PORT_ID,
IFLA_CARRIER_CHANGES,
+ IFLA_LINK_NETNSID,
__IFLA_MAX
};
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index a6882686ca3a..1b9329512496 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -862,6 +862,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
+ nla_total_size(1) /* IFLA_OPERSTATE */
+ nla_total_size(1) /* IFLA_LINKMODE */
+ nla_total_size(4) /* IFLA_CARRIER_CHANGES */
+ + nla_total_size(4) /* IFLA_LINK_NETNSID */
+ nla_total_size(ext_filter_mask
& RTEXT_FILTER_VF ? 4 : 0) /* IFLA_NUM_VF */
+ rtnl_vfinfo_size(dev, ext_filter_mask) /* IFLA_VFINFO_LIST */
@@ -1134,6 +1135,18 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
goto nla_put_failure;
}
+ if (dev->rtnl_link_ops &&
+ dev->rtnl_link_ops->get_link_net) {
+ struct net *link_net = dev->rtnl_link_ops->get_link_net(dev);
+
+ if (!net_eq(dev_net(dev), link_net)) {
+ int id = peernet2id(dev_net(dev), link_net);
+
+ if (nla_put_s32(skb, IFLA_LINK_NETNSID, id))
+ goto nla_put_failure;
+ }
+ }
+
if (!(af_spec = nla_nest_start(skb, IFLA_AF_SPEC)))
goto nla_put_failure;
--
2.1.0
next prev parent reply other threads:[~2014-10-02 13:48 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-23 13:20 [RFC PATCH net-next v2 0/5] netns: allow to identify peer netns Nicolas Dichtel
2014-09-23 13:20 ` [RFC PATCH net-next v2 1/5] netns: allocate netns ids Nicolas Dichtel
2014-09-23 13:20 ` [RFC PATCH net-next v2 2/5] netns: add genl cmd to get the id of a netns Nicolas Dichtel
2014-09-23 13:20 ` [RFC PATCH net-next v2 3/5] rtnl: add link netns id to interface messages Nicolas Dichtel
2014-09-23 13:20 ` [RFC PATCH net-next v2 4/5] iptunnels: advertise link netns via netlink Nicolas Dichtel
2014-09-23 13:20 ` [RFC PATCH net-next v2 5/5] rtnl: allow to create device with IFLA_LINK_NETNSID set Nicolas Dichtel
2014-09-23 19:22 ` [RFC PATCH net-next v2 0/5] netns: allow to identify peer netns Cong Wang
2014-09-24 9:23 ` Nicolas Dichtel
2014-09-24 16:01 ` Cong Wang
2014-09-24 16:15 ` Cong Wang
2014-09-24 16:31 ` Nicolas Dichtel
2014-09-24 16:48 ` Cong Wang
2014-09-25 8:53 ` Nicolas Dichtel
2014-09-26 1:58 ` Cong Wang
2014-09-26 13:38 ` Nicolas Dichtel
2014-09-24 16:27 ` Nicolas Dichtel
2014-09-24 16:45 ` Cong Wang
2014-09-25 8:53 ` Nicolas Dichtel
2014-09-26 2:09 ` Cong Wang
2014-09-26 13:40 ` Nicolas Dichtel
2014-09-26 19:15 ` David Ahern
2014-09-26 19:34 ` Eric W. Biederman
2014-09-26 19:44 ` David Ahern
2014-09-26 20:45 ` Eric W. Biederman
2014-09-26 20:56 ` David Ahern
2014-09-23 19:26 ` Andy Lutomirski
2014-09-24 9:31 ` Nicolas Dichtel
2014-09-24 17:05 ` Andy Lutomirski
2014-09-25 7:54 ` Nicolas Dichtel
2014-09-26 18:10 ` Eric W. Biederman
2014-09-26 18:26 ` Andy Lutomirski
2014-09-26 18:57 ` Eric W. Biederman
2014-09-29 12:06 ` Nicolas Dichtel
2014-09-29 18:43 ` Eric W. Biederman
2014-10-02 13:46 ` Nicolas Dichtel
2014-10-02 13:48 ` [RFC PATCH net-next v3 0/4] " Nicolas Dichtel
2014-10-02 13:48 ` [RFC PATCH net-next v3 1/4] netns: add genl cmd to add and get peer netns ids Nicolas Dichtel
2014-10-02 19:33 ` Eric W. Biederman
2014-10-03 12:22 ` Nicolas Dichtel
2014-10-02 13:48 ` Nicolas Dichtel [this message]
2014-10-02 13:48 ` [RFC PATCH net-next v3 3/4] iptunnels: advertise link netns via netlink Nicolas Dichtel
2014-10-02 13:48 ` [RFC PATCH net-next v3 4/4] rtnl: allow to create device with IFLA_LINK_NETNSID set Nicolas Dichtel
2014-10-30 15:25 ` [PATCH net-next v4 0/4] netns: allow to identify peer netns Nicolas Dichtel
2014-10-30 15:25 ` [PATCH net-next v4 1/4] netns: add genl cmd to add and get peer netns ids Nicolas Dichtel
2014-10-30 18:35 ` Eric W. Biederman
2014-10-31 9:41 ` Nicolas Dichtel
2014-10-30 15:25 ` [PATCH net-next v4 2/4] rtnl: add link netns id to interface messages Nicolas Dichtel
2014-10-30 15:25 ` [PATCH net-next v4 3/4] iptunnels: advertise link netns via netlink Nicolas Dichtel
2014-10-30 15:25 ` [PATCH net-next v4 4/4] rtnl: allow to create device with IFLA_LINK_NETNSID set Nicolas Dichtel
2014-10-30 18:41 ` [PATCH net-next v4 0/4] netns: allow to identify peer netns Eric W. Biederman
2014-10-31 9:48 ` Nicolas Dichtel
2014-10-31 19:14 ` Eric W. Biederman
2014-11-05 14:23 ` Nicolas Dichtel
2014-12-04 16:21 ` Nicolas Dichtel
2015-01-15 14:11 ` [PATCH net-next v5 " Nicolas Dichtel
2015-01-15 14:11 ` [PATCH net-next v5 1/4] netns: add rtnl cmd to add and get peer netns ids Nicolas Dichtel
2015-01-15 14:11 ` [PATCH net-next v5 2/4] rtnl: add link netns id to interface messages Nicolas Dichtel
2015-01-15 14:11 ` [PATCH net-next v5 3/4] tunnels: advertise link netns via netlink Nicolas Dichtel
2015-01-15 14:11 ` [PATCH net-next v5 4/4] rtnl: allow to create device with IFLA_LINK_NETNSID set Nicolas Dichtel
2015-01-19 19:16 ` [PATCH net-next v5 0/4] netns: allow to identify peer netns David Miller
2014-11-01 21:08 ` [PATCH net-next v4 " David Miller
2014-11-24 13:45 ` Nicolas Dichtel
2014-10-02 19:20 ` [RFC PATCH net-next v2 0/5] " Eric W. Biederman
2014-10-02 19:31 ` Andy Lutomirski
2014-10-02 19:45 ` Eric W. Biederman
2014-10-02 19:48 ` Andy Lutomirski
2014-10-03 12:22 ` Nicolas Dichtel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1412257690-31253-3-git-send-email-nicolas.dichtel@6wind.com \
--to=nicolas.dichtel@6wind.com \
--cc=akpm@linux-foundation.org \
--cc=containers@lists.linux-foundation.org \
--cc=cwang@twopensource.com \
--cc=davem@davemloft.net \
--cc=ebiederm@xmission.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).