net/mlx5: Do not restore destination-less TC rules
Subsystems (4)
Tariq Toukan
maintainerPATCH 1/1 net/mlx5: Do not restore destination-less TC rules
From: Jeroen Massar <[email protected]>
After IPsec policy/state TX rules are added, any TC flow rule, which forwards packets to uplink, is modified to forward to IPsec TX tables. As these tables are destroyed dynamically, whenever there is no reference to them, the destinations of this kind of rules must be restored to uplink, unless there is no destination for that rule.
The flow rules FLOW_ACTION_ACCEPT, DROP, TRAP, GOTO and SAMPLE do not have a destination port, and thus out_count = 0.
At cleanup time of the rules in mlx5_esw_ipsec_modify_flow_dests we call mlx5_eswitch_restore_ipsec_rule but as the above types do not have a destination we get an underflow of out_count, as the port is passed, which is esw_attr->out_count - 1.
This change avoids calling mlx5_eswitch_restore_ipsec_rule when there are no output destinations and thus avoids the underflow.
--- drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c +2 -1
@@ -142,7 +142,8 @@ static int mlx5_esw_ipsec_modify_flow_dests(struct mlx5_eswitch *esw, attr = flow->attr; esw_attr = attr->esw_attr; -if (esw_attr->out_count - esw_attr->split_count >1 ) +if (!esw_attr->out_count || + esw_attr->out_count - esw_attr->split_count >1 )return 0 ; err = mlx5_eswitch_restore_ipsec_rule(esw, flow->rule[0], esw_attr,
base-commit: f5b2772d14884f4be9e718644f1203d4d0e6f0d6
Signature · 1 line
2.44.0
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Wed, 13 May 2026 09:33:02 +0300 you wrote:
From: Jeroen Massar <[email protected]>
After IPsec policy/state TX rules are added, any TC flow rule, which forwards packets to uplink, is modified to forward to IPsec TX tables. As these tables are destroyed dynamically, whenever there is no reference to them, the destinations of this kind of rules must be restored to uplink, unless there is no destination for that rule.
[...]
Here is the summary with links:
- [net] net/mlx5: Do not restore destination-less TC rules
https://git.kernel.org/netdev/net/c/8d0a5af8b1ba
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html