From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=57.103.64.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796235964; b=lgy1V2n4Hhwr2d+OaiLAPmBehoRaUMfWu6WGZ7nnWQ/qIHK3XAvT+gF2wBxxE+Bo4iiR FF9bp6SGCe8/ngrU9I7lLYFo/sCEXdh0g+ilDB1x1oLWG/3agYIMdlG0A+B0xN5Cp3FCX YLgPfinWz31STdJDZX93AHGUinJKGk8H7icVTlW8A/ViP6xbpyRFdcDxylI7fec8SVPFE 2UJntYyxh/g0JAs2If64K/ecRJwoafHfzGMpJ4IuD33rSpmh3TjNWWxRrlRevNC+udDxG Ezty263ZjAEoTwPDBNUHYW8VaKdC3p+HQD1OzEhdx4+Nwmt0rHuhC9W47S/VkKHK5eQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796235964; h=DMARC-Filter:Received:X-ICL-RepId:Dkim-Signature: mail-alias-created-date:Received:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Proofpoint-Spam-Info: X-Proofpoint-Spam-Details-Enc:X-Authority-Info-Out:X-Proofpoint-GUID: X-Proofpoint-ORIG-GUID:X-JNJ; bh=c2o7qRIp3crLNSH436zVkF0wyJp3sPh3JksaOJOjtxc=; b=hVPg2WdfwMRLK+HHJ2s40vGskfBt0AXHV3x2kMFlTfrPQ4Hu+4WfbwCGUDqVTkEx18iy easaCcli30E2p871ccj8MB49+8GRRFfzGejopEvRYmiAX1TtikqMDvfeBdRyh/FUbQwe8 nFx7rWGtNacH0YoSPHTa3e/yb4j9fwbVlndd3nCmkP7HNWFUIc4P0/D7jxEgBG9SWsR5V YonysVYptxDyras1Y2aGyTjwyuVyAk8lGp7WHgi0NCFjSLGXBtOJ2dr/YJwalNRNssWII VXdMtxD8Vsa2XYm1WGQNfXkvLXKtUQu3kFZJEUx9Vg73BAGk5rygst7NEwap14zMVbw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=verdict.gg; spf=pass smtp.mailfrom=verdict.gg; dkim=pass header.d=verdict.gg header.i=@verdict.gg header.a=rsa-sha256 header.s=sig1 header.b=0NPkUGFY; arc=none smtp.remote-ip=57.103.64.44 Received: from outbound.pv.icloud.com (pv-2001e-snip4-1.eps.apple.com [57.103.64.44]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0612606A32F for ; Wed, 2 Dec 2026 18:26:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E0612606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=verdict.gg Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=verdict.gg Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=verdict.gg header.i=@verdict.gg header.a=rsa-sha256 header.s=sig1 header.b=0NPkUGFY Received: from outbound.pv.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-1a-60-percent-6 (Postfix) with ESMTPS id 560E018000FD; Wed, 02 Dec 2026 18:26:00 +0000 (UTC) X-ICL-RepId: 01a23801-9fb3-781f-a991-3d19f5681d0d Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verdict.gg; s=sig1; t=1796235963; x=1827771963; bh=c2o7qRIp3crLNSH436zVkF0wyJp3sPh3JksaOJOjtxc=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=0NPkUGFYqlctUDkcf+xYLykiJOVKCsG8RdhQdbkDGvA4c2tE/LhW7/t168Yz+ckKJIr58FlLLXUupM0S5nmHyfBkEQDCfi3KhSWiy3CP+SivzSl5bfpjxDH4O7V0NfbaCt7+1LIWTmjAF8hyxfo4gRu8Ksqhbf26VBfLXWQg9AsfEftqa1T0nWblhWcz/LBj/fIFd16woNQj1AjevU8rx8/YbVPrQd7mttezpneDhDoxLvC/yvZ+gaIr0ZfY1Pi6FR27ZQYDBEu5HZCYDJMsSQE6DEkaOJHIalqt1/7woATKRy7ahZ2F8rA9izklL7oJ61sgftoYFBu8n+oyYF7nUA== mail-alias-created-date: 1621344842221 Received: from DelNac.mail.msk (unknown [17.156.192.29]) by p00-icloudmta-asmtp-us-west-1a-60-percent-6 (Postfix) with ESMTPSA id 3151418000F9; Wed, 02 Dec 2026 18:25:57 +0000 (UTC) From: Vladimir Vdovin To: David Ahern , Ido Schimmel , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman , Shuah Khan Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, Vladimir Vdovin Subject: [PATCH net-next v5 1/2] ipv6: Cache pmtu for all paths of a multipath route Date: Wed, 2 Dec 2026 21:25:44 +0300 Message-ID: <20261202182545.19656-2-deliran@verdict.gg> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261202182545.19656-1-deliran@verdict.gg> References: <20261202182545.19656-1-deliran@verdict.gg> 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 X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAyMDA3MyBTYWx0ZWRfXxv85WMbOD73G nmi3YhC2efkrTEOq6fRTCg2w1JDB8RVDiTIkb8Q5wFIrNI3l0anY4JcNWvSoEBJh58l738syyvx mtLvxSh3z4bZZA0kWDyezzBxDvOmPO8= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAyMDA3MyBTYWx0ZWRfXwxzxBkNbQOBZ 4Dd8aot2bLeZrDdMc7IL4PfdAOCmJp0orcMsscBDi/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Xxuur0IxhhAuldbEc9R/mb6SUU27t0+wO6OGc D6UyKGjvxi7378MgzRyXwlEP0CylJU3IxiB+UCGTzfT66HKbB9QVpwXanpIxR4wQM0xcEp jWa5YRaPt90nyeE+KS6Y/FbBPT8uv6E4KRqYaMEitlp2+J7U43V/t974Uk3xxJiIv33b17 wfpRjBaW5PC4WpgxN8W7DSMFaf8zfjnkRqZz+YN5ub/RJsSuUTVoDt0LqWkJjUGxyz7nxS KyIAXA1gPKrSFaiS365MOgANGMcOln91JRvcvPKAA7n4RJMu0bVM8H+a32iFXpj79BeFYx L6Z9eGHT/yOb3CiOAfpyG0xuE5JGQTDFfbn4L3NOVRG/33TcojusfwDEW2rTXU7D87fqpx RLisy1wqBveuv6H+W26i8e5ZdgXaB5Bv1I2N/4OPirk6fLSsYWHMJi1IPreK2ld6Nxof7Z e5ZSA9OVxh5nZoFbbKginN8gbi4K++FI6WMF7So= When IPv6 receives a Packet Too Big, the route lookup can select a different nexthop from the one the original packet used. The lookup can be constrained by the incoming interface. For an unbound socket, the lookup can hash the flow without its protocol or ports. If the exception lands on the wrong path, the sender keeps using the old PMTU and oversized packets continue to be dropped. Update the PMTU on each path of the multipath route, as IPv4 does since commit 7d3f3b4367f3 ("net: ipv4: Cache pmtu for all packet paths if multipath enabled"). Compare the reported MTU with the MTU in use on each path. If it is lower, update the existing exception in place to preserve any gateway learned from a redirect, or create an exception if none exists. One Packet Too Big can thus create up to one exception per path. For legacy multipath routes, skip siblings that are no longer in the FIB. For routes that use nexthop objects, check for a blackhole as each nexthop is visited. A concurrent replacement can install a blackhole after the route lookup. Link: https://lore.kernel.org/netdev/ad29493c-9e48-4a94-b327-e47af3a9d137@kernel.org/ Signed-off-by: Vladimir Vdovin --- net/ipv6/route.c | 122 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 87 insertions(+), 35 deletions(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index df843178e5ec..cd3672287afe 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -2917,12 +2917,63 @@ 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; +}; + +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) { + /* Keep any gateway learned from a redirect. */ + 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; +} + +/* A concurrent replace can install a blackhole after the route lookup. + * Check the nh_info supplied by the iterator before caching an exception. + */ +static int rt6_nexthop_update_pmtu(struct fib6_nh *nh, void *_arg) +{ + if (container_of(nh, struct nh_info, fib6_nh)->reject_nh) + return 0; + + return rt6_nh_update_pmtu(nh, _arg); +} + 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. @@ -2945,6 +2996,7 @@ 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; @@ -2953,47 +3005,47 @@ static void __ip6_rt_update_pmtu(struct dst_entry *dst, const struct sock *sk, /* 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; + /* The PTB lookup can select a different path from the original flow. */ + if (!daddr) + return; - if (res.f6i->nh) { - struct fib6_nh_match_arg arg = { - .dev = dst_dev_rcu(dst), - .gw = &rt6->rt6i_gateway, - }; + rcu_read_lock(); + f6i = rcu_dereference(rt6->from); + /* A route on its way out of the tree takes no exceptions */ + if (!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; + if (f6i->nh) { + nexthop_for_each_fib6_nh(f6i->nh, rt6_nexthop_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(); + /* Stop when f6i leaves the sibling list, the walk would never end. + * Skip a sibling not in the tree, being added or removed. + */ + list_for_each_entry_rcu(sibling, &f6i->fib6_siblings, fib6_siblings) { + if (!READ_ONCE(f6i->fib6_nsiblings)) + break; + if (!rcu_access_pointer(sibling->fib6_node)) + continue; + 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); } +out: + rcu_read_unlock(); } static void ip6_rt_update_pmtu(struct dst_entry *dst, struct sock *sk, -- 2.56.0