diff mbox series

[next,S84-V2,02/13] i40e: Fix for adding multiple ethtool filters on the same location

Message ID 20171227123242.22356-2-alice.michael@intel.com
State Accepted
Delegated to: Jeff Kirsher
Headers show
Series None | expand

Commit Message

Michael, Alice Dec. 27, 2017, 12:32 p.m. UTC
From: Patryk Małek <patryk.malek@intel.com>

This patch reorders i40e_add_del_fdir and i40e_update_ethtool_fdir_entry
calls so that we first remove an already existing filter (inside
i40e_update_ethtool_fdir_entry using i40e_add_del_fdir) and then
we add a new one with i40e_add_del_fdir.
After applying this patch, creating multiple identical filters (with
the same location) one after another doesn't revert their behavior
but behaves correctly.

Signed-off-by: Patryk Małek <patryk.malek@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Malek, Patryk Jan. 3, 2018, 11:04 a.m. UTC | #1
ACK

-----Original Message-----
From: Michael, Alice 

Sent: Wednesday, December 27, 2017 13:33
To: Michael, Alice <alice.michael@intel.com>; intel-wired-lan@lists.osuosl.org
Cc: Malek, Patryk <patryk.malek@intel.com>
Subject: [next PATCH S84-V2 02/13] i40e: Fix for adding multiple ethtool filters on the same location

From: Patryk Małek <patryk.malek@intel.com>


This patch reorders i40e_add_del_fdir and i40e_update_ethtool_fdir_entry calls so that we first remove an already existing filter (inside i40e_update_ethtool_fdir_entry using i40e_add_del_fdir) and then we add a new one with i40e_add_del_fdir.
After applying this patch, creating multiple identical filters (with the same location) one after another doesn't revert their behavior but behaves correctly.

Signed-off-by: Patryk Małek <patryk.malek@intel.com>

---
 drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index 86329a3..099b170 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -3939,19 +3939,19 @@ static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,
 		input->flex_offset = userdef.flex_offset;
 	}
 
-	ret = i40e_add_del_fdir(vsi, input, true);
-	if (ret)
-		goto free_input;
-
 	/* Add the input filter to the fdir_input_list, possibly replacing
 	 * a previous filter. Do not free the input structure after adding it
 	 * to the list as this would cause a use-after-free bug.
 	 */
 	i40e_update_ethtool_fdir_entry(vsi, input, fsp->location, NULL);
-
+	ret = i40e_add_del_fdir(vsi, input, true);
+	if (ret)
+		goto remove_sw_rule;
 	return 0;
 
-free_input:
+remove_sw_rule:
+	hlist_del(&input->fdir_node);
+	pf->fdir_pf_active_filters--;
 	kfree(input);
 	return ret;
 }
--
2.9.5

--------------------------------------------------------------------

Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.

Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek
przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by
others is strictly prohibited.
Bowers, AndrewX Jan. 4, 2018, 9:47 p.m. UTC | #2
> -----Original Message-----

> From: Intel-wired-lan [mailto:intel-wired-lan-bounces@osuosl.org] On

> Behalf Of Alice Michael

> Sent: Wednesday, December 27, 2017 4:33 AM

> To: Michael, Alice <alice.michael@intel.com>; intel-wired-

> lan@lists.osuosl.org

> Subject: [Intel-wired-lan] [next PATCH S84-V2 02/13] i40e: Fix for adding

> multiple ethtool filters on the same location

> 

> From: Patryk Małek <patryk.malek@intel.com>

> 

> This patch reorders i40e_add_del_fdir and i40e_update_ethtool_fdir_entry

> calls so that we first remove an already existing filter (inside

> i40e_update_ethtool_fdir_entry using i40e_add_del_fdir) and then we add

> a new one with i40e_add_del_fdir.

> After applying this patch, creating multiple identical filters (with the same

> location) one after another doesn't revert their behavior but behaves

> correctly.

> 

> Signed-off-by: Patryk Małek <patryk.malek@intel.com>

> ---

>  drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 12 ++++++------

>  1 file changed, 6 insertions(+), 6 deletions(-)


Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index 86329a3..099b170 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -3939,19 +3939,19 @@  static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi,
 		input->flex_offset = userdef.flex_offset;
 	}
 
-	ret = i40e_add_del_fdir(vsi, input, true);
-	if (ret)
-		goto free_input;
-
 	/* Add the input filter to the fdir_input_list, possibly replacing
 	 * a previous filter. Do not free the input structure after adding it
 	 * to the list as this would cause a use-after-free bug.
 	 */
 	i40e_update_ethtool_fdir_entry(vsi, input, fsp->location, NULL);
-
+	ret = i40e_add_del_fdir(vsi, input, true);
+	if (ret)
+		goto remove_sw_rule;
 	return 0;
 
-free_input:
+remove_sw_rule:
+	hlist_del(&input->fdir_node);
+	pf->fdir_pf_active_filters--;
 	kfree(input);
 	return ret;
 }