History

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.

David Ahern committed 10 years ago

Commit 67eb0331 parent 22fae972 files · +29 −0Browse files

Unified · Split

2 files
  1. drivers/net/vrf.c +21 −0
  2. include/uapi/linux/if_link.h +8 −0
drivers/net/vrf.c+21−0
@@ -877,6 +877,24 @@ static int vrf_fillinfo(struct sk_buff *skb, · 876 unmodified lines
877877 return nla_put_u32(skb, IFLA_VRF_TABLE, vrf->tb_id);
878878 }
879879
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+
880898 static const struct nla_policy vrf_nl_policy[IFLA_VRF_MAX + 1] = {
881899 [IFLA_VRF_TABLE] = { .type = NLA_U32 },
882900 };
@@ -890,6 +908,9 @@ static struct rtnl_link_ops vrf_link_ops __read_mostly = { · 7 unmodified lines
890908 .validate = vrf_validate,
891909 .fill_info = vrf_fillinfo,
892910
911+ .get_slave_size = vrf_get_slave_size,
912+ .fill_slave_info = vrf_fill_slave_info,
913+
893914 .newlink = vrf_newlink,
894915 .dellink = vrf_dellink,
895916 .setup = vrf_setup,
include/uapi/linux/if_link.h+8−0
@@ -405,6 +405,14 @@ enum { · 404 unmodified lines
405405
406406 #define IFLA_VRF_MAX (__IFLA_VRF_MAX - 1)
407407
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+
408416 /* IPVLAN section */
409417 enum {
410418 IFLA_IPVLAN_UNSPEC,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t