patch 'app/testpmd: fix use of indirect action after port close' has been queued to stable release 21.11.2

Kevin Traynor ktraynor at redhat.com
Thu Jun 9 13:36:18 CEST 2022


Hi,

FYI, your patch has been queued to stable release 21.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 06/13/22. 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/057ebd40e3db01e87cd7bc7029674c4bd8d97580

Thanks.

Kevin

---
>From 057ebd40e3db01e87cd7bc7029674c4bd8d97580 Mon Sep 17 00:00:00 2001
From: Dmitry Kozlyuk <dkozlyuk at nvidia.com>
Date: Mon, 7 Mar 2022 18:48:21 +0200
Subject: [PATCH] app/testpmd: fix use of indirect action after port close

[ upstream commit f7352c176bbf131728445680ee08961a67cc09a6 ]

When a port was closed, indirect actions could remain
with their handles no longer valid.
If a newly attached device was assigned the same ID as the closed port,
those indirect actions became accessible again.
Any attempt to use them resulted in an undefined behavior.
Automatically flush indirect actions when a port is closed.

Fixes: 4b61b8774be9 ("ethdev: introduce indirect flow action")

Signed-off-by: Dmitry Kozlyuk <dkozlyuk at nvidia.com>
Acked-by: Matan Azrad <matan at nvidia.com>
Acked-by: Aman Singh <aman.deep.singh at intel.com>
---
 app/test-pmd/config.c  | 31 +++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.c |  1 +
 app/test-pmd/testpmd.h |  1 +
 3 files changed, 33 insertions(+)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index face2f805f..ae2ace42cc 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1758,4 +1758,35 @@ port_action_handle_destroy(portid_t port_id,
 }
 
+int
+port_action_handle_flush(portid_t port_id)
+{
+	struct rte_port *port;
+	struct port_indirect_action **tmp;
+	int ret = 0;
+
+	if (port_id_is_invalid(port_id, ENABLED_WARN) ||
+	    port_id == (portid_t)RTE_PORT_ALL)
+		return -EINVAL;
+	port = &ports[port_id];
+	tmp = &port->actions_list;
+	while (*tmp != NULL) {
+		struct rte_flow_error error;
+		struct port_indirect_action *pia = *tmp;
+
+		/* Poisoning to make sure PMDs update it in case of error. */
+		memset(&error, 0x44, sizeof(error));
+		if (pia->handle != NULL &&
+		    rte_flow_action_handle_destroy
+					(port_id, pia->handle, &error) != 0) {
+			printf("Indirect action #%u not destroyed\n", pia->id);
+			ret = port_flow_complain(&error);
+			tmp = &pia->next;
+		} else {
+			*tmp = pia->next;
+			free(pia);
+		}
+	}
+	return ret;
+}
 
 /** Get indirect action by port + id */
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index dd1f286d59..5c62f48efd 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3218,4 +3218,5 @@ close_port(portid_t pid)
 			port_flow_flush(pi);
 			port_flex_item_flush(pi);
+			port_action_handle_flush(pi);
 			rte_eth_dev_close(pi);
 		}
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 943217f2bd..59bb9e3c66 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -885,4 +885,5 @@ int port_action_handle_create(portid_t port_id, uint32_t id,
 int port_action_handle_destroy(portid_t port_id,
 			       uint32_t n, const uint32_t *action);
+int port_action_handle_flush(portid_t port_id);
 struct rte_flow_action_handle *port_action_handle_get_by_id(portid_t port_id,
 							    uint32_t id);
-- 
2.34.3

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-06-09 12:34:30.499983894 +0100
+++ 0031-app-testpmd-fix-use-of-indirect-action-after-port-cl.patch	2022-06-09 12:34:29.710980581 +0100
@@ -1 +1 @@
-From f7352c176bbf131728445680ee08961a67cc09a6 Mon Sep 17 00:00:00 2001
+From 057ebd40e3db01e87cd7bc7029674c4bd8d97580 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit f7352c176bbf131728445680ee08961a67cc09a6 ]
+
@@ -14 +15,0 @@
-Cc: stable at dpdk.org
@@ -26 +27 @@
-index 1b1e738f83..dc9ef1e868 100644
+index face2f805f..ae2ace42cc 100644
@@ -29 +30 @@
-@@ -1906,4 +1906,35 @@ port_action_handle_destroy(portid_t port_id,
+@@ -1758,4 +1758,35 @@ port_action_handle_destroy(portid_t port_id,
@@ -66 +67 @@
-index 777763f749..5b742911a8 100644
+index dd1f286d59..5c62f48efd 100644
@@ -69 +70 @@
-@@ -3217,4 +3217,5 @@ close_port(portid_t pid)
+@@ -3218,4 +3218,5 @@ close_port(portid_t pid)
@@ -76 +77 @@
-index f04a9a11b4..8ee682b362 100644
+index 943217f2bd..59bb9e3c66 100644
@@ -79 +80 @@
-@@ -911,4 +911,5 @@ int port_action_handle_create(portid_t port_id, uint32_t id,
+@@ -885,4 +885,5 @@ int port_action_handle_create(portid_t port_id, uint32_t id,



More information about the stable mailing list