diff options
author | Nicolas Dichtel <nicolas.dichtel@6wind.com> | 2015-01-15 09:11:16 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-01-19 14:21:26 -0500 |
commit | d37512a277dfb2cef8a578e25a3246f61399a55a (patch) | |
tree | 77d201937b891fe856ab910a5d5a86e7add51f52 /net/core | |
parent | 0c7aecd4bde4b7302cd41986d3a29e4f0b0ed218 (diff) |
rtnl: add link netns id to interface messages
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).
With this attribute, it's possible to interpret correctly all advertised
information (like IFLA_LINK, etc.).
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/rtnetlink.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 47b39f3e867c..bd6370f0cb31 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -875,6 +875,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev, | |||
875 | + nla_total_size(1) /* IFLA_OPERSTATE */ | 875 | + nla_total_size(1) /* IFLA_OPERSTATE */ |
876 | + nla_total_size(1) /* IFLA_LINKMODE */ | 876 | + nla_total_size(1) /* IFLA_LINKMODE */ |
877 | + nla_total_size(4) /* IFLA_CARRIER_CHANGES */ | 877 | + nla_total_size(4) /* IFLA_CARRIER_CHANGES */ |
878 | + nla_total_size(4) /* IFLA_LINK_NETNSID */ | ||
878 | + nla_total_size(ext_filter_mask | 879 | + nla_total_size(ext_filter_mask |
879 | & RTEXT_FILTER_VF ? 4 : 0) /* IFLA_NUM_VF */ | 880 | & RTEXT_FILTER_VF ? 4 : 0) /* IFLA_NUM_VF */ |
880 | + rtnl_vfinfo_size(dev, ext_filter_mask) /* IFLA_VFINFO_LIST */ | 881 | + rtnl_vfinfo_size(dev, ext_filter_mask) /* IFLA_VFINFO_LIST */ |
@@ -1169,6 +1170,18 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, | |||
1169 | goto nla_put_failure; | 1170 | goto nla_put_failure; |
1170 | } | 1171 | } |
1171 | 1172 | ||
1173 | if (dev->rtnl_link_ops && | ||
1174 | dev->rtnl_link_ops->get_link_net) { | ||
1175 | struct net *link_net = dev->rtnl_link_ops->get_link_net(dev); | ||
1176 | |||
1177 | if (!net_eq(dev_net(dev), link_net)) { | ||
1178 | int id = peernet2id(dev_net(dev), link_net); | ||
1179 | |||
1180 | if (nla_put_s32(skb, IFLA_LINK_NETNSID, id)) | ||
1181 | goto nla_put_failure; | ||
1182 | } | ||
1183 | } | ||
1184 | |||
1172 | if (!(af_spec = nla_nest_start(skb, IFLA_AF_SPEC))) | 1185 | if (!(af_spec = nla_nest_start(skb, IFLA_AF_SPEC))) |
1173 | goto nla_put_failure; | 1186 | goto nla_put_failure; |
1174 | 1187 | ||