DF-3311 / raceB2.sh
#!/bin/sh # DF-3310 hot race with live detection: # - churn port changes (errors visible) # - concurrently probe so_lock EXCLUSIVE path via SIOCSWG-cookie # (wg_socket_set_cookie takes so_lock LK_EXCLUSIVE); a timeout there # proves the lock corruption wedged an exclusive acquirer. ITERS=${1:-400} PINGS=${2:-2} LOG=/tmp/wgpoc/raceB2_churn.log : > $LOG p=0 while [ $p -lt $PINGS ]; do ping -f 10.7.0.2 >/dev/null 2>&1 & p=$((p+1)) done ( i=0 while [ $i -lt $ITERS ]; do p=$((30000 + (($$ + i * 7919) % 19990))) [ "$p" = "40001" ] && p=40005 [ "$p" = "40002" ] && p=40006 if ! ./wgtool setport wg0 $p >>$LOG 2>>$LOG; then echo "FAIL_ITER_$i" >> $LOG fi i=$((i+1)) done echo CHURN_DONE >> $LOG ) & n=0 while [ ! -f /tmp/wgpoc/raceB2.stop ]; do if ! timeout 3 ./wgtool cookie wg0 $n >/dev/null 2>&1; then rc=$? echo "COOKIE_PROBE_TIMEOUT rc=$rc iter=$n $(date)" >> $LOG echo "WEDGE_DETECTED" pkill -f 'wgtool setport' exit 9 fi if grep -q CHURN_DONE $LOG 2>/dev/null; then break fi n=$((n+1)) done pkill ping 2>/dev/null echo RACE_B2_CLEAN port_probes=$n |