Commit f94484b7 authored by Jacob Keller's avatar Jacob Keller Committed by Jeff Kirsher

i40e: don't allow i40e_vsi_(add|kill)_vlan to operate when VID<1

Now that we have the separate i40e_(add|rm)_vlan_all_mac functions, we
should not be using the i40e_vsi_kill_vlan or i40e_vsi_add_vlan
functions when PVID is set or when VID is less than 1. This allows us to
remove some checks in i40e_vsi_add_vlan and ensures that callers which
need to handle VID=0 or VID=-1 don't accidentally invoke the VLAN mode
handling used to convert filters when entering VLAN mode. We also update
the functions to take u16 instead of s16 as well since they no longer
expect to be called with VID=I40E_VLAN_ANY.

Change-ID: Ibddf44a8bb840dde8ceef2a4fdb92fd953b05a57
Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 8fe809a9
...@@ -852,9 +852,9 @@ int i40e_close(struct net_device *netdev); ...@@ -852,9 +852,9 @@ int i40e_close(struct net_device *netdev);
int i40e_vsi_open(struct i40e_vsi *vsi); int i40e_vsi_open(struct i40e_vsi *vsi);
void i40e_vlan_stripping_disable(struct i40e_vsi *vsi); void i40e_vlan_stripping_disable(struct i40e_vsi *vsi);
int i40e_add_vlan_all_mac(struct i40e_vsi *vsi, s16 vid); int i40e_add_vlan_all_mac(struct i40e_vsi *vsi, s16 vid);
int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid); int i40e_vsi_add_vlan(struct i40e_vsi *vsi, u16 vid);
void i40e_rm_vlan_all_mac(struct i40e_vsi *vsi, s16 vid); void i40e_rm_vlan_all_mac(struct i40e_vsi *vsi, s16 vid);
void i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid); void i40e_vsi_kill_vlan(struct i40e_vsi *vsi, u16 vid);
struct i40e_mac_filter *i40e_put_mac_in_vlan(struct i40e_vsi *vsi, struct i40e_mac_filter *i40e_put_mac_in_vlan(struct i40e_vsi *vsi,
const u8 *macaddr); const u8 *macaddr);
int i40e_del_mac_all_vlan(struct i40e_vsi *vsi, const u8 *macaddr); int i40e_del_mac_all_vlan(struct i40e_vsi *vsi, const u8 *macaddr);
......
...@@ -2568,12 +2568,15 @@ int i40e_add_vlan_all_mac(struct i40e_vsi *vsi, s16 vid) ...@@ -2568,12 +2568,15 @@ int i40e_add_vlan_all_mac(struct i40e_vsi *vsi, s16 vid)
/** /**
* i40e_vsi_add_vlan - Add VSI membership for given VLAN * i40e_vsi_add_vlan - Add VSI membership for given VLAN
* @vsi: the VSI being configured * @vsi: the VSI being configured
* @vid: VLAN id to be added (0 = untagged only , -1 = any) * @vid: VLAN id to be added
**/ **/
int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid) int i40e_vsi_add_vlan(struct i40e_vsi *vsi, u16 vid)
{ {
int err; int err;
if (!vid || vsi->info.pvid)
return -EINVAL;
/* Locked once because all functions invoked below iterates list*/ /* Locked once because all functions invoked below iterates list*/
spin_lock_bh(&vsi->mac_filter_hash_lock); spin_lock_bh(&vsi->mac_filter_hash_lock);
err = i40e_add_vlan_all_mac(vsi, vid); err = i40e_add_vlan_all_mac(vsi, vid);
...@@ -2616,10 +2619,13 @@ void i40e_rm_vlan_all_mac(struct i40e_vsi *vsi, s16 vid) ...@@ -2616,10 +2619,13 @@ void i40e_rm_vlan_all_mac(struct i40e_vsi *vsi, s16 vid)
/** /**
* i40e_vsi_kill_vlan - Remove VSI membership for given VLAN * i40e_vsi_kill_vlan - Remove VSI membership for given VLAN
* @vsi: the VSI being configured * @vsi: the VSI being configured
* @vid: VLAN id to be removed (0 = untagged only , -1 = any) * @vid: VLAN id to be removed
**/ **/
void i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid) void i40e_vsi_kill_vlan(struct i40e_vsi *vsi, u16 vid)
{ {
if (!vid || vsi->info.pvid)
return;
spin_lock_bh(&vsi->mac_filter_hash_lock); spin_lock_bh(&vsi->mac_filter_hash_lock);
i40e_rm_vlan_all_mac(vsi, vid); i40e_rm_vlan_all_mac(vsi, vid);
spin_unlock_bh(&vsi->mac_filter_hash_lock); spin_unlock_bh(&vsi->mac_filter_hash_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment