Skip to content

Commit 9eca93f

Browse files
Cosmin Ratiukuba-moo
authored andcommitted
net/mlx5: Correctly compare pkt reformat ids
struct mlx5_pkt_reformat contains a naked union of a u32 id and a dr_action pointer which is used when the action is SW-managed (when pkt_reformat.owner is set to MLX5_FLOW_RESOURCE_OWNER_SW). Using id directly in that case is incorrect, as it maps to the least significant 32 bits of the 64-bit pointer in mlx5_fs_dr_action and not to the pkt reformat id allocated in firmware. For the purpose of comparing whether two rules are identical, interpreting the least significant 32 bits of the mlx5_fs_dr_action pointer as an id mostly works... until it breaks horribly and produces the outcome described in [1]. This patch fixes mlx5_flow_dests_cmp to correctly compare ids using mlx5_fs_dr_action_get_pkt_reformat_id for the SW-managed rules. Link: https://lore.kernel.org/netdev/[email protected]/T/#u [1] Fixes: 6a48fae ("net/mlx5: Add direct rule fs_cmd implementation") Signed-off-by: Cosmin Ratiu <[email protected]> Reviewed-by: Mark Bloch <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7c6782a commit 9eca93f

File tree

1 file changed

+12
-2
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+12
-2
lines changed

drivers/net/ethernet/mellanox/mlx5/core/fs_core.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,6 +1664,16 @@ static int create_auto_flow_group(struct mlx5_flow_table *ft,
16641664
return err;
16651665
}
16661666

1667+
static bool mlx5_pkt_reformat_cmp(struct mlx5_pkt_reformat *p1,
1668+
struct mlx5_pkt_reformat *p2)
1669+
{
1670+
return p1->owner == p2->owner &&
1671+
(p1->owner == MLX5_FLOW_RESOURCE_OWNER_FW ?
1672+
p1->id == p2->id :
1673+
mlx5_fs_dr_action_get_pkt_reformat_id(p1) ==
1674+
mlx5_fs_dr_action_get_pkt_reformat_id(p2));
1675+
}
1676+
16671677
static bool mlx5_flow_dests_cmp(struct mlx5_flow_destination *d1,
16681678
struct mlx5_flow_destination *d2)
16691679
{
@@ -1675,8 +1685,8 @@ static bool mlx5_flow_dests_cmp(struct mlx5_flow_destination *d1,
16751685
((d1->vport.flags & MLX5_FLOW_DEST_VPORT_VHCA_ID) ?
16761686
(d1->vport.vhca_id == d2->vport.vhca_id) : true) &&
16771687
((d1->vport.flags & MLX5_FLOW_DEST_VPORT_REFORMAT_ID) ?
1678-
(d1->vport.pkt_reformat->id ==
1679-
d2->vport.pkt_reformat->id) : true)) ||
1688+
mlx5_pkt_reformat_cmp(d1->vport.pkt_reformat,
1689+
d2->vport.pkt_reformat) : true)) ||
16801690
(d1->type == MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE &&
16811691
d1->ft == d2->ft) ||
16821692
(d1->type == MLX5_FLOW_DESTINATION_TYPE_TIR &&

0 commit comments

Comments
 (0)