@@ -190,6 +190,8 @@ static int igb_ndo_set_vf_vlan(struct net_device *netdev,
190
190
static int igb_ndo_set_vf_bw (struct net_device * , int , int , int );
191
191
static int igb_ndo_set_vf_spoofchk (struct net_device * netdev , int vf ,
192
192
bool setting );
193
+ static int igb_ndo_set_vf_trust (struct net_device * netdev , int vf ,
194
+ bool setting );
193
195
static int igb_ndo_get_vf_config (struct net_device * netdev , int vf ,
194
196
struct ifla_vf_info * ivi );
195
197
static void igb_check_vf_rate_limit (struct igb_adapter * );
@@ -2527,6 +2529,7 @@ static const struct net_device_ops igb_netdev_ops = {
2527
2529
.ndo_set_vf_vlan = igb_ndo_set_vf_vlan ,
2528
2530
.ndo_set_vf_rate = igb_ndo_set_vf_bw ,
2529
2531
.ndo_set_vf_spoofchk = igb_ndo_set_vf_spoofchk ,
2532
+ .ndo_set_vf_trust = igb_ndo_set_vf_trust ,
2530
2533
.ndo_get_vf_config = igb_ndo_get_vf_config ,
2531
2534
#ifdef CONFIG_NET_POLL_CONTROLLER
2532
2535
.ndo_poll_controller = igb_netpoll ,
@@ -6383,6 +6386,9 @@ static int igb_vf_configure(struct igb_adapter *adapter, int vf)
6383
6386
/* By default spoof check is enabled for all VFs */
6384
6387
adapter -> vf_data [vf ].spoofchk_enabled = true;
6385
6388
6389
+ /* By default VFs are not trusted */
6390
+ adapter -> vf_data [vf ].trusted = false;
6391
+
6386
6392
return 0 ;
6387
6393
}
6388
6394
@@ -6940,13 +6946,13 @@ static int igb_set_vf_mac_filter(struct igb_adapter *adapter, const int vf,
6940
6946
}
6941
6947
break ;
6942
6948
case E1000_VF_MAC_FILTER_ADD :
6943
- if (vf_data -> flags & IGB_VF_FLAG_PF_SET_MAC ) {
6949
+ if ((vf_data -> flags & IGB_VF_FLAG_PF_SET_MAC ) &&
6950
+ !vf_data -> trusted ) {
6944
6951
dev_warn (& pdev -> dev ,
6945
6952
"VF %d requested MAC filter but is administratively denied\n" ,
6946
6953
vf );
6947
6954
return - EINVAL ;
6948
6955
}
6949
-
6950
6956
if (!is_valid_ether_addr (addr )) {
6951
6957
dev_warn (& pdev -> dev ,
6952
6958
"VF %d attempted to set invalid MAC filter\n" ,
@@ -6998,7 +7004,8 @@ static int igb_set_vf_mac_addr(struct igb_adapter *adapter, u32 *msg, int vf)
6998
7004
int ret = 0 ;
6999
7005
7000
7006
if (!info ) {
7001
- if (vf_data -> flags & IGB_VF_FLAG_PF_SET_MAC ) {
7007
+ if ((vf_data -> flags & IGB_VF_FLAG_PF_SET_MAC ) &&
7008
+ !vf_data -> trusted ) {
7002
7009
dev_warn (& pdev -> dev ,
7003
7010
"VF %d attempted to override administratively set MAC address\nReload the VF driver to resume operations\n" ,
7004
7011
vf );
@@ -8934,6 +8941,22 @@ static int igb_ndo_set_vf_spoofchk(struct net_device *netdev, int vf,
8934
8941
return 0 ;
8935
8942
}
8936
8943
8944
+ static int igb_ndo_set_vf_trust (struct net_device * netdev , int vf , bool setting )
8945
+ {
8946
+ struct igb_adapter * adapter = netdev_priv (netdev );
8947
+
8948
+ if (vf >= adapter -> vfs_allocated_count )
8949
+ return - EINVAL ;
8950
+ if (adapter -> vf_data [vf ].trusted == setting )
8951
+ return 0 ;
8952
+
8953
+ adapter -> vf_data [vf ].trusted = setting ;
8954
+
8955
+ dev_info (& adapter -> pdev -> dev , "VF %u is %strusted\n" ,
8956
+ vf , setting ? "" : "not " );
8957
+ return 0 ;
8958
+ }
8959
+
8937
8960
static int igb_ndo_get_vf_config (struct net_device * netdev ,
8938
8961
int vf , struct ifla_vf_info * ivi )
8939
8962
{
@@ -8947,6 +8970,7 @@ static int igb_ndo_get_vf_config(struct net_device *netdev,
8947
8970
ivi -> vlan = adapter -> vf_data [vf ].pf_vlan ;
8948
8971
ivi -> qos = adapter -> vf_data [vf ].pf_qos ;
8949
8972
ivi -> spoofchk = adapter -> vf_data [vf ].spoofchk_enabled ;
8973
+ ivi -> trusted = adapter -> vf_data [vf ].trusted ;
8950
8974
return 0 ;
8951
8975
}
8952
8976
0 commit comments