OSDN Git Service

ice: Don't remove VLAN filters that were never programmed
authorAkeem G Abodunrin <akeem.g.abodunrin@intel.com>
Tue, 16 Apr 2019 17:21:16 +0000 (10:21 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Sat, 4 May 2019 21:07:34 +0000 (14:07 -0700)
In case of non-trusted VFs, it is possible to program VLAN filter far
less than what is requested by the VF originally, thereby makes number of
VLAN elements being tracked by VF different from actual VLAN tags. This
patch makes sure that we are not attempting to remove VLAN filter that
does not exist.

Signed-off-by: Akeem G Abodunrin <akeem.g.abodunrin@intel.com>
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/ice/ice_lib.c
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c

index 947730d..83d0aef 100644 (file)
@@ -1616,7 +1616,11 @@ int ice_vsi_kill_vlan(struct ice_vsi *vsi, u16 vid)
        list_add(&list->list_entry, &tmp_add_list);
 
        status = ice_remove_vlan(&pf->hw, &tmp_add_list);
-       if (status) {
+       if (status == ICE_ERR_DOES_NOT_EXIST) {
+               dev_dbg(&pf->pdev->dev,
+                       "Failed to remove VLAN %d on VSI %i, it does not exist, status: %d\n",
+                       vid, vsi->vsi_num, status);
+       } else if (status) {
                dev_err(&pf->pdev->dev,
                        "Error removing VLAN %d on vsi %i error: %d\n",
                        vid, vsi->vsi_num, status);
index abc9587..f4b466c 100644 (file)
@@ -2402,7 +2402,17 @@ static int ice_vc_process_vlan_msg(struct ice_vf *vf, u8 *msg, bool add_v)
                        }
                }
        } else {
-               for (i = 0; i < vfl->num_elements; i++) {
+               /* In case of non_trusted VF, number of VLAN elements passed
+                * to PF for removal might be greater than number of VLANs
+                * filter programmed for that VF - So, use actual number of
+                * VLANS added earlier with add VLAN opcode. In order to avoid
+                * removing VLAN that doesn't exist, which result to sending
+                * erroneous failed message back to the VF
+                */
+               int num_vf_vlan;
+
+               num_vf_vlan = vf->num_vlan;
+               for (i = 0; i < vfl->num_elements && i < num_vf_vlan; i++) {
                        u16 vid = vfl->vlan_id[i];
 
                        /* Make sure ice_vsi_kill_vlan is successful before