@@ -190,6 +190,8 @@ static int igb_ndo_set_vf_vlan(struct net_device *netdev,
190190static int igb_ndo_set_vf_bw (struct net_device * , int , int , int );
191191static int igb_ndo_set_vf_spoofchk (struct net_device * netdev , int vf ,
192192 bool setting );
193+ static int igb_ndo_set_vf_trust (struct net_device * netdev , int vf ,
194+ bool setting );
193195static int igb_ndo_get_vf_config (struct net_device * netdev , int vf ,
194196 struct ifla_vf_info * ivi );
195197static void igb_check_vf_rate_limit (struct igb_adapter * );
@@ -2527,6 +2529,7 @@ static const struct net_device_ops igb_netdev_ops = {
25272529 .ndo_set_vf_vlan = igb_ndo_set_vf_vlan ,
25282530 .ndo_set_vf_rate = igb_ndo_set_vf_bw ,
25292531 .ndo_set_vf_spoofchk = igb_ndo_set_vf_spoofchk ,
2532+ .ndo_set_vf_trust = igb_ndo_set_vf_trust ,
25302533 .ndo_get_vf_config = igb_ndo_get_vf_config ,
25312534#ifdef CONFIG_NET_POLL_CONTROLLER
25322535 .ndo_poll_controller = igb_netpoll ,
@@ -6383,6 +6386,9 @@ static int igb_vf_configure(struct igb_adapter *adapter, int vf)
63836386 /* By default spoof check is enabled for all VFs */
63846387 adapter -> vf_data [vf ].spoofchk_enabled = true;
63856388
6389+ /* By default VFs are not trusted */
6390+ adapter -> vf_data [vf ].trusted = false;
6391+
63866392 return 0 ;
63876393}
63886394
@@ -6940,13 +6946,13 @@ static int igb_set_vf_mac_filter(struct igb_adapter *adapter, const int vf,
69406946 }
69416947 break ;
69426948 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 ) {
69446951 dev_warn (& pdev -> dev ,
69456952 "VF %d requested MAC filter but is administratively denied\n" ,
69466953 vf );
69476954 return - EINVAL ;
69486955 }
6949-
69506956 if (!is_valid_ether_addr (addr )) {
69516957 dev_warn (& pdev -> dev ,
69526958 "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)
69987004 int ret = 0 ;
69997005
70007006 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 ) {
70027009 dev_warn (& pdev -> dev ,
70037010 "VF %d attempted to override administratively set MAC address\nReload the VF driver to resume operations\n" ,
70047011 vf );
@@ -8934,6 +8941,22 @@ static int igb_ndo_set_vf_spoofchk(struct net_device *netdev, int vf,
89348941 return 0 ;
89358942}
89368943
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+
89378960static int igb_ndo_get_vf_config (struct net_device * netdev ,
89388961 int vf , struct ifla_vf_info * ivi )
89398962{
@@ -8947,6 +8970,7 @@ static int igb_ndo_get_vf_config(struct net_device *netdev,
89478970 ivi -> vlan = adapter -> vf_data [vf ].pf_vlan ;
89488971 ivi -> qos = adapter -> vf_data [vf ].pf_qos ;
89498972 ivi -> spoofchk = adapter -> vf_data [vf ].spoofchk_enabled ;
8973+ ivi -> trusted = adapter -> vf_data [vf ].trusted ;
89508974 return 0 ;
89518975}
89528976
0 commit comments