Repository navigation
Conversation
…on AP stop Rebased against main's restructuring. hostapd/dnsmasq already got an equivalent PIPE fix upstream independently, so this now only covers the two daemons that didn't: OpenOCD (debug_controller.py) and mosquitto (mqtt_controller.py), both still spawned with stdout=subprocess.PIPE with nothing ever draining it, which blocks the daemon in write() once ~64KB of output accumulates. Also still missing upstream: ap_stop() never tore down the NAT bridge rules _enable_nat() adds for ap_start(internet=True), so one internet-bridged AP session left the bridge in place for every AP started afterward. _disable_nat() now runs in ap_stop() and in ap_start(internet=False), and the MASQUERADE rule is scoped to the AP subnet. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
cjolly
force-pushed
the
fix/daemon-pipe-deadlock-nat-teardown
branch
from
August 27, 2026 00:15
b469a97 to
66b2f13
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Last one from this round of digging (same disclosure as #19/#20: Claude
helped track these down and write the fixes). Two independent issues found
in the same investigation — bundled here since they came from one review
pass, happy to split if you'd rather review them separately.
1. Undrained
stdout=PIPEdeadlocks daemonshostapd,dnsmasq,mosquitto, and OpenOCD were all spawned withstdout=subprocess.PIPE, and nothing ever read that pipe. Once ~64KB of logoutput accumulated (a few hours of
dnsmasq'slog-dhcpchatter, in thecase that surfaced this), the daemon blocked mid-
write()and silentlystopped doing its job — DHCP stopped answering, so AP clients associated at
the kernel level but never got a lease. From the outside this looked like a
hung DUT (
STA connect failed or timed out), whilepsshowed hostapd anddnsmasq both alive and well. It only shows up after hours of runtime, so
it's easy to miss in a quick manual test.
2. NAT rules from
ap_start(internet=True)were never torn downap_stop()had no corresponding call to remove the MASQUERADE/FORWARD rules_enable_nat()added, so one internet-bridged AP session left the bridge inplace for every AP started afterward — silently breaking the network
isolation a "plain" (non-internet) test AP is supposed to guarantee.
Fix
Long-running daemon spawns now log to a file in their work dir instead of an
unread pipe (can't block, and the log survives for post-mortem). A new
_disable_nat()is called both whenap_start(internet=False)runs after aprior internet-bridged session, and unconditionally in
ap_stop().Note for reviewers: an earlier version of this fix also scoped
mqtt_controller'spkill -f mosquittoto avoid killing unrelated brokerson the box — that fix has since landed independently on
main(with a_port_owner()conflict check added too), so this PR only carries thestill-missing PIPE fix for mosquitto's own stdout, not the pkill change.
Test plan
log-dhcpenabled, confirmDHCP keeps answering (no wedge)
ap_start(internet=True)→ap_stop()→ap_start(internet=False),confirm the second AP's clients have no route to
eth0/LANiptables -t nat -L/-L FORWARDshow no leftover rulesafter
ap_stop()/tmp/openocd.log(or$OPENOCD_LOG) captures output and the daemon doesn't wedge on along GDB session