Skip to content

ffbs-mesh-vpn-parker: client limits for 1024 clients and an event mode for large events - #70

Merged
awlx merged 8 commits into
parker-release-2026.11from
awlx-parker8-neigh-table-limits
Nov 22, 2026
Merged

awlx merged 8 commits into
parker-release-2026.11from
awlx-parker8-neigh-table-limits

Conversation

@awlx

@awlx awlx commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

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:

  • Default (all nodes): the uplink node serves up to 1024 clients. The neighbour table and conntrack are large enough for 1024 clients.
  • Event mode (opt-in): the node owner sets it in config mode or with uci. The node then makes its client network larger (same base, /20 mask, 4093 leases) and has larger tables. All values scale with the RAM. Nodes with less than 128 MB RAM cannot use the event mode.
  • Switch on and off: switching the event mode on applies in approximately 30 s without a reboot. Switching it off applies only after a reboot. A live switch off makes the client network smaller and removes the IPv4 address of many clients during the event.

The config service and salt do not change. They continue to announce the current range4 (for example 10.80.96.0/22).

Related: freifunkMUC/site-ffm#1011.

Changes

  • New module parker/limits.lua. It calculates all limits from MemTotal and the event mode setting. limits.pool(range4) calculates the DHCP pool size for the DHCP limit and for dhcpleasemax (one place, review by @grische).
  • noderoute.lua: in each cycle, it applies the limits:
    • It writes /etc/sysctl.d/41-parker-limits.conf (neighbour table and conntrack) and applies it when it changes.
    • When the node routes, it sets dhcpleasemax, noping and cachesize in the dnsmasq section. When the node stops routing, it removes them.
    • When the dnsmasq options change, it restarts dnsmasq. The clients keep their leases. Switching the event mode on needs no reboot.
    • In event mode, it uses the announced range4 with a /20 mask (10.80.96.0/22 becomes 10.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.
    • When the event mode is set to off, the node keeps the event mode until the next reboot (flag file in /tmp) and logs this one time. After the reboot, it uses the announced range4 and the default limits.
    • Before dnsmasq restarts, it removes the leases outside of the client network and the oldest leases above the limit. Without this, dnsmasq does not start ("too many stored leases") if the client network gets smaller, for example when the config service announces a smaller range4. Then DHCP and DNS stop for all clients.
    • If the event mode is set on a node with too little RAM, it uses the default limits and logs one warning.
  • New upgrade script 260-parker-limits. It writes the sysctl file at boot.
  • New config-mode page "Event mode" (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.
  • New uci section parker.event_mode (enabled, default 0).
  • README: new section "Client limits and event mode".
  • New unit test tests/limits-test.lua.

Default and event mode

Setting Default (all uplink nodes) Event mode, 256 MB Event mode, 128 MB
Client network (range4) announced, e.g. /22 same base, /20 same base, /20
DHCPv4 leases (dhcpleasemax) 1024 full pool (4093 for /20) full pool
dnsmasq ping check on off (noping) off
DNS cache (cachesize) dnsmasq default (150) 4096 2048
gc_thresh1/2/3 IPv4 and IPv6 1024 / 2048 / 4096 2048 / 8192 / 16384 1024 / 4096 / 8192
nf_conntrack_max 16384 (128 MB and more) 65536 32768

RAM 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 sets nf_conntrack_max lower than the kernel value.

Why "always" and why "event mode only":

  • Neighbour table (always): each IPv6 client has 2 to 3 addresses. The kernel default (gc_thresh3 = 1024) is full at approximately 400 clients. Then the kernel drops packets. 1024 clients need 4096.
  • Conntrack (always, 16384): a festival traffic mix uses approximately 10 entries for each client. The kernel value (14848 with 256 MiB) was full at 1000 to 1200 clients. 16384 is enough for 1024 clients. Event mode: 36101 entries at 3600 clients, thus 65536.
  • Lease limit (event mode): dnsmasq gives out no more than 1000 leases by default. Gluon and OpenWrt do not set dhcpleasemax. A normal node does not need more than 1024. A /20 pool needs 4093.
  • No ping check (event mode): dnsmasq waits up to 3 s for each ping of a new address. In that time it does no DHCP. With many new clients, the DHCP socket overflows and renewals fail (see NT-4 A/B). With 1024 clients or less, the ping check has no problem, so the default keeps it.
  • DNS cache (event mode): more clients ask for more names. The default 150 entries is enough for a normal node.
  • /20 client network (event mode): the client IPv4 network stays on the node. The CLAT translates it to IPv6, so no other system routes it. The /20 has the same base as the announced /22, so clients keep their address when the event mode goes on. A range4 of /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/22 is used only as the CLAT range4. 10.80.0.0/16 is 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_node is 10.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 node nt1: 1 vCPU, 256 MiB. A lab broker announces range4 10.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 nodes n1..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:

  • NT-1 to NT-4: v2026.11.1-parker7+cp274f53d-lab (the first two commits).
  • NT-5: v2026.11.1-parker7+cp9df9515-lab, plus the final noderoute.lua (one warning only, commit fcabd62) copied to the node. The other files are the same as in fcabd62.
  • NT-6: v2026.11.1-parker7+cp9df9515-lab, plus noderoute.lua and parker/limits.lua from 52c0e9f and then from c15f79c copied to the node.
  • Smoke test: v2026.11.1-parker7+cpc15f79c-lab (clean build, no files copied).
  • NT-7: v2026.11.1-parker7+cp636b1be-lab (clean build of the PR head, sha256 0fa0d106…) on nt1 and n1..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 with MemTotal 123904 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)

  • Neighbour flood (3000 IPv4 + approximately 3000 IPv6 neighbours): before, the tables stopped at 1024 (ndisc_cache table_fulls 2472, arp_cache table_fulls 11856). After, all entries present, table_fulls 0. Cost approximately 0.55 KiB per entry.
  • Full pool: 4093 ACK, 0 NAK, addresses 10.73.0.2 to 10.73.15.254. Inactive path: dhcpleasemax removed, then set again when the node routes again.
  • 4092 clients with 2m lease: 0 lost leases in a 16 min hold. dnsmasq 16% of one vCPU.

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) through nt1 and the live tunnels. batman-adv was not the limit. Results on nt1:

  • conntrack: the kernel value 14848 was full at approximately 1000 to 1200 festival clients. Peak 36101 entries at approximately 3600 clients.
  • Neighbours at approximately 3600 clients: IPv4 3648, IPv6 1517.
  • Minimum free RAM: 79 of 228 MiB.

A/B test of the dnsmasq ping check at 4000 clients:

Run Renewals answered Lease expiries NAK UDP 67 drops dnsmasq CPU
4a: ping check on 83% 2073 309 1200 to 1600 for each 10 s up to 98%
4b: noping 100% 0 0 0 approximately 58%

NT-5: event mode (final design)

Step Result
Default mode 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_thresh 1024/2048/4096. PASS
Event mode on during a ramp Ramp 4000 clients at 300/min. At the 1024 cap: uci 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_thresh3 16384. 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. PASS
Roaming, event mode on 200 clients (network namespaces with pings) on n1, then moved to n2 with 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. On nt1, all 200 global TT entries moved to n2 in 10 s. tt_request_tx +2, tt_response_rx +2, no full-table request storm. PASS
Event mode off uci set parker.event_mode.enabled=0: in 26 s, dhcp-lease-max=1024, ping check on, no cache option, conntrack 16384, gc_thresh3 4096. PASS
RAM gate The lab cannot boot a 128 MiB EFI guest. Thus a fake /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_thresh 1024/4096/8192, dhcp-lease-max=4093, dhcp-no-ping). PASS
Config mode Page /cgi-bin/config/admin/parker_event_mode. English and German text (Accept-Language de) 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 gives parker.event_mode.enabled=0, checked gives 1. PASS

NT-6: /20 client network in event mode (broker announces /22)

