1eccd0a80SVladimir Oltean#!/bin/bash 2eccd0a80SVladimir Oltean# SPDX-License-Identifier: GPL-2.0 3eccd0a80SVladimir Oltean 4eccd0a80SVladimir Oltean# Bridge FDB entries can be offloaded to DSA switches without holding the 5eccd0a80SVladimir Oltean# rtnl_mutex. Traditionally this mutex has conferred drivers implicit 6eccd0a80SVladimir Oltean# serialization, which means their code paths are not well tested in the 7eccd0a80SVladimir Oltean# presence of concurrency. 8eccd0a80SVladimir Oltean# This test creates a background task that stresses the FDB by adding and 9eccd0a80SVladimir Oltean# deleting an entry many times in a row without the rtnl_mutex held. 10eccd0a80SVladimir Oltean# It then tests the driver resistance to concurrency by calling .ndo_fdb_dump 11eccd0a80SVladimir Oltean# (with rtnl_mutex held) from a foreground task. 12eccd0a80SVladimir Oltean# Since either the FDB dump or the additions/removals can fail, but the 13eccd0a80SVladimir Oltean# additions and removals are performed in deferred as opposed to process 14eccd0a80SVladimir Oltean# context, we cannot simply check for user space error codes. 15eccd0a80SVladimir Oltean 16eccd0a80SVladimir OlteanWAIT_TIME=1 17eccd0a80SVladimir OlteanNUM_NETIFS=1 18eccd0a80SVladimir OlteanREQUIRE_JQ="no" 19eccd0a80SVladimir OlteanREQUIRE_MZ="no" 20eccd0a80SVladimir OlteanNETIF_CREATE="no" 21ae108c48SBenjamin Poirierlib_dir=$(dirname "$0") 22ae108c48SBenjamin Poiriersource "$lib_dir"/lib.sh 23eccd0a80SVladimir Oltean 24eccd0a80SVladimir Olteancleanup() { 25eccd0a80SVladimir Oltean echo "Cleaning up" 26eccd0a80SVladimir Oltean kill $pid && wait $pid &> /dev/null 27eccd0a80SVladimir Oltean ip link del br0 28eccd0a80SVladimir Oltean echo "Please check kernel log for errors" 29eccd0a80SVladimir Oltean} 30eccd0a80SVladimir Olteantrap 'cleanup' EXIT 31eccd0a80SVladimir Oltean 32eccd0a80SVladimir Olteaneth=${NETIFS[p1]} 33eccd0a80SVladimir Oltean 34*7f8d3fbeSPatrice Durouxip link del br0 2>&1 >/dev/null || : 35eccd0a80SVladimir Olteanip link add br0 type bridge && ip link set $eth master br0 36eccd0a80SVladimir Oltean 37eccd0a80SVladimir Oltean(while :; do 38eccd0a80SVladimir Oltean bridge fdb add 00:01:02:03:04:05 dev $eth master static 39eccd0a80SVladimir Oltean bridge fdb del 00:01:02:03:04:05 dev $eth master static 40eccd0a80SVladimir Olteandone) & 41eccd0a80SVladimir Olteanpid=$! 42eccd0a80SVladimir Oltean 43eccd0a80SVladimir Olteanfor i in $(seq 1 50); do 44eccd0a80SVladimir Oltean bridge fdb show > /dev/null 45eccd0a80SVladimir Oltean sleep 3 46eccd0a80SVladimir Oltean echo "$((${i} * 2))% complete..." 47eccd0a80SVladimir Olteandone 48