AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/10/03 08:55 flow patch-triage
3m Args:
null

Results:
{
  "EnableConfigs": [
    "AMT",
    "IP_MULTICAST",
    "INET"
  ],
  "FocusSymbols": [
    "amt_send_multicast_data",
    "amt_dev_xmit"
  ],
  "KMSANReasoning": "The patch modifies `amt_send_multicast_data()` in `drivers/net/amt.c` to adjust skb inner headers (`skb_reset_mac_header(skb)` and `skb_reset_inner_headers(skb)`) and invoke `udp_tunnel_handle_offloads(skb, true)` so that UDP segmentation offload (GSO) packets are appropriately encapsulated and marked before transmission. The rest of the diff adds user-space selftests.\n\nThis change does not introduce or modify any uninitialized variables, heap/stack allocations, or copies to user space. It only adjusts skb metadata pointers and flags for network offloading. Any potential issues with incorrect header offsets during GSO segmentation, packet trimming, or skb lifetime management would manifest as out-of-bounds memory accesses or use-after-free bugs, which are detected by KASAN rather than KMSAN. As there are no uninitialized memory read or info-leak risks, a dedicated KMSAN fuzzing session is not justified.",
  "NeedsKMSAN": false,
  "Reasoning": "The patch modifies amt_send_multicast_data() in drivers/net/amt.c to reset the MAC header and invoke udp_tunnel_handle_offloads() on outgoing multicast packets. AMT is a virtual network device driver configurable via rtnetlink and reachable in standard virtualized environments. Fuzzing is warranted to test packet segmentation, encapsulation offloading, and error handling paths.",
  "WorthFuzzing": true
}

1/1 2026/10/03 08:55 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit da0c0ce6718afdc74d647e71e13c528b1f2c0c30\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Sat Oct 3 08:55:58 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/drivers/net/amt.c b/drivers/net/amt.c\nindex 0277e4cac39bd..a8236d40c2e70 100644\n--- a/drivers/net/amt.c\n+++ b/drivers/net/amt.c\n@@ -1078,7 +1078,17 @@ static void amt_send_multicast_data(struct amt_dev *amt,\n \tif (!skb)\n \t\treturn;\n \n+\t/* amt_dev_xmit() pulled the Ethernet header without moving the mac\n+\t * header. The tunnelled payload has no link-layer header, so the\n+\t * inner mac header must coincide with the inner IP header.\n+\t */\n+\tskb_reset_mac_header(skb);\n \tskb_reset_inner_headers(skb);\n+\tif (udp_tunnel_handle_offloads(skb, true)) {\n+\t\tkfree_skb(skb);\n+\t\treturn;\n+\t}\n+\n \tmemset(\u0026fl4, 0, sizeof(struct flowi4));\n \tfl4.flowi4_oif         = amt-\u003estream_dev-\u003eifindex;\n \tfl4.daddr              = tunnel-\u003eip4;\ndiff --git a/tools/testing/selftests/net/.gitignore b/tools/testing/selftests/net/.gitignore\nindex dacd36ed8455e..489d37b990845 100644\n--- a/tools/testing/selftests/net/.gitignore\n+++ b/tools/testing/selftests/net/.gitignore\n@@ -1,4 +1,5 @@\n # SPDX-License-Identifier: GPL-2.0-only\n+amt_gso\n bind_bhash\n bind_timewait\n bind_wildcard\ndiff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile\nindex cab3f2c90039f..9af0d175b1018 100644\n--- a/tools/testing/selftests/net/Makefile\n+++ b/tools/testing/selftests/net/Makefile\n@@ -9,6 +9,7 @@ CFLAGS += -I../\n TEST_PROGS := \\\n \taltnames.sh \\\n \tamt.sh \\\n+\tamt_gso.sh \\\n \tarp_ndisc_evict_nocarrier.sh \\\n \tarp_ndisc_untracked_subnets.sh \\\n \tbareudp.sh \\\n@@ -143,6 +144,7 @@ TEST_PROGS_EXTENDED := \\\n # end of TEST_PROGS_EXTENDED\n \n TEST_GEN_FILES := \\\n+\tamt_gso \\\n \tbind_bhash \\\n \tcmsg_sender \\\n \tfin_ack_lat \\\ndiff --git a/tools/testing/selftests/net/amt_gso.c b/tools/testing/selftests/net/amt_gso.c\nnew file mode 100644\nindex 0000000000000..eebf3ecb94979\n--- /dev/null\n+++ b/tools/testing/selftests/net/amt_gso.c\n@@ -0,0 +1,457 @@\n+// SPDX-License-Identifier: GPL-2.0\n+/*\n+ * Helper for amt_gso.sh.\n+ *\n+ * send:  send datagrams to a multicast group, optionally as one UDP_SEGMENT\n+ *        burst per datagram, with a self-describing payload pattern.\n+ * recv:  receive datagrams on a UDP port and check count, length and payload\n+ *        of every one of them against the pattern used by \"send\".\n+ * sniff: capture on an interface with AF_PACKET and report how large the\n+ *        frames handed to the device were.\n+ *\n+ * Every datagram consists of cnt chunks of seg bytes followed by an optional\n+ * tail chunk of tail bytes. A chunk starts with a struct chunk_hdr and the\n+ * rest of it is a function of (datagram number, chunk number, offset).\n+ * With UDP_SEGMENT set to seg, every chunk is one segment on the wire.\n+ */\n+#define _GNU_SOURCE\n+#include \u003carpa/inet.h\u003e\n+#include \u003cerrno.h\u003e\n+#include \u003cerror.h\u003e\n+#include \u003clinux/if_packet.h\u003e\n+#include \u003clinux/if_ether.h\u003e\n+#include \u003cnet/if.h\u003e\n+#include \u003cnetinet/in.h\u003e\n+#include \u003cnetinet/udp.h\u003e\n+#include \u003cpoll.h\u003e\n+#include \u003csignal.h\u003e\n+#include \u003cstdbool.h\u003e\n+#include \u003cstdint.h\u003e\n+#include \u003cstdio.h\u003e\n+#include \u003cstdlib.h\u003e\n+#include \u003cstring.h\u003e\n+#include \u003csys/socket.h\u003e\n+#include \u003ctime.h\u003e\n+#include \u003cunistd.h\u003e\n+\n+#ifndef UDP_SEGMENT\n+#define UDP_SEGMENT\t103\n+#endif\n+\n+#define MAX_DGRAM\t65507\n+#define AMT_MSG_MCAST_DATA\t6\n+\n+struct chunk_hdr {\n+\tuint32_t seq;\n+\tuint16_t idx;\n+\tuint16_t len;\n+};\n+\n+struct cfg {\n+\tbool ipv6;\n+\tbool gso;\n+\tbool amt;\t\t/* sniff: count AMT multicast data messages */\n+\tconst char *ifname;\n+\tconst char *group;\n+\tconst char *bind_addr;\n+\tunsigned int port;\n+\tunsigned int seg;\n+\tunsigned int cnt;\n+\tunsigned int tail;\n+\tunsigned int num;\n+\tunsigned int delay_us;\n+\tunsigned int idle;\n+\tunsigned int grace;\t/* recv: extra wait for the first datagram */\n+\tunsigned int mtu;\n+};\n+\n+static uint8_t fill_byte(uint32_t seq, unsigned int idx, unsigned int off)\n+{\n+\treturn (uint8_t)(seq * 131 + idx * 17 + off * 7 + (off \u003e\u003e 8));\n+}\n+\n+static unsigned int chunk_len(const struct cfg *c, unsigned int idx)\n+{\n+\treturn idx \u003c c-\u003ecnt ? c-\u003eseg : c-\u003etail;\n+}\n+\n+static unsigned int chunks_per_dgram(const struct cfg *c)\n+{\n+\treturn c-\u003ecnt + (c-\u003etail ? 1 : 0);\n+}\n+\n+static void fill_dgram(const struct cfg *c, uint32_t seq, uint8_t *buf)\n+{\n+\tunsigned int i, off, n = chunks_per_dgram(c);\n+\n+\tfor (i = 0; i \u003c n; i++) {\n+\t\tunsigned int len = chunk_len(c, i);\n+\t\tstruct chunk_hdr h = { .seq = seq, .idx = i, .len = len };\n+\n+\t\tmemcpy(buf, \u0026h, sizeof(h));\n+\t\tfor (off = sizeof(h); off \u003c len; off++)\n+\t\t\tbuf[off] = fill_byte(seq, i, off);\n+\t\tbuf += len;\n+\t}\n+}\n+\n+static int open_udp(const struct cfg *c)\n+{\n+\tint fd = socket(c-\u003eipv6 ? AF_INET6 : AF_INET, SOCK_DGRAM, 0);\n+\n+\tif (fd \u003c 0)\n+\t\terror(2, errno, \"socket\");\n+\treturn fd;\n+}\n+\n+static void fill_addr(const struct cfg *c, const char *str, unsigned int port,\n+\t\t      struct sockaddr_storage *ss, socklen_t *len)\n+{\n+\tmemset(ss, 0, sizeof(*ss));\n+\tif (c-\u003eipv6) {\n+\t\tstruct sockaddr_in6 *a = (void *)ss;\n+\n+\t\ta-\u003esin6_family = AF_INET6;\n+\t\ta-\u003esin6_port = htons(port);\n+\t\tif (inet_pton(AF_INET6, str, \u0026a-\u003esin6_addr) != 1)\n+\t\t\terror(2, errno, \"inet_pton\");\n+\t\t*len = sizeof(*a);\n+\t} else {\n+\t\tstruct sockaddr_in *a = (void *)ss;\n+\n+\t\ta-\u003esin_family = AF_INET;\n+\t\ta-\u003esin_port = htons(port);\n+\t\tif (inet_pton(AF_INET, str, \u0026a-\u003esin_addr) != 1)\n+\t\t\terror(2, errno, \"inet_pton\");\n+\t\t*len = sizeof(*a);\n+\t}\n+}\n+\n+static int do_send(const struct cfg *c)\n+{\n+\tstatic uint8_t buf[MAX_DGRAM];\n+\tstruct sockaddr_storage dst, src;\n+\tsocklen_t dlen, slen;\n+\tunsigned int total, ifindex, i;\n+\tint fd, ttl = 8, zero = 0;\n+\n+\ttotal = c-\u003ecnt * c-\u003eseg + c-\u003etail;\n+\tif (total \u003e MAX_DGRAM ||\n+\t    (c-\u003etail \u0026\u0026 c-\u003etail \u003c sizeof(struct chunk_hdr)) ||\n+\t    c-\u003eseg \u003c sizeof(struct chunk_hdr))\n+\t\terror(2, 0, \"bad sizes\");\n+\tifindex = if_nametoindex(c-\u003eifname);\n+\tif (!ifindex)\n+\t\terror(2, errno, \"if_nametoindex\");\n+\n+\tfd = open_udp(c);\n+\tif (c-\u003ebind_addr) {\n+\t\tfill_addr(c, c-\u003ebind_addr, 0, \u0026src, \u0026slen);\n+\t\tif (bind(fd, (void *)\u0026src, slen))\n+\t\t\terror(2, errno, \"bind\");\n+\t}\n+\tif (c-\u003eipv6) {\n+\t\tif (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF, \u0026ifindex,\n+\t\t\t       sizeof(ifindex)))\n+\t\t\terror(2, errno, \"IPV6_MULTICAST_IF\");\n+\t\tif (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, \u0026ttl,\n+\t\t\t       sizeof(ttl)))\n+\t\t\terror(2, errno, \"IPV6_MULTICAST_HOPS\");\n+\t\tif (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, \u0026zero,\n+\t\t\t       sizeof(zero)))\n+\t\t\terror(2, errno, \"IPV6_MULTICAST_LOOP\");\n+\t} else {\n+\t\tstruct ip_mreqn mr = { .imr_ifindex = ifindex };\n+\n+\t\tif (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, \u0026mr,\n+\t\t\t       sizeof(mr)))\n+\t\t\terror(2, errno, \"IP_MULTICAST_IF\");\n+\t\tif (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, \u0026ttl,\n+\t\t\t       sizeof(ttl)))\n+\t\t\terror(2, errno, \"IP_MULTICAST_TTL\");\n+\t\tif (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, \u0026zero,\n+\t\t\t       sizeof(zero)))\n+\t\t\terror(2, errno, \"IP_MULTICAST_LOOP\");\n+\t}\n+\tif (c-\u003egso) {\n+\t\tint gso = c-\u003eseg;\n+\n+\t\tif (setsockopt(fd, IPPROTO_UDP, UDP_SEGMENT, \u0026gso, sizeof(gso)))\n+\t\t\terror(2, errno, \"UDP_SEGMENT\");\n+\t}\n+\tfill_addr(c, c-\u003egroup, c-\u003eport, \u0026dst, \u0026dlen);\n+\n+\tfor (i = 0; i \u003c c-\u003enum; i++) {\n+\t\tfill_dgram(c, i, buf);\n+\t\tif (sendto(fd, buf, total, 0, (void *)\u0026dst, dlen) !=\n+\t\t    (ssize_t)total)\n+\t\t\terror(2, errno, \"sendto\");\n+\t\tif (c-\u003edelay_us)\n+\t\t\tusleep(c-\u003edelay_us);\n+\t}\n+\tclose(fd);\n+\treturn 0;\n+}\n+\n+static int do_recv(const struct cfg *c)\n+{\n+\tunsigned int per = chunks_per_dgram(c), expected = c-\u003enum * per;\n+\tunsigned int good = 0, bad_len = 0, bad_payload = 0, dup = 0, unk = 0;\n+\tstatic uint8_t buf[MAX_DGRAM + 1];\n+\tstruct sockaddr_storage any;\n+\tsocklen_t alen;\n+\tuint8_t *seen;\n+\tint fd, rcvbuf = 8 \u003c\u003c 20, idle_ms = 0;\n+\tbool got_any = false;\n+\n+\tseen = calloc(expected ? expected : 1, 1);\n+\tif (!seen)\n+\t\terror(2, errno, \"calloc\");\n+\tfd = open_udp(c);\n+\tsetsockopt(fd, SOL_SOCKET, SO_RCVBUF, \u0026rcvbuf, sizeof(rcvbuf));\n+\tfill_addr(c, c-\u003eipv6 ? \"::\" : \"0.0.0.0\", c-\u003eport, \u0026any, \u0026alen);\n+\tif (bind(fd, (void *)\u0026any, alen))\n+\t\terror(2, errno, \"bind\");\n+\tprintf(\"READY\\n\");\n+\tfflush(stdout);\n+\n+\twhile (good \u003c expected) {\n+\t\tstruct pollfd pfd = { .fd = fd, .events = POLLIN };\n+\t\tstruct chunk_hdr h;\n+\t\tunsigned int off;\n+\t\tssize_t n;\n+\t\tint r = poll(\u0026pfd, 1, 100);\n+\n+\t\tif (r \u003c 0)\n+\t\t\terror(2, errno, \"poll\");\n+\t\tif (!r) {\n+\t\t\tidle_ms += 100;\n+\t\t\tif (idle_ms \u003e=\n+\t\t\t    (int)(c-\u003eidle + (got_any ? 0 : c-\u003egrace)) * 1000)\n+\t\t\t\tbreak;\n+\t\t\tcontinue;\n+\t\t}\n+\t\tidle_ms = 0;\n+\t\tgot_any = true;\n+\t\tn = recv(fd, buf, sizeof(buf), 0);\n+\t\tif (n \u003c 0)\n+\t\t\terror(2, errno, \"recv\");\n+\t\tif (n \u003c (ssize_t)sizeof(h)) {\n+\t\t\tbad_len++;\n+\t\t\tcontinue;\n+\t\t}\n+\t\tmemcpy(\u0026h, buf, sizeof(h));\n+\t\tif (h.seq \u003e= c-\u003enum || h.idx \u003e= per) {\n+\t\t\tunk++;\n+\t\t\tcontinue;\n+\t\t}\n+\t\tif ((unsigned int)n != chunk_len(c, h.idx) || h.len != n) {\n+\t\t\tbad_len++;\n+\t\t\tcontinue;\n+\t\t}\n+\t\tfor (off = sizeof(h); off \u003c (unsigned int)n; off++)\n+\t\t\tif (buf[off] != fill_byte(h.seq, h.idx, off))\n+\t\t\t\tbreak;\n+\t\tif (off != (unsigned int)n) {\n+\t\t\tbad_payload++;\n+\t\t\tcontinue;\n+\t\t}\n+\t\tif (seen[h.seq * per + h.idx]++) {\n+\t\t\tdup++;\n+\t\t\tcontinue;\n+\t\t}\n+\t\tgood++;\n+\t}\n+\tprintf(\"RECV expected=%u good=%u bad_len=%u \", expected, good, bad_len);\n+\tprintf(\"bad_payload=%u dup=%u unknown=%u\\n\", bad_payload, dup, unk);\n+\tfree(seen);\n+\treturn good == expected \u0026\u0026 !bad_len \u0026\u0026 !bad_payload \u0026\u0026 !dup \u0026\u0026\n+\t       !unk ? 0 : 1;\n+}\n+\n+static int sniff_stop;\n+\n+static void sniff_sig(int sig)\n+{\n+\t__atomic_store_n(\u0026sniff_stop, 1, __ATOMIC_RELAXED);\n+}\n+\n+static int do_sniff(const struct cfg *c)\n+{\n+\tstatic uint8_t buf[MAX_DGRAM + 256];\n+\tunsigned int n = 0, max_len = 0, over = 0, amt = 0;\n+\tstruct sockaddr_ll sll = { .sll_family = AF_PACKET };\n+\tstruct timespec t0, last, now;\n+\tstruct tpacket_stats st = { 0 };\n+\tsocklen_t stlen = sizeof(st);\n+\tint fd, rcvbuf = 32 \u003c\u003c 20;\n+\n+\tfd = socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_ALL));\n+\tif (fd \u003c 0)\n+\t\terror(2, errno, \"socket(AF_PACKET)\");\n+\tsll.sll_protocol = htons(ETH_P_ALL);\n+\tsll.sll_ifindex = if_nametoindex(c-\u003eifname);\n+\tif (!sll.sll_ifindex)\n+\t\terror(2, errno, \"if_nametoindex\");\n+\tif (bind(fd, (void *)\u0026sll, sizeof(sll)))\n+\t\terror(2, errno, \"bind(AF_PACKET)\");\n+\t/* Do not lose frames to a full receive queue: they are counted */\n+\tif (setsockopt(fd, SOL_SOCKET, SO_RCVBUFFORCE, \u0026rcvbuf, sizeof(rcvbuf)))\n+\t\tsetsockopt(fd, SOL_SOCKET, SO_RCVBUF, \u0026rcvbuf, sizeof(rcvbuf));\n+\tsignal(SIGTERM, sniff_sig);\n+\tprintf(\"READY\\n\");\n+\tfflush(stdout);\n+\tclock_gettime(CLOCK_MONOTONIC, \u0026t0);\n+\tlast = t0;\n+\n+\tfor (;;) {\n+\t\t/* Once asked to stop, read what is still queued, then report */\n+\t\tint stopping = __atomic_load_n(\u0026sniff_stop, __ATOMIC_RELAXED);\n+\t\tstruct pollfd pfd = { .fd = fd, .events = POLLIN };\n+\t\tstruct sockaddr_ll from;\n+\t\tsocklen_t flen = sizeof(from);\n+\t\tunsigned int hl, dport;\n+\t\tconst uint8_t *p = buf;\n+\t\tssize_t len, got;\n+\t\tint r;\n+\n+\t\tclock_gettime(CLOCK_MONOTONIC, \u0026now);\n+\t\tif (!stopping \u0026\u0026 (now.tv_sec - t0.tv_sec \u003e 120 ||\n+\t\t\t\t  now.tv_sec - last.tv_sec \u003e= (long)c-\u003eidle))\n+\t\t\tbreak;\n+\t\tr = poll(\u0026pfd, 1, stopping ? 0 : 100);\n+\t\tif (r \u003c 0 \u0026\u0026 errno == EINTR)\n+\t\t\tcontinue;\n+\t\tif (r \u003c 0)\n+\t\t\terror(2, errno, \"poll\");\n+\t\tif (!r) {\n+\t\t\tif (stopping)\n+\t\t\t\tbreak;\n+\t\t\tcontinue;\n+\t\t}\n+\t\tgot = recvfrom(fd, buf, sizeof(buf), MSG_TRUNC,\n+\t\t\t       (void *)\u0026from, \u0026flen);\n+\t\tif (got \u003c 0)\n+\t\t\terror(2, errno, \"recvfrom\");\n+\t\tlen = got;\n+\t\tif (got \u003e (ssize_t)sizeof(buf))\n+\t\t\tgot = sizeof(buf);\n+\n+\t\tif (ntohs(from.sll_protocol) == ETH_P_IP \u0026\u0026 got \u003e= 28 \u0026\u0026\n+\t\t    (p[0] \u003e\u003e 4) == 4 \u0026\u0026 p[9] == IPPROTO_UDP) {\n+\t\t\thl = (p[0] \u0026 0xf) * 4;\n+\t\t} else if (ntohs(from.sll_protocol) == ETH_P_IPV6 \u0026\u0026\n+\t\t\t   got \u003e= 48 \u0026\u0026 (p[0] \u003e\u003e 4) == 6 \u0026\u0026\n+\t\t\t   p[6] == IPPROTO_UDP) {\n+\t\t\thl = 40;\n+\t\t} else {\n+\t\t\tcontinue;\n+\t\t}\n+\t\tif (got \u003c (ssize_t)(hl + sizeof(struct udphdr)))\n+\t\t\tcontinue;\n+\t\tdport = (p[hl + 2] \u003c\u003c 8) | p[hl + 3];\n+\t\tif (dport != c-\u003eport)\n+\t\t\tcontinue;\n+\t\tif (c-\u003eamt) {\n+\t\t\tconst uint8_t *a = p + hl + sizeof(struct udphdr);\n+\n+\t\t\t/* version 0, type 6, a reserved byte, the IP packet */\n+\t\t\tif (got \u003c (ssize_t)(hl + sizeof(struct udphdr) + 3) ||\n+\t\t\t    a[0] != AMT_MSG_MCAST_DATA || a[1] != 0)\n+\t\t\t\tcontinue;\n+\t\t\tif ((a[2] \u003e\u003e 4) != (c-\u003eipv6 ? 6 : 4))\n+\t\t\t\tcontinue;\n+\t\t\tamt++;\n+\t\t}\n+\t\tlast = now;\n+\t\tn++;\n+\t\tif ((unsigned int)len \u003e max_len)\n+\t\t\tmax_len = len;\n+\t\tif ((unsigned int)len \u003e c-\u003emtu)\n+\t\t\tover++;\n+\t}\n+\tgetsockopt(fd, SOL_PACKET, PACKET_STATISTICS, \u0026st, \u0026stlen);\n+\tprintf(\"SNIFF frames=%u max_len=%u over_mtu=%u amt_data=%u lost=%u\\n\",\n+\t       n, max_len, over, amt, st.tp_drops);\n+\treturn 0;\n+}\n+\n+static void usage(void)\n+{\n+\tfprintf(stderr,\n+\t\t\"amt_gso send|recv|sniff [-6] [-I ifname] [-g group] [-b srcaddr]\\n\"\n+\t\t\"           [-p port] [-s seg] [-c chunks] [-t tail] [-n datagrams]\\n\"\n+\t\t\"           [-G] [-d delay_us] [-T idle_s] [-S grace_s] [-M mtu] [-a]\\n\");\n+\texit(2);\n+}\n+\n+int main(int argc, char **argv)\n+{\n+\tstruct cfg c = { .port = 4000, .seg = 1200, .cnt = 8, .tail = 100,\n+\t\t\t .num = 1, .idle = 2, .mtu = 1500 };\n+\tint opt;\n+\n+\tif (argc \u003c 2)\n+\t\tusage();\n+\toptind = 2;\n+\twhile ((opt = getopt(argc, argv,\n+\t\t\t     \"6I:g:b:p:s:c:t:n:Gd:T:S:M:a\")) != -1) {\n+\t\tswitch (opt) {\n+\t\tcase '6':\n+\t\t\tc.ipv6 = true;\n+\t\t\tbreak;\n+\t\tcase 'I':\n+\t\t\tc.ifname = optarg;\n+\t\t\tbreak;\n+\t\tcase 'g':\n+\t\t\tc.group = optarg;\n+\t\t\tbreak;\n+\t\tcase 'b':\n+\t\t\tc.bind_addr = optarg;\n+\t\t\tbreak;\n+\t\tcase 'p':\n+\t\t\tc.port = atoi(optarg);\n+\t\t\tbreak;\n+\t\tcase 's':\n+\t\t\tc.seg = atoi(optarg);\n+\t\t\tbreak;\n+\t\tcase 'c':\n+\t\t\tc.cnt = atoi(optarg);\n+\t\t\tbreak;\n+\t\tcase 't':\n+\t\t\tc.tail = atoi(optarg);\n+\t\t\tbreak;\n+\t\tcase 'n':\n+\t\t\tc.num = atoi(optarg);\n+\t\t\tbreak;\n+\t\tcase 'G':\n+\t\t\tc.gso = true;\n+\t\t\tbreak;\n+\t\tcase 'd':\n+\t\t\tc.delay_us = atoi(optarg);\n+\t\t\tbreak;\n+\t\tcase 'S':\n+\t\t\tc.grace = atoi(optarg);\n+\t\t\tbreak;\n+\t\tcase 'T':\n+\t\t\tc.idle = atoi(optarg);\n+\t\t\tbreak;\n+\t\tcase 'M':\n+\t\t\tc.mtu = atoi(optarg);\n+\t\t\tbreak;\n+\t\tcase 'a':\n+\t\t\tc.amt = true;\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tusage();\n+\t\t}\n+\t}\n+\tif (!strcmp(argv[1], \"send\") \u0026\u0026 c.ifname \u0026\u0026 c.group)\n+\t\treturn do_send(\u0026c);\n+\tif (!strcmp(argv[1], \"recv\"))\n+\t\treturn do_recv(\u0026c);\n+\tif (!strcmp(argv[1], \"sniff\") \u0026\u0026 c.ifname)\n+\t\treturn do_sniff(\u0026c);\n+\tusage();\n+\treturn 2;\n+}\ndiff --git a/tools/testing/selftests/net/amt_gso.sh b/tools/testing/selftests/net/amt_gso.sh\nnew file mode 100755\nindex 0000000000000..3c37cb59d9b02\n--- /dev/null\n+++ b/tools/testing/selftests/net/amt_gso.sh\n@@ -0,0 +1,269 @@\n+#!/bin/bash\n+# SPDX-License-Identifier: GPL-2.0\n+#\n+# Check that an AMT relay forwards a UDP GSO burst (UDP_SEGMENT) to a gateway\n+# when transmit checksum offload is enabled on the amt device.\n+#\n+# With the default features the core segments the burst before it reaches\n+# amt_dev_xmit(), so that case is the positive control for the harness. With\n+# \"tx on\" the unsegmented GSO skb is handed to the driver, which must mark it\n+# as a UDP tunnel packet before it hands it to the lower device.\n+#\n+# There are three network namespaces. The sender runs in the RELAY namespace,\n+# because a forwarded GRO skb with DF set would be dropped by the multicast\n+# router before it ever gets to amt.\n+#\n+#   LISTENER             GATEWAY                RELAY\n+#  +---------+        +-------------+       +-----------------+\n+#  |  l_gw   |--------| gw_l  br0   |       |                 |\n+#  |         |        |       amtg  |       |  amtr  \u003c- sender|\n+#  +---------+        |  gw_relay   |-------| relay_gw        |\n+#                     +-------------+       +-----------------+\n+#\n+# amt_gso, built from amt_gso.c, sends, receives and captures. The listener\n+# reports datagrams by count, length and payload. A capture on amtr shows what\n+# was handed to amt_dev_xmit(), and one on gw_relay shows what was put on the\n+# wire.\n+\n+source lib.sh\n+\n+AMT_GSO=./amt_gso\n+GRP4=239.0.0.1\n+GRP6=ff0e::5:6\n+SRC4=192.0.2.1\n+SRC6=2001:db8:3::1\n+PORT_AMT=2268\n+SEG=1200\n+TAIL=100\n+BURST=8\n+NUM=100\n+PROBE_OPTS=(-s 64 -c 1 -t 0 -n 1)\n+\n+TMPD=$(mktemp -d)\n+\n+cleanup()\n+{\n+\trm -rf \"$TMPD\"\n+\tcleanup_all_ns\n+}\n+\n+trap cleanup EXIT\n+\n+dev_stat()\n+{\n+\tip netns exec \"$1\" cat \"/sys/class/net/$2/statistics/$3\"\n+}\n+\n+csum_errors()\n+{\n+\tip netns exec \"$GATEWAY\" nstat -asz UdpInCsumErrors |\n+\t\tawk '$1 == \"UdpInCsumErrors\" { n = $2 } END { print n + 0 }'\n+}\n+\n+field()\n+{\n+\tlocal val\n+\n+\tval=$(grep -o \" $2=[0-9]*\" \"$1\" | tail -n 1 | cut -d= -f2)\n+\techo \"${val:-0}\"\n+}\n+\n+skip_all()\n+{\n+\tlog_test_skip \"$1\"\n+\texit \"$EXIT_STATUS\"\n+}\n+\n+setup_topology()\n+{\n+\tsetup_ns LISTENER GATEWAY RELAY || exit $ksft_skip\n+\n+\tip link add l_gw netns \"$LISTENER\" type veth peer name gw_l \\\n+\t\tnetns \"$GATEWAY\"\n+\tip link add gw_relay netns \"$GATEWAY\" type veth peer name relay_gw \\\n+\t\tnetns \"$RELAY\"\n+\n+\tip -n \"$LISTENER\" link set l_gw up\n+\tip -n \"$LISTENER\" addr add 192.168.0.2/24 dev l_gw\n+\tip -n \"$LISTENER\" addr add 2001:db8::2/64 dev l_gw nodad\n+\tip -n \"$LISTENER\" route add default via 192.168.0.1 dev l_gw\n+\tip -n \"$LISTENER\" addr add \"$GRP4\"/32 dev l_gw autojoin\n+\tip -n \"$LISTENER\" addr add \"$GRP6\"/128 dev l_gw autojoin\n+\n+\tip -n \"$GATEWAY\" link set gw_l up\n+\tip -n \"$GATEWAY\" link set gw_relay up\n+\tip -n \"$GATEWAY\" addr add 192.168.0.1/24 dev gw_l\n+\tip -n \"$GATEWAY\" addr add 2001:db8::1/64 dev gw_l nodad\n+\tip -n \"$GATEWAY\" addr add 10.0.0.1/24 dev gw_relay\n+\tip -n \"$GATEWAY\" link add br0 type bridge\n+\tip -n \"$GATEWAY\" link set br0 up\n+\tip -n \"$GATEWAY\" link set gw_l master br0\n+\tip -n \"$GATEWAY\" link add amtg master br0 type amt mode gateway \\\n+\t\tlocal 10.0.0.1 discovery 10.0.0.2 dev gw_relay \\\n+\t\tgateway_port $PORT_AMT relay_port $PORT_AMT || exit $ksft_skip\n+\n+\tip -n \"$RELAY\" link set relay_gw up\n+\tip -n \"$RELAY\" addr add 10.0.0.2/24 dev relay_gw\n+\tip -n \"$RELAY\" link add amtr type amt mode relay local 10.0.0.2 \\\n+\t\tdev relay_gw relay_port $PORT_AMT max_tunnels 4 ||\n+\t\texit $ksft_skip\n+\tip -n \"$RELAY\" addr add \"$SRC4\"/32 dev amtr\n+\tip -n \"$RELAY\" addr add \"$SRC6\"/128 dev amtr nodad\n+\tip -n \"$RELAY\" link set amtr up\n+\tip -n \"$GATEWAY\" link set amtg up\n+\n+\t# Segment and checksum in software on the relay's egress, so that the\n+\t# frames on the wire are at most one MTU and carry a final checksum\n+\t# whatever the veth can do.\n+\tip netns exec \"$RELAY\" ethtool -K relay_gw tx off \u003e/dev/null ||\n+\t\texit $ksft_skip\n+\n+\tAMTR_MTU=$(ip netns exec \"$RELAY\" cat /sys/class/net/amtr/mtu)\n+}\n+\n+# Send one single-datagram probe every second until the listener sees it,\n+# which means that discovery, request and update are done for this group.\n+wait_tunnel()\n+{\n+\tlocal fam=$1 v6=\"\" grp=$GRP4 src=$SRC4 port=4999 i\n+\n+\t[ \"$fam\" = 6 ] \u0026\u0026 { v6=-6; grp=$GRP6; src=$SRC6; port=6999; }\n+\n+\tfor i in $(seq 40); do\n+\t\tip netns exec \"$LISTENER\" $AMT_GSO recv $v6 -p $port \\\n+\t\t\t\"${PROBE_OPTS[@]}\" -T 1 \u003e\"$TMPD/probe.out\" \u0026\n+\t\tlocal pid=$!\n+\t\tbusywait 5000 grep -q READY \"$TMPD/probe.out\"\n+\t\tip netns exec \"$RELAY\" $AMT_GSO send $v6 -I amtr -g $grp \\\n+\t\t\t-b $src -p $port \"${PROBE_OPTS[@]}\"\n+\t\twait $pid \u0026\u0026 return 0\n+\tdone\n+\treturn 1\n+}\n+\n+# run_burst \u003c4|6\u003e \u003cgso 0|1\u003e: send NUM datagrams and capture. Sets RECV_RC.\n+run_burst()\n+{\n+\tlocal fam=$1 gso=$2 v6=\"\" grp=$GRP4 src=$SRC4 port=4000 cnt=$BURST\n+\tlocal tail=$TAIL gsoopt=\"\" pid_r pid_a pid_g f\n+\n+\t[ \"$fam\" = 6 ] \u0026\u0026 { v6=-6; grp=$GRP6; src=$SRC6; port=6000; }\n+\tif [ \"$gso\" = 1 ]; then\n+\t\tgsoopt=-G\n+\telse\n+\t\tcnt=1\n+\t\ttail=0\n+\tfi\n+\tlocal opts=(-s \"$SEG\" -c \"$cnt\" -t \"$tail\" -n \"$NUM\")\n+\n+\trm -f \"$TMPD\"/{recv,amtr,gw}.out\n+\n+\tip netns exec \"$LISTENER\" $AMT_GSO recv $v6 -p $port \"${opts[@]}\" \\\n+\t\t-T 3 -S 15 \u003e\"$TMPD/recv.out\" \u0026\n+\tpid_r=$!\n+\tip netns exec \"$RELAY\" $AMT_GSO sniff -I amtr -p $port -M \"$AMTR_MTU\" \\\n+\t\t-T 20 \u003e\"$TMPD/amtr.out\" \u0026\n+\tpid_a=$!\n+\tip netns exec \"$GATEWAY\" $AMT_GSO sniff -I gw_relay -p $PORT_AMT \\\n+\t\t-M 1500 -a $v6 -T 20 \u003e\"$TMPD/gw.out\" \u0026\n+\tpid_g=$!\n+\tfor f in recv amtr gw; do\n+\t\tbusywait 5000 grep -q READY \"$TMPD/$f.out\"\n+\tdone\n+\n+\tDROP0=$(dev_stat \"$RELAY\" relay_gw tx_dropped)\n+\tTXP0=$(dev_stat \"$RELAY\" relay_gw tx_packets)\n+\tCSUM0=$(csum_errors)\n+\tGRX0=$(dev_stat \"$GATEWAY\" amtg rx_packets)\n+\tLRX0=$(dev_stat \"$LISTENER\" l_gw rx_packets)\n+\tGRXD0=$(dev_stat \"$GATEWAY\" amtg rx_dropped)\n+\n+\tip netns exec \"$RELAY\" $AMT_GSO send $v6 -I amtr -g $grp -b $src \\\n+\t\t-p $port \"${opts[@]}\" $gsoopt -d 2000\n+\n+\twait $pid_r\n+\tRECV_RC=$?\n+\t# The receiver is done, so every frame the captures will see is already\n+\t# queued on their sockets. Ask them to drain it and report.\n+\tkill -TERM $pid_a $pid_g\n+\twait $pid_a $pid_g\n+\n+\tDROPS=$(($(dev_stat \"$RELAY\" relay_gw tx_dropped) - DROP0))\n+\tTXP=$(($(dev_stat \"$RELAY\" relay_gw tx_packets) - TXP0))\n+\tCSUMERR=$(($(csum_errors) - CSUM0))\n+\tGRX=$(($(dev_stat \"$GATEWAY\" amtg rx_packets) - GRX0))\n+\tLRX=$(($(dev_stat \"$LISTENER\" l_gw rx_packets) - LRX0))\n+\tGRXD=$(($(dev_stat \"$GATEWAY\" amtg rx_dropped) - GRXD0))\n+\tEXPECT=$((NUM * (cnt + (tail ? 1 : 0))))\n+}\n+\n+# run_case \u003cname\u003e \u003c4|6\u003e \u003ctx on|off\u003e \u003cgso 0|1\u003e\n+run_case()\n+{\n+\tlocal name=$1 fam=$2 tx=$3 gso=$4 big gwn stats\n+\n+\tRET=0\n+\tretmsg=\n+\tip netns exec \"$RELAY\" ethtool -K amtr tx \"$tx\" \u003e/dev/null\n+\tif [ \"$tx\" = on ] \u0026\u0026 ! ip netns exec \"$RELAY\" ethtool -k amtr |\n+\t   grep -q '^tx-udp-segmentation: on'; then\n+\t\tlog_test_skip \"$name\" \"amtr cannot take tx-udp-segmentation\"\n+\t\treturn\n+\tfi\n+\n+\trun_burst \"$fam\" \"$gso\"\n+\tbig=$(field \"$TMPD/amtr.out\" over_mtu)\n+\n+\tgwn=$(field \"$TMPD/gw.out\" amt_data)\n+\tlog_info \"$name: $(grep RECV \"$TMPD/recv.out\")\"\n+\tlog_info \"$name: amtr tx $(grep SNIFF \"$TMPD/amtr.out\")\"\n+\tlog_info \"$name: wire $(grep SNIFF \"$TMPD/gw.out\")\"\n+\tstats=\"relay_gw tx +$TXP drop +$DROPS; gw csum_err +$CSUMERR\"\n+\tstats=\"$stats; amtg rx +$GRX drop +$GRXD; listener rx +$LRX\"\n+\tlog_info \"$name: $stats\"\n+\n+\tcheck_err $(($(field \"$TMPD/amtr.out\" lost) + \\\n+\t\t     $(field \"$TMPD/gw.out\" lost) != 0)) \\\n+\t\t\"a packet capture lost frames, the verdict is unreliable\"\n+\tcheck_err $RECV_RC \"listener did not get every datagram intact\"\n+\tcheck_err $((DROPS != 0)) \"relay_gw dropped $DROPS packets\"\n+\tcheck_err $((CSUMERR != 0)) \"gateway counted $CSUMERR csum errors\"\n+\tcheck_err $((gwn != EXPECT)) \\\n+\t\t\"gateway saw $gwn AMT data messages, expected $EXPECT\"\n+\tcheck_err $(($(field \"$TMPD/gw.out\" over_mtu) != 0)) \\\n+\t\t\"frames larger than the MTU were put on the wire\"\n+\n+\tif [ \"$tx\" = on ] \u0026\u0026 [ \"$gso\" = 1 ]; then\n+\t\t# Without this the case proves nothing about the driver.\n+\t\t[ \"$big\" = 0 ] \u0026\u0026 ret_set_ksft_status \"$ksft_skip\" \\\n+\t\t\t\"no GSO skb reached amt_dev_xmit()\"\n+\telse\n+\t\tcheck_err $((big != 0)) \\\n+\t\t\t\"a frame larger than the MTU reached amt_dev_xmit()\"\n+\tfi\n+\n+\tlog_test \"$name\"\n+}\n+\n+require_command ip\n+require_command ethtool\n+require_command nstat\n+[ -x $AMT_GSO ] || skip_all \"amt_gso helper not built\"\n+ip link help 2\u003e\u00261 | grep -q amt || skip_all \"iproute2 without amt support\"\n+# Without AF_PACKET (CONFIG_PACKET, CAP_NET_RAW) there is no verdict.\n+$AMT_GSO sniff -I lo -p 1 -T 0 \u003e/dev/null 2\u003e\u00261 ||\n+\tskip_all \"AF_PACKET capture not available\"\n+\n+setup_topology\n+\n+wait_tunnel 4 || skip_all \"IPv4 AMT tunnel did not come up\"\n+wait_tunnel 6 || skip_all \"IPv6 AMT tunnel did not come up\"\n+\n+run_case \"IPv4 UDP_SEGMENT burst, amt tx offload off (control)\" 4 off 1\n+run_case \"IPv6 UDP_SEGMENT burst, amt tx offload off (control)\" 6 off 1\n+run_case \"IPv4 UDP_SEGMENT burst, amt tx offload on\" 4 on 1\n+run_case \"IPv6 UDP_SEGMENT burst, amt tx offload on\" 6 on 1\n+run_case \"IPv4 plain datagrams, amt tx offload on\" 4 on 0\n+run_case \"IPv6 plain datagrams, amt tx offload on\" 6 on 0\n+\n+exit \"$EXIT_STATUS\"\ndiff --git a/tools/testing/selftests/net/config b/tools/testing/selftests/net/config\nindex 737e7e6327b37..8f23da47405b9 100644\n--- a/tools/testing/selftests/net/config\n+++ b/tools/testing/selftests/net/config\n@@ -117,6 +117,7 @@ CONFIG_NFT_COMPAT=m\n CONFIG_NFT_NAT=m\n CONFIG_NUMA=y\n CONFIG_OPENVSWITCH=m\n+CONFIG_PACKET=y\n CONFIG_PAGE_POOL_STATS=y\n CONFIG_PSAMPLE=m\n CONFIG_RPS=y\n"
}

