From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796214985; b=1R+wpQq+5WPcBp8uklqAqmcpJqP9uLQ/+6xfXghF9ZlS1MNt51FTn6GXKUGuOgGUGFeN GPfdiKcpNO3OjIDg920RL9HB3TuMk/2gwKeH3RXVStoD43rtLhwCPxVcX+rtEwa1Xhe/e v7eXWNAQc62el4ZmgxT3JKsnXrG9zwzJ6YbK/cWD2yHY1K95GsQg3Xh5VBnF1sUcGKj1j SyDakqj/JG6vCg3xN6vPHh9ZaaFZ2uwsqbJvWDWjuYftlPngNyNga8hhom+Aev5Y2HdIJ 6C+zUSJpEpK7mc0PFKm0BAIrAecFCdSMQG5GiT/lhJ+fWPB6IgLuWuSNs2rCZGZfvOQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796214985; 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=2Ls9zHQ/SVff8H3sLo/TFA45hZultTjaEws8Var6Vu8=; b=QvOC97xOvuR/ZVwsUQCsxyEANmwWfmYw8+W0WrW0EtE3KY8ygB+zuBWwUHfbFJqFuolH W2MAOvy/mZd51OHxkAUCRc+siONP9SWZdcIP5nCkeZYVD+ejDTGq/lrgIffVfSBQOXc5V QcUEUvKmJ9AsJN7dE9se1LbFbu4OYvZ38eFm9GazIHMrFx0LfGtIcGMoHd71fAJ3JIenC QeAgqKBFnVRWmju/26ZHB49c9IiKgSVar8gxUzxPO4igovMhVkJuswWtPLlyaACVVXZsf Lp6fMuMLr+IAO4WwPDGnnmwu6qNEDXBi5S6SD5WAk0Au05zxPNmuwlvz0Vssh3mt6mg== 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=Dd7OYADa; arc=none smtp.remote-ip=209.85.167.48 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (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 DDFBC606A6A8 for ; Wed, 2 Dec 2026 12:36:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DDFBC606A6A8 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=Dd7OYADa Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-5be4fea434bso11973874e87.1 for ; Wed, 02 Dec 2026 04:36:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796214983; x=1796819783; 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=2Ls9zHQ/SVff8H3sLo/TFA45hZultTjaEws8Var6Vu8=; b=Dd7OYADa1SNOFHmAaQ5I65SB4IzB6EcWIM5xLMMnAWhavTmqbLFvaQZmMF6dN/NtnX V6+nzt/mJFKMryhwp5WvxkZtcShRT7h8qLA4GU/Itzs0PZnhIqKT45hjB+LZstQTK9t6 PekC0mXYdXenVfrmiyVutKpomhnECJgDTJH2mAoVpJ7HGQUfl7lpHmo9mZBkg2FJRfpO 1jmRi6nEkOjcYnJ/7sHv0iYmEeF37T9BCa5ciqXUqt/X7SxYNM8P4ym3hki4Sp2XiSRX fRfsokkNCwTMmLCy4Yewfhvj3a3q8S+z1Mfs7LvnKbRhdVL4qYi/e/vbN/3IrYBSWRDC oYfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796214983; x=1796819783; 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=2Ls9zHQ/SVff8H3sLo/TFA45hZultTjaEws8Var6Vu8=; b=p02LEIDljpeUVseONZvR1hgMmwhDqWPV8TvUPZemuytDLFRaGu8sEBy2lL7USHFr/R AZuPn/qTsIRtB8j/kuGOdvizMAalJBLr5KmD8mRDExSKOfV5ji1dvJq/uBYO17WY0TjT xFFrITAIcvZDHajy08NTLS1Ist5X+dbTrFvdzQvIVn6vgwM20uXC6Zg8jOoCmpzWUknD fvyQ5i/rflCkN5N4E51Pzxl0/M1SuY6IHTaar5dgB05RlgpaZcxC4pd0Vgg/PXY6wme6 P4EyWwSpcIwnCHP/r+1Er5eZnwhP0cWgDZZBYm3AcbMjEp46IPT/sJJtDSq2bOSd6exh 0kZg== X-Forwarded-Encrypted: i=1; AL+hErGO3IxgW9cgYu73V2y+50G23DwyCIXZXNgmhjKZbDBPISBgssdv/YiZOZ3vMIEtHDZsLmc920w43Q6HGlo=@vger.kernel.org X-Gm-Message-State: APuU4Z856ehnjAgQMXloTP1yiKRvliC8OftSEn3v2RGZ7HBZjPvW6mMA PeDSFdKYSNF98m5g0txdgqW2Y9BMPs/RT3li4ody68nQ9OXIGCzv0w0V X-Gm-Gg: AZFdTZfohC4o+a/4vpD+GFS+oYnYiMhM1h6KvI/p7TAXVNpfxrsuiEBX32HPogj9iEZ LuMkcecpMHZb8RpT6ENfNJnQmUK5xo+YuFlKrPM7AdtQtGaop5MZrDFtLRzuI+RHgRVRzOoZ1hX i5iEglghWmLNulmMqpe0GA5McqZ4AoJER0Q/MHr3V4z1YbaQq9/xcwhbfsUx5MJRoKw0QcADbCP oSUHX8UCVl9Q6ybvaaTlgzpZbeb27tbwvDYenqMyPybGi4Bt1/TWqq/h7rBso7xCoDMmf23Y5Py gTK/4y+tEkwPBh8ZrN6X7ggzRLMZvBOe38v0VfX1Y23d3C6ZcmTVpMsswTo0QnkbampMRcSnHwd 4YHCgmlclvQDKLp2RoqhvNAh2OQWwaO79xktjRq/wQZLZJ3/vEqVsUp8JBeE69k2BzDZUjqMYTc XMy09BuL5P0NXboijZP7sVomx0XbjDMXb5ZVZ+j/0VG5SiFu5rQZaDLZDcFVwW9PRwcXg4K0qRl c9lqphhHcZ3aWZ8YexGR9XBce362JWZpc1MbEc+oMLUAFq5fHdNNy2cM+bTg2gnnyjuy9SYtgHE djkH92TJGGMZARLFuQs1/dOuNJpaDqqBQCNGU1AvmQPGMWX6G4ds9gBkfaGtfqrLQaH+n60A2vo 2JcJVZEFQ9xoH1rs= X-Received: by 2002:a05:6512:3a8b:b0:5bf:b96b:89f4 with SMTP id 2adb3069b0e04-5c1b7c00ae6mr11249985e87.19.1796214983101; Wed, 02 Dec 2026 04:36:23 -0800 (PST) Received: from dau-home-pc.megasoftware.org ([94.28.149.75]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5c1bd0171c7sm9529553e87.31.2026.12.02.04.36.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 04:36:22 -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 v8 4/5] ip6_gre: go by the inner protocol behind VLAN tags in ip6erspan Date: Wed, 2 Dec 2026 15:36:12 +0300 Message-ID: <20261202123613.1708463-5-littlesmilingcloud@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261202123613.1708463-1-littlesmilingcloud@gmail.com> References: <20261202123613.1708463-1-littlesmilingcloud@gmail.com> 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 ip6erspan_tunnel_xmit() uses skb->protocol to select the inner header for traffic class and flow label inheritance, length checks and ICMP errors. ip6_tnl_xmit() uses it to select the minimum MTU. When the protocol is a VLAN EtherType, a tagged IPv4 packet can lose its traffic class and take the ICMPv6 error path on -EMSGSIZE. Use the payload protocol classified on entry to the tunnel. For IPv4 and IPv6 the classifier has pulled the header and set or preserved the network header offset. On -EMSGSIZE, send Fragmentation Needed for IPv4 and Packet Too Big for IPv6. Other payloads have no inner IP source to notify, so let them take the usual transmit error path. An AI review of an earlier version identified the traffic class issue. In VM tests with tclass inherit, a tagged IPv4 packet with TOS 0xb8 had outer traffic class 0 on ip6erspan v1 and v2. With this change it has traffic class 0xb8, as it does without a tag. On native ip6erspan v1, an oversized ARP frame took the ICMPv6 error path with the old unconditional else, both with and without an 802.1Q tag. With the IPv6 check both frames were dropped without calling either ICMP handler. For both tag layouts the IPv4 sender received Fragmentation Needed and the IPv6 sender received Packet Too Big. Each error quoted the original Echo Request and advertised MTU 1338. Signed-off-by: Anton Danilov --- net/ipv6/ip6_gre.c | 10 +++++----- net/ipv6/ip6_tunnel.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index c413e47c6ceb..0ecee2271bbd 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,10 +1132,10 @@ 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 + else if (payload_protocol == htons(ETH_P_IPV6)) icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu); } diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 931911b5e8a8..3d8b2d5851ef 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