Kea HA (hot-standby) on CARP interfaces: every DHCP packet processed twice → ResourceBusy conflicts → HA terminates. Root cause + patch (CE 2.8.1)
-
Hi all,
after moving our HA pair to Kea HA (hot-standby) we saw two symptoms that I could finally trace down. Posting here first as requested before opening Redmine issues – feedback and confirmations from other HA users welcome.
Setup: pfSense CE 2.8.1 on two nodes, Kea 2.6.2 (multi-threading defaults: 32 threads, queue 64), Kea HA hot-standby over a dedicated sync interface, 13 DHCP VLANs on a lagg, each with node address + CARP VIP. DNS registration in Kea is disabled.
Symptoms
- Mass boot of ~50 Windows clients: 18 of them had no address for ~7 minutes (Windows gives up after ~2 min, APIPA, next retry after 5 min).
- Sporadic
HA_LEASE_UPDATE_CONFLICT ... ResourceBusy: IP address ... could not be updated (error code 4)during such mass events; once the counter reachedmax-rejected-lease-updatesthe HA service terminated (HA_LEASE_UPDATE_REJECTS_CAUSED_TERMINATION), and with one node WAITING and the other TERMINATED no server answered at all untilha-reset. statistic-get-all:pkt4-receive-dropin the hundreds, ~20 % of DHCPREQUESTs without ACK.
Root cause 1 – duplicate packets on CARP interfaces
pfSense writes the DHCP interfaces tointerfaces-configby name only. Kea then opens one raw socket per IPv4 address on the interface – node IP and CARP VIP – and every broadcast is received and processed twice. Kea even says so at startup, at WARN level (check your DHCP log):DHCPSRV_MULTIPLE_RAW_SOCKETS_PER_IFACE current configuration will result in opening multiple broadcast capable socket...DEBUG log: same transaction id, same microsecond, two threads, two
DHCP4_LEASE_ALLOC, orDHCP4_PACKET_DROP_0011. In hot-standby the primary then sends two lease updates for the same IP in parallel, the standby rejects the second one with ResourceBusy – and after 10 rejects HA terminates.Root cause 2 – run_script hook always loaded
kea_run4(kea2unbound) is added as run_script hook unconditionally, even with DNS registration off. Each invocation costs ~380 ms and they are serialized: DISCOVER→OFFER 383 ms (1 ms without the hook), REQUEST→ALLOC 760 ms (1 ms). That limits a node to roughly one client every 2 s during a boot storm, which is where the 7-minute gap came from. It also hid root cause 1 most of the time: removing only the hook made HA terminate within seconds.Fix / workaround
(both changes in/etc/inc/services.inc, applied via System Patches on both nodes):- bind each Kea interface to its single CARP VIP (
laggX.Y/<vip>) – one socket instead of two; - load the run_script hook only if
kea_dnsreg_enabled().
Diff (2.8.1):
--- a/etc/inc/services.inc +++ b/etc/inc/services.inc @@ -1579,7 +1579,9 @@ } $run_script_main = '/usr/local/bin/kea_run4'; - if (file_exists($run_script_main)) { + /* local patch: kea2unbound is the only DHCPv4 run script; without DNS registration the hook only + * costs ~380 ms per lease event, serialized. */ + if (file_exists($run_script_main) && kea_dnsreg_enabled()) { $keaconf['Dhcp4']['hooks-libraries'][] = [ 'library' => '/usr/local/lib/kea/hooks/libdhcp_run_script.so', 'parameters' => [ @@ -2488,7 +2490,21 @@ } $keaconf['Dhcp4']['subnet4'][] = $keasubnet; - $keaconf['Dhcp4']['interfaces-config']['interfaces'][] = get_real_interface($dhcpif); + /* local patch: bind Kea to the single CARP VIP of this subnet. Without it Kea opens one raw socket + * per address (real IP + VIP), sees every packet twice and sends duplicate parallel HA lease updates, + * which the standby rejects (ResourceBusy) until HA terminates. */ + $kea_if = get_real_interface($dhcpif); + $kea_vips = []; + foreach (config_get_path('virtualip/vip', []) as $kea_vip) { + if (($kea_vip['mode'] == 'carp') && ($kea_vip['interface'] == $dhcpif) && + is_ipaddrv4($kea_vip['subnet']) && ip_in_subnet($kea_vip['subnet'], $keasubnet['subnet'])) { + $kea_vips[] = $kea_vip['subnet']; + } + } + if (count($kea_vips) == 1) { + $kea_if .= '/' . $kea_vips[0]; + } + $keaconf['Dhcp4']['interfaces-config']['interfaces'][] = $kea_if; if ($newzone['domain-name']) { if ($need_ddns_updates) { $newzone['dns-servers'] = array($dhcpifconf['ddnsdomainprimary'], $dhcpifconf['ddnsdomainsecondary']);Result
(mass reboot of ~50 clients): every packet received once, 0 HA conflicts, 0 receive drops, all clients served, startup warning gone, both nodes hot-standby. The standby binds to the VIP fine while it is in CARP BACKUP. Side effect: clients with the old server-id (node IP) can't unicast-renew to it anymore and renew at T2 by broadcast.Possibly related: https://forum.netgate.com/topic/197056 , Redmine #16994, #16864.
Can anyone with Kea HA + CARP confirm the
DHCPSRV_MULTIPLE_RAW_SOCKETS_PER_IFACEwarning in their log? I'm happy to open the Redmine issues afterwards. -
N NotRocketScience referenced this topic
-
Bugreports postet:
https://redmine.pfsense.org/issues/17206
https://redmine.pfsense.org/issues/17207 -
@NotRocketScience #2 sounds like https://redmine.pfsense.org/issues/16865 fixed in 2.9?
-
@SteveITS thanks for the pointer. #16865 covers DNS registration attempts when Unbound is disabled. In our setup Unbound is enabled and Kea DNS registration is disabled. Current master (services.inc, the $run_script_main block in services_kea4_configure()) still loads libdhcp_run_script.so unconditionally, and kea2unbound.sh still runs kea2unbound sync with an empty subnet list on every lease event. So this issue is related but not fixed by #16865.
-
@NotRocketScience Ah. I'd still repro in 2.9 though.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register LoginPrivacy Policy · Cookie Policy