netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] i40e: Fix limit imprecise of the number of MAC/VLAN that can be added for VFs
@ 2017-09-27  6:58 w00273186
  2017-09-27 11:33 ` Sergei Shtylyov
  0 siblings, 1 reply; 3+ messages in thread
From: w00273186 @ 2017-09-27  6:58 UTC (permalink / raw)
  To: davem, jeffrey.t.kirsher; +Cc: netdev, intel-wired-lan, caihe, Yunjian Wang

From: Yunjian Wang <wangyunjian@huawei.com>

Now it don't limit the number of MAC/VLAN strictly. When there is more
elements in the virtchnl MAC/VLAN list, it can still add successfully.

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 27 +++++++++++++---------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index 4d1e670..285b96a 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -2065,11 +2065,6 @@ static inline int i40e_check_vf_permission(struct i40e_vf *vf, u8 *macaddr)
 		dev_err(&pf->pdev->dev,
 			"VF attempting to override administratively set MAC address, reload the VF driver to resume normal operation\n");
 		ret = -EPERM;
-	} else if ((vf->num_mac >= I40E_VC_MAX_MAC_ADDR_PER_VF) &&
-		   !test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps)) {
-		dev_err(&pf->pdev->dev,
-			"VF is not trusted, switch the VF to trusted to add more functionality\n");
-		ret = -EPERM;
 	}
 	return ret;
 }
@@ -2128,6 +2123,15 @@ static int i40e_vc_add_mac_addr_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
 		} else {
 			vf->num_mac++;
 		}
+
+		if ((vf->num_mac >= I40E_VC_MAX_MAC_ADDR_PER_VF) &&
+		    !test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps)) {
+			dev_err(&pf->pdev->dev,
+				"VF is not trusted, switch the VF to trusted to add more functionality\n");
+			ret = -EPERM;
+			spin_unlock_bh(&vsi->mac_filter_hash_lock);
+			goto error_param;
+		}
 	}
 	spin_unlock_bh(&vsi->mac_filter_hash_lock);
 
@@ -2221,12 +2225,6 @@ static int i40e_vc_add_vlan_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
 	i40e_status aq_ret = 0;
 	int i;
 
-	if ((vf->num_vlan >= I40E_VC_MAX_VLAN_PER_VF) &&
-	    !test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps)) {
-		dev_err(&pf->pdev->dev,
-			"VF is not trusted, switch the VF to trusted to add more VLAN addresses\n");
-		goto error_param;
-	}
 	if (!test_bit(I40E_VF_STATE_ACTIVE, &vf->vf_states) ||
 	    !i40e_vc_isvalid_vsi_id(vf, vsi_id)) {
 		aq_ret = I40E_ERR_PARAM;
@@ -2269,6 +2267,13 @@ static int i40e_vc_add_vlan_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
 			dev_err(&pf->pdev->dev,
 				"Unable to add VLAN filter %d for VF %d, error %d\n",
 				vfl->vlan_id[i], vf->vf_id, ret);
+		if ((vf->num_vlan >= I40E_VC_MAX_VLAN_PER_VF) &&
+		    !test_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps)) {
+			dev_err(&pf->pdev->dev,
+				"VF is not trusted, switch the VF to trusted to add more VLAN addresses\n");
+			aq_ret = -EPERM;
+			goto error_param;
+		}
 	}
 
 error_param:
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] i40e: Fix limit imprecise of the number of MAC/VLAN that can be added for VFs
  2017-09-27  6:58 [PATCH net] i40e: Fix limit imprecise of the number of MAC/VLAN that can be added for VFs w00273186
@ 2017-09-27 11:33 ` Sergei Shtylyov
  2017-09-28  1:32   ` wangyunjian
  0 siblings, 1 reply; 3+ messages in thread
From: Sergei Shtylyov @ 2017-09-27 11:33 UTC (permalink / raw)
  To: w00273186, davem, jeffrey.t.kirsher; +Cc: netdev, intel-wired-lan, caihe

Hello!

On 9/27/2017 9:58 AM, w00273186 wrote:

> From: Yunjian Wang <wangyunjian@huawei.com>
> 
> Now it don't limit the number of MAC/VLAN strictly. When there is more

    Doesn't.

> elements in the virtchnl MAC/VLAN list, it can still add successfully.
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>

[...]

MBR, Sergei

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH net] i40e: Fix limit imprecise of the number of MAC/VLAN that can be added for VFs
  2017-09-27 11:33 ` Sergei Shtylyov
@ 2017-09-28  1:32   ` wangyunjian
  0 siblings, 0 replies; 3+ messages in thread
From: wangyunjian @ 2017-09-28  1:32 UTC (permalink / raw)
  To: Sergei Shtylyov, davem@davemloft.net, jeffrey.t.kirsher@intel.com
  Cc: netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org, caihe

Thanks, I will send the v2 later.

> -----Original Message-----
> From: Sergei Shtylyov [mailto:sergei.shtylyov@cogentembedded.com]
> Sent: Wednesday, September 27, 2017 7:34 PM
> To: wangyunjian <wangyunjian@huawei.com>; davem@davemloft.net;
> jeffrey.t.kirsher@intel.com
> Cc: netdev@vger.kernel.org; intel-wired-lan@lists.osuosl.org; caihe
> <caihe@huawei.com>
> Subject: Re: [PATCH net] i40e: Fix limit imprecise of the number of
> MAC/VLAN that can be added for VFs
> 
> Hello!
> 
> On 9/27/2017 9:58 AM, w00273186 wrote:
> 
> > From: Yunjian Wang <wangyunjian@huawei.com>
> >
> > Now it don't limit the number of MAC/VLAN strictly. When there is more
> 
>     Doesn't.
> 
> > elements in the virtchnl MAC/VLAN list, it can still add successfully.
> >
> > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> 
> [...]
> 
> MBR, Sergei

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-28  1:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-27  6:58 [PATCH net] i40e: Fix limit imprecise of the number of MAC/VLAN that can be added for VFs w00273186
2017-09-27 11:33 ` Sergei Shtylyov
2017-09-28  1:32   ` wangyunjian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).