Skip to contentSkip to conversation

xfrm: Prevent locally generated packets from direct output in tunnel mode

PATCH In review Jianbo Liu 2 participants 2 messages Oct 29, 2025 – Nov 1, 2025

Subsystems (3)
lore
Share & tools
lore

Jianbo Liu

author
#0 lore raw

PATCH 1/1 xfrm: Prevent locally generated packets from direct output in tunnel mode

Add a check to ensure locally generated packets (skb->sk != NULL) do not use direct output in tunnel mode, as these packets require proper L2 header setup that is handled by the normal XFRM processing path.

Fixes 5eddd76ec2fd ("xfrm: fix tunnel mode TX datapath in packet offload mode")
---
 net/xfrm/xfrm_output.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
net/xfrm/xfrm_output.c +5 -1
index 9077730ff7d0..c8fd506ca5cf 100644
@@ -772,8 +772,12 @@ int xfrm_output(struct sock *sk, struct sk_buff *skb)
 		/* Exclusive direct xmit for tunnel mode, as
 		 * some filtering or matching rules may apply
 		 * in transport mode.
+		 * Locally generated packets also require
+		 * the normal XFRM path for L2 header setup,
+		 * as the hardware needs the L2 header to match
+		 * for encryption, so skip direct output as well.
 		 */
-		if (x->props.mode == XFRM_MODE_TUNNEL)
+		if (x->props.mode == XFRM_MODE_TUNNEL && !skb->sk)
 			return xfrm_dev_direct_output(sk, x, skb);
 
 		return xfrm_output_resume(sk, skb, 0);
Signature · 1 line
2.49.0
maintainer
#1 lore raw
Quoted 7 lines · Jianbo Liu

Add a check to ensure locally generated packets (skb->sk != NULL) do not use direct output in tunnel mode, as these packets require proper L2 header setup that is handled by the normal XFRM processing path.

Fixes 5eddd76ec2fd ("xfrm: fix tunnel mode TX datapath in packet offload mode")

Also applied, thanks a lot!