[PATCH net-next v2 1/2] amt: mark relay data as a UDP tunnel packet before sending it

From: Omar Ramadan

Date: Fri Oct 02 2026 - 17:26:43 EST


amt_send_multicast_data() encapsulates the multicast packet in
AMT + UDP + IP headers, but unlike other UDP tunnels it never calls
udp_tunnel_handle_offloads().

If tx checksum offload is enabled on the amt device (off by default),
GSO packets (e.g. from a UDP_SEGMENT sender) reach amt_dev_xmit()
unsegmented. They are then sent with neither skb->encapsulation nor
SKB_GSO_UDP_TUNNEL_CSUM set, and the lower device drops them:
__udp_gso_segment() fails because csum_start does not match the
(outer) transport header.

Call udp_tunnel_handle_offloads(skb, true), as other UDP tunnels do.
udp_csum is true because udp_tunnel_xmit_skb() is called with
nocheck == false.

Also reset the mac header of the copy before recording the inner
headers. amt_dev_xmit() pulled the Ethernet header without moving
mac_header, so inner_mac_header would point 14 bytes before the
inner IP header. That makes tnl_hlen negative in
__skb_udp_tunnel_segment().

Suggested-by: Eric Dumazet <edumazet@xxxxxxxxxx>
Assisted-by: LLM
Signed-off-by: Omar Ramadan <omar@xxxxxxxxxxxxx>
---

Notes (v2):
Found by an LLM-assisted review of drivers/net/amt.c. Reproduced with
the selftest in patch 2 (x86_64 KVM guest, CONFIG_DEBUG_NET=y), tx
offload on, UDP_SEGMENT bursts of 8 x 1200 + 100 bytes, IPv4 and IPv6
inner traffic, 40 runs per kernel on net-next eb0c18404c89 and 20 with
this version of the selftest on 071876fd5048:

- before: 0 of 900 datagrams delivered and tx_dropped +100 on the
relay's egress device, in every case
- after: 900 of 900 delivered, no drops and no UDP checksum errors at
the gateway, in every case
- with only the skb_reset_mac_header() call removed (two runs, an
earlier version of the selftest), the packets are still dropped and
DEBUG_NET warns in skb_udp_tunnel_segment()
- tx offload off, and non-GSO datagrams with it on, work before and
after; amt.sh passes with the patch

Not tested here: hardware UDP tunnel segmentation offload, hardware
checksumming of a non-GSO CHECKSUM_PARTIAL packet (it now leaves amt
with skb->encapsulation set, as with other UDP tunnels; the selftest's
egress device has tx offload off), a forwarded GRO packet as the GSO
source, KASAN (the netdev CI's debug kernel ran v1), sparse, udp_csum ==
false, and amt.sh on the unpatched kernel.

drivers/net/amt.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/drivers/net/amt.c b/drivers/net/amt.c
index 0277e4c..a8236d4 100644
--- a/drivers/net/amt.c
+++ b/drivers/net/amt.c
@@ -1078,7 +1078,17 @@ static void amt_send_multicast_data(struct amt_dev *amt,
if (!skb)
return;

+ /* amt_dev_xmit() pulled the Ethernet header without moving the mac
+ * header. The tunnelled payload has no link-layer header, so the
+ * inner mac header must coincide with the inner IP header.
+ */
+ skb_reset_mac_header(skb);
skb_reset_inner_headers(skb);
+ if (udp_tunnel_handle_offloads(skb, true)) {
+ kfree_skb(skb);
+ return;
+ }
+
memset(&fl4, 0, sizeof(struct flowi4));
fl4.flowi4_oif = amt->stream_dev->ifindex;
fl4.daddr = tunnel->ip4;
--
2.50.1 (Apple Git-155)