cyclone: fail over to cellular based on WAN reachability #1363

Merged
JakeHillion merged 1 commits from jj/wmlqxmvowrlz into main 2026-10-01 01:12:39 +01:00
1 Commits
Author SHA1 Message Date
JakeHillion 36a8f06b0c cyclone: fail over to cellular based on WAN reachability
commit-validation / validate-single-commit (pull_request) Successful in 7s
flake-update / update (push) Successful in 33s
buildbot/nix-eval Build done. (636 warnings)
buildbot/nix-build Build done.
buildbot/nix-effects Build done.
Cyclone only preferred the cellular default route when dhcpcd removed
its route on enp2s0. A primary WAN that kept its route but could not
reach the internet, or an IPv4LL default route installed by dhcpcd
during a flap, still won over cellular.

Added a wanFailover module under modules/networking and enabled it on
cyclone. A service pings 1.1.1.1, 8.8.8.8 and 9.9.9.9 bound to enp2s0
every 5 seconds, starting each round at the next target in turn; a
round passes if any target answers. After 3 consecutive failed rounds
it installs a metric 100 default route via cellular, and after 12
consecutive passed rounds it removes it again. Source NAT conntrack
entries are flushed on each switch, and the current state is read back
from the routing table on start.

Probing bound to enp2s0 keeps the primary measurable while cellular is
preferred, and the asymmetric thresholds with counters reset on any
opposing result prevent a flapping primary from bouncing traffic.

Test plan:
- CI
- Deploy to cyclone and confirm wan-failover starts on enp2s0
- Drop outbound ICMP on enp2s0 with nft and confirm failover to
  cellular, then remove the rule and confirm failback after ~1 minute
2026-10-01 01:06:43 +01:00