Skip to contentSkip to conversation

net/cnxk: fix aged flows query

PATCH Applied [email protected] 2 participants 2 messages Feb 2, 2024 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/cnxk: fix aged flows query

From: Satheesh Paul <[email protected]>

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")
---
 drivers/common/cnxk/roc_npc_aging.c | 4 ++++
 drivers/net/cnxk/cnxk_flow.c        | 3 +++
 2 files changed, 7 insertions(+)
drivers/common/cnxk/roc_npc_aging.c +4 -0
index 254dd2139b..e0f2dc2291 100644
@@ -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;
drivers/net/cnxk/cnxk_flow.c +3 -0
index a92b61c332..4deccd1a67 100644
@@ -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);
 
Signature · 1 line
2.39.2
Applied
#1 lore raw
Quoted 8 lines · On Fri, Feb 2, 2024 at 10:51 AM <[email protected]> wrote:

From: Satheesh Paul <[email protected]>

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.

Quoted 5 lines
Fixes 357f5ebc8a24 ("common/cnxk: support flow aging")

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