net/mlx5e: SHAMPO: Do not merge packets with different kTLS RX state
Subsystems (6)
Tariq Toukan
maintainerPATCH 1/1 net/mlx5e: SHAMPO: Do not merge packets with different kTLS RX state
HW-GRO (SHAMPO) sessions are not terminated by HW when the kTLS RX offload indication in the CQE changes. The driver applies the offload metadata of the first packet in the session only, so ciphertext and plaintext can end up in the same skb under a single skb->decrypted indication, and resync requests carried by non-first packets are lost.
Do not merge a CQE whose decryption state differs from skb->decrypted, which the first packet of the session sets. Never merge a CQE that carries a resync request or a TLS error, so that each of them starts a session and is handled.
The failure was reproduced on ConnectX-7 with HW GRO and kTLS RX offload on and 0.3% loss added by netem on the sender's egress: TlsDecryptError increased and the receiving sockets failed with EBADMSG. With this patch, TlsDecryptError stays 0.
--- .../mellanox/mlx5/core/en_accel/en_accel.h | 5 +++-- .../mellanox/mlx5/core/en_accel/ktls_txrx.h | 21 +++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/en_rx.c | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/en_accel.h +3 -2
@@ -219,9 +219,10 @@ static inline void mlx5e_accel_tx_finish(struct mlx5e_txqsq *sq, }static inline bool -mlx5e_accel_shampo_can_merge (struct mlx5e_rq *rq,struct mlx5_cqe64 *cqe) +mlx5e_accel_shampo_can_merge (struct sk_buff *skb,struct mlx5_cqe64 *cqe) { -return mlx5e_psp_shampo_can_merge (rq->hw_gro_data->skb, cqe); +return mlx5e_psp_shampo_can_merge (skb, cqe) && +mlx5e_ktls_shampo_can_merge (skb, cqe); }static inline int mlx5e_accel_init_rx (struct mlx5e_priv *priv)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_txrx.h +21 -0
@@ -60,6 +60,21 @@ mlx5e_ktls_handle_tx_wqe(struct mlx5_wqe_ctrl_seg *cseg, { cseg->tis_tir_num =cpu_to_be32 (state->tls_tisn <<8 ); } + +/* The first CQE of a HW-GRO session sets skb->decrypted. A resync request or +* a TLS error is handled on the first CQE only, so it starts a new session. +*/ +static inline bool +mlx5e_ktls_shampo_can_merge (struct sk_buff *skb,struct mlx5_cqe64 *cqe) +{ +u8 tls_offload =get_cqe_tls_offload (cqe); + +if (unlikely (tls_offload >CQE_TLS_OFFLOAD_DECRYPTED )) +return false; + +return (tls_offload ==CQE_TLS_OFFLOAD_DECRYPTED ) == +skb_is_decrypted (skb); +}#else static inline bool mlx5e_ktls_tx_try_handle_resync_dump_comp(struct mlx5e_txqsq *sq,
@@ -93,6 +108,12 @@ static inline void mlx5e_ktls_handle_rx_skb(struct mlx5e_rq *rq, u32 *cqe_bcnt) { } + +static inline bool +mlx5e_ktls_shampo_can_merge (struct sk_buff *skb,struct mlx5_cqe64 *cqe) +{ +return true; +}#endif /* CONFIG_MLX5_EN_TLS */ #endif /* __MLX5E_TLS_TXRX_H__ */
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c +1 -1
@@ -2271,7 +2271,7 @@ static void mlx5e_handle_rx_cqe_mpwrq_shampo(struct mlx5e_rq *rq, struct mlx5_cqif (*skb && !(match &&mlx5e_hw_gro_skb_has_enough_space (*skb, data_bcnt, page_size) && -mlx5e_accel_shampo_can_merge (rq, cqe))) { +mlx5e_accel_shampo_can_merge (*skb, cqe))) { match = false;mlx5e_shampo_flush_skb (rq, cqe, match); }
base-commit: aa40afa831ebfe45e40a23721711059f2ac584d4
Signature · 1 line
2.44.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 11 lines
HW-GRO (SHAMPO) sessions are not terminated by HW when the kTLS RX offload indication in the CQE changes. The driver applies the offload metadata of the first packet in the session only, so ciphertext and plaintext can end up in the same skb under a single
skb->decryptedindication, and resync requests carried by non-first packets are lost.Do not merge a CQE whose decryption state differs from
skb->decrypted, which the first packet of the session sets. Never merge a CQE that carries a resync request or a TLS error, so that each of them starts a session and is handled.
Quoted 7 lines
The failure was reproduced on ConnectX-7 with HW GRO and kTLS RX offload on and 0.3% loss added by netem on the sender's egress: TlsDecryptError increased and the receiving sockets failed with EBADMSG. With this patch, TlsDecryptError stays 0.
Fixes 92552d3abd32 ("net/mlx5e: HW_GRO cqe handler implementation")Signed-off-by Tariq Toukan <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
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 6 lines · On Wed, 18 Nov 2026 16:40:42 +0200 you wrote:
HW-GRO (SHAMPO) sessions are not terminated by HW when the kTLS RX offload indication in the CQE changes. The driver applies the offload metadata of the first packet in the session only, so ciphertext and plaintext can end up in the same skb under a single
skb->decryptedindication, and resync requests carried by non-first packets are lost.
Quoted 6 lines
Do not merge a CQE whose decryption state differs from
skb->decrypted, which the first packet of the session sets. Never merge a CQE that carries a resync request or a TLS error, so that each of them starts a session and is handled.[...]
Here is the summary with links:
- [net] net/mlx5e: SHAMPO: Do not merge packets with different kTLS RX state
https://git.kernel.org/netdev/net/c/e421df3c8386
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html