#!/bin/sh
# DF-0605 shell-based race driver (run as root).
# Tight DIOCIGETIFACES loop (via pfctl) + concurrent vlan create/destroy.

# Walker: hammer pfctl -i all -v (which issues DIOCIGETIFACES).
( while :; do
    pfctl -i all -v > /dev/null 2>&1
  done ) &
WP=$!

# Mutator: create + destroy vlans in tight loop.
( while :; do
    i=0
    while [ $i -lt 32 ]; do
      ifconfig vlan$i create > /dev/null 2>&1
      i=$((i+1))
    done
    i=0
    while [ $i -lt 32 ]; do
      ifconfig vlan$i destroy > /dev/null 2>&1
      i=$((i+1))
    done
  done ) &
MP=$!

echo "race.sh: walker=$WP mutator=$MP running for ${1:-60}s..."
sleep "${1:-60}"
kill -9 $WP $MP 2>/dev/null
echo "race.sh: done"
