Article View: linux.kernel.netdev
Article #25557[PATCH net-next 2/2] selftests: Add stress test for dst_entries
From: David Ahern
Date: Wed, 02 Dec 2026 01:55
Date: Wed, 02 Dec 2026 01:55
213 lines
14640 bytes
14640 bytes
From: David Ahern <dahern@nvidia.com>
Signed-off-by: David Ahern <dahern@nvidia.com>
---
tools/testing/selftests/net/fib_tests.sh | 178 ++++++++++++++++++++++-
1 file changed, 177 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/fib_tests.sh b/tools/testing/selftests/net/fib_tests.sh
index d7ac3c727f70..d1686dff7a77 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"
VERBOSE=0
PAUSE_ON_FAIL=no
@@ -3228,6 +3229,179 @@ ipv6_mpath_oif_vrf_test()
cleanup
}
+# 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.
+dst_entries()
+{
+ local family=$1 hex
+
+ if [ "$family" = "6" ]; then
+ hex=$($NS_EXEC awk '{print $6}' /proc/net/rt6_stats)
+ else
+ hex=$($NS_EXEC awk 'NR == 2 {print $1}' /proc/net/stat/rt_cache)
+ fi
+
+ echo $((16#$hex))
+}
+
+# wait up to $3 seconds for the dst entry count to drop to $2 or below
+wait_dst_entries_le()
+{
+ local family=$1
+ local limit=$2
+ local secs=$3
+ local i
+
+ for ((i = 0; i < secs * 10; i++)); do
+ [ $(dst_entries $family) -le $limit ] && return 0
+ sleep 0.1
+ done
+
+ return 1
+}
+
+# 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.
+#
+# DST_STRESS_EXC is the number of destinations to send a too big packet to
+# per route, DST_STRESS_ITERS the number of churn iterations.
+dst_entries_stress()
+{
+ local family=$1
+ local exc=${DST_STRESS_EXC:-1000}
+ local iters=${DST_STRESS_ITERS:-200}
+ local ncpus=$(nproc)
+ local base after_exc after_churn cap slack i cpu dst1 dst2 ip6=""
+ local gw1 pfx1 pfx2
+
+ [ $ncpus -gt 4 ] && ncpus=4
+
+ if [ ! -x "$(command -v taskset)" ]; then
+ echo "SKIP: taskset not installed"
+ return $ksft_skip
+ fi
+
+ setup
+
+ set -e
+ setup_ns ns2
+ $IP link add veth1 type veth peer name veth2 netns $ns2
+ $IP link set veth1 up
+ ip -netns $ns2 link set veth2 up
+ ip -netns $ns2 link add dummy0 type dummy
+ ip -netns $ns2 link set dummy0 mtu 1280 up
+ # the too big messages must not be rate limited
+ ip netns exec $ns2 sysctl -qw net.ipv4.ip_forward=1
+ ip netns exec $ns2 sysctl -qw net.ipv4.icmp_ratelimit=0
+ ip netns exec $ns2 sysctl -qw net.ipv4.icmp_msgs_per_sec=100000
+ ip netns exec $ns2 sysctl -qw net.ipv4.icmp_msgs_burst=100000
+ ip netns exec $ns2 sysctl -qw net.ipv6.conf.all.forwarding=1
+ ip netns exec $ns2 sysctl -qw net.ipv6.icmp.ratelimit=0
+
+ 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)
+ slack=16
+ $IP -6 address add 2001:db8:10::1/64 dev veth1 nodad
+ ip -netns $ns2 -6 address add 2001:db8:10::2/64 dev veth2 nodad
+ ip -netns $ns2 -6 route add $pfx1 dev dummy0
+ ip -netns $ns2 -6 route add $pfx2 dev dummy0
+ else
+ gw1=10.10.0.2
+ pfx1=10.20.0.0/16
+ pfx2=10.30.0.0/16
+ cap=$((2 * 2048 * 6))
+ slack=64 # the counter is global
+ $IP address add 10.10.0.1/24 dev veth1
+ ip -netns $ns2 address add 10.10.0.2/24 dev veth2
+ ip -netns $ns2 route add $pfx1 dev dummy0
+ ip -netns $ns2 route add $pfx2 dev dummy0
+ fi
+
+ # one route with its own nexthop, one using a nexthop object
+ $IP $ip6 nexthop add id 100 via $gw1 dev veth1
+ $IP $ip6 route add $pfx1 via $gw1 dev veth1
+ $IP $ip6 route add $pfx2 nhid 100
+ set +e
+
+ base=$(dst_entries $family)
+
+ 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)"
+
+ [ $after_exc -le $((base + cap)) ]
+ log_test $? 0 "dst entries within the exception table limits ($after_exc <= $((base + cap)))"
+
+ # 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
+ $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
+
+ # 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)"
+
+ $IP $ip6 route del $pfx1
+ $IP $ip6 route del $pfx2
+ $IP $ip6 nexthop del id 100
+ wait_dst_entries_le $family $((base + slack)) 10
+ log_test $? 0 "dst entries released with routes and nexthop (base $base, now $(dst_entries $family))"
+
+ cleanup
+}
+
+ipv4_dst_entries_stress_test()
+{
+ echo
+ echo "IPv4 dst entries stress test"
+
+ dst_entries_stress 4
+}
+
+ipv6_dst_entries_stress_test()
+{
+ echo
+ echo "IPv6 dst entries stress test"
+
+ dst_entries_stress 6
+}
+
################################################################################
# usage
@@ -3322,6 +3496,8 @@ do
ipv6_mpath_oif_vrf) ipv6_mpath_oif_vrf_test;;
fib6_ra_to_static) fib6_ra_to_static;;
fib6_temp_addr_renewal) fib6_temp_addr_renewal;;
+ ipv4_dst_entries_stress) ipv4_dst_entries_stress_test;;
+ ipv6_dst_entries_stress) ipv6_dst_entries_stress_test;;
help) echo "Test names: $TESTS"; exit 0;;
esac
--
2.54.0 (Apple Git-157)
Technical Details
Message-ID:
<20261202015529.7846-3-dsahern@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!feed-us-ny.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375481-linux-kernel-netdev=dewy.ruReferences:
<20261202015529.7846-1-dsahern@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!feed-us-ny.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375481-linux-kernel-netdev=dewy.ru From: dsahern@kernel.org (David Ahern) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next 2/2] selftests: Add stress test for dst_entries Date: Tue, 1 Dec 2026 18:55:23 -0700 Organization: Usenet Network Message-ID: <20261202015529.7846-3-dsahern@kernel.org> References: <20261202015529.7846-1-dsahern@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1864191"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Ut4QBDJgXSW7rVwmvu3Z3573b34= sha256:96+BYtKxNWJV/mAdQDMWJN5mbQQWEkjGf+TK9EGU2FE= sha1:nS3tALCk717ArB3Sp1UroLooT7Y= sha256:JpIHJVx5klEqKUL9nSu/7XoUi1l54pB5ZvQnlkRbeO4= 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 D5D2A117518; Wed, 2 Dec 2026 04:55:52 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-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 8MLnHlUZDAKT; Wed, 2 Dec 2026 04:55:50 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-375481-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id CC72111751A; Wed, 2 Dec 2026 04:55:41 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id CD2B027756; Wed, 2 Dec 2026 01:55:39 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796176539; b=IEEZRbfZkpb9b6bIl/lIWvZe0kNN00MKK3IVpIB+nP2NF2Df1F6+rfWJysONXc9INho6 h6mNOtjz69auxlYan4fsvu6s9gpBcsfMhRcm7pjiLoblOnmSXZn3rrjyy5iNXhIWgs8L6 HeggKvS6Kdb2VgbzTqIhKSEpAgz4smJJhG0ZA6sgLw1FHfmsB4BbJrqAOGKEoU7mDaNg+ W79mp6qq+QLUuAQVLBXZsGyYLvFAE7Kz1mn84oTj2w1WH7xq1dfxt991lAza9jnF6haPI 5tmjzCeQA4cFFeiWn3vOD43AvZZQ/8/O1eSVw7HJNERGlsKw58FzBlAhj/AHkPj8vPA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796176539; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List: List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe: List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding; bh=i1BkfU/yMQNWkvwH0ZwzERApvQWrYRiARr123Nagp28=; b=tuuDocYnuPe5cab33jbOLKPBwXIPz/9JgmoJyyiQCKQr1YDKFysp0R7ZaCLzbu2lE2Se 42QR4jrewBR1xwyahKPOAGyza6RcIXHKkIvlNfbKXNzx8BowYTMVR0fXdmVOxuqKke8Pn FUTphtakTmIKjrpCuPCAKQOFpPkHM4zUVEKIo8XKbGDT2lrwHe+HNum08h7AM64APgNnM 0ieAyDN+TyjTH2cv8CT5kpeg0VEn3+Cp3CMxytL+RX3aA8SyrCB6/kwiiOZPL3WR6wpeO cNItQW+WNfXJtZk6jZOzccoggb172Fq2CkLfQ3yUybRIIQ/aWlFIaJTw+TxpfRENPyw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=LO8w1dY6; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A6019606A327; Wed, 2 Dec 2026 01:55:39 +0000 (UTC) X-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=LO8w1dY6 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796176533; b=gDvIgH+0BXTv5QW44vKrFFwkQ6QsHsCV8mg8OQly0PhdJyXEHH0popdtZAkurJ/XvJu8 WbsRUYXHVx1TSrGvDALasNsqw4T4b1jUyiSD5JVhOWIONM0sk138WlOluLm5p8EyGezs5 YWPHozpS3VHhzhFDrnq/67RKWCsZsHNnnvfznA52bhaYeAHToRY9KUqynLOSl9zSvkA7N 7JL092fKEBDK/m6kLLIOaD3TXMaOShdHshfKA/92HXhiX4VHBQcVefOlD5d/WUg07OHRR XBMA0bgYF5BcsYXCnCTeUx7Vpd34WOTcPx8HsoEfZCUStkJXdJcNYRtBt+1PoAaYuig== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796176533; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=i1BkfU/yMQNWkvwH0ZwzERApvQWrYRiARr123Nagp28=; b=WUd0bKf9AzXEtAAysUjEQdSpZ4Aku/G+72g/4Gf5cKfiuw61XBD12IPZ9hhEUAUYZW7H xdoY7YXvjJ9aezkVg6WANTtHlwUEcBnpWeM39P1jFeYHY8RA3vFhRVmR2wpq050EsehHz fA6EdjHdOSUEPeZlYK+uhhyLGPJiEkOuJ2TXTCl+TPsaEXNFMbrIgB2oYIXft/dvdOqmM TrFT2kyV3O0C98BJHPk9Y8cevXm9E08JoF2TQT64bhAvFyAwteHBtyt40t/hAT5D5rF48 JFow+m5JgBbTXHgJ9gqUYUNpSjn+2STATHDmlO1iJxnZrxqJ21cxfb/Pv7OtZyQJExw== X-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=LO8w1dY6; arc=none smtp.remote-ip=100.103.45.18 X-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 C3922606A330 for <netdev@vger.kernel.org>; Wed, 2 Dec 2026 01:55:33 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F1741F00893; Wed, 2 Dec 2026 01:55:33 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796176533; bh=i1BkfU/yMQNWkvwH0ZwzERApvQWrYRiARr123Nagp28=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LO8w1dY6BXPipR0c4UqrLCRMLsBrv+S019rC33tIiIyxQ4ovdqM6Irxwr47SSSacu V8GVaGx6+GvWS66HqKQycjRDU0tWf/gEswEuCfsJySDj2oL4ckkRHK2KqXDyTR6hjq xtRJiZZIcITxPO7KbiEwsx76shOW5A3HbUREm+2flPydDBlApyg82Puj8YxpxRKJEZ mPBMIlNo5zjZp/PARHWwRGF81uTeQLrII2DMi8Fcmx8HA2xe1mTn6+QwMsZ+YG/DZL 0Dj1jr9tdxZW+pPvQSo9qvDzm7oUnnRhZorF8NRNL+Yy8vXQsU6tyYfEnwFkf4Wqyh xaqvwwGUQQcDw== X-Cc: dsahern@kernel.org, idosch@nvidia.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org, David Ahern <dahern@nvidia.com> X-Mailer: git-send-email 2.54.0 X-In-Reply-To: <20261202015529.7846-1-dsahern@kernel.org> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list