From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.177 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796086791; b=kVaLFiDoF86z8O+hffclzEteqGa2I6cDewRNltEKLuXns9RzqMWFoLT7395vR8bTsTgk kojYw6mVjUe3qzIGXUvJHMtq5ndknwX7Qj8CcvT7kQ5XyENyO5FrXPizTbxos931USmqZ dgn7OpjhpvIK+WQoPXslFPWSi5WX6KydE6a+lvTAtQJRI3oTWdoH8jizCe9A19WR6bLIV KvOHikrBDkjsmaRnhtVaE9tJdcbCAY1PVIJ+pYqKn6KYNq1rx882Q8aDOIqzjIhjg31a3 fTUDEQFILzf3emC64PoPihqHQ7sGyKK1QHZZPsDLKmng9yf6TkhG+zmvcrV/VSFVbEw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796086791; 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:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=YI6QzyshgCnAiQAi0cMKDIcSabKCHc2xzycllpG1rm8=; b=0XPuCUxPIHr/a/KDWB1m1LDKsV1Zh+noG0/Hq+TfvIja0njwqiC7oXIvHhP2sFK5FwSH 27pQE/Ql6hUwyR0oJOJb+gWyPOZU0tj4FVKUYvXAgqqcxqTlLwEQ1AbHUV/Bq7dUe9ZAu XvaWn2AjOvGGAF9kvYR+yegzrsrPzmg8pC3l3IXEmvm8+/0dAWI0PbfQIv15sAnfI46Rm olbFxTmBJF0qvi/ENUc1aznqTvNcgFv8pEmujfCvTYifyF9SicGU+CSTSdyGxAdByioqz 34RfFw+N1QAiPyoWsLHdB6s+CoKBiiy6C3x2SDn++uXvpXBi2QbFkkFoRNV5pQD/Dvg== 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=G6VwrcPU; arc=none smtp.remote-ip=209.85.208.177 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (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 7FFAF606A6AF for ; Tue, 1 Dec 2026 00:59:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7FFAF606A6AF 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=G6VwrcPU Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-3adfed9a887so103056881fa.3 for ; Mon, 30 Nov 2026 16:59:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796086790; x=1796691590; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=YI6QzyshgCnAiQAi0cMKDIcSabKCHc2xzycllpG1rm8=; b=G6VwrcPUZL7datofQrtDLWOcH3pW0hb1i0FL4L5fMwpGkAu3YrTeCGDkzvy7OX7nF0 lDXaISNZrmPRhsUo4cmeDBDUoKaS+BO44Rdm+6eGRbbF+Gd5eUrqpjToEyxwlacsEbss zP7zo3jBRANOr48MaO4urRPYdBnDVoQL40EgkCJbA/t4mwn/SQmgkwi2DDfbUqzqfHkU HJSYYmZWhXl/8+raq/oo4iCd3MKn/SczsMARVz85LypNb01XtB1UyNL5BXTx3pTt2pMF WiPW8YMvwjTJovt2CDXDL6cEkhKGjxewXgOa6B5kC/w/hdosY7Y0Vky4Ywogqbh7LASv sHBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796086790; x=1796691590; h=content-transfer-encoding:mime-version:references:in-reply-to :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=YI6QzyshgCnAiQAi0cMKDIcSabKCHc2xzycllpG1rm8=; b=xODG7Uh/rzyGl1NIsv6oVMmyOnEaiGHjMky+KUgqQStU3J/xk+pa/xhQ0mOkZ1I20+ PosnxbHiKfz9TMFW9/43CLT+enLrter81cyNc4PrDVm0ir3eGhMHye4FHjXkBwe4c1Gc yxbHtdIKpzgrT9oYWdD1adY0VAlte0N2mrTZ+0sSeyzWfcoPqjNfDimGOYMogWdzt/FC qiHyD6tFez6mdGpks6nSFnoyj+a3EhVahCXDKIzRhkYW6fAWOF9gtaYaunbp5H4/6fq3 pHwG861/Gq4RBd26M0aG1EeJQif7CG+btmn1g4nV8J0e6m3wf5ulaI6V8/bOgBhsjK1z +wFQ== X-Gm-Message-State: APuU4Z82A3m8gfaxtnHdbQ6V84FTO8XOnm3C1FWtnppQBXO37LZbKIgq 6xUeZ3WYM8i4928Yg7b7g8AiEmrF3BZMH8mtYT4qJpaolVrmcMCAjjf+UUmO4xuH X-Gm-Gg: AZFdTZcUZdGiZJ398L7Xifkhqavn2Ze7MInudURAi/dNQ3oP52MMfu6wW5jrGd8+brk cRvkvz247xE9WCI5OyXxV0pB9LTUkwWAL7ROFAtOZpx25oTAHfbM2nxvnbq+M71pLY2AC66Bkid TR84EvYvSCago1+pVdEgaEYqQEVyfM15Xh85HGh4wdgfDu5TDJIKUvI7j4584LVDEP0m7bEnGXD UlVFejCH5Y1zqAOEdhoiNfBqWyyX5j8PLjc9c1aocUMK3c+EXxTIotckJVqh/74iYR+zCv2+2Aj DEHE3x76l4jXTZWeInwZvNYxVmTdgYGJCiP3htfIBo7qR1iNkPVqfZfMuFh4RHeuVStORf6YLAc SYmrTFIaX8kcXTOhzlGuEWqbKvEcPnzt5sazNyL0f0dvtvVOk0AIzzUHI1MzWK93r+i15XGWI+4 JbAjpiuusEBYYkOO2HJWNZPhNt/Rzxop9ZzkhLDnNmpf6I8CeU6y5zTWHw6zSPsXeZDYFPwfzU2 QHgFnczzlfO66Bq/akNg8LXzz70PhHsslO5la+G27cAn9um9vLHcrWWNlN68PBOM625oqBjLBvk uIbQ+gKki2naEF8f7I5ZttXYpXmSrT2X4e87HSO8ju8E60KsA2Kohf5FHjJRrcMCNsFpQqROpmR keVzK79HoNYDL41A= X-Received: by 2002:a05:6512:39d4:b0:5c1:57d7:d9f4 with SMTP id 2adb3069b0e04-5c1bc7b4c5bmr11128621e87.16.1796086789600; Mon, 30 Nov 2026 16:59:49 -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.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 16:59:49 -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 4/5] ip6_gre: go by the inner protocol behind VLAN tags in ip6erspan Date: Tue, 1 Dec 2026 03:59:40 +0300 Message-ID: <20261201005941.1536429-5-littlesmilingcloud@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261201005941.1536429-1-littlesmilingcloud@gmail.com> References: <20261201005941.1536429-1-littlesmilingcloud@gmail.com> 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 ip6erspan_tunnel_xmit() picks the traffic class and the flow label to inherit, the ERSPAN truncation bit and the ICMP error to send for a packet that is too big by skb->protocol, and ip6_tnl_xmit() picks its minimum MTU the same way. A VLAN-tagged frame therefore gets none of that: its outer traffic class is 0 where ip6gretap inherits it, the truncation bit is not set from its IP length, and an IPv4 packet behind a tag gets an ICMPv6 Packet Too Big built from its IPv4 header. Use the protocol that the previous patch works out on entry, behind the tags. The header it stands for has been pulled and the network header is on it. Found by an AI code review agent on an earlier version of the previous patch and confirmed in a VM on an unmodified kernel: an IPv4 packet with TOS 0xb8 behind a VLAN tag, sent to ip6erspan v1 and v2 with tclass inherit in each of the ways listed in the previous patch, goes out with traffic class 0 before this patch and with 0xb8 after it; untagged packets go out with 0xb8 before and after. The truncation bit, the ICMP error and the minimum MTU were not measured. Signed-off-by: Anton Danilov --- net/ipv6/ip6_gre.c | 8 ++++---- net/ipv6/ip6_tunnel.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index d7d7fd478200..698cf1cdd4ab 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -1021,11 +1021,11 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb, } nhoff = skb_network_offset(skb); - if (skb->protocol == htons(ETH_P_IP) && + if (payload_protocol == htons(ETH_P_IP) && (ntohs(ip_hdr(skb)->tot_len) > skb->len - nhoff)) truncate = true; - if (skb->protocol == htons(ETH_P_IPV6)) { + if (payload_protocol == htons(ETH_P_IPV6)) { int thoff; if (skb_transport_header_was_set(skb)) @@ -1087,7 +1087,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb, goto tx_err; } } else { - switch (skb->protocol) { + switch (payload_protocol) { case htons(ETH_P_IP): memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt)); prepare_ip6gre_xmit_ipv4(skb, dev, &fl6, @@ -1132,7 +1132,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb, if (err != 0) { /* XXX: send ICMP error even if DF is not set. */ if (err == -EMSGSIZE) { - if (skb->protocol == htons(ETH_P_IP)) + if (payload_protocol == htons(ETH_P_IP)) icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu)); else diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 868c49b97a8f..8ccc90333c99 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c @@ -1227,7 +1227,7 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield, max_headroom += 8; mtu -= 8; } - mtu = max(mtu, skb->protocol == htons(ETH_P_IPV6) ? + mtu = max(mtu, payload_protocol == htons(ETH_P_IPV6) ? IPV6_MIN_MTU : IPV4_MIN_MTU); skb_dst_update_pmtu_no_confirm(skb, mtu); -- 2.47.3