๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10494

Re: [PATCH net v4 3/4] ipmr: set up GSO state for tunnel vifs

#10494
From: Eric Dumazet
Date: Tue, 03 Nov 2026 13:13
116 lines
13590 bytes
Le dim. 1 nov. 2026 ร  17:42, Julius Bairaktaris
<julius@bairaktaris.de> a รฉcrit :
>
> ip_encap() pushes the outer IPv4 header but does not set SKB_GSO_IPXIP4,
> skb->encapsulation or the inner headers. A GSO packet forwarded to a
> VIFF_TUNNEL vif is then rejected by ipip_gso_segment() and dropped in
> validate_xmit_skb(), after being counted as sent. A device with UDP
> segmentation offload is handed a GSO packet whose transport header
> points at the inner IP header.
>
> Call iptunnel_handle_offloads() and skb_set_inner_ipproto() as
> ipip_tunnel_xmit() does, reserve one outer IP ID per segment as
> iptunnel_xmit() does, and set the outer length with iph_set_totlen(),
> since a GSO packet plus the outer header can exceed 64 KB. A GSO packet
> that GRE or UDP tunnel GRO marked as encapsulated already uses the inner
> headers for its own tunnel; drop it, as segmentation did before.
>
> Fixes: 9fd1ff5d2ac7 ("udp: Support UDP fraglist GRO/GSO.")
> Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
> ---
>  net/ipv4/ipmr.c | 23 +++++++++++++++++------
>  1 file changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
> index acacaae05cc49..98e38839f8ccb 100644
> --- a/net/ipv4/ipmr.c
> +++ b/net/ipv4/ipmr.c
> @@ -1849,12 +1849,21 @@ static struct notifier_block ip_mr_notifier = {
>   * This avoids tunnel drivers and other mess and gives us the speed so
>   * important for multicast video.
>   */
> -static void ip_encap(struct net *net, struct sk_buff *skb,
> -                    __be32 saddr, __be32 daddr)
> +static int ip_encap(struct net *net, struct sk_buff *skb,
> +                   __be32 saddr, __be32 daddr)
>  {
> +       const struct iphdr *old_iph;
>         struct iphdr *iph;
> -       const struct iphdr *old_iph = ip_hdr(skb);
>
> +       /* The inner headers can describe one tunnel only */
> +       if (skb_is_gso(skb) && skb->encapsulation)
> +               return -1;
> +
> +       if (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP4))
> +               return -1;

By the time ip_encap() runs, ipmr_prepare_xmit() has already bumped
vif->pkt_out/bytes_out and decreased the TTL, so these drops are still
counted as sent, which is what the changelog complains about.

Could you move the encapsulation check into ipmr_prepare_xmit(),
in the VIFF_TUNNEL branch before the route lookup ?

        if (vif->flags & VIFF_TUNNEL) {
                /* The inner headers can describe one tunnel only */
                if (skb_is_gso(skb) && skb->encapsulation)
                        return -1;
                rt = ip_route_output_ports(...);

Also note that iptunnel_handle_offloads() can not fail here:
skb_cow() was called before, so skb_header_unclone() has nothing to do.


> +       skb_set_inner_ipproto(skb, IPPROTO_IPIP);
> +
> +       old_iph = ip_hdr(skb);
>         skb_push(skb, sizeof(struct iphdr));
>         skb->transport_header = skb->network_header;
>         skb_reset_network_header(skb);
> @@ -1868,12 +1877,13 @@ static void ip_encap(struct net *net, struct sk_buff *skb,
>         iph->saddr      =       saddr;
>         iph->protocol   =       IPPROTO_IPIP;
>         iph->ihl        =       5;
> -       iph->tot_len    =       htons(skb->len);
> -       ip_select_ident(net, skb, NULL);
> +       iph_set_totlen(iph, skb->len);


Minor: a fraglist aggregate can reach 65535 bytes, so with the outer
header tot_len can now be 0. The packet then goes through the
NF_INET_FORWARD hook, where iph_totlen() only handles TCP GSO packets,
so nft will consider it malformed. Still better than the silent
truncation we had, but maybe worth a mention in the changelog.

Thanks.

pw-bot: cr

> +       ip_select_ident_segs(net, skb, NULL, skb_shinfo(skb)->gso_segs ?: 1);
>         ip_send_check(iph);
>
>         memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
>         nf_reset_ct(skb);
> +       return 0;
>  }
>
>  static inline int ipmr_forward_finish(struct net *net, struct sock *sk,
> @@ -1982,7 +1992,8 @@ static int ipmr_prepare_xmit(struct net *net, struct mr_table *mrt,
>          * What do we do with netfilter? -- RR
>          */
>         if (vif->flags & VIFF_TUNNEL) {
> -               ip_encap(net, skb, vif->local, vif->remote);
> +               if (ip_encap(net, skb, vif->local, vif->remote))
> +                       return -1;
>                 /* FIXME: extra output firewall step used to be here. --RR */
>                 DEV_STATS_INC(vif_dev, tx_packets);
>                 DEV_STATS_ADD(vif_dev, tx_bytes, skb->len);
> --
> 2.53.0
>
Technical Details
Message-ID: <CAL4WiioQG1Gjdppcd7QoQfac3o+9_ZMwQ2Bw+ewKiopTM67pWQ@mail.gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355624-linux-kernel-netdev=dewy.ru
References: <cover.1792838740.git.julius@bairaktaris.de> <529dd7ba1395f17c0b328ab2a597769809cbe720.1792838740.git.julius@bairaktaris.de>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355624-linux-kernel-netdev=dewy.ru
From: edumazet@kernel.org (Eric Dumazet)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v4 3/4] ipmr: set up GSO state for tunnel vifs
Date: Tue, 3 Nov 2026 14:13:53 +0100
Organization: Usenet Network
Message-ID: <CAL4WiioQG1Gjdppcd7QoQfac3o+9_ZMwQ2Bw+ewKiopTM67pWQ@mail.gmail.com>
References: <cover.1792838740.git.julius@bairaktaris.de> <529dd7ba1395f17c0b328ab2a597769809cbe720.1792838740.git.julius@bairaktaris.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="3199343"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:pIf2cjDbebHQRhJ/Dxq8Qte+DUw= sha256:WWKnnYALAEpM+qzQ3R3OEGifNH+8XuLIw7t+F9WFiwg=
	sha1:wllDS2Mw/0lCsOZK39oyZvbkNB8= sha256:N5ubBYYBXoGwlCvMLcIe5UK7bC2koS9+nkyfmmSUUYU=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 5356A11292A; Tue,  3 Nov 2026 18:35:44 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id PnYPTFA-NLDN;
	Tue,  3 Nov 2026 18:35:41 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-355624-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 5D03F11291B; Tue,  3 Nov 2026 18:35:32 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 13F602354B; Tue,  3 Nov 2026 13:14:25 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793711652;
	b=3+5nEbkadM9NMEf2XtReSwKWzUv2m0sAi2vO6LN+nqDsTLiTp+64tQAY0gQfaBaDQ8Gv
	 mqDEEybgfasM+FFiW3RTvQ3hZR7gkP6mQSOK7pgj9bz18GXn1V32I+4Sb3qZPI14BKtwf
	 EhKZY+C8GV10u3iV9MLxK2iw5tSwNEwX81Ek7gpfLtEk2ahm9oNKN/kVRvDcrIcTvgIjY
	 iRwI8Kdl0ZcXc7fU+XqDxdiVKiuwtN43L+VSr6udZinAVX5frR51QuaYCOEaSx7ioqKz8
	 YPGIZqcvY1JJuRppgvkiBYkVso3PNP3y+ypgzYtnupJmqXOGn/xNRrIt8XaYj+zpflw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793711652;
	h=X-Original-To:Received:Received:DKIM-Signature:Received:
	 X-Gm-Message-State:X-Received:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:References:In-Reply-To:From:Date:
	 X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:Subject:To:Cc:
	 Content-Type:Content-Transfer-Encoding;
	bh=BL9pF1t9cF+2q2RHW7o6tX7PCUVdJX0A44j6YGdXXNc=;
	b=jHhYMluVtl7MsqxYmKb0zXHZF+RZ6LXUhqJhbSw7NsMkiE24WT7sV0iiZU1QBw0UDudX
	 5FFKKiIsx9WTJ23ij9U4IOhO7aNn1b3kZxCDi7d00fb3XgT63JeOeKKCyUvhLsjgx2oHg
	 Fz9+3E97F3LLDzurbn7yt/S86fVYfd/hzOuiAThDPN624FanBML+cpNomsslGHBWCpDsA
	 /qBnScD1hJS3wyaU2Cfp2cicj1VLdp2psvztqnSokdH2aYhQxRMOKuwn3f4zEa/wJ3ZPf
	 eicd2bgblJGJG+ZjSAqjkw2PW97/0I0zbad84gAtrpEok3LYgXZjrhfm8+txKME5Uaw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UfTa27Y1;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id BEED2606A33F;
	Tue,  3 Nov 2026 13:14:07 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UfTa27Y1
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793711646;
	b=eeV/7fQAwV7YEz1hWYyvLZeRu6voq4c6xjDCXvge9Xt9FHRBe4RbtFZQvf3aWrvy4JSx
	 aW1saMbsUVQ/do5mDHxdz12OwR0vM/mvwHiZGMVxt6K3TWLF5iGDmX9EoFfvfQnMhXXLP
	 P4TdTF2omieJZTvJcW1mjdFsV04PhDBoj1ZooC/SdlHctaPmY+Ek/jXhaVOGFfegKgQu5
	 zCwVcuxY+uyOKQfMXsoWYTNtsW4EC9GHbRu5UllnZN9LtQn/p948BVJbIjtRuAaAu9vNq
	 MZwFdwXejb0dsHG3UgCGJw0AF+dpTNzX7cZUEHoK92+Hs1NlIDtLLlaITrXGU4h+lPQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793711646;
	h=Received:DKIM-Signature:Received:X-Gm-Message-State:X-Received:
	 MIME-Version:References:In-Reply-To:From:Date:
	 X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:Subject:To:Cc:
	 Content-Type:Content-Transfer-Encoding;
	bh=BL9pF1t9cF+2q2RHW7o6tX7PCUVdJX0A44j6YGdXXNc=;
	b=JduLcx9zwkYaQL28K2HxPCiel4xx8YiNoGe3rMS8J5p+V8wnKRkt63l2nvJBfJvEwWUL
	 mQEFhlYLYqn+6UOnlLchUvk3VY2FjX0IxFdpIXkMB9WZaNwVfwGKXE7lGTUbJEWiQJdYh
	 tvnxJ8rn1JA0iwHZVdtQobtkbKVIl1QdKUN0bk6h/j2RFCPVQbKAtyxwWgX5hQ+tX/Am1
	 Wb52cjYbog/ap5nQph1hgTVrJWX9FaOpIWvNOKhU4jCJlIxBNrtWVwz4uuG6fVKYor+Fq
	 zJF32UmD75USGb0eZbfP6TDWZee4+cAeDG6cpK+vNsSkDmGG3Th0OqffEvIByzm4Ciw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UfTa27Y1;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 970C5606A32F
	for <netdev@vger.kernel.org>; Tue,  3 Nov 2026 13:14:06 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27C721F00A18
	for <netdev@vger.kernel.org>; Tue,  3 Nov 2026 13:14:06 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793711646;
	bh=BL9pF1t9cF+2q2RHW7o6tX7PCUVdJX0A44j6YGdXXNc=;
	h=References:In-Reply-To:From:Date:Subject:To:Cc;
	b=UfTa27Y1QXdLYSYqXim5q488ksFY5pq+EI0CN70Kt7hmQrheA2qc7D6KC1ZDdjQaA
	 xqqZctH/ZwfrsEaFCoI0YSvTH/toxfzzssaDXXPNVplo5vN12q0gNChBS64FZ1edWG
	 wI0twKtpfDZ79yugtyLp0F2E1AvuMp2bukVP1k842gns0ga9Wld1BSV9mabbvRLrxl
	 ClT3MiK3f4ddFgo91NdU8u7AoQ3ftDoyWnpsucjV+Gb7ENFMJXusHHyJKaICeMTBzE
	 qDJRbqpTFR8ZcOOiIehKRU+mzyESiZf0fVXVGVBzk45Hl7Nm/zqals6VGu5Mvn3w/m
	 kz5vDkUBz2K0g==
X-Received: by mail-oo1-f53.google.com with SMTP id 006d021491bc7-7037daaa820so1511996eaf.2
        for <netdev@vger.kernel.org>; Tue, 03 Nov 2026 05:14:06 -0800 (PST)
X-Gm-Message-State: APuU4Z+8lCTnbocD1rMFLQTf5ADCKez1Vlyzh6ose0gC9lFFrU3RDZkg
	oDiJIvMN7yzWrKJyPOTcSxBkgijrrm/9FFdi4Vte3VGegV9t333JEerwbyfD6UWmIUxJat6o/ct
	LxuhC74mNNymqbEuJHrxEajE8q9TBfk8=
X-Received: by 2002:a05:6820:c3d6:b0:70a:2478:f62d with SMTP id
 006d021491bc7-714f2990e44mr4407416eaf.28.1793711645262; Tue, 03 Nov 2026
 05:14:05 -0800 (PST)
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <529dd7ba1395f17c0b328ab2a597769809cbe720.1792838740.git.julius@bairaktaris.de>
X-Gmail-Original-Message-ID: <CAL4WiioQG1Gjdppcd7QoQfac3o+9_ZMwQ2Bw+ewKiopTM67pWQ@mail.gmail.com>
X-Gm-Features: AclHuK-RykBYwOeRIuscuzIKMzRYbfnyHmlTHikMKxTcxka3Cx9X_9Ye1qSPB4Q
X-Cc: netdev@vger.kernel.org, dsahern@kernel.org, idosch@nvidia.com, 
	davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, 
	steffen.klassert@secunet.com, willemb@google.com, jiayuan.chen@linux.dev, 
	mfleming@cloudflare.com, almasrymina@google.com, bigeasy@linutronix.de, 
	richardbgobert@gmail.com, ecree.xilinx@gmail.com, 
	linux-kernel@vger.kernel.org