[v1,2/2] app/testpmd: fix flow destroy

Message ID 20241031150010.2991953-3-dvo-plv@napatech.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Testpmd flow update/destroy fixes |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Danylo Vodopianov Oct. 31, 2024, 3 p.m. UTC
Avoid removal of additional flows after requested number of flows has
been already removed.

Issue with removal of multiple flows is internal testpmd bug at
port_flow_destroy(). This function goes through all flows and compares
given flow ‘id’ with them. However in some cases it can advance pointer
with “given ID” and thus remove additional flow.

Fixes: de956d5ecf08 ("app/testpmd: support age shared action context")

Signed-off-by: Danylo Vodopianov <dvo-plv@napatech.com>
---
 app/test-pmd/config.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Comments

Dariusz Sosnowski Nov. 15, 2024, 5:40 p.m. UTC | #1
Hi,

> -----Original Message-----
> From: Danylo Vodopianov <dvo-plv@napatech.com>
> Sent: Thursday, October 31, 2024 16:00
> To: NBU-Contact-Thomas Monjalon (EXTERNAL) <thomas@monjalon.net>;
> aman.deep.singh@intel.com; yuying.zhang@intel.com; Ori Kam
> <orika@nvidia.com>; mko-plv@napatech.com; ckm@napatech.com; sil-
> plv@napatech.com
> Cc: dev@dpdk.org; ferruh.yigit@amd.com
> Subject: [PATCH v1 2/2] app/testpmd: fix flow destroy

I think it would be better to rename the commit to: "app/testpmd: fix aged flow destroy"

> 
> Avoid removal of additional flows after requested number of flows has been
> already removed.
> 
> Issue with removal of multiple flows is internal testpmd bug at
> port_flow_destroy(). This function goes through all flows and compares given
> flow ‘id’ with them. However in some cases it can advance pointer with “given ID”
> and thus remove additional flow.

I'm not sure that the issue with port_flow_destroy() is really a bug.
port_flow_destroy() function never assumed that rule array can be freed when it's executing,
and port_flow_aged() just violated that assumption.

Could you please rephrase the commit message to include that info?

> 
> Fixes: de956d5ecf08 ("app/testpmd: support age shared action context")

This fix will have to be taken into LTS releases. Please add "Cc: stable@dpdk.org"

> 
> Signed-off-by: Danylo Vodopianov <dvo-plv@napatech.com>
> ---
>  app/test-pmd/config.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index
> bf50f6adef..50c4b018c1 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -4170,8 +4170,12 @@ port_flow_aged(portid_t port_id, uint8_t destroy)
>                                ctx.pf->rule.attr->ingress ? 'i' : '-',
>                                ctx.pf->rule.attr->egress ? 'e' : '-',
>                                ctx.pf->rule.attr->transfer ? 't' : '-');
> +                       /* use local copy of id as ctx.pf is freed by
> +                        * port_flow_destroy() during processing
> +                        */

After the commit message is rephrased, I don't think this comment will be needed.

> +                       uint64_t flow_id = ctx.pf->id;

Please move the flow_id variable declaration to the beginning of the case.
Also, please enclose the case's body in braces, so that flow_id declaration does not leak to the following cases.

>                         if (destroy && !port_flow_destroy(port_id, 1,
> -                                                         &ctx.pf->id, false))
> +                                                         &flow_id,
> + false))
>                                 total++;
>                         break;
>                 case ACTION_AGE_CONTEXT_TYPE_INDIRECT_ACTION:
> --
> 2.43.5

Best regards,
Dariusz Sosnowski
  

Patch

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index bf50f6adef..50c4b018c1 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -4170,8 +4170,12 @@  port_flow_aged(portid_t port_id, uint8_t destroy)
 			       ctx.pf->rule.attr->ingress ? 'i' : '-',
 			       ctx.pf->rule.attr->egress ? 'e' : '-',
 			       ctx.pf->rule.attr->transfer ? 't' : '-');
+			/* use local copy of id as ctx.pf is freed by
+			 * port_flow_destroy() during processing
+			 */
+			uint64_t flow_id = ctx.pf->id;
 			if (destroy && !port_flow_destroy(port_id, 1,
-							  &ctx.pf->id, false))
+							  &flow_id, false))
 				total++;
 			break;
 		case ACTION_AGE_CONTEXT_TYPE_INDIRECT_ACTION: