Repository navigation
net: require_public_ip keeps redialing with backoff; a private line falls back to the main route - #175
Merged
Conversation
…te line out of routing (Closes #174) A PPPoE line behind a walled garden (AIS: a session over the concurrent limit gets 100.64/10, is up and carries nothing until the old sessions time out) used to stop the automatic redial after four tries, and policy routes kept sending their devices into it. - require_public_ip never gives up: the first four redials wait require_public_ip_gap (180 s), then the wait doubles up to 15 minutes (a longer configured gap is kept). Only the line with the private address is redialed. State stays in /run (a reboot starts over; a public address clears it). - While a require_public_ip line holds a private / CGNAT address it counts as down for routing: wanHealthMap reports it down, so the WAN table loses its default route, the main metric is raised, balance and DNS skip it. Policy routes with fallback: main use the main route at once (ppp-up hook) and go back when a public address arrives; fallback: drop stays cut off. The once-a-minute check re-routes a line whose routes do not match. - mr doctor: warn "waiting for the ISP to release a session slot ... redial N done, next in X min" instead of the "stopped" risk; the WAN page shows the same; one warning event when the fast phase ends. - Lab: the ISP simulator gets --cgnat-dials N (walled garden for the first N dials of a client MAC), isp-walled, --echo (which WAN did the request leave through), and a wire log (PADI/PADT/LCP terminate seen at the ISP). Scenario 07 (two lines, backoff, public line untouched, doctor text) and the new 14 (fallback main/drop, health check variant). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Cd1s
force-pushed
the
fix/public-ip-retry
branch
from
October 25, 2026 20:30
9adf3fa to
6e6061f
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.
Closes #174
What
require_public_ipnever gives up. The first four redials waitrequire_public_ip_gap(default 180 s), after that the wait doubles up to 15 minutes (a configured gap above 15 minutes is kept), and it stays there until the line gets a public address or the option is turned off. Only the line with the private address is redialed; a line with a public address is never touched. State stays in/run/mini-router/require-public-ip.json(a reboot starts over, a public address clears it,mr applyforgets WANs that no longer use the option). TheRisk/ "stopped" state is gone.require_public_ipPPPoE line holds an RFC1918 / 100.64/10 / 169.254/16 address,wanHealthMapreports itdown(like a failedmr-wanmoncheck, but without needingmultiwan): its WAN table loses the default route, its main-table metric is raised, balance mode and DNS ordering skip it. Policy routes withfallback: main(default) therefore use the main route at once (the ppp-up hook does it; the once-a-minutemr wan public-check --cronre-routes any line whose routes do not match, so the worst case is one minute) and go back to the via WAN when it has a public address.fallback: dropis unchanged: still cut off.mr doctor/ panel. The "stopped" RISK is replaced by a WARN:has 100.64.x.y (cgnat); waiting for the ISP to release a session slot (...): redial 5 done, next in 6 min. The WAN page shows the same next to the line (public_waitinnet.wan/status). One warning event when the fast phase ends.docs/modules/net.md(new section "PPPoE 公网地址保护", with the AIS concurrent-limit → walled-garden background; the fallback section lists the three reasons a via WAN is unusable), SKILL.md, README, UI help text + English dictionary.--cgnat-dials N [--cgnat-mac MAC](the first N dials of a client land in a walled garden: 100.64.x, up, nothing forwarded; later dials are public),lab.sh isp-walled,--echo(an address in the ISP that answers with the source it saw: through which WAN did the request leave?), and a wire log (pppoe-watch.py: PADI/PADO/PADR/PADS/PADT and LCP terminate seen at the ISP). Scenario07is reworked for the new behaviour,14-policy-fallback-walledis new.Why
Reproduces and fixes the 2026-10-26 incident: after a reboot three of four lines got CGNAT addresses from the ISP's concurrent-session limit. The guard stopped after four redials (the line then stayed broken until someone fixed it by hand), and the devices pinned to the walled lines by
policy_routeshad no internet for ~50 minutes because their tables still had a default route.Existing behaviour that stays: with
multiwanthe health check already removed the table's default route when pings through the line fail (scenario 14 checks this onmaintoo); what was missing is the line that is up, has an address and is known to be useless.Verification
Unit tests (
cd mr && go test ./...):TestRequirePublicWaitSchedule,TestRequirePublicIPRedialsOnlyThePrivateWANAndNeverStops,TestPublicIPCheckHonoursBackoff,TestRequirePublicIPClockRollbackEndsCooldown,TestPublicIPGuardHoldsPrivateWANOut,TestPublicIPGuardKeepsWanmonVerdict,TestHookPPPPrivateAddressDropsWANTableDefault,TestHookPPPPrivateAddressWithoutOptionStaysRouted,TestPublicIPCheckReroutesWhenGuardStateDiffersFromRoutes,TestFallbackDropRuleUnchangedByGuard,TestDoctorRequiresPublicIPWaitingIsWarn,TestDoctorRequiresPublicIPWaitingTexts,TestDoctorIgnoresStaleRecordWhenGuardDisabled,TestDoctorCGNATHealthHint. WithpublicIPHeldforced to "" the hold-out tests fail.Lab (id 8, QEMU Alpine 3.24 +
install.shof this tree):14-policy-fallback-walledon this branch: 22/22 ok (1m20s). The same scenario againstorigin/main(MR_LAB_TREE=…) reproduces the incident:(the health-check variant, checks 15-22, passes on both).
07-require-public-ipon this branch: 17/17 ok (~90 s with gap 2 s and a 4 s guest ticker). ISP sidedials.logfor wan2 (7 walled dials, the 8th public) and the doctor line while waiting:and no frame from wan's MAC at the ISP after wan2 was added. On
mainthe same scenario showsRISK wan.wan2 ... automatic public-IP redial stopped after repeated private addresses(checks 6 and 7 fail).sh tools/ci.sh(this tree):ALL CHECKS PASSED.Not in this PR: whether the PPPoE sessions are ended (PADT) at reboot — tracked separately.
🤖 Generated with Claude Code