diff options
author | Greg Rose <gregory.v.rose@intel.com> | 2011-10-07 23:05:24 -0400 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2011-10-16 16:15:38 -0400 |
commit | 5f8444a3fa617076f8da51a3e8ecce01a5d7f738 (patch) | |
tree | 196aa6b0e949ceef2bd7b639c300e40bc0bdb9ad | |
parent | a90b412cb8c7ccc1689f9ea130883d00a1f0a5bb (diff) |
if_link: Add additional parameter to IFLA_VF_INFO for spoof checking
Add configuration setting for drivers to turn spoof checking on or off
for discrete VFs.
v2 - Fix indentation problem, wrap the ifla_vf_info structure in
#ifdef __KERNEL__ to prevent user space from accessing and
change function paramater for the spoof check setting netdev
op from u8 to bool.
v3 - Preset spoof check setting to -1 so that user space tools such
as ip can detect that the driver didn't report a spoofcheck
setting. Prevents incorrect display of spoof check settings
for drivers that don't report it.
Signed-off-by: Greg Rose <gregory.v.rose@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
-rw-r--r-- | include/linux/if_link.h | 10 | ||||
-rw-r--r-- | include/linux/netdevice.h | 3 | ||||
-rw-r--r-- | net/core/rtnetlink.c | 33 |
3 files changed, 43 insertions, 3 deletions
diff --git a/include/linux/if_link.h b/include/linux/if_link.h index 0ee969a5593d..c52d4b5f872a 100644 --- a/include/linux/if_link.h +++ b/include/linux/if_link.h | |||
@@ -279,6 +279,7 @@ enum { | |||
279 | IFLA_VF_MAC, /* Hardware queue specific attributes */ | 279 | IFLA_VF_MAC, /* Hardware queue specific attributes */ |
280 | IFLA_VF_VLAN, | 280 | IFLA_VF_VLAN, |
281 | IFLA_VF_TX_RATE, /* TX Bandwidth Allocation */ | 281 | IFLA_VF_TX_RATE, /* TX Bandwidth Allocation */ |
282 | IFLA_VF_SPOOFCHK, /* Spoof Checking on/off switch */ | ||
282 | __IFLA_VF_MAX, | 283 | __IFLA_VF_MAX, |
283 | }; | 284 | }; |
284 | 285 | ||
@@ -300,13 +301,22 @@ struct ifla_vf_tx_rate { | |||
300 | __u32 rate; /* Max TX bandwidth in Mbps, 0 disables throttling */ | 301 | __u32 rate; /* Max TX bandwidth in Mbps, 0 disables throttling */ |
301 | }; | 302 | }; |
302 | 303 | ||
304 | struct ifla_vf_spoofchk { | ||
305 | __u32 vf; | ||
306 | __u32 setting; | ||
307 | }; | ||
308 | #ifdef __KERNEL__ | ||
309 | |||
310 | /* We don't want this structure exposed to user space */ | ||
303 | struct ifla_vf_info { | 311 | struct ifla_vf_info { |
304 | __u32 vf; | 312 | __u32 vf; |
305 | __u8 mac[32]; | 313 | __u8 mac[32]; |
306 | __u32 vlan; | 314 | __u32 vlan; |
307 | __u32 qos; | 315 | __u32 qos; |
308 | __u32 tx_rate; | 316 | __u32 tx_rate; |
317 | __u32 spoofchk; | ||
309 | }; | 318 | }; |
319 | #endif | ||
310 | 320 | ||
311 | /* VF ports management section | 321 | /* VF ports management section |
312 | * | 322 | * |
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 43b32983ba10..0db1f5f6d4a8 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -781,6 +781,7 @@ struct netdev_tc_txq { | |||
781 | * int (*ndo_set_vf_mac)(struct net_device *dev, int vf, u8* mac); | 781 | * int (*ndo_set_vf_mac)(struct net_device *dev, int vf, u8* mac); |
782 | * int (*ndo_set_vf_vlan)(struct net_device *dev, int vf, u16 vlan, u8 qos); | 782 | * int (*ndo_set_vf_vlan)(struct net_device *dev, int vf, u16 vlan, u8 qos); |
783 | * int (*ndo_set_vf_tx_rate)(struct net_device *dev, int vf, int rate); | 783 | * int (*ndo_set_vf_tx_rate)(struct net_device *dev, int vf, int rate); |
784 | * int (*ndo_set_vf_spoofchk)(struct net_device *dev, int vf, bool setting); | ||
784 | * int (*ndo_get_vf_config)(struct net_device *dev, | 785 | * int (*ndo_get_vf_config)(struct net_device *dev, |
785 | * int vf, struct ifla_vf_info *ivf); | 786 | * int vf, struct ifla_vf_info *ivf); |
786 | * int (*ndo_set_vf_port)(struct net_device *dev, int vf, | 787 | * int (*ndo_set_vf_port)(struct net_device *dev, int vf, |
@@ -900,6 +901,8 @@ struct net_device_ops { | |||
900 | int queue, u16 vlan, u8 qos); | 901 | int queue, u16 vlan, u8 qos); |
901 | int (*ndo_set_vf_tx_rate)(struct net_device *dev, | 902 | int (*ndo_set_vf_tx_rate)(struct net_device *dev, |
902 | int vf, int rate); | 903 | int vf, int rate); |
904 | int (*ndo_set_vf_spoofchk)(struct net_device *dev, | ||
905 | int vf, bool setting); | ||
903 | int (*ndo_get_vf_config)(struct net_device *dev, | 906 | int (*ndo_get_vf_config)(struct net_device *dev, |
904 | int vf, | 907 | int vf, |
905 | struct ifla_vf_info *ivf); | 908 | struct ifla_vf_info *ivf); |
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 39f8dd6a2821..9083e82bdae5 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -731,7 +731,8 @@ static inline int rtnl_vfinfo_size(const struct net_device *dev) | |||
731 | size += num_vfs * | 731 | size += num_vfs * |
732 | (nla_total_size(sizeof(struct ifla_vf_mac)) + | 732 | (nla_total_size(sizeof(struct ifla_vf_mac)) + |
733 | nla_total_size(sizeof(struct ifla_vf_vlan)) + | 733 | nla_total_size(sizeof(struct ifla_vf_vlan)) + |
734 | nla_total_size(sizeof(struct ifla_vf_tx_rate))); | 734 | nla_total_size(sizeof(struct ifla_vf_tx_rate)) + |
735 | nla_total_size(sizeof(struct ifla_vf_spoofchk))); | ||
735 | return size; | 736 | return size; |
736 | } else | 737 | } else |
737 | return 0; | 738 | return 0; |
@@ -954,13 +955,27 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, | |||
954 | struct ifla_vf_mac vf_mac; | 955 | struct ifla_vf_mac vf_mac; |
955 | struct ifla_vf_vlan vf_vlan; | 956 | struct ifla_vf_vlan vf_vlan; |
956 | struct ifla_vf_tx_rate vf_tx_rate; | 957 | struct ifla_vf_tx_rate vf_tx_rate; |
958 | struct ifla_vf_spoofchk vf_spoofchk; | ||
959 | |||
960 | /* | ||
961 | * Not all SR-IOV capable drivers support the | ||
962 | * spoofcheck query. Preset to -1 so the user | ||
963 | * space tool can detect that the driver didn't | ||
964 | * report anything. | ||
965 | */ | ||
966 | ivi.spoofchk = -1; | ||
957 | if (dev->netdev_ops->ndo_get_vf_config(dev, i, &ivi)) | 967 | if (dev->netdev_ops->ndo_get_vf_config(dev, i, &ivi)) |
958 | break; | 968 | break; |
959 | vf_mac.vf = vf_vlan.vf = vf_tx_rate.vf = ivi.vf; | 969 | vf_mac.vf = |
970 | vf_vlan.vf = | ||
971 | vf_tx_rate.vf = | ||
972 | vf_spoofchk.vf = ivi.vf; | ||
973 | |||
960 | memcpy(vf_mac.mac, ivi.mac, sizeof(ivi.mac)); | 974 | memcpy(vf_mac.mac, ivi.mac, sizeof(ivi.mac)); |
961 | vf_vlan.vlan = ivi.vlan; | 975 | vf_vlan.vlan = ivi.vlan; |
962 | vf_vlan.qos = ivi.qos; | 976 | vf_vlan.qos = ivi.qos; |
963 | vf_tx_rate.rate = ivi.tx_rate; | 977 | vf_tx_rate.rate = ivi.tx_rate; |
978 | vf_spoofchk.setting = ivi.spoofchk; | ||
964 | vf = nla_nest_start(skb, IFLA_VF_INFO); | 979 | vf = nla_nest_start(skb, IFLA_VF_INFO); |
965 | if (!vf) { | 980 | if (!vf) { |
966 | nla_nest_cancel(skb, vfinfo); | 981 | nla_nest_cancel(skb, vfinfo); |
@@ -968,7 +983,10 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, | |||
968 | } | 983 | } |
969 | NLA_PUT(skb, IFLA_VF_MAC, sizeof(vf_mac), &vf_mac); | 984 | NLA_PUT(skb, IFLA_VF_MAC, sizeof(vf_mac), &vf_mac); |
970 | NLA_PUT(skb, IFLA_VF_VLAN, sizeof(vf_vlan), &vf_vlan); | 985 | NLA_PUT(skb, IFLA_VF_VLAN, sizeof(vf_vlan), &vf_vlan); |
971 | NLA_PUT(skb, IFLA_VF_TX_RATE, sizeof(vf_tx_rate), &vf_tx_rate); | 986 | NLA_PUT(skb, IFLA_VF_TX_RATE, sizeof(vf_tx_rate), |
987 | &vf_tx_rate); | ||
988 | NLA_PUT(skb, IFLA_VF_SPOOFCHK, sizeof(vf_spoofchk), | ||
989 | &vf_spoofchk); | ||
972 | nla_nest_end(skb, vf); | 990 | nla_nest_end(skb, vf); |
973 | } | 991 | } |
974 | nla_nest_end(skb, vfinfo); | 992 | nla_nest_end(skb, vfinfo); |
@@ -1202,6 +1220,15 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr *attr) | |||
1202 | ivt->rate); | 1220 | ivt->rate); |
1203 | break; | 1221 | break; |
1204 | } | 1222 | } |
1223 | case IFLA_VF_SPOOFCHK: { | ||
1224 | struct ifla_vf_spoofchk *ivs; | ||
1225 | ivs = nla_data(vf); | ||
1226 | err = -EOPNOTSUPP; | ||
1227 | if (ops->ndo_set_vf_spoofchk) | ||
1228 | err = ops->ndo_set_vf_spoofchk(dev, ivs->vf, | ||
1229 | ivs->setting); | ||
1230 | break; | ||
1231 | } | ||
1205 | default: | 1232 | default: |
1206 | err = -EINVAL; | 1233 | err = -EINVAL; |
1207 | break; | 1234 | break; |