fix: sweep stale bypass routes at service startup #108
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/bypass-route-residue"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
systemctl restart aqomuiSIGTERMs openvpn and the python tunnel threads together; the route teardown that runs after openvpn's EOF loses that race. The table-11/main-table host-route pins and the table-11 default could survive the restart — state parked in table 11 outliving the process that put it there, the #66 failure shape again (#78).Fix
Of the two shapes the issue offers, the startup sweep: it also covers SIGKILL and crashes, and a python SIGTERM handler under the C mainloop has signal-delivery problems of its own (the service resets SIGINT to SIG_DFL for exactly that reason).
proto 111as an ownership tag. Table 11 is ours and flushes wholesale, but the main-table pin can't be found any other way after a restart — the server IP is gone with the process; the proto tag is the kernel-side handle on exactly our entries.bypass.flush_stale_routes()in startup's clean-slate block (next tokillall openvpnand the TEMPDIR sweep): flushestable 11andtable main proto 111on both stacks, tolerating the flush-of-a-nonexistent-table error, then clears leftover fwmark rules — marked traffic from a still-populated bypass cgroup must not consult whatever lands in table 11 next.create_cgroupreinstalls the table-11 default and rules when the bypass comes back up.Verification
Two new tests: exact flush sequence across both stacks + rules clear; a failing table-11 flush (table absent since boot) doesn't stop the sweep. Verified
ip route flush table main proto 111selector syntax live; current live table 11 holds only the active bypass default, which the startup-ordering argument covers. Full suite: 187 passed.Closes #78
🤖 Generated with Claude Code