patch 'net/mlx5: fix leak of flow action data list' has been queued to stable release 24.11.2

Kevin Traynor ktraynor at redhat.com
Thu Feb 13 10:57:48 CET 2025


Hi,

FYI, your patch has been queued to stable release 24.11.2

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 02/17/25. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/fbc041172e9c2008acd74e8e09f2b9ef0dd4624e

Thanks.

Kevin

---
>From fbc041172e9c2008acd74e8e09f2b9ef0dd4624e Mon Sep 17 00:00:00 2001
From: Bing Zhao <bingz at nvidia.com>
Date: Tue, 26 Nov 2024 10:34:40 +0200
Subject: [PATCH] net/mlx5: fix leak of flow action data list

[ upstream commit d68bcfb6da221ee114835db8c2ab9449d277590f ]

In the actions construction for HWS non-template API, the `masks`
parameter is always set to NULL and all the actions will be
translated in the "construct" stage as non-fixed ones.

In the stage of translating actions template, the actions data would
be allocated from the pool and managed in a list. The list would be
released when destroying the template with the actions. In the NT2HWS
implementation, the temporary template was freed directly and the
actions will be destroyed with the flow rule deletion. No other rule
would use this list anymore.

The actions data in the list should be freed when the actions
construction is done.

Fixes: ff4064d5b1fe ("net/mlx5: support bulk actions in non-template flow")

Signed-off-by: Bing Zhao <bingz at nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski at nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_hw.c | 63 ++++++++++++++++++++-------------
 1 file changed, 39 insertions(+), 24 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 50dbaa27ab..1de6b889a7 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -967,8 +967,5 @@ __flow_hw_actions_release(struct rte_eth_dev *dev, struct mlx5_hw_actions *acts)
 
 /**
- * Destroy DR actions created by action template.
- *
- * For DR actions created during table creation's action translate.
- * Need to destroy the DR action when destroying the table.
+ * Release the action data back into the pool without destroy any action.
  *
  * @param[in] dev
@@ -977,6 +974,6 @@ __flow_hw_actions_release(struct rte_eth_dev *dev, struct mlx5_hw_actions *acts)
  *   Pointer to the template HW steering DR actions.
  */
-static void
-__flow_hw_action_template_destroy(struct rte_eth_dev *dev, struct mlx5_hw_actions *acts)
+static inline void
+__flow_hw_act_data_flush(struct rte_eth_dev *dev, struct mlx5_hw_actions *acts)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
@@ -988,5 +985,21 @@ __flow_hw_action_template_destroy(struct rte_eth_dev *dev, struct mlx5_hw_action
 		mlx5_ipool_free(priv->acts_ipool, data->idx);
 	}
+}
 
+/*
+ * Destroy DR actions created by action template.
+ *
+ * For DR actions created during table creation's action translate.
+ * Need to destroy the DR action when destroying the table.
+ *
+ * @param[in] dev
+ *   Pointer to the rte_eth_dev structure.
+ * @param[in] acts
+ *   Pointer to the template HW steering DR actions.
+ */
+static void
+__flow_hw_action_template_destroy(struct rte_eth_dev *dev, struct mlx5_hw_actions *acts)
+{
+	__flow_hw_act_data_flush(dev, acts);
 	__flow_hw_actions_release(dev, acts);
 }
@@ -13493,12 +13506,12 @@ flow_nta_build_template_mask(const struct rte_flow_action actions[],
 static int
 flow_hw_translate_flow_actions(struct rte_eth_dev *dev,
-			  const struct rte_flow_attr *attr,
-			  const struct rte_flow_action actions[],
-			  struct rte_flow_hw *flow,
-			  struct mlx5_flow_hw_action_params *ap,
-			  struct mlx5_hw_actions *hw_acts,
-			  uint64_t item_flags, uint64_t action_flags,
-			  bool external,
-			  struct rte_flow_error *error)
+			       const struct rte_flow_attr *attr,
+			       const struct rte_flow_action actions[],
+			       struct rte_flow_hw *flow,
+			       struct mlx5_flow_hw_action_params *ap,
+			       struct mlx5_hw_actions *hw_acts,
+			       uint64_t item_flags, uint64_t action_flags,
+			       bool external,
+			       struct rte_flow_error *error)
 {
 	int ret = 0;
@@ -13543,5 +13556,5 @@ flow_hw_translate_flow_actions(struct rte_eth_dev *dev,
 	if (!table)
 		return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_ACTION,
-				   actions, "Failed to allocate dummy table");
+					  actions, "Failed to allocate dummy table");
 	at = __flow_hw_actions_template_create(dev, &template_attr, actions, masks, true, error);
 	if (!at) {
@@ -13557,5 +13570,5 @@ flow_hw_translate_flow_actions(struct rte_eth_dev *dev,
 	table->ats[0].action_template = at;
 	ret = __flow_hw_translate_actions_template(dev, &table->cfg, hw_acts, at,
-		&table->mpctx, true, error);
+						   &table->mpctx, true, error);
 	if (ret)
 		goto end;
@@ -13563,19 +13576,21 @@ flow_hw_translate_flow_actions(struct rte_eth_dev *dev,
 	ret = flow_hw_encap_decap_resource_register(dev, table, hw_acts, flow, error);
 	if (ret)
-		goto clean_up;
+		goto end;
 	ret = flow_hw_modify_hdr_resource_register(dev, table, hw_acts, flow, error);
 	if (ret)
-		goto clean_up;
+		goto end;
 	table->ats[0].acts = *hw_acts;
 	ret = flow_hw_actions_construct(dev, flow, ap,
-		&table->ats[0], item_flags, table,
-		actions, hw_acts->rule_acts, 0, error);
+					&table->ats[0], item_flags, table,
+					actions, hw_acts->rule_acts, 0, error);
 	if (ret)
-		goto clean_up;
+		goto end;
 	goto end;
-clean_up:
-	/* Make sure that there is no garbage in the actions. */
-	__flow_hw_action_template_destroy(dev, hw_acts);
 end:
+	if (ret)
+		/* Make sure that there is no garbage in the actions. */
+		__flow_hw_action_template_destroy(dev, hw_acts);
+	else
+		__flow_hw_act_data_flush(dev, hw_acts);
 	if (table)
 		mlx5_free(table);
-- 
2.48.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2025-02-12 17:29:36.830390319 +0000
+++ 0021-net-mlx5-fix-leak-of-flow-action-data-list.patch	2025-02-12 17:29:34.215945124 +0000
@@ -1 +1 @@
-From d68bcfb6da221ee114835db8c2ab9449d277590f Mon Sep 17 00:00:00 2001
+From fbc041172e9c2008acd74e8e09f2b9ef0dd4624e Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit d68bcfb6da221ee114835db8c2ab9449d277590f ]
+
@@ -21 +22,0 @@
-Cc: stable at dpdk.org



More information about the stable mailing list