2/1 2026/10/03 08:55 agent patch-evaluator
2m Model:
core

Args:
null

Results:
{
  "EnableConfigs": [
    "AMT",
    "IP_MULTICAST",
    "INET"
  ],
  "FocusSymbols": [
    "amt_send_multicast_data",
    "amt_dev_xmit"
  ],
  "Reasoning": "The patch modifies amt_send_multicast_data() in drivers/net/amt.c to reset the MAC header and invoke udp_tunnel_handle_offloads() on outgoing multicast packets. AMT is a virtual network device driver configurable via rtnetlink and reachable in standard virtualized environments. Fuzzing is warranted to test packet segmentation, encapsulation offloading, and error handling paths.",
  "WorthFuzzing": true
}

Instruction:
You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.

================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.

- REACHABILITY IS THE PRIMARY GATE:
  Fuzzing can only discover bugs in code that can actually execute in standard virtualized
  environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
  If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
  regardless of whether it adds assertions or complex logic.

- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
  Patch authors routinely label changes as "cleanups", "refactorings", or state
  "No functional change intended". Do NOT take these claims at face value.
  Code refactorings that rearrange logic, introduce helper functions, or alter state management
  in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
  If reachable executable code is modified or refactored, it MUST be fuzzed.

- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
  When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
  BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
  Even if the author believes the invariant always holds, fuzzing is essential to verify whether
  an unusual sequence of operations can violate it.

================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:

- Non-kernel and non-executable changes:
  * Modifications to Documentation/, comments, or spelling fixes.
  * User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
    that do not affect the compiled kernel image (vmlinux) or kernel modules.
  * Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
    that do not alter control flow or data structures.
  * Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
  * Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
    ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
  * Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
    physical PCI hot-unplug or manual sysfs driver unbinding.
  * Code paths exclusive to architectures other than the target architecture.

================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
  * Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
    BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
  * Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
  * Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
  * Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).

================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:

- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
  Do NOT list generic, ubiquitous functions called by almost every program in the corpus
  (including, but not limited to: general memory allocators and deallocators, page fault
  and trap handlers, or core synchronization primitives; this is not an exhaustive list).
  Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
  which severely dilutes fuzzing effort away from the actual changes.

- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
  List functions that specifically implement the logic being added or altered, or direct API entrypoints
  for the subsystem feature under review.

- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
  Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
  distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
  If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
  functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).

================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
Target architecture: amd64

For your convenience, here is the diff of the changes:
commit da0c0ce6718afdc74d647e71e13c528b1f2c0c30
Author: syz-cluster <triage@syzkaller.com>
Date:   Sat Oct 3 08:55:58 2026 +0000

    syz-cluster: applied patch under review

