48 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03 4# Bridge FDB entries can be offloaded to DSA switches without holding the5# rtnl_mutex. Traditionally this mutex has conferred drivers implicit6# serialization, which means their code paths are not well tested in the7# presence of concurrency.8# This test creates a background task that stresses the FDB by adding and9# 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_dump11# (with rtnl_mutex held) from a foreground task.12# Since either the FDB dump or the additions/removals can fail, but the13# additions and removals are performed in deferred as opposed to process14# context, we cannot simply check for user space error codes.15 16WAIT_TIME=117NUM_NETIFS=118REQUIRE_JQ="no"19REQUIRE_MZ="no"20NETIF_CREATE="no"21lib_dir=$(dirname "$0")22source "$lib_dir"/../../../net/forwarding/lib.sh23 24cleanup() {25 echo "Cleaning up"26 kill $pid && wait $pid &> /dev/null27 ip link del br028 echo "Please check kernel log for errors"29}30trap 'cleanup' EXIT31 32eth=${NETIFS[p1]}33 34ip link del br0 2>&1 >/dev/null || :35ip link add br0 type bridge && ip link set $eth master br036 37(while :; do38 bridge fdb add 00:01:02:03:04:05 dev $eth master static39 bridge fdb del 00:01:02:03:04:05 dev $eth master static40done) &41pid=$!42 43for i in $(seq 1 50); do44 bridge fdb show > /dev/null45 sleep 346 echo "$((${i} * 2))% complete..."47done48