Skip to content

Commit 25f2352

Browse files
rleonPaolo Abeni
authored andcommitted
net/mlx5e: Rely on reqid in IPsec tunnel mode
All packet offloads SAs have reqid in it to make sure they have corresponding policy. While it is not strictly needed for transparent mode, it is extremely important in tunnel mode. In that mode, policy and SAs have different match criteria. Policy catches the whole subnet addresses, and SA catches the tunnel gateways addresses. The source address of such tunnel is not known during egress packet traversal in flow steering as it is added only after successful encryption. As reqid is required for packet offload and it is unique for every SA, we can safely rely on it only. The output below shows the configured egress policy and SA by strongswan: [leonro@vm ~]$ sudo ip x s src 192.169.101.2 dst 192.169.101.1 proto esp spi 0xc88b7652 reqid 1 mode tunnel replay-window 0 flag af-unspec esn aead rfc4106(gcm(aes)) 0xe406a01083986e14d116488549094710e9c57bc6 128 anti-replay esn context: seq-hi 0x0, seq 0x0, oseq-hi 0x0, oseq 0x0 replay_window 1, bitmap-length 1 00000000 crypto offload parameters: dev eth2 dir out mode packet [leonro@064 ~]$ sudo ip x p src 192.170.0.0/16 dst 192.170.0.0/16 dir out priority 383615 ptype main tmpl src 192.169.101.2 dst 192.169.101.1 proto esp spi 0xc88b7652 reqid 1 mode tunnel crypto offload parameters: dev eth2 mode packet Fixes: b3beba1 ("net/mlx5e: Allow policies with reqid 0, to support IKE policy holes") Signed-off-by: Leon Romanovsky <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 2c36880 commit 25f2352

File tree

1 file changed

+5
-7
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/en_accel

1 file changed

+5
-7
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,23 +1718,21 @@ static int tx_add_rule(struct mlx5e_ipsec_sa_entry *sa_entry)
17181718
goto err_alloc;
17191719
}
17201720

1721-
if (attrs->family == AF_INET)
1722-
setup_fte_addr4(spec, &attrs->saddr.a4, &attrs->daddr.a4);
1723-
else
1724-
setup_fte_addr6(spec, attrs->saddr.a6, attrs->daddr.a6);
1725-
17261721
setup_fte_no_frags(spec);
17271722
setup_fte_upper_proto_match(spec, &attrs->upspec);
17281723

17291724
switch (attrs->type) {
17301725
case XFRM_DEV_OFFLOAD_CRYPTO:
1726+
if (attrs->family == AF_INET)
1727+
setup_fte_addr4(spec, &attrs->saddr.a4, &attrs->daddr.a4);
1728+
else
1729+
setup_fte_addr6(spec, attrs->saddr.a6, attrs->daddr.a6);
17311730
setup_fte_spi(spec, attrs->spi, false);
17321731
setup_fte_esp(spec);
17331732
setup_fte_reg_a(spec);
17341733
break;
17351734
case XFRM_DEV_OFFLOAD_PACKET:
1736-
if (attrs->reqid)
1737-
setup_fte_reg_c4(spec, attrs->reqid);
1735+
setup_fte_reg_c4(spec, attrs->reqid);
17381736
err = setup_pkt_reformat(ipsec, attrs, &flow_act);
17391737
if (err)
17401738
goto err_pkt_reformat;

0 commit comments

Comments
 (0)