From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.182 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796214985; b=G4PLKriqmgv6IobDyMf3NB2hXJy7ZV8FwTpNwAdyN7FTrvpSCyzkLdAeSpZr4MxgQLO+ YRP6c67JgiZgEx4L67WCQ0s3JxqbuO3uC1SlC1j2s671cQ+1RhDa+nx/6fEGfbTs1iwwB MfRj2uQzbn0PCL1xEGwNstXr7fXEc4XDkGUOPLf4rCFnC+2X29F9dzjztI/6P/ap36pV0 rexzCT5EiPGxVplzSBTK4qpTk+V2cnz3fmETaQFVs5Gce4u7rMfqB+zX/kwQwH/Tg/91U zvPetmXy/D/pzGbuWLPUaMUz6MOPG8RUeS/jFUoXh40YjMsfvzRwFEmNn8xcK0ox0fQ== 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-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=CtUu6mfxkSufFB5+Ts5aydxdHKZ7c15oSw69KUd50ZR7eLHJL1Lw4yfKPWP8CB43nxi8 6FqHbepTgcR0OfKoLDchh6hU37+bB6pPshHy5a/H+nSpWSCGmqURtuNrjz9LCtv85R9ab 6TkMxa/FRtxjx5x1YvxHgVLGSOaNOaB4KBS3SYjpDZZ197Ng1fJ6y/WcpEys+QiqZlmIn PJjXo3fQNtXvoKsrtSCQcUOheokEeIGE2J8bPQpEIvTiktuHYwDbZGycjn0hvmkEtFcZw EdVpM06CFjeK2CwufXTzteEI6nnHfpZjIQIlHGDD2NzaecPHHM5YPvz+gLfW7HqAESw== 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.208.182 Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 D36BB606A692 for ; Wed, 2 Dec 2026 12:36:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D36BB606A692 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-lj1-f182.google.com with SMTP id 38308e7fff4ca-3ae0a5c1715so121948861fa.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=wQFWtiGDKQ0nZcw8VnsBjETKv95RbsSem9ObjQyUynEhxs77Zx9h3zBl5sMzuMQe56 xgaMHiXAFY0VIQAsBk2kjFlGSbvVvwPj7HfKrs55Tmz6htEWNI4KuiHVsNOeYISRQ0cB 922xbtkzAjtmksUHf791iu2WF34p9X0mgWU4iXSW7l1+r/ZYYz3FC9MnIJmLGH7mf3zR vctKN7f8om1exNAqpfoFXvi6Q19cl4Ym6+aQ9mpJWMK5qixHM2/SkEw/hMZrz+chwJ8r KnsrSpF3XCkRg8BdIJI/Ek+UtNfCMm7/ELLocVTYjZMClZJdKCKsfLcD/doidvrYLhWg Zfog== X-Gm-Message-State: APuU4Z+bpsl7BwL9FTIYM1YYmFAFnyGVRkj0mgKYu9EKxCZaVumkgYSH Q+sTn6P67BjynkZyiAgnQD16XVcQPFP9n/3pe2x7r38q8WRMsHpoduQbucjWHffvzxeSjg== X-Gm-Gg: AZFdTZdCF2we6L+VQ4urGf3+cMsfS+GiosD5VjmOIvFfkLdCZfh7Nsl/6qrsrGC+Smu rQNJuavU8GKEn2YayQfgLPAsViA8BGWHYtSKLdY+dPU1nbom2p5k3BajY/wgMufIDBrAAiQmpNA 6kEoFZZYo7x1q3NGkRRamjmVl+mVXQPTS1msChLGKRvRRcT4OFmaM25f1ZTL2R1UPHRP/zacn9x z1WYgiZ0mLMyqOX/rjybFG0K5PIzguCWidj+Ug61J7ur+8FYH1tyIr22ybPjRtOSK2xrDUyU2Ql nApVlQDhMlEkD6lff/OFHbXm2UesoaeTZnvsOcdRVTTolYCmHiaTP83RCJ5mBg2u8ch6S79Pa6b Kx6SecZjQAfWUa8Pn2OmELpxt3HsW9PvuL6xQzhIQOx2sT9DqmPRacc+YCONjITTS/7bJL+CdHu G3D5enCAZgcSpSXWiXBfcZIFxUpPR2YWBVEW9u0QVlXeq+OoH3oWmWafn7+HQ1+KA593RA0AfLl BPfvuArJBU/UF3iN2cjUz9/js4Eg4AwIOyVEzQ8mz8HK14HChBvdkgDNTazKAY4g/ZpbAxJlYLP fpLkPrkrLUfDQTKt916tJ9EQ+68zzA7k9/G999Nd/gwrA3Q+PtIMMd+wlqa81ErIs0ULe4dbqRk nHS/Qu5bLJ4apiQE= 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: 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() 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