[PATCH] net/mlx5: prevent querying aged flows on uninit port

Bing Zhao bingz at nvidia.com
Wed Feb 21 04:23:22 CET 2024


In HWS template API, the aging mechanism doesn't support shared host
mode now. When the guest's counter is set to 0, the aging won't be
initialized.

The current implementation didn't prevent the user from querying the
aged flows on the uninitialized port. The access of invalid pointers
would cause a crash.

With this commit, the flag of the per port aging initialization will
be checked. This would help to get rid of the invalid accessing.

Fixes: 04a4de756e14 ("net/mlx5: support flow age action with HWS")
Cc: michaelba at nvidia.com
Cc: stable at dpdk.org

Signed-off-by: Bing Zhao <bingz at nvidia.com>
Acked-by: Suanming Mou <suanmingm at nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_hw.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 3bb3a9a178..0e6d6e02dd 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -10937,6 +10937,10 @@ flow_hw_get_q_aged_flows(struct rte_eth_dev *dev, uint32_t queue_id,
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
 					  NULL, "empty context");
+	if (!priv->hws_age_req)
+		return rte_flow_error_set(error, ENOENT,
+					  RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+					  NULL, "No aging initialized");
 	if (priv->hws_strict_queue) {
 		if (queue_id >= age_info->hw_q_age->nb_rings)
 			return rte_flow_error_set(error, EINVAL,
-- 
2.34.1



More information about the stable mailing list