From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796086787; b=waWJN2OgkzHS1JJQP+EjZrwAvIJuAdFcXV6vaTwxgZZSbMXBdGBCrZ64jRfo87rjoMhB lsWy70/epkeI12lc/rAOonK0IuPwQATqYVqMTG3axnFWq6IwcUiqW5XGb9OEGX9H4eWSS Dcxho+/LDHzdpIfA7Nnz3mgGieMMNihuh+MPG+24K55QIdjwxyEiQqbeBx69s293WUzxo kEm4HCBYQ2sMc5vYHZn3TD9Af/KBG/ixwT+gvm+W3TW1/47qCERPzf3m1fKRwZWFiJi8c OLtoDCM5V4KlNBS28Yeqb0lr8/KLqsEmKBazv/67fG8OUXYz48GPZLNJUiO7iHELDtQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796086787; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted: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=FLt7PR6pyRfWZej3P5oufPLag4mi4ZA6cGJyRnzEgzAfVmRBkysoGF2Tk4B2/5+KquCX 6gFZ41Lb9ks+kLdnLDO8mRyXAO/5ix33LkOHTXvEY+AjHozp3vXfTaFJc9F4oi6pf88vr gbb90wFX6Zw9+rc2grpAJsjwEOqDfOmJGgAQgNguhBJdlNNSVywJOwacLzjJaZgSB/7Sh qoEyDfQAT/D9K6eUlfWUZPy/4//x3gd0fYdd4gcRZ0Ajesj81ngE+oiOVplpJoKKWFq41 ecDduLid68CPbj+sUNJscANj2hNu0eeWKNYo9TD+QWB297SMwLNwlnI0GF+uIzZVtDQ== 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.170 Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (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 B6B8E606A31A for ; Tue, 1 Dec 2026 00:59:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B6B8E606A31A 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-f170.google.com with SMTP id 38308e7fff4ca-3ae2fb3fe2fso104690281fa.2 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=IcYr8ml4LXksubhEXg6rfGKMkZhbyjBxfeHdNZ8Nm9zs2uvmcwgPmLC1lbWaxgRacR KKTFZ0jpdQklDiiEnlQoZSDbcki3PjdbVU50IdxK2bRfY0ZFh0qE75Ennp0/EvdiDobe +Rce2L5AbjCZLFj0A2jl9JnUiIa/srzPn1mHqVfpfoo1wQJcFrtNbmSi6G37UoglMhMZ yScj7kBO8//18q+FSIShOSq8AYGOb7GKzWe3d9LgQLMgkaPywG0IC+bevsCU1GnD4cIr SKxOl8OrxEfhps6itHNLJDljE43FwYcBXyAI02CWX2u3yzU3RFyHt//iqd+znbfqDqCd X/Kw== X-Forwarded-Encrypted: i=1; AL+hErEygSFsSiCLVN1Wsy+iYbSI17cSPSldhVQ/bTih4jT8pkzO/4CwmxCc87GQRv2G49cHQFDVtlWTbLxSyEEJXqE=@vger.kernel.org X-Gm-Message-State: APuU4Z92cI6wVaEJDyAxekotXwvb1X4Z1qHnAIkwNzaumhWGEIihJ/Yr aONyYPmTo5V7VpChxTzdHLE6a0Jk0xY73y4r3lnP80RcqSBr0DL+UfBj X-Gm-Gg: AZFdTZdCCK2GUh1IO88XOPBkIyGnSFOEaouPIainPLI4AXpzT6cDfQWHNfVc9z7NCgq POzDIBFv8DFK4ktMRVp1R8YLMFmnfOUldRPQwGiqHw1B16bUgzxsANXcZFl3KqqxXo6g5ifDdJD g3nxH7E0lPBYJICQccsOJ2guosGw9AyGN1wPYWNivMOWeUeVD2TTECsqAahUn5LuJQ7ngeYJH4H 9o6T2vFW36C9BW1sTJC8Rtkfthkeu3vUWLkAxEdESKNI5wNiWYXs6usyp2C6xCOjd0yg3a/rSd0 +szGuaFinsyen7bxZni4ocR0Ht632KRLYod65s/AGnZhEXq2a4VgW2aHPNV3997Gj/CWUOri2/v +NZygkm8sF6JKifz9rDVnb2rPgH90Xl7YK8PDjCMFpBWL1T/K/zRTTbFQ3UfKhhSm7b8wOVfoPS p03YckgDjWwGo0nTsUPAMqvRkXp3j4RfNHNznrQtXYsPvLwvSKY9YJpEi2qivN7C2TtUoZG8Af4 M+GVw61ujA2klOGPsz/NjiyVVwrM8zAmd3XHzgRVubKvDjqSmDhMvhmBcy67xu9+U8V5XuwXTIg kDwz5O2qpPElyHJjyDRu2Qduu2bIRgHxseXkBUk3kIK56+ink3bICYmptez7KCBkAD+FqBIIjBi uFsC64dS6WkkrHKs= 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: linux-kselftest@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