Repository navigation
parker-sites: use the broker pgw, guard against flip-back after a switch - #69
Merged
Merged
Conversation
Remove the node-side pgw pin. The config service selects the pgw of each site. After a failover switch, report the switch again with backoff (3 s doubling, max 60 s) until the config service confirms it (2xx, optional "pgw" in the answer). 4xx other than 409 stops the report. While the switch is unconfirmed (max 1800 s) or younger than 300 s, a fetched config that names the left pgw gets the new pgw. A config that names another pgw is applied. A probe that the node cannot send (sendto error, for example during a firewall reload) is not counted for max 60 s.
35 of 56 tasks
wg_cX is NOARP. A default route without a gateway makes each destination its own next hop, so the node adds one neighbour entry per destination (hundreds on busy nodes, close to gc_thresh3). Set the IPv6 default routes in the main table, table 23 and the per-site tables via the address6 of the current pgw of the site. apply() runs on a pgw change, so the next hop follows the switch.
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.
Summary
This change removes the node-side pgw pin. The node now uses the pgw that the config service (broker) sends. The broker is the only authority for pgw selection, rebalancing and drain.
Thank you to the community members who reported the VIE tunnel flapping after the parker7 update.
Changes
parker-sites.lua: removepin()and the/tmp/parker-sites/pgw.<site>override.nodeconfig.shdoes not callparker-sites.lua pinanymore.GET /api/v3/switch?pubkey&site&pgw) again until the broker confirms it:pgw: confirmed.parker/switchguard.lua,parker-sites.lua guard): while a switch is not confirmed, or is younger than 300 s, the node does not apply a fetched config that moves the site back to the pgw that it left. In all other cases the node applies the broker answer.parker-sites.luawrites the switch record to/tmp/parker-sites/switch.<site>. A reboot removes it, so after a reboot the node uses the broker pgw.sendto) does not count as a miss for up to 60 s. This prevents pgw rotation during a short local firewall or route change.senderrs,reportandguard.viathe link-local address of the current pgw of the site. Before, they were device-only (default dev wg_cX). wg_cX is NOARP, so a route without a gateway makes each destination its own next hop. The node then added one neighbour entry per destination. On a live node with 97 clients we saw 325 such entries on one tunnel; the kernel limit (gc_thresh3) is 1024. The route follows the pgw on each switch, broker change and failover. The IPv4 default already usedvia 10.0.0.1and does not change.Broker side: freifunkMUC/wgkex adds a hold for reported switches (default 900 s) and the
pgwfield in the 200 answer. The node also works with the old broker: a 200 withoutpgwcounts as confirmed, and the guard ends after 300 s.Known limits
ifup wancauses real probe misses (not send errors). The node switches the pgw once per site. It reports the switch and stays stable. This change does not damp that single switch.Tests
Route fix (second commit)
Unit tests:
tests/switch-guard-test.luahas 4 new checks for the next hop (current pgw, no state, unknown pgw, no address6). 55 checks pass (luajit and lua 5.5).luacheckon the changed files: 0 warnings / 0 errors.Lab: armsr-armv8 VM u1, live broker and live pgws, light probe traffic only. Image
v2026.11.1-parker7+cp6f36d3f-lab, compared with+cp61504cb-lab(the first commit only). Each test includes real internet pings from a client: IPv4 to anycast.ffmuc.net, 1.1.1.1 and 9.9.9.9, and IPv6 to anycast.ffmuc.net, 2606:4700:4700::1111, 2620:fe::fe and www.google.com, from the source address of each site.default dev wg_cXdefault via fe80::<pgw> dev wg_cXip route get, traceroute). NAT64 and DNS64 work for both sites.default dev br-clientand are not affected.Real internet pings before and after the fix: 0 % loss, except the short gaps during the switch shown above.
Switch report and guard (first commit)
Unit tests (luajit,
LUA_PATH="luasrc/usr/share/lua/?.lua;;"):luajit tests/switch-guard-test.lua: 51 checks pass (guard decide keep/match/expire, backoff, report result parsing for uclient-fetch and busybox, send-error skip).tests/*.luapass.luacheck -q luasrc tests: 0 warnings / 0 errors.Lab (armsr-armv8 VM, image
v2026.11.1-parker7+cp61504cb-lab, a lab fake broker that proxies/configfrom the live broker, overrides the pgw and implements/api/v3/switch):ifup wan+wan6Not tested:
/api/v3/switch. The lab used a fake broker.