Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: deliran@verdict.gg
Cc: dsahern@kernel.org, idosch@nvidia.com, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	horms@kernel.org, shuah@kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net-next v3 1/3] ipv4: Only lower the pmtu of the other paths of a multipath route
Date: Tue, 17 Nov 2026 13:14:32 +0000	[thread overview]
Message-ID: <179492127205.3136.8000731978199996430@kernel.org> (raw)
In-Reply-To: <20261113122237.88990-2-deliran@verdict.gg>

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 (1) · Low: 2 (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] In __ip_rt_update_pmtu() (net/ipv4/route.c), the new per-path
  check is written as `if (!lock && mtu > fib_nhc_mtu(...)) continue;`,…
- [Low] The comment on fib_nhc_mtu() (net/ipv4/route.c) says it returns
  the mtu 'as ipv4_mtu() would report it', but it treats an exception…
- [Low] The commit message says the patch will 'Skip a path when the mtu
  would not lower what that path uses now', but __ip_rt_update_pmtu()…

Pre-existing issues:
- [Medium] This patch adds a per-path check inside the multipath loop of
  __ip_rt_update_pmtu(), but the gates before the loop still depend only…
- [Low] The new skip check reads a path's current pmtu through
  fib_nhc_mtu() under rcu_read_lock() only, using plain loads of…

--

ipv4: Only lower the pmtu of the other paths of a multipath route

This commit changes __ip_rt_update_pmtu() so that, on a multipath route,
a nexthop is skipped when the reported mtu would not lower the mtu that
nexthop uses now. A new helper, fib_nhc_mtu(), computes that mtu. An mtu
that is locked because it is below ip_rt_min_pmtu is still written to
every nexthop.

> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index d0a5f6d77094c..f0da009f41154 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c

[ ... ]

> @@ -1046,6 +1048,26 @@ out:	kfree_skb_reason(skb, reason);
>  	return 0;
>  }
>  
> +#ifdef CONFIG_IP_ROUTE_MULTIPATH
> +/* The mtu a path currently uses for daddr, as ipv4_mtu() would report it. */
> +static u32 fib_nhc_mtu(struct fib_nh_common *nhc, const struct fib_info *fi,
> +		       __be32 daddr)
> +{
> +	struct fib_nh_exception *fnhe = find_exception(nhc, daddr);
> +	u32 mtu = 0;
> +
> +	if (fnhe && fnhe->fnhe_genid == fnhe_genid(dev_net(nhc->nhc_dev)))
> +		mtu = fnhe->fnhe_pmtu;

[Severity: Low]
Does this match what ipv4_mtu() reports when jiffies == fnhe_expires?

find_exception() removes the exception only when
time_after(jiffies, fnhe->fnhe_expires). At equality it still returns the
fnhe, so fnhe_pmtu gets used here.

ipv4_mtu()->ip_dst_mtu_maybe_forward() uses rt_pmtu only while it has
not expired:

	mtu = rt->rt_pmtu;
	if (mtu && time_before(jiffies, READ_ONCE(rt->dst.expires)))
		goto out;

The existing ip_mtu_from_fib_result() handles this case:

	fnhe = find_exception(nhc, daddr);
	if (fnhe && !time_after_eq(jiffies, fnhe->fnhe_expires))
		mtu = fnhe->fnhe_pmtu;

In that one-jiffy window, an expiring lower pmtu can cause a path to be
skipped. That path then falls back to its device mtu. Should the same
!time_after_eq() check be used here?

[ ... ]

> @@ -1085,6 +1107,14 @@ static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu)
>  				nhc = fib_info_nhc(res.fi, nhsel);
>  				if (!nhc)
>  					break;
> +				/* old_mtu above is the mtu of the path dst
> +				 * is on, don't raise what another path
> +				 * uses. A locked mtu clears DF and goes
> +				 * to every path.
> +				 */

[Severity: Medium]
This is a pre-existing issue and was not introduced by this patch. The
checks that run before this loop still look only at the path of the dst
that was looked up:

	old_mtu = ipv4_mtu(dst);
	if (old_mtu < mtu)
		return;
	...
	if (rt->rt_pmtu == mtu && !lock &&
	    time_before(jiffies, READ_ONCE(dst->expires) -
				 net->ipv4.ip_rt_mtu_expires / 2))
		goto out;

ipv4_update_pmtu() and __ipv4_sk_update_pmtu() build fl4 with
__build_flow_key(), which passes 0, 0 for the ports. With L4 multipath
hashing, the lookup can land on a different nexthop than the one the
flow uses.

For example, path A has mtu 9000 and path B has mtu 1400. An ICMP
reporting 1500 arrives for an unconnected UDP flow or a tunnel flow on
A, and the portless lookup picks B. Is the update then dropped before
any path is checked? If so, flows on A never learn their pmtu. TCP is
not affected, because inet_csk_update_pmtu() passes the socket's own dst.

Now that the loop checks each path, could the multipath case skip the
old_mtu early return?

> +				if (!lock &&
> +				    mtu > fib_nhc_mtu(nhc, res.fi, fl4->daddr))
> +					continue;

[Severity: High]
Can the locked branch still raise another path's mtu? When the reported
mtu is below ip_rt_min_pmtu, earlier in __ip_rt_update_pmtu() we have:

	if (mtu < net->ipv4.ip_rt_min_pmtu) {
		lock = true;
		mtu = min(old_mtu, net->ipv4.ip_rt_min_pmtu);
	}

old_mtu is ipv4_mtu(dst), so it only reflects the path of the dst that
was looked up. Because !lock short-circuits the check, this locked value
is written to every nexthop. It is never clamped to that nexthop's own
mtu.

A nexthop whose device mtu is below this value would get a locked pmtu
it cannot carry. That happens when the device mtu is below the default
min_pmtu of 552. It also happens when net.ipv4.route.min_pmtu has been
raised above a slower path's device mtu, for example min_pmtu=1400 with
a 1380 mtu tunnel nexthop. That sysctl has extra1 = &ip_min_valid_pmtu
but no upper bound. The write also replaces a lower locked pmtu that the
path learned earlier.

Clearing DF doesn't seem to help. ip_dst_mtu_maybe_forward() uses a
locked, unexpired rt_pmtu as is, with no cap at dev->mtu. It does this
for both local output and forwarding:

	if (READ_ONCE(net->ipv4.sysctl_ip_fwd_use_pmtu) ||
	    ip_mtu_locked(dst) ||
	    !forwarding) {
		mtu = rt->rt_pmtu;
		if (mtu && time_before(jiffies, READ_ONCE(rt->dst.expires)))
			goto out;
	}

Flows on that path would then build or fragment packets to the raised
size, and the fragments are still too big for the device. This lasts
until the exception expires.

The commit message describes exactly this failure:

  A path whose device or route mtu is below it, or that already
  learned a lower pmtu, ends up with a pmtu above what it can carry

It still seems reachable through the locked branch. The behaviour is
older than this patch, but the subject and the loop comment suggest it
is now covered.

Would passing min(mtu, fib_nhc_mtu(nhc, res.fi, fl4->daddr)) with lock
still set reach every path and clear DF without raising any of them?

[Severity: Low]
The commit message says:

  Skip a path when the mtu would not lower what that path uses now

The comparison is a strict >, so an mtu equal to the path's current mtu
is not skipped. fib_nhc_mtu() also ignores fnhe_mtu_locked. Both
ipv4_mtu() and the single-path code (if (ip_mtu_locked(dst)) return;)
honour it.

Suppose path B has a locked exception at 552 from an earlier ICMP below
min_pmtu. A non-locked update of exactly 552 then arrives for a flow on
path A. B is not skipped, and update_or_create_fnhe() does:

		if (pmtu) {
			fnhe->fnhe_pmtu = pmtu;
			fnhe->fnhe_mtu_locked = lock;
		}

Would this clear the lock on B? B would then send with DF set again, and
forwarding on B would stop using the pmtu. Should the check be >=, and
should a path with a locked exception be skipped?

>  				update_or_create_fnhe(nhc, fl4->daddr, 0, mtu, lock,
>  						      jiffies + net->ipv4.ip_rt_mtu_expires);

[Severity: Low]
This is a pre-existing pattern and was not introduced by this patch.
fib_nhc_mtu() reads fnhe_pmtu under rcu_read_lock() only. Then
update_or_create_fnhe() takes fnhe_lock and writes fnhe_pmtu without
comparing it again.

Two concurrent updates for the same daddr could race. Say one CPU
reports 1400 and another reports 1300, and both see path B at 1500.
Neither skips B, and they can finish in either order. B could end up at
1400 right after it learned 1300.

The single-path code has the same lockless check before
update_or_create_fnhe(). Is "don't raise what another path uses" meant
to hold under concurrent updates?

>  			}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113122237.88990-1-deliran%40verdict.gg

  reply	other threads:[~2026-11-17 13:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 12:22 [PATCH net-next v3 0/3] ipv4/ipv6: Cache pmtu on all paths of a multipath route Vladimir Vdovin
2026-11-13 12:22 ` [PATCH net-next v3 1/3] ipv4: Only lower the pmtu of the other " Vladimir Vdovin
2026-11-17 13:14   ` netdev-bot+sashiko [this message]
2026-11-13 12:22 ` [PATCH net-next v3 2/3] ipv6: Cache pmtu for all " Vladimir Vdovin
2026-11-17 13:14   ` netdev-bot+sashiko
2026-11-13 12:22 ` [PATCH net-next v3 3/3] selftests: net: pmtu: Add IPv6 and asymmetric multipath tests Vladimir Vdovin
2026-11-17 13:14   ` netdev-bot+sashiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179492127205.3136.8000731978199996430@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=deliran@verdict.gg \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox