From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796214985; b=rzRQ3Uc4t25f3b5YboQyDjaIR09kwrQ2vD2Up1YuJr+6GaEG6R8xpCoiNWfW+6ppc2pG Vjmnk1NphOuvdG107y99vuLd44cH10+xyOhzf9IVNeL9zLEDf1sHWGKS43vovXmcUz6fV Iyrc/ku3nVQwG+iK6Y3+htVGWMFEcmwaqEg1q96HWNcxTuwprp/Ujn2qONVz9RfBUYHQ5 3KgheiSkJWUgCDFEf1x03Nqw0bb+4VktBMTw6WG1fbhZav2+KQkH+emGpqgC/Fb4xRCdI aPTHRxHLHnEPnJaIuYv9rdydIfOJgPLZ5AwPQfaPCYaqCtldVpCDt49tyqFJjnk5wGQ== 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=c/qDiiUS+AQWnMOYD4YqFH37MylR64Y6sN9tyXDpl0eXjcS6YyDGLtTilLABCLeZ5VOK o2wJJYhrCFWDLJlLHLuzPRQ9cmBeOT8jHjkUVX5ZgnkSJ9MkDShlKJg2Z2d4TkMUQpXqU RHrvgCWAFVOv4mZy6fxJoyxWiy0av4cfe8M6nnVdxrk5SWHjyVPJFvkVMiCHBwwCrCbV+ zoNCDBjMRy0tOuJ6jQYo5odN21Mk6Tj3VxgE46G06RWXDum2aLUXDe0112X+jXia/inCw oajPtj0yr7pQ4MhWewUfr+/JWjXzrpa4ju99jxtHf35UQZt4C7d9IRNn4IMyiEP6b6A== 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.49 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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 E8044606A6A9 for ; Wed, 2 Dec 2026 12:36:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E8044606A6A9 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-f49.google.com with SMTP id 2adb3069b0e04-5be4fea434bso11973875e87.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=f8BJaaEEWZqzmpapsZCIpqM66VeOeA0ZdpWEmGj8AOHJmImsOJDbvZsIPFCoS7BTz7 7iP9uwpg0MZRMPwXrrQn6zswOvgv3xlSb8+LwpEa3Sxk8Q/3EhvugPo0XSX8pgfUwSug Jnsd8LEnygGMRA7wyeMjBJ6UvoIYG9tS5kAa/09roofgWfkh/ST3eV69lqoxfaSCWjPF f3aa0P0FRcCc+YZ7zJ886iNsTYD6LSjAFbP6YLlfWR4fIyL3bMze8br2v+QnggzthJmc 4cWRxI8zNXa6BxjGT7PSeEaYIrz/WKBMUBMjHr1HqqRJMIMC3vAL5N9Z2Gj0mdWkYN7w dovA== X-Forwarded-Encrypted: i=1; AL+hErE5CRLTuhTS9A/213cL0Du2/yvBcXYZOUYL3OX7qXOArm2CTNRRlQ3LkNvHhiPy0trGa69vOn2vJ/svVIabZKk=@vger.kernel.org X-Gm-Message-State: APuU4Z/XD5Feujs7HO9E/gX6DlWQgi4L57d5LhLdRzTi4OVlXmFzRKZu WNH98rdjrNVSoiNObHOq26i01adOcdHgmWgdXR7UDKYEno10vR4aUTZG X-Gm-Gg: AZFdTZcFA0ncfT7jtjXBG9i2MRnuEW1jC+rChKwADefTQbDytqIb2YQ5oDGuQCgia5J hfjVwOv1X2S7KYBIb/v7xxL1UC4nR1lMfQGKSsIUs9lC3vbGd1VJfkPGXmQTm/Xc/m5gh1Y06Gg Ft6PulcvIGMFjmj29Y81Czzh2OE/Z5ORGOD+cZMP5Ijh/YupXvT2zm+OnICu6sKVZxJ4g2So8Jh wPIfZ4GsHZSnXYvalb7mFwsCsWr507aKOp8MMlaRssE+HPmEZPb+skSoUovsQwV17Nvh8+dhcNG xqBD7z+RZ1CA1m4/KElycNP1EDRIjzrBIcud7SIbH2iHSkXQda+3Y5a03n/kFFRLpyRkrTwrN6w vN4ffjGBo63l1WpfyoYHbAnRmg9KzSxaIjL7rlCSIs55q9A+b+FgGjPGlgZFSNOuQlCKSYClbke xpfW2NCSCdR1iYO0G+TQSodwhjANAJv3rMajhOnf2pi0ElTISVBdjyE6QmmjX95D5Pyz647ddKl ecKIXaRJ6j0cWIwNxkWai+83WcKTKnqdS+RW+zFRkZLGd9ANBLKckbXiBSLZaaXQY2wZTPI7iS7 wNxZsEu3wCN1XhwhIDJ6i8O4QcRZeabOEMebAAqUdRzN1nWrtDIwPDhUWh6/dy9wR8fii9FIUje Y0nYIegrMClmcask= 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-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() 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