From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.42 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796086786; b=Gsp2lmvmZNx2pUjy4eVlh1PY2FS5FxbR49qaCF8mMq5uBkYm3IOQLiKgxKZ9CWB1/LUn ZPE5FpylaAj5m9QIyzn7Q8ffj1BlqbqlkNRTQOP5FEG97DsQVMFuQqpBoUJ0tIySl5TRj ryvUQRlAhHEP2JY6iEhvxJQ+jwD/Co5yzP2SJLDmXkpKWWGV9bAMV4FESbnttKtbzLD/J XAOOAbPaTLYeAcItKoLNAk+sMUY/qXjkg0eLY6tuXB0E4gz5ZktAsZcf3D+eY6VCmxHcm /fRAAARANfepPR+bFCNpksnJsqxOeyxsj3fn+7TnILmzbRqQWxKy6cLulbNvq5CXndQ== 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-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=no+tQp9g3f/y46AqWaxVdMYhf+LoU69CBiRhCcWKQxGHBo5BFGCvP69ns1ClqgQkkcU/ STvR1Yf/NvpEI4HDZyb3K5ny4x9B+J6IvNj87Cw+//q0qMCXRwKvc0l5n2qYfcW1MyPBp NxUi1PHy8tfRPwTaUhzXGo9VCnQzGz/UIKuQKls4S/QwHISdUo7qL+6P2XWNOlD/lZjlJ z+EIHa9oCqVvTDNk86WtilkWctW1jwv1v9xbzaT6zdR0P398YWT1viWqGb6aWgTsk4n2W VkovooOXmdqFZ6iaH904fiTgAXGqeMkFKIvDGTwJW4DTFJdkg25/ktuxwxSA07FUKGA== 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.167.42 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (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 B86C1606A320 for ; Tue, 1 Dec 2026 00:59:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B86C1606A320 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-lf1-f42.google.com with SMTP id 2adb3069b0e04-5c15ccd7fb5so7138422e87.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=hyEHnM3ycknO10XL1nhMWTnP+k6H8jedpbWCXj1blL/Dju76eLMYwvdFR5J6PfGrr9 yYso7cXx78+VDLF+P2gmQX+V4GazBc2ndCESMTNrKhZS21MEBcvwd1SOvYnj7mRY+rbA rdEKNVGm4iEmbsNdqAEFapWagefc0uBrMsHOH+Ns54kRcnIPbj7hxzlg70nzkWkNOJi3 fHQL+8EMZ05cE+uChHdAm1J4nX62L6WDY0ewBxrNyeq7RjyhgmIa445z96wlMmZSPwFt 236CAt+/94clZHX2dN3wTfB9SzqgXbVpEPqkRm0yR0rCwFfxBly0gQU9gX3QlVKBcsWA ULtA== X-Forwarded-Encrypted: i=1; AL+hErERWYTOmfoS7aS6urGuinNQpZDZVkpLVo3B2GCwW+NNj2O7GCYMxqAppaCc9JjGsEViW3ePlKgkkqbqLos=@vger.kernel.org X-Gm-Message-State: APuU4Z/Pirx/C5QIBmX4jnLa5J8FlzxfUo5cwupY8yXA7UJArV9pivtN wMA1mJKBaemu4QkPezrgtwRG0U5BYtP1OuyvSTj8rqNIpP4YyNsJeHMs X-Gm-Gg: AZFdTZeCqU3KxlytFUYaGD7V169FjMubeqUC7NSbP0JOn6w8TQabtUssyznQ+S8vEJA orXIyienA3HQCY/LdAAnP8vC8/CYh6prLqyBRqM/MLYjRz6s97SyaCoxtfTuhIGgRb/Lx9YI+Z1 aGqHRtRWLuSfqK86wLW8tirgZzWolBXmCG8Mikp/i4Q2sj1PbfWpkyRRg3HJmEvCi9QBPCqg5y1 06kzb+nHbI9dt1Jdtdd0hzyUZvUVFkpfbpJwPFzYuJoy2q2lLVpajBgVcDQWdMzxE/6NTSAIS4d V7tCYmp6WBb4iUfyTSwcFSQFXDmETsEZafhmE6eWPXpR8TE13Uu2O/BOUmnpOTu2ghJAI+A2KEU azAwSCKET0T7+W/+grUKIZPch20J1gTm/xZGSi7eCo+93tn74isV9Cg39ZTPx4z/N4vK4EL+aCB Cy329pPOmVvf+qG6DviJ7L9JfItJgQUHrPJGZwO4KwMBmWEpSpxgTs0r+aEmE1Y5PsToQdmIkEV N6ZwKOAuHu8wozfFdWG9l3YFyLbYYu4eHWdAOraPh4Sx85m0brpv4df0HbLnkSdRdBv9Iegalf5 DlA87C2mpd7qJdq7LkyPgqvEAiZ8bnrAcFQE4+spjre9xmDMcwiWXRGOSJYWaAhnF5itKDHBu6s qGXzOSrcpYzoz2Uc= 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-kernel@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