From: Omar Ramadan <omar@blockcast.net>
To: Taehee Yoo <ap420073@gmail.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Shuah Khan <shuah@kernel.org>
Cc: Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, Eric Dumazet <edumazet@kernel.org>
Subject: [PATCH net-next v3 1/2] amt: mark relay data as a UDP tunnel packet before sending it
Date: Sun, 4 Oct 2026 19:11:59 +0300 [thread overview]
Message-ID: <20261004161200.27196-2-omar@blockcast.net> (raw)
In-Reply-To: <20261004161200.27196-1-omar@blockcast.net>
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@kernel.org>
Assisted-by: LLM
Signed-off-by: Omar Ramadan <omar@blockcast.net>
---
Notes (v3):
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)
next prev parent reply other threads:[~2026-10-04 16:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-04 16:11 [PATCH net-next v3 0/2] amt: mark relay data as a UDP tunnel packet, with a selftest Omar Ramadan
2026-10-04 16:11 ` Omar Ramadan [this message]
2026-10-04 16:12 ` [PATCH net-next v3 2/2] selftests: net: add an amt test for UDP_SEGMENT through the relay Omar Ramadan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261004161200.27196-2-omar@blockcast.net \
--to=omar@blockcast.net \
--cc=andrew+netdev@lunn.ch \
--cc=ap420073@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®