linux/net/xfrm
Sabrina Dubroca 91d8a53db2 xfrm: fix offloading of cross-family tunnels
Xiumei reported a regression in IPsec offload tests over xfrmi, where
the traffic for IPv6 over IPv4 tunnels is processed in SW instead of
going through crypto offload, after commit
cc18f482e8 ("xfrm: provide common xdo_dev_offload_ok callback
implementation").

Commit cc18f482e8 added a generic version of existing checks
attempting to prevent packets with IPv4 options or IPv6 extension
headers from being sent to HW that doesn't support offloading such
packets. The check mistakenly uses x->props.family (the outer family)
to determine the inner packet's family and verify if
options/extensions are present.

In the case of IPv6 over IPv4, the check compares some of the traffic
class bits to the expected no-options ihl value (5). The original
check was introduced in commit 2ac9cfe782 ("net/mlx5e: IPSec, Add
Innova IPSec offload TX data path"), and then duplicated in the other
drivers. Before commit cc18f482e8, the loose check (ihl > 5) passed
because those traffic class bits were not set to a value that
triggered the no-offload codepath. Packets with options/extension
headers that should have been handled in SW went through the offload
path, and were likely dropped by the NIC or incorrectly
processed. Since commit cc18f482e8, the check is now strict (ihl !=
5), and in a basic setup (no traffic class configured), all packets go
through the no-offload codepath.

The commits that introduced the incorrect family checks in each driver
are:
2ac9cfe782 ("net/mlx5e: IPSec, Add Innova IPSec offload TX data path")
8362ea16f6 ("crypto: chcr - ESN for Inline IPSec Tx")
859a497fe8 ("nfp: implement xfrm callbacks and expose ipsec offload feature to upper layer")
32188be805 ("cn10k-ipsec: Allow ipsec crypto offload for skb with SA")
[ixgbe/ixgbevf commits are ignored, as that HW does not support tunnel
mode, thus no cross-family setups are possible]

Fixes: cc18f482e8 ("xfrm: provide common xdo_dev_offload_ok callback implementation")
Reported-by: Xiumei Mu <xmu@redhat.com>
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
2025-09-15 11:35:06 +02:00
..
Kconfig xfrm: config: add CONFIG_XFRM_IPTFS 2024-12-05 10:00:53 +01:00
Makefile xfrm: iptfs: add new iptfs xfrm mode impl 2024-12-05 10:01:35 +01:00
espintcp.c espintcp: fix skb leaks 2025-04-14 11:58:50 +02:00
trace_iptfs.h xfrm: iptfs: add tracepoint functionality 2024-12-05 10:02:36 +01:00
xfrm_algo.c xfrm: ipcomp: Use crypto_acomp interface 2025-03-21 17:36:49 +08:00
xfrm_compat.c xfrm: netlink: add config (netlink) options 2024-12-05 10:01:15 +01:00
xfrm_device.c xfrm: fix offloading of cross-family tunnels 2025-09-15 11:35:06 +02:00
xfrm_hash.c
xfrm_hash.h xfrm: add state hashtable keyed by seq 2021-05-14 13:52:01 +02:00
xfrm_inout.h
xfrm_input.c xfrm: hold device only for the asynchronous decryption 2025-06-20 10:39:19 +02:00
xfrm_interface_bpf.c bpf: treewide: Annotate BPF kfuncs in BTF 2024-01-31 20:40:56 -08:00
xfrm_interface_core.c xfrm: interface: fix use-after-free after changing collect_md xfrm interface 2025-07-04 09:25:25 +02:00
xfrm_ipcomp.c xfrm: delete x->tunnel as we delete x 2025-07-08 13:28:27 +02:00
xfrm_iptfs.c xfrm: Switch to use hrtimer_setup() 2025-02-18 10:35:47 +01:00
xfrm_nat_keepalive.c xfrm: Use nested-BH locking for nat_keepalive_sk_ipv[46] 2025-05-15 15:23:31 +02:00
xfrm_output.c ipsec-next-2025-03-24 2025-03-25 08:50:10 -07:00
xfrm_policy.c net: dst: annotate data-races around dst->obsolete 2025-07-02 14:32:29 -07:00
xfrm_proc.c xfrm: add generic iptfs defines and functionality 2024-12-05 10:01:28 +01:00
xfrm_replay.c ipsec-2025-01-27 2025-01-27 15:15:12 -08:00
xfrm_state.c xfrm: xfrm_alloc_spi shouldn't use 0 as SPI 2025-09-01 08:56:00 +02:00
xfrm_state_bpf.c bpf: treewide: Annotate BPF kfuncs in BTF 2024-01-31 20:40:56 -08:00
xfrm_sysctl.c net: Remove ctl_table sentinel elements from several networking subsystems 2024-05-03 13:29:42 +01:00
xfrm_user.c Revert "xfrm: destroy xfrm_state synchronously on net exit path" 2025-07-08 13:28:29 +02:00