Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / testing / selftests / drivers / net / dsa / test_bridge_fdb_stress.sh
blob74682151d04dd673cbaab93baffd1a8bf6bc2e42
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # Bridge FDB entries can be offloaded to DSA switches without holding the
5 # rtnl_mutex. Traditionally this mutex has conferred drivers implicit
6 # serialization, which means their code paths are not well tested in the
7 # presence of concurrency.
8 # This test creates a background task that stresses the FDB by adding and
9 # deleting an entry many times in a row without the rtnl_mutex held.
10 # It then tests the driver resistance to concurrency by calling .ndo_fdb_dump
11 # (with rtnl_mutex held) from a foreground task.
12 # Since either the FDB dump or the additions/removals can fail, but the
13 # additions and removals are performed in deferred as opposed to process
14 # context, we cannot simply check for user space error codes.
16 WAIT_TIME=1
17 NUM_NETIFS=1
18 REQUIRE_JQ="no"
19 REQUIRE_MZ="no"
20 NETIF_CREATE="no"
21 lib_dir=$(dirname "$0")
22 source "$lib_dir"/../../../net/forwarding/lib.sh
24 cleanup() {
25 echo "Cleaning up"
26 kill $pid && wait $pid &> /dev/null
27 ip link del br0
28 echo "Please check kernel log for errors"
30 trap 'cleanup' EXIT
32 eth=${NETIFS[p1]}
34 ip link del br0 2>&1 >/dev/null || :
35 ip link add br0 type bridge && ip link set $eth master br0
37 (while :; do
38 bridge fdb add 00:01:02:03:04:05 dev $eth master static
39 bridge fdb del 00:01:02:03:04:05 dev $eth master static
40 done) &
41 pid=$!
43 for i in $(seq 1 50); do
44 bridge fdb show > /dev/null
45 sleep 3
46 echo "$((${i} * 2))% complete..."
47 done