net/cnxk: fix aged flows query

Message ID 20240202052137.1324084-1-psatheesh@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series net/cnxk: fix aged flows query |

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/github-robot: build success github build: passed
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-abi-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Satheesh Paul Antonysamy Feb. 2, 2024, 5:21 a.m. UTC
  From: Satheesh Paul <psatheesh@marvell.com>

After all aged flows are destroyed, the aged_flows bitmap
is free-ed. Querying aged flows tries to access this bitmap
resulting in a segmentation fault. Fixing this by not accessing
the bitmap if no aged flows are present.

Fixes: 357f5ebc8a24 ("common/cnxk: support flow aging")
Cc: stable@dpdk.org

Signed-off-by: Satheesh Paul <psatheesh@marvell.com>
Reviewed-by: Kiran Kumar K <kirankumark@marvell.com>
---
 drivers/common/cnxk/roc_npc_aging.c | 4 ++++
 drivers/net/cnxk/cnxk_flow.c        | 3 +++
 2 files changed, 7 insertions(+)
  

Comments

Jerin Jacob Feb. 2, 2024, 12:35 p.m. UTC | #1
On Fri, Feb 2, 2024 at 10:51 AM <psatheesh@marvell.com> wrote:
>
> From: Satheesh Paul <psatheesh@marvell.com>
>
> After all aged flows are destroyed, the aged_flows bitmap
> is free-ed. Querying aged flows tries to access this bitmap
> resulting in a segmentation fault. Fixing this by not accessing
> the bitmap if no aged flows are present.
>
> Fixes: 357f5ebc8a24 ("common/cnxk: support flow aging")
> Cc: stable@dpdk.org
>
> Signed-off-by: Satheesh Paul <psatheesh@marvell.com>
> Reviewed-by: Kiran Kumar K <kirankumark@marvell.com>

Applied to dpdk-next-net-mrvl/for-main. Thanks
  

Patch

diff --git a/drivers/common/cnxk/roc_npc_aging.c b/drivers/common/cnxk/roc_npc_aging.c
index 254dd2139b..e0f2dc2291 100644
--- a/drivers/common/cnxk/roc_npc_aging.c
+++ b/drivers/common/cnxk/roc_npc_aging.c
@@ -234,8 +234,11 @@  npc_age_flow_list_entry_delete(struct roc_npc *roc_npc,
 {
 	struct npc *npc = roc_npc_to_npc_priv(roc_npc);
 	struct npc_age_flow_list_head *list;
+	struct roc_npc_flow_age *flow_age;
 	struct npc_age_flow_entry *curr;
 
+	flow_age = &roc_npc->flow_age;
+
 	list = &npc->age_flow_list;
 	curr = TAILQ_FIRST(list);
 
@@ -244,6 +247,7 @@  npc_age_flow_list_entry_delete(struct roc_npc *roc_npc,
 
 	while (curr) {
 		if (flow->mcam_id == curr->flow->mcam_id) {
+			plt_bitmap_clear(flow_age->aged_flows, flow->mcam_id);
 			TAILQ_REMOVE(list, curr, next);
 			plt_free(curr);
 			break;
diff --git a/drivers/net/cnxk/cnxk_flow.c b/drivers/net/cnxk/cnxk_flow.c
index a92b61c332..4deccd1a67 100644
--- a/drivers/net/cnxk/cnxk_flow.c
+++ b/drivers/net/cnxk/cnxk_flow.c
@@ -616,6 +616,9 @@  cnxk_flow_get_aged_flows(struct rte_eth_dev *eth_dev, void **context,
 
 	flow_age = &roc_npc->flow_age;
 
+	if (!flow_age->age_flow_refcnt)
+		return 0;
+
 	do {
 		sn = plt_seqcount_read_begin(&flow_age->seq_cnt);