Skip to contentSkip to conversation

net/mlx5e: fix swapped IPv6 IPsec policy masks

PATCH Applied Andrea Parri 4 participants 4 messages Sep 17 – Sep 22

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5e: fix swapped IPv6 IPsec policy masks

IPv6 XFRM policies may use different source and destination prefix lengths. mlx5e_ipsec_policy_mask() builds the corresponding masks independently, but setup_fte_addr6() installs each mask in the opposite address field.

When the prefix lengths differ, this makes the source match use the destination prefix and the destination match use the source prefix. The resulting hardware rule can both miss traffic covered by the policy and match traffic outside it.

Install each mask in its corresponding match field.

Fixes ca7992f52c2c ("net/mlx5e: Properly match IPsec subnet addresses")
Assisted-by LLM
---
 drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c +2 -2
index 329608c59313b..8ffa8068e90ac 100644
@@ -1564,14 +1564,14 @@ static void setup_fte_addr6(struct mlx5_flow_spec *spec,
 		memcpy(MLX5_ADDR_OF(fte_match_param, spec->match_value,
 				    outer_headers.src_ipv4_src_ipv6.ipv6_layout.ipv6), saddr, 16);
 		memcpy(MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
-				    outer_headers.src_ipv4_src_ipv6.ipv6_layout.ipv6), dmask, 16);
+				    outer_headers.src_ipv4_src_ipv6.ipv6_layout.ipv6), smask, 16);
 	}
 
 	if (!addr6_all_zero(daddr)) {
 		memcpy(MLX5_ADDR_OF(fte_match_param, spec->match_value,
 				    outer_headers.dst_ipv4_dst_ipv6.ipv6_layout.ipv6), daddr, 16);
 		memcpy(MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
-				    outer_headers.dst_ipv4_dst_ipv6.ipv6_layout.ipv6), smask, 16);
+				    outer_headers.dst_ipv4_dst_ipv6.ipv6_layout.ipv6), dmask, 16);
 	}
 }
 
Signature · 1 line
2.53.0
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 10 lines

IPv6 XFRM policies may use different source and destination prefix lengths. mlx5e_ipsec_policy_mask() builds the corresponding masks independently, but setup_fte_addr6() installs each mask in the opposite address field.

When the prefix lengths differ, this makes the source match use the destination prefix and the destination match use the source prefix. The resulting hardware rule can both miss traffic covered by the policy and match traffic outside it.

Quoted 6 lines

Install each mask in its corresponding match field.

Fixes ca7992f52c2c ("net/mlx5e: Properly match IPsec subnet addresses")
Assisted-by LLM

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Andrea Parri
Quoted 31 lines · Andrea Parri

IPv6 XFRM policies may use different source and destination prefix lengths. mlx5e_ipsec_policy_mask() builds the corresponding masks independently, but setup_fte_addr6() installs each mask in the opposite address field.

When the prefix lengths differ, this makes the source match use the destination prefix and the destination match use the source prefix. The resulting hardware rule can both miss traffic covered by the policy and match traffic outside it.

Install each mask in its corresponding match field.

Fixes ca7992f52c2c ("net/mlx5e: Properly match IPsec subnet addresses")
Assisted-by LLM
---
  drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c +1 -1
index 329608c59313b..8ffa8068e90ac 100644
@@ -1564,14 +1564,14 @@ static void setup_fte_addr6(struct mlx5_flow_spec *spec,
  		memcpy(MLX5_ADDR_OF(fte_match_param, spec->match_value,
  				    outer_headers.src_ipv4_src_ipv6.ipv6_layout.ipv6), saddr, 16);
  		memcpy(MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
-				    outer_headers.src_ipv4_src_ipv6.ipv6_layout.ipv6), dmask, 16);
+				    outer_headers.src_ipv4_src_ipv6.ipv6_layout.ipv6), smask, 16);
  	}

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c static void setup_fte_addr6(struct mlx5_flow_spec *spec, · line 1577

Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c +1 -1
 
  	if (!addr6_all_zero(daddr)) {
  		memcpy(MLX5_ADDR_OF(fte_match_param, spec->match_value,
  				    outer_headers.dst_ipv4_dst_ipv6.ipv6_layout.ipv6), daddr, 16);
  		memcpy(MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
-				    outer_headers.dst_ipv4_dst_ipv6.ipv6_layout.ipv6), smask, 16);
+				    outer_headers.dst_ipv4_dst_ipv6.ipv6_layout.ipv6), dmask, 16);
  	}
  }
 

Thanks for your patch.

#3 lore raw
In reply to Andrea Parri
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 11 lines · On Thu, 17 Sep 2026 13:55:42 +0200 you wrote:

IPv6 XFRM policies may use different source and destination prefix lengths. mlx5e_ipsec_policy_mask() builds the corresponding masks independently, but setup_fte_addr6() installs each mask in the opposite address field.

When the prefix lengths differ, this makes the source match use the destination prefix and the destination match use the source prefix. The resulting hardware rule can both miss traffic covered by the policy and match traffic outside it.

[...]

Here is the summary with links:
- [net] net/mlx5e: fix swapped IPv6 IPsec policy masks

    https://git.kernel.org/netdev/net/c/10de7ed8ef48

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html