linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: prestera: flower: fix destroy tmpl in chain
@ 2022-02-16 14:43 Volodymyr Mytnyk
  2022-02-18  4:51 ` Jakub Kicinski
  2022-02-18  4:52 ` Jakub Kicinski
  0 siblings, 2 replies; 3+ messages in thread
From: Volodymyr Mytnyk @ 2022-02-16 14:43 UTC (permalink / raw)
  To: netdev
  Cc: Taras Chornyi, Mickey Rachamim, Serhiy Pshyk, Volodymyr Mytnyk,
	Taras Chornyi, David S. Miller, Jakub Kicinski, linux-kernel

From: Volodymyr Mytnyk <vmytnyk@marvell.com>

Fix flower destroy template callback to release template
only for specific tc chain instead of all chain tempaltes.

The issue was intruduced by previous commit that introduced
multi-chain support.

Fixes: fa5d824ce5dd ("net: prestera: acl: add multi-chain support offload")

Signed-off-by: Volodymyr Mytnyk <vmytnyk@marvell.com>
---
 .../ethernet/marvell/prestera/prestera_flower.c    | 24 ++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/marvell/prestera/prestera_flower.c b/drivers/net/ethernet/marvell/prestera/prestera_flower.c
index 580fb986496a..9587707e3148 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_flower.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_flower.c
@@ -12,6 +12,14 @@ struct prestera_flower_template {
 	u32 chain_index;
 };
 
+static void
+prestera_flower_template_free(struct prestera_flower_template *template)
+{
+	prestera_acl_ruleset_put(template->ruleset);
+	list_del(&template->list);
+	kfree(template);
+}
+
 void prestera_flower_template_cleanup(struct prestera_flow_block *block)
 {
 	struct prestera_flower_template *template;
@@ -20,9 +28,7 @@ void prestera_flower_template_cleanup(struct prestera_flow_block *block)
 	/* put the reference to all rulesets kept in tmpl create */
 	list_for_each_safe(pos, n, &block->template_list) {
 		template = list_entry(pos, typeof(*template), list);
-		prestera_acl_ruleset_put(template->ruleset);
-		list_del(&template->list);
-		kfree(template);
+		prestera_flower_template_free(template);
 	}
 }
 
@@ -423,7 +429,17 @@ int prestera_flower_tmplt_create(struct prestera_flow_block *block,
 void prestera_flower_tmplt_destroy(struct prestera_flow_block *block,
 				   struct flow_cls_offload *f)
 {
-	prestera_flower_template_cleanup(block);
+	struct prestera_flower_template *template;
+	struct list_head *pos, *n;
+
+	list_for_each_safe(pos, n, &block->template_list) {
+		template = list_entry(pos, typeof(*template), list);
+		if (template->chain_index == f->common.chain_index) {
+			/* put the reference to the ruleset kept in create */
+			prestera_flower_template_free(template);
+			return;
+		}
+	}
 }
 
 int prestera_flower_stats(struct prestera_flow_block *block,
-- 
2.7.4


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

* Re: [PATCH net-next] net: prestera: flower: fix destroy tmpl in chain
  2022-02-16 14:43 [PATCH net-next] net: prestera: flower: fix destroy tmpl in chain Volodymyr Mytnyk
@ 2022-02-18  4:51 ` Jakub Kicinski
  2022-02-18  4:52 ` Jakub Kicinski
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2022-02-18  4:51 UTC (permalink / raw)
  To: Volodymyr Mytnyk
  Cc: netdev, Taras Chornyi, Mickey Rachamim, Serhiy Pshyk,
	Volodymyr Mytnyk, Taras Chornyi, David S. Miller, linux-kernel

On Wed, 16 Feb 2022 16:43:44 +0200 Volodymyr Mytnyk wrote:
> +	list_for_each_safe(pos, n, &block->template_list) {
> +		template = list_entry(pos, typeof(*template), list);

nit: list_for_each_entry_safe()

> +		if (template->chain_index == f->common.chain_index) {
> +			/* put the reference to the ruleset kept in create */
> +			prestera_flower_template_free(template);
> +			return;
> +		}
> +	}

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

* Re: [PATCH net-next] net: prestera: flower: fix destroy tmpl in chain
  2022-02-16 14:43 [PATCH net-next] net: prestera: flower: fix destroy tmpl in chain Volodymyr Mytnyk
  2022-02-18  4:51 ` Jakub Kicinski
@ 2022-02-18  4:52 ` Jakub Kicinski
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2022-02-18  4:52 UTC (permalink / raw)
  To: Volodymyr Mytnyk
  Cc: netdev, Taras Chornyi, Mickey Rachamim, Serhiy Pshyk,
	Volodymyr Mytnyk, Taras Chornyi, David S. Miller, linux-kernel

On Wed, 16 Feb 2022 16:43:44 +0200 Volodymyr Mytnyk wrote:
> Fixes: fa5d824ce5dd ("net: prestera: acl: add multi-chain support offload")
> 
> Signed-off-by: Volodymyr Mytnyk <vmytnyk@marvell.com>

Ah, and please don't put empty lines between tags.

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

end of thread, other threads:[~2022-02-18  4:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16 14:43 [PATCH net-next] net: prestera: flower: fix destroy tmpl in chain Volodymyr Mytnyk
2022-02-18  4:51 ` Jakub Kicinski
2022-02-18  4:52 ` Jakub Kicinski

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).