DPDK patches and discussions
 help / color / mirror / Atom feed
From: Danylo Vodopianov <dvo-plv@napatech.com>
To: thomas@monjalon.net, aman.deep.singh@intel.com,
	yuying.zhang@intel.com, orika@nvidia.com, mko-plv@napatech.com,
	ckm@napatech.com, dsosnowski@nvidia.com, sil-plv@napatech.com
Cc: getelson@nvidia.com, akozyrev@nvidia.com, dev@dpdk.org,
	stable@dpdk.org, ferruh.yigit@amd.com
Subject: [PATCH v3 2/2] app/testpmd: fix aged flow destroy
Date: Mon, 18 Nov 2024 19:03:23 +0100	[thread overview]
Message-ID: <20241118180323.2046886-3-dvo-plv@napatech.com> (raw)
In-Reply-To: <20241118180323.2046886-1-dvo-plv@napatech.com>

port_flow_destroy() function never assumed that rule array can be freed
when it's executing, and port_flow_aged() just violated that assumption.

In case of flow async create failure, it tries to do a cleanup, but it
wrongly removes a 1st flow (with id 0). pf->id is not set at this
moment and it always is 0, thus 1st flow is removed. A local copy of
flow->id must be used to call of port_flow_destroy() to avoid access
and processing of flow->id after the flow is removed.

Fixes: de956d5ecf08 ("app/testpmd: support age shared action context")
Cc: stable@dpdk.org

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

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index c831166431..28d45568ac 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -4160,8 +4160,10 @@ port_flow_aged(portid_t port_id, uint8_t destroy)
 		}
 		type = (enum age_action_context_type *)contexts[idx];
 		switch (*type) {
-		case ACTION_AGE_CONTEXT_TYPE_FLOW:
+		case ACTION_AGE_CONTEXT_TYPE_FLOW: {
+			uint64_t flow_id;
 			ctx.pf = container_of(type, struct port_flow, age_type);
+			flow_id = ctx.pf->id;
 			printf("%-20s\t%" PRIu64 "\t%" PRIu32 "\t%" PRIu32
 								 "\t%c%c%c\t\n",
 			       "Flow",
@@ -4172,9 +4174,10 @@ port_flow_aged(portid_t port_id, uint8_t destroy)
 			       ctx.pf->rule.attr->egress ? 'e' : '-',
 			       ctx.pf->rule.attr->transfer ? 't' : '-');
 			if (destroy && !port_flow_destroy(port_id, 1,
-							  &ctx.pf->id, false))
+							  &flow_id, false))
 				total++;
 			break;
+		}
 		case ACTION_AGE_CONTEXT_TYPE_INDIRECT_ACTION:
 			ctx.pia = container_of(type,
 					struct port_indirect_action, age_type);
-- 
2.43.5


  parent reply	other threads:[~2024-11-18 18:03 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-31 15:00 [PATCH v1 0/2] Testpmd flow update/destroy fixes Danylo Vodopianov
2024-10-31 15:00 ` [PATCH v1 1/2] app/testpmd: fix flow update Danylo Vodopianov
2024-11-15 17:39   ` Dariusz Sosnowski
2024-10-31 15:00 ` [PATCH v1 2/2] app/testpmd: fix flow destroy Danylo Vodopianov
2024-11-15 17:40   ` Dariusz Sosnowski
2024-11-11 13:35 ` [PATCH v1 0/2] Testpmd flow update/destroy fixes Ferruh Yigit
2024-11-14 14:12   ` Serhii Iliushyk
2024-11-14 20:18     ` Thomas Monjalon
2024-11-18 10:25 ` [PATCH v2 " Danylo Vodopianov
2024-11-18 10:25   ` [PATCH v2 1/2] app/testpmd: fix flow update Danylo Vodopianov
2024-11-18 10:38     ` Dariusz Sosnowski
2024-11-18 10:25   ` [PATCH v2 2/2] app/testpmd: fix aged flow destroy Danylo Vodopianov
2024-11-18 10:43   ` [PATCH v2 0/2] Testpmd flow update/destroy fixes Dariusz Sosnowski
     [not found]     ` <PAWP190MB2160717526F6D67E34952D2E8B272@PAWP190MB2160.EURP190.PROD.OUTLOOK.COM>
2024-11-18 10:59       ` Dariusz Sosnowski
2024-11-18 11:26 ` Danylo Vodopianov
2024-11-18 11:26   ` [PATCH v2 1/2] app/testpmd: fix flow update Danylo Vodopianov
2024-11-18 12:40     ` Dariusz Sosnowski
2024-11-18 18:02     ` [PATCH v2 0/2] Testpmd flow update/destroy fixes Danylo Vodopianov
2024-11-18 18:02       ` [PATCH v2 1/2] app/testpmd: fix flow update Danylo Vodopianov
2024-11-18 18:02       ` [PATCH v2 2/2] app/testpmd: fix aged flow destroy Danylo Vodopianov
2024-11-18 18:03     ` [PATCH v3 0/2] Testpmd flow update/destroy fixes Danylo Vodopianov
2024-11-18 18:03       ` [PATCH v3 1/2] app/testpmd: fix flow update Danylo Vodopianov
2024-11-18 18:25         ` Dariusz Sosnowski
2024-11-18 18:03       ` Danylo Vodopianov [this message]
2024-11-18 18:25         ` [PATCH v3 2/2] app/testpmd: fix aged flow destroy Dariusz Sosnowski
2024-11-18 11:26   ` [PATCH v2 " Danylo Vodopianov
2024-11-18 13:37     ` Dariusz Sosnowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241118180323.2046886-3-dvo-plv@napatech.com \
    --to=dvo-plv@napatech.com \
    --cc=akozyrev@nvidia.com \
    --cc=aman.deep.singh@intel.com \
    --cc=ckm@napatech.com \
    --cc=dev@dpdk.org \
    --cc=dsosnowski@nvidia.com \
    --cc=ferruh.yigit@amd.com \
    --cc=getelson@nvidia.com \
    --cc=mko-plv@napatech.com \
    --cc=orika@nvidia.com \
    --cc=sil-plv@napatech.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    --cc=yuying.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).