diff --git a/drivers/net/amt.c b/drivers/net/amt.c
index 0277e4cac39bd..a8236d40c2e70 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;
diff --git a/tools/testing/selftests/net/.gitignore b/tools/testing/selftests/net/.gitignore
index dacd36ed8455e..489d37b990845 100644
--- a/tools/testing/selftests/net/.gitignore
+++ b/tools/testing/selftests/net/.gitignore
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
+amt_gso
 bind_bhash
 bind_timewait
 bind_wildcard
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index cab3f2c90039f..9af0d175b1018 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -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 \
diff --git a/tools/testing/selftests/net/amt_gso.c b/tools/testing/selftests/net/amt_gso.c
new file mode 100644
index 0000000000000..eebf3ecb94979
--- /dev/null
+++ b/tools/testing/selftests/net/amt_gso.c
@@ -0,0 +1,457 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Helper for amt_gso.sh.
+ *
+ * send:  send datagrams to a multicast group, optionally as one UDP_SEGMENT
+ *        burst per datagram, with a self-describing payload pattern.
+ * recv:  receive datagrams on a UDP port and check count, length and payload
+ *        of every one of them against the pattern used by "send".
+ * sniff: capture on an interface with AF_PACKET and report how large the
+ *        frames handed to the device were.
+ *
+ * Every datagram consists of cnt chunks of seg bytes followed by an optional
+ * tail chunk of tail bytes. A chunk starts with a struct chunk_hdr and the
+ * rest of it is a function of (datagram number, chunk number, offset).
+ * With UDP_SEGMENT set to seg, every chunk is one segment on the wire.
+ */
+#define _GNU_SOURCE
+#include <arpa/inet.h>
+#include <errno.h>
+#include <error.h>
+#include <linux/if_packet.h>
+#include <linux/if_ether.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <netinet/udp.h>
+#include <poll.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <time.h>
+#include <unistd.h>
+
+#ifndef UDP_SEGMENT
+#define UDP_SEGMENT	103
+#endif
+
+#define MAX_DGRAM	65507
+#define AMT_MSG_MCAST_DATA	6
+
+struct chunk_hdr {
+	uint32_t seq;
+	uint16_t idx;
+	uint16_t len;
+};
+
+struct cfg {
+	bool ipv6;
+	bool gso;
+	bool amt;		/* sniff: count AMT multicast data messages */
+	const char *ifname;
+	const char *group;
+	const char *bind_addr;
+	unsigned int port;
+	unsigned int seg;
+	unsigned int cnt;
+	unsigned int tail;
+	unsigned int num;
+	unsigned int delay_us;
+	unsigned int idle;
+	unsigned int grace;	/* recv: extra wait for the first datagram */
+	unsigned int mtu;
+};
+
+static uint8_t fill_byte(uint32_t seq, unsigned int idx, unsigned int off)
+{
+	return (uint8_t)(seq * 131 + idx * 17 + off * 7 + (off >> 8));
+}
+
+static unsigned int chunk_len(const struct cfg *c, unsigned int idx)
+{
+	return idx < c->cnt ? c->seg : c->tail;
+}
+
+static unsigned int chunks_per_dgram(const struct cfg *c)
+{
+	return c->cnt + (c->tail ? 1 : 0);
+}
+
+static void fill_dgram(const struct cfg *c, uint32_t seq, uint8_t *buf)
+{
+	unsigned int i, off, n = chunks_per_dgram(c);
+
+	for (i = 0; i < n; i++) {
+		unsigned int len = chunk_len(c, i);
+		struct chunk_hdr h = { .seq = seq, .idx = i, .len = len };
+
+		memcpy(buf, &h, sizeof(h));
+		for (off = sizeof(h); off < len; off++)
+			buf[off] = fill_byte(seq, i, off);
+		buf += len;
+	}
+}
+
+static int open_udp(const struct cfg *c)
+{
+	int fd = socket(c->ipv6 ? AF_INET6 : AF_INET, SOCK_DGRAM, 0);
+
+	if (fd < 0)
+		error(2, errno, "socket");
+	return fd;
+}
+
+static void fill_addr(const struct cfg *c, const char *str, unsigned int port,
+		      struct sockaddr_storage *ss, socklen_t *len)
+{
+	memset(ss, 0, sizeof(*ss));
+	if (c->ipv6) {
+		struct sockaddr_in6 *a = (void *)ss;
+
+		a->sin6_family = AF_INET6;
+		a->sin6_port = htons(port);
+		if (inet_pton(AF_INET6, str, &a->sin6_addr) != 1)
+			error(2, errno, "inet_pton");
+		*len = sizeof(*a);
+	} else {
+		struct sockaddr_in *a = (void *)ss;
+
+		a->sin_family = AF_INET;
+		a->sin_port = htons(port);
+		if (inet_pton(AF_INET, str, &a->sin_addr) != 1)
+			error(2, errno, "inet_pton");
+		*len = sizeof(*a);
+	}
+}
+
+static int do_send(const struct cfg *c)
+{
+	static uint8_t buf[MAX_DGRAM];
+	struct sockaddr_storage dst, src;
+	socklen_t dlen, slen;
+	unsigned int total, ifindex, i;
+	int fd, ttl = 8, zero = 0;
+
+	total = c->cnt * c->seg + c->tail;
+	if (total > MAX_DGRAM ||
+	    (c->tail && c->tail < sizeof(struct chunk_hdr)) ||
+	    c->seg < sizeof(struct chunk_hdr))
+		error(2, 0, "bad sizes");
+	ifindex = if_nametoindex(c->ifname);
+	if (!ifindex)
+		error(2, errno, "if_nametoindex");
+
+	fd = open_udp(c);
+	if (c->bind_addr) {
+		fill_addr(c, c->bind_addr, 0, &src, &slen);
+		if (bind(fd, (void *)&src, slen))
+			error(2, errno, "bind");
+	}
+	if (c->ipv6) {
+		if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF, &ifindex,
+			       sizeof(ifindex)))
+			error(2, errno, "IPV6_MULTICAST_IF");
+		if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &ttl,
+			       sizeof(ttl)))
+			error(2, errno, "IPV6_MULTICAST_HOPS");
+		if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &zero,
+			       sizeof(zero)))
+			error(2, errno, "IPV6_MULTICAST_LOOP");
+	} else {
+		struct ip_mreqn mr = { .imr_ifindex = ifindex };
+
+		if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, &mr,
+			       sizeof(mr)))
+			error(2, errno, "IP_MULTICAST_IF");
+		if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl,
+			       sizeof(ttl)))
+			error(2, errno, "IP_MULTICAST_TTL");
+		if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, &zero,
+			       sizeof(zero)))
+			error(2, errno, "IP_MULTICAST_LOOP");
+	}
+	if (c->gso) {
+		int gso = c->seg;
+
+		if (setsockopt(fd, IPPROTO_UDP, UDP_SEGMENT, &gso, sizeof(gso)))
+			error(2, errno, "UDP_SEGMENT");
+	}
+	fill_addr(c, c->group, c->port, &dst, &dlen);
+
+	for (i = 0; i < c->num; i++) {
+		fill_dgram(c, i, buf);
+		if (sendto(fd, buf, total, 0, (void *)&dst, dlen) !=
+		    (ssize_t)total)
+			error(2, errno, "sendto");
+		if (c->delay_us)
+			usleep(c->delay_us);
+	}
+	close(fd);
+	return 0;
+}
+
+static int do_recv(const struct cfg *c)
+{
+	unsigned int per = chunks_per_dgram(c), expected = c->num * per;
+	unsigned int good = 0, bad_len = 0, bad_payload = 0, dup = 0, unk = 0;
+	static uint8_t buf[MAX_DGRAM + 1];
+	struct sockaddr_storage any;
+	socklen_t alen;
+	uint8_t *seen;
+	int fd, rcvbuf = 8 << 20, idle_ms = 0;
+	bool got_any = false;
+
+	seen = calloc(expected ? expected : 1, 1);
+	if (!seen)
+		error(2, errno, "calloc");
+	fd = open_udp(c);
+	setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(rcvbuf));
+	fill_addr(c, c->ipv6 ? "::" : "0.0.0.0", c->port, &any, &alen);
+	if (bind(fd, (void *)&any, alen))
+		error(2, errno, "bind");
+	printf("READY\n");
+	fflush(stdout);
+
+	while (good < expected) {
+		struct pollfd pfd = { .fd = fd, .events = POLLIN };
+		struct chunk_hdr h;
+		unsigned int off;
+		ssize_t n;
+		int r = poll(&pfd, 1, 100);
+
+		if (r < 0)
+			error(2, errno, "poll");
+		if (!r) {
+			idle_ms += 100;
+			if (idle_ms >=
+			    (int)(c->idle + (got_any ? 0 : c->grace)) * 1000)
+				break;
+			continue;
+		}
+		idle_ms = 0;
+		got_any = true;
+		n = recv(fd, buf, sizeof(buf), 0);
+		if (n < 0)
+			error(2, errno, "recv");
+		if (n < (ssize_t)sizeof(h)) {
+			bad_len++;
+			continue;
+		}
+		memcpy(&h, buf, sizeof(h));
+		if (h.seq >= c->num || h.idx >= per) {
+			unk++;
+			continue;
+		}
+		if ((unsigned int)n != chunk_len(c, h.idx) || h.len != n) {
+			bad_len++;
+			continue;
+		}
+		for (off = sizeof(h); off < (unsigned int)n; off++)
+			if (buf[off] != fill_byte(h.seq, h.idx, off))
+				break;
+		if (off != (unsigned int)n) {
+			bad_payload++;
+			continue;
+		}
+		if (seen[h.seq * per + h.idx]++) {
+			dup++;
+			continue;
+		}
+		good++;
+	}
+	printf("RECV expected=%u good=%u bad_len=%u ", expected, good, bad_len);
+	printf("bad_payload=%u dup=%u unknown=%u\n", bad_payload, dup, unk);
+	free(seen);
+	return good == expected && !bad_len && !bad_payload && !dup &&
+	       !unk ? 0 : 1;
+}
+
+static int sniff_stop;
+
+static void sniff_sig(int sig)
+{
+	__atomic_store_n(&sniff_stop, 1, __ATOMIC_RELAXED);
+}
+
+static int do_sniff(const struct cfg *c)
+{
+	static uint8_t buf[MAX_DGRAM + 256];
+	unsigned int n = 0, max_len = 0, over = 0, amt = 0;
+	struct sockaddr_ll sll = { .sll_family = AF_PACKET };
+	struct timespec t0, last, now;
+	struct tpacket_stats st = { 0 };
+	socklen_t stlen = sizeof(st);
+	int fd, rcvbuf = 32 << 20;
+
+	fd = socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_ALL));
+	if (fd < 0)
+		error(2, errno, "socket(AF_PACKET)");
+	sll.sll_protocol = htons(ETH_P_ALL);
+	sll.sll_ifindex = if_nametoindex(c->ifname);
+	if (!sll.sll_ifindex)
+		error(2, errno, "if_nametoindex");
+	if (bind(fd, (void *)&sll, sizeof(sll)))
+		error(2, errno, "bind(AF_PACKET)");
+	/* Do not lose frames to a full receive queue: they are counted */
+	if (setsockopt(fd, SOL_SOCKET, SO_RCVBUFFORCE, &rcvbuf, sizeof(rcvbuf)))
+		setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(rcvbuf));
+	signal(SIGTERM, sniff_sig);
+	printf("READY\n");
+	fflush(stdout);
+	clock_gettime(CLOCK_MONOTONIC, &t0);
+	last = t0;
+
+	for (;;) {
+		/* Once asked to stop, read what is still queued, then report */
+		int stopping = __atomic_load_n(&sniff_stop, __ATOMIC_RELAXED);
+		struct pollfd pfd = { .fd = fd, .events = POLLIN };
+		struct sockaddr_ll from;
+		socklen_t flen = sizeof(from);
+		unsigned int hl, dport;
+		const uint8_t *p = buf;
+		ssize_t len, got;
+		int r;
+
+		clock_gettime(CLOCK_MONOTONIC, &now);
+		if (!stopping && (now.tv_sec - t0.tv_sec > 120 ||
+				  now.tv_sec - last.tv_sec >= (long)c->idle))
+			break;
+		r = poll(&pfd, 1, stopping ? 0 : 100);
+		if (r < 0 && errno == EINTR)
+			continue;
+		if (r < 0)
+			error(2, errno, "poll");
+		if (!r) {
+			if (stopping)
+				break;
+			continue;
+		}
+		got = recvfrom(fd, buf, sizeof(buf), MSG_TRUNC,
+			       (void *)&from, &flen);
+		if (got < 0)
+			error(2, errno, "recvfrom");
+		len = got;
+		if (got > (ssize_t)sizeof(buf))
+			got = sizeof(buf);
+
+		if (ntohs(from.sll_protocol) == ETH_P_IP && got >= 28 &&
+		    (p[0] >> 4) == 4 && p[9] == IPPROTO_UDP) {
+			hl = (p[0] & 0xf) * 4;
+		} else if (ntohs(from.sll_protocol) == ETH_P_IPV6 &&
+			   got >= 48 && (p[0] >> 4) == 6 &&
+			   p[6] == IPPROTO_UDP) {
+			hl = 40;
+		} else {
+			continue;
+		}
+		if (got < (ssize_t)(hl + sizeof(struct udphdr)))
+			continue;
+		dport = (p[hl + 2] << 8) | p[hl + 3];
+		if (dport != c->port)
+			continue;
+		if (c->amt) {
+			const uint8_t *a = p + hl + sizeof(struct udphdr);
+
+			/* version 0, type 6, a reserved byte, the IP packet */
+			if (got < (ssize_t)(hl + sizeof(struct udphdr) + 3) ||
+			    a[0] != AMT_MSG_MCAST_DATA || a[1] != 0)
+				continue;
+			if ((a[2] >> 4) != (c->ipv6 ? 6 : 4))
+				continue;
+			amt++;
+		}
+		last = now;
+		n++;
+		if ((unsigned int)len > max_len)
+			max_len = len;
+		if ((unsigned int)len > c->mtu)
+			over++;
+	}
+	getsockopt(fd, SOL_PACKET, PACKET_STATISTICS, &st, &stlen);
+	printf("SNIFF frames=%u max_len=%u over_mtu=%u amt_data=%u lost=%u\n",
+	       n, max_len, over, amt, st.tp_drops);
+	return 0;
+}
+
+static void usage(void)
+{
+	fprintf(stderr,
+		"amt_gso send|recv|sniff [-6] [-I ifname] [-g group] [-b srcaddr]\n"
+		"           [-p port] [-s seg] [-c chunks] [-t tail] [-n datagrams]\n"
+		"           [-G] [-d delay_us] [-T idle_s] [-S grace_s] [-M mtu] [-a]\n");
+	exit(2);
+}
+
+int main(int argc, char **argv)
+{
+	struct cfg c = { .port = 4000, .seg = 1200, .cnt = 8, .tail = 100,
+			 .num = 1, .idle = 2, .mtu = 1500 };
+	int opt;
+
+	if (argc < 2)
+		usage();
+	optind = 2;
+	while ((opt = getopt(argc, argv,
+			     "6I:g:b:p:s:c:t:n:Gd:T:S:M:a")) != -1) {
+		switch (opt) {
+		case '6':
+			c.ipv6 = true;
+			break;
+		case 'I':
+			c.ifname = optarg;
+			break;
+		case 'g':
+			c.group = optarg;
+			break;
+		case 'b':
+			c.bind_addr = optarg;
+			break;
+		case 'p':
+			c.port = atoi(optarg);
+			break;
+		case 's':
+			c.seg = atoi(optarg);
+			break;
+		case 'c':
+			c.cnt = atoi(optarg);
+			break;
+		case 't':
+			c.tail = atoi(optarg);
+			break;
+		case 'n':
+			c.num = atoi(optarg);
+			break;
+		case 'G':
+			c.gso = true;
+			break;
+		case 'd':
+			c.delay_us = atoi(optarg);
+			break;
+		case 'S':
+			c.grace = atoi(optarg);
+			break;
+		case 'T':
+			c.idle = atoi(optarg);
+			break;
+		case 'M':
+			c.mtu = atoi(optarg);
+			break;
+		case 'a':
+			c.amt = true;
+			break;
+		default:
+			usage();
+		}
+	}
+	if (!strcmp(argv[1], "send") && c.ifname && c.group)
+		return do_send(&c);
+	if (!strcmp(argv[1], "recv"))
+		return do_recv(&c);
+	if (!strcmp(argv[1], "sniff") && c.ifname)
+		return do_sniff(&c);
+	usage();
+	return 2;
+}
diff --git a/tools/testing/selftests/net/amt_gso.sh b/tools/testing/selftests/net/amt_gso.sh
new file mode 100755
index 0000000000000..3c37cb59d9b02
--- /dev/null
+++ b/tools/testing/selftests/net/amt_gso.sh
@@ -0,0 +1,269 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# Check that an AMT relay forwards a UDP GSO burst (UDP_SEGMENT) to a gateway
+# when transmit checksum offload is enabled on the amt device.
+#
+# With the default features the core segments the burst before it reaches
+# amt_dev_xmit(), so that case is the positive control for the harness. With
+# "tx on" the unsegmented GSO skb is handed to the driver, which must mark it
+# as a UDP tunnel packet before it hands it to the lower device.
+#
+# There are three network namespaces. The sender runs in the RELAY namespace,
+# because a forwarded GRO skb with DF set would be dropped by the multicast
+# router before it ever gets to amt.
+#
+#   LISTENER             GATEWAY                RELAY
+#  +---------+        +-------------+       +-----------------+
+#  |  l_gw   |--------| gw_l  br0   |       |                 |
+#  |         |        |       amtg  |       |  amtr  <- sender|
+#  +---------+        |  gw_relay   |-------| relay_gw        |
+#                     +-------------+       +-----------------+
+#
+# amt_gso, built from amt_gso.c, sends, receives and captures. The listener
+# reports datagrams by count, length and payload. A capture on amtr shows what
+# was handed to amt_dev_xmit(), and one on gw_relay shows what was put on the
+# wire.
+
+source lib.sh
+
+AMT_GSO=./amt_gso
+GRP4=239.0.0.1
+GRP6=ff0e::5:6
+SRC4=192.0.2.1
+SRC6=2001:db8:3::1
+PORT_AMT=2268
+SEG=1200
+TAIL=100
+BURST=8
+NUM=100
+PROBE_OPTS=(-s 64 -c 1 -t 0 -n 1)
+
+TMPD=$(mktemp -d)
+
+cleanup()
+{
+	rm -rf "$TMPD"
+	cleanup_all_ns
+}
+
+trap cleanup EXIT
+
+dev_stat()
+{
+	ip netns exec "$1" cat "/sys/class/net/$2/statistics/$3"
+}
+
+csum_errors()
+{
+	ip netns exec "$GATEWAY" nstat -asz UdpInCsumErrors |
+		awk '$1 == "UdpInCsumErrors" { n = $2 } END { print n + 0 }'
+}
+
+field()
+{
+	local val
+
+	val=$(grep -o " $2=[0-9]*" "$1" | tail -n 1 | cut -d= -f2)
+	echo "${val:-0}"
+}
+
+skip_all()
+{
+	log_test_skip "$1"
+	exit "$EXIT_STATUS"
+}
+
+setup_topology()
+{
+	setup_ns LISTENER GATEWAY RELAY || exit $ksft_skip
+
+	ip link add l_gw netns "$LISTENER" type veth peer name gw_l \
+		netns "$GATEWAY"
+	ip link add gw_relay netns "$GATEWAY" type veth peer name relay_gw \
+		netns "$RELAY"
+
+	ip -n "$LISTENER" link set l_gw up
+	ip -n "$LISTENER" addr add 192.168.0.2/24 dev l_gw
+	ip -n "$LISTENER" addr add 2001:db8::2/64 dev l_gw nodad
+	ip -n "$LISTENER" route add default via 192.168.0.1 dev l_gw
+	ip -n "$LISTENER" addr add "$GRP4"/32 dev l_gw autojoin
+	ip -n "$LISTENER" addr add "$GRP6"/128 dev l_gw autojoin
+
+	ip -n "$GATEWAY" link set gw_l up
+	ip -n "$GATEWAY" link set gw_relay up
+	ip -n "$GATEWAY" addr add 192.168.0.1/24 dev gw_l
+	ip -n "$GATEWAY" addr add 2001:db8::1/64 dev gw_l nodad
+	ip -n "$GATEWAY" addr add 10.0.0.1/24 dev gw_relay
+	ip -n "$GATEWAY" link add br0 type bridge
+	ip -n "$GATEWAY" link set br0 up
+	ip -n "$GATEWAY" link set gw_l master br0
+	ip -n "$GATEWAY" link add amtg master br0 type amt mode gateway \
+		local 10.0.0.1 discovery 10.0.0.2 dev gw_relay \
+		gateway_port $PORT_AMT relay_port $PORT_AMT || exit $ksft_skip
+
+	ip -n "$RELAY" link set relay_gw up
+	ip -n "$RELAY" addr add 10.0.0.2/24 dev relay_gw
+	ip -n "$RELAY" link add amtr type amt mode relay local 10.0.0.2 \
+		dev relay_gw relay_port $PORT_AMT max_tunnels 4 ||
+		exit $ksft_skip
+	ip -n "$RELAY" addr add "$SRC4"/32 dev amtr
+	ip -n "$RELAY" addr add "$SRC6"/128 dev amtr nodad
+	ip -n "$RELAY" link set amtr up
+	ip -n "$GATEWAY" link set amtg up
+
+	# Segment and checksum in software on the relay's egress, so that the
+	# frames on the wire are at most one MTU and carry a final checksum
+	# whatever the veth can do.
+	ip netns exec "$RELAY" ethtool -K relay_gw tx off >/dev/null ||
+		exit $ksft_skip
+
+	AMTR_MTU=$(ip netns exec "$RELAY" cat /sys/class/net/amtr/mtu)
+}
+
+# Send one single-datagram probe every second until the listener sees it,
+# which means that discovery, request and update are done for this group.
+wait_tunnel()
+{
+	local fam=$1 v6="" grp=$GRP4 src=$SRC4 port=4999 i
+
+	[ "$fam" = 6 ] && { v6=-6; grp=$GRP6; src=$SRC6; port=6999; }
+
+	for i in $(seq 40); do
+		ip netns exec "$LISTENER" $AMT_GSO recv $v6 -p $port \
+			"${PROBE_OPTS[@]}" -T 1 >"$TMPD/probe.out" &
+		local pid=$!
+		busywait 5000 grep -q READY "$TMPD/probe.out"
+		ip netns exec "$RELAY" $AMT_GSO send $v6 -I amtr -g $grp \
+			-b $src -p $port "${PROBE_OPTS[@]}"
+		wait $pid && return 0
+	done
+	return 1
+}
+
+# run_burst <4|6> <gso 0|1>: send NUM datagrams and capture. Sets RECV_RC.
+run_burst()
+{
+	local fam=$1 gso=$2 v6="" grp=$GRP4 src=$SRC4 port=4000 cnt=$BURST
+	local tail=$TAIL gsoopt="" pid_r pid_a pid_g f
+
+	[ "$fam" = 6 ] && { v6=-6; grp=$GRP6; src=$SRC6; port=6000; }
+	if [ "$gso" = 1 ]; then
+		gsoopt=-G
+	else
+		cnt=1
+		tail=0
+	fi
+	local opts=(-s "$SEG" -c "$cnt" -t "$tail" -n "$NUM")
+
+	rm -f "$TMPD"/{recv,amtr,gw}.out
+
+	ip netns exec "$LISTENER" $AMT_GSO recv $v6 -p $port "${opts[@]}" \
+		-T 3 -S 15 >"$TMPD/recv.out" &
+	pid_r=$!
+	ip netns exec "$RELAY" $AMT_GSO sniff -I amtr -p $port -M "$AMTR_MTU" \
+		-T 20 >"$TMPD/amtr.out" &
+	pid_a=$!
+	ip netns exec "$GATEWAY" $AMT_GSO sniff -I gw_relay -p $PORT_AMT \
+		-M 1500 -a $v6 -T 20 >"$TMPD/gw.out" &
+	pid_g=$!
+	for f in recv amtr gw; do
+		busywait 5000 grep -q READY "$TMPD/$f.out"
+	done
+
+	DROP0=$(dev_stat "$RELAY" relay_gw tx_dropped)
+	TXP0=$(dev_stat "$RELAY" relay_gw tx_packets)
+	CSUM0=$(csum_errors)
+	GRX0=$(dev_stat "$GATEWAY" amtg rx_packets)
+	LRX0=$(dev_stat "$LISTENER" l_gw rx_packets)
+	GRXD0=$(dev_stat "$GATEWAY" amtg rx_dropped)
+
+	ip netns exec "$RELAY" $AMT_GSO send $v6 -I amtr -g $grp -b $src \
+		-p $port "${opts[@]}" $gsoopt -d 2000
+
+	wait $pid_r
+	RECV_RC=$?
+	# The receiver is done, so every frame the captures will see is already
+	# queued on their sockets. Ask them to drain it and report.
+	kill -TERM $pid_a $pid_g
+	wait $pid_a $pid_g
+
+	DROPS=$(($(dev_stat "$RELAY" relay_gw tx_dropped) - DROP0))
+	TXP=$(($(dev_stat "$RELAY" relay_gw tx_packets) - TXP0))
+	CSUMERR=$(($(csum_errors) - CSUM0))
+	GRX=$(($(dev_stat "$GATEWAY" amtg rx_packets) - GRX0))
+	LRX=$(($(dev_stat "$LISTENER" l_gw rx_packets) - LRX0))
+	GRXD=$(($(dev_stat "$GATEWAY" amtg rx_dropped) - GRXD0))
+	EXPECT=$((NUM * (cnt + (tail ? 1 : 0))))
+}
+
+# run_case <name> <4|6> <tx on|off> <gso 0|1>
+run_case()
+{
+	local name=$1 fam=$2 tx=$3 gso=$4 big gwn stats
+
+	RET=0
+	retmsg=
+	ip netns exec "$RELAY" ethtool -K amtr tx "$tx" >/dev/null
+	if [ "$tx" = on ] && ! ip netns exec "$RELAY" ethtool -k amtr |
+	   grep -q '^tx-udp-segmentation: on'; then
+		log_test_skip "$name" "amtr cannot take tx-udp-segmentation"
+		return
+	fi
+
+	run_burst "$fam" "$gso"
+	big=$(field "$TMPD/amtr.out" over_mtu)
+
+	gwn=$(field "$TMPD/gw.out" amt_data)
+	log_info "$name: $(grep RECV "$TMPD/recv.out")"
+	log_info "$name: amtr tx $(grep SNIFF "$TMPD/amtr.out")"
+	log_info "$name: wire $(grep SNIFF "$TMPD/gw.out")"
+	stats="relay_gw tx +$TXP drop +$DROPS; gw csum_err +$CSUMERR"
+	stats="$stats; amtg rx +$GRX drop +$GRXD; listener rx +$LRX"
+	log_info "$name: $stats"
+
+	check_err $(($(field "$TMPD/amtr.out" lost) + \
+		     $(field "$TMPD/gw.out" lost) != 0)) \
+		"a packet capture lost frames, the verdict is unreliable"
+	check_err $RECV_RC "listener did not get every datagram intact"
+	check_err $((DROPS != 0)) "relay_gw dropped $DROPS packets"
+	check_err $((CSUMERR != 0)) "gateway counted $CSUMERR csum errors"
+	check_err $((gwn != EXPECT)) \
+		"gateway saw $gwn AMT data messages, expected $EXPECT"
+	check_err $(($(field "$TMPD/gw.out" over_mtu) != 0)) \
+		"frames larger than the MTU were put on the wire"
+
+	if [ "$tx" = on ] && [ "$gso" = 1 ]; then
+		# Without this the case proves nothing about the driver.
+		[ "$big" = 0 ] && ret_set_ksft_status "$ksft_skip" \
+			"no GSO skb reached amt_dev_xmit()"
+	else
+		check_err $((big != 0)) \
+			"a frame larger than the MTU reached amt_dev_xmit()"
+	fi
+
+	log_test "$name"
+}
+
+require_command ip
+require_command ethtool
+require_command nstat
+[ -x $AMT_GSO ] || skip_all "amt_gso helper not built"
+ip link help 2>&1 | grep -q amt || skip_all "iproute2 without amt support"
+# Without AF_PACKET (CONFIG_PACKET, CAP_NET_RAW) there is no verdict.
+$AMT_GSO sniff -I lo -p 1 -T 0 >/dev/null 2>&1 ||
+	skip_all "AF_PACKET capture not available"
+
+setup_topology
+
+wait_tunnel 4 || skip_all "IPv4 AMT tunnel did not come up"
+wait_tunnel 6 || skip_all "IPv6 AMT tunnel did not come up"
+
+run_case "IPv4 UDP_SEGMENT burst, amt tx offload off (control)" 4 off 1
+run_case "IPv6 UDP_SEGMENT burst, amt tx offload off (control)" 6 off 1
+run_case "IPv4 UDP_SEGMENT burst, amt tx offload on" 4 on 1
+run_case "IPv6 UDP_SEGMENT burst, amt tx offload on" 6 on 1
+run_case "IPv4 plain datagrams, amt tx offload on" 4 on 0
+run_case "IPv6 plain datagrams, amt tx offload on" 6 on 0
+
+exit "$EXIT_STATUS"
diff --git a/tools/testing/selftests/net/config b/tools/testing/selftests/net/config
index 737e7e6327b37..8f23da47405b9 100644
--- a/tools/testing/selftests/net/config
+++ b/tools/testing/selftests/net/config
@@ -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

3/2 2026/10/03 08:55 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 12855
							output: 36
							thoughts: 149
						

Thoughts:
Okay, here's my assessment of this patch series, as I see it.

**Syzkaller Fuzzing Evaluation**

Alright, I need to figure out if this patch series is worth the effort of fuzzing with syzkaller. My instinct is that this should be straightforward. First, I'll need to examine the changes themselves. Let's see... the diff lists a few modified files: `drivers/net/amt.c`, a `.gitignore` and `Makefile` within the self-tests directory, `amt_gso.c`, `amt_gso.sh`, and `config` also in the self-tests area.

The driver file, `drivers/net/amt.c` is the most interesting, so I should read around line 1078 to understand the core changes. This will give me a better understanding of what the patch actually *does*. This will be key. Depending on the changes in that driver, I'll be able to decide whether syzkaller is going to provide any benefit in finding new and interesting states.



4/2 2026/10/03 08:56 tool read-file
0m Args:
{
  "File": "drivers/net/amt.c",
  "FirstLine": 1060,
  "LineCount": 50
}

Results:
{
  "Contents": "1060:\tstatic void amt_send_multicast_data(struct amt_dev *amt,\n1061:\t\t\t\t\t    const struct sk_buff *oskb,\n1062:\t\t\t\t\t    struct amt_tunnel_list *tunnel,\n1063:\t\t\t\t\t    bool v6)\n1064:\t{\n1065:\t\tstruct amt_header_mcast_data *amtmd;\n1066:\t\tstruct sk_buff *skb;\n1067:\t\tstruct iphdr *iph;\n1068:\t\tstruct flowi4 fl4;\n1069:\t\tstruct rtable *rt;\n1070:\t\tstruct sock *sk;\n1071:\t\n1072:\t\tsk = rcu_dereference_bh(amt-\u003esk);\n1073:\t\tif (!sk)\n1074:\t\t\treturn;\n1075:\t\n1076:\t\tskb = skb_copy_expand(oskb, sizeof(*amtmd) + sizeof(*iph) +\n1077:\t\t\t\t      sizeof(struct udphdr), 0, GFP_ATOMIC);\n1078:\t\tif (!skb)\n1079:\t\t\treturn;\n1080:\t\n1081:\t\t/* amt_dev_xmit() pulled the Ethernet header without moving the mac\n1082:\t\t * header. The tunnelled payload has no link-layer header, so the\n1083:\t\t * inner mac header must coincide with the inner IP header.\n1084:\t\t */\n1085:\t\tskb_reset_mac_header(skb);\n1086:\t\tskb_reset_inner_headers(skb);\n1087:\t\tif (udp_tunnel_handle_offloads(skb, true)) {\n1088:\t\t\tkfree_skb(skb);\n1089:\t\t\treturn;\n1090:\t\t}\n1091:\t\n1092:\t\tmemset(\u0026fl4, 0, sizeof(struct flowi4));\n1093:\t\tfl4.flowi4_oif         = amt-\u003estream_dev-\u003eifindex;\n1094:\t\tfl4.daddr              = tunnel-\u003eip4;\n1095:\t\tfl4.saddr              = amt-\u003elocal_ip;\n1096:\t\tfl4.flowi4_proto       = IPPROTO_UDP;\n1097:\t\trt = ip_route_output_key(amt-\u003enet, \u0026fl4);\n1098:\t\tif (IS_ERR(rt)) {\n1099:\t\t\tnetdev_dbg(amt-\u003edev, \"no route to %pI4\\n\", \u0026tunnel-\u003eip4);\n1100:\t\t\tkfree_skb(skb);\n1101:\t\t\treturn;\n1102:\t\t}\n1103:\t\n1104:\t\tamtmd = skb_push(skb, sizeof(*amtmd));\n1105:\t\tamtmd-\u003eversion = 0;\n1106:\t\tamtmd-\u003ereserved = 0;\n1107:\t\tamtmd-\u003etype = AMT_MSG_MULTICAST_DATA;\n1108:\t\n1109:\t\tif (!v6)\n"
}

5/2 2026/10/03 08:56 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 14073
							output: 36
							thoughts: 57
						

Thoughts:
Okay, let's dive into this `amt_send_multicast_data` function. I need to understand its role within the larger framework of AMT device operation. My initial instinct is to trace its usage, to understand its call stack and what context it operates in. I need a clear picture of how multicast data transmission is handled in this AMT environment.

I'm thinking the best starting point is probably to jump right into the `drivers/net/amt.c` file and zero in on the relevant section of code. I'll focus on lines 1050 to 1180, or, I will use grep to filter for that function name to limit my search. This should give me a solid handle on how the function interacts with the rest of the AMT driver. Understanding this function's immediate dependencies and its overall place in the AMT data flow is critical to any deeper analysis.



6/2 2026/10/03 08:56 tool read-file
0m Args:
{
  "File": "drivers/net/amt.c",
  "FirstLine": 1110,
  "LineCount": 80
}

Results:
{
  "Contents": "1110:\t\t\tskb_set_inner_protocol(skb, htons(ETH_P_IP));\n1111:\t\telse\n1112:\t\t\tskb_set_inner_protocol(skb, htons(ETH_P_IPV6));\n1113:\t\tudp_tunnel_xmit_skb(rt, sk, skb,\n1114:\t\t\t\t    fl4.saddr,\n1115:\t\t\t\t    fl4.daddr,\n1116:\t\t\t\t    AMT_TOS,\n1117:\t\t\t\t    ip4_dst_hoplimit(\u0026rt-\u003edst),\n1118:\t\t\t\t    0,\n1119:\t\t\t\t    amt-\u003erelay_port,\n1120:\t\t\t\t    tunnel-\u003esource_port,\n1121:\t\t\t\t    false,\n1122:\t\t\t\t    false,\n1123:\t\t\t\t    0);\n1124:\t}\n1125:\t\n1126:\tstatic bool amt_send_membership_query(struct amt_dev *amt,\n1127:\t\t\t\t\t      struct sk_buff *skb,\n1128:\t\t\t\t\t      struct amt_tunnel_list *tunnel,\n1129:\t\t\t\t\t      bool v6)\n1130:\t{\n1131:\t\tstruct amt_header_membership_query *amtmq;\n1132:\t\tstruct rtable *rt;\n1133:\t\tstruct flowi4 fl4;\n1134:\t\tstruct sock *sk;\n1135:\t\tint err;\n1136:\t\n1137:\t\tsk = rcu_dereference_bh(amt-\u003esk);\n1138:\t\tif (!sk)\n1139:\t\t\treturn true;\n1140:\t\n1141:\t\terr = skb_cow_head(skb, LL_RESERVED_SPACE(amt-\u003edev) + sizeof(*amtmq) +\n1142:\t\t\t\t   sizeof(struct iphdr) + sizeof(struct udphdr));\n1143:\t\tif (err)\n1144:\t\t\treturn true;\n1145:\t\n1146:\t\tskb_reset_inner_headers(skb);\n1147:\t\tmemset(\u0026fl4, 0, sizeof(struct flowi4));\n1148:\t\tfl4.flowi4_oif         = amt-\u003estream_dev-\u003eifindex;\n1149:\t\tfl4.daddr              = tunnel-\u003eip4;\n1150:\t\tfl4.saddr              = amt-\u003elocal_ip;\n1151:\t\tfl4.flowi4_dscp        = inet_dsfield_to_dscp(AMT_TOS);\n1152:\t\tfl4.flowi4_proto       = IPPROTO_UDP;\n1153:\t\trt = ip_route_output_key(amt-\u003enet, \u0026fl4);\n1154:\t\tif (IS_ERR(rt)) {\n1155:\t\t\tnetdev_dbg(amt-\u003edev, \"no route to %pI4\\n\", \u0026tunnel-\u003eip4);\n1156:\t\t\treturn true;\n1157:\t\t}\n1158:\t\n1159:\t\tamtmq\t\t= skb_push(skb, sizeof(*amtmq));\n1160:\t\tamtmq-\u003eversion\t= 0;\n1161:\t\tamtmq-\u003etype\t= AMT_MSG_MEMBERSHIP_QUERY;\n1162:\t\tamtmq-\u003ereserved = 0;\n1163:\t\tamtmq-\u003el\t= 0;\n1164:\t\tamtmq-\u003eg\t= 0;\n1165:\t\tamtmq-\u003enonce\t= tunnel-\u003enonce;\n1166:\t\tamtmq-\u003eresponse_mac = tunnel-\u003emac;\n1167:\t\n1168:\t\tif (!v6)\n1169:\t\t\tskb_set_inner_protocol(skb, htons(ETH_P_IP));\n1170:\t\telse\n1171:\t\t\tskb_set_inner_protocol(skb, htons(ETH_P_IPV6));\n1172:\t\tudp_tunnel_xmit_skb(rt, sk, skb,\n1173:\t\t\t\t    fl4.saddr,\n1174:\t\t\t\t    fl4.daddr,\n1175:\t\t\t\t    AMT_TOS,\n1176:\t\t\t\t    ip4_dst_hoplimit(\u0026rt-\u003edst),\n1177:\t\t\t\t    0,\n1178:\t\t\t\t    amt-\u003erelay_port,\n1179:\t\t\t\t    tunnel-\u003esource_port,\n1180:\t\t\t\t    false,\n1181:\t\t\t\t    false,\n1182:\t\t\t\t    0);\n1183:\t\tamt_update_relay_status(tunnel, AMT_STATUS_SENT_QUERY, true);\n1184:\t\treturn false;\n1185:\t}\n1186:\t\n1187:\tstatic netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev)\n1188:\t{\n1189:\t\tstruct amt_dev *amt = netdev_priv(dev);\n"
}

7/2 2026/10/03 08:56 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 15654
							output: 36
							thoughts: 15
						

Thoughts:
Okay, here's my interpretation of that thought process, tailored for an expert audience, and rendered in the first person:

**Analyzing the Transmission Data**

Right, so we're looking at the data flow... I'm immediately thinking, "Okay, we've got the standard metrics, but what about the actual transmission volume?" It's not enough to just know the overall state; understanding the "amount of data development transmitted," or `amt_dev_xmit`, is critical. This is where the real meat of the analysis is, and if there is a gap between state, and transmitted data volume, then we have real questions to ask about our underlying systems. Gotta factor that in to have a full, clear picture.



8/2 2026/10/03 08:56 tool read-file
0m Args:
{
  "File": "drivers/net/amt.c",
  "FirstLine": 1187,
  "LineCount": 80
}

Results:
{
  "Contents": "1187:\tstatic netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev)\n1188:\t{\n1189:\t\tstruct amt_dev *amt = netdev_priv(dev);\n1190:\t\tstruct amt_tunnel_list *tunnel;\n1191:\t\tstruct amt_group_node *gnode;\n1192:\t\tunion amt_addr group = {0,};\n1193:\t#if IS_ENABLED(CONFIG_IPV6)\n1194:\t\tstruct ipv6hdr *ip6h;\n1195:\t\tstruct mld_msg *mld;\n1196:\t#endif\n1197:\t\tbool report = false;\n1198:\t\tstruct igmphdr *ih;\n1199:\t\tbool query = false;\n1200:\t\tstruct iphdr *iph;\n1201:\t\tbool data = false;\n1202:\t\tbool v6 = false;\n1203:\t\tu32 hash;\n1204:\t\n1205:\t\tiph = ip_hdr(skb);\n1206:\t\tif (iph-\u003eversion == 4) {\n1207:\t\t\tif (!ipv4_is_multicast(iph-\u003edaddr))\n1208:\t\t\t\tgoto free;\n1209:\t\n1210:\t\t\tif (!ip_mc_check_igmp(skb)) {\n1211:\t\t\t\tih = igmp_hdr(skb);\n1212:\t\t\t\tswitch (ih-\u003etype) {\n1213:\t\t\t\tcase IGMPV3_HOST_MEMBERSHIP_REPORT:\n1214:\t\t\t\tcase IGMP_HOST_MEMBERSHIP_REPORT:\n1215:\t\t\t\t\treport = true;\n1216:\t\t\t\t\tbreak;\n1217:\t\t\t\tcase IGMP_HOST_MEMBERSHIP_QUERY:\n1218:\t\t\t\t\tquery = true;\n1219:\t\t\t\t\tbreak;\n1220:\t\t\t\tdefault:\n1221:\t\t\t\t\tgoto free;\n1222:\t\t\t\t}\n1223:\t\t\t} else {\n1224:\t\t\t\tdata = true;\n1225:\t\t\t}\n1226:\t\t\tv6 = false;\n1227:\t\t\tgroup.ip4 = ip_hdr(skb)-\u003edaddr;\n1228:\t#if IS_ENABLED(CONFIG_IPV6)\n1229:\t\t} else if (iph-\u003eversion == 6) {\n1230:\t\t\tip6h = ipv6_hdr(skb);\n1231:\t\t\tif (!ipv6_addr_is_multicast(\u0026ip6h-\u003edaddr))\n1232:\t\t\t\tgoto free;\n1233:\t\n1234:\t\t\tif (!ipv6_mc_check_mld(skb)) {\n1235:\t\t\t\tmld = (struct mld_msg *)skb_transport_header(skb);\n1236:\t\t\t\tswitch (mld-\u003emld_type) {\n1237:\t\t\t\tcase ICMPV6_MGM_REPORT:\n1238:\t\t\t\tcase ICMPV6_MLD2_REPORT:\n1239:\t\t\t\t\treport = true;\n1240:\t\t\t\t\tbreak;\n1241:\t\t\t\tcase ICMPV6_MGM_QUERY:\n1242:\t\t\t\t\tquery = true;\n1243:\t\t\t\t\tbreak;\n1244:\t\t\t\tdefault:\n1245:\t\t\t\t\tgoto free;\n1246:\t\t\t\t}\n1247:\t\t\t} else {\n1248:\t\t\t\tdata = true;\n1249:\t\t\t}\n1250:\t\t\tv6 = true;\n1251:\t\t\tgroup.ip6 = ipv6_hdr(skb)-\u003edaddr;\n1252:\t#endif\n1253:\t\t} else {\n1254:\t\t\tdev-\u003estats.tx_errors++;\n1255:\t\t\tgoto free;\n1256:\t\t}\n1257:\t\n1258:\t\tif (!pskb_may_pull(skb, sizeof(struct ethhdr)))\n1259:\t\t\tgoto free;\n1260:\t\n1261:\t\tskb_pull(skb, sizeof(struct ethhdr));\n1262:\t\n1263:\t\tif (amt-\u003emode == AMT_MODE_GATEWAY) {\n1264:\t\t\t/* Gateway only passes IGMP/MLD packets */\n1265:\t\t\tif (!report)\n1266:\t\t\t\tgoto free;\n"
}

9/2 2026/10/03 08:56 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 16995
							output: 36
							thoughts: 16
						

Thoughts:
Okay, here's my attempt at summarizing the thought process, tailored for an expert audience, and written in the first person:

**Diving into `amt_dev_xmit`**

Alright, let's get down to brass tacks. I'm focusing on the next steps within the `amt_dev_xmit` function. My primary concern here is the flow of data transmission, and I'm instantly thinking about potential bottlenecks or points of failure. I need to understand how the data is being constructed, segmented, and then pushed out onto the wire.

I'm mentally tracing the sequence now. Are we dealing with hardware offload? If so, what's the interaction with the DMA engine? I need to quickly recall the interrupt handling strategy. Are we using a completion queue, or something more basic? Understanding the acknowledgement scheme is crucial for reliable delivery.

I'm immediately considering the potential for congestion. Are there any buffers involved? How are they managed? What's the backpressure mechanism if the downstream network is saturated? I need to think about error handling, too. What happens if a packet gets dropped or corrupted? Is there robust retransmission built in?

My intuition says there's a delicate balance here between performance and reliability. I suspect there are some trade-offs involved in optimizing for low latency versus guaranteed delivery. I'm looking for clues in the code about how those choices were made. Perhaps, the function utilizes a variety of configurable knobs in this area.

Ultimately, I'm trying to mentally map out the execution path to confirm that it's all making sense and isn't introducing a significant vulnerability or performance issue. I'm ready to dig deeper into the specifics, perhaps starting with the memory layout, next.



10/2 2026/10/03 08:56 tool read-file
0m Args:
{
  "File": "drivers/net/amt.c",
  "FirstLine": 1265,
  "LineCount": 40
}

Results:
{
  "Contents": "1265:\t\t\tif (!report)\n1266:\t\t\t\tgoto free;\n1267:\t\t\tif ((!v6 \u0026\u0026 !READ_ONCE(amt-\u003eready4)) ||\n1268:\t\t\t    (v6 \u0026\u0026 !READ_ONCE(amt-\u003eready6)))\n1269:\t\t\t\tgoto free;\n1270:\t\t\tif (amt_send_membership_update(amt, skb,  v6))\n1271:\t\t\t\tgoto free;\n1272:\t\t\tgoto unlock;\n1273:\t\t} else if (amt-\u003emode == AMT_MODE_RELAY) {\n1274:\t\t\tif (query) {\n1275:\t\t\t\ttunnel = amt_skb_cb(skb)-\u003etunnel;\n1276:\t\t\t\tif (!tunnel) {\n1277:\t\t\t\t\tWARN_ON(1);\n1278:\t\t\t\t\tgoto free;\n1279:\t\t\t\t}\n1280:\t\n1281:\t\t\t\t/* Do not forward unexpected query */\n1282:\t\t\t\tif (amt_send_membership_query(amt, skb, tunnel, v6))\n1283:\t\t\t\t\tgoto free;\n1284:\t\t\t\tgoto unlock;\n1285:\t\t\t}\n1286:\t\n1287:\t\t\tif (!data)\n1288:\t\t\t\tgoto free;\n1289:\t\t\tlist_for_each_entry_rcu(tunnel, \u0026amt-\u003etunnel_list, list) {\n1290:\t\t\t\thash = amt_group_hash(tunnel, \u0026group);\n1291:\t\t\t\thlist_for_each_entry_rcu(gnode, \u0026tunnel-\u003egroups[hash],\n1292:\t\t\t\t\t\t\t node) {\n1293:\t\t\t\t\tif (!v6) {\n1294:\t\t\t\t\t\tif (gnode-\u003egroup_addr.ip4 == group.ip4)\n1295:\t\t\t\t\t\t\tgoto found;\n1296:\t#if IS_ENABLED(CONFIG_IPV6)\n1297:\t\t\t\t\t} else {\n1298:\t\t\t\t\t\tif (ipv6_addr_equal(\u0026gnode-\u003egroup_addr.ip6,\n1299:\t\t\t\t\t\t\t\t    \u0026group.ip6))\n1300:\t\t\t\t\t\t\tgoto found;\n1301:\t#endif\n1302:\t\t\t\t\t}\n1303:\t\t\t\t}\n1304:\t\t\t\tcontinue;\n"
}

11/2 2026/10/03 08:56 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 18002
							output: 36
							thoughts: 16
						

Thoughts:
Okay, I'm ready to dive into that specific section. Let's focus on lines 1305-1335. This chunk...right, I need to understand what's being discussed here in order to offer a meaningful summary. I can't just regurgitate the text; I have to interpret it. Let me think. What's the context? What's the core argument or point being made within this segment? Is it a rebuttal, an elaboration, an example, or something else entirely? The specific line numbers suggest a focused discussion, so let's aim for the crux of this material. The goal is to provide a concise and, more importantly, accurate rendering of these ideas.

**My Analysis of Lines 1305-1335**

Okay, here's what I'm seeing. The key takeaway from these lines seems to be [Insert the core argument of the lines here, such as: "the author is outlining the inherent limitations of applying this particular model to systems with complex feedback loops"]. They're pointing out that [elaboration, adding context, and making this summary specific, not general]. Essentially, the author is cautioning against [a specific claim or assumption the author is countering, perhaps based on the previous lines' content]. It's a critical point to consider because [explain the implication of this point, demonstrating your expert knowledge to the user]. They also touch on [mention any significant supporting argument or illustrative example presented in the lines]. By presenting this section to me, I suspect they want me to understand the nuances of [specific topic related to the field]. Overall, this section serves as a [the purpose, function, and conclusion of this section in this context].



12/2 2026/10/03 08:56 tool read-file
0m Args:
{
  "File": "drivers/net/amt.c",
  "FirstLine": 1305,
  "LineCount": 40
}

Results:
{
  "Contents": "1305:\tfound:\n1306:\t\t\t\tamt_send_multicast_data(amt, skb, tunnel, v6);\n1307:\t\t\t}\n1308:\t\t}\n1309:\t\n1310:\t\tdev_kfree_skb(skb);\n1311:\t\treturn NETDEV_TX_OK;\n1312:\tfree:\n1313:\t\tdev_kfree_skb(skb);\n1314:\tunlock:\n1315:\t\tdev-\u003estats.tx_dropped++;\n1316:\t\treturn NETDEV_TX_OK;\n1317:\t}\n1318:\t\n1319:\tstatic int amt_parse_type(struct sk_buff *skb)\n1320:\t{\n1321:\t\tstruct amt_header *amth;\n1322:\t\n1323:\t\t/* skb-\u003edata is the UDP header on receive, but the quoted IP header\n1324:\t\t * when amt_err_lookup() parses an ICMP error, so pull up to the\n1325:\t\t * transport header rather than from skb-\u003edata.\n1326:\t\t */\n1327:\t\tif (!pskb_may_pull(skb, skb_transport_offset(skb) +\n1328:\t\t\t\t   sizeof(struct udphdr) + sizeof(struct amt_header)))\n1329:\t\t\treturn -1;\n1330:\t\n1331:\t\tamth = (struct amt_header *)(udp_hdr(skb) + 1);\n1332:\t\n1333:\t\tif (amth-\u003eversion != 0)\n1334:\t\t\treturn -1;\n1335:\t\n1336:\t\tif (amth-\u003etype \u003e= __AMT_MSG_MAX || !amth-\u003etype)\n1337:\t\t\treturn -1;\n1338:\t\treturn amth-\u003etype;\n1339:\t}\n1340:\t\n1341:\tstatic void amt_clear_groups(struct amt_tunnel_list *tunnel)\n1342:\t{\n1343:\t\tstruct amt_dev *amt = tunnel-\u003eamt;\n1344:\t\tstruct amt_group_node *gnode;\n"
}

13/2 2026/10/03 08:56 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 19000
							output: 16
							thoughts: 141
						

Thoughts:
**AMT Device Creation and Reachability in Standard Linux**

Okay, let's break this down. AMT – that's Automatic Multicast Tunneling, as defined in RFC 7450. And it seems like it's implemented as a virtual network device driver, specifically `amt.c`. The question is, can I instantiate one of these AMT devices in a standard Linux environment, without needing any special hardware? The answer appears to be yes. I can use the `ip link add` command with the `amt` type and specify either `relay` or `gateway` mode. This is all done through netlink, specifically rtnetlink.

Next, I need to know if this functionality is accessible in a standard QEMU setup, or even better, through something like syzkaller. The good news is, yes, syzkaller supports netlink operations, so I should be able to trigger AMT device creation there. It looks like it uses `syz_init_net_socket` or direct rtnetlink messages to create the AMT devices. Now, I should probably check the Kconfig file for AMT support to make sure it's enabled.



14/2 2026/10/03 08:56 tool grepper
0m Args:
{
  "Expression": "config AMT"
}

Results:
{
  "Output": "drivers/net/Kconfig=289=config PFCP\n--\ndrivers/net/Kconfig-301-\ndrivers/net/Kconfig:302:config AMT\ndrivers/net/Kconfig-303-\ttristate \"Automatic Multicast Tunneling (AMT)\"\n"
}

15/2 2026/10/03 08:56 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 19479
							output: 34
							thoughts: 18
						

Thoughts:
Okay, here's my summary, presented as a stream of thought:

**Checking the AMT Kconfig Definition**

Alright, let's get down to brass tacks. I need to understand how AMT (Active Management Technology) is configured within this network driver. So, my initial thought is, let's dive straight into the source. The `Kconfig` files are the bread and butter for configuration options in the kernel, so I'm heading directly to `drivers/net/Kconfig`. That's where I expect to find the definitive definition for anything AMT-related in this driver. No need to waste time guessing; the `Kconfig` file holds the truth. Let's see what's what.



16/2 2026/10/03 08:56 tool read-file
0m Args:
{
  "File": "drivers/net/Kconfig",
  "FirstLine": 300,
  "LineCount": 25
}

Results:
{
  "Contents": " 300:\t\t  will be called pfcp.\n 301:\t\n 302:\tconfig AMT\n 303:\t\ttristate \"Automatic Multicast Tunneling (AMT)\"\n 304:\t\tdepends on INET \u0026\u0026 IP_MULTICAST\n 305:\t\tselect NET_UDP_TUNNEL\n 306:\t\thelp\n 307:\t\t  This allows one to create AMT(Automatic Multicast Tunneling)\n 308:\t\t  virtual interfaces that provide multicast tunneling.\n 309:\t\t  There are two roles, Gateway, and Relay.\n 310:\t\t  Gateway Encapsulates IGMP/MLD traffic from listeners to the Relay.\n 311:\t\t  Gateway Decapsulates multicast traffic from the Relay to Listeners.\n 312:\t\t  Relay Encapsulates multicast traffic from Sources to Gateway.\n 313:\t\t  Relay Decapsulates IGMP/MLD traffic from Gateway.\n 314:\t\n 315:\t\t  To compile this drivers as a module, choose M here: the module\n 316:\t\t  will be called amt.\n 317:\t\n 318:\tconfig MACSEC\n 319:\t\ttristate \"IEEE 802.1AE MAC-level encryption (MACsec)\"\n 320:\t\tselect CRYPTO\n 321:\t\tselect CRYPTO_AES\n 322:\t\tselect CRYPTO_GCM\n 323:\t\tselect GRO_CELLS\n 324:\t\thelp\n"
}

17/2 2026/10/03 08:56 llm patch-evaluator
1m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 20065
							output: 22
							thoughts: 386
						

Thoughts:
**Analyzing the AMT Driver's Multicast Path**

Okay, so `CONFIG_AMT` hinges on `INET` and `IP_MULTICAST`, which makes sense. And it also brings in `NET_UDP_TUNNEL` – right, a tunnel interface is core to the function. Now, let's dissect this patch and see what's being tweaked.

Looking at the diff, it seems there's a significant change around the multicast data transmission: specifically, within `amt_send_multicast_data`. The code appears to be addressing a potential alignment issue with headers when tunneling. The comment about `amt_dev_xmit()` pulling the Ethernet header *without* shifting the MAC header is crucial. The payload within the tunnel lacks a link-layer header, so it's likely the code is ensuring the inner MAC header and the inner IP header are contiguous.

The `skb_reset_mac_header(skb)` and `skb_reset_inner_headers(skb)` calls confirm this is about header repositioning, that makes perfect sense. And now we have `udp_tunnel_handle_offloads(skb, true)` being introduced. It looks like the kernel is checking for offload handling and possibly releasing the skb if that fails, but I need to investigate what that function actually *does* to be certain. Where is that defined? I need to understand its role in this process and what offloads it's concerned with. Specifically, how it interacts with the UDP tunnel functionality and offload capabilities.



18/2 2026/10/03 08:57 tool grepper
0m Args:
{
  "Expression": "udp_tunnel_handle_offloads"
}

Results:
{
  "Output": "drivers/net/amt.c=1060=static void amt_send_multicast_data(struct amt_dev *amt,\n--\ndrivers/net/amt.c-1086-\tskb_reset_inner_headers(skb);\ndrivers/net/amt.c:1087:\tif (udp_tunnel_handle_offloads(skb, true)) {\ndrivers/net/amt.c-1088-\t\tkfree_skb(skb);\n--\ndrivers/net/bareudp.c=302=static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev,\n--\ndrivers/net/bareudp.c-354-\ndrivers/net/bareudp.c:355:\terr = udp_tunnel_handle_offloads(skb, udp_sum);\ndrivers/net/bareudp.c-356-\tif (err)\n--\ndrivers/net/bareudp.c=372=static int bareudp6_xmit_skb(struct sk_buff *skb, struct net_device *dev,\n--\ndrivers/net/bareudp.c-422-\ndrivers/net/bareudp.c:423:\terr = udp_tunnel_handle_offloads(skb, udp_sum);\ndrivers/net/bareudp.c-424-\tif (err)\n--\ndrivers/net/geneve.c=1320=static int geneve_build_skb(struct dst_entry *dst, struct sk_buff *skb,\n--\ndrivers/net/geneve.c-1346-\tdouble_encap = udp_tunnel_handle_partial(skb);\ndrivers/net/geneve.c:1347:\terr = udp_tunnel_handle_offloads(skb, udp_sum);\ndrivers/net/geneve.c-1348-\tif (err)\n--\ninclude/net/udp_tunnel.h=152=static inline bool udp_tunnel_handle_partial(struct sk_buff *skb)\n--\ninclude/net/udp_tunnel.h-159-\t * UDP_TUNNEL, that will be re-added by the later\ninclude/net/udp_tunnel.h:160:\t * udp_tunnel_handle_offloads().\ninclude/net/udp_tunnel.h-161-\t */\n--\ninclude/net/udp_tunnel.h=197=struct metadata_dst *udp_tun_rx_dst(struct sk_buff *skb, unsigned short family,\n--\ninclude/net/udp_tunnel.h-201-#ifdef CONFIG_INET\ninclude/net/udp_tunnel.h:202:static inline int udp_tunnel_handle_offloads(struct sk_buff *skb, bool udp_csum)\ninclude/net/udp_tunnel.h-203-{\n"
}

19/2 2026/10/03 08:57 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 21510
							output: 37
							thoughts: 22
						

Thoughts:
Here's a summary of my thinking process, assuming I'm an expert:

**Diving into the UDP Tunnel Header**

Okay, I need to understand something specific about the UDP tunnel implementation in the kernel.  The reference to `include/net/udp_tunnel.h` and the line number, around 200, strongly suggests we're looking at a critical data structure or macro definition related to handling encapsulated UDP traffic. This probably concerns the structure used to represent the tunnel itself or perhaps some core parameter related to connection management. I’m guessing it’s either the definition of the *struct* or a significant macro defining options or perhaps error codes. Line 200 is likely where the heart of the matter lies. Time to dig in and see what's what.



20/2 2026/10/03 08:57 tool read-file
0m Args:
{
  "File": "include/net/udp_tunnel.h",
  "FirstLine": 195,
  "LineCount": 40
}

Results:
{
  "Contents": " 195:\t\t\t\t\t\t struct dst_cache *dst_cache);\n 196:\t\n 197:\tstruct metadata_dst *udp_tun_rx_dst(struct sk_buff *skb, unsigned short family,\n 198:\t\t\t\t\t    const unsigned long *flags,\n 199:\t\t\t\t\t    __be64 tunnel_id, int md_size);\n 200:\t\n 201:\t#ifdef CONFIG_INET\n 202:\tstatic inline int udp_tunnel_handle_offloads(struct sk_buff *skb, bool udp_csum)\n 203:\t{\n 204:\t\tint type = udp_csum ? SKB_GSO_UDP_TUNNEL_CSUM : SKB_GSO_UDP_TUNNEL;\n 205:\t\n 206:\t\treturn iptunnel_handle_offloads(skb, type);\n 207:\t}\n 208:\t#endif\n 209:\t\n 210:\t#if IS_ENABLED(CONFIG_NET_UDP_TUNNEL)\n 211:\tvoid udp_tunnel_update_gro_lookup(struct net *net, struct sock *sk, bool add);\n 212:\tvoid udp_tunnel_update_gro_rcv(struct sock *sk, bool add);\n 213:\t#else\n 214:\tstatic inline void udp_tunnel_update_gro_lookup(struct net *net,\n 215:\t\t\t\t\t\t\tstruct sock *sk, bool add) {}\n 216:\tstatic inline void udp_tunnel_update_gro_rcv(struct sock *sk, bool add) {}\n 217:\t#endif\n 218:\t\n 219:\tstatic inline void udp_tunnel_cleanup_gro(struct sock *sk)\n 220:\t{\n 221:\t\tudp_tunnel_update_gro_rcv(sk, false);\n 222:\t\tudp_tunnel_update_gro_lookup(sock_net(sk), sk, false);\n 223:\t}\n 224:\t\n 225:\tstatic inline void udp_tunnel_encap_enable(struct sock *sk)\n 226:\t{\n 227:\t\tif (udp_test_and_set_bit(ENCAP_ENABLED, sk))\n 228:\t\t\treturn;\n 229:\t\n 230:\t#if IS_ENABLED(CONFIG_IPV6)\n 231:\t\tif (READ_ONCE(sk-\u003esk_family) == PF_INET6)\n 232:\t\t\tudpv6_encap_enable();\n 233:\t#endif\n 234:\t\tudp_encap_enable();\n"
}

21/2 2026/10/03 08:57 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 22418
							output: 21
							thoughts: 60
						

Thoughts:
Here's my summary, as if I were thinking it:

**Digging into IP Tunnel Offload Handling**

Okay, so I need to understand how IP tunnel offloads are managed. The first thing I'm going to check is the `iptunnel_handle_offloads` function. I remember seeing that name somewhere, but I need to refresh my memory on the exact functionality. Let's see... what does this function *actually* do? I'll head over to the source code – most likely `net/ipv4/ip_tunnel_core.c`, or wherever this is defined, and delve in there to get a better handle on this. I'll need to understand the relationship between the `skb` (socket buffer) and the `type` parameter, too.



22/2 2026/10/03 08:57 tool grepper
0m Args:
{
  "Expression": "iptunnel_handle_offloads"
}

Results:
{
  "Output": "drivers/net/vxlan/vxlan_core.c=2245=static int vxlan_build_skb(struct sk_buff *skb, struct dst_entry *dst,\n--\ndrivers/net/vxlan/vxlan_core.c-2276-\tdouble_encap = udp_tunnel_handle_partial(skb);\ndrivers/net/vxlan/vxlan_core.c:2277:\terr = iptunnel_handle_offloads(skb, type);\ndrivers/net/vxlan/vxlan_core.c-2278-\tif (err)\n--\ninclude/net/ip_tunnels.h=647=static inline void ip_tunnel_adj_headroom(struct net_device *dev,\n--\ninclude/net/ip_tunnels.h-655-\ninclude/net/ip_tunnels.h:656:int iptunnel_handle_offloads(struct sk_buff *skb, int gso_type_mask);\ninclude/net/ip_tunnels.h-657-\n--\ninclude/net/udp_tunnel.h=202=static inline int udp_tunnel_handle_offloads(struct sk_buff *skb, bool udp_csum)\n--\ninclude/net/udp_tunnel.h-205-\ninclude/net/udp_tunnel.h:206:\treturn iptunnel_handle_offloads(skb, type);\ninclude/net/udp_tunnel.h-207-}\n--\nnet/ipv4/fou_core.c=944=int __fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,\n--\nnet/ipv4/fou_core.c-948-\nnet/ipv4/fou_core.c:949:\terr = iptunnel_handle_offloads(skb, type);\nnet/ipv4/fou_core.c-950-\tif (err)\n--\nnet/ipv4/fou_core.c=960=int __gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,\n--\nnet/ipv4/fou_core.c-977-\nnet/ipv4/fou_core.c:978:\terr = iptunnel_handle_offloads(skb, type);\nnet/ipv4/fou_core.c-979-\tif (err)\n--\nnet/ipv4/ip_gre.c=491=static int gre_handle_offloads(struct sk_buff *skb, bool csum)\nnet/ipv4/ip_gre.c-492-{\nnet/ipv4/ip_gre.c:493:\treturn iptunnel_handle_offloads(skb, csum ? SKB_GSO_GRE_CSUM : SKB_GSO_GRE);\nnet/ipv4/ip_gre.c-494-}\n--\nnet/ipv4/ip_tunnel_core.c=172=EXPORT_SYMBOL_GPL(iptunnel_metadata_reply);\nnet/ipv4/ip_tunnel_core.c-173-\nnet/ipv4/ip_tunnel_core.c:174:int iptunnel_handle_offloads(struct sk_buff *skb,\nnet/ipv4/ip_tunnel_core.c-175-\t\t\t     int gso_type_mask)\n--\nnet/ipv4/ip_tunnel_core.c-203-}\nnet/ipv4/ip_tunnel_core.c:204:EXPORT_SYMBOL_GPL(iptunnel_handle_offloads);\nnet/ipv4/ip_tunnel_core.c-205-\n--\nnet/ipv4/ipip.c=282=static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb,\n--\nnet/ipv4/ipip.c-307-\nnet/ipv4/ipip.c:308:\tif (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP4))\nnet/ipv4/ipip.c-309-\t\tgoto tx_error;\n--\nnet/ipv6/ip6_gre.c=598=static int gre_handle_offloads(struct sk_buff *skb, bool csum)\nnet/ipv6/ip6_gre.c-599-{\nnet/ipv6/ip6_gre.c:600:\treturn iptunnel_handle_offloads(skb,\nnet/ipv6/ip6_gre.c-601-\t\t\t\t\tcsum ? SKB_GSO_GRE_CSUM : SKB_GSO_GRE);\n--\nnet/ipv6/ip6_tunnel.c=1297=ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,\n--\nnet/ipv6/ip6_tunnel.c-1399-\nnet/ipv6/ip6_tunnel.c:1400:\tif (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP6))\nnet/ipv6/ip6_tunnel.c-1401-\t\treturn -1;\n--\nnet/ipv6/seg6_iptunnel.c=398=static int seg6_do_srh(struct sk_buff *skb, struct dst_entry *cache_dst)\n--\nnet/ipv6/seg6_iptunnel.c-419-\tcase SEG6_IPTUN_MODE_ENCAP_RED:\nnet/ipv6/seg6_iptunnel.c:420:\t\terr = iptunnel_handle_offloads(skb, SKB_GSO_IPXIP6);\nnet/ipv6/seg6_iptunnel.c-421-\t\tif (err)\n--\nnet/ipv6/sit.c=966=static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,\n--\nnet/ipv6/sit.c-1032-\nnet/ipv6/sit.c:1033:\tif (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP4)) {\nnet/ipv6/sit.c-1034-\t\tip_rt_put(rt);\n--\nnet/ipv6/sit.c=1118=static netdev_tx_t sit_tunnel_xmit__(struct sk_buff *skb,\n--\nnet/ipv6/sit.c-1124-\nnet/ipv6/sit.c:1125:\tif (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP4))\nnet/ipv6/sit.c-1126-\t\tgoto tx_error;\n--\nnet/netfilter/ipvs/ip_vs_xmit.c=1147=ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,\n--\nnet/netfilter/ipvs/ip_vs_xmit.c-1233-\nnet/netfilter/ipvs/ip_vs_xmit.c:1234:\tif (iptunnel_handle_offloads(skb, gso_type))\nnet/netfilter/ipvs/ip_vs_xmit.c-1235-\t\tgoto tx_error;\n--\nnet/netfilter/ipvs/ip_vs_xmit.c=1292=ip_vs_tunnel_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,\n--\nnet/netfilter/ipvs/ip_vs_xmit.c-1376-\nnet/netfilter/ipvs/ip_vs_xmit.c:1377:\tif (iptunnel_handle_offloads(skb, gso_type))\nnet/netfilter/ipvs/ip_vs_xmit.c-1378-\t\tgoto tx_error;\n--\nnet/netfilter/nf_flow_table_ip.c=583=static int nf_flow_tunnel_ipip_push(struct net *net, struct sk_buff *skb,\n--\nnet/netfilter/nf_flow_table_ip.c-593-\nnet/netfilter/nf_flow_table_ip.c:594:\terr = iptunnel_handle_offloads(skb, SKB_GSO_IPXIP4);\nnet/netfilter/nf_flow_table_ip.c-595-\tif (err)\n--\nnet/netfilter/nf_flow_table_ip.c=639=static int nf_flow_tunnel_ip6ip6_push(struct net *net, struct sk_buff *skb,\n--\nnet/netfilter/nf_flow_table_ip.c-655-\nnet/netfilter/nf_flow_table_ip.c:656:\terr = iptunnel_handle_offloads(skb, SKB_GSO_IPXIP6);\nnet/netfilter/nf_flow_table_ip.c-657-\tif (err)\n"
}

23/2 2026/10/03 08:57 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 24921
							output: 40
							thoughts: 38
						

Thoughts:
Here's a breakdown of my thought process:

**Diving into the IP Tunnel Offload Handling**

Okay, so I need to understand how IP tunnel offloads are managed. My first move is to zero in on the `net/ipv4/ip_tunnel_core.c` file, specifically around line 174. That's where I believe the `iptunnel_handle_offloads` function lives. I'm going to carefully dissect what's happening within that function to get a handle on the offload logic. From there I expect to see how the kernel takes the packets and does what's needed. Then, I will focus on performance considerations. I wonder if there are any specific structures or flags involved that are critical for efficient processing. I'll need to pay close attention to the data flow to fully grasp the intricacies of this implementation.



24/2 2026/10/03 08:57 tool read-file
0m Args:
{
  "File": "net/ipv4/ip_tunnel_core.c",
  "FirstLine": 174,
  "LineCount": 35
}

Results:
{
  "Contents": " 174:\tint iptunnel_handle_offloads(struct sk_buff *skb,\n 175:\t\t\t\t     int gso_type_mask)\n 176:\t{\n 177:\t\tint err;\n 178:\t\n 179:\t\tif (likely(!skb-\u003eencapsulation)) {\n 180:\t\t\tskb_reset_inner_headers(skb);\n 181:\t\t\tskb-\u003eencapsulation = 1;\n 182:\t\t}\n 183:\t\n 184:\t\tif (skb_is_gso(skb)) {\n 185:\t\t\terr = skb_header_unclone(skb, GFP_ATOMIC);\n 186:\t\t\tif (unlikely(err))\n 187:\t\t\t\treturn err;\n 188:\t\t\tskb_shinfo(skb)-\u003egso_type |= gso_type_mask;\n 189:\t\t\treturn 0;\n 190:\t\t}\n 191:\t\n 192:\t\tif (skb-\u003eip_summed != CHECKSUM_PARTIAL) {\n 193:\t\t\tskb-\u003eip_summed = CHECKSUM_NONE;\n 194:\t\t\t/* We clear encapsulation here to prevent badly-written\n 195:\t\t\t * drivers potentially deciding to offload an inner checksum\n 196:\t\t\t * if we set CHECKSUM_PARTIAL on the outer header.\n 197:\t\t\t * This should go away when the drivers are all fixed.\n 198:\t\t\t */\n 199:\t\t\tskb-\u003eencapsulation = 0;\n 200:\t\t}\n 201:\t\n 202:\t\treturn 0;\n 203:\t}\n 204:\tEXPORT_SYMBOL_GPL(iptunnel_handle_offloads);\n 205:\t\n 206:\t/**\n 207:\t * iptunnel_pmtud_build_icmp() - Build ICMP error message for PMTUD\n 208:\t * @skb:\tOriginal packet with L2 header\n"
}

25/2 2026/10/03 08:57 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 25721
							output: 33
							thoughts: 1010
						

Thoughts:
**AMT GSO Offload: Worthy of Fuzzing**

Okay, let's break this down. First, this patch in `iptunnel_handle_offloads` is dealing with Generic Segmentation Offload (GSO) for UDP tunnels. Specifically, it seems to be fixing a problem where the Ethernet header wasn't being handled correctly in the AMT (Active Multicast Tunneling) driver. The original code was pulling the Ethernet header in `amt_dev_xmit` without properly updating `skb->mac_header`, leading to issues with subsequent processing, especially when `skb_copy_expand` and `skb_reset_mac_header` were called in `amt_send_multicast_data`. This patch addresses this, and crucial is the addition of `udp_tunnel_handle_offloads(skb, true)` which sets GSO flags. This ensures the packet is properly offloaded, segmented, and handled correctly by hardware or GSO engines via `udp_tunnel_xmit_skb()`.

Now, is this fuzzable? Absolutely. According to the "CORE TRIAGE PHILOSOPHY," reachability is the primary gate. AMT is a software virtual network device driver (`amt.c`), and it can be configured via `ip link add type amt...` using rtnetlink. Multicast packets transmitted through the AMT device will call `amt_dev_xmit` then `amt_send_multicast_data`. This patch *enables* a feature. And according to the positive criteria outlined, this is precisely the type of code change that warrants fuzzing. The patch touches reachable executable code, it's a driver accessible via netlink/sockets! So WorthFuzzing=true.

Now, let's identify the specific functions involved for fuzzing.  `amt_send_multicast_data` is the function that's being directly modified. Its caller is `amt_dev_xmit`. Tracing through the code, I see that:

*   `amt_send_multicast_data` is defined as `static void amt_send_multicast_data(...)` on line 1060 of `amt.c`.
*   It is called from `amt_dev_xmit` (line 1306 of `amt.c`): `amt_send_multicast_data(amt, skb, tunnel, v6);`.
*   `amt_dev_xmit` is defined as `static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev)` which is the `ndo_start_xmit` function for the AMT device.

Therefore, fuzzing should focus on interactions through `amt_dev_xmit` and `amt_send_multicast_data`, as well as inputs and control flows that lead to their execution within the AMT driver.



26/2 2026/10/03 08:58 tool grepper
0m Args:
{
  "Expression": "amt_dev_xmit",
  "PathPrefix": "drivers/net/amt.c"
}

Results:
{
  "Output": "drivers/net/amt.c=1060=static void amt_send_multicast_data(struct amt_dev *amt,\n--\ndrivers/net/amt.c-1080-\ndrivers/net/amt.c:1081:\t/* amt_dev_xmit() pulled the Ethernet header without moving the mac\ndrivers/net/amt.c-1082-\t * header. The tunnelled payload has no link-layer header, so the\n--\ndrivers/net/amt.c=1126=static bool amt_send_membership_query(struct amt_dev *amt,\n--\ndrivers/net/amt.c-1186-\ndrivers/net/amt.c:1187:static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev)\ndrivers/net/amt.c-1188-{\n--\ndrivers/net/amt.c=3150=static const struct net_device_ops amt_netdev_ops = {\n--\ndrivers/net/amt.c-3154-\t.ndo_stop\t\t= amt_dev_stop,\ndrivers/net/amt.c:3155:\t.ndo_start_xmit         = amt_dev_xmit,\ndrivers/net/amt.c-3156-};\n"
}

27/2 2026/10/03 08:58 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 27720
							output: 31
							thoughts: 153
						

Thoughts:
**Optimizing AMT Code: Inlining Considerations**

Okay, so I'm looking at `amt_send_multicast_data`. It's static, and seems to only be called from `amt_dev_xmit`. The question is, can the compiler, specifically GCC or Clang, inline `amt_send_multicast_data` directly into `amt_dev_xmit`? That'd be a nice optimization if it's feasible. Let's verify that `amt_send_multicast_data` truly *only* gets called from `amt_dev_xmit`. Yep, one caller, just as suspected.

Given that it's static and called only once within the file, this strongly suggests the compiler *should* be able to inline it. That's a classic case for inlining optimization. So, including both `amt_send_multicast_data` and `amt_dev_xmit` within FocusSymbols is definitely a sound practice; it gives the compiler the best opportunity to perform this optimization.

Now, I'm thinking more broadly about other functions within `amt.c`. Specifically, let's explore `amt_newlink` or any of the link setup functions.



28/2 2026/10/03 08:58 tool grepper
0m Args:
{
  "Expression": "amt_newlink",
  "PathPrefix": "drivers/net/amt.c"
}

Results:
{
  "Output": "drivers/net/amt.c=3193=static int amt_validate(struct nlattr *tb[], struct nlattr *data[],\n--\ndrivers/net/amt.c-3232-\ndrivers/net/amt.c:3233:static int amt_newlink(struct net_device *dev,\ndrivers/net/amt.c-3234-\t\t       struct rtnl_newlink_params *params,\n--\ndrivers/net/amt.c=3412=static struct rtnl_link_ops amt_link_ops __read_mostly = {\n--\ndrivers/net/amt.c-3418-\t.validate\t= amt_validate,\ndrivers/net/amt.c:3419:\t.newlink\t= amt_newlink,\ndrivers/net/amt.c-3420-\t.dellink\t= amt_dellink,\n"
}

29/2 2026/10/03 08:58 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 28389
							output: 27
							thoughts: 146
						

Thoughts:
**My Assessment of the AMT Device Creation and Transmission**

Okay, so I'm looking at this code and trying to get a handle on the changes made, specifically concerning multicast data transmission within the AMT framework. It seems `amt_newlink` is the crucial entry point for bringing up an AMT device, and `amt_dev_xmit` handles the actual transmission of data from that device. The real meat of the modification, though, seems to be in `amt_send_multicast_data`. That's where I need to focus.

Now, let's nail down the configuration requirements. A quick glance at `drivers/net/Kconfig` is in order. Aha! The `config AMT` entry tells the tale. It's a tristate option, but depends on both `INET` and `IP_MULTICAST`, and, importantly, it *selects* `NET_UDP_TUNNEL`. That suggests a UDP-based tunneling mechanism, which aligns with my understanding of AMT.

But I can't be too hasty. I need to make sure there are *no* other subtle dependencies or conditional guards lurking within `drivers/net/amt.c` itself. Best practice demands that I examine the top of the file, and the Makefile as well. I don't want to get tripped up by some obscure `#ifdef` or build-time variable. It's time to dig into those files to verify the configuration requirements are straightforward.



30/2 2026/10/03 08:58 tool grepper
0m Args:
{
  "Expression": "amt\\.o",
  "PathPrefix": "drivers/net/"
}

Results:
{
  "Output": "drivers/net/Makefile=17=obj-$(CONFIG_MACSEC) += macsec.o\ndrivers/net/Makefile:18:obj-$(CONFIG_AMT) += amt.o\ndrivers/net/Makefile-19-obj-$(CONFIG_MACVLAN) += macvlan.o\n"
}

31/2 2026/10/03 08:58 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 28950
							output: 20
							thoughts: 35
						

Thoughts:
Okay, here's my interpretation of those thoughts, tailored for an expert audience, presented in the first person:

**Kernel Object Inclusion and IPv4 Multicast Dependency**

Alright, so the first thing I'm doing is adding `amt.o` to a build object list, which is conditional on `CONFIG_AMT`. That's standard practice, nothing surprising there. I need to make sure I am including the right modules. I need to check the build process to be sure everything is working as expected.

My next immediate thought is that `amt.o`, given the file name "amt", is likely related to Address Mapping of IPv4 Transport (AMT). Therefore, it should be dependent on IPv4 multicast functionality. So, the logical follow-up is to immediately dive into `net/ipv4/Kconfig` to verify the dependency on `IP_MULTICAST`. It's crucial to confirm that `CONFIG_IP_MULTICAST` is properly defined and enabled alongside `CONFIG_AMT`, ensuring the module builds correctly and that all the necessary network stack support is present. No point trying to build AMT without multicast support, after all. Gotta ensure the underlying infrastructure is there before anything else.



32/2 2026/10/03 08:58 tool grepper
0m Args:
{
  "Expression": "config IP_MULTICAST"
}

Results:
{
  "Output": "net/ipv4/Kconfig-4-#\nnet/ipv4/Kconfig:5:config IP_MULTICAST\nnet/ipv4/Kconfig-6-\tbool \"IP: multicasting\"\n"
}

33/2 2026/10/03 08:58 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 29315
							output: 33
							thoughts: 16
						

Thoughts:
Here's my thought process, summarized as you requested:

**Investigating the Dependencies of IP_MULTICAST**

Okay, so I'm thinking, before I proceed any further with this, I need to get a really good understanding of the foundation this code is built on. So, my initial thought is: Let's explicitly check to see if the `IP_MULTICAST` functionality relies on any other specific components, protocols, or settings. I need to know the preconditions to even start. I'm going to start digging into the dependencies; I need to know exactly what I'm dealing with.



34/2 2026/10/03 08:58 tool read-file
0m Args:
{
  "File": "net/ipv4/Kconfig",
  "FirstLine": 1,
  "LineCount": 20
}

Results:
{
  "Contents": "   1:\t# SPDX-License-Identifier: GPL-2.0-only\n   2:\t#\n   3:\t# IP configuration\n   4:\t#\n   5:\tconfig IP_MULTICAST\n   6:\t\tbool \"IP: multicasting\"\n   7:\t\thelp\n   8:\t\t  This is code for addressing several networked computers at once,\n   9:\t\t  enlarging your kernel by about 2 KB. You need multicasting if you\n  10:\t\t  intend to participate in the MBONE, a high bandwidth network on top\n  11:\t\t  of the Internet which carries audio and video broadcasts. More\n  12:\t\t  information about the MBONE is on the WWW at\n  13:\t\t  \u003chttps://www.savetz.com/mbone/\u003e. For most people, it's safe to say N.\n  14:\t\n  15:\tconfig IP_ADVANCED_ROUTER\n  16:\t\tbool \"IP: advanced router\"\n  17:\t\thelp\n  18:\t\t  If you intend to run your Linux box mostly as a router, i.e. as a\n  19:\t\t  computer that forwards and redistributes network packets, say Y; you\n  20:\t\t  will then be presented with several options that allow more precise\n"
}

35/2 2026/10/03 08:58 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 29807
							output: 21
							thoughts: 132
						

Thoughts:
**Analyzing Network Configuration Dependencies**

Okay, so I'm diving into some network configuration code, and immediately I see `INET` is tied to `CONFIG_INET`, which, as expected, is almost ubiquitous in any modern networking setup. That's a solid base to start from.

Now, `CONFIG_IP_MULTICAST` is a straightforward boolean option, easy enough. But then I hit `CONFIG_AMT`, which is tristate. That means it can be modularly compiled in, built-in, or completely omitted. I need to keep that flexibility in mind as I trace dependencies.

Looking deeper, in the `amt_send_multicast_data()` function, I see `udp_tunnel_handle_offloads` is defined only when `CONFIG_INET` is present. That makes sense, standard infrastructure. And crucially, `AMT` appears to be selecting `CONFIG_NET_UDP_TUNNEL`. Aha, I've got a dependency chain emerging.

Which brings me to my next question: What about `CONFIG_NET_UDP_TUNNEL` itself? I need to understand that component in more detail. Let's dig into `net/ipv4/Kconfig` and see what that config option controls. It's time to follow the trail.



36/2 2026/10/03 08:58 tool grepper
0m Args:
{
  "Expression": "config NET_UDP_TUNNEL"
}

Results:
{
  "Output": "net/ipv4/Kconfig=304=config NET_IPVTI\n--\nnet/ipv4/Kconfig-315-\nnet/ipv4/Kconfig:316:config NET_UDP_TUNNEL\nnet/ipv4/Kconfig-317-\ttristate\n"
}

37/2 2026/10/03 08:58 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 30312
							output: 145
							thoughts: 756
						

Thoughts:
**My Assessment of the AMT Driver Vulnerability**

Okay, so the `NET_UDP_TUNNEL` config is automatically selected when `AMT` is enabled. That, along with `IP_MULTICAST` and `INET`, are the critical configs here. Let's break down this triage step-by-step.

First, reachability. The AMT driver is perfectly configurable in userspace/VMs using netlink (rtnetlink), which is straightforward. Packets traversing the AMT interface or UDP socket route through `amt_dev_xmit()` and `amt_send_multicast_data()`. Standard syzkaller configs handle network devices and virtual tunnels, so we have good coverage there. The patch itself is the kicker; it adds `skb_reset_mac_header(skb);` and `udp_tunnel_handle_offloads(skb, true)` with error handling within `amt_send_multicast_data()`. This means there are direct changes to packet header offsets, offload flags, and error paths during skb transmission, and that, my friend, is *absolutely* fuzz-worthy: `WorthFuzzing = true`.

Focus symbols are now crystal clear. `amt_send_multicast_data` is the modified function, and `amt_dev_xmit` is the caller (the `ndo_start_xmit` entrypoint).

Enable configs, as we covered, are `AMT`, `IP_MULTICAST`, and `INET`.

Let's do a quick sanity check to make sure we didn't miss anything. Could `udp_tunnel_handle_offloads` be a focus symbol? No, it's a static inline, which means it doesn't have a distinct symbol address, and per the documentation, static inlines should be exercised through caller functions. `iptunnel_handle_offloads`, its callee, *is* exported, but it's used across a ton of tunnels, so focusing on it would be too broad. Sticking with `amt_send_multicast_data` and `amt_dev_xmit` directly targets the AMT driver itself, which is where the patch and offload handling was added, and that's the smart move.

Finally, a quick check of the other files changed in the patch: `.gitignore`, `Makefile`, `amt_gso.c`, `amt_gso.sh`, and `config` are all selftests - user space tools, not kernel code. The *only* kernel change is in `drivers/net/amt.c`.

Everything is consistent, and we've got a clear picture of the situation. Time to call `set-results`.



38/2 2026/10/03 08:58 tool set-results
0m Args:
{
  "EnableConfigs": [
    "AMT",
    "IP_MULTICAST",
    "INET"
  ],
  "FocusSymbols": [
    "amt_send_multicast_data",
    "amt_dev_xmit"
  ],
  "Reasoning": "The patch modifies amt_send_multicast_data() in drivers/net/amt.c to reset the MAC header and invoke udp_tunnel_handle_offloads() on outgoing multicast packets. AMT is a virtual network device driver configurable via rtnetlink and reachable in standard virtualized environments. Fuzzing is warranted to test packet segmentation, encapsulation offloading, and error handling paths.",
  "WorthFuzzing": true
}

Results:
{
  "EnableConfigs": [
    "AMT",
    "IP_MULTICAST",
    "INET"
  ],
  "FocusSymbols": [
    "amt_send_multicast_data",
    "amt_dev_xmit"
  ],
  "Reasoning": "The patch modifies amt_send_multicast_data() in drivers/net/amt.c to reset the MAC header and invoke udp_tunnel_handle_offloads() on outgoing multicast packets. AMT is a virtual network device driver configurable via rtnetlink and reachable in standard virtualized environments. Fuzzing is warranted to test packet segmentation, encapsulation offloading, and error handling paths.",
  "WorthFuzzing": true
}

39/1 2026/10/03 08:58 action If
0m Args:
{
  "WorthFuzzing": true
}

Results:
null

40/2 2026/10/03 08:58 agent kmsan-evaluator
0m Model:
core

Args:
null

Results:
{
  "KMSANReasoning": "The patch modifies `amt_send_multicast_data()` in `drivers/net/amt.c` to adjust skb inner headers (`skb_reset_mac_header(skb)` and `skb_reset_inner_headers(skb)`) and invoke `udp_tunnel_handle_offloads(skb, true)` so that UDP segmentation offload (GSO) packets are appropriately encapsulated and marked before transmission. The rest of the diff adds user-space selftests.\n\nThis change does not introduce or modify any uninitialized variables, heap/stack allocations, or copies to user space. It only adjusts skb metadata pointers and flags for network offloading. Any potential issues with incorrect header offsets during GSO segmentation, packet trimming, or skb lifetime management would manifest as out-of-bounds memory accesses or use-after-free bugs, which are detected by KASAN rather than KMSAN. As there are no uninitialized memory read or info-leak risks, a dedicated KMSAN fuzzing session is not justified.",
  "NeedsKMSAN": false
}

Instruction:
You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.

CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
  a comprehensive suite of debugging tools and sanitizers, including KASAN
  (out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
  (locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
  or page allocations) and kernel-to-user memory info-leaks.

Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.

Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.

Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
   attributes, ioctl output arguments, socket options, or BPF buffers) where fields
   or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
   or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
   could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
   uninitialized bytes of existing buffers.

Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
  dereferences, locking deadlocks, or use-after-free bugs (these are already caught
  by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
  or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.

Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
Target architecture: amd64

For your convenience, here is the diff of the changes:
commit da0c0ce6718afdc74d647e71e13c528b1f2c0c30
Author: syz-cluster <triage@syzkaller.com>
Date:   Sat Oct 3 08:55:58 2026 +0000

    syz-cluster: applied patch under review

diff --git a/drivers/net/amt.c b/drivers/net/amt.c
index 0277e4cac39bd..a8236d40c2e70 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;
diff --git a/tools/testing/selftests/net/.gitignore b/tools/testing/selftests/net/.gitignore
index dacd36ed8455e..489d37b990845 100644
--- a/tools/testing/selftests/net/.gitignore
+++ b/tools/testing/selftests/net/.gitignore
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
+amt_gso
 bind_bhash
 bind_timewait
 bind_wildcard
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index cab3f2c90039f..9af0d175b1018 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -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 \
diff --git a/tools/testing/selftests/net/amt_gso.c b/tools/testing/selftests/net/amt_gso.c
new file mode 100644
index 0000000000000..eebf3ecb94979
--- /dev/null
+++ b/tools/testing/selftests/net/amt_gso.c
@@ -0,0 +1,457 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Helper for amt_gso.sh.
+ *
+ * send:  send datagrams to a multicast group, optionally as one UDP_SEGMENT
+ *        burst per datagram, with a self-describing payload pattern.
+ * recv:  receive datagrams on a UDP port and check count, length and payload
+ *        of every one of them against the pattern used by "send".
+ * sniff: capture on an interface with AF_PACKET and report how large the
+ *        frames handed to the device were.
+ *
+ * Every datagram consists of cnt chunks of seg bytes followed by an optional
+ * tail chunk of tail bytes. A chunk starts with a struct chunk_hdr and the
+ * rest of it is a function of (datagram number, chunk number, offset).
+ * With UDP_SEGMENT set to seg, every chunk is one segment on the wire.
+ */
+#define _GNU_SOURCE
+#include <arpa/inet.h>
+#include <errno.h>
+#include <error.h>
+#include <linux/if_packet.h>
+#include <linux/if_ether.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <netinet/udp.h>
+#include <poll.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <time.h>
+#include <unistd.h>
+
+#ifndef UDP_SEGMENT
+#define UDP_SEGMENT	103
+#endif
+
+#define MAX_DGRAM	65507
+#define AMT_MSG_MCAST_DATA	6
+
+struct chunk_hdr {
+	uint32_t seq;
+	uint16_t idx;
+	uint16_t len;
+};
+
+struct cfg {
+	bool ipv6;
+	bool gso;
+	bool amt;		/* sniff: count AMT multicast data messages */
+	const char *ifname;
+	const char *group;
+	const char *bind_addr;
+	unsigned int port;
+	unsigned int seg;
+	unsigned int cnt;
+	unsigned int tail;
+	unsigned int num;
+	unsigned int delay_us;
+	unsigned int idle;
+	unsigned int grace;	/* recv: extra wait for the first datagram */
+	unsigned int mtu;
+};
+
+static uint8_t fill_byte(uint32_t seq, unsigned int idx, unsigned int off)
+{
+	return (uint8_t)(seq * 131 + idx * 17 + off * 7 + (off >> 8));
+}
+
+static unsigned int chunk_len(const struct cfg *c, unsigned int idx)
+{
+	return idx < c->cnt ? c->seg : c->tail;
+}
+
+static unsigned int chunks_per_dgram(const struct cfg *c)
+{
+	return c->cnt + (c->tail ? 1 : 0);
+}
+
+static void fill_dgram(const struct cfg *c, uint32_t seq, uint8_t *buf)
+{
+	unsigned int i, off, n = chunks_per_dgram(c);
+
+	for (i = 0; i < n; i++) {
+		unsigned int len = chunk_len(c, i);
+		struct chunk_hdr h = { .seq = seq, .idx = i, .len = len };
+
+		memcpy(buf, &h, sizeof(h));
+		for (off = sizeof(h); off < len; off++)
+			buf[off] = fill_byte(seq, i, off);
+		buf += len;
+	}
+}
+
+static int open_udp(const struct cfg *c)
+{
+	int fd = socket(c->ipv6 ? AF_INET6 : AF_INET, SOCK_DGRAM, 0);
+
+	if (fd < 0)
+		error(2, errno, "socket");
+	return fd;
+}
+
+static void fill_addr(const struct cfg *c, const char *str, unsigned int port,
+		      struct sockaddr_storage *ss, socklen_t *len)
+{
+	memset(ss, 0, sizeof(*ss));
+	if (c->ipv6) {
+		struct sockaddr_in6 *a = (void *)ss;
+
+		a->sin6_family = AF_INET6;
+		a->sin6_port = htons(port);
+		if (inet_pton(AF_INET6, str, &a->sin6_addr) != 1)
+			error(2, errno, "inet_pton");
+		*len = sizeof(*a);
+	} else {
+		struct sockaddr_in *a = (void *)ss;
+
+		a->sin_family = AF_INET;
+		a->sin_port = htons(port);
+		if (inet_pton(AF_INET, str, &a->sin_addr) != 1)
+			error(2, errno, "inet_pton");
+		*len = sizeof(*a);
+	}
+}
+
+static int do_send(const struct cfg *c)
+{
+	static uint8_t buf[MAX_DGRAM];
+	struct sockaddr_storage dst, src;
+	socklen_t dlen, slen;
+	unsigned int total, ifindex, i;
+	int fd, ttl = 8, zero = 0;
+
+	total = c->cnt * c->seg + c->tail;
+	if (total > MAX_DGRAM ||
+	    (c->tail && c->tail < sizeof(struct chunk_hdr)) ||
+	    c->seg < sizeof(struct chunk_hdr))
+		error(2, 0, "bad sizes");
+	ifindex = if_nametoindex(c->ifname);
+	if (!ifindex)
+		error(2, errno, "if_nametoindex");
+
+	fd = open_udp(c);
+	if (c->bind_addr) {
+		fill_addr(c, c->bind_addr, 0, &src, &slen);
+		if (bind(fd, (void *)&src, slen))
+			error(2, errno, "bind");
+	}
+	if (c->ipv6) {
+		if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF, &ifindex,
+			       sizeof(ifindex)))
+			error(2, errno, "IPV6_MULTICAST_IF");
+		if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &ttl,
+			       sizeof(ttl)))
+			error(2, errno, "IPV6_MULTICAST_HOPS");
+		if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &zero,
+			       sizeof(zero)))
+			error(2, errno, "IPV6_MULTICAST_LOOP");
+	} else {
+		struct ip_mreqn mr = { .imr_ifindex = ifindex };
+
+		if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, &mr,
+			       sizeof(mr)))
+			error(2, errno, "IP_MULTICAST_IF");
+		if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl,
+			       sizeof(ttl)))
+			error(2, errno, "IP_MULTICAST_TTL");
+		if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, &zero,
+			       sizeof(zero)))
+			error(2, errno, "IP_MULTICAST_LOOP");
+	}
+	if (c->gso) {
+		int gso = c->seg;
+
+		if (setsockopt(fd, IPPROTO_UDP, UDP_SEGMENT, &gso, sizeof(gso)))
+			error(2, errno, "UDP_SEGMENT");
+	}
+	fill_addr(c, c->group, c->port, &dst, &dlen);
+
+	for (i = 0; i < c->num; i++) {
+		fill_dgram(c, i, buf);
+		if (sendto(fd, buf, total, 0, (void *)&dst, dlen) !=
+		    (ssize_t)total)
+			error(2, errno, "sendto");
+		if (c->delay_us)
+			usleep(c->delay_us);
+	}
+	close(fd);
+	return 0;
+}
+
+static int do_recv(const struct cfg *c)
+{
+	unsigned int per = chunks_per_dgram(c), expected = c->num * per;
+	unsigned int good = 0, bad_len = 0, bad_payload = 0, dup = 0, unk = 0;
+	static uint8_t buf[MAX_DGRAM + 1];
+	struct sockaddr_storage any;
+	socklen_t alen;
+	uint8_t *seen;
+	int fd, rcvbuf = 8 << 20, idle_ms = 0;
+	bool got_any = false;
+
+	seen = calloc(expected ? expected : 1, 1);
+	if (!seen)
+		error(2, errno, "calloc");
+	fd = open_udp(c);
+	setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(rcvbuf));
+	fill_addr(c, c->ipv6 ? "::" : "0.0.0.0", c->port, &any, &alen);
+	if (bind(fd, (void *)&any, alen))
+		error(2, errno, "bind");
+	printf("READY\n");
+	fflush(stdout);
+
+	while (good < expected) {
+		struct pollfd pfd = { .fd = fd, .events = POLLIN };
+		struct chunk_hdr h;
+		unsigned int off;
+		ssize_t n;
+		int r = poll(&pfd, 1, 100);
+
+		if (r < 0)
+			error(2, errno, "poll");
+		if (!r) {
+			idle_ms += 100;
+			if (idle_ms >=
+			    (int)(c->idle + (got_any ? 0 : c->grace)) * 1000)
+				break;
+			continue;
+		}
+		idle_ms = 0;
+		got_any = true;
+		n = recv(fd, buf, sizeof(buf), 0);
+		if (n < 0)
+			error(2, errno, "recv");
+		if (n < (ssize_t)sizeof(h)) {
+			bad_len++;
+			continue;
+		}
+		memcpy(&h, buf, sizeof(h));
+		if (h.seq >= c->num || h.idx >= per) {
+			unk++;
+			continue;
+		}
+		if ((unsigned int)n != chunk_len(c, h.idx) || h.len != n) {
+			bad_len++;
+			continue;
+		}
+		for (off = sizeof(h); off < (unsigned int)n; off++)
+			if (buf[off] != fill_byte(h.seq, h.idx, off))
+				break;
+		if (off != (unsigned int)n) {
+			bad_payload++;
+			continue;
+		}
+		if (seen[h.seq * per + h.idx]++) {
+			dup++;
+			continue;
+		}
+		good++;
+	}
+	printf("RECV expected=%u good=%u bad_len=%u ", expected, good, bad_len);
+	printf("bad_payload=%u dup=%u unknown=%u\n", bad_payload, dup, unk);
+	free(seen);
+	return good == expected && !bad_len && !bad_payload && !dup &&
+	       !unk ? 0 : 1;
+}
+
+static int sniff_stop;
+
+static void sniff_sig(int sig)
+{
+	__atomic_store_n(&sniff_stop, 1, __ATOMIC_RELAXED);
+}
+
+static int do_sniff(const struct cfg *c)
+{
+	static uint8_t buf[MAX_DGRAM + 256];
+	unsigned int n = 0, max_len = 0, over = 0, amt = 0;
+	struct sockaddr_ll sll = { .sll_family = AF_PACKET };
+	struct timespec t0, last, now;
+	struct tpacket_stats st = { 0 };
+	socklen_t stlen = sizeof(st);
+	int fd, rcvbuf = 32 << 20;
+
+	fd = socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_ALL));
+	if (fd < 0)
+		error(2, errno, "socket(AF_PACKET)");
+	sll.sll_protocol = htons(ETH_P_ALL);
+	sll.sll_ifindex = if_nametoindex(c->ifname);
+	if (!sll.sll_ifindex)
+		error(2, errno, "if_nametoindex");
+	if (bind(fd, (void *)&sll, sizeof(sll)))
+		error(2, errno, "bind(AF_PACKET)");
+	/* Do not lose frames to a full receive queue: they are counted */
+	if (setsockopt(fd, SOL_SOCKET, SO_RCVBUFFORCE, &rcvbuf, sizeof(rcvbuf)))
+		setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(rcvbuf));
+	signal(SIGTERM, sniff_sig);
+	printf("READY\n");
+	fflush(stdout);
+	clock_gettime(CLOCK_MONOTONIC, &t0);
+	last = t0;
+
+	for (;;) {
+		/* Once asked to stop, read what is still queued, then report */
+		int stopping = __atomic_load_n(&sniff_stop, __ATOMIC_RELAXED);
+		struct pollfd pfd = { .fd = fd, .events = POLLIN };
+		struct sockaddr_ll from;
+		socklen_t flen = sizeof(from);
+		unsigned int hl, dport;
+		const uint8_t *p = buf;
+		ssize_t len, got;
+		int r;
+
+		clock_gettime(CLOCK_MONOTONIC, &now);
+		if (!stopping && (now.tv_sec - t0.tv_sec > 120 ||
+				  now.tv_sec - last.tv_sec >= (long)c->idle))
+			break;
+		r = poll(&pfd, 1, stopping ? 0 : 100);
+		if (r < 0 && errno == EINTR)
+			continue;
+		if (r < 0)
+			error(2, errno, "poll");
+		if (!r) {
+			if (stopping)
+				break;
+			continue;
+		}
+		got = recvfrom(fd, buf, sizeof(buf), MSG_TRUNC,
+			       (void *)&from, &flen);
+		if (got < 0)
+			error(2, errno, "recvfrom");
+		len = got;
+		if (got > (ssize_t)sizeof(buf))
+			got = sizeof(buf);
+
+		if (ntohs(from.sll_protocol) == ETH_P_IP && got >= 28 &&
+		    (p[0] >> 4) == 4 && p[9] == IPPROTO_UDP) {
+			hl = (p[0] & 0xf) * 4;
+		} else if (ntohs(from.sll_protocol) == ETH_P_IPV6 &&
+			   got >= 48 && (p[0] >> 4) == 6 &&
+			   p[6] == IPPROTO_UDP) {
+			hl = 40;
+		} else {
+			continue;
+		}
+		if (got < (ssize_t)(hl + sizeof(struct udphdr)))
+			continue;
+		dport = (p[hl + 2] << 8) | p[hl + 3];
+		if (dport != c->port)
+			continue;
+		if (c->amt) {
+			const uint8_t *a = p + hl + sizeof(struct udphdr);
+
+			/* version 0, type 6, a reserved byte, the IP packet */
+			if (got < (ssize_t)(hl + sizeof(struct udphdr) + 3) ||
+			    a[0] != AMT_MSG_MCAST_DATA || a[1] != 0)
+				continue;
+			if ((a[2] >> 4) != (c->ipv6 ? 6 : 4))
+				continue;
+			amt++;
+		}
+		last = now;
+		n++;
+		if ((unsigned int)len > max_len)
+			max_len = len;
+		if ((unsigned int)len > c->mtu)
+			over++;
+	}
+	getsockopt(fd, SOL_PACKET, PACKET_STATISTICS, &st, &stlen);
+	printf("SNIFF frames=%u max_len=%u over_mtu=%u amt_data=%u lost=%u\n",
+	       n, max_len, over, amt, st.tp_drops);
+	return 0;
+}
+
+static void usage(void)
+{
+	fprintf(stderr,
+		"amt_gso send|recv|sniff [-6] [-I ifname] [-g group] [-b srcaddr]\n"
+		"           [-p port] [-s seg] [-c chunks] [-t tail] [-n datagrams]\n"
+		"           [-G] [-d delay_us] [-T idle_s] [-S grace_s] [-M mtu] [-a]\n");
+	exit(2);
+}
+
+int main(int argc, char **argv)
+{
+	struct cfg c = { .port = 4000, .seg = 1200, .cnt = 8, .tail = 100,
+			 .num = 1, .idle = 2, .mtu = 1500 };
+	int opt;
+
+	if (argc < 2)
+		usage();
+	optind = 2;
+	while ((opt = getopt(argc, argv,
+			     "6I:g:b:p:s:c:t:n:Gd:T:S:M:a")) != -1) {
+		switch (opt) {
+		case '6':
+			c.ipv6 = true;
+			break;
+		case 'I':
+			c.ifname = optarg;
+			break;
+		case 'g':
+			c.group = optarg;
+			break;
+		case 'b':
+			c.bind_addr = optarg;
+			break;
+		case 'p':
+			c.port = atoi(optarg);
+			break;
+		case 's':
+			c.seg = atoi(optarg);
+			break;
+		case 'c':
+			c.cnt = atoi(optarg);
+			break;
+		case 't':
+			c.tail = atoi(optarg);
+			break;
+		case 'n':
+			c.num = atoi(optarg);
+			break;
+		case 'G':
+			c.gso = true;
+			break;
+		case 'd':
+			c.delay_us = atoi(optarg);
+			break;
+		case 'S':
+			c.grace = atoi(optarg);
+			break;
+		case 'T':
+			c.idle = atoi(optarg);
+			break;
+		case 'M':
+			c.mtu = atoi(optarg);
+			break;
+		case 'a':
+			c.amt = true;
+			break;
+		default:
+			usage();
+		}
+	}
+	if (!strcmp(argv[1], "send") && c.ifname && c.group)
+		return do_send(&c);
+	if (!strcmp(argv[1], "recv"))
+		return do_recv(&c);
+	if (!strcmp(argv[1], "sniff") && c.ifname)
+		return do_sniff(&c);
+	usage();
+	return 2;
+}
diff --git a/tools/testing/selftests/net/amt_gso.sh b/tools/testing/selftests/net/amt_gso.sh
new file mode 100755
index 0000000000000..3c37cb59d9b02
--- /dev/null
+++ b/tools/testing/selftests/net/amt_gso.sh
@@ -0,0 +1,269 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# Check that an AMT relay forwards a UDP GSO burst (UDP_SEGMENT) to a gateway
+# when transmit checksum offload is enabled on the amt device.
+#
+# With the default features the core segments the burst before it reaches
+# amt_dev_xmit(), so that case is the positive control for the harness. With
+# "tx on" the unsegmented GSO skb is handed to the driver, which must mark it
+# as a UDP tunnel packet before it hands it to the lower device.
+#
+# There are three network namespaces. The sender runs in the RELAY namespace,
+# because a forwarded GRO skb with DF set would be dropped by the multicast
+# router before it ever gets to amt.
+#
+#   LISTENER             GATEWAY                RELAY
+#  +---------+        +-------------+       +-----------------+
+#  |  l_gw   |--------| gw_l  br0   |       |                 |
+#  |         |        |       amtg  |       |  amtr  <- sender|
+#  +---------+        |  gw_relay   |-------| relay_gw        |
+#                     +-------------+       +-----------------+
+#
+# amt_gso, built from amt_gso.c, sends, receives and captures. The listener
+# reports datagrams by count, length and payload. A capture on amtr shows what
+# was handed to amt_dev_xmit(), and one on gw_relay shows what was put on the
+# wire.
+
+source lib.sh
+
+AMT_GSO=./amt_gso
+GRP4=239.0.0.1
+GRP6=ff0e::5:6
+SRC4=192.0.2.1
+SRC6=2001:db8:3::1
+PORT_AMT=2268
+SEG=1200
+TAIL=100
+BURST=8
+NUM=100
+PROBE_OPTS=(-s 64 -c 1 -t 0 -n 1)
+
+TMPD=$(mktemp -d)
+
+cleanup()
+{
+	rm -rf "$TMPD"
+	cleanup_all_ns
+}
+
+trap cleanup EXIT
+
+dev_stat()
+{
+	ip netns exec "$1" cat "/sys/class/net/$2/statistics/$3"
+}
+
+csum_errors()
+{
+	ip netns exec "$GATEWAY" nstat -asz UdpInCsumErrors |
+		awk '$1 == "UdpInCsumErrors" { n = $2 } END { print n + 0 }'
+}
+
+field()
+{
+	local val
+
+	val=$(grep -o " $2=[0-9]*" "$1" | tail -n 1 | cut -d= -f2)
+	echo "${val:-0}"
+}
+
+skip_all()
+{
+	log_test_skip "$1"
+	exit "$EXIT_STATUS"
+}
+
+setup_topology()
+{
+	setup_ns LISTENER GATEWAY RELAY || exit $ksft_skip
+
+	ip link add l_gw netns "$LISTENER" type veth peer name gw_l \
+		netns "$GATEWAY"
+	ip link add gw_relay netns "$GATEWAY" type veth peer name relay_gw \
+		netns "$RELAY"
+
+	ip -n "$LISTENER" link set l_gw up
+	ip -n "$LISTENER" addr add 192.168.0.2/24 dev l_gw
+	ip -n "$LISTENER" addr add 2001:db8::2/64 dev l_gw nodad
+	ip -n "$LISTENER" route add default via 192.168.0.1 dev l_gw
+	ip -n "$LISTENER" addr add "$GRP4"/32 dev l_gw autojoin
+	ip -n "$LISTENER" addr add "$GRP6"/128 dev l_gw autojoin
+
+	ip -n "$GATEWAY" link set gw_l up
+	ip -n "$GATEWAY" link set gw_relay up
+	ip -n "$GATEWAY" addr add 192.168.0.1/24 dev gw_l
+	ip -n "$GATEWAY" addr add 2001:db8::1/64 dev gw_l nodad
+	ip -n "$GATEWAY" addr add 10.0.0.1/24 dev gw_relay
+	ip -n "$GATEWAY" link add br0 type bridge
+	ip -n "$GATEWAY" link set br0 up
+	ip -n "$GATEWAY" link set gw_l master br0
+	ip -n "$GATEWAY" link add amtg master br0 type amt mode gateway \
+		local 10.0.0.1 discovery 10.0.0.2 dev gw_relay \
+		gateway_port $PORT_AMT relay_port $PORT_AMT || exit $ksft_skip
+
+	ip -n "$RELAY" link set relay_gw up
+	ip -n "$RELAY" addr add 10.0.0.2/24 dev relay_gw
+	ip -n "$RELAY" link add amtr type amt mode relay local 10.0.0.2 \
+		dev relay_gw relay_port $PORT_AMT max_tunnels 4 ||
+		exit $ksft_skip
+	ip -n "$RELAY" addr add "$SRC4"/32 dev amtr
+	ip -n "$RELAY" addr add "$SRC6"/128 dev amtr nodad
+	ip -n "$RELAY" link set amtr up
+	ip -n "$GATEWAY" link set amtg up
+
+	# Segment and checksum in software on the relay's egress, so that the
+	# frames on the wire are at most one MTU and carry a final checksum
+	# whatever the veth can do.
+	ip netns exec "$RELAY" ethtool -K relay_gw tx off >/dev/null ||
+		exit $ksft_skip
+
+	AMTR_MTU=$(ip netns exec "$RELAY" cat /sys/class/net/amtr/mtu)
+}
+
+# Send one single-datagram probe every second until the listener sees it,
+# which means that discovery, request and update are done for this group.
+wait_tunnel()
+{
+	local fam=$1 v6="" grp=$GRP4 src=$SRC4 port=4999 i
+
+	[ "$fam" = 6 ] && { v6=-6; grp=$GRP6; src=$SRC6; port=6999; }
+
+	for i in $(seq 40); do
+		ip netns exec "$LISTENER" $AMT_GSO recv $v6 -p $port \
+			"${PROBE_OPTS[@]}" -T 1 >"$TMPD/probe.out" &
+		local pid=$!
+		busywait 5000 grep -q READY "$TMPD/probe.out"
+		ip netns exec "$RELAY" $AMT_GSO send $v6 -I amtr -g $grp \
+			-b $src -p $port "${PROBE_OPTS[@]}"
+		wait $pid && return 0
+	done
+	return 1
+}
+
+# run_burst <4|6> <gso 0|1>: send NUM datagrams and capture. Sets RECV_RC.
+run_burst()
+{
+	local fam=$1 gso=$2 v6="" grp=$GRP4 src=$SRC4 port=4000 cnt=$BURST
+	local tail=$TAIL gsoopt="" pid_r pid_a pid_g f
+
+	[ "$fam" = 6 ] && { v6=-6; grp=$GRP6; src=$SRC6; port=6000; }
+	if [ "$gso" = 1 ]; then
+		gsoopt=-G
+	else
+		cnt=1
+		tail=0
+	fi
+	local opts=(-s "$SEG" -c "$cnt" -t "$tail" -n "$NUM")
+
+	rm -f "$TMPD"/{recv,amtr,gw}.out
+
+	ip netns exec "$LISTENER" $AMT_GSO recv $v6 -p $port "${opts[@]}" \
+		-T 3 -S 15 >"$TMPD/recv.out" &
+	pid_r=$!
+	ip netns exec "$RELAY" $AMT_GSO sniff -I amtr -p $port -M "$AMTR_MTU" \
+		-T 20 >"$TMPD/amtr.out" &
+	pid_a=$!
+	ip netns exec "$GATEWAY" $AMT_GSO sniff -I gw_relay -p $PORT_AMT \
+		-M 1500 -a $v6 -T 20 >"$TMPD/gw.out" &
+	pid_g=$!
+	for f in recv amtr gw; do
+		busywait 5000 grep -q READY "$TMPD/$f.out"
+	done
+
+	DROP0=$(dev_stat "$RELAY" relay_gw tx_dropped)
+	TXP0=$(dev_stat "$RELAY" relay_gw tx_packets)
+	CSUM0=$(csum_errors)
+	GRX0=$(dev_stat "$GATEWAY" amtg rx_packets)
+	LRX0=$(dev_stat "$LISTENER" l_gw rx_packets)
+	GRXD0=$(dev_stat "$GATEWAY" amtg rx_dropped)
+
+	ip netns exec "$RELAY" $AMT_GSO send $v6 -I amtr -g $grp -b $src \
+		-p $port "${opts[@]}" $gsoopt -d 2000
+
+	wait $pid_r
+	RECV_RC=$?
+	# The receiver is done, so every frame the captures will see is already
+	# queued on their sockets. Ask them to drain it and report.
+	kill -TERM $pid_a $pid_g
+	wait $pid_a $pid_g
+
+	DROPS=$(($(dev_stat "$RELAY" relay_gw tx_dropped) - DROP0))
+	TXP=$(($(dev_stat "$RELAY" relay_gw tx_packets) - TXP0))
+	CSUMERR=$(($(csum_errors) - CSUM0))
+	GRX=$(($(dev_stat "$GATEWAY" amtg rx_packets) - GRX0))
+	LRX=$(($(dev_stat "$LISTENER" l_gw rx_packets) - LRX0))
+	GRXD=$(($(dev_stat "$GATEWAY" amtg rx_dropped) - GRXD0))
+	EXPECT=$((NUM * (cnt + (tail ? 1 : 0))))
+}
+
+# run_case <name> <4|6> <tx on|off> <gso 0|1>
+run_case()
+{
+	local name=$1 fam=$2 tx=$3 gso=$4 big gwn stats
+
+	RET=0
+	retmsg=
+	ip netns exec "$RELAY" ethtool -K amtr tx "$tx" >/dev/null
+	if [ "$tx" = on ] && ! ip netns exec "$RELAY" ethtool -k amtr |
+	   grep -q '^tx-udp-segmentation: on'; then
+		log_test_skip "$name" "amtr cannot take tx-udp-segmentation"
+		return
+	fi
+
+	run_burst "$fam" "$gso"
+	big=$(field "$TMPD/amtr.out" over_mtu)
+
+	gwn=$(field "$TMPD/gw.out" amt_data)
+	log_info "$name: $(grep RECV "$TMPD/recv.out")"
+	log_info "$name: amtr tx $(grep SNIFF "$TMPD/amtr.out")"
+	log_info "$name: wire $(grep SNIFF "$TMPD/gw.out")"
+	stats="relay_gw tx +$TXP drop +$DROPS; gw csum_err +$CSUMERR"
+	stats="$stats; amtg rx +$GRX drop +$GRXD; listener rx +$LRX"
+	log_info "$name: $stats"
+
+	check_err $(($(field "$TMPD/amtr.out" lost) + \
+		     $(field "$TMPD/gw.out" lost) != 0)) \
+		"a packet capture lost frames, the verdict is unreliable"
+	check_err $RECV_RC "listener did not get every datagram intact"
+	check_err $((DROPS != 0)) "relay_gw dropped $DROPS packets"
+	check_err $((CSUMERR != 0)) "gateway counted $CSUMERR csum errors"
+	check_err $((gwn != EXPECT)) \
+		"gateway saw $gwn AMT data messages, expected $EXPECT"
+	check_err $(($(field "$TMPD/gw.out" over_mtu) != 0)) \
+		"frames larger than the MTU were put on the wire"
+
+	if [ "$tx" = on ] && [ "$gso" = 1 ]; then
+		# Without this the case proves nothing about the driver.
+		[ "$big" = 0 ] && ret_set_ksft_status "$ksft_skip" \
+			"no GSO skb reached amt_dev_xmit()"
+	else
+		check_err $((big != 0)) \
+			"a frame larger than the MTU reached amt_dev_xmit()"
+	fi
+
+	log_test "$name"
+}
+
+require_command ip
+require_command ethtool
+require_command nstat
+[ -x $AMT_GSO ] || skip_all "amt_gso helper not built"
+ip link help 2>&1 | grep -q amt || skip_all "iproute2 without amt support"
+# Without AF_PACKET (CONFIG_PACKET, CAP_NET_RAW) there is no verdict.
+$AMT_GSO sniff -I lo -p 1 -T 0 >/dev/null 2>&1 ||
+	skip_all "AF_PACKET capture not available"
+
+setup_topology
+
+wait_tunnel 4 || skip_all "IPv4 AMT tunnel did not come up"
+wait_tunnel 6 || skip_all "IPv6 AMT tunnel did not come up"
+
+run_case "IPv4 UDP_SEGMENT burst, amt tx offload off (control)" 4 off 1
+run_case "IPv6 UDP_SEGMENT burst, amt tx offload off (control)" 6 off 1
+run_case "IPv4 UDP_SEGMENT burst, amt tx offload on" 4 on 1
+run_case "IPv6 UDP_SEGMENT burst, amt tx offload on" 6 on 1
+run_case "IPv4 plain datagrams, amt tx offload on" 4 on 0
+run_case "IPv6 plain datagrams, amt tx offload on" 6 on 0
+
+exit "$EXIT_STATUS"
diff --git a/tools/testing/selftests/net/config b/tools/testing/selftests/net/config
index 737e7e6327b37..8f23da47405b9 100644
--- a/tools/testing/selftests/net/config
+++ b/tools/testing/selftests/net/config
@@ -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

41/3 2026/10/03 08:58 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 12067
							output: 36
							thoughts: 421
						

Thoughts:
**KMSAN Fuzzing Justification: AMT Driver Patch**

Alright, let's see if this patch is juicy enough to warrant a dedicated KMSAN fuzzing run. My initial instinct is to dig into it. First, I need to understand what this patch is even *doing*.  I'll start by taking a close look at the diff. Okay, I see it's touching `drivers/net/amt.c` and specifically focusing on the `amt_send_multicast_data` function.  The change is inserting `skb_reset_mac_header`, `skb_reset_inner_headers`, and a call to `udp_tunnel_handle_offloads`.  I get the sense that there's some kind of tunneling or offload logic involved, which can always be a potential area for memory safety issues.

Now, I'm going to jump into the code around line 1078 in `drivers/net/amt.c`. I need to grok `amt_send_multicast_data` and get a feel for what the original intent was, so I can grasp the impact of the patch. I need to understand what the role of `udp_tunnel_handle_offloads` is and why this patch touches it.  I'm also going to check if there are any selftests in `tools/testing/selftests/net/`, that could help me grasp the issue at hand. Understanding the context is going to be key here.  Depending on what I find, this could be a quick "yes" to fuzzing, or I'll need to dig deeper.



42/3 2026/10/03 08:58 tool read-file
0m Args:
{
  "File": "drivers/net/amt.c",
  "FirstLine": 1060,
  "LineCount": 50
}

Results:
{
  "Contents": "1060:\tstatic void amt_send_multicast_data(struct amt_dev *amt,\n1061:\t\t\t\t\t    const struct sk_buff *oskb,\n1062:\t\t\t\t\t    struct amt_tunnel_list *tunnel,\n1063:\t\t\t\t\t    bool v6)\n1064:\t{\n1065:\t\tstruct amt_header_mcast_data *amtmd;\n1066:\t\tstruct sk_buff *skb;\n1067:\t\tstruct iphdr *iph;\n1068:\t\tstruct flowi4 fl4;\n1069:\t\tstruct rtable *rt;\n1070:\t\tstruct sock *sk;\n1071:\t\n1072:\t\tsk = rcu_dereference_bh(amt-\u003esk);\n1073:\t\tif (!sk)\n1074:\t\t\treturn;\n1075:\t\n1076:\t\tskb = skb_copy_expand(oskb, sizeof(*amtmd) + sizeof(*iph) +\n1077:\t\t\t\t      sizeof(struct udphdr), 0, GFP_ATOMIC);\n1078:\t\tif (!skb)\n1079:\t\t\treturn;\n1080:\t\n1081:\t\t/* amt_dev_xmit() pulled the Ethernet header without moving the mac\n1082:\t\t * header. The tunnelled payload has no link-layer header, so the\n1083:\t\t * inner mac header must coincide with the inner IP header.\n1084:\t\t */\n1085:\t\tskb_reset_mac_header(skb);\n1086:\t\tskb_reset_inner_headers(skb);\n1087:\t\tif (udp_tunnel_handle_offloads(skb, true)) {\n1088:\t\t\tkfree_skb(skb);\n1089:\t\t\treturn;\n1090:\t\t}\n1091:\t\n1092:\t\tmemset(\u0026fl4, 0, sizeof(struct flowi4));\n1093:\t\tfl4.flowi4_oif         = amt-\u003estream_dev-\u003eifindex;\n1094:\t\tfl4.daddr              = tunnel-\u003eip4;\n1095:\t\tfl4.saddr              = amt-\u003elocal_ip;\n1096:\t\tfl4.flowi4_proto       = IPPROTO_UDP;\n1097:\t\trt = ip_route_output_key(amt-\u003enet, \u0026fl4);\n1098:\t\tif (IS_ERR(rt)) {\n1099:\t\t\tnetdev_dbg(amt-\u003edev, \"no route to %pI4\\n\", \u0026tunnel-\u003eip4);\n1100:\t\t\tkfree_skb(skb);\n1101:\t\t\treturn;\n1102:\t\t}\n1103:\t\n1104:\t\tamtmd = skb_push(skb, sizeof(*amtmd));\n1105:\t\tamtmd-\u003eversion = 0;\n1106:\t\tamtmd-\u003ereserved = 0;\n1107:\t\tamtmd-\u003etype = AMT_MSG_MULTICAST_DATA;\n1108:\t\n1109:\t\tif (!v6)\n"
}

43/3 2026/10/03 08:58 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 13677
							output: 36
							thoughts: 17
						

Thoughts:
Okay, here's my interpretation of that thought process, tailored for an expert audience, and presented as if it were my own internal monologue:

**Diving Deeper into `amt_send_multicast_data`**

Alright, so the initial direction is clear: we need to understand the data transmission process. The hint is to look further down in `amt_send_multicast_data`. This immediately suggests we're troubleshooting, trying to pinpoint something within this core function. We're not just glancing at the entry point; we're trying to trace the flow of execution within it. This tells me we’re past the initial checks and want to understand how the data is actually *being* sent. We've probably already identified an issue related to this specific function, or we're in the process of building it, and we are working our way through the code. I need to be able to fully visualize the different paths the function could take. I will need to understand what events trigger execution further down. This means I'm looking for the meat of the multicast sending logic. Likely, there are checks, buffer manipulations, network calls (sockets, I presume), and maybe even error handling and retries in that code. The focus is to look at the process in motion, not the setup. I need to check for optimization options.



44/3 2026/10/03 08:58 tool read-file
0m Args:
{
  "File": "drivers/net/amt.c",
  "FirstLine": 1105,
  "LineCount": 50
}

Results:
{
  "Contents": "1105:\t\tamtmd-\u003eversion = 0;\n1106:\t\tamtmd-\u003ereserved = 0;\n1107:\t\tamtmd-\u003etype = AMT_MSG_MULTICAST_DATA;\n1108:\t\n1109:\t\tif (!v6)\n1110:\t\t\tskb_set_inner_protocol(skb, htons(ETH_P_IP));\n1111:\t\telse\n1112:\t\t\tskb_set_inner_protocol(skb, htons(ETH_P_IPV6));\n1113:\t\tudp_tunnel_xmit_skb(rt, sk, skb,\n1114:\t\t\t\t    fl4.saddr,\n1115:\t\t\t\t    fl4.daddr,\n1116:\t\t\t\t    AMT_TOS,\n1117:\t\t\t\t    ip4_dst_hoplimit(\u0026rt-\u003edst),\n1118:\t\t\t\t    0,\n1119:\t\t\t\t    amt-\u003erelay_port,\n1120:\t\t\t\t    tunnel-\u003esource_port,\n1121:\t\t\t\t    false,\n1122:\t\t\t\t    false,\n1123:\t\t\t\t    0);\n1124:\t}\n1125:\t\n1126:\tstatic bool amt_send_membership_query(struct amt_dev *amt,\n1127:\t\t\t\t\t      struct sk_buff *skb,\n1128:\t\t\t\t\t      struct amt_tunnel_list *tunnel,\n1129:\t\t\t\t\t      bool v6)\n1130:\t{\n1131:\t\tstruct amt_header_membership_query *amtmq;\n1132:\t\tstruct rtable *rt;\n1133:\t\tstruct flowi4 fl4;\n1134:\t\tstruct sock *sk;\n1135:\t\tint err;\n1136:\t\n1137:\t\tsk = rcu_dereference_bh(amt-\u003esk);\n1138:\t\tif (!sk)\n1139:\t\t\treturn true;\n1140:\t\n1141:\t\terr = skb_cow_head(skb, LL_RESERVED_SPACE(amt-\u003edev) + sizeof(*amtmq) +\n1142:\t\t\t\t   sizeof(struct iphdr) + sizeof(struct udphdr));\n1143:\t\tif (err)\n1144:\t\t\treturn true;\n1145:\t\n1146:\t\tskb_reset_inner_headers(skb);\n1147:\t\tmemset(\u0026fl4, 0, sizeof(struct flowi4));\n1148:\t\tfl4.flowi4_oif         = amt-\u003estream_dev-\u003eifindex;\n1149:\t\tfl4.daddr              = tunnel-\u003eip4;\n1150:\t\tfl4.saddr              = amt-\u003elocal_ip;\n1151:\t\tfl4.flowi4_dscp        = inet_dsfield_to_dscp(AMT_TOS);\n1152:\t\tfl4.flowi4_proto       = IPPROTO_UDP;\n1153:\t\trt = ip_route_output_key(amt-\u003enet, \u0026fl4);\n1154:\t\tif (IS_ERR(rt)) {\n"
}

45/3 2026/10/03 08:58 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 14817
							output: 33
							thoughts: 19
						

Thoughts:
Okay, let's dive into this. Here's my thought process on dissecting `amt_dev_xmit`:

**Diving into `amt_dev_xmit`**

Alright, my immediate focus is on understanding what the function `amt_dev_xmit` actually *does* and, crucially, where it's defined within this code. I need to get a clear picture of its role. Is it a central component? A helper function? What does it transmit? Why is it relevant? My mental gears are already turning, considering potential areas of interest within the broader architecture. I'm going to follow the trail of this function and determine its place in the overall scheme of things.



46/3 2026/10/03 08:58 tool grepper
0m Args:
{
  "Expression": "amt_dev_xmit",
  "PathPrefix": "drivers/net/amt.c"
}

Results:
{
  "Output": "drivers/net/amt.c=1060=static void amt_send_multicast_data(struct amt_dev *amt,\n--\ndrivers/net/amt.c-1080-\ndrivers/net/amt.c:1081:\t/* amt_dev_xmit() pulled the Ethernet header without moving the mac\ndrivers/net/amt.c-1082-\t * header. The tunnelled payload has no link-layer header, so the\n--\ndrivers/net/amt.c=1126=static bool amt_send_membership_query(struct amt_dev *amt,\n--\ndrivers/net/amt.c-1186-\ndrivers/net/amt.c:1187:static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev)\ndrivers/net/amt.c-1188-{\n--\ndrivers/net/amt.c=3150=static const struct net_device_ops amt_netdev_ops = {\n--\ndrivers/net/amt.c-3154-\t.ndo_stop\t\t= amt_dev_stop,\ndrivers/net/amt.c:3155:\t.ndo_start_xmit         = amt_dev_xmit,\ndrivers/net/amt.c-3156-};\n"
}

47/3 2026/10/03 08:58 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 15352
							output: 36
							thoughts: 22
						

Thoughts:
Here's my analysis of the provided thought process, tailored for an expert audience:

**Diving into `amt_dev_xmit`**

Okay, so the thought process kicks off with a clear directive: we need to examine the `amt_dev_xmit` function within the `drivers/net/amt.c` file. This immediately tells me we're dealing with an AMT (Active Management Technology) driver, specifically related to network functionality, likely transmission or packet handling. The fact that `amt_dev_xmit` is being targeted suggests it's a critical function, possibly handling the actual transmission of packets. I'm already mentally running through the typical areas I'd expect to see in a function like this: packet construction, hardware interface interaction (registers, DMA setups), error handling, and perhaps some form of queuing mechanism if it's not a direct, immediate transmission. My expectation is that this is where the meat of the AMT network driver lives. It is probably handling how the network adapter is accessed via the AMT protocol.



48/3 2026/10/03 08:58 tool read-file
0m Args:
{
  "File": "drivers/net/amt.c",
  "FirstLine": 1185,
  "LineCount": 80
}

Results:
{
  "Contents": "1185:\t}\n1186:\t\n1187:\tstatic netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev)\n1188:\t{\n1189:\t\tstruct amt_dev *amt = netdev_priv(dev);\n1190:\t\tstruct amt_tunnel_list *tunnel;\n1191:\t\tstruct amt_group_node *gnode;\n1192:\t\tunion amt_addr group = {0,};\n1193:\t#if IS_ENABLED(CONFIG_IPV6)\n1194:\t\tstruct ipv6hdr *ip6h;\n1195:\t\tstruct mld_msg *mld;\n1196:\t#endif\n1197:\t\tbool report = false;\n1198:\t\tstruct igmphdr *ih;\n1199:\t\tbool query = false;\n1200:\t\tstruct iphdr *iph;\n1201:\t\tbool data = false;\n1202:\t\tbool v6 = false;\n1203:\t\tu32 hash;\n1204:\t\n1205:\t\tiph = ip_hdr(skb);\n1206:\t\tif (iph-\u003eversion == 4) {\n1207:\t\t\tif (!ipv4_is_multicast(iph-\u003edaddr))\n1208:\t\t\t\tgoto free;\n1209:\t\n1210:\t\t\tif (!ip_mc_check_igmp(skb)) {\n1211:\t\t\t\tih = igmp_hdr(skb);\n1212:\t\t\t\tswitch (ih-\u003etype) {\n1213:\t\t\t\tcase IGMPV3_HOST_MEMBERSHIP_REPORT:\n1214:\t\t\t\tcase IGMP_HOST_MEMBERSHIP_REPORT:\n1215:\t\t\t\t\treport = true;\n1216:\t\t\t\t\tbreak;\n1217:\t\t\t\tcase IGMP_HOST_MEMBERSHIP_QUERY:\n1218:\t\t\t\t\tquery = true;\n1219:\t\t\t\t\tbreak;\n1220:\t\t\t\tdefault:\n1221:\t\t\t\t\tgoto free;\n1222:\t\t\t\t}\n1223:\t\t\t} else {\n1224:\t\t\t\tdata = true;\n1225:\t\t\t}\n1226:\t\t\tv6 = false;\n1227:\t\t\tgroup.ip4 = ip_hdr(skb)-\u003edaddr;\n1228:\t#if IS_ENABLED(CONFIG_IPV6)\n1229:\t\t} else if (iph-\u003eversion == 6) {\n1230:\t\t\tip6h = ipv6_hdr(skb);\n1231:\t\t\tif (!ipv6_addr_is_multicast(\u0026ip6h-\u003edaddr))\n1232:\t\t\t\tgoto free;\n1233:\t\n1234:\t\t\tif (!ipv6_mc_check_mld(skb)) {\n1235:\t\t\t\tmld = (struct mld_msg *)skb_transport_header(skb);\n1236:\t\t\t\tswitch (mld-\u003emld_type) {\n1237:\t\t\t\tcase ICMPV6_MGM_REPORT:\n1238:\t\t\t\tcase ICMPV6_MLD2_REPORT:\n1239:\t\t\t\t\treport = true;\n1240:\t\t\t\t\tbreak;\n1241:\t\t\t\tcase ICMPV6_MGM_QUERY:\n1242:\t\t\t\t\tquery = true;\n1243:\t\t\t\t\tbreak;\n1244:\t\t\t\tdefault:\n1245:\t\t\t\t\tgoto free;\n1246:\t\t\t\t}\n1247:\t\t\t} else {\n1248:\t\t\t\tdata = true;\n1249:\t\t\t}\n1250:\t\t\tv6 = true;\n1251:\t\t\tgroup.ip6 = ipv6_hdr(skb)-\u003edaddr;\n1252:\t#endif\n1253:\t\t} else {\n1254:\t\t\tdev-\u003estats.tx_errors++;\n1255:\t\t\tgoto free;\n1256:\t\t}\n1257:\t\n1258:\t\tif (!pskb_may_pull(skb, sizeof(struct ethhdr)))\n1259:\t\t\tgoto free;\n1260:\t\n1261:\t\tskb_pull(skb, sizeof(struct ethhdr));\n1262:\t\n1263:\t\tif (amt-\u003emode == AMT_MODE_GATEWAY) {\n1264:\t\t\t/* Gateway only passes IGMP/MLD packets */\n"
}

49/3 2026/10/03 08:58 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 16760
							output: 30
							thoughts: 253
						

Thoughts:
**Analyzing the AMT Relay Multicast Data Path**

Okay, so I'm diving into the `amt_dev_xmit` function, specifically looking at that `skb_pull(skb, sizeof(struct ethhdr))` call. That's pulling off the Ethernet header, as expected, setting up the packet for further processing, likely for transmission over the tunnel. Then, `amt_send_multicast_data` is invoked to handle the relaying of this data.

Now, I need to focus on the evolution of `amt_send_multicast_data`. I see a significant change in the way the Socket Buffer (SKB) is handled. The old code involved `skb_copy_expand` to allocate more space for headers and payload and then `memset` to zero out the flow information. I can see what they were doing and this seems straightforward. However, this has been replaced with:

```c
	skb_reset_mac_header(skb);
	skb_reset_inner_headers(skb);
	if (udp_tunnel_handle_offloads(skb, true)) {
		kfree_skb(skb);
		return;
	}
```

The MAC and inner headers are reset, which is consistent with the packet being re-encapsulated. But what jumps out at me is that `udp_tunnel_handle_offloads` function call. My interest is definitely piqued here. This suggests that the code is now managing offload capabilities during the tunnel handling. If that function returns true, the SKB is freed. This strongly suggests that `udp_tunnel_handle_offloads` is now responsible for handling potentially more complex, more modern and offloaded packet processing scenarios, and that handling of this kind may fail, and so the skb is freed if so. I need to dig into `udp_tunnel_handle_offloads` to understand the implications of this change. It looks like the main part of the packet construction has been handed over to the offload subsystem.



50/3 2026/10/03 08:58 tool grepper
0m Error:
no matches

Args:
{
  "Expression": "udp_tunnel_handle_offloads",
  "PathPrefix": "net/"
}

Results:
{
  "error": "no matches"
}

51/3 2026/10/03 08:58 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 17493
							output: 22
							thoughts: 19
						

Thoughts:
Okay, here's my take on that thought process, tailored for an expert audience:

**Kernel-Wide UDP Tunnel Offload Hunting**

Alright, so I need to get a handle on `udp_tunnel_handle_offloads`. My initial instinct is to treat this as a global search. I'm thinking I'll want to use a tool that can dive deep into the entire kernel source tree, likely something more robust than just a `grep` or `ack`. I’ll need to target the kernel build tree specifically, because I want to make sure I’m examining the code that’s actually compiled. The exact tool choice will depend on the development environment, but I'll want something that can quickly and accurately pinpoint all instances of that function. I need to be able to jump to the definition and all calls. I'm anticipating that this function is involved in some critical networking path, so I want to understand its integration with the rest of the UDP tunnel implementation. I'm going to also consider surrounding code to determine how that function is being used, so that I can figure out the context. I’m also going to check for other relevant functions or data structures which might be relevant. My gut feeling is that this has something to do with the offload engine, potentially hardware or software-based. I'll need to correlate the usages of this function with the relevant network device drivers, stack components, and possibly even the Netfilter subsystem, depending on the kernel version and feature configuration. The specific goal will be determine where this is being used and why. I'll probably also want to cross-reference this function name with any kernel documentation or mailing list archives to get a sense of its history and purpose.



52/3 2026/10/03 08:58 tool grepper
0m Args:
{
  "Expression": "udp_tunnel_handle_offloads"
}

Results:
{
  "Output": "drivers/net/amt.c=1060=static void amt_send_multicast_data(struct amt_dev *amt,\n--\ndrivers/net/amt.c-1086-\tskb_reset_inner_headers(skb);\ndrivers/net/amt.c:1087:\tif (udp_tunnel_handle_offloads(skb, true)) {\ndrivers/net/amt.c-1088-\t\tkfree_skb(skb);\n--\ndrivers/net/bareudp.c=302=static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev,\n--\ndrivers/net/bareudp.c-354-\ndrivers/net/bareudp.c:355:\terr = udp_tunnel_handle_offloads(skb, udp_sum);\ndrivers/net/bareudp.c-356-\tif (err)\n--\ndrivers/net/bareudp.c=372=static int bareudp6_xmit_skb(struct sk_buff *skb, struct net_device *dev,\n--\ndrivers/net/bareudp.c-422-\ndrivers/net/bareudp.c:423:\terr = udp_tunnel_handle_offloads(skb, udp_sum);\ndrivers/net/bareudp.c-424-\tif (err)\n--\ndrivers/net/geneve.c=1320=static int geneve_build_skb(struct dst_entry *dst, struct sk_buff *skb,\n--\ndrivers/net/geneve.c-1346-\tdouble_encap = udp_tunnel_handle_partial(skb);\ndrivers/net/geneve.c:1347:\terr = udp_tunnel_handle_offloads(skb, udp_sum);\ndrivers/net/geneve.c-1348-\tif (err)\n--\ninclude/net/udp_tunnel.h=152=static inline bool udp_tunnel_handle_partial(struct sk_buff *skb)\n--\ninclude/net/udp_tunnel.h-159-\t * UDP_TUNNEL, that will be re-added by the later\ninclude/net/udp_tunnel.h:160:\t * udp_tunnel_handle_offloads().\ninclude/net/udp_tunnel.h-161-\t */\n--\ninclude/net/udp_tunnel.h=197=struct metadata_dst *udp_tun_rx_dst(struct sk_buff *skb, unsigned short family,\n--\ninclude/net/udp_tunnel.h-201-#ifdef CONFIG_INET\ninclude/net/udp_tunnel.h:202:static inline int udp_tunnel_handle_offloads(struct sk_buff *skb, bool udp_csum)\ninclude/net/udp_tunnel.h-203-{\n"
}

53/3 2026/10/03 08:58 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 18601
							output: 37
							thoughts: 26
						

Thoughts:
Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:

**Diving into the UDP Tunnel Offload Handling**

Alright, time to get my hands dirty. I'm thinking I should start digging into `udp_tunnel_handle_offloads`. I'm going to head straight to `include/net/udp_tunnel.h`. That's where I'd expect to find the core definitions and structures related to how the kernel manages offloading for UDP tunnels. I need to refresh my memory on the interactions between the UDP tunneling mechanisms and the hardware offload capabilities. Specifically, I'm interested in how it deals with checksum offload, fragmentation offload (if supported), and potentially even generic segmentation offload (GSO). Understanding the data structures used there will give me a solid foundation for tracing the code paths involved in actual packet processing. I'm keen to see if any new techniques have been implemented with newer hardware.



54/3 2026/10/03 08:59 tool read-file
0m Args:
{
  "File": "include/net/udp_tunnel.h",
  "FirstLine": 195,
  "LineCount": 40
}

Results:
{
  "Contents": " 195:\t\t\t\t\t\t struct dst_cache *dst_cache);\n 196:\t\n 197:\tstruct metadata_dst *udp_tun_rx_dst(struct sk_buff *skb, unsigned short family,\n 198:\t\t\t\t\t    const unsigned long *flags,\n 199:\t\t\t\t\t    __be64 tunnel_id, int md_size);\n 200:\t\n 201:\t#ifdef CONFIG_INET\n 202:\tstatic inline int udp_tunnel_handle_offloads(struct sk_buff *skb, bool udp_csum)\n 203:\t{\n 204:\t\tint type = udp_csum ? SKB_GSO_UDP_TUNNEL_CSUM : SKB_GSO_UDP_TUNNEL;\n 205:\t\n 206:\t\treturn iptunnel_handle_offloads(skb, type);\n 207:\t}\n 208:\t#endif\n 209:\t\n 210:\t#if IS_ENABLED(CONFIG_NET_UDP_TUNNEL)\n 211:\tvoid udp_tunnel_update_gro_lookup(struct net *net, struct sock *sk, bool add);\n 212:\tvoid udp_tunnel_update_gro_rcv(struct sock *sk, bool add);\n 213:\t#else\n 214:\tstatic inline void udp_tunnel_update_gro_lookup(struct net *net,\n 215:\t\t\t\t\t\t\tstruct sock *sk, bool add) {}\n 216:\tstatic inline void udp_tunnel_update_gro_rcv(struct sock *sk, bool add) {}\n 217:\t#endif\n 218:\t\n 219:\tstatic inline void udp_tunnel_cleanup_gro(struct sock *sk)\n 220:\t{\n 221:\t\tudp_tunnel_update_gro_rcv(sk, false);\n 222:\t\tudp_tunnel_update_gro_lookup(sock_net(sk), sk, false);\n 223:\t}\n 224:\t\n 225:\tstatic inline void udp_tunnel_encap_enable(struct sock *sk)\n 226:\t{\n 227:\t\tif (udp_test_and_set_bit(ENCAP_ENABLED, sk))\n 228:\t\t\treturn;\n 229:\t\n 230:\t#if IS_ENABLED(CONFIG_IPV6)\n 231:\t\tif (READ_ONCE(sk-\u003esk_family) == PF_INET6)\n 232:\t\t\tudpv6_encap_enable();\n 233:\t#endif\n 234:\t\tudp_encap_enable();\n"
}

55/3 2026/10/03 08:59 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 19554
							output: 21
							thoughts: 16
						

Thoughts:
Okay, let's dive into this. Here's my take on understanding `iptunnel_handle_offloads`:

**Analyzing iptunnel_handle_offloads**

Alright, I'm going to take a closer look at this `iptunnel_handle_offloads` function. I already have a pretty good grasp of tunneling mechanisms, so I'm thinking about the low-level details of how offloads are handled within this context. The core of my interest lies in how the kernel interacts with network hardware to enhance tunnel performance. I want to see precisely where the interface between software processing and hardware acceleration occurs. I suspect it relates to checksum offloading, segmentation offload, and potentially LRO/GRO within the tunnel itself, so I'll be looking for clues around those areas. I'm keen to dissect the data structures and control paths involved and find out how it interacts with the underlying network interfaces and their respective drivers. Ultimately, I'm trying to pin down the specific optimizations it's implementing and how it's designed to minimize overhead, and maximise throughput. I'm especially interested if there are any vendor-specific implementation details that I should be aware of.



56/3 2026/10/03 08:59 tool grepper
0m Args:
{
  "Expression": "iptunnel_handle_offloads"
}

Results:
{
  "Output": "drivers/net/vxlan/vxlan_core.c=2245=static int vxlan_build_skb(struct sk_buff *skb, struct dst_entry *dst,\n--\ndrivers/net/vxlan/vxlan_core.c-2276-\tdouble_encap = udp_tunnel_handle_partial(skb);\ndrivers/net/vxlan/vxlan_core.c:2277:\terr = iptunnel_handle_offloads(skb, type);\ndrivers/net/vxlan/vxlan_core.c-2278-\tif (err)\n--\ninclude/net/ip_tunnels.h=647=static inline void ip_tunnel_adj_headroom(struct net_device *dev,\n--\ninclude/net/ip_tunnels.h-655-\ninclude/net/ip_tunnels.h:656:int iptunnel_handle_offloads(struct sk_buff *skb, int gso_type_mask);\ninclude/net/ip_tunnels.h-657-\n--\ninclude/net/udp_tunnel.h=202=static inline int udp_tunnel_handle_offloads(struct sk_buff *skb, bool udp_csum)\n--\ninclude/net/udp_tunnel.h-205-\ninclude/net/udp_tunnel.h:206:\treturn iptunnel_handle_offloads(skb, type);\ninclude/net/udp_tunnel.h-207-}\n--\nnet/ipv4/fou_core.c=944=int __fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,\n--\nnet/ipv4/fou_core.c-948-\nnet/ipv4/fou_core.c:949:\terr = iptunnel_handle_offloads(skb, type);\nnet/ipv4/fou_core.c-950-\tif (err)\n--\nnet/ipv4/fou_core.c=960=int __gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,\n--\nnet/ipv4/fou_core.c-977-\nnet/ipv4/fou_core.c:978:\terr = iptunnel_handle_offloads(skb, type);\nnet/ipv4/fou_core.c-979-\tif (err)\n--\nnet/ipv4/ip_gre.c=491=static int gre_handle_offloads(struct sk_buff *skb, bool csum)\nnet/ipv4/ip_gre.c-492-{\nnet/ipv4/ip_gre.c:493:\treturn iptunnel_handle_offloads(skb, csum ? SKB_GSO_GRE_CSUM : SKB_GSO_GRE);\nnet/ipv4/ip_gre.c-494-}\n--\nnet/ipv4/ip_tunnel_core.c=172=EXPORT_SYMBOL_GPL(iptunnel_metadata_reply);\nnet/ipv4/ip_tunnel_core.c-173-\nnet/ipv4/ip_tunnel_core.c:174:int iptunnel_handle_offloads(struct sk_buff *skb,\nnet/ipv4/ip_tunnel_core.c-175-\t\t\t     int gso_type_mask)\n--\nnet/ipv4/ip_tunnel_core.c-203-}\nnet/ipv4/ip_tunnel_core.c:204:EXPORT_SYMBOL_GPL(iptunnel_handle_offloads);\nnet/ipv4/ip_tunnel_core.c-205-\n--\nnet/ipv4/ipip.c=282=static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb,\n--\nnet/ipv4/ipip.c-307-\nnet/ipv4/ipip.c:308:\tif (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP4))\nnet/ipv4/ipip.c-309-\t\tgoto tx_error;\n--\nnet/ipv6/ip6_gre.c=598=static int gre_handle_offloads(struct sk_buff *skb, bool csum)\nnet/ipv6/ip6_gre.c-599-{\nnet/ipv6/ip6_gre.c:600:\treturn iptunnel_handle_offloads(skb,\nnet/ipv6/ip6_gre.c-601-\t\t\t\t\tcsum ? SKB_GSO_GRE_CSUM : SKB_GSO_GRE);\n--\nnet/ipv6/ip6_tunnel.c=1297=ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,\n--\nnet/ipv6/ip6_tunnel.c-1399-\nnet/ipv6/ip6_tunnel.c:1400:\tif (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP6))\nnet/ipv6/ip6_tunnel.c-1401-\t\treturn -1;\n--\nnet/ipv6/seg6_iptunnel.c=398=static int seg6_do_srh(struct sk_buff *skb, struct dst_entry *cache_dst)\n--\nnet/ipv6/seg6_iptunnel.c-419-\tcase SEG6_IPTUN_MODE_ENCAP_RED:\nnet/ipv6/seg6_iptunnel.c:420:\t\terr = iptunnel_handle_offloads(skb, SKB_GSO_IPXIP6);\nnet/ipv6/seg6_iptunnel.c-421-\t\tif (err)\n--\nnet/ipv6/sit.c=966=static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,\n--\nnet/ipv6/sit.c-1032-\nnet/ipv6/sit.c:1033:\tif (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP4)) {\nnet/ipv6/sit.c-1034-\t\tip_rt_put(rt);\n--\nnet/ipv6/sit.c=1118=static netdev_tx_t sit_tunnel_xmit__(struct sk_buff *skb,\n--\nnet/ipv6/sit.c-1124-\nnet/ipv6/sit.c:1125:\tif (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP4))\nnet/ipv6/sit.c-1126-\t\tgoto tx_error;\n--\nnet/netfilter/ipvs/ip_vs_xmit.c=1147=ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,\n--\nnet/netfilter/ipvs/ip_vs_xmit.c-1233-\nnet/netfilter/ipvs/ip_vs_xmit.c:1234:\tif (iptunnel_handle_offloads(skb, gso_type))\nnet/netfilter/ipvs/ip_vs_xmit.c-1235-\t\tgoto tx_error;\n--\nnet/netfilter/ipvs/ip_vs_xmit.c=1292=ip_vs_tunnel_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,\n--\nnet/netfilter/ipvs/ip_vs_xmit.c-1376-\nnet/netfilter/ipvs/ip_vs_xmit.c:1377:\tif (iptunnel_handle_offloads(skb, gso_type))\nnet/netfilter/ipvs/ip_vs_xmit.c-1378-\t\tgoto tx_error;\n--\nnet/netfilter/nf_flow_table_ip.c=583=static int nf_flow_tunnel_ipip_push(struct net *net, struct sk_buff *skb,\n--\nnet/netfilter/nf_flow_table_ip.c-593-\nnet/netfilter/nf_flow_table_ip.c:594:\terr = iptunnel_handle_offloads(skb, SKB_GSO_IPXIP4);\nnet/netfilter/nf_flow_table_ip.c-595-\tif (err)\n--\nnet/netfilter/nf_flow_table_ip.c=639=static int nf_flow_tunnel_ip6ip6_push(struct net *net, struct sk_buff *skb,\n--\nnet/netfilter/nf_flow_table_ip.c-655-\nnet/netfilter/nf_flow_table_ip.c:656:\terr = iptunnel_handle_offloads(skb, SKB_GSO_IPXIP6);\nnet/netfilter/nf_flow_table_ip.c-657-\tif (err)\n"
}

57/3 2026/10/03 08:59 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 22091
							output: 40
							thoughts: 28
						

Thoughts:
Okay, here's my take on those thoughts, framed as an expert's internal monologue:

**Diving into `iptunnel_handle_offloads`**

Right, let's refresh our memory on that function. Time to crack open `net/ipv4/ip_tunnel_core.c` and dig into `iptunnel_handle_offloads`. I'm interested in how it manages offload capabilities within the IP tunnel framework. Given my experience, I'm expecting this function to be the central point for dealing with checksum offloading, TSO/GSO, and perhaps even GRO within the context of encapsulated traffic. I need to understand the control flow, specifically how it interacts with the underlying devices, and what checks it performs to ensure that the offloads are valid and compatible with the tunnel configuration. I will be particularly focused on how it handles differing MTUs between inner and outer headers, and how it deals with fragmentation if necessary. A sharp understanding of the interactions with the skb's frag lists and the device's TX queues is a must. Let's see if the code clearly separates the concerns around configuration validation, offload enabling and disabling, and potential error handling. I'm hoping to see a well-structured approach that ensures efficient and reliable operation. This is likely an area where performance can be severely impacted by implementation issues, so I'm paying close attention to any potential bottlenecks or inefficiencies. Alright, let's see what we've got.



58/3 2026/10/03 08:59 tool read-file
0m Args:
{
  "File": "net/ipv4/ip_tunnel_core.c",
  "FirstLine": 170,
  "LineCount": 40
}

Results:
{
  "Contents": " 170:\t\treturn res;\n 171:\t}\n 172:\tEXPORT_SYMBOL_GPL(iptunnel_metadata_reply);\n 173:\t\n 174:\tint iptunnel_handle_offloads(struct sk_buff *skb,\n 175:\t\t\t\t     int gso_type_mask)\n 176:\t{\n 177:\t\tint err;\n 178:\t\n 179:\t\tif (likely(!skb-\u003eencapsulation)) {\n 180:\t\t\tskb_reset_inner_headers(skb);\n 181:\t\t\tskb-\u003eencapsulation = 1;\n 182:\t\t}\n 183:\t\n 184:\t\tif (skb_is_gso(skb)) {\n 185:\t\t\terr = skb_header_unclone(skb, GFP_ATOMIC);\n 186:\t\t\tif (unlikely(err))\n 187:\t\t\t\treturn err;\n 188:\t\t\tskb_shinfo(skb)-\u003egso_type |= gso_type_mask;\n 189:\t\t\treturn 0;\n 190:\t\t}\n 191:\t\n 192:\t\tif (skb-\u003eip_summed != CHECKSUM_PARTIAL) {\n 193:\t\t\tskb-\u003eip_summed = CHECKSUM_NONE;\n 194:\t\t\t/* We clear encapsulation here to prevent badly-written\n 195:\t\t\t * drivers potentially deciding to offload an inner checksum\n 196:\t\t\t * if we set CHECKSUM_PARTIAL on the outer header.\n 197:\t\t\t * This should go away when the drivers are all fixed.\n 198:\t\t\t */\n 199:\t\t\tskb-\u003eencapsulation = 0;\n 200:\t\t}\n 201:\t\n 202:\t\treturn 0;\n 203:\t}\n 204:\tEXPORT_SYMBOL_GPL(iptunnel_handle_offloads);\n 205:\t\n 206:\t/**\n 207:\t * iptunnel_pmtud_build_icmp() - Build ICMP error message for PMTUD\n 208:\t * @skb:\tOriginal packet with L2 header\n 209:\t * @mtu:\tMTU value for ICMP error\n"
}

59/3 2026/10/03 08:59 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 23074
							output: 245
							thoughts: 1592
						

Thoughts:
**Analysis of AMT GSO Offload Patch**

Okay, let's break this down. It looks like we're dealing with a patch that's tweaking the AMT (Automatic Multicast Tunneling) driver, specifically in `amt_send_multicast_data`. The goal is to properly handle UDP segmentation offload (UDP GSO) when AMT is enabled.  The core issue seems to be how the Ethernet and MAC headers are managed within the `skb` (socket buffer) when GSO is in play. `amt_dev_xmit` appears to have been pulling off the Ethernet header without adjusting the MAC header. This patch corrects the MAC header pointer after the pull and before inner header processing, and then calls the `udp_tunnel_handle_offloads` function to correctly handle GSO-related encapsulation and flags.

My initial thought is to assess the KMSAN implications. First, is this touching kernel structures passed to userspace via any method? No, this is purely internal packet manipulation. Next, are we dealing with uninitialized memory? The code carefully resets and modifies skb header pointers, and the offload handler manipulates encapsulation flags, not uninitialized data. There are no allocations or direct reads/copies of uninitialized data in this patch. Crucially, is the patch altering bounds checks or introducing logic that *could* lead to access of uninitialized memory in surrounding code? No, the focus here is GSO, which deals with packet segmentation and encapsulation, not boundary modification.

The worst-case scenarios I foresee here are memory corruption or leaks.  If there were a bug, we could have out-of-bounds access during segmentation, corrupted packets, or issues with skb lifecycle (memory leaks/use-after-free) due to incorrect offload handling or header pointer manipulation. However, all of these are types of bugs that KASAN should easily catch, such as out-of-bounds access and memory lifecycle issues. No information is leaked or uninitialized memory is read.

Therefore, this patch doesn't trigger the need for KMSAN analysis. The changes are focused on correcting header pointers and offload processing for GSO, which are issues detectable by existing tools like KASAN. We are good to go.



60/3 2026/10/03 08:59 tool set-results
0m Args:
{
  "KMSANReasoning": "The patch modifies `amt_send_multicast_data()` in `drivers/net/amt.c` to adjust skb inner headers (`skb_reset_mac_header(skb)` and `skb_reset_inner_headers(skb)`) and invoke `udp_tunnel_handle_offloads(skb, true)` so that UDP segmentation offload (GSO) packets are appropriately encapsulated and marked before transmission. The rest of the diff adds user-space selftests.\n\nThis change does not introduce or modify any uninitialized variables, heap/stack allocations, or copies to user space. It only adjusts skb metadata pointers and flags for network offloading. Any potential issues with incorrect header offsets during GSO segmentation, packet trimming, or skb lifetime management would manifest as out-of-bounds memory accesses or use-after-free bugs, which are detected by KASAN rather than KMSAN. As there are no uninitialized memory read or info-leak risks, a dedicated KMSAN fuzzing session is not justified.",
  "NeedsKMSAN": false
}

Results:
{
  "KMSANReasoning": "The patch modifies `amt_send_multicast_data()` in `drivers/net/amt.c` to adjust skb inner headers (`skb_reset_mac_header(skb)` and `skb_reset_inner_headers(skb)`) and invoke `udp_tunnel_handle_offloads(skb, true)` so that UDP segmentation offload (GSO) packets are appropriately encapsulated and marked before transmission. The rest of the diff adds user-space selftests.\n\nThis change does not introduce or modify any uninitialized variables, heap/stack allocations, or copies to user space. It only adjusts skb metadata pointers and flags for network offloading. Any potential issues with incorrect header offsets during GSO segmentation, packet trimming, or skb lifetime management would manifest as out-of-bounds memory accesses or use-after-free bugs, which are detected by KASAN rather than KMSAN. As there are no uninitialized memory read or info-leak risks, a dedicated KMSAN fuzzing session is not justified.",
  "NeedsKMSAN": false
}

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)