#!/bin/sh
# DF-0589 run: load netgraph7 modules + run the race PoC
# Run as root on the DragonFly guest.
# Note: this pty-based PoC exercises the FORCE_WRITER-protected paths.
# The actual race (siopoll → l_start → ng_h4_start vs IF_DRAIN) requires
# a real sio serial port, which conflicts with the console on this guest.

# Load modules
kldload /usr/src/sys/netgraph7/netgraph/netgraph.ko 2>/dev/null || true
kldload /usr/src/sys/netgraph7/socket/ng_socket.ko 2>/dev/null || true
kldload /usr/src/sys/netgraph7/bluetooth/drivers/h4/ng_h4.ko 2>/dev/null || true
echo "=== loaded modules ==="
kldstat | grep -E "netgraph|ng_"

# Run the PoC for 30 seconds
echo "=== running race PoC (30s) ==="
timeout 45 /tmp/race 30
echo "RACE_EXIT=$?"
echo "=== check for panic ==="
dmesg | tail -5
