From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.171 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796086786; b=46skb1wS3Fof+FhhDWmeY8bBnhtpdSyuzbyE2lh9a27y8FIVdW66Megr23XjEagMNhMI Ajl33tdYtmcXDksmQMrsTob9b9d/ytRUWkHlJergrzK6kRhbHqqGbeB4/DZILvqd7d8Su X1FIdNSfllaMrcKGTjSKnm70CG3B00XFhXxtGfe1iM6pC/6TeniQXGcvxtMiLH9CuhhnD IZOaOrksUf0bVPJ2NYiqAVReqkyb0W/C2oFgoJb+tEzTRzQPBhn0vkJH8Hg00TspIGUJB zva6DVPVqeDJBiYUAXzKjeELPCmjHGtoZs5tU+FvjjsQrZdebpUesBi1m+q528QXC3g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796086786; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=NeEXyGCm+HgbzlK8qAe/UZ+HeBfY7S6hlxWR2jbTR+s=; b=ts0w8COrYXj6ySMoxn96gnY6WCHgxfLS5DO7lnC5RsIOuxCjr/UD9OFB/U8kulxyx6k5 sMO/VfPwAqnB2zlXTxFXqOepLXJgUarLv1fL6QLXEgXIREXLRYjfziGFq18yoPclCCCPK 3he/kjrIKVWohn6SWTSpho/gynpvCk5sa82nNJ7l9QTI/uB8LqKG/9qgS/5JDw3aXwbCo 65gq3pekqyyfhXFzO5NCPKgG2Bnsvi3NATg8CyxC7UuZS8Sk85O2AyyNPuO/9NgehwSqQ DPMmoInPJhoOy48iT9kL7MUXEV/q2yKw483sLcIb6DNwPs+jtAQaw4JX1ywASNIBIsQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Blhye6lQ; arc=none smtp.remote-ip=209.85.208.171 Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B879F606A325 for ; Tue, 1 Dec 2026 00:59:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B879F606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Blhye6lQ Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-3ae7d1ce1bfso93230801fa.1 for ; Mon, 30 Nov 2026 16:59:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796086784; x=1796691584; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=NeEXyGCm+HgbzlK8qAe/UZ+HeBfY7S6hlxWR2jbTR+s=; b=Blhye6lQSP7f+EB9l5fjAaVqXVkfp4qA6qCYKvrlqjPonJvwr67F8DZU9V3cKrq2il oRT+zxfu6Ml0NFLTBJBDn5DFerfppJxnUm249YGFsDsVMcG2l0n5zVMuwV5s0hvIAAvo GioUeMmRDv06UB1xa+BLl3kcBgj+TY4XW4miNclxx2BeHTA2rYjum3Q7k5X6859cyNRA FqioJvaNKso12hylf51VNm7JOAUdtkny3IKrdGW8bEWVQ9FVue2XuirxdDNZbimRSLTX +ZUZbpUd05zJAgHnV7pzppx3suMY+cj7pgUGxjbnqiTFT/b/WIe4LttdxiSUfRbTtNeb 35dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796086784; x=1796691584; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=NeEXyGCm+HgbzlK8qAe/UZ+HeBfY7S6hlxWR2jbTR+s=; b=BG/eaxiudCtF847akrQBv4TeOvbkDRz4pk+YpyzBxdKpTwb2dW5trZtuqugS+IIO1T 3EMpvdsTfO9G7sWWZ/SWun7rZqr4jMpM75jHUJAiMcANYu3TqNh27rRb3HJzGi1c9aXx 8zSDcGOiLfiGYZK9Uods/GtR7M0fGidIvjA4K4TNhRCo/16BAxJoMYts3lV7a39UmOql koKzDNK6izbvFIMC5U2PAhjBVBxGGyF9dKMZQNNl+dWyK9E/OoX0+PHDiSUZgh14aG06 sueh/6nwjZWRVmA1TtpShWQlzSQMZMxFQAFnKZ02KjND3KA0PLBXNOJ0Hf9oSA1AfvsT Aijw== X-Gm-Message-State: APuU4Z815DZx2bd0C7QyBOBCp4wN4LhlUSPWbgy61mjn2GDRAYsSpMLX ++6jfBfRaiwxE5Y7L/kEucPsSmN4vLyONMghFuWjXLXSbX5FtlOoexigUziX1+Dr X-Gm-Gg: AZFdTZeeYIh2c61HTju/duODW5s4bFpyGCjcZ9zkR4nCDWPayjc4YDoQn7Oh8X1qyB2 C2fc55yPJCZ6yeF6gJWvAhY36p3lb0tEZWUOx5UU9kgpR4Q+SQaUiRks338gB6RXYkMqwWMAoSQ xgO2xE1SCNbdndkm0ID6V67SO0G8ape73i7G9BYNIxp8/bhALqdCO2PPXTAeD2pc0IyYpC3h1oS 5xaWp5emAW/Xp6lfzrmLcjMF6S9aw6H08pkp4ocScpuc0y6MxDqPyA4xs9JIEKrK4SzKHjqvEku 7f0YOy/ARVHxB8gjOjyBJJxXlY4PcOoMgvGWGrNWFnLO8pD3zhuwuxXXPAmDLUS/iR33SJyQEir X7tScj7XuaWzZtzpo1S7bpMd7DTQXsOB8tO7m2hOsR+0JU5uAxtbzmaL9KQChMESv2g6enIepA7 1SkIy7tRqu+0Y4fIvJmHJaVIIfeK1b9nueqDyokt5tLZ5/MwiCueQ3G7jDeqOiqWbbBfraXEDSN nmLajZHEF7gEFMGNMl+CYvzGxS4WADt/DDjNEXRnbg8iCpowKXuE1XjbLqchL5E9NmYu/49czDT W7ZV2CMCMOasugf1/zCVND4SK/ZDgqPxAvaXSaeEddIjBFQ7PNQLrk8UryiIoqxOdCqIaWd7TOa shUv7RQ5stj6dlWI= X-Received: by 2002:a05:6512:1052:b0:5c0:c5e:3d7 with SMTP id 2adb3069b0e04-5c1bc81d5ffmr12766376e87.52.1796086783631; Mon, 30 Nov 2026 16:59:43 -0800 (PST) Received: from dau-home-pc.megasoftware.org ([94.28.149.75]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5c1bd040a9bsm8895709e87.48.2026.11.30.16.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 16:59:42 -0800 (PST) From: Anton Danilov To: netdev@vger.kernel.org Cc: Eric Dumazet , Jakub Kicinski , Paolo Abeni , "David S. Miller" , Simon Horman , David Ahern , Willem de Bruijn , Ido Schimmel , Florian Westphal , William Tu , Meenakshi Vohra , Matthias May , Mazin Al Haddad , Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v7 0/5] ip6_gre, erspan: fix inner header handling for VLAN-tagged and short frames Date: Tue, 1 Dec 2026 03:59:36 +0300 Message-ID: <20261201005941.1536429-1-littlesmilingcloud@gmail.com> X-Mailer: git-send-email 2.47.3 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This is v7 of "ip6_gre: use skb_vlan_inet_prepare() instead of pskb_inet_may_pull()", a single patch for net through v6. It is now a series for net-next. The reviews of v4 to v6 kept finding the same thing from different sides: on transmit ip6_gre works out what the frame carries in three places, each by its own rule, and making one of them right moved the problem to another. I asked about the scope in the v6 thread [1]. This is the wider version: the packet is classified once, on entry to ndo_start_xmit, and the result is passed down, to ip6_tnl_xmit() as well. The whole series grew out of Eric's original patch (v1 to v3 below). Patch 3 still fixes the mismatch that patch fixed, at the same two call sites, and carries his Suggested-by; the other patches are what testing it turned up along the way. The series targets net-next because it reworks the transmit path and changes the exported ip6_tnl_xmit() interface to fix these long-standing bugs together. Patches 1 and 2 are about erspan_build_header() and erspan_build_header_v2(), shared by erspan and ip6erspan: - patch 1 bounds the VLAN tag read, which does not check that the frame is long enough (syzbot report); - patch 2 takes the TOS for the COS field as IPv4 or IPv6 by the frame's own protocol rather than by the tunnel family, with bounded reads. Patch 3 is the classification in ip6gre_tunnel_xmit() and ip6erspan_tunnel_xmit(): one length check and one answer, read from the frame itself when skb->protocol is a VLAN type, and no second parse in ip6_tnl_xmit() after the GRE header has been pushed. It closes the second syzbot report and makes the hop limit of a VLAN-tagged frame inherited on all ip6gretap and ip6erspan devices. Patch 4 makes ip6erspan use that answer where it went by skb->protocol, so that a tagged frame gets its traffic class inherited as well. Patch 5 adds a selftest for the inherited hop limit and traffic class and for the ERSPAN COS, with and without a VLAN tag. The erspan patches and the ip6_gre ones are in one series because they are about the same frames on the same transmit path. Not in this series, for follow-ups: - the IPv4 side: gre_tap_xmit() and erspan_xmit() have the same mismatch between the check and the parsing, and ip_tunnel_xmit() and ip_md_tunnel_xmit() the same parse after the push; - ip_tunnel_rcv(), which sets the network header of a tagged frame on the tag; - an ip6gre device with ip6gre_header_ops takes the outer destination from the packet in __gre6_xmit() without a length check; - vxlan and geneve call skb_vlan_inet_prepare() on transmit for every skb, which sets the network header on the VLAN tag for a frame that comes from a VLAN device with reorder_hdr off. This series was developed with LLM-based coding assistants (Claude Code and Codex). They were used to write and revise the code and the changelogs, to build and test the series in virtme-ng, and to review it before posting with a local run of the Sashiko review prompts. I have reviewed every change and every text and take responsibility for them. Testing on net-next 5eb53a1fbf80, which includes the tunnel drop-reason series, was repeated for both the base and this series in virtme-ng: - the new selftest passes all 24 checks with the series; 10 fail on the base; - 16 existing networking selftest scripts pass on both, including all 72 l2_tos_ttl_inherit checks; - 264 functional scenarios per kernel reproduce the earlier results, covering frame layouts, COS, mac_len and reorder_hdr; - KMSAN probes cover 61 scenarios per kernel. With the series, only the known IPv4 gretap short-frame case outside its scope still reports an error. Both KMSAN builds needed the same test-only objtool workaround in mm/Makefile and emitted a return-thunk warning at boot, before the networking tests; - all five intermediate commits build, including W=1 checks of the affected networking objects. With CONFIG_INET=n, cls_flower.o builds at every step and the final kernel builds as well. The series was then rebased onto net-next 16f67342f619. The normal-kernel selftests, the 264-scenario functional matrix, the intermediate builds and the CONFIG_INET=n checks were repeated there with the same results. The KMSAN results above are from 5eb53a1fbf80; KMSAN was not rerun after this rebase. Patch 2 retains the existing DSCP-to-COS mapping. For a VLAN protocol, it uses the version nibble at the network header as a heuristic for IP; this can also match a non-IP payload such as an MPLS label. Its COS is not guaranteed to be zero or unchanged from the old implementation. General non-IP classification and a new COS policy based on VLAN PCP, MPLS TC or skb->priority are outside this series. After changing patch 2 to read named IP header fields, I rebuilt patch 2 and the full series, including CONFIG_INET=n, and reran the new selftest, gre_gso and the 52-case COS matrix. The full regression and KMSAN runs described above predate that cleanup. Changes since v6: - a series for net-next instead of one patch for net; - skb_vlan_inet_prepare() is not used any more. The review of v6 pointed out that it also moves a network header that is correct: a VLAN device with reorder_hdr off leaves the tag in the frame and skb->protocol as the inner protocol, and for a frame mirrored from it v6 took the hop limit and the traffic class from the tag. Now the frame is only looked into when skb->protocol is a VLAN type, and the network header is only set when the tags lead to IPv4 or IPv6; - the payload type behind the tags is read from the frame, from the EtherType at offset 12, not from a depth given by skb->mac_len; - ip6_tnl_xmit() gets the payload protocol from its caller instead of parsing the packet after the GRE header has been pushed. This was listed as a follow-up in v6; - the two erspan_build_header() fixes, listed as a follow-up in v6, come first as patches 1 and 2; - new: ip6erspan uses the classified protocol (patch 4) and a selftest (patch 5); - the subject of the main patch says what it does now. [1] https://lore.kernel.org/netdev/20261014005308.1606362-1-littlesmilingcloud@gmail.com/ v6: https://lore.kernel.org/netdev/20261008012554.202925-1-littlesmilingcloud@gmail.com/ v5: https://lore.kernel.org/netdev/20261005231414.932997-1-littlesmilingcloud@gmail.com/ v4: https://lore.kernel.org/netdev/20261004145205.226974-1-littlesmilingcloud@gmail.com/ v3: https://lore.kernel.org/netdev/20260119112512.28196-1-fw@strlen.de/ v2: https://lore.kernel.org/netdev/20260106144529.1424886-1-edumazet@google.com/ v1: https://lore.kernel.org/netdev/20260105100330.2258612-1-edumazet@google.com/ Anton Danilov (5): erspan: bound the VLAN tag read in erspan_build_header{,_v2}() erspan: take the COS from the mirrored frame, not from the tunnel family ip6_gre: classify the inner packet once on transmit ip6_gre: go by the inner protocol behind VLAN tags in ip6erspan selftests: net: add a test for ip6gretap and ip6erspan with VLAN tags include/net/erspan.h | 68 +++++-- include/net/ip6_tunnel.h | 3 +- net/ipv4/ip_gre.c | 13 +- net/ipv6/ip6_gre.c | 95 +++++++--- net/ipv6/ip6_tunnel.c | 11 +- tools/testing/selftests/net/Makefile | 1 + .../selftests/net/ip6_gre_vlan_inherit.sh | 172 ++++++++++++++++++ 7 files changed, 308 insertions(+), 55 deletions(-) create mode 100755 tools/testing/selftests/net/ip6_gre_vlan_inherit.sh base-commit: 16f67342f6192f04fec94fa0c7a3ba03e7a24578 -- 2.47.3