* [PATCH net-next v3 0/3] ipv4/ipv6: Cache pmtu on all paths of a multipath route
@ 2026-11-13 12:22 Vladimir Vdovin
2026-11-13 12:22 ` [PATCH net-next v3 1/3] ipv4: Only lower the pmtu of the other " Vladimir Vdovin
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Vladimir Vdovin @ 2026-11-13 12:22 UTC (permalink / raw)
To: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan
Cc: netdev, linux-kernel, linux-kselftest, Vladimir Vdovin
IPv6 counterpart of commit 7d3f3b4367f3 ("net: ipv4: Cache pmtu for
all packet paths if multipath enabled"), deferred back then [1].
Patch 1 keeps the IPv4 fan-out from raising the pmtu of a path above
what it can carry, patch 2 does the IPv6 side, patch 3 adds the tests:
the IPv6 variant of the pmtu.sh multipath test and, for both families,
a multipath test with paths of different MTU. The asymmetric tests
fail without patch 1, the IPv6 ones without patch 2.
v3, after the Sashiko review of v2:
- compare the mtu with what each path uses now, not once with the
looked-up dst, so no path gets a pmtu above what it can carry
- ipv6: keep updating a cached dst itself, the walk may not find it
- ipv4: Fixes: tag, Fragmentation Needed wording
- tests: MTU 1350 on the link to R2, so a Packet Too Big from R1 must
not be cached on the path via R2
- tests: return routes on R1 and R2, hex flow labels, skip when
"ip route get" has no flowlabel
v2: https://lore.kernel.org/netdev/20261110095903.84813-1-deliran@verdict.gg/
v2, after the Sashiko review of v1:
- update an existing exception in place, on every Packet Too Big
- don't walk the siblings of a fib6_info no longer in the tree
- commit message: the lookup in ip6_update_pmtu() hashes without
protocol and ports
- new ipv4 patch, tests with paths of different MTU
v1: https://lore.kernel.org/netdev/20261017210508.71849-1-deliran@verdict.gg/
[1] https://lore.kernel.org/netdev/ad29493c-9e48-4a94-b327-e47af3a9d137@kernel.org/
Vladimir Vdovin (3):
ipv4: Only lower the pmtu of the other paths of a multipath route
ipv6: Cache pmtu for all paths of a multipath route
selftests: net: pmtu: Add IPv6 and asymmetric multipath tests
net/ipv4/route.c | 30 +++
net/ipv6/route.c | 121 ++++++++----
tools/testing/selftests/net/pmtu.sh | 281 ++++++++++++++++++++++++----
3 files changed, 355 insertions(+), 77 deletions(-)
base-commit: d26955e57475434b59d43ba372b2a50d33d5e0ed
--
2.56.0
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH net-next v3 1/3] ipv4: Only lower the pmtu of the other paths of a multipath route 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 ` Vladimir Vdovin 2026-11-17 13:14 ` netdev-bot+sashiko 2026-11-13 12:22 ` [PATCH net-next v3 2/3] ipv6: Cache pmtu for all " Vladimir Vdovin 2026-11-13 12:22 ` [PATCH net-next v3 3/3] selftests: net: pmtu: Add IPv6 and asymmetric multipath tests Vladimir Vdovin 2 siblings, 1 reply; 7+ messages in thread From: Vladimir Vdovin @ 2026-11-13 12:22 UTC (permalink / raw) To: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan Cc: netdev, linux-kernel, linux-kselftest, Vladimir Vdovin Since commit 7d3f3b4367f3 ("net: ipv4: Cache pmtu for all packet paths if multipath enabled") __ip_rt_update_pmtu() caches the mtu of a Fragmentation Needed on every path of a multipath route, as the lookup there doesn't know the flow the message was sent for and may land on another path than the one that flow is on. But only that path is checked against the mtu, by the old_mtu early return, the others get it as is. 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: its flows send packets of that size, which don't get through, and no Fragmentation Needed comes back for them until the exception expires. Skip a path when the mtu would not lower what that path uses now: the pmtu of its live exception if it has one, else the mtu of the route or the device, the way ipv4_mtu() would report them. A mtu locked because it is below ip_rt_min_pmtu is still written everywhere, it clears DF and has to reach the path the flow is on. Fixes: 7d3f3b4367f3 ("net: ipv4: Cache pmtu for all packet paths if multipath enabled") Signed-off-by: Vladimir Vdovin <deliran@verdict.gg> --- net/ipv4/route.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/net/ipv4/route.c b/net/ipv4/route.c index d0a5f6d77094..f0da009f4115 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -150,6 +150,8 @@ static struct neighbour *ipv4_dst_neigh_lookup(const struct dst_entry *dst, struct sk_buff *skb, const void *daddr); static void ipv4_confirm_neigh(const struct dst_entry *dst, const void *daddr); +static struct fib_nh_exception *find_exception(struct fib_nh_common *nhc, + __be32 daddr); static struct dst_ops ipv4_dst_ops = { .family = AF_INET, @@ -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; + if (!mtu) + mtu = fi->fib_mtu; + if (!mtu) + mtu = READ_ONCE(nhc->nhc_dev->mtu); + mtu = min(mtu, IP_MAX_MTU); + + return mtu - lwtunnel_headroom(nhc->nhc_lwtstate, mtu); +} +#endif + static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu) { struct dst_entry *dst = &rt->dst; @@ -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. + */ + if (!lock && + mtu > fib_nhc_mtu(nhc, res.fi, fl4->daddr)) + continue; update_or_create_fnhe(nhc, fl4->daddr, 0, mtu, lock, jiffies + net->ipv4.ip_rt_mtu_expires); } -- 2.56.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next v3 1/3] ipv4: Only lower the pmtu of the other paths of a multipath route 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 0 siblings, 0 replies; 7+ messages in thread From: netdev-bot+sashiko @ 2026-11-17 13:14 UTC (permalink / raw) To: deliran Cc: dsahern, idosch, davem, edumazet, kuba, pabeni, horms, shuah, netdev, linux-kernel, linux-kselftest 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net-next v3 2/3] ipv6: Cache pmtu for all paths of a multipath route 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-13 12:22 ` 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 2 siblings, 1 reply; 7+ messages in thread From: Vladimir Vdovin @ 2026-11-13 12:22 UTC (permalink / raw) To: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan Cc: netdev, linux-kernel, linux-kselftest, Vladimir Vdovin ip6_update_pmtu() looks the destination up without the protocol and ports the offending packet was hashed on, so with a multipath route the exception may be created on another path than the one the packet took. The flow then keeps sending too big packets on its path, every Packet Too Big lands on the same wrong path, and the flow blackholes. Same problem and same fix as for IPv4 in commit 7d3f3b4367f3 ("net: ipv4: Cache pmtu for all packet paths if multipath enabled"): cache the pmtu on every path of the route. For a nexthop object walk all of its fib6_nh, for a legacy multipath route walk the siblings of the fib6_info the dst came from. A path only ever lowers what it uses: the pmtu of the exception it already has for the destination, which is updated in place so that a gateway from a redirect stays, the mtu of the device for an exception without a pmtu, or the mtu of the route and the device when a new exception is created. That check moves from the looked-up dst to each path: the lookup may land on a path narrower than the Packet Too Big, which used to end the update before the path the flow is on had learned anything. A dst that is a cached exception, or can't have one, is still updated itself as before: the walk is keyed by the destination and would not find the first hop dst of a socket with a routing header. Link: https://lore.kernel.org/netdev/ad29493c-9e48-4a94-b327-e47af3a9d137@kernel.org/ Signed-off-by: Vladimir Vdovin <deliran@verdict.gg> --- net/ipv6/route.c | 121 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 82 insertions(+), 39 deletions(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 04098cf32eab..ccb11a465528 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -2911,12 +2911,55 @@ static bool rt6_cache_allowed_for_pmtu(const struct rt6_info *rt) (rt->rt6i_flags & RTF_PCPU || rcu_access_pointer(rt->from)); } +struct rt6_pmtu_arg { + struct fib6_result res; + const struct in6_addr *daddr; + const struct in6_addr *saddr; + u32 mtu; +}; + +/* Cache a pmtu on one path of a route, never raising what the path + * uses for daddr. An existing exception is updated in place, a new + * one would lose a gateway learned from a redirect. + */ +static int rt6_nh_update_pmtu(struct fib6_nh *nh, void *_arg) +{ + struct rt6_pmtu_arg *arg = _arg; + struct fib6_result *res = &arg->res; + struct rt6_info *rt; + + res->nh = nh; + rt = rt6_find_cached_rt(res, arg->daddr, arg->saddr); + if (rt) { + if (arg->mtu < dst6_mtu(&rt->dst)) { + rt6_do_update_pmtu(rt, arg->mtu); + fib6_nh_update_exception(nh, res->f6i->fib6_src.plen, + rt); + } + return 0; + } + + if (arg->mtu >= fib6_mtu(res)) + return 0; + + rt = ip6_rt_cache_alloc(res, arg->daddr, arg->saddr); + if (rt) { + rt6_do_update_pmtu(rt, arg->mtu); + if (rt6_insert_exception(rt, res)) + dst_release_immediate(&rt->dst); + } + + return 0; +} + static void __ip6_rt_update_pmtu(struct dst_entry *dst, const struct sock *sk, const struct ipv6hdr *iph, u32 mtu, bool confirm_neigh) { - const struct in6_addr *daddr, *saddr; + struct rt6_pmtu_arg arg = { .mtu = mtu }; struct rt6_info *rt6 = dst_rt6_info(dst); + const struct in6_addr *daddr, *saddr; + struct fib6_info *f6i, *sibling; /* Note: do *NOT* check dst_metric_locked(dst, RTAX_MTU) * IPv6 pmtu discovery isn't optional, so 'mtu lock' cannot disable it. @@ -2939,55 +2982,55 @@ static void __ip6_rt_update_pmtu(struct dst_entry *dst, const struct sock *sk, if (mtu < IPV6_MIN_MTU) return; - if (mtu >= dst6_mtu(dst)) - return; - if (!rt6_cache_allowed_for_pmtu(rt6)) { + rcu_read_lock(); + /* A dst that is a cached exception, or can't have one, is updated + * itself: the walk below is keyed by daddr and may not find it, a + * socket with a routing header holds the dst of the first hop while + * daddr is the final destination. + */ + if (!rt6_cache_allowed_for_pmtu(rt6) && mtu < dst6_mtu(dst)) { rt6_do_update_pmtu(rt6, mtu); /* update rt6_ex->stamp for cache */ if (rt6->rt6i_flags & RTF_CACHE) rt6_update_exception_stamp_rt(rt6); - } else if (daddr) { - struct fib6_result res = {}; - struct rt6_info *nrt6; - - rcu_read_lock(); - res.f6i = rcu_dereference(rt6->from); - if (!res.f6i) - goto out_unlock; - - res.fib6_flags = res.f6i->fib6_flags; - res.fib6_type = res.f6i->fib6_type; + } - if (res.f6i->nh) { - struct fib6_nh_match_arg arg = { - .dev = dst_dev_rcu(dst), - .gw = &rt6->rt6i_gateway, - }; + f6i = rcu_dereference(rt6->from); + /* Don't walk the siblings of a route being removed from the tree */ + if (!daddr || !f6i || !rcu_access_pointer(f6i->fib6_node)) + goto out; - nexthop_for_each_fib6_nh(res.f6i->nh, - fib6_nh_find_match, &arg); + arg.daddr = daddr; + arg.saddr = saddr; + arg.res.f6i = f6i; + arg.res.fib6_flags = f6i->fib6_flags; + arg.res.fib6_type = f6i->fib6_type; - /* fib6_info uses a nexthop that does not have fib6_nh - * using the dst->dev + gw. Should be impossible. - */ - if (!arg.match) - goto out_unlock; + /* The lookup in ip6_update_pmtu() doesn't hash on the protocol and + * ports, dst may be another path than the too big packet took: + * cache the pmtu on every path it lowers. + */ + if (f6i->nh) { + nexthop_for_each_fib6_nh(f6i->nh, rt6_nh_update_pmtu, &arg); + goto out; + } - res.nh = arg.match; - } else { - res.nh = res.f6i->fib6_nh; - } + rt6_nh_update_pmtu(f6i->fib6_nh, &arg); - nrt6 = ip6_rt_cache_alloc(&res, daddr, saddr); - if (nrt6) { - rt6_do_update_pmtu(nrt6, mtu); - if (rt6_insert_exception(nrt6, &res)) - dst_release_immediate(&nrt6->dst); - } -out_unlock: - rcu_read_unlock(); + /* fib6_del_route() zeroes fib6_nsiblings before unlinking f6i, stop + * then as the walk would never get back to its head. + */ + list_for_each_entry_rcu(sibling, &f6i->fib6_siblings, fib6_siblings) { + arg.res.f6i = sibling; + arg.res.fib6_flags = sibling->fib6_flags; + arg.res.fib6_type = sibling->fib6_type; + rt6_nh_update_pmtu(sibling->fib6_nh, &arg); + if (!READ_ONCE(f6i->fib6_nsiblings)) + break; } +out: + rcu_read_unlock(); } static void ip6_rt_update_pmtu(struct dst_entry *dst, struct sock *sk, -- 2.56.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next v3 2/3] ipv6: Cache pmtu for all paths of a multipath route 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 0 siblings, 0 replies; 7+ messages in thread From: netdev-bot+sashiko @ 2026-11-17 13:14 UTC (permalink / raw) To: deliran Cc: dsahern, idosch, davem, edumazet, kuba, pabeni, horms, shuah, netdev, linux-kernel, linux-kselftest Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 4 · 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). - [Medium] The patch removes the early `if (mtu >= dst6_mtu(dst)) return;` from __ip6_rt_update_pmtu() (net/ipv6/route.c). - [Medium] The new legacy-sibling walk in __ip6_rt_update_pmtu() can create a PMTU exception on a fib6_info that fib6_add_rt2node() has put… - [Medium] One unauthenticated ICMPv6 Packet Too Big now costs up to N exception allocations and inserts, where N is the number of paths of… - [Medium] ipv6: blackhole bypass in __ip6_rt_update_pmtu() on nexthop replace - [Low] rt6_nh_update_pmtu() checks for an existing exception with rt6_find_cached_rt() under RCU only. -- ipv6: Cache pmtu for all paths of a multipath route With this patch, __ip6_rt_update_pmtu() caches a PMTU exception on every path of a multipath IPv6 route. It walks all fib6_nh of a nexthop object, or all siblings of a legacy multipath route. The mtu >= dst6_mtu(dst) check moves from the looked-up dst into each path, and an existing exception is lowered in place, mirroring commit 7d3f3b4367f3 for IPv4. Link: https://lore.kernel.org/netdev/ad29493c-9e48-4a94-b327-e47af3a9d137@kernel.org/ > diff --git a/net/ipv6/route.c b/net/ipv6/route.c > index 04098cf32eabe..ccb11a4655287 100644 > --- a/net/ipv6/route.c > +++ b/net/ipv6/route.c > @@ -2911,12 +2911,55 @@ static bool rt6_cache_allowed_for_pmtu(const struct rt6_info *rt) [ ... ] > +static int rt6_nh_update_pmtu(struct fib6_nh *nh, void *_arg) > +{ > + struct rt6_pmtu_arg *arg = _arg; > + struct fib6_result *res = &arg->res; > + struct rt6_info *rt; > + > + res->nh = nh; > + rt = rt6_find_cached_rt(res, arg->daddr, arg->saddr); > + if (rt) { > + if (arg->mtu < dst6_mtu(&rt->dst)) { > + rt6_do_update_pmtu(rt, arg->mtu); > + fib6_nh_update_exception(nh, res->f6i->fib6_src.plen, > + rt); > + } > + return 0; > + } > + > + if (arg->mtu >= fib6_mtu(res)) > + return 0; > + > + rt = ip6_rt_cache_alloc(res, arg->daddr, arg->saddr); > + if (rt) { > + rt6_do_update_pmtu(rt, arg->mtu); > + if (rt6_insert_exception(rt, res)) > + dst_release_immediate(&rt->dst); > + } [Severity: Low] Does the "never raising what the path uses for daddr" guarantee in the comment above rt6_nh_update_pmtu() still hold when two CPUs race here? The rt6_find_cached_rt() check runs under RCU only. On a miss, rt6_insert_exception() takes rt6_exception_lock and replaces any exception it finds for the same key: net/ipv6/route.c:rt6_insert_exception() { ... rt6_ex = __rt6_find_exception_spinlock(&bucket, &nrt->rt6i_dst.addr, src_key); if (rt6_ex) rt6_remove_exception(bucket, rt6_ex); ... } Under the lock, the new mtu is only compared with fib6_mtu(res). It is not compared with the mtu or gateway of the exception being replaced. Suppose two Packet Too Bigs for the same daddr (say 1300 and 1400) are handled on different CPUs and both miss in rt6_find_cached_rt(). Could the later 1400 insert replace the 1300 exception and raise the path's pmtu again? The same question applies if rt6_do_redirect() inserts a redirect exception between the lookup and the insert. Would the redirect gateway be lost then? The old code had the same find-then-replace window, but only on the looked-up path. With the walk, two PTBs for different flows to the same daddr now race on every sibling. Would re-checking for an existing exception under rt6_exception_lock, and lowering it in place, make the guarantee in the commit message hold? > + > + return 0; > +} [ ... ] > @@ -2939,55 +2982,55 @@ static void __ip6_rt_update_pmtu(struct dst_entry *dst, const struct sock *sk, > > if (mtu < IPV6_MIN_MTU) > return; > - if (mtu >= dst6_mtu(dst)) > - return; [Severity: Medium] Does dropping this early return affect callers other than ip6_update_pmtu()? __ip6_rt_update_pmtu() is dst_ops->update_pmtu for every IPv6 dst. Several tunnel xmit paths call it on every packet, with an mtu equal to or above the inner dst's mtu. One example is tnl_update_pmtu() in net/ipv4/ip_tunnel.c when DF is not set: mtu = skb_valid_dst(skb) ? dst_mtu(skb_dst(skb)) : dev->mtu; } if (skb_valid_dst(skb)) skb_dst_update_pmtu_no_confirm(skb, mtu); ip6_tnl_xmit() in net/ipv6/ip6_tunnel.c always calls skb_dst_update_pmtu_no_confirm() with the outer mtu minus overhead, which normally equals the ip6tnl device mtu. ipip6_tunnel_xmit() in net/ipv6/sit.c does the same when DF is set. Before this patch these calls returned here. Now every such packet takes rcu_read_lock() and walks every fib6_nh of the inner route, running rt6_find_cached_rt() and fib6_mtu() on each path. Take an inner route that is multipath with a wider sibling, for example ECMP over a GRE/sit/ip6tnl leg at 1476/1480/1452 and a native 1500 byte leg. On the wide leg, rt6_nh_update_pmtu() sees arg->mtu < fib6_mtu(res). Would that create an RTF_CACHE exception on the wide leg with the tunnel's own mtu, for every new inner daddr, without any Packet Too Big being received? Each insert also runs fib6_update_sernum() and fib6_force_start_gc(). Nothing is cached on the tunnel leg, since its mtu is equal rather than lower. The skb dst stays the pcpu route, so the walk repeats on every packet. In the ip6_tnl_xmit() case where the skb dst is an RTF_CACHE exception narrower than the tunnel mtu (mtu > dst mtu), wouldn't the larger tunnel mtu also be copied onto the wider siblings? IPv4 also continues on an equal mtu, since its gate is old_mtu < mtu. But it caches on its own path and returns early on rt->rt_pmtu == mtu, so the repeated per-packet walk looks specific to IPv6. The caller in nf_flow_table_ip.c is not affected, because skb_scrub_packet() drops the dst first. The commit message explains moving the check per path by the PTB lookup landing on the wrong path. For these local callers the dst is already the flow's own path. Was the change in behaviour for them intended? > > - if (!rt6_cache_allowed_for_pmtu(rt6)) { > + rcu_read_lock(); [ ... ] > + /* The lookup in ip6_update_pmtu() doesn't hash on the protocol and > + * ports, dst may be another path than the too big packet took: > + * cache the pmtu on every path it lowers. > + */ > + if (f6i->nh) { > + nexthop_for_each_fib6_nh(f6i->nh, rt6_nh_update_pmtu, &arg); > + goto out; > + } [Severity: Medium] Can this walk insert a usable exception into the fib6_nh of a blackhole nexthop? For a route using a nexthop object, the blackhole state lives in nhi->reject_nh, not in the fib6_info. f6i->fib6_flags has no RTF_REJECT, and f6i->fib6_type is RTN_UNICAST. The route lookup only puts RTF_REJECT and RTN_BLACKHOLE into the fib6_result when it sees nexthop_is_blackhole(). Here, arg.res.fib6_flags and arg.res.fib6_type are copied straight from f6i, and f6i->nh is walked without that check. Suppose replace_nexthop() swaps the nh_info under f6i->nh to a blackhole one after ip6_update_pmtu() looked up its dst, but before this walk. The walk then reaches the blackhole fib6_nh, whose fib_nh_dev is loopback_dev. rt6_find_cached_rt() misses, and arg->mtu is below fib6_mtu() for loopback_dev, so ip6_rt_cache_alloc() is called. Without RTF_REJECT in res->fib6_flags, ip6_rt_init_dst() sets up a normal unicast dst on loopback_dev. It has error 0, output ip6_output and input ip6_forward. rt6_insert_exception() then adds it to the blackhole fib6_nh's exception bucket. ip6_pol_route() checks the exception table before the reject dst is ever built: net/ipv6/route.c:ip6_pol_route() { ... rt = rt6_find_cached_rt(&res, &fl6->daddr, &fl6->saddr); if (rt) { goto out; ... } So lookups for that daddr bypass the blackhole. Packets go out loopback_dev, come back in and are forwarded to loopback_dev again until hop_limit runs out. This lasts for ip6_rt_mtu_expires. The old code did not reach this. fib6_nh_find_match() matched on the dst's device and rt6i_gateway. A blackhole fib6_nh on loopback_dev without a gateway never matches, so nothing was inserted. Triggering this needs CAP_NET_ADMIN to replace a nexthop, used directly or in a single path group, with a blackhole. This has to happen while PMTU discovery is running on the route. The window is small, but the exception outlives it. Would returning early when nexthop_is_blackhole(f6i->nh) be enough here? Or should arg.res.fib6_flags and arg.res.fib6_type be set the same way the lookup sets them for a blackhole nexthop? [Severity: Medium] Can one unauthenticated Packet Too Big now cost up to N exception allocations and inserts instead of at most one, where N is the number of paths of the route? icmpv6_err() calls ip6_update_pmtu() for every ICMPV6_PKT_TOOBIG that carries an inner ICMPv6 header, without a socket lookup: if (type == ICMPV6_PKT_TOOBIG) ip6_update_pmtu(skb, net, info, skb->dev->ifindex, 0, sock_net_uid(net, NULL)); ip6_update_pmtu() routes on the inner daddr, saddr and flowlabel, which the sender chooses. That means any multipath route, such as an ECMP default route, can be targeted. With the mtu >= dst6_mtu(dst) return gone, every path whose fib6_mtu() is above the advertised mtu (which can be just over 1280) goes through: icmpv6_err()->ip6_update_pmtu()->__ip6_rt_update_pmtu() ->rt6_nh_update_pmtu() ->ip6_rt_cache_alloc() ->rt6_insert_exception() global rt6_exception_lock, GFP_ATOMIC allocation, possible eviction of the oldest entry on success: tb6_lock, fib6_update_sernum(), fib6_force_start_gc() With random inner daddrs, each PTB does N such inserts in softirq context, all serialized on one global spinlock. Each sernum bump also invalidates cached dsts on that fib6_node. Memory stays bounded by the per-bucket max depth, but CPU work and lock hold time per received packet grow with N. IPv4 accepted the same trade-off in commit 7d3f3b4367f3. Lowering the pmtu on other paths was already possible by choosing flowlabels, so what's new is the per-packet amplification. The IPv6 version also does a sernum bump and a GC kick on every insert. Could the commit message mention this cost? [ ... ] > + /* fib6_del_route() zeroes fib6_nsiblings before unlinking f6i, stop > + * then as the walk would never get back to its head. > + */ > + list_for_each_entry_rcu(sibling, &f6i->fib6_siblings, fib6_siblings) { > + arg.res.f6i = sibling; > + arg.res.fib6_flags = sibling->fib6_flags; > + arg.res.fib6_type = sibling->fib6_type; > + rt6_nh_update_pmtu(sibling->fib6_nh, &arg); > + if (!READ_ONCE(f6i->fib6_nsiblings)) > + break; > } [Severity: Medium] Can this walk create an exception on a sibling that is in the ring but not yet in the tree? If a FIB notifier then vetoes that route, the exception would leak. Only f6i->fib6_node is checked before the walk. fib6_add_rt2node() links the new route into the sibling list before the notifiers run and before rt->fib6_node is set: net/ipv6/ip6_fib.c:fib6_add_rt2node() { ... list_add_tail_rcu(&rt->fib6_siblings, &sibling->fib6_siblings); ... err = call_fib6_entry_notifiers(info->nl_net, fib_event, rt, extack); if (err) { ... WRITE_ONCE(rt->fib6_nsiblings, 0); list_del_rcu(&rt->fib6_siblings); rt6_multipath_rebalance(next_sibling); return err; } ... rcu_assign_pointer(rt->fib6_node, fn); ... } A PTB handled on another CPU can start from an in-tree sibling, reach rt in the ring, and call rt6_nh_update_pmtu(rt->fib6_nh). ip6_rt_cache_alloc() then takes a reference on rt with fib6_info_hold_safe(). rt6_insert_exception() only checks f6i->fib6_destroying, which is 0 here, so the exception is added to rt->fib6_nh->rt6i_exception_bucket. If the notifier then fails, the error path above only unlinks rt. fib6_add() fails without calling fib6_purge_rt(), so the exceptions are never flushed. fib6_add_gc_list() returns early for a route without a fib6_node, so the exception never ages out either. The only flush left is fib6_nh_release() from fib6_info_destroy_rcu(). That needs rt's refcount to reach zero, but the exception's rt6_info->from holds a reference on rt. Would this leak the fib6_info, the exception rt6_info and their netdev references, so that unregistering the device waits forever? Triggering this needs a CAP_NET_ADMIN append (RTM_NEWROUTE with NLM_F_APPEND) that an in-kernel notifier rejects, for example netdevsim limits or an offload driver. It also has to race with a Packet Too Big for a destination the route covers. The same lifetime hole already exists through fib6_select_path()->rt6_make_pcpu_route(). The old PTB code, though, only inserted on rt6->from, which came from a tree lookup. Would skipping siblings with !rcu_access_pointer(sibling->fib6_node) in this walk close the new case? > +out: > + rcu_read_unlock(); > } -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113122237.88990-1-deliran%40verdict.gg ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net-next v3 3/3] selftests: net: pmtu: Add IPv6 and asymmetric multipath tests 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-13 12:22 ` [PATCH net-next v3 2/3] ipv6: Cache pmtu for all " Vladimir Vdovin @ 2026-11-13 12:22 ` Vladimir Vdovin 2026-11-17 13:14 ` netdev-bot+sashiko 2 siblings, 1 reply; 7+ messages in thread From: Vladimir Vdovin @ 2026-11-13 12:22 UTC (permalink / raw) To: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan Cc: netdev, linux-kernel, linux-kselftest, Vladimir Vdovin Make pmtu_ipv4_mp_exceptions family agnostic and add pmtu_ipv6_mp_exceptions: one oversized ping over a multipath route must leave PMTU exceptions on both paths. Add pmtu_ipv4_mp_asym_exceptions and pmtu_ipv6_mp_asym_exceptions with an MTU of 1400 behind one router, and 1350 on the link to the other router with 1300 behind it. They pick a flow through each router (a source address for IPv4, whose multipath hash covers addresses only, a flow label for IPv6) and check that a Packet Too Big from the first router is cached on its path only, as the second one can't carry 1400, then that a flow through the second router lowers the PMTU of both paths. Without the preceding fixes the asymmetric tests fail for both families and the IPv6 multipath test as well, with both legacy nexthops and nexthop objects. Signed-off-by: Vladimir Vdovin <deliran@verdict.gg> --- tools/testing/selftests/net/pmtu.sh | 281 ++++++++++++++++++++++++---- 1 file changed, 243 insertions(+), 38 deletions(-) diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh index c7cd271714ef..2bd132991841 100755 --- a/tools/testing/selftests/net/pmtu.sh +++ b/tools/testing/selftests/net/pmtu.sh @@ -203,6 +203,19 @@ # on host A and B on lo reachable via both routers. Host A and B # addresses have multipath routes to each other, b_r1 mtu = 1500. # Check that PMTU exceptions are created for both paths. +# +# - pmtu_ipv6_mp_exceptions +# Same as above but with IPv6 +# +# - pmtu_ipv4_mp_asym_exceptions +# Same topology as pmtu_ipv4_mp_exceptions, with b_r1 mtu = 1400, +# a_r2 mtu = 1350 and b_r2 mtu = 1300. Pick a flow through each router +# and check that a Packet Too Big from R1 creates a PMTU exception on +# the path via R1 only, as the path via R2 can't carry 1400, then that +# a flow through R2 lowers the PMTU of both paths +# +# - pmtu_ipv6_mp_asym_exceptions +# Same as above but with IPv6 source lib.sh @@ -272,7 +285,10 @@ tests=" list_flush_ipv6_exception ipv6: list and flush cached exceptions 1 pmtu_ipv4_route_change ipv4: PMTU exception w/route replace 1 pmtu_ipv6_route_change ipv6: PMTU exception w/route replace 1 - pmtu_ipv4_mp_exceptions ipv4: PMTU multipath nh exceptions 1" + pmtu_ipv4_mp_exceptions ipv4: PMTU multipath nh exceptions 1 + pmtu_ipv6_mp_exceptions ipv6: PMTU multipath nh exceptions 1 + pmtu_ipv4_mp_asym_exceptions ipv4: PMTU multipath nh exceptions, asymmetric MTUs 1 + pmtu_ipv6_mp_asym_exceptions ipv6: PMTU multipath nh exceptions, asymmetric MTUs 1" # Addressing and routing for tests with routers: four network segments, with # index SEGMENT between 1 and 4, a common prefix (PREFIX4 or PREFIX6) and an @@ -350,8 +366,12 @@ tunnel6_b_addr="fd00:2::b" tunnel6_mask="64" host4_a_addr="192.168.99.99" +host4_a_net="192.168.97" host4_b_addr="192.168.88.88" +host6_a_addr="fc00:1000::a" +host6_b_addr="fc00:1001::b" + dummy6_0_prefix="fc00:1000::" dummy6_1_prefix="fc00:1001::" dummy6_mask="64" @@ -994,49 +1014,112 @@ setup_ovs_bridge() { } setup_multipath_new() { - # Set up host A with multipath routes to host B host4_b_addr - run_cmd ${ns_a} ip addr add ${host4_a_addr} dev lo - run_cmd ${ns_a} ip nexthop add id 401 via ${prefix4}.${a_r1}.2 dev veth_A-R1 - run_cmd ${ns_a} ip nexthop add id 402 via ${prefix4}.${a_r2}.2 dev veth_A-R2 - run_cmd ${ns_a} ip nexthop add id 403 group 401/402 - run_cmd ${ns_a} ip route add ${host4_b_addr} src ${host4_a_addr} nhid 403 + family=${1} + + if [ ${family} -eq 4 ]; then + host_a_addr=${host4_a_addr} + host_b_addr=${host4_b_addr} + nh_a_r1=${prefix4}.${a_r1}.2 + nh_a_r2=${prefix4}.${a_r2}.2 + nh_b_r1=${prefix4}.${b_r1}.2 + nh_b_r2=${prefix4}.${b_r2}.2 + else + host_a_addr=${host6_a_addr} + host_b_addr=${host6_b_addr} + nh_a_r1=${prefix6}:${a_r1}::2 + nh_a_r2=${prefix6}:${a_r2}::2 + nh_b_r1=${prefix6}:${b_r1}::2 + nh_b_r2=${prefix6}:${b_r2}::2 + fi + + # Set up host A with multipath routes to host B host_b_addr + run_cmd ${ns_a} ip addr add ${host_a_addr} dev lo + run_cmd ${ns_a} ip nexthop add id ${family}01 via ${nh_a_r1} dev veth_A-R1 + run_cmd ${ns_a} ip nexthop add id ${family}02 via ${nh_a_r2} dev veth_A-R2 + run_cmd ${ns_a} ip nexthop add id ${family}03 group ${family}01/${family}02 + run_cmd ${ns_a} ip route add ${host_b_addr} src ${host_a_addr} nhid ${family}03 - # Set up host B with multipath routes to host A host4_a_addr - run_cmd ${ns_b} ip addr add ${host4_b_addr} dev lo - run_cmd ${ns_b} ip nexthop add id 401 via ${prefix4}.${b_r1}.2 dev veth_B-R1 - run_cmd ${ns_b} ip nexthop add id 402 via ${prefix4}.${b_r2}.2 dev veth_B-R2 - run_cmd ${ns_b} ip nexthop add id 403 group 401/402 - run_cmd ${ns_b} ip route add ${host4_a_addr} src ${host4_b_addr} nhid 403 + # Set up host B with multipath routes to host A host_a_addr + run_cmd ${ns_b} ip addr add ${host_b_addr} dev lo + run_cmd ${ns_b} ip nexthop add id ${family}01 via ${nh_b_r1} dev veth_B-R1 + run_cmd ${ns_b} ip nexthop add id ${family}02 via ${nh_b_r2} dev veth_B-R2 + run_cmd ${ns_b} ip nexthop add id ${family}03 group ${family}01/${family}02 + run_cmd ${ns_b} ip route add ${host_a_addr} src ${host_b_addr} nhid ${family}03 } setup_multipath_old() { - # Set up host A with multipath routes to host B host4_b_addr - run_cmd ${ns_a} ip addr add ${host4_a_addr} dev lo - run_cmd ${ns_a} ip route add ${host4_b_addr} \ - src ${host4_a_addr} \ - nexthop via ${prefix4}.${a_r1}.2 weight 1 \ - nexthop via ${prefix4}.${a_r2}.2 weight 1 + family=${1} + + if [ ${family} -eq 4 ]; then + host_a_addr=${host4_a_addr} + host_b_addr=${host4_b_addr} + nh_a_r1=${prefix4}.${a_r1}.2 + nh_a_r2=${prefix4}.${a_r2}.2 + nh_b_r1=${prefix4}.${b_r1}.2 + nh_b_r2=${prefix4}.${b_r2}.2 + else + host_a_addr=${host6_a_addr} + host_b_addr=${host6_b_addr} + nh_a_r1=${prefix6}:${a_r1}::2 + nh_a_r2=${prefix6}:${a_r2}::2 + nh_b_r1=${prefix6}:${b_r1}::2 + nh_b_r2=${prefix6}:${b_r2}::2 + fi + + # Set up host A with multipath routes to host B host_b_addr + run_cmd ${ns_a} ip addr add ${host_a_addr} dev lo + run_cmd ${ns_a} ip route add ${host_b_addr} \ + src ${host_a_addr} \ + nexthop via ${nh_a_r1} weight 1 \ + nexthop via ${nh_a_r2} weight 1 - # Set up host B with multipath routes to host A host4_a_addr - run_cmd ${ns_b} ip addr add ${host4_b_addr} dev lo - run_cmd ${ns_b} ip route add ${host4_a_addr} \ - src ${host4_b_addr} \ - nexthop via ${prefix4}.${b_r1}.2 weight 1 \ - nexthop via ${prefix4}.${b_r2}.2 weight 1 + # Set up host B with multipath routes to host A host_a_addr + run_cmd ${ns_b} ip addr add ${host_b_addr} dev lo + run_cmd ${ns_b} ip route add ${host_a_addr} \ + src ${host_b_addr} \ + nexthop via ${nh_b_r1} weight 1 \ + nexthop via ${nh_b_r2} weight 1 } + setup_multipath() { + family="$1" + + if [ ${family} -eq 4 ]; then + host_a_addr=${host4_a_addr} + host_b_addr=${host4_b_addr} + nh_r1_a=${prefix4}.${a_r1}.1 + nh_r1_b=${prefix4}.${b_r1}.1 + nh_r2_a=${prefix4}.${a_r2}.1 + nh_r2_b=${prefix4}.${b_r2}.1 + else + host_a_addr=${host6_a_addr} + host_b_addr=${host6_b_addr} + nh_r1_a=${prefix6}:${a_r1}::1 + nh_r1_b=${prefix6}:${b_r1}::1 + nh_r2_a=${prefix6}:${a_r2}::1 + nh_r2_b=${prefix6}:${b_r2}::1 + fi + if [ "$USE_NH" = "yes" ]; then - setup_multipath_new + setup_multipath_new ${family} else - setup_multipath_old + setup_multipath_old ${family} fi # Set up routers with routes to dummies - run_cmd ${ns_r1} ip route add ${host4_a_addr} via ${prefix4}.${a_r1}.1 - run_cmd ${ns_r2} ip route add ${host4_a_addr} via ${prefix4}.${a_r2}.1 - run_cmd ${ns_r1} ip route add ${host4_b_addr} via ${prefix4}.${b_r1}.1 - run_cmd ${ns_r2} ip route add ${host4_b_addr} via ${prefix4}.${b_r2}.1 + run_cmd ${ns_r1} ip route add ${host_a_addr} via ${nh_r1_a} + run_cmd ${ns_r2} ip route add ${host_a_addr} via ${nh_r2_a} + run_cmd ${ns_r1} ip route add ${host_b_addr} via ${nh_r1_b} + run_cmd ${ns_r2} ip route add ${host_b_addr} via ${nh_r2_b} +} + +setup_multipath4() { + setup_multipath 4 +} + +setup_multipath6() { + setup_multipath 6 } setup() { @@ -2377,8 +2460,18 @@ test_pmtu_ipv6_route_change() { test_pmtu_ipvX_route_change 6 } -test_pmtu_ipv4_mp_exceptions() { - setup namespaces routing multipath || return $ksft_skip +test_pmtu_ipvX_mp_exceptions() { + family=${1} + + if [ ${family} -eq 4 ]; then + ping=ping + dst="${host4_b_addr}" + else + ping=${ping6} + dst="${host6_b_addr}" + fi + + setup namespaces routing multipath${family} || return $ksft_skip trace "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \ "${ns_r1}" veth_R1-B "${ns_b}" veth_B-R1 \ @@ -2395,18 +2488,130 @@ test_pmtu_ipv4_mp_exceptions() { mtu "${ns_r2}" veth_R2-A 2000 mtu "${ns_r2}" veth_R2-B 1500 mtu "${ns_b}" veth_B-R2 1500 - # Ping and expect two nexthop exceptions for two routes - run_cmd ${ns_a} ping -q -M want -i 0.1 -c 1 -s 1800 "${host4_b_addr}" + run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -c 1 -s 1800 "${dst}" # Check that exceptions have been created with the correct PMTU - pmtu_a_R1="$(route_get_dst_pmtu_from_exception "${ns_a}" "${host4_b_addr}" oif veth_A-R1)" - pmtu_a_R2="$(route_get_dst_pmtu_from_exception "${ns_a}" "${host4_b_addr}" oif veth_A-R2)" - + pmtu_a_R1="$(route_get_dst_pmtu_from_exception "${ns_a}" "${dst}" oif veth_A-R1)" + pmtu_a_R2="$(route_get_dst_pmtu_from_exception "${ns_a}" "${dst}" oif veth_A-R2)" check_pmtu_value "1500" "${pmtu_a_R1}" "exceeding MTU (veth_A-R1)" || return 1 check_pmtu_value "1500" "${pmtu_a_R2}" "exceeding MTU (veth_A-R2)" || return 1 } +test_pmtu_ipv4_mp_exceptions() { + test_pmtu_ipvX_mp_exceptions 4 +} + +# Find a flow from host A to ${2} that goes out through ${3}: a source +# address out of ${host4_a_net}, added to lo as needed, since the IPv4 +# multipath hash covers addresses only, or an IPv6 flow label, in hex as +# both ip and ping take it, for a packet sent from ${host6_a_addr} +mp_flow_via() { + family="${1}" + dst="${2}" + oif="${3}" + + for i in $(seq 1 32); do + if [ ${family} -eq 4 ]; then + flow="${host4_a_net}.${i}" + ${ns_a} ip addr add ${flow}/32 dev lo 2>/dev/null + out="$(${ns_a} ip route get ${dst} from ${flow} 2>/dev/null)" + else + flow="$(printf "0x%x" ${i})" + out="$(${ns_a} ip route get ${dst} from ${host6_a_addr} \ + ipproto 58 flowlabel ${flow} 2>/dev/null)" + fi + case "${out}" in + *" dev ${oif} "*) + echo "${flow}" + return 0 + ;; + esac + done + + return 1 +} + +test_pmtu_ipvX_mp_asym_exceptions() { + family=${1} + + if [ ${family} -eq 4 ]; then + ping=ping + dst="${host4_b_addr}" + else + ping=${ping6} + dst="${host6_b_addr}" + fi + + setup namespaces routing multipath${family} || return $ksft_skip + + trace "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \ + "${ns_r1}" veth_R1-B "${ns_b}" veth_B-R1 \ + "${ns_a}" veth_A-R2 "${ns_r2}" veth_R2-A \ + "${ns_r2}" veth_R2-B "${ns_b}" veth_B-R2 + + if [ ${family} -eq 4 ]; then + # Routes back to the source addresses mp_flow_via() picks + run_cmd ${ns_r1} ip route add ${host4_a_net}.0/24 via ${prefix4}.${a_r1}.1 + run_cmd ${ns_r2} ip route add ${host4_a_net}.0/24 via ${prefix4}.${a_r2}.1 + else + ${ns_a} ip route get ${dst} ipproto 58 flowlabel 0x1 >/dev/null 2>&1 || { + err " ip route get flowlabel not supported"; return $ksft_skip; } + fi + + # Set up initial MTU values: 1400 behind R1, 1350 to R2, 1300 behind R2 + mtu "${ns_a}" veth_A-R1 2000 + mtu "${ns_r1}" veth_R1-A 2000 + mtu "${ns_r1}" veth_R1-B 1400 + mtu "${ns_b}" veth_B-R1 1400 + + mtu "${ns_a}" veth_A-R2 1350 + mtu "${ns_r2}" veth_R2-A 1350 + mtu "${ns_r2}" veth_R2-B 1300 + mtu "${ns_b}" veth_B-R2 1300 + + flow_r1="$(mp_flow_via ${family} ${dst} veth_A-R1)" || { + err " no flow through veth_A-R1 found"; return 1; } + flow_r2="$(mp_flow_via ${family} ${dst} veth_A-R2)" || { + err " no flow through veth_A-R2 found"; return 1; } + if [ ${family} -eq 4 ]; then + ping_r1="${ping} -I ${flow_r1}" + ping_r2="${ping} -I ${flow_r2}" + else + ping_r1="${ping} -I ${host6_a_addr} -F ${flow_r1}" + ping_r2="${ping} -I ${host6_a_addr} -F ${flow_r2}" + fi + + # A Packet Too Big from R1 is cached on the path via R1, not on the + # path via R2, whose link can't carry 1400 + run_cmd ${ns_a} ${ping_r1} -q -M want -i 0.1 -c 1 -s 1800 "${dst}" + + pmtu_a_R1="$(route_get_dst_pmtu_from_exception "${ns_a}" "${dst}" oif veth_A-R1)" + pmtu_a_R2="$(route_get_dst_pmtu_from_exception "${ns_a}" "${dst}" oif veth_A-R2)" + check_pmtu_value "1400" "${pmtu_a_R1}" "exceeding MTU via R1 (veth_A-R1)" || return 1 + check_pmtu_value "" "${pmtu_a_R2}" "exceeding MTU via R1 (veth_A-R2)" || return 1 + + # The lower MTU behind R2 lowers the PMTU of both paths + run_cmd ${ns_a} ${ping_r2} -q -M want -i 0.1 -c 1 -s 1300 "${dst}" + + pmtu_a_R1="$(route_get_dst_pmtu_from_exception "${ns_a}" "${dst}" oif veth_A-R1)" + pmtu_a_R2="$(route_get_dst_pmtu_from_exception "${ns_a}" "${dst}" oif veth_A-R2)" + check_pmtu_value "1300" "${pmtu_a_R1}" "exceeding MTU via R2 (veth_A-R1)" || return 1 + check_pmtu_value "1300" "${pmtu_a_R2}" "exceeding MTU via R2 (veth_A-R2)" || return 1 +} + +test_pmtu_ipv4_mp_asym_exceptions() { + test_pmtu_ipvX_mp_asym_exceptions 4 +} + +test_pmtu_ipv6_mp_asym_exceptions() { + test_pmtu_ipvX_mp_asym_exceptions 6 +} + +test_pmtu_ipv6_mp_exceptions() { + test_pmtu_ipvX_mp_exceptions 6 +} + usage() { echo echo "$0 [OPTIONS] [TEST]..." -- 2.56.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net-next v3 3/3] selftests: net: pmtu: Add IPv6 and asymmetric multipath tests 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 0 siblings, 0 replies; 7+ messages in thread From: netdev-bot+sashiko @ 2026-11-17 13:14 UTC (permalink / raw) To: deliran Cc: dsahern, idosch, davem, edumazet, kuba, pabeni, horms, shuah, netdev, linux-kernel, linux-kselftest Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 0 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). - [Medium] In tools/testing/selftests/net/pmtu.sh, the new IPv6 variants of setup_multipath_new() and setup_multipath_old() add host6_a_addr… -- selftests: net: pmtu: Add IPv6 and asymmetric multipath tests This commit makes pmtu_ipv4_mp_exceptions family agnostic and adds an IPv6 variant of it. It also adds IPv4 and IPv6 asymmetric multipath tests. These pick a flow through each router and check which paths get PMTU exceptions. > diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh > index c7cd271714ef7..2bd132991841a 100755 > --- a/tools/testing/selftests/net/pmtu.sh > +++ b/tools/testing/selftests/net/pmtu.sh [ ... ] > @@ -994,49 +1014,112 @@ setup_ovs_bridge() { > } > > setup_multipath_new() { > - # Set up host A with multipath routes to host B host4_b_addr > - run_cmd ${ns_a} ip addr add ${host4_a_addr} dev lo > - run_cmd ${ns_a} ip nexthop add id 401 via ${prefix4}.${a_r1}.2 dev veth_A-R1 > - run_cmd ${ns_a} ip nexthop add id 402 via ${prefix4}.${a_r2}.2 dev veth_A-R2 > - run_cmd ${ns_a} ip nexthop add id 403 group 401/402 > - run_cmd ${ns_a} ip route add ${host4_b_addr} src ${host4_a_addr} nhid 403 > + family=${1} > + > + if [ ${family} -eq 4 ]; then [ ... ] > + else > + host_a_addr=${host6_a_addr} > + host_b_addr=${host6_b_addr} [ ... ] > + fi > + > + # Set up host A with multipath routes to host B host_b_addr > + run_cmd ${ns_a} ip addr add ${host_a_addr} dev lo > + run_cmd ${ns_a} ip nexthop add id ${family}01 via ${nh_a_r1} dev veth_A-R1 > + run_cmd ${ns_a} ip nexthop add id ${family}02 via ${nh_a_r2} dev veth_A-R2 > + run_cmd ${ns_a} ip nexthop add id ${family}03 group ${family}01/${family}02 > + run_cmd ${ns_a} ip route add ${host_b_addr} src ${host_a_addr} nhid ${family}03 [Severity: Medium] With family 6, can this route add race against DAD on the lo address? host6_a_addr is added to lo without nodad, so ipv6_add_addr() marks it IFA_F_TENTATIVE. addrconf_dad_start() only queues dad_work. The flag is cleared later, once addrconf_dad_work() takes the rtnl lock and reaches the IFF_LOOPBACK shortcut in addrconf_dad_begin(). The next command uses that address as the prefsrc. In ip6_route_info_create_nh() the address is checked like this: if (!ipv6_chk_addr(net, &cfg->fc_prefsrc, dev, 0)) { NL_SET_ERR_MSG(extack, "Invalid source address"); err = -EINVAL; ipv6_chk_addr() bans IFA_F_TENTATIVE. If dad_work hasn't run yet, the route add fails with "Invalid source address". The same check covers the legacy nexthop route in setup_multipath_old(), and the host B routes in both helpers. The run_cmd return values are ignored. The status of setup_multipath() comes from the last router route add, so setup() still succeeds even when host A or B has no multipath route. Would that lead to spurious failures? Examples would be "no flow through veth_A-R2 found" in test_pmtu_ipvX_mp_asym_exceptions(), or a missing exception on veth_A-R2 in pmtu_ipv6_mp_exceptions. IPv4 has no DAD, so the IPv4-only version of these helpers didn't have this race. Would adding nodad to the IPv6 lo addresses, as other net selftests do, avoid it? [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113122237.88990-1-deliran%40verdict.gg ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-17 13:14 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox