Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/bash
0002 # SPDX-License-Identifier: GPL-2.0
0003 
0004 # Bridge FDB entries can be offloaded to DSA switches without holding the
0005 # rtnl_mutex. Traditionally this mutex has conferred drivers implicit
0006 # serialization, which means their code paths are not well tested in the
0007 # presence of concurrency.
0008 # This test creates a background task that stresses the FDB by adding and
0009 # deleting an entry many times in a row without the rtnl_mutex held.
0010 # It then tests the driver resistance to concurrency by calling .ndo_fdb_dump
0011 # (with rtnl_mutex held) from a foreground task.
0012 # Since either the FDB dump or the additions/removals can fail, but the
0013 # additions and removals are performed in deferred as opposed to process
0014 # context, we cannot simply check for user space error codes.
0015 
0016 WAIT_TIME=1
0017 NUM_NETIFS=1
0018 REQUIRE_JQ="no"
0019 REQUIRE_MZ="no"
0020 NETIF_CREATE="no"
0021 lib_dir=$(dirname $0)/../../../net/forwarding
0022 source $lib_dir/lib.sh
0023 
0024 cleanup() {
0025         echo "Cleaning up"
0026         kill $pid && wait $pid &> /dev/null
0027         ip link del br0
0028         echo "Please check kernel log for errors"
0029 }
0030 trap 'cleanup' EXIT
0031 
0032 eth=${NETIFS[p1]}
0033 
0034 ip link del br0 2&>1 >/dev/null || :
0035 ip link add br0 type bridge && ip link set $eth master br0
0036 
0037 (while :; do
0038         bridge fdb add 00:01:02:03:04:05 dev $eth master static
0039         bridge fdb del 00:01:02:03:04:05 dev $eth master static
0040 done) &
0041 pid=$!
0042 
0043 for i in $(seq 1 50); do
0044         bridge fdb show > /dev/null
0045         sleep 3
0046         echo "$((${i} * 2))% complete..."
0047 done