[v2,01/10] net/mlx5/hws: skip RTE item when inserting rules by index

Message ID 20240218051125.717011-1-igozlan@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers
Series [v2,01/10] 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. 18, 2024, 5:11 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(+)
  

Comments

Raslan Darawsheh Feb. 26, 2024, 10:16 a.m. UTC | #1
Hi,

> -----Original Message-----
> From: Itamar Gozlan <igozlan@nvidia.com>
> Sent: Sunday, February 18, 2024 7:11 AM
> To: Itamar Gozlan <igozlan@nvidia.com>; Erez Shitrit <erezsh@nvidia.com>;
> Hamdan Agbariya <hamdani@nvidia.com>; Yevgeny Kliteynik
> <kliteyn@nvidia.com>; Slava Ovsiienko <viacheslavo@nvidia.com>; NBU-
> Contact-Thomas Monjalon (EXTERNAL) <thomas@monjalon.net>; Suanming
> Mou <suanmingm@nvidia.com>; Dariusz Sosnowski
> <dsosnowski@nvidia.com>; Ori Kam <orika@nvidia.com>; Matan Azrad
> <matan@nvidia.com>; Alex Vesker <valex@nvidia.com>
> Cc: dev@dpdk.org
> Subject: [v2 01/10] net/mlx5/hws: skip RTE item when inserting rules by index
> 
> 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>


Fixed few fixes tags, 
Series applied to next-net-mlx,

Kindest regards
Raslan Darawsheh
  

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);