From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796263363; b=UCTsWMcyeBUlMgYZ0d10gxabccDa8ZaHGOjuIJHoW1uG6zRwDN/KKrLcsSRTg54e99+M 8bU7u9LRkihHjFOUwD+EKuq8vIJUne+SQQU2dpyNwwJcxhj78M8KDlpTsdgqzW/ta1jVo RFwzYmpu3ZlwDYoY7yngov4kfp1/6zJlBXoP7eL2w7kH2F/vVTjSzrjrHfnt3jrU7R5lM 5vw1AIakbL8XhzoFlWhdbJeIHubIyerSdqVCnjreMGq6+tgKWBMHFKmYZWK7/l6GAgcT2 GxA+C24OqfmAUH6sVI93NhnWY9Vuob3Q0vWLgKRsNW62Q5COyfUWwGOpLMUeamrhtKw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796263363; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=gr8djFaGAqr/Pkn38aWvPkralUavfK7/oyT7InQvOsc=; b=yWa7dmk2OsQwGgKak6VAinYZksPKfSoQKKr6of4HKculg1s3NWEPW7gfnyW5GxMT2VvX niqE5m0TRVeEX+eH8SYzbAb/FqoA49+faoopdzUr2axVUhDHYVizvIZ37k2zT2v47EMDS PrNZQMsafu8G+lPeOvxUbrupMTfbBaTj5qi33xqyDDZpbRlmEzjJk0I+LjZpoRaPcJp9R VjZNtqsRKzFnezpp2uaYqc+nDe6E2gLkqV8Li38KJGwUrTBbeeXEJi22qZ4/mB6iH+uuG eYNmZMfeZH75vg6WA56HfBf8lA4A+Vm2eqBzEdxgJyt776GCrT1vTR8dwYmQd75l0Zg== 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=DaKb+2Zt; arc=none smtp.remote-ip=100.103.45.18 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 06171606A322 for ; Thu, 3 Dec 2026 02:02:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DaKb+2Zt Received: by smtp.kernel.org (Postfix) with ESMTPSA id E99181F000C1; Thu, 3 Dec 2026 02:02:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796263362; bh=gr8djFaGAqr/Pkn38aWvPkralUavfK7/oyT7InQvOsc=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=DaKb+2ZtIHC75JAJqaAfIyaulMHP6/VwA3nBZ3C5lG3DzU5+3IbzeAMwZRMxqFNKV gdRAO0+Colh2mUmAIKn4kf8B5V/4Jw7b+S61ys/HeVUzFryEwB44YKSQ4CRSqPf81n Na33P7x4+3/hq4O9yi6DaH6kgFFJU46P4tSqt0bSKsVsdayIIvFUK53pSPnaBRvK74 oILDcaappL6qnK2azF0cSyCYnqGKuMdgx8Ju0JpfC667x3wlXirEdo3IsVzinCZ6o5 iLe6/O5ErQxLj6FFQ/X0xVhvbd7wbsu1rwWiQTcdPltzip8KNMQLfMSnhC+7nj72pf W8AusJoUS1hVw== Subject: Re: [PATCH net-next 2/2] selftests: Add stress test for dst_entries From: netdev-bot+sashiko@kernel.org To: dsahern@kernel.org Cc: netdev@vger.kernel.org, idosch@nvidia.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org, dahern@nvidia.com Date: Thu, 03 Dec 2026 02:02:41 +0000 Message-ID: <179626336146.3146.13691811000551069483@kernel.org> In-Reply-To: <20261202015529.7846-3-dsahern@kernel.org> References: <20261202015529.7846-3-dsahern@kernel.org> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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 Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 2 · Low: 5 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 IPv4 variant of dst_entries_stress() fails on a correct kernel. - [Medium] dst_entries_stress() says it creates "more PMTU exceptions than the exception tables allow". - [Low] In the dst_entries_stress() churn loop, on IPv4, `$IP route replace $pfx1 via $gw1 dev veth1` and `$IP route replace $pfx2 nhid… - [Low] The "dst entries do not grow with route churn" check in dst_entries_stress() compares after_churn with after_exc + slack, and… - [Low] dst_entries_stress() sets `local ncpus=$(nproc)`. - [Low] The dst_entries() helper comment says "DST_NOCOUNT dsts (pcpu routes) are not in it, but exceptions, clones and uncached dsts are"… - [Low] The commit "selftests: Add stress test for dst_entries" has no body beyond the Signed-off-by. -- selftests: Add stress test for dst_entries This adds ipv4_dst_entries_stress and ipv6_dst_entries_stress to fib_tests.sh. Each test creates PMTU exceptions through a forwarding namespace, churns routes and a nexthop object while pinning route lookups to several CPUs, and checks the dst_ops entry counter at each stage. Both tests are added to the default TESTS list. > diff --git a/tools/testing/selftests/net/fib_tests.sh b/tools/testing/selftests/net/fib_tests.sh > index d7ac3c727f704..d1686dff7a774 100755 > --- a/tools/testing/selftests/net/fib_tests.sh > +++ b/tools/testing/selftests/net/fib_tests.sh > @@ -14,7 +14,8 @@ TESTS="unregister down carrier nexthop suppress ipv6_notify ipv4_notify \ > ipv4_mpath_list ipv6_mpath_list ipv4_mpath_balance ipv6_mpath_balance \ > ipv4_mpath_balance_preferred ipv4_mpath_oif ipv4_mpath_oif_nh \ > ipv4_mpath_oif_vrf ipv6_mpath_oif ipv6_mpath_oif_nh ipv6_mpath_oif_vrf \ > - fib6_ra_to_static fib6_temp_addr_renewal" > + fib6_ra_to_static fib6_temp_addr_renewal \ > + ipv4_dst_entries_stress ipv6_dst_entries_stress" [Severity: Low] This isn't a bug, but the commit message has nothing beyond the Signed-off-by. Could it say: - what the test is meant to validate (for example the "ipv6: remove dst_ops gc handler" change) - what each log_test asserts - what DST_STRESS_EXC and DST_STRESS_ITERS control - why there is an IPv4 variant when the series changes no IPv4 code - that taskset is required It would also help to say that both tests join the default TESTS list. That means every default fib_tests.sh run now does thousands of ping and ip invocations. [ ... ] > +# Number of dst entries the netns' dst_ops accounts for. DST_NOCOUNT dsts > +# (pcpu routes) are not in it, but exceptions, clones and uncached dsts are. > +# The IPv4 counter belongs to the global ipv4_dst_ops, so it also sees other > +# netns. [Severity: Low] Is this description accurate for IPv4? It matches IPv6, but on IPv4 rt_dst_alloc() in net/ipv4/route.c never passes DST_NOCOUNT: rt = dst_alloc(&ipv4_dst_ops, dev, DST_OBSOLETE_FORCE_CHK, (noxfrm ? DST_NOXFRM : 0)); So IPv4 pcpu output dsts (nhc_pcpu_rth_output) are counted. An IPv4 exception (fnhe) has no dst unless a later lookup binds one. The IPv4 and IPv6 halves of the test therefore measure different sets of objects. The IPv4 slack=64 is justified only by "the counter is global", not by the counted pcpu dsts that the churn keeps alive. [ ... ] > +# Create more PMTU exceptions than the exception tables allow and churn the > +# routes while every cpu keeps building pcpu dsts. The dst count must stay > +# within the table limits, must not grow because of the churn, and must go > +# back to where it started once the routes and nexthops are gone. [ ... ] > + if [ "$family" = "6" ]; then > + ip6="-6" > + gw1=2001:db8:10::2 > + pfx1=2001:db8:12::/64 > + pfx2=2001:db8:13::/64 > + cap=$((2 * 1024 * 6)) # 2 fib6_nh * buckets * (depth + 1) [ ... ] > + cap=$((2 * 2048 * 6)) [Severity: Medium] Does the default run really create more exceptions than the tables allow? With DST_STRESS_EXC=1000 per route, each nexthop gets about 1000 exceptions. A fib6_nh has 1024 buckets (FIB6_EXCEPTION_BUCKET_SIZE_SHIFT 10) and an IPv4 nexthop has 2048 (FNHE_HASH_SHIFT 11), so that is about one entry per bucket. Eviction only starts once a bucket goes over a randomized depth, in rt6_insert_exception() in net/ipv6/route.c: max_depth = FIB6_MAX_DEPTH + get_random_u32_below(FIB6_MAX_DEPTH); while (bucket->depth > max_depth) rt6_exception_remove_oldest(bucket); update_or_create_fnhe() does the same thing using FNHE_RECLAIM_DEPTH. This means rt6_exception_remove_oldest() is almost never reached. The "within the exception table limits" check (about 2000 against a cap of 12288) cannot fail with the defaults. The cap formula also assumes a fixed 6 entries per bucket. Since max_depth ranges from 5 to 9, an IPv6 bucket can hold up to 9 entries. An IPv4 bucket can hold up to 10, because update_or_create_fnhe() trims before it inserts. If DST_STRESS_EXC is raised enough to fill the IPv6 tables, couldn't after_exc settle above base + 12288 and report a failure on a correct kernel? [ ... ] > + for ((i = 1; i <= exc; i++)); do > + if [ "$family" = "6" ]; then > + dst1=2001:db8:12::$(printf %x $i) > + dst2=2001:db8:13::$(printf %x $i) > + $NS_EXEC $ping6 -c1 -W1 -s1400 $dst1 &> /dev/null > + $NS_EXEC $ping6 -c1 -W1 -s1400 $dst2 &> /dev/null > + else > + dst1=10.20.$((i / 250)).$((i % 250 + 1)) > + dst2=10.30.$((i / 250)).$((i % 250 + 1)) > + $NS_EXEC ping -c1 -W1 -s1400 -M do $dst1 &> /dev/null > + $NS_EXEC ping -c1 -W1 -s1400 -M do $dst2 &> /dev/null > + fi > + done > + > + after_exc=$(dst_entries $family) > + [ $after_exc -gt $((base + exc / 2)) ] > + log_test $? 0 "PMTU exceptions created ($base -> $after_exc dst entries)" [Severity: Medium] Can this check pass on IPv4? Creating an IPv4 exception does not allocate a dst. update_or_create_fnhe() in net/ipv4/route.c only allocates a struct fib_nh_exception. It then marks nhc_rth_input and the nhc_pcpu_rth_output entries DST_OBSOLETE_KILL. An rtable is only bound to an fnhe by a later output lookup for the same daddr, in __mkroute_output(): prth = &fnhe->fnhe_rth_output; Each destination here gets a single ping -c1 -M do. The frag-needed error is handled once, through raw_err() or ping_err() and then ipv4_sk_update_pmtu(). For an unconnected socket, that path ends in __ipv4_sk_update_pmtu(): if (sock_owned_by_user(sk) || !odst) { __ipv4_sk_update_pmtu(skb, sk, mtu); goto out; } __ipv4_sk_update_pmtu() does its route lookup before __ip_rt_update_pmtu() creates the fnhe, and nothing looks up that daddr again. The next lookup on the same nexthop finds the killed pcpu route and allocates a replacement. rt_cache_route() then releases the old one, so the counter stays roughly flat. Since ipv4_dst_entries_stress is in the default TESTS list, won't fib_tests.sh report a failure here on a correct kernel? This assumes ping uses an unconnected socket, which iputils does since it uses sendto(). A connected socket would take the dst_check() path in ipv4_sk_update_pmtu() and look up the route again. [ ... ] > + # churn: every cpu builds pcpu dsts, then the routes and the nexthop > + # change, which invalidates them > + for ((i = 0; i < iters; i++)); do > + for ((cpu = 0; cpu < ncpus; cpu++)); do > + if [ "$family" = "6" ]; then > + taskset -a -c $cpu $IP -6 route get 2001:db8:12::1 &> /dev/null > + taskset -a -c $cpu $IP -6 route get 2001:db8:13::1 &> /dev/null > + else > + taskset -a -c $cpu $IP route get 10.20.0.1 &> /dev/null > + taskset -a -c $cpu $IP route get 10.30.0.1 &> /dev/null > + fi > + done [Severity: Low] ncpus comes from "local ncpus=$(nproc)". That is the number of CPUs in the affinity mask, not a range of CPU ids starting at 0. Suppose the allowed set isn't {0..n-1}, for example under a cpuset that excludes CPU 0, or with offline CPUs in the low range. Then taskset fails to set the affinity and the ip route get never runs. Both stderr and the exit status are thrown away here. Would the per-CPU pcpu dst building then be skipped silently while the test still reports a pass? > + $IP $ip6 route replace $pfx1 via $gw1 dev veth1 > + $IP $ip6 nexthop replace id 100 via $gw1 dev veth1 > + $IP $ip6 route replace $pfx2 nhid 100 > + done [Severity: Low] On IPv4, do the two route replace commands change anything? They resend the existing route exactly. fib_create_info() finds the identical fib_info through fib_find_info() and returns it. fib_table_insert() then matches it and exits early: if (fa_match) { if (fa == fa_match) err = 0; goto out; } No alias is replaced, and no fib_info or fib_nh is released. Only the nexthop replace has an effect. It still invalidates pfx1's cached dsts, because nh_rt_cache_flush() calls rt_cache_flush() when nexthop 100's fi_list is non-empty, and that bumps the genid. What the IPv4 run never covers is the fib_info and fib_nh release path for a replaced route. IPv6 does cover it through fib6_add_rt2node() and fib6_purge_rt(). For IPv4, the comment "then the routes and the nexthop change" is only half true. > + > + # let the deferred releases run > + sleep 2 > + after_churn=$(dst_entries $family) > + [ $after_churn -le $((after_exc + slack)) ] > + log_test $? 0 "dst entries do not grow with route churn ($after_exc -> $after_churn)" [Severity: Low] On IPv6, after_exc includes about 2 * exc exception dsts. In the first churn iteration, ip -6 route replace runs fib6_purge_rt() on the old fib6_info: fib6_drop_pcpu_from(rt); rt6_flush_exceptions(rt); The nexthop replace also frees the old nh_info. fib6_nh_release()->fib6_nh_release_dsts() then calls fib6_nh_flush_exceptions(). Together these drop the counter back to about base. Doesn't that let this check pass even with a churn-induced leak of up to after_exc - base dsts, about 2000 with the defaults? Also, the pcpu dsts the churn builds come from ip6_rt_pcpu_alloc(): pcpu_rt = ip6_dst_alloc(dev_net(dev), dev, flags | DST_NOCOUNT); so /proc/net/rt6_stats never counts them, and a leak of IPv6 pcpu dsts would not show up here. The later base + slack check still catches counted leaks that outlive the route deletion. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202015529.7846-1-dsahern%40kernel.org