amt: mark relay data as a UDP tunnel packet, with a selftest
v3 cover amt: mark relay data as a UDP tunnel packet, with a selftest
amt_send_multicast_data() never calls udp_tunnel_handle_offloads(), unlike other UDP tunnels. With tx checksum offload on the amt device (off by default), a UDP_SEGMENT burst through the relay is dropped before patch 1 and delivered after it. Patch 2 adds the selftest.
This follows Eric Dumazet's suggestion on my withdrawn [PATCH net] "amt:
do not offer software GSO on the amt device":
https://lore.kernel.org/all/[email protected]/
Not touched: amt advertises NETIF_F_GSO_FRAGLIST and skb_copy_expand() refuses such skbs with a WARN_ON_ONCE(). I have not reproduced it, and it would be a separate fix.
v3:
- patch 2: fail a case when one of its captures dies (Sashiko review)
- patch 2: also check amtg rx_dropped, as the changelog says, and mention the plain-datagram cases there (Sashiko review)
- patch 2: wait for a fresh READY, and fail a case when a helper does not start (Sashiko review)
- patch 2: fail, not skip, when no relayed probe gets through (Sashiko review)
- patch 2: fail, not skip, a tx-on UDP_SEGMENT case in which no GSO skb reaches amt_dev_xmit(), as the changelog says
- patch 2: make amt_gso reject sizes that would overflow its buffers (Sashiko review)
- patch 1 is unchanged
v2: https://lore.kernel.org/all/[email protected]/
- shorten the changelogs, add Suggested-by, and move the testing notes below the "---" (Eric); patch 1's code is unchanged, one comment is corrected
- patch 2: fix the shellcheck and 80-column checkpatch findings reported by the netdev CI, skip when AF_PACKET is not available (v1 reported no result and exit 0), add CONFIG_PACKET to the config, drop dead options and code
v1: https://lore.kernel.org/all/[email protected]/
Omar Ramadan (2):
amt: mark relay data as a UDP tunnel packet before sending it
selftests: net: add an amt test for UDP_SEGMENT through the relay
drivers/net/amt.c | 10 + tools/testing/selftests/net/.gitignore | 1 + tools/testing/selftests/net/Makefile | 2 + tools/testing/selftests/net/amt_gso.c | 462 +++++++++++++++++++++++++ tools/testing/selftests/net/amt_gso.sh | 282 +++++++++++++++ tools/testing/selftests/net/config | 1 + 6 files changed, 758 insertions(+) create mode 100644 tools/testing/selftests/net/amt_gso.c create mode 100755 tools/testing/selftests/net/amt_gso.sh
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v3 1/2 amt: mark relay data as a UDP tunnel packet before sending it
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().
---
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(+)
drivers/net/amt.c +10 -0
@@ -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;
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v3 2/2 selftests: net: add an amt test for UDP_SEGMENT through the relay
In reply to Omar RamadanAdd amt_gso.sh and its helper amt_gso. The test sends a UDP_SEGMENT burst from the relay namespace through an amt relay and gateway to a listener, with tx checksum offload off on the amt device (a control:
the core segments the burst before the driver) and on (the GSO skb reaches amt_dev_xmit()). It also sends plain (non-GSO) datagrams with tx offload on, which must keep working. It checks that the listener gets every datagram intact, that a GSO skb really reached the driver, that nothing larger than the MTU was put on the wire, and that the relay's egress device and the gateway report no drops or checksum errors.
The verdict needs AF_PACKET captures: add CONFIG_PACKET to the config, and skip when they are not available.
---
Notes (v3):
New in v3: a case fails when a capture dies or a helper does not start, the gateway's amt device must report no drops, the test fails instead of skipping when no relayed probe gets through, and amt_gso rejects sizes that would overflow its buffers (all from the Sashiko review). A tx-on UDP_SEGMENT case now also fails, instead of skipping, when no GSO skb reaches the driver. Timing is unchanged. It gave the expected result in 20 of 20 runs per kernel on net-next 071876fd5048 (v2: 20 of 20; v1:
40 of 40 on eb0c18404c89), in a 4-vCPU KVM guest on a busy host:
unpatched, only the two tx-on UDP_SEGMENT cases fail; patched, all six pass. With the probe sent to the wrong port, or a capture on a missing interface, it fails as expected. An earlier draft failed in about 3 of 25 runs on a loaded guest because the receiver gave up waiting for the first datagram (inferred from the counters); it now waits up to 15 s for it, but the test may still be flaky elsewhere.
tools/testing/selftests/net/.gitignore | 1 + tools/testing/selftests/net/Makefile | 2 + tools/testing/selftests/net/amt_gso.c | 462 +++++++++++++++++++++++++ tools/testing/selftests/net/amt_gso.sh | 282 +++++++++++++++ tools/testing/selftests/net/config | 1 + 5 files changed, 748 insertions(+) create mode 100644 tools/testing/selftests/net/amt_gso.c create mode 100755 tools/testing/selftests/net/amt_gso.sh
tools/testing/selftests/net/.gitignore +1 -0
@@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only +amt_gso bind_bhash bind_timewait bind_wildcard
tools/testing/selftests/net/Makefile +2 -0
@@ -9,6 +9,7 @@ CFLAGS += -I../ TEST_PROGS := \ altnames.sh \ amt.sh \ + amt_gso.sh \ arp_ndisc_evict_nocarrier.sh \ arp_ndisc_untracked_subnets.sh \ bareudp.sh \
@@ -143,6 +144,7 @@ TEST_PROGS_EXTENDED := \ # end of TEST_PROGS_EXTENDED TEST_GEN_FILES := \ + amt_gso \ bind_bhash \ cmsg_sender \ fin_ack_lat \
tools/testing/selftests/net/amt_gso.c new file +462 -0
462 lines not on this page · raw message
tools/testing/selftests/net/amt_gso.sh new file +282 -0
282 lines not on this page · raw message
tools/testing/selftests/net/config +1 -0
@@ -117,6 +117,7 @@ CONFIG_NFT_COMPAT=m CONFIG_NFT_NAT=m CONFIG_NUMA=y CONFIG_OPENVSWITCH=m +CONFIG_PACKET=y CONFIG_PAGE_POOL_STATS=y CONFIG_PSAMPLE=m CONFIG_RPS=y
Signature · 1 line
2.50.1 (Apple Git-155)
Jakub Kicinski
maintainerRe: [PATCH net-next v3 2/2] selftests: net: add an amt test for UDP_SEGMENT through the relay
Quoted 5 lines · On Sun, 4 Oct 2026 19:12:00 +0300 Omar Ramadan wrote:
tools/testing/selftests/net/.gitignore | 1 + tools/testing/selftests/net/Makefile | 2 + tools/testing/selftests/net/amt_gso.c | 462 +++++++++++++++++++++++++ tools/testing/selftests/net/amt_gso.sh | 282 +++++++++++++++ tools/testing/selftests/net/config | 1 +
This looks overdone, pass.
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Sun, 4 Oct 2026 19:11:58 +0300 you wrote:
amt_send_multicast_data()never callsudp_tunnel_handle_offloads(), unlike other UDP tunnels. With tx checksum offload on the amt device (off by default), aUDP_SEGMENTburst through the relay is dropped before patch 1 and delivered after it. Patch 2 adds the selftest.This follows Eric Dumazet's suggestion on my withdrawn [PATCH net] "amt:
do not offer software GSO on the amt device":
https://lore.kernel.org/all/[email protected]/[...]
Here is the summary with links:
- [net-next,v3,1/2] amt: mark relay data as a UDP tunnel packet before sending it
https://git.kernel.org/netdev/net-next/c/47bb8dfbe1d2
- [net-next,v3,2/2] selftests: net: add an amt test for UDP_SEGMENT through the relay (no matching commit)
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html