aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorJiri Pirko <jiri@resnulli.us>2013-07-29 12:16:50 -0400
committerDavid S. Miller <davem@davemloft.net>2013-07-30 20:31:24 -0400
commit66cae9ed6bc46b8cc57a9693f99f69926f3cc7ef (patch)
tree32b187701434051c013863bdd7c65d3a69f7b64d /net/core
parent66b52b0dc82c5c88d769dc1c7d44cf45d0deb07c (diff)
rtnl: export physical port id via RT netlink
Signed-off-by: Jiri Pirko <jiri@resnulli.us> Acked-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: Narendra K <narendra_k@dell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/rtnetlink.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 3de740834d1f..0b2972c59b97 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -767,7 +767,8 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
767 + rtnl_vfinfo_size(dev, ext_filter_mask) /* IFLA_VFINFO_LIST */ 767 + rtnl_vfinfo_size(dev, ext_filter_mask) /* IFLA_VFINFO_LIST */
768 + rtnl_port_size(dev) /* IFLA_VF_PORTS + IFLA_PORT_SELF */ 768 + rtnl_port_size(dev) /* IFLA_VF_PORTS + IFLA_PORT_SELF */
769 + rtnl_link_get_size(dev) /* IFLA_LINKINFO */ 769 + rtnl_link_get_size(dev) /* IFLA_LINKINFO */
770 + rtnl_link_get_af_size(dev); /* IFLA_AF_SPEC */ 770 + rtnl_link_get_af_size(dev) /* IFLA_AF_SPEC */
771 + nla_total_size(MAX_PHYS_PORT_ID_LEN); /* IFLA_PHYS_PORT_ID */
771} 772}
772 773
773static int rtnl_vf_ports_fill(struct sk_buff *skb, struct net_device *dev) 774static int rtnl_vf_ports_fill(struct sk_buff *skb, struct net_device *dev)
@@ -846,6 +847,24 @@ static int rtnl_port_fill(struct sk_buff *skb, struct net_device *dev)
846 return 0; 847 return 0;
847} 848}
848 849
850static int rtnl_phys_port_id_fill(struct sk_buff *skb, struct net_device *dev)
851{
852 int err;
853 struct netdev_phys_port_id ppid;
854
855 err = dev_get_phys_port_id(dev, &ppid);
856 if (err) {
857 if (err == -EOPNOTSUPP)
858 return 0;
859 return err;
860 }
861
862 if (nla_put(skb, IFLA_PHYS_PORT_ID, ppid.id_len, ppid.id))
863 return -EMSGSIZE;
864
865 return 0;
866}
867
849static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, 868static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
850 int type, u32 pid, u32 seq, u32 change, 869 int type, u32 pid, u32 seq, u32 change,
851 unsigned int flags, u32 ext_filter_mask) 870 unsigned int flags, u32 ext_filter_mask)
@@ -913,6 +932,9 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
913 goto nla_put_failure; 932 goto nla_put_failure;
914 } 933 }
915 934
935 if (rtnl_phys_port_id_fill(skb, dev))
936 goto nla_put_failure;
937
916 attr = nla_reserve(skb, IFLA_STATS, 938 attr = nla_reserve(skb, IFLA_STATS,
917 sizeof(struct rtnl_link_stats)); 939 sizeof(struct rtnl_link_stats));
918 if (attr == NULL) 940 if (attr == NULL)
@@ -1113,6 +1135,7 @@ const struct nla_policy ifla_policy[IFLA_MAX+1] = {
1113 [IFLA_PROMISCUITY] = { .type = NLA_U32 }, 1135 [IFLA_PROMISCUITY] = { .type = NLA_U32 },
1114 [IFLA_NUM_TX_QUEUES] = { .type = NLA_U32 }, 1136 [IFLA_NUM_TX_QUEUES] = { .type = NLA_U32 },
1115 [IFLA_NUM_RX_QUEUES] = { .type = NLA_U32 }, 1137 [IFLA_NUM_RX_QUEUES] = { .type = NLA_U32 },
1138 [IFLA_PHYS_PORT_ID] = { .type = NLA_BINARY, .len = MAX_PHYS_PORT_ID_LEN },
1116}; 1139};
1117EXPORT_SYMBOL(ifla_policy); 1140EXPORT_SYMBOL(ifla_policy);
1118 1141