Article View: linux.kernel.netdev
Article #26375Re: [PATCH net-next v8 2/5] erspan: take the COS from the mirrored frame, not from the tunnel family
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 12:38
Date: Thu, 03 Dec 2026 12:38
148 lines
13640 bytes
13640 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit fixes two bugs that are visible on the wire, but it
has no Fixes: tag.
Pre-existing issues:
- [Medium] erspan_frame_tos() (include/net/erspan.h) still gets the COS
wrong for double-tagged (QinQ) frames mirrored from tc ingress.
--
erspan: take the COS from the mirrored frame, not from the tunnel family
This patch changes how erspan_build_header() and erspan_build_header_v2()
get the COS. They used to pick IPv4 or IPv6 from the tunnel family; now
they pick it from the mirrored frame, using skb->protocol and, for VLAN
types, the version nibble at the network header. The read uses
skb_header_pointer() and gives 0 if the bytes are not there, and the
is_ipv4 argument is dropped from both builders.
> - a 14 byte non-IP frame gives a KMSAN report when the packet is
> received on the other side; with the patch it does not.
>
> Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
[Severity: Low]
Should this commit carry Fixes: tags?
It fixes two bugs that show up on the wire. One is the COS taken from the
tunnel family. The other is the read past the end of a short non-IP frame,
which puts uninitialized bits into the transmitted COS field.
The previous patch in the series, "erspan: bound the VLAN tag read in
erspan_build_header{,_v2}()", has Fixes: tags and a syzbot Closes:. Its
message says the KMSAN reports only go away "with this patch and the next
one, which bounds the remaining read of this kind".
Without tags here, stable tooling could take the previous patch alone and
leave the uninitialized COS read in stable kernels.
Based on blame of the removed reads, the candidates look like:
Fixes: 84e54fe0a5ea ("gre: introduce native tunnel support for ERSPAN")
Fixes: f551c91de262 ("net: erspan: introduce erspan v2 for ip_gre")
Fixes: 5a963eb61b7c ("ip6_gre: Add ERSPAN native tunnel support")
a3222dc95ca7 only moved this code into erspan.h, so it does not look like
the origin.
> diff --git a/include/net/erspan.h b/include/net/erspan.h
> index 6bda757b6da21..c272b3fb9bfd6 100644
> --- a/include/net/erspan.h
> +++ b/include/net/erspan.h
[ ... ]
> @@ -170,9 +172,46 @@ static inline u8 tos_to_cos(u8 tos)
> return cos;
> }
>
> +/* TOS of the mirrored frame, for the COS field, read at the network
> + * header. The IP version comes from skb->protocol or, for a VLAN type,
> + * from the version field there, and not from the tunnel family. The
> + * bytes are read with skb_header_pointer(), so a frame that does not
> + * have them gets 0.
> + */
> +static inline u8 erspan_frame_tos(const struct sk_buff *skb)
> +{
[ ... ]
> + /* Version and DS field fit in the first 16 bits of either IP header. */
> + iph = skb_header_pointer(skb, offset, sizeof(_prefix), &_prefix);
> + if (!iph)
> + return 0;
> +
> + if (eth_type_vlan(type)) {
> + if (iph->version == 4)
> + type = htons(ETH_P_IP);
> + else if (iph->version == 6)
> + type = htons(ETH_P_IPV6);
> + }
> +
> + if (type == htons(ETH_P_IP))
> + return iph->tos;
> + if (type == htons(ETH_P_IPV6))
> + return ipv6_get_dsfield((const struct ipv6hdr *)iph);
> + return 0;
> +}
[Severity: Medium]
This is a pre-existing issue and was not introduced by this patch. For
double-tagged (QinQ) frames mirrored from tc ingress, does this heuristic
still take the COS from VLAN ID bits?
On receive, __netif_receive_skb_core() untags only once before
sch_handle_ingress():
if (eth_type_vlan(skb->protocol)) {
skb = skb_vlan_untag(skb);
skb_vlan_untag() moves the outer tag into hwaccel and sets skb->protocol
to the inner 0x8100. It then calls skb_reset_network_header(), which
leaves the network header on the inner TCI. If the NIC already stripped
the outer tag, the network header ends up there as well.
The path then continues:
tcf_mirred_to_dev() -> validate_xmit_vlan() -> erspan_xmit()
-> erspan_build_header() -> erspan_frame_tos()
erspan has no NETIF_F_HW_VLAN_*_TX, so validate_xmit_vlan() pushes the
tag back inline with __vlan_insert_inner_tag(). That moves only
mac_header and sets skb->protocol to the outer vlan_proto.
In erspan_frame_tos(), eth_type_vlan(type) is then true, and iph->version
is the top nibble of the inner TCI (PCP << 1 | DEI):
- inner PCP 2 with DEI 0 is taken as IPv4, and iph->tos returns VID
bits 0-7
- inner PCP 3 with DEI 0 is taken as IPv6, and ipv6_get_dsfield()
returns TCI bits 4-11
- any other PCP gives COS 0, even when the payload is IP
The commit message says:
The TOS is still read at the network header. That is where the stack,
tc mirred and packet sockets leave the IP header, ...
Is that accurate for this ingress QinQ path? Could it be added to the
list of cases where the COS stays wrong?
Also, the later patch "ip6_gre: classify the inner packet once on
transmit" adds ip6gre_xmit_classify(). It walks the tags with
__vlan_get_protocol() and calls skb_set_network_header() on the inner IP
header.
No later patch in the series seems to change erspan_xmit() or
erspan_fb_xmit() in net/ipv4/ip_gre.c. At the end of the series, would
the same QinQ frame get a different COS over erspan than over ip6erspan?
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202123613.1708463-1-littlesmilingcloud%40gmail.com
Technical Details
Message-ID:
<179630153945.3146.8297999303296790417@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376601-linux-kernel-netdev=dewy.ruReferences:
<20261202123613.1708463-3-littlesmilingcloud@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376601-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v8 2/5] erspan: take the COS from the mirrored frame, not from the tunnel family Date: Thu, 03 Dec 2026 12:38:59 +0000 Organization: Usenet Network Message-ID: <179630153945.3146.8297999303296790417@kernel.org> References: <20261202123613.1708463-3-littlesmilingcloud@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2489365"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:RYtcYc3Ng81xIhMV3i9Kj5v4aXE= sha256:CbkksjhmTN6+cRUbA+hk9zfRaIzgeKJnaTN0AceQnKQ= sha1:jegYRCbdGQhY0RsrlaodxQ8EZgg= sha256:HmL/S25BIXTTYD6DCam8eg1G7cJ6j6j2fFvbMvH1rv8= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 83D72117941; Thu, 3 Dec 2026 15:39:20 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.74 X-Spam-Status: No, score=-3.74 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id L2xHbfwQA3Ch; Thu, 3 Dec 2026 15:39:17 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376601-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 4BC041178EF; Thu, 3 Dec 2026 15:39:09 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id C3FBB258D0; Thu, 3 Dec 2026 12:39:06 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796301542; b=gjkGhfiWVYkSmdhmqhj8er/iaJBsvyMnvcURe1VnupL2W8YT2IliR5fxHgj32cOjbkIi 1zUISL0aw1FXyUROg6S3LJ8xdB+oBDjuq6oHvCuUZVw0fHkPAZ7ZmFPwbgnzTBGk3zy0U G271x3I664AttYU2TwUdsWo+PbJ0dbjgmyK/urd9g/66B4DyibbtZEomjm6qBzDI6ac9B UmeKY/PULi3C7riDAnBi7ZjxyFEwVVvHod15Tx/iD0MR46M4FyStjwHERYxyf+2GPL5sE 5O+fHUslL73PlHmz4OKokphB16Zu+rHN67UNPJ6k9mjfdZc36ilomU3vrWe4yVQaD/A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796301542; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=xTSSt6Nrw7Pom8Ttc1VGW/qD+IeQzSk6349JVAU/8Mg=; b=cJ+S6zJLG0YlCDuB3QrH0buhNY4R73l0yOu3JICQhx5iMYivyHuwbjd+FqmPVu9quAEQ x3+o8FU3S+RwjGnGWczARqEOgFDmr1XWx8A4fZJjzih68aZoJhDH1CKH8UHI4GU4/gXCM JFYDBvIjfAR3T6MqS9vEuqZmvi7Y7lGbZM2RpYAA4R3uY1/BjkyXMML24N05sG62oQe30 dnst3a+EKBQMcMmMWrfd2OPu5ZZbo36AA2/M6WEBBvrzmdNRXGd85+Z5TNlalVEq8TvBa B48u8OZfztASa59janAIChQ3kfEJ5gJZ8geoJeIFxpAu+RMYUJSbWRl+FTonxLBv6eA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jLtuqpJf; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 573EC606A691; Thu, 3 Dec 2026 12:39:02 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jLtuqpJf X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796301541; b=SdhLUcK2DEAN6VRSvVAflYY3Uwtj/W/0FSlZZPcXPNjYdfwC0a1kd1qmruiMpPEvDnvd BThWTUJhAloJq2/gvGPuO86PrWKJgMf1vBQJkikw7T6mAhkjXNHtvSdihZN31KeacwG6J uETgFY80lPlMY6TG4T5R0q00o0OndZnrff3YVOct5nwM/EwxGiSKvBKtkK3gwU2AT2rfy 7v3Sxjc78o6bbsX+uBFq5s3F48twboBBsOSaoz0cV72IqZSMH6GR+k/YXTUGoOAgBuUtv YwIu22l83DwP1QWY4lw85CQvovw8HTuEwXzz9aUCcul4UXEhXzQfCcOWWfOJLmlrNVA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796301541; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=xTSSt6Nrw7Pom8Ttc1VGW/qD+IeQzSk6349JVAU/8Mg=; b=QuiJODcOcwgal4cVnj65uFmBArTl9bzsFJ5kRcUig//8U91dPQPaCQc6b5i6ob/nNDab ax8o7Xrk4c7fB/Ujag1Yflk4jmV9t7+Aqcjn7tvhyuiufUgQsU9iGWmIsDy0IA7isv0dG WPWunvxAqyKh/3884zf97i3m3e/XCUhNihhcngt53BzoJlnVYddZHHzQSiGuCQEgl9+JN UxstUEdEQGw/ewEdCsbDAoiI+nu2g+hcvHeyYiknw57GIPvxYcwe/nc1Vvvj5P6NuYSA2 MyAluf/eDlfdIKBbvdiVDwehua/7j46pC7r1faRNHDo7+l2CEq/UrQaATThZXJZ58dA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jLtuqpJf; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7567B606A68A; Thu, 3 Dec 2026 12:39:01 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFE481F000C1; Thu, 3 Dec 2026 12:38:59 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796301541; bh=xTSSt6Nrw7Pom8Ttc1VGW/qD+IeQzSk6349JVAU/8Mg=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=jLtuqpJfqfeyPKdBMQH6b888d1nnvV2v7JbpgeZwIndWVIDHCik5KAqA23y4y3MfB 8roRK5n8p7wahB/5TwpH75ruQS4DmK00WvMiUPZ9+0ApFk/EKESecunMOUSCMWlzV2 wYiJt49D0BakTWtgAmfGFPDEu7eELouYA3Erb6uw6fWDxx+u32RYyDB4QSRMHE7OWz 4E2+DljWFA6sKzCsyRIBQzSHi1rnO6v/du1R93M4LAKo6uU0G9QF/jSS7arBh2eS78 F4j/HJhRD692qSbbuqcu5qNpoWflbKBV/9Xsszn8AVM39D7dHHxHTrRI21NnNRAgWX m9D/CpV8Rwx2A== X-Cc: netdev@vger.kernel.org, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, horms@kernel.org, dsahern@kernel.org, willemb@google.com, idosch@nvidia.com, fw@strlen.de, u9012063@gmail.com, mvohra@vmware.com, matthias.may@westermo.com, mazin@getstate.dev, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org X-In-Reply-To: <20261202123613.1708463-3-littlesmilingcloud@gmail.com> X-sashiko-severity: Low X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list