]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net/mlx5e: Prevent tunnel reformat when tunnel mode not allowed
authorCarolina Jubran <cjubran@nvidia.com>
Sun, 5 Oct 2025 08:29:58 +0000 (11:29 +0300)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 7 Oct 2025 10:59:56 +0000 (12:59 +0200)
commit22239eb258bc1e6ccdb2d3502fce1cc2b2a88386
treeda0f0b3fb2f71b8e87a97fa5fbdbe500a9bd4989
parent7593439c13933164f701eed9c83d89358f203469
net/mlx5e: Prevent tunnel reformat when tunnel mode not allowed

When configuring IPsec packet offload in tunnel mode, the driver tries
to create tunnel reformat objects unconditionally. This is incorrect,
because tunnel mode is only permitted under specific encapsulation
settings, and that decision is already made when the flow table is
created.

The offending commit attempted to block this case in the state add
path, but the check there happens too late and does not prevent the
reformat from being configured.

Fix by taking short reservations for both the eswitch mode and the
encap at the start of state setup. This preserves the block ordering
(mode --> encap) used later: the mode is blocked during RX/TX get, and
the encap is blocked during flow-table creation. This lets us fail
early if either reservation cannot be obtained, it means a mode
transition is underway or a conflicting configuration already owns
encap. If both succeed, the flow-table path later takes the ownership
and the reservations are released on exit.

Fixes: 146c196b60e4 ("net/mlx5e: Create IPsec table with tunnel support only when encap is disabled")
Signed-off-by: Carolina Jubran <cjubran@nvidia.com>
Reviewed-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/1759652999-858513-3-git-send-email-tariqt@nvidia.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c