[1/9] net/mlx5/hws: skip RTE item when inserting rules by index

Message ID 20240213095038.451299-1-igozlan@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Raslan Darawsheh
Headers
Series [1/9] net/mlx5/hws: skip RTE item when inserting rules by index |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Itamar Gozlan Feb. 13, 2024, 9:50 a.m. UTC
  The location of indexed rules is determined by the index, not the item
hash. A matcher test is added to prevent access to non-existent items.
This avoids unnecessary processing and potential segmentation faults.

Fixes: 405242c ("net/mlx5/hws: add rule object")
Signed-off-by: Itamar Gozlan <igozlan@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr_rule.c | 3 +++
 1 file changed, 3 insertions(+)
  

Patch

diff --git a/drivers/net/mlx5/hws/mlx5dr_rule.c b/drivers/net/mlx5/hws/mlx5dr_rule.c
index fa19303b91..e39137a6ee 100644
--- a/drivers/net/mlx5/hws/mlx5dr_rule.c
+++ b/drivers/net/mlx5/hws/mlx5dr_rule.c
@@ -23,6 +23,9 @@  static void mlx5dr_rule_skip(struct mlx5dr_matcher *matcher,
 	*skip_rx = false;
 	*skip_tx = false;
 
+	if (unlikely(mlx5dr_matcher_is_insert_by_idx(matcher)))
+		return;
+
 	if (mt->item_flags & MLX5_FLOW_ITEM_REPRESENTED_PORT) {
 		v = items[mt->vport_item_id].spec;
 		vport = flow_hw_conv_port_id(v->port_id);