-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
selftests: net: dsa: add a stress test for unlocked FDB operations
This test is a bit strange in that it is perhaps more manual than others: it does not transmit a clear OK/FAIL verdict, because user space does not have synchronous feedback from the kernel. If a hardware access fails, it is in deferred context. Nonetheless, on sja1105 I have used it successfully to find and solve a concurrency issue, so it can be used as a starting point for other driver maintainers too. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Vladimir Oltean
authored and
David S. Miller
committed
Oct 25, 2021
1 parent
d70b51f
commit eccd0a8
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
tools/testing/selftests/drivers/net/dsa/test_bridge_fdb_stress.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
# Bridge FDB entries can be offloaded to DSA switches without holding the | ||
# rtnl_mutex. Traditionally this mutex has conferred drivers implicit | ||
# serialization, which means their code paths are not well tested in the | ||
# presence of concurrency. | ||
# This test creates a background task that stresses the FDB by adding and | ||
# deleting an entry many times in a row without the rtnl_mutex held. | ||
# It then tests the driver resistance to concurrency by calling .ndo_fdb_dump | ||
# (with rtnl_mutex held) from a foreground task. | ||
# Since either the FDB dump or the additions/removals can fail, but the | ||
# additions and removals are performed in deferred as opposed to process | ||
# context, we cannot simply check for user space error codes. | ||
|
||
WAIT_TIME=1 | ||
NUM_NETIFS=1 | ||
REQUIRE_JQ="no" | ||
REQUIRE_MZ="no" | ||
NETIF_CREATE="no" | ||
lib_dir=$(dirname $0)/../../../net/forwarding | ||
source $lib_dir/lib.sh | ||
|
||
cleanup() { | ||
echo "Cleaning up" | ||
kill $pid && wait $pid &> /dev/null | ||
ip link del br0 | ||
echo "Please check kernel log for errors" | ||
} | ||
trap 'cleanup' EXIT | ||
|
||
eth=${NETIFS[p1]} | ||
|
||
ip link del br0 2&>1 >/dev/null || : | ||
ip link add br0 type bridge && ip link set $eth master br0 | ||
|
||
(while :; do | ||
bridge fdb add 00:01:02:03:04:05 dev $eth master static | ||
bridge fdb del 00:01:02:03:04:05 dev $eth master static | ||
done) & | ||
pid=$! | ||
|
||
for i in $(seq 1 50); do | ||
bridge fdb show > /dev/null | ||
sleep 3 | ||
echo "$((${i} * 2))% complete..." | ||
done |