ap: keep AP beaconing across USB re-enumeration

Starlink's USB ethernet shares a hub with the rtw89 Wi-Fi adapter; when Starlink
flaps, the hub re-enumerates and tears the radio down, so hostapd loses its
interface and exits. Two stock defaults left the AP dark: Restart=on-failure
misses clean exits, and the 5-in-10s start limit makes systemd give up during a
re-enumeration storm.

- hostapd-restart.conf drop-in: Restart=always, RestartSec=5, StartLimitIntervalSec=0
  so hostapd retries forever until the interface returns (verified: SIGKILL -> back
  to state=ENABLED in ~7s).
- van-ap-watchdog daemon: backstop for the case systemd can't see (hostapd running
  but radio wedged). Polls hostapd_cli status; restarts hostapd if the iface is
  present but not ENABLED, waits it out if the iface is mid-re-enumeration.
- hostapd.conf: add ctrl_interface so the watchdog can read the real AP state.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Andreas Wrede
2026-07-01 14:36:14 -04:00
co-authored by Claude Opus 4.8
parent 830ef52641
commit 877fa14d0c
6 changed files with 164 additions and 2 deletions
+20
View File
@@ -0,0 +1,20 @@
# Drop-in: /etc/systemd/system/hostapd.service.d/restart.conf
#
# The AP wlan (rtw89, USB) shares a USB hub with the Starlink ethernet (r8152, USB).
# When Starlink flaps, the hub re-enumerates and the Wi-Fi radio is torn down with it:
# hostapd's interface vanishes ("No such device") and it exits. Two stock defaults then
# leave the AP dark until someone intervenes — this drop-in closes both:
#
# 1. Restart=on-failure ignores a *clean* exit, but hostapd exits 0 in some of these
# cases. Restart=always covers every exit.
# 2. The default start limit (5 starts / 10s) is exhausted by a re-enumeration storm,
# after which systemd gives up permanently. StartLimitIntervalSec=0 disables the
# limit so hostapd keeps retrying until the interface comes back.
[Unit]
StartLimitIntervalSec=0
[Service]
Restart=always
# A few seconds' backoff so the USB device has a chance to re-enumerate before we retry
# (retrying instantly just fails on "No such device" and spins).
RestartSec=5