Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796086791; b=BFGggTB3D6mmohmdqs7Lo4x7UafK+yTUR//2bOfg3KjSl5eIXXGIfuHnybk2GrMcHzm2 /wd7ygBdcIL2mO0gsvpJEQWjxRyOn6ie+vml+F4Ix8LVMq9Ojdxb3DzljOG2US3U+eVkl Wl7xKGDyWGH/vplNeZ0tUI50zjrYpn5PqQ39MylJ05xkl+SD7SJmc1jsb9FosXWOMGaYH qWnug1JHA4kdjXckcM5H+efPcix2tdSFpY2QYX285XXBs/JDIMWRDgqUlDCwVzFl8FLF3 BXs34U9VfYjfdFDZBeX+OZ+u2vjRkZO/d1HTaDGwSN3WCTfWFfcY15S+v5HmuPrSA+Q== 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-Forwarded-Encrypted: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=GLBhUNa5GdQYEbwvXS5RGvjXcis+RC7U4cluGaQ9H2goATVvcmmnKSpfOyTAMPsrO9hJ E8yIl8Paia+sxx8yO9HydRGdQ7826ZbT0muVqdCjQHf5bt4dxf3Azu3nnbkR98fJnUuJc MF4JPrvpGKsOcHy6d108cSUMJYOL02nKiBcPRCPSszJvSGbbEXSHnwl+gqr7SI4+r4WKE TpkVXeNPE/e+7l1lOe+wxiI8CA9x9jp/4uqYeCGdIVA1JkFPP6hV2z8TihrF+2ewzcirb QBrBbTQ1mBC3nlVUMebaW85ylaKplaAAH1kl7/TsykVKEz8FTi+5bwbHONGEljyxMfw== 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.167.52 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (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 681A8606A691 for ; Tue, 1 Dec 2026 00:59:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 681A8606A691 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-lf1-f52.google.com with SMTP id 2adb3069b0e04-5c14a204305so7481119e87.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=h9Wcz6JrQDJ9cOMq3ghDdff9/z/80/MOm2BTxtPN3mhpv5u9nAWLy7vlruWDZ6EQGA UFymD+bs+gF8+NtaJ6veLpeWQZm/RtZKJZTom4Ys4Y5K4b3W2sJRbXVJSba6MliTQOoV ruKGf6qGr34fKLcQ4BsuCyB+wI1wski6CkHPmXDx+bsM+SiUETRyA2+mMWKFYDGynWLY Elc6A49y9/GQxyAMOiP/r64T3QL96k6DErCGqAO8mEA/MAyVDOLJ7M4AG35iYlT71ayQ htDihm00UGPk+YDJ4HhlqIVE2YYuVMek6d9F2e7i5a4RT2uXkufpN7UHQXRKcJ5uaf6q xjxA== X-Forwarded-Encrypted: i=1; AL+hErGBn7NDAkyN1TuwkUXXMkW4Zn5BjIMQZR9LDJ1vQ+BX59sMSWLSHeY3yBtQtXtkqUvUC7HSEXjDGehd+bjTwhs=@vger.kernel.org X-Gm-Message-State: APuU4Z/MnMGHghUpkXzHbWJvGz9hw5haOXBa10p7DtR+12oXEc269X6x KxlGCfrZqxMIWc2PpKv/vw8WAmlzmDEh/AF7KfmWdk8vnIVPWNI4eKBu X-Gm-Gg: AZFdTZelLCj3FaHbZYQqIIUAHOwzCkUSghKReGVoOSA6mf3NLSpcFyF8mBF4drtx3rU ovnUmazM/lWKITupXKAMldF7eLpKYHBneejGJagL+8YEwBT8MTVnNr5/d9BpDtc0mMSWEylf8oR uTJksENx7zxU51jEKBkfBju+WgcLKts9ZTiqCJ8dMrJoc8Dg9CIOvpnCcjQ00T3y2MlEX7tS/An H5OzZcebaI7QTLJvwho0vxnGS4MbttrxxqbA7OuO5cERk2zxsebZGcAePRj34x9OZZx8mWDuwZp UNrQ3gluysKlyl4guC3AL+nHEkIgUoJDBDuGVm8eqXgnASrZiD0D22TgHIHoyCNQ+A5+VbJs952 lc3p2NjY7xwwwBVGupAEtVXbZCiNnOiAXVmU94K7fDOKxz0Q2UNYKEzHZjXO6Qvnm+06O8r3Jry 5lv/dEDZLUdogLUYRWoW/eaOFf4nulAFpMqhUky3CE4rUYlxM1pvCgbDvgPfyKNFat3izeyYBHJ JbEwOISR+HeKQ+FXdOy27F3GRcPNKOKa1F2gctvSHnRTbuWRFwRKMYFdjDcmYURWNBtcUWeekMJ 1nBfrYKe6A2PuXrk94fKJ3IiX0rCxJ/I5T8TTPLkeL9GbRbHhLf+/EwfbJRMzutIlxqOcvuJ5wQ k08kfR9ddZo+amb4= 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: 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 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