🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #1934

Re: [PATCH net] ipmr: do not drop GSO packets that fit the MTU after segmentation

#1934
From: netdev-bot+sashiko
Date: Sun, 11 Oct 2026 13:44
141 lines
10934 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] On VIFF_TUNNEL vifs the patch does not stop the drop it claims
  to fix.
- [Low] The patch rewrites the DF/MTU check in ipmr_prepare_xmit() from
  `skb->len + encap > dst4_mtu(&rt->dst)` (which cannot wrap) to `mtu =…

--

ipmr: do not drop GSO packets that fit the MTU after segmentation

This patch changes ipmr_prepare_xmit() so a DF packet larger than the
route MTU is no longer dropped if it is a GSO packet whose segments fit
that MTU. This matches the skb_gso_validate_network_len() check in
ip_forward(). The MTU used for the check is now dst4_mtu() minus the
tunnel encapsulation overhead.

> diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
> index b9c544d48c452..06c37b4e653bf 100644
> --- a/net/ipv4/ipmr.c
> +++ b/net/ipv4/ipmr.c
> @@ -1908,6 +1908,7 @@ static int ipmr_prepare_xmit(struct net *net, struct mr_table *mrt,
>  	struct rtable *rt;
>  	struct flowi4 fl4;
>  	int    encap = 0;
> +	unsigned int mtu;
>  
>  	vif_dev = vif_dev_read(vif);
>  	if (!vif_dev)
> @@ -1940,7 +1941,9 @@ static int ipmr_prepare_xmit(struct net *net, struct mr_table *mrt,
>  			return -1;
>  	}
>  
> -	if (skb->len+encap > dst4_mtu(&rt->dst) && (ntohs(iph->frag_off) & IP_DF)) {
> +	mtu = dst4_mtu(&rt->dst) - encap;
> +	if (skb->len > mtu && (ntohs(iph->frag_off) & IP_DF) &&
> +	    !(skb_is_gso(skb) && skb_gso_validate_network_len(skb, mtu))) {

[Severity: High]
The new mtu value subtracts encap, so this check seems meant to cover
VIFF_TUNNEL vifs too. Can a DF GSO aggregate that passes it actually be
transmitted on a tunnel vif?

Further down in ipmr_prepare_xmit(), such an skb goes to ip_encap():

	if (vif->flags & VIFF_TUNNEL) {
		ip_encap(net, skb, vif->local, vif->remote);

ip_encap() only adds the outer header:

	skb_push(skb, sizeof(struct iphdr));
	skb->transport_header = skb->network_header;
	skb_reset_network_header(skb);
	...
	iph->protocol	=	IPPROTO_IPIP;
	...
	iph->tot_len	=	htons(skb->len);

It does not add SKB_GSO_IPXIP4 to gso_type, set skb->encapsulation or
set the inner header offsets. ipip_tunnel_xmit() does set up that state,
by calling iptunnel_handle_offloads(skb, SKB_GSO_IPXIP4) first.

Software segmentation runs for fraglist GSO, and on any device without
hardware USO. In that case the path is:

validate_xmit_skb()
  skb_gso_segment()
    inet_gso_segment()
      ipip_gso_segment()

and ipip_gso_segment() rejects the skb:

	if (!(skb_shinfo(skb)->gso_type & SKB_GSO_IPXIP4))
		return ERR_PTR(-EINVAL);

validate_xmit_skb() then frees the skb and only increments tx_dropped.
The skb_gso_network_seglen() check in ip_finish_output_gso() does not
catch this either. After ip_encap(), transport minus network covers only
the 20-byte outer header.

So on tunnel vifs, are these packets still dropped, just no longer
counted in FragFails? Meanwhile vif->pkt_out, vif->bytes_out,
tx_packets and OUTFORWDATAGRAMS count them as sent.

There is also a hardware case, which I have not fully traced. If the
egress device advertises NETIF_F_GSO_UDP_L4 and the aggregate is plain
UDP_L4 from UDP GRO forwarding, could the device get a GSO skb whose
transport offset points at the inner IP header and has no encapsulation
flag? Could it then send malformed segments?

Before this patch these DF aggregates were dropped up front here. The
ip_encap() GSO problem already existed for non-DF GSO skbs, but this
change lets DF traffic reach it as well.

Would it work to apply the exemption only when encap == 0? Other options
are to segment before ip_encap(), or to have ip_encap() set up the
IPXIP4 GSO state the way iptunnel_handle_offloads() does.

[Severity: Low]
The old check was additive and could not wrap:

	if (skb->len+encap > dst4_mtu(&rt->dst) && ...

The new code does an unsigned subtraction instead. On the VIFF_TUNNEL
path encap is sizeof(struct iphdr), which is 20. If the route to
vif->remote has an MTU below 20, can mtu wrap to a value near UINT_MAX?

ip_metrics_convert() only clamps RTAX_MTU from above:

	if (type == RTAX_MTU && val > 65535 - 15)
		val = 65535 - 15;

ip_dst_mtu_maybe_forward() also returns the metric with no lower bound,
apart from subtracting the lwtunnel headroom.

If mtu wraps, skb->len > mtu is false for every DF packet, GSO or not,
so the drop and its IPSTATS_MIB_FRAGFAILS count are skipped. The packet
then gets vif and device tx accounting and goes through the
NF_INET_FORWARD hook. It is only dropped later, by the mtu < hlen + 8
check in ip_do_fragment(), or during GSO segmentation.

This needs a privileged and odd route configuration. Would keeping the
additive comparison, or checking that dst4_mtu() > encap before
subtracting, avoid it?

>  		/* Do not fragment multicasts. Alas, IPv4 does not
>  		 * allow to send ICMP, so that packets will disappear
>  		 * to blackhole.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261010131842.2157365-1-julius%40bairaktaris.de
Technical Details
Message-ID: <179172627842.434549.17722584347227331391@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-344506-linux-kernel-netdev=dewy.ru
References: <20261010131842.2157365-1-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-344506-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] ipmr: do not drop GSO packets that fit the MTU after
 segmentation
Date: Sun, 11 Oct 2026 13:44:38 +0000
Organization: Usenet Network
Message-ID: <179172627842.434549.17722584347227331391@kernel.org>
References: <20261010131842.2157365-1-julius@bairaktaris.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1549125"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:uzOPlfl2PmzvL7mR1LCbTMwqxIs= sha256:mGKwK9BEMRCIa51vxbnut3VMyrJlKz/royKOJxMRiK0=
	sha1:ZW7SoDoKWowqJX7nixGu3orfQMA= sha256:QQJX9Jwjdvxz0dLdE2bTJQLO7c2BKjwxSHwWl9k7/pY=
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 8AFFD10FA06; Sun, 11 Oct 2026 16:44:59 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.34
X-Spam-Status: No, score=-1.34 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.241, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=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 2bTmgsx_OhQ3;
	Sun, 11 Oct 2026 16:44:51 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-344506-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id BADE910FA03; Sun, 11 Oct 2026 16:44:44 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by tor.lore.kernel.org (Postfix) with ESMTP id 7449427D36; Sun, 11 Oct 2026 13:44:42 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 22FAF429014;
	Sun, 11 Oct 2026 13:44:41 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PMI/KlHo"
X-Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8CCE23ED5E;
	Sun, 11 Oct 2026 13:44:39 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1791726281; cv=none; b=js+FAV2LN7oPE7PxxyP5Hgcmy2SYo0mERqvBPZdnXcUJjsCoZhDuF+qQlYEHiSR1XCV8Qf3mWXX5/CMjasWfO5NTE3iEdC0Ou10+rJNiiQkE+WTMvZSu1jdSCKuad267k/IEuRwjSrYxDycQaozyo8angAd04BiJ7/YFNZxResQ=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1791726281; c=relaxed/simple;
	bh=SY1aZ5FFRmCf+dJslwGoOhZMH+FBGqIQNpQZvMzedXI=;
	h=Subject:From:To:Cc:Date:Message-ID:In-Reply-To:References:
	 Content-Type:MIME-Version; b=jeovNFrx76ArL5Hm/Po5qQLbXgdD3w2dU+PgT2gASgQHmPbIDIFMfO1dBtCwjg/8VMflCVHTOWngVm8BsXKsk7rMXMZCFG3U1RJvqfFVEoPJZYJLXn0Hy4MQ84aKYVIa6Fn2h2VzZKNYOULgGHXEIkfiYSblPO7eRRlQ9jDoZ5A=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PMI/KlHo; arc=none smtp.client-ip=100.103.45.18
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA8AC1F0089B;
	Sun, 11 Oct 2026 13:44:38 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1791726279;
	bh=vu2YEMKauIpc7tvvbmbxBOjYQhZ2cgVTT1RoZH61C8c=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=PMI/KlHobLaSx5EuU461CGRAlXhLirQE/q/5v8VIxncXoqknMmuf8MeEeX8LuYoBC
	 neaMqygQiTTbD6ygjWM/oDvBRyO5EpxVCr/e6L7Av0diTQ871vJBvgzvg/DvPcJP6a
	 u52WQ7sy6y9Wzaws0IIkpVMuxKo0Hk2C1lhYJFhWTxIcMDAAqMXxVTQqOo2aTOVjPW
	 W2Xk9K7AFd5jGiKXgqb1pFuouDul/HKBC1sW0/8TkgZqugd5Jg/OYgy5YC8IYsLGQD
	 gDjmKJPahwzBMOcFcY2O0FjKCuK2R4iHWuPn9IZ6RR9svSWxNt1eqlv9EDJXL/vzgn
	 A2G7RdhdQNm4A==
X-Cc: netdev@vger.kernel.org, dsahern@kernel.org, idosch@nvidia.com,
 davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 horms@kernel.org, steffen.klassert@secunet.com, willemb@google.com,
 linux-kernel@vger.kernel.org
X-In-Reply-To: <20261010131842.2157365-1-julius@bairaktaris.de>
X-sashiko-severity: High
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>