aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Dichtel <nicolas.dichtel@6wind.com>2015-04-02 11:07:11 -0400
committerDavid S. Miller <davem@davemloft.net>2015-04-02 14:05:01 -0400
commita45253bf32bf49cdb2807bad212b84f5ab51ac26 (patch)
treeae8db8c41d5950644db9d4f5e609f228df958e57
parente1622baf54df8cc958bf29d71de5ad545ea7d93c (diff)
veth: set iflink to the peer veth
Now that the peer netns is advertised in rtnl messages, we can set this property so that IFLA_LINK will advertise the peer ifindex. It allows the userland to get the full veth configuration. Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/veth.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 4cca36ebc4fb..c8186ffda1a3 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -263,6 +263,20 @@ static void veth_poll_controller(struct net_device *dev)
263} 263}
264#endif /* CONFIG_NET_POLL_CONTROLLER */ 264#endif /* CONFIG_NET_POLL_CONTROLLER */
265 265
266static int veth_get_iflink(const struct net_device *dev)
267{
268 struct veth_priv *priv = netdev_priv(dev);
269 struct net_device *peer;
270 int iflink;
271
272 rcu_read_lock();
273 peer = rcu_dereference(priv->peer);
274 iflink = peer ? peer->ifindex : 0;
275 rcu_read_unlock();
276
277 return iflink;
278}
279
266static const struct net_device_ops veth_netdev_ops = { 280static const struct net_device_ops veth_netdev_ops = {
267 .ndo_init = veth_dev_init, 281 .ndo_init = veth_dev_init,
268 .ndo_open = veth_open, 282 .ndo_open = veth_open,
@@ -275,6 +289,7 @@ static const struct net_device_ops veth_netdev_ops = {
275#ifdef CONFIG_NET_POLL_CONTROLLER 289#ifdef CONFIG_NET_POLL_CONTROLLER
276 .ndo_poll_controller = veth_poll_controller, 290 .ndo_poll_controller = veth_poll_controller,
277#endif 291#endif
292 .ndo_get_iflink = veth_get_iflink,
278}; 293};
279 294
280#define VETH_FEATURES (NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_ALL_TSO | \ 295#define VETH_FEATURES (NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_ALL_TSO | \