diff options
author | David Ahern <dsa@cumulusnetworks.com> | 2016-02-02 10:43:45 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-02-07 14:02:22 -0500 |
commit | 67eb03318bc5fe170ae832423fda7a23b0d801cf (patch) | |
tree | 9f5a83fb008781ba06e605a2ef88ec6d294ec24a | |
parent | 22fae97d863679994b951799dd4bbe7afd95897b (diff) |
net: Add support for fill_slave_info to VRF device
Allows userspace to have direct access to VRF table association
versus looking up master device and its table.
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/vrf.c | 21 | ||||
-rw-r--r-- | include/uapi/linux/if_link.h | 8 |
2 files changed, 29 insertions, 0 deletions
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c index 66addb7a7911..76e1fc9d8748 100644 --- a/drivers/net/vrf.c +++ b/drivers/net/vrf.c | |||
@@ -877,6 +877,24 @@ static int vrf_fillinfo(struct sk_buff *skb, | |||
877 | return nla_put_u32(skb, IFLA_VRF_TABLE, vrf->tb_id); | 877 | return nla_put_u32(skb, IFLA_VRF_TABLE, vrf->tb_id); |
878 | } | 878 | } |
879 | 879 | ||
880 | static size_t vrf_get_slave_size(const struct net_device *bond_dev, | ||
881 | const struct net_device *slave_dev) | ||
882 | { | ||
883 | return nla_total_size(sizeof(u32)); /* IFLA_VRF_PORT_TABLE */ | ||
884 | } | ||
885 | |||
886 | static int vrf_fill_slave_info(struct sk_buff *skb, | ||
887 | const struct net_device *vrf_dev, | ||
888 | const struct net_device *slave_dev) | ||
889 | { | ||
890 | struct net_vrf *vrf = netdev_priv(vrf_dev); | ||
891 | |||
892 | if (nla_put_u32(skb, IFLA_VRF_PORT_TABLE, vrf->tb_id)) | ||
893 | return -EMSGSIZE; | ||
894 | |||
895 | return 0; | ||
896 | } | ||
897 | |||
880 | static const struct nla_policy vrf_nl_policy[IFLA_VRF_MAX + 1] = { | 898 | static const struct nla_policy vrf_nl_policy[IFLA_VRF_MAX + 1] = { |
881 | [IFLA_VRF_TABLE] = { .type = NLA_U32 }, | 899 | [IFLA_VRF_TABLE] = { .type = NLA_U32 }, |
882 | }; | 900 | }; |
@@ -890,6 +908,9 @@ static struct rtnl_link_ops vrf_link_ops __read_mostly = { | |||
890 | .validate = vrf_validate, | 908 | .validate = vrf_validate, |
891 | .fill_info = vrf_fillinfo, | 909 | .fill_info = vrf_fillinfo, |
892 | 910 | ||
911 | .get_slave_size = vrf_get_slave_size, | ||
912 | .fill_slave_info = vrf_fill_slave_info, | ||
913 | |||
893 | .newlink = vrf_newlink, | 914 | .newlink = vrf_newlink, |
894 | .dellink = vrf_dellink, | 915 | .dellink = vrf_dellink, |
895 | .setup = vrf_setup, | 916 | .setup = vrf_setup, |
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index d3e90b91e07e..d452cea59020 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h | |||
@@ -405,6 +405,14 @@ enum { | |||
405 | 405 | ||
406 | #define IFLA_VRF_MAX (__IFLA_VRF_MAX - 1) | 406 | #define IFLA_VRF_MAX (__IFLA_VRF_MAX - 1) |
407 | 407 | ||
408 | enum { | ||
409 | IFLA_VRF_PORT_UNSPEC, | ||
410 | IFLA_VRF_PORT_TABLE, | ||
411 | __IFLA_VRF_PORT_MAX | ||
412 | }; | ||
413 | |||
414 | #define IFLA_VRF_PORT_MAX (__IFLA_VRF_PORT_MAX - 1) | ||
415 | |||
408 | /* IPVLAN section */ | 416 | /* IPVLAN section */ |
409 | enum { | 417 | enum { |
410 | IFLA_IPVLAN_UNSPEC, | 418 | IFLA_IPVLAN_UNSPEC, |