Step Result
Default mode br-client 10.73.0.1/22, dhcp.client.limit 1021, dhcp-lease-max=1024, range 10.73.0.2 to 10.73.3.254. PASS
Event mode on during a ramp python3 -u dhcpramp.py lan0 2000 300 900 61. At the 1024 cap: event mode on. In 30 s: br-client 10.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. PASS
CLAT IPv4 above the /22 Client with 10.73.11.12/20: ping to 185.150.99.255 5 of 5 (34 ms). curl -4 https://ip.ffmuc.net gave the CLAT public IPv4. PASS
Config service poll The lab broker sent the /22 at each poll (120 s). The node stayed on the /20. No network reload. PASS
Event mode off, 52c0e9f 1926 leases, 904 above the /22. The node went back to /22 in 15 s. Then dnsmasq did not start: "too many stored leases". DHCP and DNS stopped, all 1914 clients lost their lease. FAIL. Fixed in c15f79c.
Event mode off, c15f79c New ramp dhcpramp.py lan0 2000 300 900 3001 in 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. PASS

Smoke test: clean cpc15f79c image on nt1

Step Result
Default mode 10.73.0.1/22, limit 1021, dhcp-lease-max=1024, ping check on, gc_thresh 1024/2048/4096, conntrack 16384. Ramp of 1500 clients: 1010 bound, the other clients gave up after 15 tries (simulator limit). PASS
Event mode on during the ramp /20 in 22 s or less, 4093, dhcp-no-ping, cache-size=4096, conntrack 65536, gc_thresh3 16384. PASS
CLAT IPv4 on the /20 Client 10.73.5.232/20: ping 5 of 5, curl -4 https://ip.ffmuc.net gave the CLAT public IPv4. PASS
Event mode off live (old design) 1310 leases: /22 in 11 s, Removed 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.
RAM gate, log one time Fake MemTotal 58368 kB, event mode on: 1 warning in approximately 4 cycles, /22 and default limits stay. PASS
Config mode English and German text, checkbox shown on 256 MB, form save gives 1 and 0. PASS

NT-7: switch off applies after a reboot, live config service

Step Result
Latch, nt1 with a lab broker Event on: 10.73.0.1/20, 4093, gc_thresh3 16384. 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_thresh3 4096, no flag file. PASS
Live config service config_server broker.ffmuc.net. nt1 got 10.80.96.1/22. Client 10.80.99.214/22: ping 5 of 5, curl -4 https://ip.ffmuc.net gave 5.1.66.16. PASS
Event on during a ramp python3 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. PASS
Config service poll Polls for approximately 6 min. The config service announced 10.80.96.0/22. The node stayed on 10.80.96.0/20. CLAT IPv4: ping 10 of 10, egress 5.1.66.16. PASS
Event off, no reboot /20 and 4093 stay, flag files present, 1 log line. 1200 of 1200 bound, 0 lost. PASS
Reboot 10.80.96.1/22, dhcp-lease-max=1024, ping check on, conntrack 16384, gc_thresh3 4096, no flag file, 5 batman neighbours. Client 10.80.99.235/22: ping 5 of 5, egress 5.1.66.16. PASS
Mesh nodes n1..n5 updated one at a time to cp636b1be. Each node has 5 batman neighbours. PASS
Pool refactor 8a37d57 noderoute.lua and parker/limits.lua copied to nt1. Default: limit 1021, dhcpleasemax 1024. Event on: 4093 and 4093. 0 Lua errors. PASS
Config-mode text The English and German .lmo files on nt1 contain 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.

awlx added 2 commits November 22, 2026 10:31
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.
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.
@awlx awlx changed the title ffbs-mesh-vpn-parker: raise neighbour table and DHCPv4 lease limits for large events ffbs-mesh-vpn-parker: client limits for 1024 clients and an event mode for large events Nov 22, 2026
awlx added 5 commits November 22, 2026 19:43
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.
@awlx
awlx merged commit 169f0a1 into parker-release-2026.11 Nov 22, 2026
11 of 12 checks passed
@awlx
awlx deleted the awlx-parker8-neigh-table-limits branch November 22, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants