| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/11/01 22:46 | flow | patch-triage |
4mArgs:null Results: {
"EnableConfigs": [
"INET",
"IPV6",
"NET_IPGRE",
"NET_IPIP",
"VXLAN",
"LWTUNNEL_BPF",
"BPF_SYSCALL"
],
"FocusSymbols": [
"iptunnel_handle_offloads",
"__iptunnel_pull_header",
"gre_gso_segment",
"skb_udp_tunnel_segment",
"bpf_skb_net_grow",
"bpf_skb_net_shrink",
"bpf_lwt_push_ip_encap",
"ipv6_srh_rcv",
"ipv6_rpl_srh_rcv"
],
"KMSANReasoning": "The patch series introduces helper functions (skb_gso_fixedid_encap, skb_gso_fixedid_decap) to properly update GSO flags (SKB_GSO_TCP_FIXEDID and SKB_GSO_TCP_FIXEDID_INNER) when packets are encapsulated or decapsulated across tunnel offloads, BPF packet adjustments, and SRv6 processing. It also preserves SKB_GSO_CB(skb)-\u003eencap_level across GRE/UDP tunnel segmentation so inner GSO segmentation recognizes encapsulation.\n\nNone of these changes allocate uninitialized buffers, introduce uninitialized fields, or expose uninitialized kernel memory to user space. All manipulated fields (skb-\u003eencapsulation, shinfo-\u003egso_type, SKB_GSO_CB(skb)-\u003eencap_level) are existing, fully initialized members of sk_buff/skb_shared_info/skb_gso_cb. Furthermore, no new data is copied to user space or exposed via network packet payloads. Any potential regression would be related to protocol logic or skb lifetime/bounds, which are covered by standard testing and KASAN. Therefore, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false,
"Reasoning": "The patch modifies core networking GSO offload handling across tunnel encapsulation and decapsulation paths, as well as BPF room adjustment helpers (bpf_skb_net_grow, bpf_skb_net_shrink) and IPv6 Segment Routing (SRH/RPL SRH). Specifically, it manages shifting of SKB_GSO_TCP_FIXEDID and SKB_GSO_TCP_FIXEDID_INNER flags on encap/decap and removes encap_level resets in GRE and UDP tunnel segmentation. These changes alter packet transformations, unclone logic, and segmentation invariant handling across reachable virtual networking devices (veth, tunnels, VXLAN) and BPF programs, making it valuable to fuzz for crashes, memory corruption, or incorrect packet handling.",
"WorthFuzzing": true
} |
| 1/1 | 2026/11/01 22:46 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 6eb51eb6a4f2ce92cd7840a9e1ae1209dfff657f\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Sun Nov 1 22:46:47 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/include/linux/skbuff.h b/include/linux/skbuff.h\nindex 6787fcf6ac3e43..00df57cbc05c27 100644\n--- a/include/linux/skbuff.h\n+++ b/include/linux/skbuff.h\n@@ -5337,6 +5337,36 @@ static inline void skb_decrease_gso_size(struct skb_shared_info *shinfo,\n \tshinfo-\u003egso_size -= decrement;\n }\n \n+/**\n+ * skb_gso_fixedid_encap - move the TCP fixed-ID flag to the inner header\n+ * @shinfo: shared info of a GSO packet that becomes encapsulated\n+ *\n+ * The IPv4 header that SKB_GSO_TCP_FIXEDID describes becomes the inner one,\n+ * and the new outer header gets an incrementing ID.\n+ */\n+static inline void skb_gso_fixedid_encap(struct skb_shared_info *shinfo)\n+{\n+\tunsigned int fixedid = shinfo-\u003egso_type \u0026 SKB_GSO_TCP_FIXEDID;\n+\n+\tshinfo-\u003egso_type \u0026= ~(SKB_GSO_TCP_FIXEDID | SKB_GSO_TCP_FIXEDID_INNER);\n+\tshinfo-\u003egso_type |= fixedid \u003c\u003c 1;\n+}\n+\n+/**\n+ * skb_gso_fixedid_decap - move the TCP fixed-ID flag to the new outer header\n+ * @shinfo: shared info of an encapsulated GSO packet losing its outer header\n+ *\n+ * The inner IPv4 header, which SKB_GSO_TCP_FIXEDID_INNER describes, becomes\n+ * the outer one, and the state of the removed outer header is dropped.\n+ */\n+static inline void skb_gso_fixedid_decap(struct skb_shared_info *shinfo)\n+{\n+\tunsigned int fixedid = shinfo-\u003egso_type \u0026 SKB_GSO_TCP_FIXEDID_INNER;\n+\n+\tshinfo-\u003egso_type \u0026= ~(SKB_GSO_TCP_FIXEDID | SKB_GSO_TCP_FIXEDID_INNER);\n+\tshinfo-\u003egso_type |= fixedid \u003e\u003e 1;\n+}\n+\n void __skb_warn_lro_forwarding(const struct sk_buff *skb);\n \n static __always_inline bool skb_warn_if_lro(const struct sk_buff *skb)\ndiff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h\nindex 5cccf4c0e6913a..c2ffda6029a062 100644\n--- a/include/net/ip_tunnels.h\n+++ b/include/net/ip_tunnels.h\n@@ -665,6 +665,8 @@ static inline int iptunnel_pull_offloads(struct sk_buff *skb)\n \t\terr = skb_unclone(skb, GFP_ATOMIC);\n \t\tif (unlikely(err))\n \t\t\treturn err;\n+\t\tif (skb-\u003eencapsulation)\n+\t\t\tskb_gso_fixedid_decap(skb_shinfo(skb));\n \t\tskb_shinfo(skb)-\u003egso_type \u0026= ~(NETIF_F_GSO_ENCAP_ALL \u003e\u003e\n \t\t\t\t\t NETIF_F_GSO_SHIFT);\n \t}\ndiff --git a/net/core/filter.c b/net/core/filter.c\nindex 09c60a58c82abe..4f87a827b25be4 100644\n--- a/net/core/filter.c\n+++ b/net/core/filter.c\n@@ -3718,6 +3718,9 @@ static int bpf_skb_net_grow(struct sk_buff *skb, u32 off, u32 len_diff,\n \tif (skb_is_gso(skb)) {\n \t\tstruct skb_shared_info *shinfo = skb_shinfo(skb);\n \n+\t\tif (encap)\n+\t\t\tskb_gso_fixedid_encap(shinfo);\n+\n \t\t/* Header must be checked, and gso_segs recomputed. */\n \t\tshinfo-\u003egso_type |= gso_type;\n \t\tshinfo-\u003egso_segs = 0;\n@@ -3809,9 +3812,11 @@ static int bpf_skb_net_shrink(struct sk_buff *skb, u32 off, u32 len_diff,\n \t\t\t\t\t\t SKB_GSO_GRE_CSUM |\n \t\t\t\t\t\t SKB_GSO_IPXIP4 |\n \t\t\t\t\t\t SKB_GSO_IPXIP6 |\n-\t\t\t\t\t\t SKB_GSO_ESP)))\n-\t\t\t\tif (skb-\u003eencapsulation)\n-\t\t\t\t\tskb-\u003eencapsulation = 0;\n+\t\t\t\t\t\t SKB_GSO_ESP)) \u0026\u0026\n+\t\t\t skb-\u003eencapsulation) {\n+\t\t\t\tskb_gso_fixedid_decap(shinfo);\n+\t\t\t\tskb-\u003eencapsulation = 0;\n+\t\t\t}\n \t\t}\n \n \t\t/* Header must be checked, and gso_segs recomputed. */\ndiff --git a/net/core/lwt_bpf.c b/net/core/lwt_bpf.c\nindex da49364ec63de7..4d9faf2cc5de59 100644\n--- a/net/core/lwt_bpf.c\n+++ b/net/core/lwt_bpf.c\n@@ -539,6 +539,7 @@ static int handle_gso_type(struct sk_buff *skb, unsigned int gso_type,\n {\n \tstruct skb_shared_info *shinfo = skb_shinfo(skb);\n \n+\tskb_gso_fixedid_encap(shinfo);\n \tgso_type |= SKB_GSO_DODGY;\n \tshinfo-\u003egso_type |= gso_type;\n \tskb_decrease_gso_size(shinfo, encap_len);\ndiff --git a/net/ipv4/gre_offload.c b/net/ipv4/gre_offload.c\nindex c8129782d39de4..a8f9a0a0b06bdf 100644\n--- a/net/ipv4/gre_offload.c\n+++ b/net/ipv4/gre_offload.c\n@@ -35,7 +35,6 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,\n \n \t/* setup inner skb. */\n \tskb-\u003eencapsulation = 0;\n-\tSKB_GSO_CB(skb)-\u003eencap_level = 0;\n \t__skb_pull(skb, tnl_hlen);\n \tskb_reset_mac_header(skb);\n \tskb_set_network_header(skb, skb_inner_network_offset(skb));\ndiff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c\nindex 6c2855adff2899..59050229e34996 100644\n--- a/net/ipv4/ip_tunnel_core.c\n+++ b/net/ipv4/ip_tunnel_core.c\n@@ -182,9 +182,10 @@ EXPORT_SYMBOL_GPL(iptunnel_metadata_reply);\n int iptunnel_handle_offloads(struct sk_buff *skb,\n \t\t\t int gso_type_mask)\n {\n+\tbool encap = !skb-\u003eencapsulation;\n \tint err;\n \n-\tif (likely(!skb-\u003eencapsulation)) {\n+\tif (likely(encap)) {\n \t\tskb_reset_inner_headers(skb);\n \t\tskb-\u003eencapsulation = 1;\n \t}\n@@ -193,6 +194,8 @@ int iptunnel_handle_offloads(struct sk_buff *skb,\n \t\terr = skb_header_unclone(skb, GFP_ATOMIC);\n \t\tif (unlikely(err))\n \t\t\treturn err;\n+\t\tif (encap)\n+\t\t\tskb_gso_fixedid_encap(skb_shinfo(skb));\n \t\tskb_shinfo(skb)-\u003egso_type |= gso_type_mask;\n \t\treturn 0;\n \t}\ndiff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c\nindex cf07c3c6611a22..edcabe1115a60c 100644\n--- a/net/ipv4/udp_offload.c\n+++ b/net/ipv4/udp_offload.c\n@@ -205,7 +205,6 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,\n \n \t/* setup inner skb. */\n \tskb-\u003eencapsulation = 0;\n-\tSKB_GSO_CB(skb)-\u003eencap_level = 0;\n \t__skb_pull(skb, tnl_hlen);\n \tskb_reset_mac_header(skb);\n \tskb_set_network_header(skb, skb_inner_network_offset(skb));\ndiff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c\nindex 96c8402a27a549..126058772bc5ae 100644\n--- a/net/ipv6/exthdrs.c\n+++ b/net/ipv6/exthdrs.c\n@@ -53,6 +53,7 @@\n #include \u003clinux/ioam6_genl.h\u003e\n #include \u003cnet/ioam6.h\u003e\n #include \u003cnet/dst_metadata.h\u003e\n+#include \u003cnet/ip_tunnels.h\u003e\n \n #include \u003clinux/uaccess.h\u003e\n \n@@ -406,7 +407,10 @@ static int ipv6_srh_rcv(struct sk_buff *skb, struct inet6_dev *idev)\n \n \t\t\tskb_reset_network_header(skb);\n \t\t\tskb_reset_transport_header(skb);\n-\t\t\tskb-\u003eencapsulation = 0;\n+\t\t\tif (iptunnel_pull_offloads(skb)) {\n+\t\t\t\tkfree_skb(skb);\n+\t\t\t\treturn -1;\n+\t\t\t}\n \t\t\tif (hdr-\u003enexthdr == NEXTHDR_IPV4)\n \t\t\t\tskb-\u003eprotocol = htons(ETH_P_IP);\n \t\t\t__skb_tunnel_rx(skb, skb-\u003edev, net);\n@@ -513,7 +517,10 @@ static int ipv6_rpl_srh_rcv(struct sk_buff *skb, struct inet6_dev *idev)\n \n \t\t\tskb_reset_network_header(skb);\n \t\t\tskb_reset_transport_header(skb);\n-\t\t\tskb-\u003eencapsulation = 0;\n+\t\t\tif (iptunnel_pull_offloads(skb)) {\n+\t\t\t\tkfree_skb(skb);\n+\t\t\t\treturn -1;\n+\t\t\t}\n \n \t\t\t__skb_tunnel_rx(skb, skb-\u003edev, net);\n \ndiff --git a/tools/testing/selftests/net/.gitignore b/tools/testing/selftests/net/.gitignore\nindex 21412510ac26b8..96263d5978258f 100644\n--- a/tools/testing/selftests/net/.gitignore\n+++ b/tools/testing/selftests/net/.gitignore\n@@ -46,6 +46,7 @@ so_rcv_listener\n stress_reuseport_listen\n tap\n tcp_fastopen_backup_key\n+tcp_fixedid\n tcp_inq\n tcp_mmap\n tcp_port_share\ndiff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile\nindex 9180b9bec5155e..dd402814bc7483 100644\n--- a/tools/testing/selftests/net/Makefile\n+++ b/tools/testing/selftests/net/Makefile\n@@ -106,6 +106,7 @@ TEST_PROGS := \\\n \tsrv6_iptunnel_cache.sh \\\n \tstress_reuseport_listen.sh \\\n \ttcp_ecmp_failover.sh \\\n+\ttcp_fixedid.sh \\\n \ttcp_fastopen_backup_key.sh \\\n \ttest_bridge_backup_port.sh \\\n \ttest_bridge_neigh_suppress.sh \\\n@@ -169,6 +170,7 @@ TEST_GEN_FILES := \\\n \tsocket \\\n \tstress_reuseport_listen \\\n \ttcp_fastopen_backup_key \\\n+\ttcp_fixedid \\\n \ttcp_inq \\\n \ttcp_mmap \\\n \ttfo \\\ndiff --git a/tools/testing/selftests/net/tcp_fixedid.c b/tools/testing/selftests/net/tcp_fixedid.c\nnew file mode 100644\nindex 00000000000000..d507d12b46308f\n--- /dev/null\n+++ b/tools/testing/selftests/net/tcp_fixedid.c\n@@ -0,0 +1,396 @@\n+// SPDX-License-Identifier: GPL-2.0\n+/*\n+ * Send TCP segments with fixed or incrementing IPv4 IDs, optionally in\n+ * VXLAN, and report the IP IDs of TCP segments received on a device.\n+ *\n+ * tx: tcp_fixedid -T -i dev -M dmac -s saddr -d daddr [-f] [-n segs]\n+ * [-b bursts] [-l len] [-V osaddr,odaddr -m inner_dmac [-F]]\n+ * rx: tcp_fixedid -R -i dev [-c segs] [-w ms]\n+ *\n+ * The receiver prints \"ready\" once it is bound, then the number of\n+ * segments, of segments with an outer IPv4 header, and of distinct outer\n+ * and inner IDs.\n+ */\n+\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 \u003cnet/ethernet.h\u003e\n+#include \u003cnet/if.h\u003e\n+#include \u003cnetinet/ip.h\u003e\n+#include \u003cnetinet/ip6.h\u003e\n+#include \u003cnetinet/tcp.h\u003e\n+#include \u003cnetinet/udp.h\u003e\n+#include \u003cpoll.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+#define TEST_PORT\t9000\n+#define VXLAN_PORT\t4789\n+#define FIXED_ID\t0x1234\n+\n+static const char *ifname;\n+static bool fixed_id, fixed_outer;\n+static int segs = 40, bursts = 10, len = 1000, wait_ms = 2000, stop;\n+static struct in_addr saddr, daddr, osaddr, odaddr;\n+static bool vxlan;\n+static unsigned char dmac[ETH_ALEN], inner_dmac[ETH_ALEN];\n+\n+static void parse_mac(const char *s, unsigned char *mac)\n+{\n+\tif (sscanf(s, \"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx\", \u0026mac[0], \u0026mac[1],\n+\t\t \u0026mac[2], \u0026mac[3], \u0026mac[4], \u0026mac[5]) != 6)\n+\t\terror(1, 0, \"bad mac %s\", s);\n+}\n+\n+static void parse_addr(const char *s, struct in_addr *a)\n+{\n+\tif (inet_pton(AF_INET, s, a) != 1)\n+\t\terror(1, 0, \"bad address %s\", s);\n+}\n+\n+static uint32_t csum_add(uint32_t sum, const void *data, size_t n)\n+{\n+\tconst uint8_t *p = data;\n+\n+\twhile (n \u003e 1) {\n+\t\tsum += (p[0] \u003c\u003c 8) | p[1];\n+\t\tp += 2;\n+\t\tn -= 2;\n+\t}\n+\tif (n)\n+\t\tsum += p[0] \u003c\u003c 8;\n+\treturn sum;\n+}\n+\n+static uint16_t csum_fold(uint32_t sum)\n+{\n+\twhile (sum \u003e\u003e 16)\n+\t\tsum = (sum \u0026 0xffff) + (sum \u003e\u003e 16);\n+\treturn htons(~sum \u0026 0xffff);\n+}\n+\n+static void build_ip(struct iphdr *iph, int proto, int payload, uint16_t id,\n+\t\t struct in_addr s, struct in_addr d)\n+{\n+\tmemset(iph, 0, sizeof(*iph));\n+\tiph-\u003eversion = 4;\n+\tiph-\u003eihl = 5;\n+\tiph-\u003etot_len = htons(sizeof(*iph) + payload);\n+\tiph-\u003eid = htons(id);\n+\tiph-\u003efrag_off = htons(IP_DF);\n+\tiph-\u003ettl = 64;\n+\tiph-\u003eprotocol = proto;\n+\tiph-\u003esaddr = s.s_addr;\n+\tiph-\u003edaddr = d.s_addr;\n+\tiph-\u003echeck = csum_fold(csum_add(0, iph, sizeof(*iph)));\n+}\n+\n+/* Ethernet, IPv4 and TCP header plus payload for segment @i at @p */\n+static int build_tcp(unsigned char *p, const unsigned char *mac, int i,\n+\t\t uint16_t id)\n+{\n+\tstruct ethhdr *eth = (struct ethhdr *)p;\n+\tstruct iphdr *iph = (struct iphdr *)(eth + 1);\n+\tstruct tcphdr *th = (struct tcphdr *)(iph + 1);\n+\tstruct {\n+\t\tuint32_t s, d;\n+\t\tuint8_t zero, proto;\n+\t\tuint16_t len;\n+\t} ph;\t/* 12 bytes, no padding */\n+\tuint32_t sum;\n+\n+\tmemcpy(eth-\u003eh_dest, mac, ETH_ALEN);\n+\tmemset(eth-\u003eh_source, 0, ETH_ALEN);\n+\teth-\u003eh_source[0] = 0x02;\n+\teth-\u003eh_source[5] = 0x01;\n+\teth-\u003eh_proto = htons(ETH_P_IP);\n+\tbuild_ip(iph, IPPROTO_TCP, sizeof(*th) + len, id, saddr, daddr);\n+\n+\tmemset(th, 0, sizeof(*th));\n+\tth-\u003esource = htons(TEST_PORT + 1);\n+\tth-\u003edest = htons(TEST_PORT);\n+\tth-\u003eseq = htonl(1 + i * len);\n+\tth-\u003eack_seq = htonl(1);\n+\tth-\u003edoff = 5;\n+\tth-\u003eack = 1;\n+\tth-\u003ewindow = htons(65535);\n+\tmemset(th + 1, 'a' + i % 26, len);\n+\n+\tph.s = iph-\u003esaddr;\n+\tph.d = iph-\u003edaddr;\n+\tph.zero = 0;\n+\tph.proto = IPPROTO_TCP;\n+\tph.len = htons(sizeof(*th) + len);\n+\tsum = csum_add(0, \u0026ph, sizeof(ph));\n+\tth-\u003echeck = csum_fold(csum_add(sum, th, sizeof(*th) + len));\n+\n+\treturn sizeof(*eth) + sizeof(*iph) + sizeof(*th) + len;\n+}\n+\n+static int do_tx(int fd, struct sockaddr_ll *sll)\n+{\n+\tunsigned char buf[ETH_FRAME_LEN + 128];\n+\tint b, s, i = 0, n;\n+\n+\tfor (b = 0; b \u003c bursts; b++) {\n+\t\tfor (s = 0; s \u003c segs; s++, i++) {\n+\t\t\tuint16_t id = fixed_id ? FIXED_ID : 0x1000 + i;\n+\t\t\tunsigned char *p = buf;\n+\n+\t\t\tif (vxlan) {\n+\t\t\t\tstruct ethhdr *eth = (struct ethhdr *)p;\n+\t\t\t\tstruct iphdr *iph = (struct iphdr *)(eth + 1);\n+\t\t\t\tstruct udphdr *uh = (struct udphdr *)(iph + 1);\n+\t\t\t\tuint32_t *vx = (uint32_t *)(uh + 1);\n+\t\t\t\tint inner;\n+\n+\t\t\t\tinner = build_tcp((unsigned char *)(vx + 2),\n+\t\t\t\t\t\t inner_dmac, i, id);\n+\t\t\t\tmemcpy(eth-\u003eh_dest, dmac, ETH_ALEN);\n+\t\t\t\tmemset(eth-\u003eh_source, 0, ETH_ALEN);\n+\t\t\t\teth-\u003eh_source[0] = 0x02;\n+\t\t\t\teth-\u003eh_source[5] = 0x01;\n+\t\t\t\teth-\u003eh_proto = htons(ETH_P_IP);\n+\t\t\t\tmemset(uh, 0, sizeof(*uh));\n+\t\t\t\tuh-\u003esource = htons(VXLAN_PORT + 1);\n+\t\t\t\tuh-\u003edest = htons(VXLAN_PORT);\n+\t\t\t\tuh-\u003elen = htons(sizeof(*uh) + 8 + inner);\n+\t\t\t\tvx[0] = htonl(0x08000000);\n+\t\t\t\tvx[1] = htonl(42 \u003c\u003c 8);\n+\t\t\t\tbuild_ip(iph, IPPROTO_UDP,\n+\t\t\t\t\t sizeof(*uh) + 8 + inner,\n+\t\t\t\t\t fixed_outer ? FIXED_ID : 0x2000 + i,\n+\t\t\t\t\t osaddr, odaddr);\n+\t\t\t\tn = sizeof(*eth) + sizeof(*iph) + sizeof(*uh) +\n+\t\t\t\t 8 + inner;\n+\t\t\t} else {\n+\t\t\t\tn = build_tcp(p, dmac, i, id);\n+\t\t\t}\n+\n+\t\t\tif (sendto(fd, buf, n, 0, (struct sockaddr *)sll,\n+\t\t\t\t sizeof(*sll)) != n)\n+\t\t\t\terror(1, errno, \"sendto\");\n+\t\t}\n+\t\tusleep(50000);\n+\t}\n+\treturn 0;\n+}\n+\n+/* Return the inner IPv4 header of a TCP segment to TEST_PORT, or NULL */\n+static const struct iphdr *find_inner(const unsigned char *p, int n,\n+\t\t\t\t const struct iphdr **outer4)\n+{\n+\tconst struct ethhdr *eth = (const struct ethhdr *)p;\n+\tconst unsigned char *end = p + n;\n+\tconst unsigned char *l4;\n+\tint proto, depth;\n+\n+\t*outer4 = NULL;\n+\tif (n \u003c (int)sizeof(*eth))\n+\t\treturn NULL;\n+\tp += sizeof(*eth);\n+\n+\tfor (depth = 0; depth \u003c 2; depth++) {\n+\t\tuint16_t etype = depth ? htons(ETH_P_IP) : eth-\u003eh_proto;\n+\n+\t\tif (etype == htons(ETH_P_IP)) {\n+\t\t\tconst struct iphdr *iph = (const struct iphdr *)p;\n+\n+\t\t\tif (p + sizeof(*iph) \u003e end)\n+\t\t\t\treturn NULL;\n+\t\t\tproto = iph-\u003eprotocol;\n+\t\t\tl4 = p + iph-\u003eihl * 4;\n+\t\t\tif (proto == IPPROTO_TCP) {\n+\t\t\t\tconst struct tcphdr *th;\n+\n+\t\t\t\tth = (const struct tcphdr *)l4;\n+\t\t\t\tif (l4 + sizeof(*th) \u003e end ||\n+\t\t\t\t th-\u003edest != htons(TEST_PORT))\n+\t\t\t\t\treturn NULL;\n+\t\t\t\treturn iph;\n+\t\t\t}\n+\t\t\tif (depth)\n+\t\t\t\treturn NULL;\n+\t\t\t*outer4 = iph;\n+\t\t} else if (etype == htons(ETH_P_IPV6)) {\n+\t\t\tconst struct ip6_hdr *ip6h = (const struct ip6_hdr *)p;\n+\n+\t\t\tif (p + sizeof(*ip6h) \u003e end)\n+\t\t\t\treturn NULL;\n+\t\t\tproto = ip6h-\u003eip6_nxt;\n+\t\t\tl4 = p + sizeof(*ip6h);\n+\t\t} else {\n+\t\t\treturn NULL;\n+\t\t}\n+\n+\t\t/* step over the tunnel header to the inner IPv4 header */\n+\t\tif (proto == IPPROTO_IPIP) {\n+\t\t\tp = l4;\n+\t\t} else if (proto == IPPROTO_GRE) {\n+\t\t\tuint16_t flags;\n+\n+\t\t\tif (l4 + 4 \u003e end)\n+\t\t\t\treturn NULL;\n+\t\t\tflags = (l4[0] \u003c\u003c 8) | l4[1];\n+\t\t\tif (((l4[2] \u003c\u003c 8) | l4[3]) != ETH_P_IP)\n+\t\t\t\treturn NULL;\n+\t\t\tp = l4 + 4 + 4 * (!!(flags \u0026 0x8000) +\n+\t\t\t\t\t !!(flags \u0026 0x2000) +\n+\t\t\t\t\t !!(flags \u0026 0x1000));\n+\t\t} else if (proto == IPPROTO_UDP) {\n+\t\t\tconst struct udphdr *uh = (const struct udphdr *)l4;\n+\n+\t\t\tif (l4 + sizeof(*uh) + 8 + sizeof(*eth) \u003e end ||\n+\t\t\t uh-\u003edest != htons(VXLAN_PORT))\n+\t\t\t\treturn NULL;\n+\t\t\tp = l4 + sizeof(*uh) + 8 + sizeof(*eth);\n+\t\t} else {\n+\t\t\treturn NULL;\n+\t\t}\n+\t}\n+\treturn NULL;\n+}\n+\n+static void count_id(uint8_t *map, unsigned int *distinct, uint16_t id)\n+{\n+\tif (!(map[id / 8] \u0026 (1 \u003c\u003c (id % 8)))) {\n+\t\tmap[id / 8] |= 1 \u003c\u003c (id % 8);\n+\t\t(*distinct)++;\n+\t}\n+}\n+\n+static int do_rx(int fd)\n+{\n+\tstatic uint8_t outer_map[8192], inner_map[8192];\n+\tunsigned int frames = 0, outer4 = 0, outer_ids = 0, inner_ids = 0;\n+\tunsigned char buf[65536];\n+\tstruct pollfd pfd = { .fd = fd, .events = POLLIN };\n+\n+\tprintf(\"ready\\n\");\n+\tfflush(stdout);\n+\n+\t/* wait longer for the first segment than between segments */\n+\twhile (poll(\u0026pfd, 1, frames ? wait_ms : 10 * wait_ms) \u003e 0) {\n+\t\tconst struct iphdr *iph, *oiph;\n+\t\tstruct sockaddr_ll from;\n+\t\tsocklen_t fl = sizeof(from);\n+\t\tint n;\n+\n+\t\tn = recvfrom(fd, buf, sizeof(buf), 0, (struct sockaddr *)\u0026from,\n+\t\t\t \u0026fl);\n+\t\tif (n \u003c 0)\n+\t\t\terror(1, errno, \"recvfrom\");\n+\t\tif (from.sll_pkttype == PACKET_OUTGOING)\n+\t\t\tcontinue;\n+\t\tiph = find_inner(buf, n, \u0026oiph);\n+\t\tif (!iph)\n+\t\t\tcontinue;\n+\t\tframes++;\n+\t\tcount_id(inner_map, \u0026inner_ids, ntohs(iph-\u003eid));\n+\t\tif (oiph) {\n+\t\t\touter4++;\n+\t\t\tcount_id(outer_map, \u0026outer_ids, ntohs(oiph-\u003eid));\n+\t\t}\n+\t\tif (stop \u0026\u0026 frames == (unsigned int)stop)\n+\t\t\tbreak;\n+\t}\n+\n+\tprintf(\"frames %u outer4 %u outer_ids %u inner_ids %u\\n\", frames,\n+\t outer4, outer_ids, inner_ids);\n+\treturn 0;\n+}\n+\n+int main(int argc, char **argv)\n+{\n+\tstruct sockaddr_ll sll = {};\n+\tbool tx = false, rx = false;\n+\tchar *comma;\n+\tint c, fd;\n+\n+\twhile ((c = getopt(argc, argv, \"TRi:M:s:d:fn:b:l:V:m:Fw:c:\")) != -1) {\n+\t\tswitch (c) {\n+\t\tcase 'T':\n+\t\t\ttx = true;\n+\t\t\tbreak;\n+\t\tcase 'R':\n+\t\t\trx = true;\n+\t\t\tbreak;\n+\t\tcase 'i':\n+\t\t\tifname = optarg;\n+\t\t\tbreak;\n+\t\tcase 'M':\n+\t\t\tparse_mac(optarg, dmac);\n+\t\t\tbreak;\n+\t\tcase 's':\n+\t\t\tparse_addr(optarg, \u0026saddr);\n+\t\t\tbreak;\n+\t\tcase 'd':\n+\t\t\tparse_addr(optarg, \u0026daddr);\n+\t\t\tbreak;\n+\t\tcase 'f':\n+\t\t\tfixed_id = true;\n+\t\t\tbreak;\n+\t\tcase 'n':\n+\t\t\tsegs = atoi(optarg);\n+\t\t\tbreak;\n+\t\tcase 'b':\n+\t\t\tbursts = atoi(optarg);\n+\t\t\tbreak;\n+\t\tcase 'l':\n+\t\t\tlen = atoi(optarg);\n+\t\t\tbreak;\n+\t\tcase 'V':\n+\t\t\tcomma = strchr(optarg, ',');\n+\t\t\tif (!comma)\n+\t\t\t\terror(1, 0, \"-V needs outer saddr,daddr\");\n+\t\t\t*comma = '\\0';\n+\t\t\tparse_addr(optarg, \u0026osaddr);\n+\t\t\tparse_addr(comma + 1, \u0026odaddr);\n+\t\t\tvxlan = true;\n+\t\t\tbreak;\n+\t\tcase 'm':\n+\t\t\tparse_mac(optarg, inner_dmac);\n+\t\t\tbreak;\n+\t\tcase 'F':\n+\t\t\tfixed_outer = true;\n+\t\t\tbreak;\n+\t\tcase 'w':\n+\t\t\twait_ms = atoi(optarg);\n+\t\t\tbreak;\n+\t\tcase 'c':\n+\t\t\tstop = atoi(optarg);\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\terror(1, 0, \"bad option\");\n+\t\t}\n+\t}\n+\tif (tx == rx || !ifname || len \u003c 1 || len \u003e 1400 || segs \u003c 1 ||\n+\t bursts \u003c 1)\n+\t\terror(1, 0, \"usage: see the comment at the top of %s\",\n+\t\t __FILE__);\n+\n+\tfd = socket(AF_PACKET, SOCK_RAW, htons(tx ? 0 : ETH_P_ALL));\n+\tif (fd \u003c 0)\n+\t\terror(1, errno, \"socket\");\n+\tsll.sll_family = AF_PACKET;\n+\tsll.sll_protocol = htons(ETH_P_ALL);\n+\tsll.sll_ifindex = if_nametoindex(ifname);\n+\tif (!sll.sll_ifindex)\n+\t\terror(1, errno, \"%s\", ifname);\n+\tif (bind(fd, (struct sockaddr *)\u0026sll, sizeof(sll)))\n+\t\terror(1, errno, \"bind\");\n+\tsll.sll_halen = ETH_ALEN;\n+\tmemcpy(sll.sll_addr, dmac, ETH_ALEN);\n+\n+\tc = tx ? do_tx(fd, \u0026sll) : do_rx(fd);\n+\tclose(fd);\n+\treturn c;\n+}\ndiff --git a/tools/testing/selftests/net/tcp_fixedid.sh b/tools/testing/selftests/net/tcp_fixedid.sh\nnew file mode 100755\nindex 00000000000000..88f92981740771\n--- /dev/null\n+++ b/tools/testing/selftests/net/tcp_fixedid.sh\n@@ -0,0 +1,291 @@\n+#!/bin/bash\n+# SPDX-License-Identifier: GPL-2.0\n+#\n+# Check the IPv4 IDs of a TCP stream that GRO merged and software\n+# segmentation split again across a tunnel. A sender in NSRC writes\n+# segments with fixed or incrementing IDs onto a veth with GRO on in\n+# NRTR, which forwards the merged packets:\n+#\n+# encap: into an IPIP, GRE or VXLAN tunnel over IPv4 or IPv6,\n+# segmented on the underlay towards NMID\n+# decap: out of VXLAN, received from NSRC with one header fixed and\n+# the other incrementing, into an IPIP tunnel towards NMID\n+# encap+decap: into a tunnel that NMID ends without segmenting, and on\n+# to NDST, segmented there\n+#\n+# The inner IDs must come out as they went in, and the IDs of a new outer\n+# IPv4 header must be unique. Packets that GRO did not merge are not\n+# tested, so a run where nothing was merged is skipped.\n+\n+source lib.sh\n+\n+NSRC=\"\"\n+NRTR=\"\"\n+NMID=\"\"\n+NDST=\"\"\n+\n+SEGS=40\n+BURSTS=10\n+TOTAL=$((SEGS * BURSTS))\n+INNER_SRC=10.1.0.1\n+INNER_DST=10.9.0.2\n+VX_MAC=02:00:00:00:00:42\n+TUN_MAC=02:00:00:00:00:99\n+MID_MAC=02:00:00:00:00:98\n+TX=./tcp_fixedid\n+\n+NOSEG=\"tso gso tx-gre-segmentation tx-gre-csum-segmentation\n+ tx-ipxip4-segmentation tx-ipxip6-segmentation\n+ tx-udp_tnl-segmentation tx-udp_tnl-csum-segmentation\"\n+\n+cleanup() {\n+\tcleanup_all_ns\n+}\n+\n+trap cleanup EXIT\n+\n+# NSRC s0 - r0 NRTR r1 - m1 NMID m2 - d2 NDST\n+setup() {\n+\tsetup_ns NSRC NRTR NMID NDST || return \"$ksft_skip\"\n+\n+\tip link add s0 netns \"$NSRC\" type veth peer name r0 netns \"$NRTR\"\n+\tip link add r1 netns \"$NRTR\" type veth peer name m1 netns \"$NMID\"\n+\tip link add m2 netns \"$NMID\" type veth peer name d2 netns \"$NDST\"\n+\n+\tip -n \"$NRTR\" addr add 10.1.0.2/24 dev r0\n+\tip -n \"$NRTR\" addr add 10.2.0.1/24 dev r1\n+\tip -n \"$NRTR\" addr add fd02::1/64 dev r1 nodad\n+\tip -n \"$NMID\" addr add 10.2.0.2/24 dev m1\n+\tip -n \"$NMID\" addr add fd02::2/64 dev m1 nodad\n+\tip -n \"$NMID\" addr add 10.4.0.1/24 dev m2\n+\tip -n \"$NDST\" addr add 10.4.0.2/24 dev d2\n+\tip -n \"$NSRC\" link set s0 up\n+\tip -n \"$NRTR\" link set r0 up\n+\tip -n \"$NRTR\" link set r1 up\n+\tip -n \"$NMID\" link set m1 up\n+\tip -n \"$NMID\" link set m2 up\n+\tip -n \"$NDST\" link set d2 up\n+\n+\tip netns exec \"$NRTR\" sysctl -qw net.ipv4.ip_forward=1\n+\tip netns exec \"$NMID\" sysctl -qw net.ipv4.ip_forward=1\n+\tfor ns in \"$NRTR\" \"$NMID\"; do\n+\t\tip netns exec \"$ns\" sysctl -qw net.ipv4.conf.all.rp_filter=0 \\\n+\t\t\tnet.ipv4.conf.default.rp_filter=0\n+\tdone\n+\n+\t# veth passes packets to GRO only if the sender does not do TSO\n+\tip netns exec \"$NRTR\" ethtool -K r0 gro on \u003e/dev/null ||\n+\t\treturn \"$ksft_skip\"\n+\tip netns exec \"$NSRC\" ethtool -K s0 tso off \u003e/dev/null ||\n+\t\treturn \"$ksft_skip\"\n+\t# release the sender's segments in bursts for GRO to merge\n+\ttc -n \"$NSRC\" qdisc add dev s0 root netem slot 20ms 20ms \\\n+\t\tpackets \"$SEGS\" || return \"$ksft_skip\"\n+}\n+\n+# tunnel \u003cns\u003e \u003cname\u003e \u003ctype\u003e \u003cfamily\u003e \u003clocal\u003e \u003cremote\u003e\n+tunnel() {\n+\tlocal ns=$1 name=$2 type=$3 family=$4 local=$5 remote=$6\n+\n+\tcase \"$type\" in\n+\tipip)\n+\t\tif [ \"$family\" = 4 ]; then\n+\t\t\tip -n \"$ns\" link add \"$name\" type ipip \\\n+\t\t\t\tlocal \"$local\" remote \"$remote\"\n+\t\telse\n+\t\t\tip -n \"$ns\" link add \"$name\" type ip6tnl mode ipip6 \\\n+\t\t\t\tlocal \"$local\" remote \"$remote\" encaplimit none\n+\t\tfi ;;\n+\tgre)\n+\t\tif [ \"$family\" = 4 ]; then\n+\t\t\tip -n \"$ns\" link add \"$name\" type gre \\\n+\t\t\t\tlocal \"$local\" remote \"$remote\"\n+\t\telse\n+\t\t\tip -n \"$ns\" link add \"$name\" type ip6gre \\\n+\t\t\t\tlocal \"$local\" remote \"$remote\" encaplimit none\n+\t\tfi ;;\n+\tvxlan)\n+\t\tip -n \"$ns\" link add \"$name\" address \"$TUN_MAC\" type vxlan \\\n+\t\t\tid 7 dstport 4789 local \"$local\" remote \"$remote\" \\\n+\t\t\tnolearning ;;\n+\tesac || return 1\n+\tip -n \"$ns\" link set \"$name\" up\n+}\n+\n+# route_into \u003cns\u003e \u003cdev\u003e: send INNER_DST into \u003cdev\u003e\n+route_into() {\n+\tip -n \"$1\" route add \"$INNER_DST/32\" dev \"$2\"\n+\tip -n \"$1\" neigh add \"$INNER_DST\" lladdr \"$TUN_MAC\" dev \"$2\" \\\n+\t\t2\u003e/dev/null\n+\treturn 0\n+}\n+\n+# noseg \u003cns\u003e \u003cdev\u003e: segment everything in software before \u003cdev\u003e\n+noseg() {\n+\tlocal f\n+\n+\tfor f in $NOSEG; do\n+\t\tip netns exec \"$1\" ethtool -K \"$2\" \"$f\" off \u003e/dev/null 2\u003e\u00261\n+\tdone\n+}\n+\n+tx_packets() {\n+\tip netns exec \"$1\" cat \"/sys/class/net/$2/statistics/tx_packets\"\n+}\n+\n+# check \u003cname\u003e \u003cresult\u003e \u003cwant: fixed|incr\u003e \u003couter: 0|1\u003e \u003cmerged-into-dev\u003e\n+check() {\n+\tlocal name=$1 res=$2 want=$3 outer=$4 sent=$5\n+\tlocal frames outer_ids inner_ids\n+\n+\tread -r _ frames _ _ _ outer_ids _ inner_ids \u003c\u003c\u003c \"$res\"\n+\tRET=0\n+\tcheck_err $((frames != TOTAL)) \"$frames of $TOTAL segments received\"\n+\tif [ \"$want\" = fixed ]; then\n+\t\tcheck_err $((inner_ids != 1)) \"$inner_ids inner IDs, want 1\"\n+\telse\n+\t\tcheck_err $((inner_ids != TOTAL)) \\\n+\t\t\t\"$inner_ids inner IDs, want $TOTAL\"\n+\tfi\n+\tif [ \"$outer\" = 1 ]; then\n+\t\tcheck_err $((outer_ids != frames)) \\\n+\t\t\t\"$outer_ids outer IDs for $frames segments\"\n+\tfi\n+\tif [ \"$RET\" -eq 0 ] \u0026\u0026 [ \"$sent\" -ge \"$TOTAL\" ]; then\n+\t\tret_set_ksft_status \"$ksft_skip\" \"GRO did not merge\"\n+\tfi\n+\tlog_test \"$name\"\n+}\n+\n+# capture \u003cns\u003e \u003cdev\u003e: start the receiver in the background, pid in CAP_PID,\n+# and wait until it is bound\n+capture() {\n+\tlocal i\n+\n+\t: \u003e \"$RESULT\"\n+\tip netns exec \"$1\" \"$TX\" -R -i \"$2\" -c \"$TOTAL\" -w 3000 \u003e \"$RESULT\" \u0026\n+\tCAP_PID=$!\n+\tfor i in $(seq 100); do\n+\t\tgrep -q ready \"$RESULT\" \u0026\u0026 return\n+\t\tsleep 0.1\n+\tdone\n+}\n+\n+run_encap() {\n+\tlocal type=$1 family=$2 want=$3\n+\tlocal r0mac t0 laddr=10.2.0.1 raddr=10.2.0.2\n+\tlocal f=\"\"\n+\n+\tsetup || { log_test_skip \"encap $type IPv$family\"; return; }\n+\tif [ \"$family\" = 6 ]; then\n+\t\tladdr=fd02::1\n+\t\traddr=fd02::2\n+\tfi\n+\ttunnel \"$NRTR\" tun0 \"$type\" \"$family\" \"$laddr\" \"$raddr\" ||\n+\t\t{ log_test_skip \"encap $type IPv$family\"; cleanup_all_ns; return; }\n+\troute_into \"$NRTR\" tun0\n+\tnoseg \"$NRTR\" r1\n+\n+\tr0mac=$(ip -n \"$NRTR\" -br link show r0 | awk '{ print $3 }')\n+\tcapture \"$NMID\" m1\n+\tt0=$(tx_packets \"$NRTR\" tun0)\n+\t[ \"$want\" = fixed ] \u0026\u0026 f=-f\n+\tip netns exec \"$NSRC\" \"$TX\" -T -i s0 -M \"$r0mac\" -s \"$INNER_SRC\" \\\n+\t\t-d \"$INNER_DST\" -n \"$SEGS\" -b \"$BURSTS\" $f\n+\twait \"$CAP_PID\"\n+\tcheck \"encap $type IPv$family, $want inner IDs\" \"$(tail -n 1 \"$RESULT\")\" \\\n+\t\t\"$want\" $((family == 4)) $(($(tx_packets \"$NRTR\" tun0) - t0))\n+\tcleanup_all_ns\n+}\n+\n+# run_decap \u003cfixed: inner|outer\u003e: VXLAN from NSRC, decapsulated in NRTR\n+run_decap() {\n+\tlocal fixed=$1 want=incr flags=-F\n+\tlocal r0mac t0\n+\n+\tsetup || { log_test_skip \"decap\"; return; }\n+\tip -n \"$NRTR\" link add vx0 address \"$VX_MAC\" type vxlan id 42 \\\n+\t\tdstport 4789 local 10.1.0.2 nolearning ||\n+\t\t{ log_test_skip \"decap\"; cleanup_all_ns; return; }\n+\tip -n \"$NRTR\" addr add 10.3.0.2/24 dev vx0\n+\tip -n \"$NRTR\" link set vx0 up\n+\ttunnel \"$NRTR\" tun0 ipip 4 10.2.0.1 10.2.0.2\n+\troute_into \"$NRTR\" tun0\n+\tnoseg \"$NRTR\" r1\n+\n+\tif [ \"$fixed\" = inner ]; then\n+\t\twant=fixed\n+\t\tflags=-f\n+\tfi\n+\tr0mac=$(ip -n \"$NRTR\" -br link show r0 | awk '{ print $3 }')\n+\tcapture \"$NMID\" m1\n+\tt0=$(tx_packets \"$NRTR\" tun0)\n+\tip netns exec \"$NSRC\" \"$TX\" -T -i s0 -M \"$r0mac\" -s 10.3.0.1 \\\n+\t\t-d \"$INNER_DST\" -n \"$SEGS\" -b \"$BURSTS\" \\\n+\t\t-V 10.1.0.1,10.1.0.2 -m \"$VX_MAC\" $flags\n+\twait \"$CAP_PID\"\n+\tcheck \"decap VXLAN with fixed $fixed IDs, into IPIP\" \\\n+\t\t\"$(tail -n 1 \"$RESULT\")\" \"$want\" 1 \\\n+\t\t$(($(tx_packets \"$NRTR\" tun0) - t0))\n+\tcleanup_all_ns\n+}\n+\n+# run_encap_decap \u003ctype\u003e: NRTR encapsulates, NMID decapsulates the GSO\n+# packet without segmenting it and forwards it to NDST\n+run_encap_decap() {\n+\tlocal type=$1\n+\tlocal r0mac t0\n+\n+\tsetup || { log_test_skip \"encap+decap $type\"; return; }\n+\tif ! tunnel \"$NRTR\" tun0 \"$type\" 4 10.2.0.1 10.2.0.2 ||\n+\t ! tunnel \"$NMID\" tun0 \"$type\" 4 10.2.0.2 10.2.0.1; then\n+\t\tlog_test_skip \"encap+decap $type\"\n+\t\tcleanup_all_ns\n+\t\treturn\n+\tfi\n+\troute_into \"$NRTR\" tun0\n+\t# VXLAN drops frames from its own address as loops\n+\tif [ \"$type\" = vxlan ]; then\n+\t\tip -n \"$NMID\" link set tun0 address \"$MID_MAC\"\n+\t\tip -n \"$NRTR\" neigh replace \"$INNER_DST\" lladdr \"$MID_MAC\" \\\n+\t\t\tdev tun0\n+\tfi\n+\tip -n \"$NMID\" route add \"$INNER_DST/32\" via 10.4.0.2\n+\tip -n \"$NDST\" addr add \"$INNER_DST/32\" dev d2\n+\tnoseg \"$NMID\" m2\n+\n+\tr0mac=$(ip -n \"$NRTR\" -br link show r0 | awk '{ print $3 }')\n+\tcapture \"$NDST\" d2\n+\tt0=$(tx_packets \"$NRTR\" tun0)\n+\tip netns exec \"$NSRC\" \"$TX\" -T -i s0 -M \"$r0mac\" -s \"$INNER_SRC\" \\\n+\t\t-d \"$INNER_DST\" -n \"$SEGS\" -b \"$BURSTS\" -f\n+\twait \"$CAP_PID\"\n+\tcheck \"encap+decap $type, fixed inner IDs\" \"$(tail -n 1 \"$RESULT\")\" fixed 0 \\\n+\t\t$(($(tx_packets \"$NRTR\" tun0) - t0))\n+\tcleanup_all_ns\n+}\n+\n+require_command ethtool\n+require_command tc\n+\n+if [ ! -x \"$TX\" ]; then\n+\techo \"SKIP: $TX not built\"\n+\texit \"$ksft_skip\"\n+fi\n+\n+RESULT=$(mktemp)\n+\n+for type in ipip gre vxlan; do\n+\tfor family in 4 6; do\n+\t\trun_encap \"$type\" \"$family\" fixed\n+\t\trun_encap \"$type\" \"$family\" incr\n+\tdone\n+done\n+run_decap inner\n+run_decap outer\n+for type in ipip gre vxlan; do\n+\trun_encap_decap \"$type\"\n+done\n+\n+rm -f \"$RESULT\"\n+exit \"$EXIT_STATUS\"\n"
} |
| 2/1 | 2026/11/01 22:46 | agent | patch-evaluator |
3mModel:core Args: null Results: {
"EnableConfigs": [
"INET",
"IPV6",
"NET_IPGRE",
"NET_IPIP",
"VXLAN",
"LWTUNNEL_BPF",
"BPF_SYSCALL"
],
"FocusSymbols": [
"iptunnel_handle_offloads",
"__iptunnel_pull_header",
"gre_gso_segment",
"skb_udp_tunnel_segment",
"bpf_skb_net_grow",
"bpf_skb_net_shrink",
"bpf_lwt_push_ip_encap",
"ipv6_srh_rcv",
"ipv6_rpl_srh_rcv"
],
"Reasoning": "The patch modifies core networking GSO offload handling across tunnel encapsulation and decapsulation paths, as well as BPF room adjustment helpers (bpf_skb_net_grow, bpf_skb_net_shrink) and IPv6 Segment Routing (SRH/RPL SRH). Specifically, it manages shifting of SKB_GSO_TCP_FIXEDID and SKB_GSO_TCP_FIXEDID_INNER flags on encap/decap and removes encap_level resets in GRE and UDP tunnel segmentation. These changes alter packet transformations, unclone logic, and segmentation invariant handling across reachable virtual networking devices (veth, tunnels, VXLAN) and BPF programs, making it valuable to fuzz for crashes, memory corruption, or incorrect packet handling.",
"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 6eb51eb6a4f2ce92cd7840a9e1ae1209dfff657f
Author: syz-cluster <triage@syzkaller.com>
Date: Sun Nov 1 22:46:47 2026 +0000
syz-cluster: applied patch under review
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 6787fcf6ac3e43..00df57cbc05c27 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -5337,6 +5337,36 @@ static inline void skb_decrease_gso_size(struct skb_shared_info *shinfo,
shinfo->gso_size -= decrement;
}
+/**
+ * skb_gso_fixedid_encap - move the TCP fixed-ID flag to the inner header
+ * @shinfo: shared info of a GSO packet that becomes encapsulated
+ *
+ * The IPv4 header that SKB_GSO_TCP_FIXEDID describes becomes the inner one,
+ * and the new outer header gets an incrementing ID.
+ */
+static inline void skb_gso_fixedid_encap(struct skb_shared_info *shinfo)
+{
+ unsigned int fixedid = shinfo->gso_type & SKB_GSO_TCP_FIXEDID;
+
+ shinfo->gso_type &= ~(SKB_GSO_TCP_FIXEDID | SKB_GSO_TCP_FIXEDID_INNER);
+ shinfo->gso_type |= fixedid << 1;
+}
+
+/**
+ * skb_gso_fixedid_decap - move the TCP fixed-ID flag to the new outer header
+ * @shinfo: shared info of an encapsulated GSO packet losing its outer header
+ *
+ * The inner IPv4 header, which SKB_GSO_TCP_FIXEDID_INNER describes, becomes
+ * the outer one, and the state of the removed outer header is dropped.
+ */
+static inline void skb_gso_fixedid_decap(struct skb_shared_info *shinfo)
+{
+ unsigned int fixedid = shinfo->gso_type & SKB_GSO_TCP_FIXEDID_INNER;
+
+ shinfo->gso_type &= ~(SKB_GSO_TCP_FIXEDID | SKB_GSO_TCP_FIXEDID_INNER);
+ shinfo->gso_type |= fixedid >> 1;
+}
+
void __skb_warn_lro_forwarding(const struct sk_buff *skb);
static __always_inline bool skb_warn_if_lro(const struct sk_buff *skb)
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
index 5cccf4c0e6913a..c2ffda6029a062 100644
--- a/include/net/ip_tunnels.h
+++ b/include/net/ip_tunnels.h
@@ -665,6 +665,8 @@ static inline int iptunnel_pull_offloads(struct sk_buff *skb)
err = skb_unclone(skb, GFP_ATOMIC);
if (unlikely(err))
return err;
+ if (skb->encapsulation)
+ skb_gso_fixedid_decap(skb_shinfo(skb));
skb_shinfo(skb)->gso_type &= ~(NETIF_F_GSO_ENCAP_ALL >>
NETIF_F_GSO_SHIFT);
}
diff --git a/net/core/filter.c b/net/core/filter.c
index 09c60a58c82abe..4f87a827b25be4 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -3718,6 +3718,9 @@ static int bpf_skb_net_grow(struct sk_buff *skb, u32 off, u32 len_diff,
if (skb_is_gso(skb)) {
struct skb_shared_info *shinfo = skb_shinfo(skb);
+ if (encap)
+ skb_gso_fixedid_encap(shinfo);
+
/* Header must be checked, and gso_segs recomputed. */
shinfo->gso_type |= gso_type;
shinfo->gso_segs = 0;
@@ -3809,9 +3812,11 @@ static int bpf_skb_net_shrink(struct sk_buff *skb, u32 off, u32 len_diff,
SKB_GSO_GRE_CSUM |
SKB_GSO_IPXIP4 |
SKB_GSO_IPXIP6 |
- SKB_GSO_ESP)))
- if (skb->encapsulation)
- skb->encapsulation = 0;
+ SKB_GSO_ESP)) &&
+ skb->encapsulation) {
+ skb_gso_fixedid_decap(shinfo);
+ skb->encapsulation = 0;
+ }
}
/* Header must be checked, and gso_segs recomputed. */
diff --git a/net/core/lwt_bpf.c b/net/core/lwt_bpf.c
index da49364ec63de7..4d9faf2cc5de59 100644
--- a/net/core/lwt_bpf.c
+++ b/net/core/lwt_bpf.c
@@ -539,6 +539,7 @@ static int handle_gso_type(struct sk_buff *skb, unsigned int gso_type,
{
struct skb_shared_info *shinfo = skb_shinfo(skb);
+ skb_gso_fixedid_encap(shinfo);
gso_type |= SKB_GSO_DODGY;
shinfo->gso_type |= gso_type;
skb_decrease_gso_size(shinfo, encap_len);
diff --git a/net/ipv4/gre_offload.c b/net/ipv4/gre_offload.c
index c8129782d39de4..a8f9a0a0b06bdf 100644
--- a/net/ipv4/gre_offload.c
+++ b/net/ipv4/gre_offload.c
@@ -35,7 +35,6 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
/* setup inner skb. */
skb->encapsulation = 0;
- SKB_GSO_CB(skb)->encap_level = 0;
__skb_pull(skb, tnl_hlen);
skb_reset_mac_header(skb);
skb_set_network_header(skb, skb_inner_network_offset(skb));
diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c
index 6c2855adff2899..59050229e34996 100644
--- a/net/ipv4/ip_tunnel_core.c
+++ b/net/ipv4/ip_tunnel_core.c
@@ -182,9 +182,10 @@ EXPORT_SYMBOL_GPL(iptunnel_metadata_reply);
int iptunnel_handle_offloads(struct sk_buff *skb,
int gso_type_mask)
{
+ bool encap = !skb->encapsulation;
int err;
- if (likely(!skb->encapsulation)) {
+ if (likely(encap)) {
skb_reset_inner_headers(skb);
skb->encapsulation = 1;
}
@@ -193,6 +194,8 @@ int iptunnel_handle_offloads(struct sk_buff *skb,
err = skb_header_unclone(skb, GFP_ATOMIC);
if (unlikely(err))
return err;
+ if (encap)
+ skb_gso_fixedid_encap(skb_shinfo(skb));
skb_shinfo(skb)->gso_type |= gso_type_mask;
return 0;
}
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index cf07c3c6611a22..edcabe1115a60c 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -205,7 +205,6 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
/* setup inner skb. */
skb->encapsulation = 0;
- SKB_GSO_CB(skb)->encap_level = 0;
__skb_pull(skb, tnl_hlen);
skb_reset_mac_header(skb);
skb_set_network_header(skb, skb_inner_network_offset(skb));
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 96c8402a27a549..126058772bc5ae 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -53,6 +53,7 @@
#include <linux/ioam6_genl.h>
#include <net/ioam6.h>
#include <net/dst_metadata.h>
+#include <net/ip_tunnels.h>
#include <linux/uaccess.h>
@@ -406,7 +407,10 @@ static int ipv6_srh_rcv(struct sk_buff *skb, struct inet6_dev *idev)
skb_reset_network_header(skb);
skb_reset_transport_header(skb);
- skb->encapsulation = 0;
+ if (iptunnel_pull_offloads(skb)) {
+ kfree_skb(skb);
+ return -1;
+ }
if (hdr->nexthdr == NEXTHDR_IPV4)
skb->protocol = htons(ETH_P_IP);
__skb_tunnel_rx(skb, skb->dev, net);
@@ -513,7 +517,10 @@ static int ipv6_rpl_srh_rcv(struct sk_buff *skb, struct inet6_dev *idev)
skb_reset_network_header(skb);
skb_reset_transport_header(skb);
- skb->encapsulation = 0;
+ if (iptunnel_pull_offloads(skb)) {
+ kfree_skb(skb);
+ return -1;
+ }
__skb_tunnel_rx(skb, skb->dev, net);
diff --git a/tools/testing/selftests/net/.gitignore b/tools/testing/selftests/net/.gitignore
index 21412510ac26b8..96263d5978258f 100644
--- a/tools/testing/selftests/net/.gitignore
+++ b/tools/testing/selftests/net/.gitignore
@@ -46,6 +46,7 @@ so_rcv_listener
stress_reuseport_listen
tap
tcp_fastopen_backup_key
+tcp_fixedid
tcp_inq
tcp_mmap
tcp_port_share
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 9180b9bec5155e..dd402814bc7483 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -106,6 +106,7 @@ TEST_PROGS := \
srv6_iptunnel_cache.sh \
stress_reuseport_listen.sh \
tcp_ecmp_failover.sh \
+ tcp_fixedid.sh \
tcp_fastopen_backup_key.sh \
test_bridge_backup_port.sh \
test_bridge_neigh_suppress.sh \
@@ -169,6 +170,7 @@ TEST_GEN_FILES := \
socket \
stress_reuseport_listen \
tcp_fastopen_backup_key \
+ tcp_fixedid \
tcp_inq \
tcp_mmap \
tfo \
diff --git a/tools/testing/selftests/net/tcp_fixedid.c b/tools/testing/selftests/net/tcp_fixedid.c
new file mode 100644
index 00000000000000..d507d12b46308f
--- /dev/null
+++ b/tools/testing/selftests/net/tcp_fixedid.c
@@ -0,0 +1,396 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Send TCP segments with fixed or incrementing IPv4 IDs, optionally in
+ * VXLAN, and report the IP IDs of TCP segments received on a device.
+ *
+ * tx: tcp_fixedid -T -i dev -M dmac -s saddr -d daddr [-f] [-n segs]
+ * [-b bursts] [-l len] [-V osaddr,odaddr -m inner_dmac [-F]]
+ * rx: tcp_fixedid -R -i dev [-c segs] [-w ms]
+ *
+ * The receiver prints "ready" once it is bound, then the number of
+ * segments, of segments with an outer IPv4 header, and of distinct outer
+ * and inner IDs.
+ */
+
+#include <arpa/inet.h>
+#include <errno.h>
+#include <error.h>
+#include <linux/if_packet.h>
+#include <net/ethernet.h>
+#include <net/if.h>
+#include <netinet/ip.h>
+#include <netinet/ip6.h>
+#include <netinet/tcp.h>
+#include <netinet/udp.h>
+#include <poll.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>
+
+#define TEST_PORT 9000
+#define VXLAN_PORT 4789
+#define FIXED_ID 0x1234
+
+static const char *ifname;
+static bool fixed_id, fixed_outer;
+static int segs = 40, bursts = 10, len = 1000, wait_ms = 2000, stop;
+static struct in_addr saddr, daddr, osaddr, odaddr;
+static bool vxlan;
+static unsigned char dmac[ETH_ALEN], inner_dmac[ETH_ALEN];
+
+static void parse_mac(const char *s, unsigned char *mac)
+{
+ if (sscanf(s, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &mac[0], &mac[1],
+ &mac[2], &mac[3], &mac[4], &mac[5]) != 6)
+ error(1, 0, "bad mac %s", s);
+}
+
+static void parse_addr(const char *s, struct in_addr *a)
+{
+ if (inet_pton(AF_INET, s, a) != 1)
+ error(1, 0, "bad address %s", s);
+}
+
+static uint32_t csum_add(uint32_t sum, const void *data, size_t n)
+{
+ const uint8_t *p = data;
+
+ while (n > 1) {
+ sum += (p[0] << 8) | p[1];
+ p += 2;
+ n -= 2;
+ }
+ if (n)
+ sum += p[0] << 8;
+ return sum;
+}
+
+static uint16_t csum_fold(uint32_t sum)
+{
+ while (sum >> 16)
+ sum = (sum & 0xffff) + (sum >> 16);
+ return htons(~sum & 0xffff);
+}
+
+static void build_ip(struct iphdr *iph, int proto, int payload, uint16_t id,
+ struct in_addr s, struct in_addr d)
+{
+ memset(iph, 0, sizeof(*iph));
+ iph->version = 4;
+ iph->ihl = 5;
+ iph->tot_len = htons(sizeof(*iph) + payload);
+ iph->id = htons(id);
+ iph->frag_off = htons(IP_DF);
+ iph->ttl = 64;
+ iph->protocol = proto;
+ iph->saddr = s.s_addr;
+ iph->daddr = d.s_addr;
+ iph->check = csum_fold(csum_add(0, iph, sizeof(*iph)));
+}
+
+/* Ethernet, IPv4 and TCP header plus payload for segment @i at @p */
+static int build_tcp(unsigned char *p, const unsigned char *mac, int i,
+ uint16_t id)
+{
+ struct ethhdr *eth = (struct ethhdr *)p;
+ struct iphdr *iph = (struct iphdr *)(eth + 1);
+ struct tcphdr *th = (struct tcphdr *)(iph + 1);
+ struct {
+ uint32_t s, d;
+ uint8_t zero, proto;
+ uint16_t len;
+ } ph; /* 12 bytes, no padding */
+ uint32_t sum;
+
+ memcpy(eth->h_dest, mac, ETH_ALEN);
+ memset(eth->h_source, 0, ETH_ALEN);
+ eth->h_source[0] = 0x02;
+ eth->h_source[5] = 0x01;
+ eth->h_proto = htons(ETH_P_IP);
+ build_ip(iph, IPPROTO_TCP, sizeof(*th) + len, id, saddr, daddr);
+
+ memset(th, 0, sizeof(*th));
+ th->source = htons(TEST_PORT + 1);
+ th->dest = htons(TEST_PORT);
+ th->seq = htonl(1 + i * len);
+ th->ack_seq = htonl(1);
+ th->doff = 5;
+ th->ack = 1;
+ th->window = htons(65535);
+ memset(th + 1, 'a' + i % 26, len);
+
+ ph.s = iph->saddr;
+ ph.d = iph->daddr;
+ ph.zero = 0;
+ ph.proto = IPPROTO_TCP;
+ ph.len = htons(sizeof(*th) + len);
+ sum = csum_add(0, &ph, sizeof(ph));
+ th->check = csum_fold(csum_add(sum, th, sizeof(*th) + len));
+
+ return sizeof(*eth) + sizeof(*iph) + sizeof(*th) + len;
+}
+
+static int do_tx(int fd, struct sockaddr_ll *sll)
+{
+ unsigned char buf[ETH_FRAME_LEN + 128];
+ int b, s, i = 0, n;
+
+ for (b = 0; b < bursts; b++) {
+ for (s = 0; s < segs; s++, i++) {
+ uint16_t id = fixed_id ? FIXED_ID : 0x1000 + i;
+ unsigned char *p = buf;
+
+ if (vxlan) {
+ struct ethhdr *eth = (struct ethhdr *)p;
+ struct iphdr *iph = (struct iphdr *)(eth + 1);
+ struct udphdr *uh = (struct udphdr *)(iph + 1);
+ uint32_t *vx = (uint32_t *)(uh + 1);
+ int inner;
+
+ inner = build_tcp((unsigned char *)(vx + 2),
+ inner_dmac, i, id);
+ memcpy(eth->h_dest, dmac, ETH_ALEN);
+ memset(eth->h_source, 0, ETH_ALEN);
+ eth->h_source[0] = 0x02;
+ eth->h_source[5] = 0x01;
+ eth->h_proto = htons(ETH_P_IP);
+ memset(uh, 0, sizeof(*uh));
+ uh->source = htons(VXLAN_PORT + 1);
+ uh->dest = htons(VXLAN_PORT);
+ uh->len = htons(sizeof(*uh) + 8 + inner);
+ vx[0] = htonl(0x08000000);
+ vx[1] = htonl(42 << 8);
+ build_ip(iph, IPPROTO_UDP,
+ sizeof(*uh) + 8 + inner,
+ fixed_outer ? FIXED_ID : 0x2000 + i,
+ osaddr, odaddr);
+ n = sizeof(*eth) + sizeof(*iph) + sizeof(*uh) +
+ 8 + inner;
+ } else {
+ n = build_tcp(p, dmac, i, id);
+ }
+
+ if (sendto(fd, buf, n, 0, (struct sockaddr *)sll,
+ sizeof(*sll)) != n)
+ error(1, errno, "sendto");
+ }
+ usleep(50000);
+ }
+ return 0;
+}
+
+/* Return the inner IPv4 header of a TCP segment to TEST_PORT, or NULL */
+static const struct iphdr *find_inner(const unsigned char *p, int n,
+ const struct iphdr **outer4)
+{
+ const struct ethhdr *eth = (const struct ethhdr *)p;
+ const unsigned char *end = p + n;
+ const unsigned char *l4;
+ int proto, depth;
+
+ *outer4 = NULL;
+ if (n < (int)sizeof(*eth))
+ return NULL;
+ p += sizeof(*eth);
+
+ for (depth = 0; depth < 2; depth++) {
+ uint16_t etype = depth ? htons(ETH_P_IP) : eth->h_proto;
+
+ if (etype == htons(ETH_P_IP)) {
+ const struct iphdr *iph = (const struct iphdr *)p;
+
+ if (p + sizeof(*iph) > end)
+ return NULL;
+ proto = iph->protocol;
+ l4 = p + iph->ihl * 4;
+ if (proto == IPPROTO_TCP) {
+ const struct tcphdr *th;
+
+ th = (const struct tcphdr *)l4;
+ if (l4 + sizeof(*th) > end ||
+ th->dest != htons(TEST_PORT))
+ return NULL;
+ return iph;
+ }
+ if (depth)
+ return NULL;
+ *outer4 = iph;
+ } else if (etype == htons(ETH_P_IPV6)) {
+ const struct ip6_hdr *ip6h = (const struct ip6_hdr *)p;
+
+ if (p + sizeof(*ip6h) > end)
+ return NULL;
+ proto = ip6h->ip6_nxt;
+ l4 = p + sizeof(*ip6h);
+ } else {
+ return NULL;
+ }
+
+ /* step over the tunnel header to the inner IPv4 header */
+ if (proto == IPPROTO_IPIP) {
+ p = l4;
+ } else if (proto == IPPROTO_GRE) {
+ uint16_t flags;
+
+ if (l4 + 4 > end)
+ return NULL;
+ flags = (l4[0] << 8) | l4[1];
+ if (((l4[2] << 8) | l4[3]) != ETH_P_IP)
+ return NULL;
+ p = l4 + 4 + 4 * (!!(flags & 0x8000) +
+ !!(flags & 0x2000) +
+ !!(flags & 0x1000));
+ } else if (proto == IPPROTO_UDP) {
+ const struct udphdr *uh = (const struct udphdr *)l4;
+
+ if (l4 + sizeof(*uh) + 8 + sizeof(*eth) > end ||
+ uh->dest != htons(VXLAN_PORT))
+ return NULL;
+ p = l4 + sizeof(*uh) + 8 + sizeof(*eth);
+ } else {
+ return NULL;
+ }
+ }
+ return NULL;
+}
+
+static void count_id(uint8_t *map, unsigned int *distinct, uint16_t id)
+{
+ if (!(map[id / 8] & (1 << (id % 8)))) {
+ map[id / 8] |= 1 << (id % 8);
+ (*distinct)++;
+ }
+}
+
+static int do_rx(int fd)
+{
+ static uint8_t outer_map[8192], inner_map[8192];
+ unsigned int frames = 0, outer4 = 0, outer_ids = 0, inner_ids = 0;
+ unsigned char buf[65536];
+ struct pollfd pfd = { .fd = fd, .events = POLLIN };
+
+ printf("ready\n");
+ fflush(stdout);
+
+ /* wait longer for the first segment than between segments */
+ while (poll(&pfd, 1, frames ? wait_ms : 10 * wait_ms) > 0) {
+ const struct iphdr *iph, *oiph;
+ struct sockaddr_ll from;
+ socklen_t fl = sizeof(from);
+ int n;
+
+ n = recvfrom(fd, buf, sizeof(buf), 0, (struct sockaddr *)&from,
+ &fl);
+ if (n < 0)
+ error(1, errno, "recvfrom");
+ if (from.sll_pkttype == PACKET_OUTGOING)
+ continue;
+ iph = find_inner(buf, n, &oiph);
+ if (!iph)
+ continue;
+ frames++;
+ count_id(inner_map, &inner_ids, ntohs(iph->id));
+ if (oiph) {
+ outer4++;
+ count_id(outer_map, &outer_ids, ntohs(oiph->id));
+ }
+ if (stop && frames == (unsigned int)stop)
+ break;
+ }
+
+ printf("frames %u outer4 %u outer_ids %u inner_ids %u\n", frames,
+ outer4, outer_ids, inner_ids);
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ struct sockaddr_ll sll = {};
+ bool tx = false, rx = false;
+ char *comma;
+ int c, fd;
+
+ while ((c = getopt(argc, argv, "TRi:M:s:d:fn:b:l:V:m:Fw:c:")) != -1) {
+ switch (c) {
+ case 'T':
+ tx = true;
+ break;
+ case 'R':
+ rx = true;
+ break;
+ case 'i':
+ ifname = optarg;
+ break;
+ case 'M':
+ parse_mac(optarg, dmac);
+ break;
+ case 's':
+ parse_addr(optarg, &saddr);
+ break;
+ case 'd':
+ parse_addr(optarg, &daddr);
+ break;
+ case 'f':
+ fixed_id = true;
+ break;
+ case 'n':
+ segs = atoi(optarg);
+ break;
+ case 'b':
+ bursts = atoi(optarg);
+ break;
+ case 'l':
+ len = atoi(optarg);
+ break;
+ case 'V':
+ comma = strchr(optarg, ',');
+ if (!comma)
+ error(1, 0, "-V needs outer saddr,daddr");
+ *comma = '\0';
+ parse_addr(optarg, &osaddr);
+ parse_addr(comma + 1, &odaddr);
+ vxlan = true;
+ break;
+ case 'm':
+ parse_mac(optarg, inner_dmac);
+ break;
+ case 'F':
+ fixed_outer = true;
+ break;
+ case 'w':
+ wait_ms = atoi(optarg);
+ break;
+ case 'c':
+ stop = atoi(optarg);
+ break;
+ default:
+ error(1, 0, "bad option");
+ }
+ }
+ if (tx == rx || !ifname || len < 1 || len > 1400 || segs < 1 ||
+ bursts < 1)
+ error(1, 0, "usage: see the comment at the top of %s",
+ __FILE__);
+
+ fd = socket(AF_PACKET, SOCK_RAW, htons(tx ? 0 : ETH_P_ALL));
+ if (fd < 0)
+ error(1, errno, "socket");
+ sll.sll_family = AF_PACKET;
+ sll.sll_protocol = htons(ETH_P_ALL);
+ sll.sll_ifindex = if_nametoindex(ifname);
+ if (!sll.sll_ifindex)
+ error(1, errno, "%s", ifname);
+ if (bind(fd, (struct sockaddr *)&sll, sizeof(sll)))
+ error(1, errno, "bind");
+ sll.sll_halen = ETH_ALEN;
+ memcpy(sll.sll_addr, dmac, ETH_ALEN);
+
+ c = tx ? do_tx(fd, &sll) : do_rx(fd);
+ close(fd);
+ return c;
+}
diff --git a/tools/testing/selftests/net/tcp_fixedid.sh b/tools/testing/selftests/net/tcp_fixedid.sh
new file mode 100755
index 00000000000000..88f92981740771
--- /dev/null
+++ b/tools/testing/selftests/net/tcp_fixedid.sh
@@ -0,0 +1,291 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# Check the IPv4 IDs of a TCP stream that GRO merged and software
+# segmentation split again across a tunnel. A sender in NSRC writes
+# segments with fixed or incrementing IDs onto a veth with GRO on in
+# NRTR, which forwards the merged packets:
+#
+# encap: into an IPIP, GRE or VXLAN tunnel over IPv4 or IPv6,
+# segmented on the underlay towards NMID
+# decap: out of VXLAN, received from NSRC with one header fixed and
+# the other incrementing, into an IPIP tunnel towards NMID
+# encap+decap: into a tunnel that NMID ends without segmenting, and on
+# to NDST, segmented there
+#
+# The inner IDs must come out as they went in, and the IDs of a new outer
+# IPv4 header must be unique. Packets that GRO did not merge are not
+# tested, so a run where nothing was merged is skipped.
+
+source lib.sh
+
+NSRC=""
+NRTR=""
+NMID=""
+NDST=""
+
+SEGS=40
+BURSTS=10
+TOTAL=$((SEGS * BURSTS))
+INNER_SRC=10.1.0.1
+INNER_DST=10.9.0.2
+VX_MAC=02:00:00:00:00:42
+TUN_MAC=02:00:00:00:00:99
+MID_MAC=02:00:00:00:00:98
+TX=./tcp_fixedid
+
+NOSEG="tso gso tx-gre-segmentation tx-gre-csum-segmentation
+ tx-ipxip4-segmentation tx-ipxip6-segmentation
+ tx-udp_tnl-segmentation tx-udp_tnl-csum-segmentation"
+
+cleanup() {
+ cleanup_all_ns
+}
+
+trap cleanup EXIT
+
+# NSRC s0 - r0 NRTR r1 - m1 NMID m2 - d2 NDST
+setup() {
+ setup_ns NSRC NRTR NMID NDST || return "$ksft_skip"
+
+ ip link add s0 netns "$NSRC" type veth peer name r0 netns "$NRTR"
+ ip link add r1 netns "$NRTR" type veth peer name m1 netns "$NMID"
+ ip link add m2 netns "$NMID" type veth peer name d2 netns "$NDST"
+
+ ip -n "$NRTR" addr add 10.1.0.2/24 dev r0
+ ip -n "$NRTR" addr add 10.2.0.1/24 dev r1
+ ip -n "$NRTR" addr add fd02::1/64 dev r1 nodad
+ ip -n "$NMID" addr add 10.2.0.2/24 dev m1
+ ip -n "$NMID" addr add fd02::2/64 dev m1 nodad
+ ip -n "$NMID" addr add 10.4.0.1/24 dev m2
+ ip -n "$NDST" addr add 10.4.0.2/24 dev d2
+ ip -n "$NSRC" link set s0 up
+ ip -n "$NRTR" link set r0 up
+ ip -n "$NRTR" link set r1 up
+ ip -n "$NMID" link set m1 up
+ ip -n "$NMID" link set m2 up
+ ip -n "$NDST" link set d2 up
+
+ ip netns exec "$NRTR" sysctl -qw net.ipv4.ip_forward=1
+ ip netns exec "$NMID" sysctl -qw net.ipv4.ip_forward=1
+ for ns in "$NRTR" "$NMID"; do
+ ip netns exec "$ns" sysctl -qw net.ipv4.conf.all.rp_filter=0 \
+ net.ipv4.conf.default.rp_filter=0
+ done
+
+ # veth passes packets to GRO only if the sender does not do TSO
+ ip netns exec "$NRTR" ethtool -K r0 gro on >/dev/null ||
+ return "$ksft_skip"
+ ip netns exec "$NSRC" ethtool -K s0 tso off >/dev/null ||
+ return "$ksft_skip"
+ # release the sender's segments in bursts for GRO to merge
+ tc -n "$NSRC" qdisc add dev s0 root netem slot 20ms 20ms \
+ packets "$SEGS" || return "$ksft_skip"
+}
+
+# tunnel <ns> <name> <type> <family> <local> <remote>
+tunnel() {
+ local ns=$1 name=$2 type=$3 family=$4 local=$5 remote=$6
+
+ case "$type" in
+ ipip)
+ if [ "$family" = 4 ]; then
+ ip -n "$ns" link add "$name" type ipip \
+ local "$local" remote "$remote"
+ else
+ ip -n "$ns" link add "$name" type ip6tnl mode ipip6 \
+ local "$local" remote "$remote" encaplimit none
+ fi ;;
+ gre)
+ if [ "$family" = 4 ]; then
+ ip -n "$ns" link add "$name" type gre \
+ local "$local" remote "$remote"
+ else
+ ip -n "$ns" link add "$name" type ip6gre \
+ local "$local" remote "$remote" encaplimit none
+ fi ;;
+ vxlan)
+ ip -n "$ns" link add "$name" address "$TUN_MAC" type vxlan \
+ id 7 dstport 4789 local "$local" remote "$remote" \
+ nolearning ;;
+ esac || return 1
+ ip -n "$ns" link set "$name" up
+}
+
+# route_into <ns> <dev>: send INNER_DST into <dev>
+route_into() {
+ ip -n "$1" route add "$INNER_DST/32" dev "$2"
+ ip -n "$1" neigh add "$INNER_DST" lladdr "$TUN_MAC" dev "$2" \
+ 2>/dev/null
+ return 0
+}
+
+# noseg <ns> <dev>: segment everything in software before <dev>
+noseg() {
+ local f
+
+ for f in $NOSEG; do
+ ip netns exec "$1" ethtool -K "$2" "$f" off >/dev/null 2>&1
+ done
+}
+
+tx_packets() {
+ ip netns exec "$1" cat "/sys/class/net/$2/statistics/tx_packets"
+}
+
+# check <name> <result> <want: fixed|incr> <outer: 0|1> <merged-into-dev>
+check() {
+ local name=$1 res=$2 want=$3 outer=$4 sent=$5
+ local frames outer_ids inner_ids
+
+ read -r _ frames _ _ _ outer_ids _ inner_ids <<< "$res"
+ RET=0
+ check_err $((frames != TOTAL)) "$frames of $TOTAL segments received"
+ if [ "$want" = fixed ]; then
+ check_err $((inner_ids != 1)) "$inner_ids inner IDs, want 1"
+ else
+ check_err $((inner_ids != TOTAL)) \
+ "$inner_ids inner IDs, want $TOTAL"
+ fi
+ if [ "$outer" = 1 ]; then
+ check_err $((outer_ids != frames)) \
+ "$outer_ids outer IDs for $frames segments"
+ fi
+ if [ "$RET" -eq 0 ] && [ "$sent" -ge "$TOTAL" ]; then
+ ret_set_ksft_status "$ksft_skip" "GRO did not merge"
+ fi
+ log_test "$name"
+}
+
+# capture <ns> <dev>: start the receiver in the background, pid in CAP_PID,
+# and wait until it is bound
+capture() {
+ local i
+
+ : > "$RESULT"
+ ip netns exec "$1" "$TX" -R -i "$2" -c "$TOTAL" -w 3000 > "$RESULT" &
+ CAP_PID=$!
+ for i in $(seq 100); do
+ grep -q ready "$RESULT" && return
+ sleep 0.1
+ done
+}
+
+run_encap() {
+ local type=$1 family=$2 want=$3
+ local r0mac t0 laddr=10.2.0.1 raddr=10.2.0.2
+ local f=""
+
+ setup || { log_test_skip "encap $type IPv$family"; return; }
+ if [ "$family" = 6 ]; then
+ laddr=fd02::1
+ raddr=fd02::2
+ fi
+ tunnel "$NRTR" tun0 "$type" "$family" "$laddr" "$raddr" ||
+ { log_test_skip "encap $type IPv$family"; cleanup_all_ns; return; }
+ route_into "$NRTR" tun0
+ noseg "$NRTR" r1
+
+ r0mac=$(ip -n "$NRTR" -br link show r0 | awk '{ print $3 }')
+ capture "$NMID" m1
+ t0=$(tx_packets "$NRTR" tun0)
+ [ "$want" = fixed ] && f=-f
+ ip netns exec "$NSRC" "$TX" -T -i s0 -M "$r0mac" -s "$INNER_SRC" \
+ -d "$INNER_DST" -n "$SEGS" -b "$BURSTS" $f
+ wait "$CAP_PID"
+ check "encap $type IPv$family, $want inner IDs" "$(tail -n 1 "$RESULT")" \
+ "$want" $((family == 4)) $(($(tx_packets "$NRTR" tun0) - t0))
+ cleanup_all_ns
+}
+
+# run_decap <fixed: inner|outer>: VXLAN from NSRC, decapsulated in NRTR
+run_decap() {
+ local fixed=$1 want=incr flags=-F
+ local r0mac t0
+
+ setup || { log_test_skip "decap"; return; }
+ ip -n "$NRTR" link add vx0 address "$VX_MAC" type vxlan id 42 \
+ dstport 4789 local 10.1.0.2 nolearning ||
+ { log_test_skip "decap"; cleanup_all_ns; return; }
+ ip -n "$NRTR" addr add 10.3.0.2/24 dev vx0
+ ip -n "$NRTR" link set vx0 up
+ tunnel "$NRTR" tun0 ipip 4 10.2.0.1 10.2.0.2
+ route_into "$NRTR" tun0
+ noseg "$NRTR" r1
+
+ if [ "$fixed" = inner ]; then
+ want=fixed
+ flags=-f
+ fi
+ r0mac=$(ip -n "$NRTR" -br link show r0 | awk '{ print $3 }')
+ capture "$NMID" m1
+ t0=$(tx_packets "$NRTR" tun0)
+ ip netns exec "$NSRC" "$TX" -T -i s0 -M "$r0mac" -s 10.3.0.1 \
+ -d "$INNER_DST" -n "$SEGS" -b "$BURSTS" \
+ -V 10.1.0.1,10.1.0.2 -m "$VX_MAC" $flags
+ wait "$CAP_PID"
+ check "decap VXLAN with fixed $fixed IDs, into IPIP" \
+ "$(tail -n 1 "$RESULT")" "$want" 1 \
+ $(($(tx_packets "$NRTR" tun0) - t0))
+ cleanup_all_ns
+}
+
+# run_encap_decap <type>: NRTR encapsulates, NMID decapsulates the GSO
+# packet without segmenting it and forwards it to NDST
+run_encap_decap() {
+ local type=$1
+ local r0mac t0
+
+ setup || { log_test_skip "encap+decap $type"; return; }
+ if ! tunnel "$NRTR" tun0 "$type" 4 10.2.0.1 10.2.0.2 ||
+ ! tunnel "$NMID" tun0 "$type" 4 10.2.0.2 10.2.0.1; then
+ log_test_skip "encap+decap $type"
+ cleanup_all_ns
+ return
+ fi
+ route_into "$NRTR" tun0
+ # VXLAN drops frames from its own address as loops
+ if [ "$type" = vxlan ]; then
+ ip -n "$NMID" link set tun0 address "$MID_MAC"
+ ip -n "$NRTR" neigh replace "$INNER_DST" lladdr "$MID_MAC" \
+ dev tun0
+ fi
+ ip -n "$NMID" route add "$INNER_DST/32" via 10.4.0.2
+ ip -n "$NDST" addr add "$INNER_DST/32" dev d2
+ noseg "$NMID" m2
+
+ r0mac=$(ip -n "$NRTR" -br link show r0 | awk '{ print $3 }')
+ capture "$NDST" d2
+ t0=$(tx_packets "$NRTR" tun0)
+ ip netns exec "$NSRC" "$TX" -T -i s0 -M "$r0mac" -s "$INNER_SRC" \
+ -d "$INNER_DST" -n "$SEGS" -b "$BURSTS" -f
+ wait "$CAP_PID"
+ check "encap+decap $type, fixed inner IDs" "$(tail -n 1 "$RESULT")" fixed 0 \
+ $(($(tx_packets "$NRTR" tun0) - t0))
+ cleanup_all_ns
+}
+
+require_command ethtool
+require_command tc
+
+if [ ! -x "$TX" ]; then
+ echo "SKIP: $TX not built"
+ exit "$ksft_skip"
+fi
+
+RESULT=$(mktemp)
+
+for type in ipip gre vxlan; do
+ for family in 4 6; do
+ run_encap "$type" "$family" fixed
+ run_encap "$type" "$family" incr
+ done
+done
+run_decap inner
+run_decap outer
+for type in ipip gre vxlan; do
+ run_encap_decap "$type"
+done
+
+rm -f "$RESULT"
+exit "$EXIT_STATUS"
|
| 3/2 | 2026/11/01 22:46 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 14760 output: 45 thoughts: 763 Thoughts: **Analyzing a Kernel Patch Series: GSO Fixed ID Handling** Okay, so I've been asked to review a patch series targeting the amd64 architecture, presumably against the kernel's HEAD. My initial thought is to dive right into the code and see what's changed. Let's see... First, I've got a diff summary. It looks like this patch is fundamentally about tweaking how the kernel handles GSO (Generic Segmentation Offload) with respect to a "fixed ID" concept, specifically related to encapsulated packets. The core change seems to revolve around shifting the `SKB_GSO_TCP_FIXEDID` flag. There are a couple of new functions introduced, `skb_gso_fixedid_encap` and `skb_gso_fixedid_decap`, which seem to handle this bit shifting. Specifically, I see changes in the following files, which immediately pique my interest: * `include/linux/skbuff.h`: Where the core bit-shifting functions are defined. This is the heart of the change, clearly. * `include/net/ip_tunnels.h`: Calls to the `skb_gso_fixedid_decap` function within the `iptunnel_pull_offloads` function, and this is important because it deals with removing the fixed ID. * `net/core/filter.c`: This file shows calls to both `skb_gso_fixedid_encap` and `skb_gso_fixedid_decap` within BPF-related functions, suggesting these changes are critical for BPF programs interacting with encapsulated packets. * `net/core/lwt_bpf.c`: This applies to `handle_gso_type`, so potentially related to BPF and LWT. * `net/ipv4/gre_offload.c`: and `net/ipv4/udp_offload.c` which now remove the assignment of encap\_level = 0. * `net/ipv4/ip_tunnel_core.c`: I see a call to `skb_gso_fixedid_encap` based on the state of `skb->encapsulation`, this is another key spot. * `net/ipv6/exthdrs.c`: Replacement with `iptunnel_pull_offloads` suggesting some ipv6 interaction. Now, ideally, I'd want to examine the commit log to understand the rationale behind these modifications. What problem is this patch solving? Is there a performance benefit? A security improvement? A bug fix? Normally, I'd just use `git log`, but it seems that I don't have access to that tool. I do have `grepper` and `read-file` which can hopefully give me some idea from the commit message. Without direct access to git log, I'm going to have to rely on `grepper` or `read-file` to get a sense of the surrounding context for each modified file to determine the commit message and understand the problem being solved. I'll need to carefully inspect the code itself to see how these changes integrate with the existing GSO functionality and potentially look for any impact on packet handling in different scenarios, especially encapsulated traffic. Finally I see there are selftests, `tcp_fixedid.c`, `tcp_fixedid.sh`, hopefully the tests are comprehensive! |
| 4/2 | 2026/11/01 22:46 | tool | grepper |
0mArgs:{
"Expression": "SKB_GSO_TCP_FIXEDID",
"PathPrefixes": [
"include/linux/skbuff.h",
"net/"
]
}Results: {
"Output": "include/linux/skbuff.h=674=enum {\n--\ninclude/linux/skbuff.h-682-\ninclude/linux/skbuff.h:683:\t__SKB_GSO_TCP_FIXEDID = 1 \u003c\u003c 3,\ninclude/linux/skbuff.h-684-\n--\ninclude/linux/skbuff.h-719-\t */\ninclude/linux/skbuff.h:720:\tSKB_GSO_TCP_FIXEDID = 1 \u003c\u003c 30,\ninclude/linux/skbuff.h:721:\tSKB_GSO_TCP_FIXEDID_INNER = 1 \u003c\u003c 31,\ninclude/linux/skbuff.h-722-};\n--\ninclude/linux/skbuff.h=5332=static inline void skb_decrease_gso_size(struct skb_shared_info *shinfo,\n--\ninclude/linux/skbuff.h-5343- *\ninclude/linux/skbuff.h:5344: * The IPv4 header that SKB_GSO_TCP_FIXEDID describes becomes the inner one,\ninclude/linux/skbuff.h-5345- * and the new outer header gets an incrementing ID.\n--\ninclude/linux/skbuff.h=5347=static inline void skb_gso_fixedid_encap(struct skb_shared_info *shinfo)\ninclude/linux/skbuff.h-5348-{\ninclude/linux/skbuff.h:5349:\tunsigned int fixedid = shinfo-\u003egso_type \u0026 SKB_GSO_TCP_FIXEDID;\ninclude/linux/skbuff.h-5350-\ninclude/linux/skbuff.h:5351:\tshinfo-\u003egso_type \u0026= ~(SKB_GSO_TCP_FIXEDID | SKB_GSO_TCP_FIXEDID_INNER);\ninclude/linux/skbuff.h-5352-\tshinfo-\u003egso_type |= fixedid \u003c\u003c 1;\n--\ninclude/linux/skbuff.h-5358- *\ninclude/linux/skbuff.h:5359: * The inner IPv4 header, which SKB_GSO_TCP_FIXEDID_INNER describes, becomes\ninclude/linux/skbuff.h-5360- * the outer one, and the state of the removed outer header is dropped.\n--\ninclude/linux/skbuff.h=5362=static inline void skb_gso_fixedid_decap(struct skb_shared_info *shinfo)\ninclude/linux/skbuff.h-5363-{\ninclude/linux/skbuff.h:5364:\tunsigned int fixedid = shinfo-\u003egso_type \u0026 SKB_GSO_TCP_FIXEDID_INNER;\ninclude/linux/skbuff.h-5365-\ninclude/linux/skbuff.h:5366:\tshinfo-\u003egso_type \u0026= ~(SKB_GSO_TCP_FIXEDID | SKB_GSO_TCP_FIXEDID_INNER);\ninclude/linux/skbuff.h-5367-\tshinfo-\u003egso_type |= fixedid \u003e\u003e 1;\n--\nnet/ipv4/af_inet.c=1362=struct sk_buff *inet_gso_segment(struct sk_buff *skb,\n--\nnet/ipv4/af_inet.c-1404-\nnet/ipv4/af_inet.c:1405:\tfixedid = !!(skb_shinfo(skb)-\u003egso_type \u0026 (SKB_GSO_TCP_FIXEDID \u003c\u003c encap));\nnet/ipv4/af_inet.c-1406-\n--\nnet/ipv4/tcp_offload.c=458=INDIRECT_CALLABLE_SCOPE int tcp4_gro_complete(struct sk_buff *skb, int thoff)\n--\nnet/ipv4/tcp_offload.c-475-\nnet/ipv4/tcp_offload.c:476:\tBUILD_BUG_ON(SKB_GSO_TCP_FIXEDID \u003c\u003c 1 != SKB_GSO_TCP_FIXEDID_INNER);\nnet/ipv4/tcp_offload.c-477-\tskb_shinfo(skb)-\u003egso_type |= SKB_GSO_TCPV4 |\nnet/ipv4/tcp_offload.c:478:\t\t\t(NAPI_GRO_CB(skb)-\u003eip_fixedid * SKB_GSO_TCP_FIXEDID);\nnet/ipv4/tcp_offload.c-479-\n"
} |
| 5/2 | 2026/11/01 22:46 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 17460 output: 39 thoughts: 95 Thoughts: Okay, here's my interpretation of those code snippets and where my mind went as an expert: **Understanding SKB_GSO_TCP_FIXEDID and Its Context** Right, so I see these definitions: `SKB_GSO_TCP_FIXEDID = 1 << 30` and `SKB_GSO_TCP_FIXEDID_INNER = 1 << 31`. I instantly recognize these are bit flags, likely used within a `sk_buff` structure (or similar) to control TCP segment offload. My immediate thought is, "What specifically are these flags controlling in the GSO process?" My intuition suggests the "FIXEDID" part is related to, perhaps, ensuring a consistent TCP identification (ID) across segmented packets. Given the context, this is most likely referring to Genera Segment Offload (GSO) functionality. I'm guessing `SKB_GSO_TCP_FIXEDID_INNER` might be for an inner header of a nested packet, or, possibly, related to some specialized TCP offload functionality. To get the full picture, I need to zoom in on how this is used within the kernel. My next step will be to head directly to `net/ipv4/af_inet.c:1400`. That's where I expect to find the meat of the implementation where these flags are set, checked, and used during the GSO or related offload operations. I'll read around that line, looking at the surrounding code to determine how the `fixedid` value and these flags play a part in constructing and sending TCP segments. I'm keen to understand the nuances of how the kernel manages these IDs and how it prevents potential issues with sequence numbers or reassembly at the receiver side. I suspect I might find some subtle optimizations or workarounds for specific NIC or driver behavior. |
| 6/2 | 2026/11/01 22:47 | tool | read-file |
0mArgs:{
"File": "net/ipv4/af_inet.c",
"FirstLine": 1395,
"LineCount": 40
}Results: {
"Contents": "1395:\t\n1396:\t\tencap = SKB_GSO_CB(skb)-\u003eencap_level \u003e 0;\n1397:\t\tif (encap)\n1398:\t\t\tfeatures \u0026= skb-\u003edev-\u003ehw_enc_features;\n1399:\t\tSKB_GSO_CB(skb)-\u003eencap_level += ihl;\n1400:\t\n1401:\t\tskb_reset_transport_header(skb);\n1402:\t\n1403:\t\tsegs = ERR_PTR(-EPROTONOSUPPORT);\n1404:\t\n1405:\t\tfixedid = !!(skb_shinfo(skb)-\u003egso_type \u0026 (SKB_GSO_TCP_FIXEDID \u003c\u003c encap));\n1406:\t\n1407:\t\tif (!skb-\u003eencapsulation || encap)\n1408:\t\t\tudpfrag = !!(skb_shinfo(skb)-\u003egso_type \u0026 SKB_GSO_UDP);\n1409:\t\n1410:\t\tops = rcu_dereference(inet_offloads[proto]);\n1411:\t\tif (likely(ops \u0026\u0026 ops-\u003ecallbacks.gso_segment)) {\n1412:\t\t\tsegs = ops-\u003ecallbacks.gso_segment(skb, features);\n1413:\t\t\tif (!segs)\n1414:\t\t\t\tskb-\u003enetwork_header = skb_mac_header(skb) + nhoff - skb-\u003ehead;\n1415:\t\t}\n1416:\t\n1417:\t\tif (IS_ERR_OR_NULL(segs))\n1418:\t\t\tgoto out;\n1419:\t\n1420:\t\tgso_partial = !!(skb_shinfo(segs)-\u003egso_type \u0026 SKB_GSO_PARTIAL);\n1421:\t\n1422:\t\tskb = segs;\n1423:\t\tdo {\n1424:\t\t\tiph = (struct iphdr *)(skb_mac_header(skb) + nhoff);\n1425:\t\t\tif (udpfrag) {\n1426:\t\t\t\tiph-\u003efrag_off = htons(offset \u003e\u003e 3);\n1427:\t\t\t\tif (skb-\u003enext)\n1428:\t\t\t\t\tiph-\u003efrag_off |= htons(IP_MF);\n1429:\t\t\t\toffset += skb-\u003elen - nhoff - ihl;\n1430:\t\t\t\ttot_len = skb-\u003elen - nhoff;\n1431:\t\t\t} else if (skb_is_gso(skb)) {\n1432:\t\t\t\tif (!fixedid) {\n1433:\t\t\t\t\tiph-\u003eid = htons(id);\n1434:\t\t\t\t\tid += skb_shinfo(skb)-\u003egso_segs;\n"
} |
| 7/2 | 2026/11/01 22:47 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 18705 output: 40 thoughts: 1395 Thoughts: **Analyzing GSO and Encapsulation Changes** Okay, let's dive into these code changes. I need to understand how Generic Segmentation Offload (GSO) interacts with encapsulation, particularly concerning how tunnel offloads are handled. First, I see the removal of `SKB_GSO_CB(skb)->encap_level = 0;` in `gre_offload.c` and `udp_offload.c`. This suggests a simplification in how the encapsulation level is tracked within the `sk_buff`'s control block, or a move to another method. I'll need to figure out what replaced it, or if it was removed in favor of something else. Then, there is an addition in `ipv6/exthdrs.c` where, before the encapsulation flag was set to zero, there is now a call to `iptunnel_pull_offloads(skb)`. This looks critical. Let me see... In `include/net/ip_tunnels.h`, the function definition reveals that it's essentially a mechanism to "decap" or remove the outer tunnel headers, especially when GSO is involved. It checks if the `skb` is GSO-capable, and if so, it attempts to unclone the `skb` (which likely deals with reference counting), and calls `skb_gso_fixedid_decap` if encapsulation is enabled. It then clears the GSO type flags related to encapsulation. This function is being called prior to setting `skb->encapsulation = 0;`. This signals that the GSO state must be dealt with before we reset the `skb->encapsulation`. I am going to have to check what `skb_gso_fixedid_decap` does. Let's now move on to `net/core/filter.c`. Here, in `bpf_skb_net_grow`, the code now conditionally calls `skb_gso_fixedid_encap` if `encap` is true. Here, the existing `skb_shinfo(skb)` is modified as well. This, in conjunction with the changes in `bpf_skb_net_shrink`, tells me this must be about maintaining the GSO state during packet processing within the BPF (Berkeley Packet Filter) context. In the shrink function, there is a check for `SKB_GSO_ESP` and the call to `skb_gso_fixedid_decap` seems related to handling ESP (Encapsulating Security Payload) packets, which are a common part of VPN setups. The `encapsulation` flag is then set to 0. Lastly, in `net/core/lwt_bpf.c` and `net/ipv4/ip_tunnel_core.c`, the new call `skb_gso_fixedid_encap` appears again. In `handle_gso_type`, it modifies `gso_type`. This is clearly related to BPF and LWT (Lightweight Tunnel) processing. It seems there is a consistent pattern to ensure that the GSO state is correctly managed, especially around encapsulation and decapsulation, within the BPF and LWT layers. In the tunnel core file, the addition of `skb_reset_inner_headers` is interesting: this call indicates a re-initialization of the inner headers within an encapsulated packet. This confirms the need to handle the inner header when using a tunnel, and it's being done while the `encapsulation` flag is set to 1. There is also a change to the `gso_type_mask` which is the value of the flags that can be set for GSO operations. I'll have to delve deeper into `skb_gso_fixedid_encap` and `skb_gso_fixedid_decap` to understand the low-level details of how they manage GSO's "fixed ID" feature. But the high-level picture is forming: these changes are about consistent and correct GSO handling across different layers (tunnels, BPF, LWT), ensuring encapsulation/decapsulation operations do not break GSO capabilities. It looks like it's a refactoring to ensure that GSO offloads work as expected when used in conjunction with tunnels and filtering. |
| 8/2 | 2026/11/01 22:47 | tool | read-file |
0mArgs:{
"File": "net/ipv4/ip_tunnel_core.c",
"FirstLine": 180,
"LineCount": 35
}Results: {
"Contents": " 180:\tEXPORT_SYMBOL_GPL(iptunnel_metadata_reply);\n 181:\t\n 182:\tint iptunnel_handle_offloads(struct sk_buff *skb,\n 183:\t\t\t\t int gso_type_mask)\n 184:\t{\n 185:\t\tbool encap = !skb-\u003eencapsulation;\n 186:\t\tint err;\n 187:\t\n 188:\t\tif (likely(encap)) {\n 189:\t\t\tskb_reset_inner_headers(skb);\n 190:\t\t\tskb-\u003eencapsulation = 1;\n 191:\t\t}\n 192:\t\n 193:\t\tif (skb_is_gso(skb)) {\n 194:\t\t\terr = skb_header_unclone(skb, GFP_ATOMIC);\n 195:\t\t\tif (unlikely(err))\n 196:\t\t\t\treturn err;\n 197:\t\t\tif (encap)\n 198:\t\t\t\tskb_gso_fixedid_encap(skb_shinfo(skb));\n 199:\t\t\tskb_shinfo(skb)-\u003egso_type |= gso_type_mask;\n 200:\t\t\treturn 0;\n 201:\t\t}\n 202:\t\n 203:\t\tif (skb-\u003eip_summed != CHECKSUM_PARTIAL) {\n 204:\t\t\tskb-\u003eip_summed = CHECKSUM_NONE;\n 205:\t\t\t/* We clear encapsulation here to prevent badly-written\n 206:\t\t\t * drivers potentially deciding to offload an inner checksum\n 207:\t\t\t * if we set CHECKSUM_PARTIAL on the outer header.\n 208:\t\t\t * This should go away when the drivers are all fixed.\n 209:\t\t\t */\n 210:\t\t\tskb-\u003eencapsulation = 0;\n 211:\t\t}\n 212:\t\n 213:\t\treturn 0;\n 214:\t}\n"
} |
| 9/2 | 2026/11/01 22:47 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 21608 output: 27 thoughts: 384 Thoughts: **Analyzing Potential Reachable Executable Code** Okay, let's dive into this. My initial thought is to figure out if this change actually touches any executable code we can reach. I need to understand the scope of this. Here's what I've identified in terms of subsystems that have been modified: * **`net/core/filter.c`**: Specifically, these BPF skb helpers, `bpf_skb_net_grow` and `bpf_skb_net_shrink`. They seem directly tied to `bpf_skb_adjust_room`. That's interesting, definitely a focal point. * **`net/core/lwt_bpf.c`**: The `handle_gso_type` function is here, which seems to play a role in LWT BPF encapsulation. This is important to consider in relation to the BPF helpers. * **`net/ipv4/gre_offload.c`**: This has `gre_gso_segment` which relates to GRE segmentation. This warrants scrutiny because the GSO segment code is a common source of bugs. * **`net/ipv4/udp_offload.c`**: Similarly, `__skb_udp_tunnel_segment` for UDP tunnel segmentation. More segmentation code, more things to look at. * **`net/ipv4/ip_tunnel_core.c`**: The function `iptunnel_handle_offloads` is in here. * **`include/net/ip_tunnels.h`**: We see `iptunnel_pull_offloads`, which is called by tunnel drivers, including IPv6 SRH. * **`net/ipv6/exthdrs.c`**: The IPv6 SRH and RPL SRH receive handling, with `ipv6_srh_rcv` and `ipv6_rpl_srh_rcv`. This is important, IPv6 is always worth looking at, especially with SRH. * **`include/linux/skbuff.h`**: Finally, `skb_gso_fixedid_encap` and `skb_gso_fixedid_decap` are defined here. Now, a critical observation. It looks like `SKB_GSO_CB(skb)->encap_level = 0;` was REMOVED in both `net/ipv4/gre_offload.c` and `net/ipv4/udp_offload.c`. Hmm. Why? What's the rationale behind this? I need to understand the implication of this removal. The next step is clear: I need to analyze how `encap_level` is used across the kernel. This is essential to understanding the intent of the change and if there are any subtle side effects. |
| 10/2 | 2026/11/01 22:47 | tool | grepper |
0mArgs:{
"Expression": "encap_level",
"PathPrefixes": [
"net/"
]
}Results: {
"Output": "net/core/gso.c=90=struct sk_buff *__skb_gso_segment(struct sk_buff *skb,\n--\nnet/core/gso.c-121-\tSKB_GSO_CB(skb)-\u003emac_offset = skb_headroom(skb);\nnet/core/gso.c:122:\tSKB_GSO_CB(skb)-\u003eencap_level = 0;\nnet/core/gso.c-123-\tSKB_GSO_CB(skb)-\u003erecursion_counter = 0;\n--\nnet/ipv4/af_inet.c=1362=struct sk_buff *inet_gso_segment(struct sk_buff *skb,\n--\nnet/ipv4/af_inet.c-1395-\nnet/ipv4/af_inet.c:1396:\tencap = SKB_GSO_CB(skb)-\u003eencap_level \u003e 0;\nnet/ipv4/af_inet.c-1397-\tif (encap)\nnet/ipv4/af_inet.c-1398-\t\tfeatures \u0026= skb-\u003edev-\u003ehw_enc_features;\nnet/ipv4/af_inet.c:1399:\tSKB_GSO_CB(skb)-\u003eencap_level += ihl;\nnet/ipv4/af_inet.c-1400-\n--\nnet/ipv6/ip6_offload.c=92=static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,\n--\nnet/ipv6/ip6_offload.c-114-\nnet/ipv6/ip6_offload.c:115:\tencap = SKB_GSO_CB(skb)-\u003eencap_level \u003e 0;\nnet/ipv6/ip6_offload.c-116-\tif (encap)\nnet/ipv6/ip6_offload.c-117-\t\tfeatures \u0026= skb-\u003edev-\u003ehw_enc_features;\nnet/ipv6/ip6_offload.c:118:\tSKB_GSO_CB(skb)-\u003eencap_level += sizeof(*ipv6h);\nnet/ipv6/ip6_offload.c-119-\n"
} |
| 11/2 | 2026/11/01 22:47 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 23210 output: 48 thoughts: 885 Thoughts: **GSO/Tunnel Encapsulation/Decapsulation: A Critical Change** Okay, so I've been digging into this, and it looks like `gre_gso_segment` and `__skb_udp_tunnel_segment` were incorrectly resetting `SKB_GSO_CB(skb)->encap_level` to zero. Because of that, `inet_gso_segment` wasn't behaving as expected on the inner packet. Specifically, the check for `fixedid` was broken. Now that I see it, by removing the reset, `encap_level` remains non-zero, correctly reflecting that the packet is encapsulated. Consequently, the logic for `fixedid` works as expected for inner IPv4 segments, checking `SKB_GSO_TCP_FIXEDID_INNER`. The `skb_gso_fixedid_encap()` and `skb_gso_fixedid_decap()` functions are shifting the `SKB_GSO_TCP_FIXEDID` flag correctly between inner and outer packets during encapsulation and decapsulation! Then, in IPv6 SRH decapsulation, things are significantly improved. It's no longer just a simple reset of `skb->encapsulation`. Now, `iptunnel_pull_offloads(skb)` is called, which is *much* more comprehensive. It considers whether the packet is a GSO packet, unclones the SKB if necessary, calls `skb_gso_fixedid_decap` if `skb->encapsulation` is set, and properly strips off the `NETIF_F_GSO_ENCAP_ALL >> NETIF_F_GSO_SHIFT` flag from `gso_type`. Plus, it checks the return code of `iptunnel_pull_offloads` and properly handles failures. That's good defensive programming! This is a fundamental shift in how GSO interacts with tunnel encapsulation/decapsulation! It touches the very core of networking: net/core/, net/ipv4/, net/ipv6/, and even BPF. I'm thinking this is easily reachable in standard virtualized environments. Any packet sending GSO packets through tunnels like vxlan, gre, ipip, geneve, fou, etc., or BPF programs utilizing `bpf_skb_adjust_room`, or IPv6 SRH packets will hit this code path. No specialized hardware is needed since it's all software-based - tunnels and virtual devices are standard. So, *definitely* worth fuzzing. The next steps are: 1. Figure out the required configs to compile and reach this code. 2. Identify the correct focus symbols for efficient fuzzing. 3. Document the reasoning behind these configurations and focus symbols. I'll start checking the configs by looking for these files and the relevant Makefile and Kconfig entries: - `bpf_skb_net_grow` / `bpf_skb_net_shrink` in `net/core/filter.c` - `lwt_bpf` in `net/core/lwt_bpf.c` - `gre_offload.c` in `net/ipv4/gre_offload.c` - `ip_tunnel_core.c` in `net/ipv4/ip_tunnel_core.c` - `udp_offload.c` in `net/ipv4/udp_offload.c` - `exthdrs.c` in `net/ipv6/exthdrs.c` |
| 12/2 | 2026/11/01 22:47 | tool | grepper |
0mArgs:{
"Expression": "(gre_offload|ip_tunnel_core|udp_offload|lwt_bpf)\\.o",
"PathPrefixes": [
"net/"
]
}Results: {
"Output": "net/core/Makefile=38=obj-$(CONFIG_LWTUNNEL) += lwtunnel.o\nnet/core/Makefile:39:obj-$(CONFIG_LWTUNNEL_BPF) += lwt_bpf.o\nnet/core/Makefile-40-obj-$(CONFIG_DST_CACHE) += dst_cache.o\n--\nnet/ipv4/Makefile=6=obj-y := route.o inetpeer.o protocol.o \\\n--\nnet/ipv4/Makefile-13-\t tcp_offload.o tcp_plb.o datagram.o raw.o udp.o \\\nnet/ipv4/Makefile:14:\t udp_offload.o arp.o icmp.o devinet.o af_inet.o igmp.o \\\nnet/ipv4/Makefile-15-\t fib_frontend.o fib_semantics.o fib_trie.o fib_notifier.o \\\nnet/ipv4/Makefile:16:\t inet_fragment.o ping.o ip_tunnel_core.o gre_offload.o \\\nnet/ipv4/Makefile-17-\t metrics.o netlink.o nexthop.o udp_tunnel_stub.o\n--\nnet/ipv6/Makefile=8=ipv6-y :=\taf_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.o \\\n--\nnet/ipv6/Makefile-12-\t\texthdrs.o datagram.o ip6_flowlabel.o inet6_connection_sock.o \\\nnet/ipv6/Makefile:13:\t\tudp_offload.o seg6.o fib6_notifier.o rpl.o ioam6.o\nnet/ipv6/Makefile-14-\n"
} |
| 13/2 | 2026/11/01 22:47 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 25356 output: 31 thoughts: 115 Thoughts: **Examining the IPv4 Tunneling Infrastructure** Okay, let's dive into the IPv4 networking code, specifically the `net/ipv4/Makefile`. Right, so I see `ip_tunnel_core.o`, `gre_offload.o`, and `udp_offload.o` are all directly included in `obj-y`. That's expected, given their core roles in handling tunneling. Interesting, and as expected, `exthdrs.o` is under `ipv6-y`, which is governed by `CONFIG_IPV6`. Makes perfect sense. Now, `lwt_bpf.o` catches my eye; it's conditionalized by `CONFIG_LWTUNNEL_BPF`. I need to understand that dependency fully. Time to check `Kconfig` to see what else enables or requires that specific option. Let's see what's what. |
| 14/2 | 2026/11/01 22:47 | tool | grepper |
0mArgs:{
"Expression": "config LWTUNNEL_BPF",
"PathPrefixes": [
"net/"
]
}Results: {
"Output": "net/Kconfig=444=config LWTUNNEL\n--\nnet/Kconfig-451-\nnet/Kconfig:452:config LWTUNNEL_BPF\nnet/Kconfig-453-\tbool \"Execute BPF program as route nexthop action\"\n"
} |
| 15/2 | 2026/11/01 22:47 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 25776 output: 32 thoughts: 17 Thoughts: Okay, here's my interpretation of that thought process, assuming I'm an expert in this field, rendered in the first person: **Diving into the Kernel Configuration Landscape** Right, let's get down to brass tacks. I'm thinking we need to delve into `net/Kconfig`, specifically around line 452. Given my experience, that location likely houses some critical network configuration options. I'm probably looking for something specific, maybe related to a particular network protocol, a new feature I need to understand, or a problem I'm trying to debug within the network subsystem. I'm already visualizing the structure of the Kconfig file – the dependencies, the help text, the default values, all of it. Knowing the general layout of the file, this should allow me to hone in on the exact location I need to understand. Let's see what we can dig up. |
| 16/2 | 2026/11/01 22:48 | tool | read-file |
0mArgs:{
"File": "net/Kconfig",
"FirstLine": 444,
"LineCount": 25
}Results: {
"Contents": " 444:\tconfig LWTUNNEL\n 445:\t\tbool \"Network light weight tunnels\"\n 446:\t\thelp\n 447:\t\t This feature provides an infrastructure to support light weight\n 448:\t\t tunnels like mpls. There is no netdevice associated with a light\n 449:\t\t weight tunnel endpoint. Tunnel encapsulation parameters are stored\n 450:\t\t with light weight tunnel state associated with fib routes.\n 451:\t\n 452:\tconfig LWTUNNEL_BPF\n 453:\t\tbool \"Execute BPF program as route nexthop action\"\n 454:\t\tdepends on LWTUNNEL \u0026\u0026 INET\n 455:\t\tdefault y if LWTUNNEL=y\n 456:\t\thelp\n 457:\t\t Allows to run BPF programs as a nexthop action following a route\n 458:\t\t lookup for incoming and outgoing packets.\n 459:\t\n 460:\tconfig DST_CACHE\n 461:\t\tbool\n 462:\t\tdefault n\n 463:\t\n 464:\tconfig GRO_CELLS\n 465:\t\tbool\n 466:\t\tdefault n\n 467:\t\n 468:\tconfig SOCK_VALIDATE_XMIT\n"
} |
| 17/2 | 2026/11/01 22:48 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 26352 output: 44 thoughts: 85 Thoughts: Okay, let's take a look at IPv6 SRH and RPL configurations within the kernel. I need to refresh my memory on where these are handled, so I'll start by checking the `net/ipv6/Kconfig` file. I'm expecting to find the relevant configurations there, specifically looking for `ipv6_srh_rcv` and `ipv6_rpl_srh_rcv`. Based on my understanding, the actual implementations, the code that deals with handling these extension headers, should be in `net/ipv6/exthdrs.c`. I need to confirm where the code is defined, and especially what preprocessor directives are being used, so that I can understand any conditional compilation or dependencies that affect their availability. I'll need to carefully inspect the ifdefs surrounding the functions within `net/ipv6/exthdrs.c` to see how the code is enabled. |
| 18/2 | 2026/11/01 22:48 | tool | grepper |
0mArgs:{
"Expression": "ipv6_(rpl_)?srh_rcv",
"PathPrefixes": [
"net/ipv6/exthdrs.c"
]
}Results: {
"Output": "net/ipv6/exthdrs.c=343=static void seg6_update_csum(struct sk_buff *skb)\n--\nnet/ipv6/exthdrs.c-371-\nnet/ipv6/exthdrs.c:372:static int ipv6_srh_rcv(struct sk_buff *skb, struct inet6_dev *idev)\nnet/ipv6/exthdrs.c-373-{\n--\nnet/ipv6/exthdrs.c-484-\nnet/ipv6/exthdrs.c:485:static int ipv6_rpl_srh_rcv(struct sk_buff *skb, struct inet6_dev *idev)\nnet/ipv6/exthdrs.c-486-{\n--\nnet/ipv6/exthdrs.c=652=static int ipv6_rthdr_rcv(struct sk_buff *skb)\n--\nnet/ipv6/exthdrs.c-690-\t\t\tgoto disabled;\nnet/ipv6/exthdrs.c:691:\t\treturn ipv6_srh_rcv(skb, idev);\nnet/ipv6/exthdrs.c-692-\tcase IPV6_SRCRT_TYPE_3:\n--\nnet/ipv6/exthdrs.c-695-\t\t\tgoto disabled;\nnet/ipv6/exthdrs.c:696:\t\treturn ipv6_rpl_srh_rcv(skb, idev);\nnet/ipv6/exthdrs.c-697-\tdefault:\n"
} |
| 19/2 | 2026/11/01 22:48 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 27092 output: 39 thoughts: 74 Thoughts: Here's my thought process, as it stands: **Examining IPv6 Source Routing Header Handling** Okay, so I need to quickly refresh my memory on how the kernel handles the Source Routing Header (SRH) for IPv6. I suspect there might be conditional compilation involved, perhaps based on some feature flag or kernel configuration. My immediate plan is to zero in on the `ipv6_srh_rcv` function, and the file I'm going to check is `net/ipv6/exthdrs.c`. Specifically, I'm going to look for any `#ifdef` blocks that might conditionally include or exclude the code related to that function. To get a good overview, I think I'll zero in on a few specific line ranges. The area around lines 365-375 seems like a reasonable place to start, as it's likely to deal with the primary processing logic. Then, I'll also want to read around lines 480-490. This likely handles, the actual receiving, or some other aspects related to reception and processing. By examining these sections, I should get a quick grasp of how the kernel manages IPv6 SRH reception, especially the conditional aspects. |
| 20/2 | 2026/11/01 22:48 | tool | read-file |
0mArgs:{
"File": "net/ipv6/exthdrs.c",
"FirstLine": 365,
"LineCount": 20
}Results: {
"Contents": " 365:\t\n 366:\t\t/* compute csum diff between current and next segment and update */\n 367:\t\n 368:\t\tupdate_csum_diff16(skb, (__be32 *)(\u0026ipv6_hdr(skb)-\u003edaddr),\n 369:\t\t\t\t (__be32 *)addr);\n 370:\t}\n 371:\t\n 372:\tstatic int ipv6_srh_rcv(struct sk_buff *skb, struct inet6_dev *idev)\n 373:\t{\n 374:\t\tstruct inet6_skb_parm *opt = IP6CB(skb);\n 375:\t\tstruct net *net = dev_net(skb-\u003edev);\n 376:\t\tstruct ipv6_sr_hdr *hdr;\n 377:\t\tstruct in6_addr *addr;\n 378:\t\tint accept_seg6;\n 379:\t\n 380:\t\thdr = (struct ipv6_sr_hdr *)skb_transport_header(skb);\n 381:\t\n 382:\t\taccept_seg6 = min(READ_ONCE(net-\u003eipv6.devconf_all-\u003eseg6_enabled),\n 383:\t\t\t\t READ_ONCE(idev-\u003ecnf.seg6_enabled));\n 384:\t\n"
} |
| 21/2 | 2026/11/01 22:48 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 27817 output: 36 thoughts: 72 Thoughts: Here's my thought process, as it stands: **Debugging the IPv6 Segment Routing Header Handling** Okay, so I'm digging into this code around line 365, and I need to figure out what's going on with the IPv6 Segment Routing Header. My initial thought is to quickly see if there are any conditional compilation blocks, specifically `#ifdef` directives, around that line that might be influencing its behavior. I know how tricky these can be. Maybe it's all part of a larger configuration issue. Next, I'll check if the code depends on a configuration option like `CONFIG_IPV6_SEG6_LWTUNNEL` or something related. That's a good place to start. A quick grep will tell the story. Finally, just to be thorough and because it's good practice, I need to look for any references to the functions/variables involved. I need to grep the `net/ipv6/exthdrs.c` file for `ipv6_srh_rcv` or the keyword `SEG6` (since that's the technology we're dealing with). This should give me a good overview of the surrounding code and potentially lead me to the root cause of the issue. A systematic approach is always best. |
| 22/2 | 2026/11/01 22:48 | tool | grepper |
0mArgs:{
"Expression": "CONFIG_IPV6",
"PathPrefixes": [
"net/ipv6/exthdrs.c"
]
}Results: {
"Output": "net/ipv6/exthdrs.c-42-#include \u003cnet/calipso.h\u003e\nnet/ipv6/exthdrs.c:43:#if IS_ENABLED(CONFIG_IPV6_MIP6)\nnet/ipv6/exthdrs.c-44-#include \u003cnet/xfrm.h\u003e\n--\nnet/ipv6/exthdrs.c-47-#include \u003cnet/seg6.h\u003e\nnet/ipv6/exthdrs.c:48:#ifdef CONFIG_IPV6_SEG6_HMAC\nnet/ipv6/exthdrs.c-49-#include \u003cnet/seg6_hmac.h\u003e\n--\nnet/ipv6/exthdrs.c=108=static bool ipv6_hop_calipso(struct sk_buff *skb, int optoff);\nnet/ipv6/exthdrs.c:109:#if IS_ENABLED(CONFIG_IPV6_MIP6)\nnet/ipv6/exthdrs.c-110-static bool ipv6_dest_hao(struct sk_buff *skb, int optoff);\n--\nnet/ipv6/exthdrs.c=115=static bool ip6_parse_tlv(bool hopbyhop,\n--\nnet/ipv6/exthdrs.c-198-\t\t\t\tswitch (nh[off]) {\nnet/ipv6/exthdrs.c:199:#if IS_ENABLED(CONFIG_IPV6_MIP6)\nnet/ipv6/exthdrs.c-200-\t\t\t\tcase IPV6_TLV_HAO:\n--\nnet/ipv6/exthdrs.c-231-\nnet/ipv6/exthdrs.c:232:#if IS_ENABLED(CONFIG_IPV6_MIP6)\nnet/ipv6/exthdrs.c-233-static bool ipv6_dest_hao(struct sk_buff *skb, int optoff)\n--\nnet/ipv6/exthdrs.c=297=static int ipv6_destopt_rcv(struct sk_buff *skb)\n--\nnet/ipv6/exthdrs.c-300-\tstruct inet6_skb_parm *opt = IP6CB(skb);\nnet/ipv6/exthdrs.c:301:#if IS_ENABLED(CONFIG_IPV6_MIP6)\nnet/ipv6/exthdrs.c-302-\t__u16 dstbuf;\n--\nnet/ipv6/exthdrs.c-322-\topt-\u003elastopt = opt-\u003edst1 = skb_network_header_len(skb);\nnet/ipv6/exthdrs.c:323:#if IS_ENABLED(CONFIG_IPV6_MIP6)\nnet/ipv6/exthdrs.c-324-\tdstbuf = opt-\u003edst1;\n--\nnet/ipv6/exthdrs.c-330-\t\topt = IP6CB(skb);\nnet/ipv6/exthdrs.c:331:#if IS_ENABLED(CONFIG_IPV6_MIP6)\nnet/ipv6/exthdrs.c-332-\t\topt-\u003enhoff = dstbuf;\n--\nnet/ipv6/exthdrs.c=372=static int ipv6_srh_rcv(struct sk_buff *skb, struct inet6_dev *idev)\n--\nnet/ipv6/exthdrs.c-389-\nnet/ipv6/exthdrs.c:390:#ifdef CONFIG_IPV6_SEG6_HMAC\nnet/ipv6/exthdrs.c-391-\tif (!seg6_hmac_validate_skb(skb, hdr)) {\n--\nnet/ipv6/exthdrs.c=652=static int ipv6_rthdr_rcv(struct sk_buff *skb)\n--\nnet/ipv6/exthdrs.c-703-\t\tswitch (hdr-\u003etype) {\nnet/ipv6/exthdrs.c:704:#if IS_ENABLED(CONFIG_IPV6_MIP6)\nnet/ipv6/exthdrs.c-705-\t\tcase IPV6_SRCRT_TYPE_2:\n--\nnet/ipv6/exthdrs.c-729-\tswitch (hdr-\u003etype) {\nnet/ipv6/exthdrs.c:730:#if IS_ENABLED(CONFIG_IPV6_MIP6)\nnet/ipv6/exthdrs.c-731-\tcase IPV6_SRCRT_TYPE_2:\n--\nnet/ipv6/exthdrs.c-784-\tswitch (hdr-\u003etype) {\nnet/ipv6/exthdrs.c:785:#if IS_ENABLED(CONFIG_IPV6_MIP6)\nnet/ipv6/exthdrs.c-786-\tcase IPV6_SRCRT_TYPE_2:\n--\nnet/ipv6/exthdrs.c=1131=static u8 ipv6_push_rthdr4(struct sk_buff *skb, u8 proto,\n--\nnet/ipv6/exthdrs.c-1159-\nnet/ipv6/exthdrs.c:1160:#ifdef CONFIG_IPV6_SEG6_HMAC\nnet/ipv6/exthdrs.c-1161-\tif (sr_has_hmac(sr_phdr)) {\n"
} |
| 23/2 | 2026/11/01 22:48 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 29565 output: 35 thoughts: 79 Thoughts: Okay, here's my summary, considering my expertise: **Examining IPv6 and Tunneling Configuration Dependencies** Alright, let's see. My initial thought process revolves around simplifying configurations, which I'm always looking to do. Specifically, I'm noting that the `ipv6_srh_rcv` and `ipv6_rpl_srh_rcv` functions, seemingly related to Source Routing Header (SRH) processing in IPv6, only require `CONFIG_IPV6` to be enabled. That makes intuitive sense; no surprises there. But now, my attention shifts to `iptunnel_pull_offloads`. I remember that function. It's declared in `include/net/ip_tunnels.h`, so it's clearly involved with tunneling functionality, probably handling some form of hardware offload. I immediately wonder about its configuration dependencies. I'm going to want to track down what calls this function to get a good understanding of what other options might need to be enabled alongside it. I want to make sure I don't introduce any unnecessary dependencies, or miss any that are required. I'll need to dig into the call sites of `iptunnel_pull_offloads` and see where it's actually being used. |
| 24/2 | 2026/11/01 22:48 | tool | grepper |
0mArgs:{
"Expression": "iptunnel_pull_offloads",
"PathPrefixes": [
"net/",
"include/"
]
}Results: {
"Output": "include/net/ip_tunnels.h=658=int iptunnel_handle_offloads(struct sk_buff *skb, int gso_type_mask);\ninclude/net/ip_tunnels.h-659-\ninclude/net/ip_tunnels.h:660:static inline int iptunnel_pull_offloads(struct sk_buff *skb)\ninclude/net/ip_tunnels.h-661-{\n--\nnet/ipv4/fou_core.c=56=static int fou_recv_pull(struct sk_buff *skb, struct fou *fou, size_t len)\n--\nnet/ipv4/fou_core.c-69-\tskb_reset_transport_header(skb);\nnet/ipv4/fou_core.c:70:\treturn iptunnel_pull_offloads(skb);\nnet/ipv4/fou_core.c-71-}\n--\nnet/ipv4/fou_core.c=120=static int gue_udp_recv(struct sock *sk, struct sk_buff *skb)\n--\nnet/ipv4/fou_core.c-223-\nnet/ipv4/fou_core.c:224:\tif (iptunnel_pull_offloads(skb))\nnet/ipv4/fou_core.c-225-\t\tgoto drop;\n--\nnet/ipv4/ip_tunnel_core.c=110=__iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\n--\nnet/ipv4/ip_tunnel_core.c-142-\nnet/ipv4/ip_tunnel_core.c:143:\tif (unlikely(iptunnel_pull_offloads(skb)))\nnet/ipv4/ip_tunnel_core.c-144-\t\treturn SKB_DROP_REASON_NOMEM;\n--\nnet/ipv6/exthdrs.c=372=static int ipv6_srh_rcv(struct sk_buff *skb, struct inet6_dev *idev)\n--\nnet/ipv6/exthdrs.c-409-\t\t\tskb_reset_transport_header(skb);\nnet/ipv6/exthdrs.c:410:\t\t\tif (iptunnel_pull_offloads(skb)) {\nnet/ipv6/exthdrs.c-411-\t\t\t\tkfree_skb(skb);\n--\nnet/ipv6/exthdrs.c=485=static int ipv6_rpl_srh_rcv(struct sk_buff *skb, struct inet6_dev *idev)\n--\nnet/ipv6/exthdrs.c-519-\t\t\tskb_reset_transport_header(skb);\nnet/ipv6/exthdrs.c:520:\t\t\tif (iptunnel_pull_offloads(skb)) {\nnet/ipv6/exthdrs.c-521-\t\t\t\tkfree_skb(skb);\n--\nnet/ipv6/seg6_local.c=230=static bool decap_and_validate(struct sk_buff *skb, int proto)\n--\nnet/ipv6/seg6_local.c-253-\tskb_reset_transport_header(skb);\nnet/ipv6/seg6_local.c:254:\tif (iptunnel_pull_offloads(skb))\nnet/ipv6/seg6_local.c-255-\t\treturn false;\n"
} |
| 25/2 | 2026/11/01 22:48 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 30816 output: 37 thoughts: 162 Thoughts: Here's my analysis of the provided code references: **Offload Handling in the Tunneling Subsystem** Okay, so I'm looking at how offload functionality is integrated within the tunneling code. The core function, `iptunnel_pull_offloads`, seems to be the central point for handling incoming packets for various tunneling protocols. It's used within a number of different functions, and I'll need to understand the relationship between each of these calling functions and offload handling. Specifically, `iptunnel_pull_offloads` is directly invoked within: * `fou_recv_pull` (for FOU tunnel receive): This is expected; FOU needs offload support. * `gue_udp_recv` (GUE UDP receive): Again, a valid use case for Generic UDP Encapsulation. * `__iptunnel_pull_header` (used by IPIP, GRE, etc. in `ip_tunnel_core.c` and `ip_tunnel.c`): This makes sense, given that IPIP, GRE, and similar protocols are built upon the common tunneling infrastructure. * `ipv6_srh_rcv` / `ipv6_rpl_srh_rcv`: This suggests that Segment Routing Header (SRH) and RPL (Routing Protocol for Low-Power and Lossy Networks) are also integrating with the offload mechanisms. That's good to know. * `decap_and_validate` in `net/ipv6/seg6_local.c`: Another SRH related function, this one dealing with decap and validation. My next step is to examine where `iptunnel_handle_offloads` is called. Let me grep for that function, to get the call tree from the other side. That will reveal the mechanism for _issuing_ offload requests, which, when coupled with the receiver side, provides a full picture of the ofload control and use mechanism. |
| 26/2 | 2026/11/01 22:48 | tool | grepper |
0mArgs:{
"Expression": "iptunnel_handle_offloads",
"PathPrefixes": [
"net/",
"drivers/net/"
]
}Results: {
"Output": "drivers/net/vxlan/vxlan_core.c=2239=static int vxlan_build_skb(struct sk_buff *skb, struct dst_entry *dst,\n--\ndrivers/net/vxlan/vxlan_core.c-2270-\tdouble_encap = udp_tunnel_handle_partial(skb);\ndrivers/net/vxlan/vxlan_core.c:2271:\terr = iptunnel_handle_offloads(skb, type);\ndrivers/net/vxlan/vxlan_core.c-2272-\tif (err)\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=180=EXPORT_SYMBOL_GPL(iptunnel_metadata_reply);\nnet/ipv4/ip_tunnel_core.c-181-\nnet/ipv4/ip_tunnel_core.c:182:int iptunnel_handle_offloads(struct sk_buff *skb,\nnet/ipv4/ip_tunnel_core.c-183-\t\t\t int gso_type_mask)\n--\nnet/ipv4/ip_tunnel_core.c-214-}\nnet/ipv4/ip_tunnel_core.c:215:EXPORT_SYMBOL_GPL(iptunnel_handle_offloads);\nnet/ipv4/ip_tunnel_core.c-216-\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=591=static int nf_flow_tunnel_ip_push(struct net *net, struct sk_buff *skb,\n--\nnet/netfilter/nf_flow_table_ip.c-621-\nnet/netfilter/nf_flow_table_ip.c:622:\terr = iptunnel_handle_offloads(skb, SKB_GSO_IPXIP4);\nnet/netfilter/nf_flow_table_ip.c-623-\tif (err)\n--\nnet/netfilter/nf_flow_table_ip.c=659=static int nf_flow_tunnel_ip6_push(struct net *net, struct sk_buff *skb,\n--\nnet/netfilter/nf_flow_table_ip.c-690-\nnet/netfilter/nf_flow_table_ip.c:691:\terr = iptunnel_handle_offloads(skb, SKB_GSO_IPXIP6);\nnet/netfilter/nf_flow_table_ip.c-692-\tif (err)\n"
} |
| 27/2 | 2026/11/01 22:48 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 33469 output: 37 thoughts: 97 Thoughts: Okay, here's my take on those thoughts, framed from my expert perspective: **Deep Dive into Offload Handling and BPF Interaction** Alright, let's break this down. My mind immediately flags `iptunnel_handle_offloads`. Seeing its usage across a diverse set of tunneling protocols – VXLAN, FOU, GRE (IPv4 and IPv6 variations), even SEG6, SIT, and IPVS, plus potentially NFT – tells me this function is *crucial* to packet processing efficiency in the kernel's network stack, particularly when dealing with tunneling. I need to understand its role in hardware offload capabilities. This is where the magic happens, or can fail spectacularly if not handled carefully. Now, that line of thought inevitably draws my attention to BPF. I recall that `bpf_skb_net_grow` and `bpf_skb_net_shrink` functions in `net/core/filter.c` are key to how BPF programs manipulate network buffers. My next move is clear. I must examine which BPF helper calls those functions. Understanding the connection between these two areas, the offload handling and the BPF manipulation of SKBs, gives me the complete picture and the opportunity to enhance performance, efficiency, and perhaps address some specific networking issues. I'm keen to see if any offload-specific handling interacts with BPF here, or even if BPF is being used to *control* the offload behavior itself. This investigation holds the potential to unlock optimization opportunities, or maybe even to identify subtle bugs lurking within the offload path. |
| 28/2 | 2026/11/01 22:48 | tool | grepper |
0mArgs:{
"Expression": "bpf_skb_net_(grow|shrink)",
"PathPrefixes": [
"net/core/"
]
}Results: {
"Output": "net/core/filter.c=3577=static u32 bpf_skb_net_base_len(const struct sk_buff *skb)\n--\nnet/core/filter.c-3616-\nnet/core/filter.c:3617:static int bpf_skb_net_grow(struct sk_buff *skb, u32 off, u32 len_diff,\nnet/core/filter.c-3618-\t\t\t u64 flags)\n--\nnet/core/filter.c-3742-\nnet/core/filter.c:3743:static int bpf_skb_net_shrink(struct sk_buff *skb, u32 off, u32 len_diff,\nnet/core/filter.c-3744-\t\t\t u64 flags)\n--\nnet/core/filter.c=3879=BPF_CALL_4(bpf_skb_adjust_room, struct sk_buff *, skb, s32, len_diff,\n--\nnet/core/filter.c-3964-\nnet/core/filter.c:3965:\tret = shrink ? bpf_skb_net_shrink(skb, off, len_diff_abs, flags) :\nnet/core/filter.c:3966:\t\t bpf_skb_net_grow(skb, off, len_diff_abs, flags);\nnet/core/filter.c-3967-\tif (!ret \u0026\u0026 !(flags \u0026 BPF_F_ADJ_ROOM_NO_CSUM_RESET))\n"
} |
| 29/2 | 2026/11/01 22:48 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 34339 output: 38 thoughts: 88 Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience: **Analyzing `bpf_skb_adjust_room` and GSO Handling** Right, let me break this down. My initial thought process is centered around `bpf_skb_adjust_room`. I know that this function, critical for manipulating SKB data, leverages `bpf_skb_net_shrink` and `bpf_skb_net_grow` internally. It's a natural progression – adjust the room, shrink if you have to, grow if you need more. Classic. Now, my attention immediately shifts. I see the mention of `handle_gso_type` within `net/core/lwt_bpf.c`. This triggers a deeper dive, as I need to figure out how this function fits into the equation. My mental checklist kicks in: What specifically *calls* `handle_gso_type`? I need to understand its relationship to the BPF operations, and how it's integrated with Generic Segmentation Offload (GSO). Is it being used for fragmentation, reassembly, or something else entirely? Understanding the calling context is key to grasping the overall flow. Time to trace those calls and see what context it's being used in. |
| 30/2 | 2026/11/01 22:48 | tool | grepper |
0mArgs:{
"Expression": "handle_gso_type",
"PathPrefixes": [
"net/core/lwt_bpf.c"
]
}Results: {
"Output": "net/core/lwt_bpf.c=525=static const struct lwtunnel_encap_ops bpf_encap_ops = {\n--\nnet/core/lwt_bpf.c-536-\nnet/core/lwt_bpf.c:537:static int handle_gso_type(struct sk_buff *skb, unsigned int gso_type,\nnet/core/lwt_bpf.c-538-\t\t\t int encap_len)\n--\nnet/core/lwt_bpf.c=550=static int handle_gso_encap(struct sk_buff *skb, bool ipv4, int encap_len)\n--\nnet/core/lwt_bpf.c-556-\t/* SCTP and UDP_L4 gso need more nuanced handling than what\nnet/core/lwt_bpf.c:557:\t * handle_gso_type() does above: skb_decrease_gso_size() is not enough.\nnet/core/lwt_bpf.c-558-\t * So at the moment only TCP GSO packets are let through.\n--\nnet/core/lwt_bpf.c-579-\t\tif (((struct gre_base_hdr *)next_hdr)-\u003eflags \u0026 GRE_CSUM)\nnet/core/lwt_bpf.c:580:\t\t\treturn handle_gso_type(skb, SKB_GSO_GRE_CSUM,\nnet/core/lwt_bpf.c-581-\t\t\t\t\t encap_len);\nnet/core/lwt_bpf.c:582:\t\treturn handle_gso_type(skb, SKB_GSO_GRE, encap_len);\nnet/core/lwt_bpf.c-583-\n--\nnet/core/lwt_bpf.c-589-\t\tif (((struct udphdr *)next_hdr)-\u003echeck)\nnet/core/lwt_bpf.c:590:\t\t\treturn handle_gso_type(skb, SKB_GSO_UDP_TUNNEL_CSUM,\nnet/core/lwt_bpf.c-591-\t\t\t\t\t encap_len);\nnet/core/lwt_bpf.c:592:\t\treturn handle_gso_type(skb, SKB_GSO_UDP_TUNNEL, encap_len);\nnet/core/lwt_bpf.c-593-\n--\nnet/core/lwt_bpf.c-596-\t\tif (ipv4)\nnet/core/lwt_bpf.c:597:\t\t\treturn handle_gso_type(skb, SKB_GSO_IPXIP4, encap_len);\nnet/core/lwt_bpf.c-598-\t\telse\nnet/core/lwt_bpf.c:599:\t\t\treturn handle_gso_type(skb, SKB_GSO_IPXIP6, encap_len);\nnet/core/lwt_bpf.c-600-\n"
} |
| 31/2 | 2026/11/01 22:48 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 35506 output: 32 thoughts: 839 Thoughts: **Analyzing GSO/UFO Patch Implications** Alright, let's break this down. The first thing that jumps out is the removal of `SKB_GSO_CB(skb)->encap_level = 0;` in both `gre_gso_segment` and `__skb_udp_tunnel_segment`. This is immediately interesting, as this is a key part of how GSO/UFO offloading handles encapsulated packets. Then I recall that `inet_gso_segment` leverages the `encap_level` to determine whether to check `SKB_GSO_TCP_FIXEDID` or `SKB_GSO_TCP_FIXEDID_INNER`. Next, I need to understand the implications of this change and how it impacts the interaction with `skb_gso_fixedid_encap` and `skb_gso_fixedid_decap`. These are inline functions, so I'll need to focus on where they're *called* rather than their direct definitions. The documentation states that this is the best approach for coverage filters. So, let's see where they're actually used. `skb_gso_fixedid_encap` is called by `bpf_skb_net_grow`, which in turn is called by `bpf_skb_adjust_room`, and also by `handle_gso_type` via `handle_gso_encap` through `bpf_lwt_xmit_reroute` and `bpf_lwt_xmit`. More importantly, `iptunnel_handle_offloads` also uses it. Given its EXPORT_SYMBOL_GPL status, this is critical, as any change to its behaviour must be considered carefully. Now, for `skb_gso_fixedid_decap`. It's called by `iptunnel_pull_offloads`, and this looks like a critical point. `iptunnel_pull_offloads` in turn is called by `ipv6_srh_rcv`, `ipv6_rpl_srh_rcv`, and internal tunnel functions, plus `fou_recv_pull` / `gue_udp_recv`. I also see `bpf_skb_net_shrink`, again through `bpf_skb_adjust_room`. So, this function is critical. This leads me to the question of what these functions do, and why this is being impacted. I need to dig into the details of these callers and their interaction with the network stack. I'll need to trace the paths of encapsulated packets, focusing on those using GSO/UFO, and see if the removal of `encap_level = 0` causes any regressions. The patch also modifies `gre_gso_segment` and `__skb_udp_tunnel_segment`. I need to understand the relationship between these and the changes to the `encap_level`, and what the impact is. Finally, I should check whether `__skb_udp_tunnel_segment` in `net/ipv4/udp_offload.c` is static or exported, and where it is called. That could be very important as a direct link between the new changes. |
| 32/2 | 2026/11/01 22:49 | tool | grepper |
0mArgs:{
"Expression": "__skb_udp_tunnel_segment",
"PathPrefixes": [
"net/"
]
}Results: {
"Output": "net/ipv4/udp_offload.c=163=static struct sk_buff *udp_tunnel_gro_rcv(struct sock *sk,\n--\nnet/ipv4/udp_offload.c-171-\nnet/ipv4/udp_offload.c:172:static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,\nnet/ipv4/udp_offload.c-173-\tnetdev_features_t features,\n--\nnet/ipv4/udp_offload.c=310=struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb,\n--\nnet/ipv4/udp_offload.c-338-\nnet/ipv4/udp_offload.c:339:\tsegs = __skb_udp_tunnel_segment(skb, features, gso_inner_segment,\nnet/ipv4/udp_offload.c-340-\t\t\t\t\tprotocol, is_ipv6);\n"
} |
| 33/2 | 2026/11/01 22:49 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 37340 output: 29 thoughts: 53 Thoughts: Here's my summary, as though I'm thinking through this process: **Investigating UDP Tunnel Segmentation and GRE GSO** Okay, so `skb_udp_tunnel_segment` is the function we need to focus on, and that's over in `net/ipv4/udp_offload.c`. Got it. Now, given that, let's pivot and see how GRE is handling Generic Segmentation Offload (GSO). The logical next step is to examine `gre_gso_segment`. That function should be in `net/ipv4/gre_offload.c`. I'm curious to see how the segmentation logic compares, especially considering the tunneling context. This comparison will likely reveal useful optimizations or considerations. |
| 34/2 | 2026/11/01 22:49 | tool | grepper |
0mArgs:{
"Expression": "gre_gso_segment",
"PathPrefixes": [
"net/"
]
}Results: {
"Output": "net/ipv4/gre_offload.c-15-\nnet/ipv4/gre_offload.c:16:static struct sk_buff *gre_gso_segment(struct sk_buff *skb,\nnet/ipv4/gre_offload.c-17-\t\t\t\t netdev_features_t features)\n--\nnet/ipv4/gre_offload.c=262=static const struct net_offload gre_offload = {\nnet/ipv4/gre_offload.c-263-\t.callbacks = {\nnet/ipv4/gre_offload.c:264:\t\t.gso_segment = gre_gso_segment,\nnet/ipv4/gre_offload.c-265-\t\t.gro_receive = gre_gro_receive,\n"
} |
| 35/2 | 2026/11/01 22:49 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 37785 output: 37 thoughts: 221 Thoughts: **Investigating BPF SKB Room Adjustment** Okay, let's dive into this. My initial focus is on how we're handling SKB room adjustments within the BPF framework. I need to understand the relationship between `bpf_skb_net_grow`, `bpf_skb_net_shrink`, and especially `bpf_skb_adjust_room`. The key here is to determine their accessibility. Are they directly available symbols within `vmlinux`, or are we dealing with something defined differently? First things first, I'm going to quickly verify their presence, or lack thereof, within the kernel symbol table. Then, since `bpf_skb_adjust_room` seems central, I should grep for `BPF_CALL_4(bpf_skb_adjust_room` within `net/core/filter.c` to see how it's actually defined. Ah, right, that macro expands to `___bpf_skb_adjust_room` and the "cleaner" `bpf_skb_adjust_room`. So I will need to take this into account. Lastly, I need to check the scope of those `bpf_skb_net_*` functions. Are they static or inlined? This will be crucial to understand how they are called and what options are available when using them in BPF programs. This detail will provide insight into whether they can be easily invoked by BPF programs or if they are subject to optimization by the kernel in ways that could influence BPF program behavior. |
| 36/2 | 2026/11/01 22:49 | tool | grepper |
0mArgs:{
"Expression": "bpf_skb_net_grow",
"PathPrefixes": [
"net/core/filter.c"
]
}Results: {
"Output": "net/core/filter.c=3577=static u32 bpf_skb_net_base_len(const struct sk_buff *skb)\n--\nnet/core/filter.c-3616-\nnet/core/filter.c:3617:static int bpf_skb_net_grow(struct sk_buff *skb, u32 off, u32 len_diff,\nnet/core/filter.c-3618-\t\t\t u64 flags)\n--\nnet/core/filter.c=3879=BPF_CALL_4(bpf_skb_adjust_room, struct sk_buff *, skb, s32, len_diff,\n--\nnet/core/filter.c-3965-\tret = shrink ? bpf_skb_net_shrink(skb, off, len_diff_abs, flags) :\nnet/core/filter.c:3966:\t\t bpf_skb_net_grow(skb, off, len_diff_abs, flags);\nnet/core/filter.c-3967-\tif (!ret \u0026\u0026 !(flags \u0026 BPF_F_ADJ_ROOM_NO_CSUM_RESET))\n"
} |
| 37/2 | 2026/11/01 22:49 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 38680 output: 39 thoughts: 38 Thoughts: Okay, let's dive into this. Here's my summary, presented as my own thought process: **Diving into the BPF Encapsulation Logic** Right, so we're dealing with encapsulated traffic, probably with BPF involved, and I need to understand how the Linux kernel handles it. My initial focus is on where this encapsulation actually *happens* within the network stack. Given the context, the two key functions that spring to mind are `bpf_lwt_xmit` and `handle_gso_encap`. They are likely at the heart of this process. It seems like the `lwt_bpf.c` file is probably the place where the BPF logic for lightweight tunnels (LWT) resides, so that's where I need to start. I'll need to confirm that those functions are doing what I think they are, which is to implement a fast path for encapsulated packets. |
| 38/2 | 2026/11/01 22:49 | tool | grepper |
0mArgs:{
"Expression": "handle_gso_encap",
"PathPrefixes": [
"net/core/lwt_bpf.c"
]
}Results: {
"Output": "net/core/lwt_bpf.c=537=static int handle_gso_type(struct sk_buff *skb, unsigned int gso_type,\n--\nnet/core/lwt_bpf.c-549-\nnet/core/lwt_bpf.c:550:static int handle_gso_encap(struct sk_buff *skb, bool ipv4, int encap_len)\nnet/core/lwt_bpf.c-551-{\n--\nnet/core/lwt_bpf.c=606=int bpf_lwt_push_ip_encap(struct sk_buff *skb, void *hdr, u32 len, bool ingress)\n--\nnet/core/lwt_bpf.c-673-\tif (skb_is_gso(skb))\nnet/core/lwt_bpf.c:674:\t\treturn handle_gso_encap(skb, ipv4, len);\nnet/core/lwt_bpf.c-675-\n"
} |
| 39/2 | 2026/11/01 22:49 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 39226 output: 35 thoughts: 56 Thoughts: Here's my take on the situation: **Investigating the `bpf_lwt_push_ip_encap` Function** Okay, so `bpf_lwt_push_ip_encap` is *not* a static function, indicated by its declaration, `int bpf_lwt_push_ip_encap`. That means it's got external linkage, and it's visible outside its current compilation unit. That fact alone doesn't necessarily raise a red flag, but it *does* mean we need to understand where it's being used. Now, let's trace its callsites. I need to figure out the context in which this function is being invoked to truly understand its role and potential impact within the system. |
| 40/2 | 2026/11/01 22:49 | tool | grepper |
0mArgs:{
"Expression": "bpf_lwt_push_ip_encap",
"PathPrefixes": [
"net/"
]
}Results: {
"Output": "net/core/filter.c=6947=static int bpf_push_ip_encap(struct sk_buff *skb, void *hdr, u32 len,\n--\nnet/core/filter.c-6949-{\nnet/core/filter.c:6950:\treturn bpf_lwt_push_ip_encap(skb, hdr, len, ingress);\nnet/core/filter.c-6951-}\n--\nnet/core/lwt_bpf.c=182=static int bpf_lwt_xmit_reroute(struct sk_buff *skb)\n--\nnet/core/lwt_bpf.c-251-\nnet/core/lwt_bpf.c:252:\t/* Although skb header was reserved in bpf_lwt_push_ip_encap(), it\nnet/core/lwt_bpf.c-253-\t * was done for the previous dst, so we are doing it here again, in\n--\nnet/core/lwt_bpf.c=550=static int handle_gso_encap(struct sk_buff *skb, bool ipv4, int encap_len)\n--\nnet/core/lwt_bpf.c-605-\nnet/core/lwt_bpf.c:606:int bpf_lwt_push_ip_encap(struct sk_buff *skb, void *hdr, u32 len, bool ingress)\nnet/core/lwt_bpf.c-607-{\n"
} |
| 41/2 | 2026/11/01 22:49 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 39871 output: 37 thoughts: 31 Thoughts: Here's my analysis of the provided thought process, summarized as you requested: **Deconstructing `bpf_push_ip_encap` Usage** Okay, so I see a call to `bpf_push_ip_encap` within `net/core/filter.c`. My immediate thought is, "Where *else* is this function being used? What's the call graph look like?" I need to understand the context and the potential side effects of this function, so tracing back the calls is crucial. I want to identify all the points in the system where encapsulation is being performed via BPF and understand the control flow that leads to it. Understanding the call chain will tell me about its purpose and potential vulnerabilities. I need to know the origin and understand how it interacts with other parts of the network stack. Let's dig in and figure out who is calling this thing. |
| 42/2 | 2026/11/01 22:49 | tool | grepper |
0mArgs:{
"Expression": "bpf_push_ip_encap",
"PathPrefixes": [
"net/core/filter.c"
]
}Results: {
"Output": "net/core/filter.c=6912=static int bpf_push_seg6_encap(struct sk_buff *skb, u32 type, void *hdr, u32 len)\n--\nnet/core/filter.c-6946-#if IS_ENABLED(CONFIG_LWTUNNEL_BPF)\nnet/core/filter.c:6947:static int bpf_push_ip_encap(struct sk_buff *skb, void *hdr, u32 len,\nnet/core/filter.c-6948-\t\t\t bool ingress)\n--\nnet/core/filter.c=6954=BPF_CALL_4(bpf_lwt_in_push_encap, struct sk_buff *, skb, u32, type, void *, hdr,\n--\nnet/core/filter.c-6964-\tcase BPF_LWT_ENCAP_IP:\nnet/core/filter.c:6965:\t\treturn bpf_push_ip_encap(skb, hdr, len, true /* ingress */);\nnet/core/filter.c-6966-#endif\n--\nnet/core/filter.c=6972=BPF_CALL_4(bpf_lwt_xmit_push_encap, struct sk_buff *, skb, u32, type,\n--\nnet/core/filter.c-6977-\tcase BPF_LWT_ENCAP_IP:\nnet/core/filter.c:6978:\t\treturn bpf_push_ip_encap(skb, hdr, len, false /* egress */);\nnet/core/filter.c-6979-#endif\n"
} |
| 43/2 | 2026/11/01 22:49 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 40549 output: 34 thoughts: 275 Thoughts: **My Mental Map of BPF LWT Encapsulation** Okay, so I'm thinking about BPF LWT encapsulation and tracing its path. *`bpf_lwt_push_ip_encap`* seems to be the obvious starting point – it's the direct entrypoint. Now, let's follow the breadcrumbs. In `ip_tunnel_core.c`, I see *`iptunnel_handle_offloads`*. That's likely involved. Then, over in `exthdrs.c`, I find *`ipv6_srh_rcv`* and *`ipv6_rpl_srh_rcv`* related to IPv6 headers, which could be part of the encapsulation/decapsulation process. Moving on to `gre_offload.c`, I spot *`gre_gso_segment`*, suggesting GSO support for GRE tunnels in this context. And in `udp_offload.c`, I see *`skb_udp_tunnel_segment`* (and the inline version *`__skb_udp_tunnel_segment`*), dealing with UDP tunnels and segmentation. Now, let's consider the BPF-related pieces within the kernel network stack, as I can't leave those untouched. In `net/core/filter.c` I see *`bpf_skb_net_grow`*, *`bpf_skb_net_shrink`*, and the helper *`bpf_skb_adjust_room`*. These functions are fundamental for manipulating skb buffers. And, of course, the interesting inline function *`iptunnel_pull_offloads`* is in `include/net/ip_tunnels.h`. Although static inline, it's called by `__iptunnel_pull_header` in `ip_tunnel_core.c`. This could be useful for examining what the offload process is. So I'll go back and check *`__iptunnel_pull_header`* and *`iptunnel_pull_header`* in a moment, to get a clear picture of their relationship. |
| 44/2 | 2026/11/01 22:49 | tool | grepper |
0mArgs:{
"Expression": "iptunnel_pull_header",
"PathPrefixes": [
"net/",
"include/"
]
}Results: {
"Output": "include/net/ip_tunnels.h=617=enum skb_drop_reason\ninclude/net/ip_tunnels.h:618:__iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\ninclude/net/ip_tunnels.h-619-\t\t __be16 inner_proto, bool raw_proto, bool xnet);\n--\ninclude/net/ip_tunnels.h=621=static inline enum skb_drop_reason\ninclude/net/ip_tunnels.h:622:iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\ninclude/net/ip_tunnels.h-623-\t\t __be16 inner_proto, bool xnet)\ninclude/net/ip_tunnels.h-624-{\ninclude/net/ip_tunnels.h:625:\treturn __iptunnel_pull_header(skb, hdr_len, inner_proto, false, xnet);\ninclude/net/ip_tunnels.h-626-}\n--\ninclude/net/udp.h=632=static inline void udp_post_segment_fix_csum(struct sk_buff *skb)\n--\ninclude/net/udp.h-638-\t * can reach an UDP socket with CHECKSUM_NONE, because\ninclude/net/udp.h:639:\t * __iptunnel_pull_header() converts CHECKSUM_PARTIAL into NONE.\ninclude/net/udp.h-640-\t * SKB_GSO_UDP_L4 or SKB_GSO_FRAGLIST packets with no UDP tunnel will\n--\nnet/ipv4/ip_gre.c=267=static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n--\nnet/ipv4/ip_gre.c-311-\nnet/ipv4/ip_gre.c:312:\t\tif (__iptunnel_pull_header(skb,\nnet/ipv4/ip_gre.c-313-\t\t\t\t\t len,\n--\nnet/ipv4/ip_gre.c-336-\nnet/ipv4/ip_gre.c:337:\t\t\t/* skb can be uncloned in __iptunnel_pull_header, so\nnet/ipv4/ip_gre.c-338-\t\t\t * old pkt_md is no longer valid and we need to reset\n--\nnet/ipv4/ip_gre.c=366=static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,\n--\nnet/ipv4/ip_gre.c-379-\nnet/ipv4/ip_gre.c:380:\t\tif (__iptunnel_pull_header(skb, hdr_len, tpi-\u003eproto,\nnet/ipv4/ip_gre.c-381-\t\t\t\t\t raw_proto, false))\n--\nnet/ipv4/ip_tunnel_core.c=109=enum skb_drop_reason\nnet/ipv4/ip_tunnel_core.c:110:__iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\nnet/ipv4/ip_tunnel_core.c-111-\t\t __be16 inner_proto, bool raw_proto, bool xnet)\n--\nnet/ipv4/ip_tunnel_core.c-147-}\nnet/ipv4/ip_tunnel_core.c:148:EXPORT_SYMBOL_GPL(__iptunnel_pull_header);\nnet/ipv4/ip_tunnel_core.c-149-\n--\nnet/ipv4/ipip.c=215=static int ipip_tunnel_rcv(struct sk_buff *skb, u8 ipproto)\n--\nnet/ipv4/ipip.c-243-\t\t\ttpi = \u0026ipip_tpi;\nnet/ipv4/ipip.c:244:\t\tif (iptunnel_pull_header(skb, 0, tpi-\u003eproto, false))\nnet/ipv4/ipip.c-245-\t\t\tgoto drop;\n--\nnet/ipv6/ip6_gre.c=487=static int ip6erspan_rcv(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-512-\nnet/ipv6/ip6_gre.c:513:\t\tif (__iptunnel_pull_header(skb, len,\nnet/ipv6/ip6_gre.c-514-\t\t\t\t\t htons(ETH_P_TEB),\n--\nnet/ipv6/ip6_gre.c-538-\nnet/ipv6/ip6_gre.c:539:\t\t\t/* skb can be uncloned in __iptunnel_pull_header, so\nnet/ipv6/ip6_gre.c-540-\t\t\t * old pkt_md is no longer valid and we need to reset\n--\nnet/ipv6/ip6_gre.c=567=static int gre_rcv(struct sk_buff *skb)\n--\nnet/ipv6/ip6_gre.c-576-\nnet/ipv6/ip6_gre.c:577:\tif (iptunnel_pull_header(skb, hdr_len, tpi.proto, false))\nnet/ipv6/ip6_gre.c-578-\t\tgoto drop;\n--\nnet/ipv6/ip6_tunnel.c=938=static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,\n--\nnet/ipv6/ip6_tunnel.c-961-\t\t\tgoto drop;\nnet/ipv6/ip6_tunnel.c:962:\t\tif (iptunnel_pull_header(skb, 0, tpi-\u003eproto, false))\nnet/ipv6/ip6_tunnel.c-963-\t\t\tgoto drop;\n--\nnet/ipv6/sit.c=738=static int ipip6_rcv(struct sk_buff *skb)\n--\nnet/ipv6/sit.c-765-\nnet/ipv6/sit.c:766:\t\tif (iptunnel_pull_header(skb, 0, htons(ETH_P_IPV6),\nnet/ipv6/sit.c-767-\t\t !net_eq(tunnel-\u003enet, dev_net(tunnel-\u003edev))))\n--\nnet/ipv6/sit.c-769-\nnet/ipv6/sit.c:770:\t\t/* skb can be uncloned in iptunnel_pull_header, so\nnet/ipv6/sit.c-771-\t\t * old iph is no longer valid\n--\nnet/ipv6/sit.c=814=static int sit_tunnel_rcv(struct sk_buff *skb, u8 ipproto)\n--\nnet/ipv6/sit.c-841-\t\t\ttpi = \u0026ipip_tpi;\nnet/ipv6/sit.c:842:\t\tif (iptunnel_pull_header(skb, 0, tpi-\u003eproto, false))\nnet/ipv6/sit.c-843-\t\t\tgoto drop;\n"
} |
| 45/2 | 2026/11/01 22:49 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 43115 output: 30 thoughts: 244 Thoughts: **Configuration Verification for IPv6 SRH Handling** Okay, so I need to make sure all the necessary configurations are in place. First things first, I'll confirm that the basics are covered: `CONFIG_INET` for IPv4 is a given, obviously. Then, I need to verify that `CONFIG_IPV6` is enabled, as this should handle the core IPv6 SRH functionality, specifically in `net/ipv6/exthdrs.c`. I also need to make sure `CONFIG_LWTUNNEL_BPF` is configured, which I know is in `net/core/lwt_bpf.c`, and also standard configurations, `CONFIG_BPF_SYSCALL` and `CONFIG_NET`. Now, I want to double-check my understanding. I need to know for sure what controls the `ipv6_srh_rcv` function. Is `CONFIG_IPV6` sufficient, or am I missing something? Let me quickly revisit `net/ipv6/exthdrs.c`. Ah, right, `ipv6_srh_rcv` is called by `ipv6_rthdr_rcv`, which is indeed compiled when `CONFIG_IPV6` is enabled. Seems straightforward. Hold on a second, though. I should probably be thorough. I'm wondering if there's a more specific config, something like `CONFIG_IPV6_SEG6_LWTUNNEL`, that might enable SRH functionality independently. Is there some subtle dependency I'm missing? I'll grep for `seg6_enabled` within the `net/ipv6/` directory to make absolutely sure. Better safe than sorry. |
| 46/2 | 2026/11/01 22:49 | tool | grepper |
0mArgs:{
"Expression": "seg6_enabled",
"PathPrefixes": [
"net/ipv6/"
]
}Results: {
"Output": "net/ipv6/addrconf.c=181=static struct ipv6_devconf ipv6_devconf __read_mostly = {\n--\nnet/ipv6/addrconf.c-228-\t.keep_addr_on_down\t= 0,\nnet/ipv6/addrconf.c:229:\t.seg6_enabled\t\t= 0,\nnet/ipv6/addrconf.c-230-#ifdef CONFIG_IPV6_SEG6_HMAC\n--\nnet/ipv6/addrconf.c=246=static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {\n--\nnet/ipv6/addrconf.c-293-\t.keep_addr_on_down\t= 0,\nnet/ipv6/addrconf.c:294:\t.seg6_enabled\t\t= 0,\nnet/ipv6/addrconf.c-295-#ifdef CONFIG_IPV6_SEG6_HMAC\n--\nnet/ipv6/addrconf.c=5689=static void ipv6_store_devconf(const struct ipv6_devconf *cnf,\n--\nnet/ipv6/addrconf.c-5762-\tarray[DEVCONF_KEEP_ADDR_ON_DOWN] = READ_ONCE(cnf-\u003ekeep_addr_on_down);\nnet/ipv6/addrconf.c:5763:\tarray[DEVCONF_SEG6_ENABLED] = READ_ONCE(cnf-\u003eseg6_enabled);\nnet/ipv6/addrconf.c-5764-#ifdef CONFIG_IPV6_SEG6_HMAC\n--\nnet/ipv6/addrconf.c=6874=static const struct ctl_table addrconf_sysctl[] = {\n--\nnet/ipv6/addrconf.c-7244-\t{\nnet/ipv6/addrconf.c:7245:\t\t.procname\t= \"seg6_enabled\",\nnet/ipv6/addrconf.c:7246:\t\t.data\t\t= \u0026ipv6_devconf.seg6_enabled,\nnet/ipv6/addrconf.c-7247-\t\t.maxlen\t\t= sizeof(int),\n--\nnet/ipv6/exthdrs.c=372=static int ipv6_srh_rcv(struct sk_buff *skb, struct inet6_dev *idev)\n--\nnet/ipv6/exthdrs.c-381-\nnet/ipv6/exthdrs.c:382:\taccept_seg6 = min(READ_ONCE(net-\u003eipv6.devconf_all-\u003eseg6_enabled),\nnet/ipv6/exthdrs.c:383:\t\t\t READ_ONCE(idev-\u003ecnf.seg6_enabled));\nnet/ipv6/exthdrs.c-384-\n"
} |
| 47/2 | 2026/11/01 22:49 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 44451 output: 30 thoughts: 69 Thoughts: Here's my summary, as I'm thinking through this: **Investigating IPv6 Tunnel Configuration** Okay, so `seg6_enabled` is definitely tied to `ipv6_devconf`, and that's built in if IPv6 itself is enabled – straightforward enough. But now I'm wondering about the *broader* implications for tunneling. Specifically, I need to understand if `CONFIG_NET_IP_TUNNEL` or even just the base `CONFIG_INET` might somehow influence or conflict with this IPv6 configuration or any related tunnel functionality. To get a clear picture, let's dive into the `net/ipv4/Kconfig` file and take a look at how `CONFIG_NET_IP_TUNNEL` is defined and what it depends on, because that seems like the most relevant place to start unraveling this. I need to make sure I've got a complete understanding. |
| 48/2 | 2026/11/01 22:49 | tool | grepper |
0mArgs:{
"Expression": "config NET_IP_TUNNEL",
"PathPrefixes": [
"net/"
]
}Results: {
"Output": "net/ipv4/Kconfig=180=config NET_IPGRE_DEMUX\n--\nnet/ipv4/Kconfig-185-\nnet/ipv4/Kconfig:186:config NET_IP_TUNNEL\nnet/ipv4/Kconfig-187-\ttristate\n"
} |
| 49/2 | 2026/11/01 22:49 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 44828 output: 37 thoughts: 14 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience and presented in the first person: **Investigating NET_IP_TUNNEL Configuration** Alright, let's dive into this. My immediate thought is, "What specifically *leverages* `NET_IP_TUNNEL`?" I need to understand the practical applications and dependencies associated with this configuration option. Knowing *what* utilizes it is crucial before I start poking around. I'm thinking, this could be anything from simple GRE tunnels to more complex setups involving VXLAN or even advanced routing protocols using encapsulation. I need to refresh my memory on any recent developments in networking that rely on tunneling and see if that jogs any specific areas of interest. The kernel documentation is always a good starting point, but I'm looking for the implementation details that actually *use* this flag, not just the description. It's time to follow the code paths. |
| 50/2 | 2026/11/01 22:49 | tool | grepper |
0mArgs:{
"Expression": "select NET_IP_TUNNEL",
"PathPrefixes": [
"net/",
"drivers/net/"
]
}Results: {
"Output": "net/ipv4/Kconfig=162=config NET_IPIP\n--\nnet/ipv4/Kconfig-164-\tselect INET_TUNNEL\nnet/ipv4/Kconfig:165:\tselect NET_IP_TUNNEL\nnet/ipv4/Kconfig-166-\thelp\n--\nnet/ipv4/Kconfig=192=config NET_IPGRE\n--\nnet/ipv4/Kconfig-194-\tdepends on NET_IPGRE_DEMUX\nnet/ipv4/Kconfig:195:\tselect NET_IP_TUNNEL\nnet/ipv4/Kconfig-196-\thelp\n--\nnet/ipv4/Kconfig=304=config NET_IPVTI\n--\nnet/ipv4/Kconfig-306-\tselect INET_TUNNEL\nnet/ipv4/Kconfig:307:\tselect NET_IP_TUNNEL\nnet/ipv4/Kconfig-308-\tselect XFRM\n--\nnet/ipv4/Kconfig=316=config NET_UDP_TUNNEL\nnet/ipv4/Kconfig-317-\ttristate\nnet/ipv4/Kconfig:318:\tselect NET_IP_TUNNEL\nnet/ipv4/Kconfig-319-\tdefault n\n--\nnet/ipv6/Kconfig=150=config IPV6_VTI\n--\nnet/ipv6/Kconfig-152-\tselect IPV6_TUNNEL\nnet/ipv6/Kconfig:153:\tselect NET_IP_TUNNEL\nnet/ipv6/Kconfig-154-\tselect XFRM\n--\nnet/ipv6/Kconfig=162=config IPV6_SIT\n--\nnet/ipv6/Kconfig-164-\tselect INET_TUNNEL\nnet/ipv6/Kconfig:165:\tselect NET_IP_TUNNEL\nnet/ipv6/Kconfig-166-\tselect IPV6_NDISC_NODETYPE\n--\nnet/ipv6/Kconfig=210=config IPV6_GRE\n--\nnet/ipv6/Kconfig-212-\tselect IPV6_TUNNEL\nnet/ipv6/Kconfig:213:\tselect NET_IP_TUNNEL\nnet/ipv6/Kconfig-214-\tdepends on NET_IPGRE_DEMUX\n"
} |
| 51/2 | 2026/11/01 22:49 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 45660 output: 343 thoughts: 3243 Thoughts: **Analysis of Kernel Configuration and Focus Symbols for Tunneling and GSO Logic** Okay, let's break this down. My goal here is to identify the critical kernel configurations and specific function entry points relevant to the recent patch concerning GSO (Generic Segmentation Offload) and tunnel handling, particularly around IPv4 fixed IDs. I'm focusing on providing the fuzzer with the most targeted information, avoiding ubiquitous functions, and ensuring that any changes to static inline functions are addressed by referencing their callers. First, I looked at which components within the kernel utilize the `ip_tunnel_core.o` object, since that is a focus of the patch. It seems that if IPv4 is enabled (`CONFIG_INET`), it's unconditionally compiled in. After reviewing `net/ipv4/Makefile`, I see that `ip_tunnel_core.c`, along with `gre_offload.c`, and `udp_offload.c` are unconditionally compiled if `CONFIG_INET` is set. Also, `CONFIG_LWTUNNEL_BPF` enables `lwt_bpf.c` and `CONFIG_BPF_SYSCALL` is also needed for BPF. `CONFIG_IPV6` for `net/ipv6/exthdrs.c`. Then, I identified the potentially relevant tunnel driver configurations: `CONFIG_NET_IP_TUNNEL`, `CONFIG_NET_IPIP`, `CONFIG_NET_IPGRE`, and `CONFIG_VXLAN`. Per the instructions, I need to list the relevant configs, stripping the `CONFIG_` prefix. Here's the list of configs, after examining the dependencies and Kconfig files: - `INET` - `IPV6` - `LWTUNNEL_BPF` - `BPF_SYSCALL` - `NET_IPGRE` - `NET_IPIP` - `VXLAN` Now, let's zero in on the key functions to fuzz, given the patch's impact on encapsulation, decapsulation, and GSO offloads. I've pinpointed the entry points, focusing on those directly involved in the altered logic. They are: - `iptunnel_handle_offloads` - `__iptunnel_pull_header` - `gre_gso_segment` - `skb_udp_tunnel_segment` - `bpf_skb_net_grow` - `bpf_skb_net_shrink` - `bpf_lwt_push_ip_encap` - `ipv6_srh_rcv` - `ipv6_rpl_srh_rcv` I verified that none of these are ubiquitous lifecycle functions; they are all specific to either tunnel logic or relevant BPF actions and that any static inlines are called by these specific functions. I also confirmed that even though some of these functions may call inlined static functions, they are visible symbols, so they can be identified, and that including them and their callers provides greater robustness. Next, I need to understand what this patch is fixing. My analysis reveals it is correcting issues with how `SKB_GSO_TCP_FIXEDID` is handled during encapsulation and decapsulation, especially in scenarios with multiple layers of tunneling and when TCP packets are aggregated by GRO. It also adjusts BPF logic. Specifically: 1. The patch fixes a missing shift of `SKB_GSO_TCP_FIXEDID` to `SKB_GSO_TCP_FIXEDID_INNER` during encapsulation. 2. It addresses incorrect `encap_level` resets in `gre_gso_segment` and `__skb_udp_tunnel_segment`. 3. It adds the correct shift back during decapsulation. 4. It corrects missing calls to `iptunnel_pull_offloads` in the `ipv6_srh_rcv` path. I'm now thinking about potential regressions and edge cases. Removing `SKB_GSO_CB(skb)->encap_level = 0` could introduce problems if we have *nested* tunnel encapsulations, and I'm watching this. The use of `skb_unclone` in the `ipv6_srh_rcv` case is another potential problem. Now, my configurations list and the focus symbols are: **FocusSymbols:** * `iptunnel_handle_offloads` * `__iptunnel_pull_header` * `gre_gso_segment` * `skb_udp_tunnel_segment` * `bpf_skb_net_grow |
| 52/2 | 2026/11/01 22:50 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"INET",
"IPV6",
"NET_IPGRE",
"NET_IPIP",
"VXLAN",
"LWTUNNEL_BPF",
"BPF_SYSCALL"
],
"FocusSymbols": [
"iptunnel_handle_offloads",
"__iptunnel_pull_header",
"gre_gso_segment",
"skb_udp_tunnel_segment",
"bpf_skb_net_grow",
"bpf_skb_net_shrink",
"bpf_lwt_push_ip_encap",
"ipv6_srh_rcv",
"ipv6_rpl_srh_rcv"
],
"Reasoning": "The patch modifies core networking GSO offload handling across tunnel encapsulation and decapsulation paths, as well as BPF room adjustment helpers (bpf_skb_net_grow, bpf_skb_net_shrink) and IPv6 Segment Routing (SRH/RPL SRH). Specifically, it manages shifting of SKB_GSO_TCP_FIXEDID and SKB_GSO_TCP_FIXEDID_INNER flags on encap/decap and removes encap_level resets in GRE and UDP tunnel segmentation. These changes alter packet transformations, unclone logic, and segmentation invariant handling across reachable virtual networking devices (veth, tunnels, VXLAN) and BPF programs, making it valuable to fuzz for crashes, memory corruption, or incorrect packet handling.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"INET",
"IPV6",
"NET_IPGRE",
"NET_IPIP",
"VXLAN",
"LWTUNNEL_BPF",
"BPF_SYSCALL"
],
"FocusSymbols": [
"iptunnel_handle_offloads",
"__iptunnel_pull_header",
"gre_gso_segment",
"skb_udp_tunnel_segment",
"bpf_skb_net_grow",
"bpf_skb_net_shrink",
"bpf_lwt_push_ip_encap",
"ipv6_srh_rcv",
"ipv6_rpl_srh_rcv"
],
"Reasoning": "The patch modifies core networking GSO offload handling across tunnel encapsulation and decapsulation paths, as well as BPF room adjustment helpers (bpf_skb_net_grow, bpf_skb_net_shrink) and IPv6 Segment Routing (SRH/RPL SRH). Specifically, it manages shifting of SKB_GSO_TCP_FIXEDID and SKB_GSO_TCP_FIXEDID_INNER flags on encap/decap and removes encap_level resets in GRE and UDP tunnel segmentation. These changes alter packet transformations, unclone logic, and segmentation invariant handling across reachable virtual networking devices (veth, tunnels, VXLAN) and BPF programs, making it valuable to fuzz for crashes, memory corruption, or incorrect packet handling.",
"WorthFuzzing": true
} |
| 53/1 | 2026/11/01 22:50 | action | If |
1mArgs:{
"WorthFuzzing": true
}Results: null |
| 54/2 | 2026/11/01 22:50 | agent | kmsan-evaluator |
1mModel:core Args: null Results: {
"KMSANReasoning": "The patch series introduces helper functions (skb_gso_fixedid_encap, skb_gso_fixedid_decap) to properly update GSO flags (SKB_GSO_TCP_FIXEDID and SKB_GSO_TCP_FIXEDID_INNER) when packets are encapsulated or decapsulated across tunnel offloads, BPF packet adjustments, and SRv6 processing. It also preserves SKB_GSO_CB(skb)-\u003eencap_level across GRE/UDP tunnel segmentation so inner GSO segmentation recognizes encapsulation.\n\nNone of these changes allocate uninitialized buffers, introduce uninitialized fields, or expose uninitialized kernel memory to user space. All manipulated fields (skb-\u003eencapsulation, shinfo-\u003egso_type, SKB_GSO_CB(skb)-\u003eencap_level) are existing, fully initialized members of sk_buff/skb_shared_info/skb_gso_cb. Furthermore, no new data is copied to user space or exposed via network packet payloads. Any potential regression would be related to protocol logic or skb lifetime/bounds, which are covered by standard testing and KASAN. Therefore, a dedicated KMSAN fuzzing session is not warranted.",
"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 6eb51eb6a4f2ce92cd7840a9e1ae1209dfff657f
Author: syz-cluster <triage@syzkaller.com>
Date: Sun Nov 1 22:46:47 2026 +0000
syz-cluster: applied patch under review
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 6787fcf6ac3e43..00df57cbc05c27 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -5337,6 +5337,36 @@ static inline void skb_decrease_gso_size(struct skb_shared_info *shinfo,
shinfo->gso_size -= decrement;
}
+/**
+ * skb_gso_fixedid_encap - move the TCP fixed-ID flag to the inner header
+ * @shinfo: shared info of a GSO packet that becomes encapsulated
+ *
+ * The IPv4 header that SKB_GSO_TCP_FIXEDID describes becomes the inner one,
+ * and the new outer header gets an incrementing ID.
+ */
+static inline void skb_gso_fixedid_encap(struct skb_shared_info *shinfo)
+{
+ unsigned int fixedid = shinfo->gso_type & SKB_GSO_TCP_FIXEDID;
+
+ shinfo->gso_type &= ~(SKB_GSO_TCP_FIXEDID | SKB_GSO_TCP_FIXEDID_INNER);
+ shinfo->gso_type |= fixedid << 1;
+}
+
+/**
+ * skb_gso_fixedid_decap - move the TCP fixed-ID flag to the new outer header
+ * @shinfo: shared info of an encapsulated GSO packet losing its outer header
+ *
+ * The inner IPv4 header, which SKB_GSO_TCP_FIXEDID_INNER describes, becomes
+ * the outer one, and the state of the removed outer header is dropped.
+ */
+static inline void skb_gso_fixedid_decap(struct skb_shared_info *shinfo)
+{
+ unsigned int fixedid = shinfo->gso_type & SKB_GSO_TCP_FIXEDID_INNER;
+
+ shinfo->gso_type &= ~(SKB_GSO_TCP_FIXEDID | SKB_GSO_TCP_FIXEDID_INNER);
+ shinfo->gso_type |= fixedid >> 1;
+}
+
void __skb_warn_lro_forwarding(const struct sk_buff *skb);
static __always_inline bool skb_warn_if_lro(const struct sk_buff *skb)
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
index 5cccf4c0e6913a..c2ffda6029a062 100644
--- a/include/net/ip_tunnels.h
+++ b/include/net/ip_tunnels.h
@@ -665,6 +665,8 @@ static inline int iptunnel_pull_offloads(struct sk_buff *skb)
err = skb_unclone(skb, GFP_ATOMIC);
if (unlikely(err))
return err;
+ if (skb->encapsulation)
+ skb_gso_fixedid_decap(skb_shinfo(skb));
skb_shinfo(skb)->gso_type &= ~(NETIF_F_GSO_ENCAP_ALL >>
NETIF_F_GSO_SHIFT);
}
diff --git a/net/core/filter.c b/net/core/filter.c
index 09c60a58c82abe..4f87a827b25be4 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -3718,6 +3718,9 @@ static int bpf_skb_net_grow(struct sk_buff *skb, u32 off, u32 len_diff,
if (skb_is_gso(skb)) {
struct skb_shared_info *shinfo = skb_shinfo(skb);
+ if (encap)
+ skb_gso_fixedid_encap(shinfo);
+
/* Header must be checked, and gso_segs recomputed. */
shinfo->gso_type |= gso_type;
shinfo->gso_segs = 0;
@@ -3809,9 +3812,11 @@ static int bpf_skb_net_shrink(struct sk_buff *skb, u32 off, u32 len_diff,
SKB_GSO_GRE_CSUM |
SKB_GSO_IPXIP4 |
SKB_GSO_IPXIP6 |
- SKB_GSO_ESP)))
- if (skb->encapsulation)
- skb->encapsulation = 0;
+ SKB_GSO_ESP)) &&
+ skb->encapsulation) {
+ skb_gso_fixedid_decap(shinfo);
+ skb->encapsulation = 0;
+ }
}
/* Header must be checked, and gso_segs recomputed. */
diff --git a/net/core/lwt_bpf.c b/net/core/lwt_bpf.c
index da49364ec63de7..4d9faf2cc5de59 100644
--- a/net/core/lwt_bpf.c
+++ b/net/core/lwt_bpf.c
@@ -539,6 +539,7 @@ static int handle_gso_type(struct sk_buff *skb, unsigned int gso_type,
{
struct skb_shared_info *shinfo = skb_shinfo(skb);
+ skb_gso_fixedid_encap(shinfo);
gso_type |= SKB_GSO_DODGY;
shinfo->gso_type |= gso_type;
skb_decrease_gso_size(shinfo, encap_len);
diff --git a/net/ipv4/gre_offload.c b/net/ipv4/gre_offload.c
index c8129782d39de4..a8f9a0a0b06bdf 100644
--- a/net/ipv4/gre_offload.c
+++ b/net/ipv4/gre_offload.c
@@ -35,7 +35,6 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
/* setup inner skb. */
skb->encapsulation = 0;
- SKB_GSO_CB(skb)->encap_level = 0;
__skb_pull(skb, tnl_hlen);
skb_reset_mac_header(skb);
skb_set_network_header(skb, skb_inner_network_offset(skb));
diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c
index 6c2855adff2899..59050229e34996 100644
--- a/net/ipv4/ip_tunnel_core.c
+++ b/net/ipv4/ip_tunnel_core.c
@@ -182,9 +182,10 @@ EXPORT_SYMBOL_GPL(iptunnel_metadata_reply);
int iptunnel_handle_offloads(struct sk_buff *skb,
int gso_type_mask)
{
+ bool encap = !skb->encapsulation;
int err;
- if (likely(!skb->encapsulation)) {
+ if (likely(encap)) {
skb_reset_inner_headers(skb);
skb->encapsulation = 1;
}
@@ -193,6 +194,8 @@ int iptunnel_handle_offloads(struct sk_buff *skb,
err = skb_header_unclone(skb, GFP_ATOMIC);
if (unlikely(err))
return err;
+ if (encap)
+ skb_gso_fixedid_encap(skb_shinfo(skb));
skb_shinfo(skb)->gso_type |= gso_type_mask;
return 0;
}
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index cf07c3c6611a22..edcabe1115a60c 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -205,7 +205,6 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
/* setup inner skb. */
skb->encapsulation = 0;
- SKB_GSO_CB(skb)->encap_level = 0;
__skb_pull(skb, tnl_hlen);
skb_reset_mac_header(skb);
skb_set_network_header(skb, skb_inner_network_offset(skb));
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 96c8402a27a549..126058772bc5ae 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -53,6 +53,7 @@
#include <linux/ioam6_genl.h>
#include <net/ioam6.h>
#include <net/dst_metadata.h>
+#include <net/ip_tunnels.h>
#include <linux/uaccess.h>
@@ -406,7 +407,10 @@ static int ipv6_srh_rcv(struct sk_buff *skb, struct inet6_dev *idev)
skb_reset_network_header(skb);
skb_reset_transport_header(skb);
- skb->encapsulation = 0;
+ if (iptunnel_pull_offloads(skb)) {
+ kfree_skb(skb);
+ return -1;
+ }
if (hdr->nexthdr == NEXTHDR_IPV4)
skb->protocol = htons(ETH_P_IP);
__skb_tunnel_rx(skb, skb->dev, net);
@@ -513,7 +517,10 @@ static int ipv6_rpl_srh_rcv(struct sk_buff *skb, struct inet6_dev *idev)
skb_reset_network_header(skb);
skb_reset_transport_header(skb);
- skb->encapsulation = 0;
+ if (iptunnel_pull_offloads(skb)) {
+ kfree_skb(skb);
+ return -1;
+ }
__skb_tunnel_rx(skb, skb->dev, net);
diff --git a/tools/testing/selftests/net/.gitignore b/tools/testing/selftests/net/.gitignore
index 21412510ac26b8..96263d5978258f 100644
--- a/tools/testing/selftests/net/.gitignore
+++ b/tools/testing/selftests/net/.gitignore
@@ -46,6 +46,7 @@ so_rcv_listener
stress_reuseport_listen
tap
tcp_fastopen_backup_key
+tcp_fixedid
tcp_inq
tcp_mmap
tcp_port_share
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 9180b9bec5155e..dd402814bc7483 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -106,6 +106,7 @@ TEST_PROGS := \
srv6_iptunnel_cache.sh \
stress_reuseport_listen.sh \
tcp_ecmp_failover.sh \
+ tcp_fixedid.sh \
tcp_fastopen_backup_key.sh \
test_bridge_backup_port.sh \
test_bridge_neigh_suppress.sh \
@@ -169,6 +170,7 @@ TEST_GEN_FILES := \
socket \
stress_reuseport_listen \
tcp_fastopen_backup_key \
+ tcp_fixedid \
tcp_inq \
tcp_mmap \
tfo \
diff --git a/tools/testing/selftests/net/tcp_fixedid.c b/tools/testing/selftests/net/tcp_fixedid.c
new file mode 100644
index 00000000000000..d507d12b46308f
--- /dev/null
+++ b/tools/testing/selftests/net/tcp_fixedid.c
@@ -0,0 +1,396 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Send TCP segments with fixed or incrementing IPv4 IDs, optionally in
+ * VXLAN, and report the IP IDs of TCP segments received on a device.
+ *
+ * tx: tcp_fixedid -T -i dev -M dmac -s saddr -d daddr [-f] [-n segs]
+ * [-b bursts] [-l len] [-V osaddr,odaddr -m inner_dmac [-F]]
+ * rx: tcp_fixedid -R -i dev [-c segs] [-w ms]
+ *
+ * The receiver prints "ready" once it is bound, then the number of
+ * segments, of segments with an outer IPv4 header, and of distinct outer
+ * and inner IDs.
+ */
+
+#include <arpa/inet.h>
+#include <errno.h>
+#include <error.h>
+#include <linux/if_packet.h>
+#include <net/ethernet.h>
+#include <net/if.h>
+#include <netinet/ip.h>
+#include <netinet/ip6.h>
+#include <netinet/tcp.h>
+#include <netinet/udp.h>
+#include <poll.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>
+
+#define TEST_PORT 9000
+#define VXLAN_PORT 4789
+#define FIXED_ID 0x1234
+
+static const char *ifname;
+static bool fixed_id, fixed_outer;
+static int segs = 40, bursts = 10, len = 1000, wait_ms = 2000, stop;
+static struct in_addr saddr, daddr, osaddr, odaddr;
+static bool vxlan;
+static unsigned char dmac[ETH_ALEN], inner_dmac[ETH_ALEN];
+
+static void parse_mac(const char *s, unsigned char *mac)
+{
+ if (sscanf(s, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &mac[0], &mac[1],
+ &mac[2], &mac[3], &mac[4], &mac[5]) != 6)
+ error(1, 0, "bad mac %s", s);
+}
+
+static void parse_addr(const char *s, struct in_addr *a)
+{
+ if (inet_pton(AF_INET, s, a) != 1)
+ error(1, 0, "bad address %s", s);
+}
+
+static uint32_t csum_add(uint32_t sum, const void *data, size_t n)
+{
+ const uint8_t *p = data;
+
+ while (n > 1) {
+ sum += (p[0] << 8) | p[1];
+ p += 2;
+ n -= 2;
+ }
+ if (n)
+ sum += p[0] << 8;
+ return sum;
+}
+
+static uint16_t csum_fold(uint32_t sum)
+{
+ while (sum >> 16)
+ sum = (sum & 0xffff) + (sum >> 16);
+ return htons(~sum & 0xffff);
+}
+
+static void build_ip(struct iphdr *iph, int proto, int payload, uint16_t id,
+ struct in_addr s, struct in_addr d)
+{
+ memset(iph, 0, sizeof(*iph));
+ iph->version = 4;
+ iph->ihl = 5;
+ iph->tot_len = htons(sizeof(*iph) + payload);
+ iph->id = htons(id);
+ iph->frag_off = htons(IP_DF);
+ iph->ttl = 64;
+ iph->protocol = proto;
+ iph->saddr = s.s_addr;
+ iph->daddr = d.s_addr;
+ iph->check = csum_fold(csum_add(0, iph, sizeof(*iph)));
+}
+
+/* Ethernet, IPv4 and TCP header plus payload for segment @i at @p */
+static int build_tcp(unsigned char *p, const unsigned char *mac, int i,
+ uint16_t id)
+{
+ struct ethhdr *eth = (struct ethhdr *)p;
+ struct iphdr *iph = (struct iphdr *)(eth + 1);
+ struct tcphdr *th = (struct tcphdr *)(iph + 1);
+ struct {
+ uint32_t s, d;
+ uint8_t zero, proto;
+ uint16_t len;
+ } ph; /* 12 bytes, no padding */
+ uint32_t sum;
+
+ memcpy(eth->h_dest, mac, ETH_ALEN);
+ memset(eth->h_source, 0, ETH_ALEN);
+ eth->h_source[0] = 0x02;
+ eth->h_source[5] = 0x01;
+ eth->h_proto = htons(ETH_P_IP);
+ build_ip(iph, IPPROTO_TCP, sizeof(*th) + len, id, saddr, daddr);
+
+ memset(th, 0, sizeof(*th));
+ th->source = htons(TEST_PORT + 1);
+ th->dest = htons(TEST_PORT);
+ th->seq = htonl(1 + i * len);
+ th->ack_seq = htonl(1);
+ th->doff = 5;
+ th->ack = 1;
+ th->window = htons(65535);
+ memset(th + 1, 'a' + i % 26, len);
+
+ ph.s = iph->saddr;
+ ph.d = iph->daddr;
+ ph.zero = 0;
+ ph.proto = IPPROTO_TCP;
+ ph.len = htons(sizeof(*th) + len);
+ sum = csum_add(0, &ph, sizeof(ph));
+ th->check = csum_fold(csum_add(sum, th, sizeof(*th) + len));
+
+ return sizeof(*eth) + sizeof(*iph) + sizeof(*th) + len;
+}
+
+static int do_tx(int fd, struct sockaddr_ll *sll)
+{
+ unsigned char buf[ETH_FRAME_LEN + 128];
+ int b, s, i = 0, n;
+
+ for (b = 0; b < bursts; b++) {
+ for (s = 0; s < segs; s++, i++) {
+ uint16_t id = fixed_id ? FIXED_ID : 0x1000 + i;
+ unsigned char *p = buf;
+
+ if (vxlan) {
+ struct ethhdr *eth = (struct ethhdr *)p;
+ struct iphdr *iph = (struct iphdr *)(eth + 1);
+ struct udphdr *uh = (struct udphdr *)(iph + 1);
+ uint32_t *vx = (uint32_t *)(uh + 1);
+ int inner;
+
+ inner = build_tcp((unsigned char *)(vx + 2),
+ inner_dmac, i, id);
+ memcpy(eth->h_dest, dmac, ETH_ALEN);
+ memset(eth->h_source, 0, ETH_ALEN);
+ eth->h_source[0] = 0x02;
+ eth->h_source[5] = 0x01;
+ eth->h_proto = htons(ETH_P_IP);
+ memset(uh, 0, sizeof(*uh));
+ uh->source = htons(VXLAN_PORT + 1);
+ uh->dest = htons(VXLAN_PORT);
+ uh->len = htons(sizeof(*uh) + 8 + inner);
+ vx[0] = htonl(0x08000000);
+ vx[1] = htonl(42 << 8);
+ build_ip(iph, IPPROTO_UDP,
+ sizeof(*uh) + 8 + inner,
+ fixed_outer ? FIXED_ID : 0x2000 + i,
+ osaddr, odaddr);
+ n = sizeof(*eth) + sizeof(*iph) + sizeof(*uh) +
+ 8 + inner;
+ } else {
+ n = build_tcp(p, dmac, i, id);
+ }
+
+ if (sendto(fd, buf, n, 0, (struct sockaddr *)sll,
+ sizeof(*sll)) != n)
+ error(1, errno, "sendto");
+ }
+ usleep(50000);
+ }
+ return 0;
+}
+
+/* Return the inner IPv4 header of a TCP segment to TEST_PORT, or NULL */
+static const struct iphdr *find_inner(const unsigned char *p, int n,
+ const struct iphdr **outer4)
+{
+ const struct ethhdr *eth = (const struct ethhdr *)p;
+ const unsigned char *end = p + n;
+ const unsigned char *l4;
+ int proto, depth;
+
+ *outer4 = NULL;
+ if (n < (int)sizeof(*eth))
+ return NULL;
+ p += sizeof(*eth);
+
+ for (depth = 0; depth < 2; depth++) {
+ uint16_t etype = depth ? htons(ETH_P_IP) : eth->h_proto;
+
+ if (etype == htons(ETH_P_IP)) {
+ const struct iphdr *iph = (const struct iphdr *)p;
+
+ if (p + sizeof(*iph) > end)
+ return NULL;
+ proto = iph->protocol;
+ l4 = p + iph->ihl * 4;
+ if (proto == IPPROTO_TCP) {
+ const struct tcphdr *th;
+
+ th = (const struct tcphdr *)l4;
+ if (l4 + sizeof(*th) > end ||
+ th->dest != htons(TEST_PORT))
+ return NULL;
+ return iph;
+ }
+ if (depth)
+ return NULL;
+ *outer4 = iph;
+ } else if (etype == htons(ETH_P_IPV6)) {
+ const struct ip6_hdr *ip6h = (const struct ip6_hdr *)p;
+
+ if (p + sizeof(*ip6h) > end)
+ return NULL;
+ proto = ip6h->ip6_nxt;
+ l4 = p + sizeof(*ip6h);
+ } else {
+ return NULL;
+ }
+
+ /* step over the tunnel header to the inner IPv4 header */
+ if (proto == IPPROTO_IPIP) {
+ p = l4;
+ } else if (proto == IPPROTO_GRE) {
+ uint16_t flags;
+
+ if (l4 + 4 > end)
+ return NULL;
+ flags = (l4[0] << 8) | l4[1];
+ if (((l4[2] << 8) | l4[3]) != ETH_P_IP)
+ return NULL;
+ p = l4 + 4 + 4 * (!!(flags & 0x8000) +
+ !!(flags & 0x2000) +
+ !!(flags & 0x1000));
+ } else if (proto == IPPROTO_UDP) {
+ const struct udphdr *uh = (const struct udphdr *)l4;
+
+ if (l4 + sizeof(*uh) + 8 + sizeof(*eth) > end ||
+ uh->dest != htons(VXLAN_PORT))
+ return NULL;
+ p = l4 + sizeof(*uh) + 8 + sizeof(*eth);
+ } else {
+ return NULL;
+ }
+ }
+ return NULL;
+}
+
+static void count_id(uint8_t *map, unsigned int *distinct, uint16_t id)
+{
+ if (!(map[id / 8] & (1 << (id % 8)))) {
+ map[id / 8] |= 1 << (id % 8);
+ (*distinct)++;
+ }
+}
+
+static int do_rx(int fd)
+{
+ static uint8_t outer_map[8192], inner_map[8192];
+ unsigned int frames = 0, outer4 = 0, outer_ids = 0, inner_ids = 0;
+ unsigned char buf[65536];
+ struct pollfd pfd = { .fd = fd, .events = POLLIN };
+
+ printf("ready\n");
+ fflush(stdout);
+
+ /* wait longer for the first segment than between segments */
+ while (poll(&pfd, 1, frames ? wait_ms : 10 * wait_ms) > 0) {
+ const struct iphdr *iph, *oiph;
+ struct sockaddr_ll from;
+ socklen_t fl = sizeof(from);
+ int n;
+
+ n = recvfrom(fd, buf, sizeof(buf), 0, (struct sockaddr *)&from,
+ &fl);
+ if (n < 0)
+ error(1, errno, "recvfrom");
+ if (from.sll_pkttype == PACKET_OUTGOING)
+ continue;
+ iph = find_inner(buf, n, &oiph);
+ if (!iph)
+ continue;
+ frames++;
+ count_id(inner_map, &inner_ids, ntohs(iph->id));
+ if (oiph) {
+ outer4++;
+ count_id(outer_map, &outer_ids, ntohs(oiph->id));
+ }
+ if (stop && frames == (unsigned int)stop)
+ break;
+ }
+
+ printf("frames %u outer4 %u outer_ids %u inner_ids %u\n", frames,
+ outer4, outer_ids, inner_ids);
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ struct sockaddr_ll sll = {};
+ bool tx = false, rx = false;
+ char *comma;
+ int c, fd;
+
+ while ((c = getopt(argc, argv, "TRi:M:s:d:fn:b:l:V:m:Fw:c:")) != -1) {
+ switch (c) {
+ case 'T':
+ tx = true;
+ break;
+ case 'R':
+ rx = true;
+ break;
+ case 'i':
+ ifname = optarg;
+ break;
+ case 'M':
+ parse_mac(optarg, dmac);
+ break;
+ case 's':
+ parse_addr(optarg, &saddr);
+ break;
+ case 'd':
+ parse_addr(optarg, &daddr);
+ break;
+ case 'f':
+ fixed_id = true;
+ break;
+ case 'n':
+ segs = atoi(optarg);
+ break;
+ case 'b':
+ bursts = atoi(optarg);
+ break;
+ case 'l':
+ len = atoi(optarg);
+ break;
+ case 'V':
+ comma = strchr(optarg, ',');
+ if (!comma)
+ error(1, 0, "-V needs outer saddr,daddr");
+ *comma = '\0';
+ parse_addr(optarg, &osaddr);
+ parse_addr(comma + 1, &odaddr);
+ vxlan = true;
+ break;
+ case 'm':
+ parse_mac(optarg, inner_dmac);
+ break;
+ case 'F':
+ fixed_outer = true;
+ break;
+ case 'w':
+ wait_ms = atoi(optarg);
+ break;
+ case 'c':
+ stop = atoi(optarg);
+ break;
+ default:
+ error(1, 0, "bad option");
+ }
+ }
+ if (tx == rx || !ifname || len < 1 || len > 1400 || segs < 1 ||
+ bursts < 1)
+ error(1, 0, "usage: see the comment at the top of %s",
+ __FILE__);
+
+ fd = socket(AF_PACKET, SOCK_RAW, htons(tx ? 0 : ETH_P_ALL));
+ if (fd < 0)
+ error(1, errno, "socket");
+ sll.sll_family = AF_PACKET;
+ sll.sll_protocol = htons(ETH_P_ALL);
+ sll.sll_ifindex = if_nametoindex(ifname);
+ if (!sll.sll_ifindex)
+ error(1, errno, "%s", ifname);
+ if (bind(fd, (struct sockaddr *)&sll, sizeof(sll)))
+ error(1, errno, "bind");
+ sll.sll_halen = ETH_ALEN;
+ memcpy(sll.sll_addr, dmac, ETH_ALEN);
+
+ c = tx ? do_tx(fd, &sll) : do_rx(fd);
+ close(fd);
+ return c;
+}
diff --git a/tools/testing/selftests/net/tcp_fixedid.sh b/tools/testing/selftests/net/tcp_fixedid.sh
new file mode 100755
index 00000000000000..88f92981740771
--- /dev/null
+++ b/tools/testing/selftests/net/tcp_fixedid.sh
@@ -0,0 +1,291 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# Check the IPv4 IDs of a TCP stream that GRO merged and software
+# segmentation split again across a tunnel. A sender in NSRC writes
+# segments with fixed or incrementing IDs onto a veth with GRO on in
+# NRTR, which forwards the merged packets:
+#
+# encap: into an IPIP, GRE or VXLAN tunnel over IPv4 or IPv6,
+# segmented on the underlay towards NMID
+# decap: out of VXLAN, received from NSRC with one header fixed and
+# the other incrementing, into an IPIP tunnel towards NMID
+# encap+decap: into a tunnel that NMID ends without segmenting, and on
+# to NDST, segmented there
+#
+# The inner IDs must come out as they went in, and the IDs of a new outer
+# IPv4 header must be unique. Packets that GRO did not merge are not
+# tested, so a run where nothing was merged is skipped.
+
+source lib.sh
+
+NSRC=""
+NRTR=""
+NMID=""
+NDST=""
+
+SEGS=40
+BURSTS=10
+TOTAL=$((SEGS * BURSTS))
+INNER_SRC=10.1.0.1
+INNER_DST=10.9.0.2
+VX_MAC=02:00:00:00:00:42
+TUN_MAC=02:00:00:00:00:99
+MID_MAC=02:00:00:00:00:98
+TX=./tcp_fixedid
+
+NOSEG="tso gso tx-gre-segmentation tx-gre-csum-segmentation
+ tx-ipxip4-segmentation tx-ipxip6-segmentation
+ tx-udp_tnl-segmentation tx-udp_tnl-csum-segmentation"
+
+cleanup() {
+ cleanup_all_ns
+}
+
+trap cleanup EXIT
+
+# NSRC s0 - r0 NRTR r1 - m1 NMID m2 - d2 NDST
+setup() {
+ setup_ns NSRC NRTR NMID NDST || return "$ksft_skip"
+
+ ip link add s0 netns "$NSRC" type veth peer name r0 netns "$NRTR"
+ ip link add r1 netns "$NRTR" type veth peer name m1 netns "$NMID"
+ ip link add m2 netns "$NMID" type veth peer name d2 netns "$NDST"
+
+ ip -n "$NRTR" addr add 10.1.0.2/24 dev r0
+ ip -n "$NRTR" addr add 10.2.0.1/24 dev r1
+ ip -n "$NRTR" addr add fd02::1/64 dev r1 nodad
+ ip -n "$NMID" addr add 10.2.0.2/24 dev m1
+ ip -n "$NMID" addr add fd02::2/64 dev m1 nodad
+ ip -n "$NMID" addr add 10.4.0.1/24 dev m2
+ ip -n "$NDST" addr add 10.4.0.2/24 dev d2
+ ip -n "$NSRC" link set s0 up
+ ip -n "$NRTR" link set r0 up
+ ip -n "$NRTR" link set r1 up
+ ip -n "$NMID" link set m1 up
+ ip -n "$NMID" link set m2 up
+ ip -n "$NDST" link set d2 up
+
+ ip netns exec "$NRTR" sysctl -qw net.ipv4.ip_forward=1
+ ip netns exec "$NMID" sysctl -qw net.ipv4.ip_forward=1
+ for ns in "$NRTR" "$NMID"; do
+ ip netns exec "$ns" sysctl -qw net.ipv4.conf.all.rp_filter=0 \
+ net.ipv4.conf.default.rp_filter=0
+ done
+
+ # veth passes packets to GRO only if the sender does not do TSO
+ ip netns exec "$NRTR" ethtool -K r0 gro on >/dev/null ||
+ return "$ksft_skip"
+ ip netns exec "$NSRC" ethtool -K s0 tso off >/dev/null ||
+ return "$ksft_skip"
+ # release the sender's segments in bursts for GRO to merge
+ tc -n "$NSRC" qdisc add dev s0 root netem slot 20ms 20ms \
+ packets "$SEGS" || return "$ksft_skip"
+}
+
+# tunnel <ns> <name> <type> <family> <local> <remote>
+tunnel() {
+ local ns=$1 name=$2 type=$3 family=$4 local=$5 remote=$6
+
+ case "$type" in
+ ipip)
+ if [ "$family" = 4 ]; then
+ ip -n "$ns" link add "$name" type ipip \
+ local "$local" remote "$remote"
+ else
+ ip -n "$ns" link add "$name" type ip6tnl mode ipip6 \
+ local "$local" remote "$remote" encaplimit none
+ fi ;;
+ gre)
+ if [ "$family" = 4 ]; then
+ ip -n "$ns" link add "$name" type gre \
+ local "$local" remote "$remote"
+ else
+ ip -n "$ns" link add "$name" type ip6gre \
+ local "$local" remote "$remote" encaplimit none
+ fi ;;
+ vxlan)
+ ip -n "$ns" link add "$name" address "$TUN_MAC" type vxlan \
+ id 7 dstport 4789 local "$local" remote "$remote" \
+ nolearning ;;
+ esac || return 1
+ ip -n "$ns" link set "$name" up
+}
+
+# route_into <ns> <dev>: send INNER_DST into <dev>
+route_into() {
+ ip -n "$1" route add "$INNER_DST/32" dev "$2"
+ ip -n "$1" neigh add "$INNER_DST" lladdr "$TUN_MAC" dev "$2" \
+ 2>/dev/null
+ return 0
+}
+
+# noseg <ns> <dev>: segment everything in software before <dev>
+noseg() {
+ local f
+
+ for f in $NOSEG; do
+ ip netns exec "$1" ethtool -K "$2" "$f" off >/dev/null 2>&1
+ done
+}
+
+tx_packets() {
+ ip netns exec "$1" cat "/sys/class/net/$2/statistics/tx_packets"
+}
+
+# check <name> <result> <want: fixed|incr> <outer: 0|1> <merged-into-dev>
+check() {
+ local name=$1 res=$2 want=$3 outer=$4 sent=$5
+ local frames outer_ids inner_ids
+
+ read -r _ frames _ _ _ outer_ids _ inner_ids <<< "$res"
+ RET=0
+ check_err $((frames != TOTAL)) "$frames of $TOTAL segments received"
+ if [ "$want" = fixed ]; then
+ check_err $((inner_ids != 1)) "$inner_ids inner IDs, want 1"
+ else
+ check_err $((inner_ids != TOTAL)) \
+ "$inner_ids inner IDs, want $TOTAL"
+ fi
+ if [ "$outer" = 1 ]; then
+ check_err $((outer_ids != frames)) \
+ "$outer_ids outer IDs for $frames segments"
+ fi
+ if [ "$RET" -eq 0 ] && [ "$sent" -ge "$TOTAL" ]; then
+ ret_set_ksft_status "$ksft_skip" "GRO did not merge"
+ fi
+ log_test "$name"
+}
+
+# capture <ns> <dev>: start the receiver in the background, pid in CAP_PID,
+# and wait until it is bound
+capture() {
+ local i
+
+ : > "$RESULT"
+ ip netns exec "$1" "$TX" -R -i "$2" -c "$TOTAL" -w 3000 > "$RESULT" &
+ CAP_PID=$!
+ for i in $(seq 100); do
+ grep -q ready "$RESULT" && return
+ sleep 0.1
+ done
+}
+
+run_encap() {
+ local type=$1 family=$2 want=$3
+ local r0mac t0 laddr=10.2.0.1 raddr=10.2.0.2
+ local f=""
+
+ setup || { log_test_skip "encap $type IPv$family"; return; }
+ if [ "$family" = 6 ]; then
+ laddr=fd02::1
+ raddr=fd02::2
+ fi
+ tunnel "$NRTR" tun0 "$type" "$family" "$laddr" "$raddr" ||
+ { log_test_skip "encap $type IPv$family"; cleanup_all_ns; return; }
+ route_into "$NRTR" tun0
+ noseg "$NRTR" r1
+
+ r0mac=$(ip -n "$NRTR" -br link show r0 | awk '{ print $3 }')
+ capture "$NMID" m1
+ t0=$(tx_packets "$NRTR" tun0)
+ [ "$want" = fixed ] && f=-f
+ ip netns exec "$NSRC" "$TX" -T -i s0 -M "$r0mac" -s "$INNER_SRC" \
+ -d "$INNER_DST" -n "$SEGS" -b "$BURSTS" $f
+ wait "$CAP_PID"
+ check "encap $type IPv$family, $want inner IDs" "$(tail -n 1 "$RESULT")" \
+ "$want" $((family == 4)) $(($(tx_packets "$NRTR" tun0) - t0))
+ cleanup_all_ns
+}
+
+# run_decap <fixed: inner|outer>: VXLAN from NSRC, decapsulated in NRTR
+run_decap() {
+ local fixed=$1 want=incr flags=-F
+ local r0mac t0
+
+ setup || { log_test_skip "decap"; return; }
+ ip -n "$NRTR" link add vx0 address "$VX_MAC" type vxlan id 42 \
+ dstport 4789 local 10.1.0.2 nolearning ||
+ { log_test_skip "decap"; cleanup_all_ns; return; }
+ ip -n "$NRTR" addr add 10.3.0.2/24 dev vx0
+ ip -n "$NRTR" link set vx0 up
+ tunnel "$NRTR" tun0 ipip 4 10.2.0.1 10.2.0.2
+ route_into "$NRTR" tun0
+ noseg "$NRTR" r1
+
+ if [ "$fixed" = inner ]; then
+ want=fixed
+ flags=-f
+ fi
+ r0mac=$(ip -n "$NRTR" -br link show r0 | awk '{ print $3 }')
+ capture "$NMID" m1
+ t0=$(tx_packets "$NRTR" tun0)
+ ip netns exec "$NSRC" "$TX" -T -i s0 -M "$r0mac" -s 10.3.0.1 \
+ -d "$INNER_DST" -n "$SEGS" -b "$BURSTS" \
+ -V 10.1.0.1,10.1.0.2 -m "$VX_MAC" $flags
+ wait "$CAP_PID"
+ check "decap VXLAN with fixed $fixed IDs, into IPIP" \
+ "$(tail -n 1 "$RESULT")" "$want" 1 \
+ $(($(tx_packets "$NRTR" tun0) - t0))
+ cleanup_all_ns
+}
+
+# run_encap_decap <type>: NRTR encapsulates, NMID decapsulates the GSO
+# packet without segmenting it and forwards it to NDST
+run_encap_decap() {
+ local type=$1
+ local r0mac t0
+
+ setup || { log_test_skip "encap+decap $type"; return; }
+ if ! tunnel "$NRTR" tun0 "$type" 4 10.2.0.1 10.2.0.2 ||
+ ! tunnel "$NMID" tun0 "$type" 4 10.2.0.2 10.2.0.1; then
+ log_test_skip "encap+decap $type"
+ cleanup_all_ns
+ return
+ fi
+ route_into "$NRTR" tun0
+ # VXLAN drops frames from its own address as loops
+ if [ "$type" = vxlan ]; then
+ ip -n "$NMID" link set tun0 address "$MID_MAC"
+ ip -n "$NRTR" neigh replace "$INNER_DST" lladdr "$MID_MAC" \
+ dev tun0
+ fi
+ ip -n "$NMID" route add "$INNER_DST/32" via 10.4.0.2
+ ip -n "$NDST" addr add "$INNER_DST/32" dev d2
+ noseg "$NMID" m2
+
+ r0mac=$(ip -n "$NRTR" -br link show r0 | awk '{ print $3 }')
+ capture "$NDST" d2
+ t0=$(tx_packets "$NRTR" tun0)
+ ip netns exec "$NSRC" "$TX" -T -i s0 -M "$r0mac" -s "$INNER_SRC" \
+ -d "$INNER_DST" -n "$SEGS" -b "$BURSTS" -f
+ wait "$CAP_PID"
+ check "encap+decap $type, fixed inner IDs" "$(tail -n 1 "$RESULT")" fixed 0 \
+ $(($(tx_packets "$NRTR" tun0) - t0))
+ cleanup_all_ns
+}
+
+require_command ethtool
+require_command tc
+
+if [ ! -x "$TX" ]; then
+ echo "SKIP: $TX not built"
+ exit "$ksft_skip"
+fi
+
+RESULT=$(mktemp)
+
+for type in ipip gre vxlan; do
+ for family in 4 6; do
+ run_encap "$type" "$family" fixed
+ run_encap "$type" "$family" incr
+ done
+done
+run_decap inner
+run_decap outer
+for type in ipip gre vxlan; do
+ run_encap_decap "$type"
+done
+
+rm -f "$RESULT"
+exit "$EXIT_STATUS"
|
| 55/3 | 2026/11/01 22:50 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 13972 output: 25 thoughts: 338 Thoughts: **Evaluating the Patch for KMSAN Necessity** Okay, so I've got a patch series to evaluate, and the question is whether it needs KMSAN. First things first: I need to really understand what this patch actually *does*. Let's dig in and read it carefully. Alright, the patch modifies `include/linux/skbuff.h`. It introduces two inline functions: `skb_gso_fixedid_encap` and `skb_gso_fixedid_decap`. From a quick glance, it seems like these functions manipulate the `gso_type` field within a `skb_shared_info` structure, particularly around bits related to "fixedid" values and GSO (Generic Segmentation Offload). The functions appear to be doing some bit manipulation, shifting around `SKB_GSO_TCP_FIXEDID` and `SKB_GSO_TCP_FIXEDID_INNER` flags. The encap function seems to move the `fixedid` value left (multiplies by 2), and the decap function does the inverse, moving the value to the right (divides by 2). This might be a hint for what is going on, but it is better to understand the context. Hold on, before I dive deeper, I need to check something. Let's find out exactly what `SKB_GSO_TCP_FIXEDID` and `SKB_GSO_TCP_FIXEDID_INNER` actually *mean*. Time for a quick `grep` through the kernel source to see where these constants are defined and used. Understanding the *context* of these bits is absolutely crucial to determining if this patch introduces any potential memory safety concerns that KMSAN should be concerned about. |
| 56/3 | 2026/11/01 22:50 | tool | grepper |
0mArgs:{
"Expression": "SKB_GSO_TCP_FIXEDID"
}Results: {
"Output": "Documentation/networking/segmentation-offloads.rst=48=The default behavior is to increment the IP ID with every segment. If the\nDocumentation/networking/segmentation-offloads.rst:49:GSO type SKB_GSO_TCP_FIXEDID is specified then we will not increment the IP\nDocumentation/networking/segmentation-offloads.rst-50-ID and all segments will use the same IP ID.\nDocumentation/networking/segmentation-offloads.rst-51-\nDocumentation/networking/segmentation-offloads.rst:52:For encapsulated packets, SKB_GSO_TCP_FIXEDID refers only to the outer header.\nDocumentation/networking/segmentation-offloads.rst:53:SKB_GSO_TCP_FIXEDID_INNER can be used to specify the same for the inner header.\nDocumentation/networking/segmentation-offloads.rst-54-Any combination of these two GSO types is allowed.\n--\ndrivers/net/ethernet/google/gve/gve_tx_dqo.c=571=static int gve_prep_tso(struct sk_buff *skb)\n--\ndrivers/net/ethernet/google/gve/gve_tx_dqo.c-603-\t/* gso_type is a bitmask: SKB_GSO_DODGY, SKB_GSO_TCP_ECN and\ndrivers/net/ethernet/google/gve/gve_tx_dqo.c:604:\t * SKB_GSO_TCP_FIXEDID may be set alongside the protocol bit.\ndrivers/net/ethernet/google/gve/gve_tx_dqo.c-605-\t */\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3_enet.c=3872=static int hns3_gro_complete(struct sk_buff *skb, u32 l234info)\n--\ndrivers/net/ethernet/hisilicon/hns3/hns3_enet.c-3918-\tif (l234info \u0026 BIT(HNS3_RXD_GRO_FIXID_B))\ndrivers/net/ethernet/hisilicon/hns3/hns3_enet.c:3919:\t\tskb_shinfo(skb)-\u003egso_type |= SKB_GSO_TCP_FIXEDID;\ndrivers/net/ethernet/hisilicon/hns3/hns3_enet.c-3920-\n--\ndrivers/net/ethernet/mellanox/mlx5/core/en_rx.c=1164=static void mlx5e_shampo_update_ipv4_tcp_hdr(struct mlx5e_rq *rq, struct iphdr *ipv4,\n--\ndrivers/net/ethernet/mellanox/mlx5/core/en_rx.c-1180-\ndrivers/net/ethernet/mellanox/mlx5/core/en_rx.c:1181:\t\tskb_shinfo(skb)-\u003egso_type |= encap ? SKB_GSO_TCP_FIXEDID_INNER :\ndrivers/net/ethernet/mellanox/mlx5/core/en_rx.c:1182:\t\t\t\t\t\t SKB_GSO_TCP_FIXEDID;\ndrivers/net/ethernet/mellanox/mlx5/core/en_rx.c-1183-\t}\n--\ndrivers/net/ethernet/sfc/ef100_tx.c=185=static void ef100_make_tso_desc(struct efx_nic *efx,\n--\ndrivers/net/ethernet/sfc/ef100_tx.c-204-\tif (encap) {\ndrivers/net/ethernet/sfc/ef100_tx.c:205:\t\tif (skb_shinfo(skb)-\u003egso_type \u0026 SKB_GSO_TCP_FIXEDID_INNER)\ndrivers/net/ethernet/sfc/ef100_tx.c-206-\t\t\tmangleid = ESE_GZ_TX_DESC_IP4_ID_NO_OP;\ndrivers/net/ethernet/sfc/ef100_tx.c:207:\t\tif (skb_shinfo(skb)-\u003egso_type \u0026 SKB_GSO_TCP_FIXEDID)\ndrivers/net/ethernet/sfc/ef100_tx.c-208-\t\t\tmangleid_outer = ESE_GZ_TX_DESC_IP4_ID_NO_OP;\ndrivers/net/ethernet/sfc/ef100_tx.c-209-\t} else {\ndrivers/net/ethernet/sfc/ef100_tx.c:210:\t\tif (skb_shinfo(skb)-\u003egso_type \u0026 SKB_GSO_TCP_FIXEDID)\ndrivers/net/ethernet/sfc/ef100_tx.c-211-\t\t\tmangleid = ESE_GZ_TX_DESC_IP4_ID_NO_OP;\n--\ndrivers/net/ppp/ppp_generic.c=2270=static bool ppp_decompress_proto(struct sk_buff *skb)\n--\ndrivers/net/ppp/ppp_generic.c-2283-\t\t\t SKB_GSO_TCP_ECN | SKB_GSO_TCP_ACCECN |\t\\\ndrivers/net/ppp/ppp_generic.c:2284:\t\t\t SKB_GSO_TCP_FIXEDID | SKB_GSO_UDP_L4 |\t\\\ndrivers/net/ppp/ppp_generic.c-2285-\t\t\t SKB_GSO_FRAGLIST | SKB_GSO_DODGY)\n--\ninclude/linux/netdevice.h=5535=static inline bool net_gso_ok(netdev_features_t features, int gso_type)\n--\ninclude/linux/netdevice.h-5538-\ninclude/linux/netdevice.h:5539:\tif (gso_type \u0026 (SKB_GSO_TCP_FIXEDID | SKB_GSO_TCP_FIXEDID_INNER))\ninclude/linux/netdevice.h:5540:\t\tgso_type |= __SKB_GSO_TCP_FIXEDID;\ninclude/linux/netdevice.h-5541-\n--\ninclude/linux/netdevice.h-5547-\tBUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN \u003e\u003e NETIF_F_GSO_SHIFT));\ninclude/linux/netdevice.h:5548:\tBUILD_BUG_ON(__SKB_GSO_TCP_FIXEDID != (NETIF_F_TSO_MANGLEID \u003e\u003e NETIF_F_GSO_SHIFT));\ninclude/linux/netdevice.h-5549-\tBUILD_BUG_ON(SKB_GSO_TCPV6 != (NETIF_F_TSO6 \u003e\u003e NETIF_F_GSO_SHIFT));\n--\ninclude/linux/skbuff.h=674=enum {\n--\ninclude/linux/skbuff.h-682-\ninclude/linux/skbuff.h:683:\t__SKB_GSO_TCP_FIXEDID = 1 \u003c\u003c 3,\ninclude/linux/skbuff.h-684-\n--\ninclude/linux/skbuff.h-719-\t */\ninclude/linux/skbuff.h:720:\tSKB_GSO_TCP_FIXEDID = 1 \u003c\u003c 30,\ninclude/linux/skbuff.h:721:\tSKB_GSO_TCP_FIXEDID_INNER = 1 \u003c\u003c 31,\ninclude/linux/skbuff.h-722-};\n--\ninclude/linux/skbuff.h=5332=static inline void skb_decrease_gso_size(struct skb_shared_info *shinfo,\n--\ninclude/linux/skbuff.h-5343- *\ninclude/linux/skbuff.h:5344: * The IPv4 header that SKB_GSO_TCP_FIXEDID describes becomes the inner one,\ninclude/linux/skbuff.h-5345- * and the new outer header gets an incrementing ID.\n--\ninclude/linux/skbuff.h=5347=static inline void skb_gso_fixedid_encap(struct skb_shared_info *shinfo)\ninclude/linux/skbuff.h-5348-{\ninclude/linux/skbuff.h:5349:\tunsigned int fixedid = shinfo-\u003egso_type \u0026 SKB_GSO_TCP_FIXEDID;\ninclude/linux/skbuff.h-5350-\ninclude/linux/skbuff.h:5351:\tshinfo-\u003egso_type \u0026= ~(SKB_GSO_TCP_FIXEDID | SKB_GSO_TCP_FIXEDID_INNER);\ninclude/linux/skbuff.h-5352-\tshinfo-\u003egso_type |= fixedid \u003c\u003c 1;\n--\ninclude/linux/skbuff.h-5358- *\ninclude/linux/skbuff.h:5359: * The inner IPv4 header, which SKB_GSO_TCP_FIXEDID_INNER describes, becomes\ninclude/linux/skbuff.h-5360- * the outer one, and the state of the removed outer header is dropped.\n--\ninclude/linux/skbuff.h=5362=static inline void skb_gso_fixedid_decap(struct skb_shared_info *shinfo)\ninclude/linux/skbuff.h-5363-{\ninclude/linux/skbuff.h:5364:\tunsigned int fixedid = shinfo-\u003egso_type \u0026 SKB_GSO_TCP_FIXEDID_INNER;\ninclude/linux/skbuff.h-5365-\ninclude/linux/skbuff.h:5366:\tshinfo-\u003egso_type \u0026= ~(SKB_GSO_TCP_FIXEDID | SKB_GSO_TCP_FIXEDID_INNER);\ninclude/linux/skbuff.h-5367-\tshinfo-\u003egso_type |= fixedid \u003e\u003e 1;\n--\nnet/ipv4/af_inet.c=1362=struct sk_buff *inet_gso_segment(struct sk_buff *skb,\n--\nnet/ipv4/af_inet.c-1404-\nnet/ipv4/af_inet.c:1405:\tfixedid = !!(skb_shinfo(skb)-\u003egso_type \u0026 (SKB_GSO_TCP_FIXEDID \u003c\u003c encap));\nnet/ipv4/af_inet.c-1406-\n--\nnet/ipv4/tcp_offload.c=458=INDIRECT_CALLABLE_SCOPE int tcp4_gro_complete(struct sk_buff *skb, int thoff)\n--\nnet/ipv4/tcp_offload.c-475-\nnet/ipv4/tcp_offload.c:476:\tBUILD_BUG_ON(SKB_GSO_TCP_FIXEDID \u003c\u003c 1 != SKB_GSO_TCP_FIXEDID_INNER);\nnet/ipv4/tcp_offload.c-477-\tskb_shinfo(skb)-\u003egso_type |= SKB_GSO_TCPV4 |\nnet/ipv4/tcp_offload.c:478:\t\t\t(NAPI_GRO_CB(skb)-\u003eip_fixedid * SKB_GSO_TCP_FIXEDID);\nnet/ipv4/tcp_offload.c-479-\n"
} |
| 57/3 | 2026/11/01 22:50 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 17597 output: 18 thoughts: 852 Thoughts: **Analyzing the GSO Fixed ID Patch** Okay, let's dive into this patch. My initial thought is to trace the flow of these GSO (Generic Segmentation Offload) flag manipulations. The diff touches a few key areas, and I need to understand how the `SKB_GSO_TCP_FIXEDID` flag is being shifted and why. First, I see the changes in `include/linux/skbuff.h`. The functions `skb_gso_fixedid_encap` and `skb_gso_fixedid_decap` are clearly the core of this logic. When encapsulating, the patch shifts `SKB_GSO_TCP_FIXEDID` to `SKB_GSO_TCP_FIXEDID_INNER`. Makes sense: the outer header *was* the one with the fixed ID, now it's the inner. Decapsulation does the reverse shift, which is logical. Next, I look at `include/net/ip_tunnels.h`, specifically `iptunnel_pull_offloads`. Here, I find the call to `skb_gso_fixedid_decap` when the skb is encapsulated, which supports the encapsulation/decapsulation idea. It also masks out `NETIF_F_GSO_ENCAP_ALL`, which is likely about clearing any pre-existing encapsulation GSO flags, to start fresh. Then `net/core/filter.c` is updated, especially `bpf_skb_net_grow` and `bpf_skb_net_shrink`. I see how `skb_gso_fixedid_encap` is called in `bpf_skb_net_grow` when encapsulation occurs and `skb_gso_fixedid_decap` in `bpf_skb_net_shrink`. The `shinfo->gso_type` manipulations make sense in context: updating the GSO type after a BPF filter grows or shrinks an skb. Critically, there's a check for `SKB_GSO_ESP` when decapsulating in `bpf_skb_net_shrink`. This suggests that the fixed ID handling is specifically related to ESP encapsulation. This is an important detail. `net/core/lwt_bpf.c` and `net/ipv4/gre_offload.c` are also modified. In `lwt_bpf.c` `handle_gso_type` function, I notice that it calls `skb_gso_fixedid_encap` and then sets the `SKB_GSO_DODGY` flag, which seems like a bit of a warning flag after encapsulation, interesting. In `net/ipv4/gre_offload.c`, a line `SKB_GSO_CB(skb)->encap_level = 0;` was removed from the `gre_gso_segment` function. Why was this removed? That's the real question. Let me check what `encap_level` is actually *doing* in `gre_gso_segment` and compare it to its usage in `udp_offload.c`. This needs more investigation. I'll grep for the `encap_level` variable and see where else it's used to understand what's changed and why. That's the key to this patch. |
| 58/3 | 2026/11/01 22:50 | tool | grepper |
0mArgs:{
"Expression": "encap_level"
}Results: {
"Output": "include/net/gso.h=14=struct skb_gso_cb {\n--\ninclude/net/gso.h-18-\t};\ninclude/net/gso.h:19:\tint\tencap_level;\ninclude/net/gso.h-20-\t__wsum\tcsum;\n--\nnet/core/gso.c=90=struct sk_buff *__skb_gso_segment(struct sk_buff *skb,\n--\nnet/core/gso.c-121-\tSKB_GSO_CB(skb)-\u003emac_offset = skb_headroom(skb);\nnet/core/gso.c:122:\tSKB_GSO_CB(skb)-\u003eencap_level = 0;\nnet/core/gso.c-123-\tSKB_GSO_CB(skb)-\u003erecursion_counter = 0;\n--\nnet/ipv4/af_inet.c=1362=struct sk_buff *inet_gso_segment(struct sk_buff *skb,\n--\nnet/ipv4/af_inet.c-1395-\nnet/ipv4/af_inet.c:1396:\tencap = SKB_GSO_CB(skb)-\u003eencap_level \u003e 0;\nnet/ipv4/af_inet.c-1397-\tif (encap)\nnet/ipv4/af_inet.c-1398-\t\tfeatures \u0026= skb-\u003edev-\u003ehw_enc_features;\nnet/ipv4/af_inet.c:1399:\tSKB_GSO_CB(skb)-\u003eencap_level += ihl;\nnet/ipv4/af_inet.c-1400-\n--\nnet/ipv6/ip6_offload.c=92=static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,\n--\nnet/ipv6/ip6_offload.c-114-\nnet/ipv6/ip6_offload.c:115:\tencap = SKB_GSO_CB(skb)-\u003eencap_level \u003e 0;\nnet/ipv6/ip6_offload.c-116-\tif (encap)\nnet/ipv6/ip6_offload.c-117-\t\tfeatures \u0026= skb-\u003edev-\u003ehw_enc_features;\nnet/ipv6/ip6_offload.c:118:\tSKB_GSO_CB(skb)-\u003eencap_level += sizeof(*ipv6h);\nnet/ipv6/ip6_offload.c-119-\n"
} |
| 59/3 | 2026/11/01 22:50 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 19864 output: 39 thoughts: 580 Thoughts: **Analyzing GSO and Encapsulation Bug in the Kernel** Okay, let's break this down. I'm looking at how Generic Segmentation Offload (GSO) interacts with encapsulated packets, and I think I've spotted a significant flaw. Specifically, in `inet_gso_segment`, the code checks `encap = SKB_GSO_CB(skb)->encap_level > 0;` and then `fixedid = !!(skb_shinfo(skb)->gso_type & (SKB_GSO_TCP_FIXEDID << encap));`. If `encap_level` is incorrectly set to zero by functions like `gre_gso_segment` or `__skb_udp_tunnel_segment`, then the inner header will incorrectly perceive the packet as not being encapsulated, meaning that `encap` will equal zero. I see the problem - these functions are inappropriately zeroing `encap_level`, leading to the inner header falsely believing it isn't encapsulated. But, if `encap_level` *isn't* reset, then for the inner header, `encap_level > 0` will evaluate to true. Digging further, I'm checking `net/ipv4/ip_tunnel_core.c`, specifically `iptunnel_handle_offloads`. Here, if the packet isn't already encapsulated ( `encap = !skb->encapsulation;` is true), the code resets inner headers and *then* sets `skb->encapsulation = 1;`. Crucially, if there's encapsulation, it also calls `skb_gso_fixedid_encap`. This function is likely meant to handle some of the encapsulation complexities, and it's called *conditionally* on encapsulation! But, if the `encap_level` issue I identified is present, the inner header won't see this encapsulation. The `gso_type_mask` gets applied and should be correct, but the initial misinterpretation is crucial. Finally, I’m reviewing `net/ipv6/exthdrs.c`, specifically `ipv6_srh_rcv` and `ipv6_rpl_srh_rcv`. They have replaced setting `skb->encapsulation = 0;` with a call to `iptunnel_pull_offloads(skb)`. This looks like a more robust way to handle the de-encapsulation process, and failing that, will `kfree_skb(skb)`. This is a step in the right direction, but does not fix the original bug. |
| 60/3 | 2026/11/01 22:50 | tool | read-file |
0mArgs:{
"File": "net/ipv6/exthdrs.c",
"FirstLine": 400,
"LineCount": 30
}Results: {
"Contents": " 400:\t\t\t\tint offset = (hdr-\u003ehdrlen + 1) \u003c\u003c 3;\n 401:\t\n 402:\t\t\t\tskb_postpull_rcsum(skb, skb_network_header(skb),\n 403:\t\t\t\t\t\t skb_network_header_len(skb));\n 404:\t\t\t\tskb_pull(skb, offset);\n 405:\t\t\t\tskb_postpull_rcsum(skb, skb_transport_header(skb),\n 406:\t\t\t\t\t\t offset);\n 407:\t\n 408:\t\t\t\tskb_reset_network_header(skb);\n 409:\t\t\t\tskb_reset_transport_header(skb);\n 410:\t\t\t\tif (iptunnel_pull_offloads(skb)) {\n 411:\t\t\t\t\tkfree_skb(skb);\n 412:\t\t\t\t\treturn -1;\n 413:\t\t\t\t}\n 414:\t\t\t\tif (hdr-\u003enexthdr == NEXTHDR_IPV4)\n 415:\t\t\t\t\tskb-\u003eprotocol = htons(ETH_P_IP);\n 416:\t\t\t\t__skb_tunnel_rx(skb, skb-\u003edev, net);\n 417:\t\n 418:\t\t\t\tnetif_rx(skb);\n 419:\t\t\t\treturn -1;\n 420:\t\t\t}\n 421:\t\n 422:\t\t\topt-\u003esrcrt = skb_network_header_len(skb);\n 423:\t\t\topt-\u003elastopt = opt-\u003esrcrt;\n 424:\t\t\tskb-\u003etransport_header += (hdr-\u003ehdrlen + 1) \u003c\u003c 3;\n 425:\t\t\topt-\u003enhoff = (\u0026hdr-\u003enexthdr) - skb_network_header(skb);\n 426:\t\n 427:\t\t\treturn 1;\n 428:\t\t}\n 429:\t\n"
} |
| 61/3 | 2026/11/01 22:50 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 21543 output: 36 thoughts: 1140 Thoughts: **KMSAN Needs Analysis: Network Core Changes** Okay, let's break down these changes and determine if we need to flag them for KMSAN testing. First, I've got the `tools/testing/selftests/net/` directory in mind, with `tcp_fixedid.c`, `tcp_fixedid.sh`, the Makefile, and the .gitignore. That's our context. Now, a quick reminder: We *only* kick off a KMSAN session if standard detectors like KASAN, LOCKDEP, and UB-sanitizers *won't* catch a potential issue. KMSAN is resource-intensive, so we use it judiciously. It's all about catching reads of uninitialized memory and information leaks. We're looking for kernel data potentially exposed to userspace or dependent on uninitialized data. Specifically: 1. Kernel data structures passed to user space. 2. Conditional logic based on uninitialized variables. 3. Allocation where uninitialized fields might be read later. 4. Bounds checks that could lead to reading outside of allocated buffers. Conversely, if the code is primarily at risk for out-of-bounds access, overflows, NULL pointer dereferences, locking issues, or use-after-free bugs, we *don't* need KMSAN. If everything is zeroed or initialized, we're good. Let's dive into the patch: 1. **`skb_gso_fixedid_encap` and `skb_gso_fixedid_decap` in `skbuff.h`:** These functions operate on `shinfo->gso_type`. That's part of the `skb_shared_info` structure, and it is initialized when the skb is allocated. It looks like it's a bitmask. The code does bitwise operations on `shinfo->gso_type`. There's no risk of uninitialized memory here because `skb_shinfo(skb)` handles initialization. Safe. 2. **`include/net/ip_tunnels.h`:** We've got `iptunnel_pull_offloads`, which checks `skb->encapsulation` and calls `skb_gso_fixedid_decap`. The `skb->encapsulation` bitfield is initialized to 0 or 1. Then we call the function we already reviewed. No issues here. 3. **`net/core/filter.c`: `bpf_skb_net_grow`**: Here, there's a conditional: `if (encap) skb_gso_fixedid_encap(shinfo);`. The parameter `encap` in the function `bpf_skb_net_grow`is a boolean. We are not directly using any potentially uninitialized data. Conclusion: Based on this analysis, none of these changes seem to introduce the risk of uninitialized memory reads or information leaks that would *only* be caught by KMSAN. We don't need `NeedsKMSAN=true`. |
| 62/3 | 2026/11/01 22:51 | tool | read-file |
0mArgs:{
"File": "net/core/filter.c",
"FirstLine": 3710,
"LineCount": 25
}Results: {
"Contents": "3710:\t\t\t\tskb-\u003eprotocol = htons(ETH_P_IPV6);\n3711:\t\t\telse if (flags \u0026 BPF_F_ADJ_ROOM_ENCAP_L3_IPV4)\n3712:\t\t\t\tskb-\u003eprotocol = htons(ETH_P_IP);\n3713:\t\n3714:\t\t\tif (skb_valid_dst(skb))\n3715:\t\t\t\tskb_dst_drop(skb);\n3716:\t\t}\n3717:\t\n3718:\t\tif (skb_is_gso(skb)) {\n3719:\t\t\tstruct skb_shared_info *shinfo = skb_shinfo(skb);\n3720:\t\n3721:\t\t\tif (encap)\n3722:\t\t\t\tskb_gso_fixedid_encap(shinfo);\n3723:\t\n3724:\t\t\t/* Header must be checked, and gso_segs recomputed. */\n3725:\t\t\tshinfo-\u003egso_type |= gso_type;\n3726:\t\t\tshinfo-\u003egso_segs = 0;\n3727:\t\n3728:\t\t\t/* Due to header growth, MSS needs to be downgraded.\n3729:\t\t\t * There is a BUG_ON() when segmenting the frag_list with\n3730:\t\t\t * head_frag true, so linearize the skb after downgrading\n3731:\t\t\t * the MSS.\n3732:\t\t\t */\n3733:\t\t\tif (!(flags \u0026 BPF_F_ADJ_ROOM_FIXED_GSO)) {\n3734:\t\t\t\tskb_decrease_gso_size(shinfo, len_diff);\n"
} |
| 63/3 | 2026/11/01 22:51 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 23837 output: 41 thoughts: 911 Thoughts: **Analyzing Potential Uninitialized Memory Issues in Network Offload and Encapsulation Code** Okay, let's break down these changes piece by piece to confirm there are no uninitialized memory concerns. First, with `bpf_skb_net_shrink`, it seems we're dealing with decapsulation, and the code appears to correctly handle `encapsulation` and clears it. No uninitialized memory there, that's good. Next, in `lwt_bpf.c`, specifically `handle_gso_type` and `skb_gso_fixedid_encap`, no uninitialized memory issues are apparent; the encapsulation is being handled correctly. Now, concerning the removals in `gre_offload.c` and `udp_offload.c`, specifically `SKB_GSO_CB(skb)->encap_level = 0`, it looks like this was resetting the `encap_level` unnecessarily, breaking the tracking for nested encapsulations. `encap_level` is initialized during GSO segmentation in `__skb_gso_segment`, so that assignment was redundant. This change actually *prevents* incorrect behavior; it maintains `encap_level > 0` for inner headers. It does not involve uninitialized memory in any way. The code in `ip_tunnel_core.c`, specifically `iptunnel_handle_offloads`, focuses on the `encapsulation` bitfield in `sk_buff`, which is correctly initialized. The call to `skb_gso_fixedid_encap` based on `encap` seems safe. Regarding `ipv6_srh_rcv` and `ipv6_rpl_srh_rcv` in `exthdrs.c`, the replacement of `skb->encapsulation = 0;` with `iptunnel_pull_offloads` is a clear improvement. `iptunnel_pull_offloads` un-clones and resets offload flags when necessary. No uninitialized memory is involved. Finally, the selftests are user-space programs, so that's not relevant in terms of potential kernel memory exposures. So, the crucial question: do these changes expose any uninitialized data to userspace, or affect buffer lengths in a dangerous manner? **No**. The core of these modifications centers around managing IPv4 ID flags for GSO/GRO handling across encapsulation and decapsulation, and proper maintenance of the `encap_level` variable. When a packet is segmented, the IP ID header field is correctly managed (incremented or fixed) and written to the IP header (`iph->id`). No reading or copying of potentially uninitialized memory occurs. Let's do a double check. Are there new structs allocated without zeroing? Nope. Are there new fields added without initialization? Not that I can see. Are there any `ioctl` calls, `copy_to_user` calls, or `bpf` helpers that could return uninitialized data? No, not here. And remember, the initialization of the `SKB_GSO_CB(skb)` happens in `__skb_gso_segment`. Based on this analysis, I am comfortable that the changes are safe and correctly prevent potential issues by handling GSO/GRO encap behavior accurately. The focus here is maintaining the state of the packet's encapsulation. |
| 64/3 | 2026/11/01 22:51 | tool | grepper |
0mArgs:{
"Expression": "SKB_GSO_CB\\(skb\\)-\u003e",
"PathPrefixes": [
"net/core/gso.c"
]
}Results: {
"Output": "net/core/gso.c=90=struct sk_buff *__skb_gso_segment(struct sk_buff *skb,\n--\nnet/core/gso.c-120-\nnet/core/gso.c:121:\tSKB_GSO_CB(skb)-\u003emac_offset = skb_headroom(skb);\nnet/core/gso.c:122:\tSKB_GSO_CB(skb)-\u003eencap_level = 0;\nnet/core/gso.c:123:\tSKB_GSO_CB(skb)-\u003erecursion_counter = 0;\nnet/core/gso.c:124:\tSKB_GSO_CB(skb)-\u003emax_segs = min(max_segs, U8_MAX);\nnet/core/gso.c-125-\n"
} |
| 65/3 | 2026/11/01 22:51 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 25741 output: 289 thoughts: 380 Thoughts: **My Assessment: KMSAN is Unnecessary Here** Okay, let's break this down. From what I'm seeing, `SKB_GSO_CB(skb)->encap_level = 0;` is initialized correctly upon entry into `__skb_gso_segment`. That's a good starting point. The core of this patch series revolves around precisely managing GSO flags, specifically `SKB_GSO_TCP_FIXEDID` and `SKB_GSO_TCP_FIXEDID_INNER`, and tunnel offload states as packets traverse different network subsystems. Essentially, the patch is about ensuring the integrity of these flags and the `encap_level` across various encapsulations and decapsulations, including BPF, IP tunnels, GRE, and SRv6. No new memory is being allocated. We're not dealing with any uninitialized memory reads, variables, or structures being read or written, nor is kernel memory being exposed to userspace. The kinds of errors we *might* see would be logic errors in the flag handling, packet mangling resulting in bad offsets, or skb lifetime issues. However, KASAN, standard detectors, and functional tests should catch all of these. KMSAN isn't going to help here; it's designed to find uninitialized memory accesses and kernel information leaks, which aren't the primary concerns. The focus is on the *correctness* of the flag propagation and tunnel offload state management, not on memory initialization or leaks. I'm satisfied that `NeedsKMSAN` is definitively `false`. Therefore, I can confidently go ahead and call `set-results`. |
| 66/3 | 2026/11/01 22:51 | tool | set-results |
0mArgs:{
"KMSANReasoning": "The patch series introduces helper functions (skb_gso_fixedid_encap, skb_gso_fixedid_decap) to properly update GSO flags (SKB_GSO_TCP_FIXEDID and SKB_GSO_TCP_FIXEDID_INNER) when packets are encapsulated or decapsulated across tunnel offloads, BPF packet adjustments, and SRv6 processing. It also preserves SKB_GSO_CB(skb)-\u003eencap_level across GRE/UDP tunnel segmentation so inner GSO segmentation recognizes encapsulation.\n\nNone of these changes allocate uninitialized buffers, introduce uninitialized fields, or expose uninitialized kernel memory to user space. All manipulated fields (skb-\u003eencapsulation, shinfo-\u003egso_type, SKB_GSO_CB(skb)-\u003eencap_level) are existing, fully initialized members of sk_buff/skb_shared_info/skb_gso_cb. Furthermore, no new data is copied to user space or exposed via network packet payloads. Any potential regression would be related to protocol logic or skb lifetime/bounds, which are covered by standard testing and KASAN. Therefore, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false
}Results: {
"KMSANReasoning": "The patch series introduces helper functions (skb_gso_fixedid_encap, skb_gso_fixedid_decap) to properly update GSO flags (SKB_GSO_TCP_FIXEDID and SKB_GSO_TCP_FIXEDID_INNER) when packets are encapsulated or decapsulated across tunnel offloads, BPF packet adjustments, and SRv6 processing. It also preserves SKB_GSO_CB(skb)-\u003eencap_level across GRE/UDP tunnel segmentation so inner GSO segmentation recognizes encapsulation.\n\nNone of these changes allocate uninitialized buffers, introduce uninitialized fields, or expose uninitialized kernel memory to user space. All manipulated fields (skb-\u003eencapsulation, shinfo-\u003egso_type, SKB_GSO_CB(skb)-\u003eencap_level) are existing, fully initialized members of sk_buff/skb_shared_info/skb_gso_cb. Furthermore, no new data is copied to user space or exposed via network packet payloads. Any potential regression would be related to protocol logic or skb lifetime/bounds, which are covered by standard testing and KASAN. Therefore, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|