diff options
author | Masatake YAMATO <yamato@redhat.com> | 2013-10-03 22:34:21 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-10-08 15:23:25 -0400 |
commit | 612c337306f00dc8d396830212de51c475844791 (patch) | |
tree | daaf06eece2745046fc44946aa24c12d65e1b571 /drivers/net/veth.c | |
parent | 33bc801dddc14f0f96b79e453ec51cecfe5ed612 (diff) |
veth: Showing peer of veth type dev in ip link (kernel side)
ip link has ability to show extra information of net work device if
kernel provides sunh information. With this patch veth driver can
provide its peer ifindex information to ip command via netlink
interface.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/veth.c')
-rw-r--r-- | drivers/net/veth.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/net/veth.c b/drivers/net/veth.c index eee1f19ef1e9..54187b9c0efc 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c | |||
@@ -434,6 +434,25 @@ static const struct nla_policy veth_policy[VETH_INFO_MAX + 1] = { | |||
434 | [VETH_INFO_PEER] = { .len = sizeof(struct ifinfomsg) }, | 434 | [VETH_INFO_PEER] = { .len = sizeof(struct ifinfomsg) }, |
435 | }; | 435 | }; |
436 | 436 | ||
437 | static size_t veth_get_size(const struct net_device *dev) | ||
438 | { | ||
439 | return nla_total_size(sizeof(u64)) + /* VETH_INFO_PEER */ | ||
440 | 0; | ||
441 | } | ||
442 | |||
443 | static int veth_fill_info(struct sk_buff *skb, const struct net_device *dev) | ||
444 | { | ||
445 | struct veth_priv *priv = netdev_priv(dev); | ||
446 | struct net_device *peer = rtnl_dereference(priv->peer); | ||
447 | u64 peer_ifindex; | ||
448 | |||
449 | peer_ifindex = peer ? peer->ifindex : 0; | ||
450 | if (nla_put_u64(skb, VETH_INFO_PEER, peer_ifindex)) | ||
451 | return -EMSGSIZE; | ||
452 | |||
453 | return 0; | ||
454 | } | ||
455 | |||
437 | static struct rtnl_link_ops veth_link_ops = { | 456 | static struct rtnl_link_ops veth_link_ops = { |
438 | .kind = DRV_NAME, | 457 | .kind = DRV_NAME, |
439 | .priv_size = sizeof(struct veth_priv), | 458 | .priv_size = sizeof(struct veth_priv), |
@@ -443,6 +462,8 @@ static struct rtnl_link_ops veth_link_ops = { | |||
443 | .dellink = veth_dellink, | 462 | .dellink = veth_dellink, |
444 | .policy = veth_policy, | 463 | .policy = veth_policy, |
445 | .maxtype = VETH_INFO_MAX, | 464 | .maxtype = VETH_INFO_MAX, |
465 | .get_size = veth_get_size, | ||
466 | .fill_info = veth_fill_info, | ||
446 | }; | 467 | }; |
447 | 468 | ||
448 | /* | 469 | /* |