Repository navigation
ffbs-mesh-vpn-parker: client limits for 1024 clients and an event mode for large events - #70
Merged
Merged
Conversation
The uplink node routes for all clients of its mesh. Each IPv6 client has 2 to 3 addresses, so the kernel default gc_thresh3 of 1024 is full at approximately 400 clients. Then the kernel drops packets. Write the limits to /etc/sysctl.d at upgrade time and scale them with the RAM: 4096, 8192 or 16384 entries for gc_thresh3.
dnsmasq gives out no more than dhcp-lease-max leases, 1000 by default. Gluon does not set it, so a range4 larger than /22 is not usable completely. Set dhcpleasemax to the pool size (at least 1000) while the node routes, and remove it again when the node stops routing.
35 of 56 tasks
grische
reviewed
Nov 22, 2026
By default, an uplink node now serves up to 1024 clients. The neighbour table and conntrack are large enough for that number of clients. The node owner can set the event mode in config mode or with uci (parker.event_mode.enabled). Then dnsmasq gives out the full pool, does not ping new addresses and has a larger DNS cache. The neighbour table and conntrack are larger. All values scale with the RAM. Nodes with less than 128 MB RAM cannot use the event mode: config mode does not show it, and noderoute ignores the uci setting and logs a warning. noderoute applies the values in each cycle. A change needs no reboot. When the dnsmasq options change, noderoute restarts dnsmasq. The clients keep their leases.
The config service announces one client network (range4) for all nodes, for example 10.80.96.0/22. In event mode, the node now uses the same base with a /20 mask, for example 10.80.96.0/20. dnsmasq then gives out up to 4093 leases. The node address and the existing leases stay valid. The client network stays on the node: the CLAT translates the client addresses to IPv6. Thus a larger mask needs no change on the config service or the gateways. When the event mode is off again, the node uses the announced range4. clientaddr always uses the announced range4, so a moved node address stays valid.
dnsmasq does not start when its lease file has more leases than dhcp-lease-max. When event mode goes off with more than 1024 clients, DHCP and DNS stop for all clients. Before the restart, remove the leases outside the client range and the oldest ones.
Switching the event mode off live makes the client network smaller and removes the IPv4 address of many clients during the event. Switching it on still applies live. Switching it off applies after a reboot.
noderoute calculated the pool of range4 two times. Use limits.pool() for the dnsmasq lease limit and for the DHCP limit.
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
Large events can have more than 3000 clients in one batman-adv mesh. The uplink node routes for all of these clients. Some default limits on the uplink node are too small for this. But most nodes never serve more than a few hundred clients.
Thus this PR has two levels:
The config service and salt do not change. They continue to announce the current
range4(for example10.80.96.0/22).Related: freifunkMUC/site-ffm#1011.
Changes
parker/limits.lua. It calculates all limits fromMemTotaland the event mode setting.limits.pool(range4)calculates the DHCP pool size for the DHCPlimitand fordhcpleasemax(one place, review by @grische).noderoute.lua: in each cycle, it applies the limits:/etc/sysctl.d/41-parker-limits.conf(neighbour table and conntrack) and applies it when it changes.dhcpleasemax,nopingandcachesizein the dnsmasq section. When the node stops routing, it removes them.range4with a /20 mask (10.80.96.0/22becomes10.80.96.0/20). The node address and the existing leases stay valid. The config service poll (each 120 s) does not reset the /20./tmp) and logs this one time. After the reboot, it uses the announcedrange4and the default limits.range4. Then DHCP and DNS stop for all clients.260-parker-limits. It writes the sysctl file at boot.gluon-web-admin), with German and English text. The text tells that switching off applies only after a reboot. On a node with less than 128 MB RAM, the page shows a note and no checkbox.parker.event_mode(enabled, default0).tests/limits-test.lua.Default and event mode
range4)dhcpleasemax)noping)cachesize)gc_thresh1/2/3IPv4 and IPv6nf_conntrack_maxRAM classes from
MemTotal: 256 MB is more than 192 MiB, 128 MB is more than 96 MiB. A real 128 MB node shows approximately 120 MiB, so it is in the 128 MB class. Below 128 MB: default limits, except that the node keeps the kernel conntrack value. The node never setsnf_conntrack_maxlower than the kernel value.Why "always" and why "event mode only":
gc_thresh3= 1024) is full at approximately 400 clients. Then the kernel drops packets. 1024 clients need 4096.dhcpleasemax. A normal node does not need more than 1024. A /20 pool needs 4093.range4of /20 or larger, or a base that is not on a /20 boundary, does not change. A change of the mask restarts the client interface one time (some seconds).Address check for
10.80.96.0/20: in salt,10.80.96.0/22is used only as the CLATrange4.10.80.0.0/16is used in the gateway SNAT, the DNS ACLs and the reverse DNS zone. These do not see the CLAT addresses, because these addresses do not leave the node. In site-ffm,next_nodeis10.80.0.1, outside of the /20. No collision found. NetBox was not checked.Tests
All lab tests ran in a local lab: QEMU arm64 guests (HVF), image
armsr-armv8. Uplink nodent1: 1 vCPU, 256 MiB. A lab broker announcesrange410.73.0.0/20 (NT-1 to NT-5) or 10.73.0.0/22 (NT-6, smoke test). NT-7 uses the live config service (broker.ffmuc.net), which announces 10.80.96.0/22. Mesh nodesn1..n5: batman-adv only, each with a client container. The clients are simulated: raw DHCP with a 2m lease, renewals at half the lease time, ARP/ND, IPv6 SLAAC.Images:
v2026.11.1-parker7+cp274f53d-lab(the first two commits).v2026.11.1-parker7+cp9df9515-lab, plus the finalnoderoute.lua(one warning only, commitfcabd62) copied to the node. The other files are the same as infcabd62.v2026.11.1-parker7+cp9df9515-lab, plusnoderoute.luaandparker/limits.luafrom52c0e9fand then fromc15f79ccopied to the node.v2026.11.1-parker7+cpc15f79c-lab(clean build, no files copied).v2026.11.1-parker7+cp636b1be-lab(clean build of the PR head, sha2560fa0d106…) onnt1andn1..n5.Static checks
luacheck ffbs-mesh-vpn-parker(repository config): 0 warnings, 0 errors in 28 files.cd ffbs-mesh-vpn-parker && luajit tests/limits-test.lua: all passed. The test covers the RAM classes, the 128 MB gate (a 128 MB node withMemTotal123904 kB can use the event mode, 58368 kB cannot), the conntrack floor and the dnsmasq options.NT-1 to NT-3: neighbour table and full /20 pool (first two commits)
ndisc_cachetable_fulls 2472,arp_cachetable_fulls 11856). After, all entries present, table_fulls 0. Cost approximately 0.55 KiB per entry.dhcpleasemaxremoved, then set again when the node routes again.NT-4: batman mesh with 4000 clients and festival traffic
4000 clients on
n1..n5(500 to 1000 each), real internet traffic (HTTPS, QUIC, DNS,ip.ffmuc.net,ffmuc.net) throughnt1and the live tunnels. batman-adv was not the limit. Results onnt1:A/B test of the dnsmasq ping check at 4000 clients:
nopingNT-5: event mode (final design)
python3 dhcpramp.py lan0 1500 600 …: 1024 leases, then dnsmasq sends NAK ("no leases left").dhcp-lease-max=1024, ping check on, conntrack 16384,gc_thresh1024/2048/4096. PASSuci set parker.event_mode.enabled=1; uci commit parker. In 25 s or less:dhcp-lease-max=4093,dhcp-no-ping,cache-size=4096, conntrack 65536,gc_thresh316384. dnsmasq restarted, the client interface did not restart, the leases stayed. 4000 of 4000 clients got a lease, 0 lost. Hold more than 6 min: approximately 49600 renewals, all answered. dnsmasq approximately 10% CPU, 127 of 228 MiB free. PASSn1, then moved ton2with the same MACs. DHCP: 200 of 200 same address, p50 0.1 s, max 0.25 s. IPv4 to the gateway: p50 1.64 s, max 1.71 s. IPv6: p50 0.42 s, p95 5.57 s, max 5.98 s. Internet (anycast.ffmuc.net, 20 clients, IPv4 and IPv6): 0.2 s. Onnt1, all 200 global TT entries moved ton2in 10 s.tt_request_tx+2,tt_response_rx+2, no full-table request storm. PASSuci set parker.event_mode.enabled=0: in 26 s,dhcp-lease-max=1024, ping check on, no cache option, conntrack 16384,gc_thresh34096. PASS/proc/meminfo(bind mount) with event mode on. 58368 kB (64 MB node): default limits, one warning in the log. 123904 kB (128 MB node): event mode, 128 MB class (cache-size=2048, conntrack 32768,gc_thresh1024/4096/8192,dhcp-lease-max=4093,dhcp-no-ping). PASS/cgi-bin/config/admin/parker_event_mode. English and German text (Accept-Languagede) correct. With 57 MiB: note "This node has less than 128 MB RAM. It cannot use the event mode." and no checkbox. Form save: unchecked givesparker.event_mode.enabled=0, checked gives1. PASSNT-6: /20 client network in event mode (broker announces /22)
br-client10.73.0.1/22,dhcp.client.limit1021,dhcp-lease-max=1024, range 10.73.0.2 to 10.73.3.254. PASSpython3 -u dhcpramp.py lan0 2000 300 900 61. At the 1024 cap: event mode on. In 30 s:br-client10.73.0.1/20, limit 4093,dhcp-lease-max=4093,dhcp-no-ping,cache-size=4096, range 10.73.0.2 to 10.73.15.254. The client interface restarted one time, 0 leases lost. PASS185.150.99.2555 of 5 (34 ms).curl -4 https://ip.ffmuc.netgave the CLAT public IPv4. PASS52c0e9fc15f79c.c15f79cdhcpramp.py lan0 2000 300 900 3001in event mode: 2000 of 2000 bound, 0 NAK. Event mode off: /22 in 4 s.Removed 1498 DHCP leases that do not fit 10.73.0.0/22 / 1024. dnsmasq started, 0 "too many stored leases". After approximately 80 s: 1010 clients bound, the other clients got a NAK, 0 leases outside of the /22. Ping to anycast during the switch: 1 of 900 lost. DNS: 89 of 90 queries answered. PASSSmoke test: clean
cpc15f79cimage onnt1dhcp-lease-max=1024, ping check on,gc_thresh1024/2048/4096, conntrack 16384. Ramp of 1500 clients: 1010 bound, the other clients gave up after 15 tries (simulator limit). PASSdhcp-no-ping,cache-size=4096, conntrack 65536,gc_thresh316384. PASScurl -4 https://ip.ffmuc.netgave the CLAT public IPv4. PASSRemoved 182 DHCP leases, dnsmasq started. PASS. Effect: clients above 1024 lose IPv4 until they renew, and one removed address went to another client. This is why NT-7 changes the design.MemTotal58368 kB, event mode on: 1 warning in approximately 4 cycles, /22 and default limits stay. PASS1and0. PASSNT-7: switch off applies after a reboot, live config service
nt1with a lab brokergc_thresh316384. Event off: /20 and 4093 stay, 1 log line "The node keeps the event mode until the next reboot". After a reboot: /22, 1024, ping check on, default cache, conntrack 16384,gc_thresh34096, no flag file. PASSconfig_serverbroker.ffmuc.net.nt1got 10.80.96.1/22. Client 10.80.99.214/22: ping 5 of 5,curl -4 https://ip.ffmuc.netgave 5.1.66.16. PASSpython3 dhcpramp.py lan0 1200 600 900 7000, event on at 700 clients: 10.80.96.1/20,dhcp-lease-max=4093. 1200 of 1200 bound, 214 leases above the /22, 0 lost. PASSdhcp-lease-max=1024, ping check on, conntrack 16384,gc_thresh34096, no flag file, 5 batman neighbours. Client 10.80.99.235/22: ping 5 of 5, egress 5.1.66.16. PASSn1..n5updated one at a time tocp636b1be. Each node has 5 batman neighbours. PASS8a37d57noderoute.luaandparker/limits.luacopied tont1. Default:limit1021,dhcpleasemax1024. Event on: 4093 and 4093. 0 Lua errors. PASS.lmofiles onnt1contain the new reboot text. The page itself was tested in the smoke test (previous text).Finding, not changed in this PR: in default mode, when more than 1024 clients try to get a lease, dnsmasq sends NAKs in a loop to the other clients. This used approximately 15% dnsmasq CPU in the lab. The clients that have a lease were not affected. Real phones wait longer between tries than the simulator.
Not tested
The reboot tests used a cold restart of the lab VM. In the lab, a warm reboot can stop at the GRUB menu because of the serial console. This is a lab problem.
The config-mode page with the new reboot text was not opened in a browser. Only the translation files were checked.
No test on live nodes or at a real event.
No boot on real 64 MB or 128 MB hardware. The RAM gate used a fake
MemTotal.No test with two uplink nodes in one mesh where one uses the event mode and the other does not.
NetBox was not checked for
10.80.96.0/20.No test with real phones. Roaming used simulated clients.
No test on a slow router (MT7621 class). From the lab CPU cost, a slow router is not a good uplink node for a large event.