Client Class Reservation for selecting pool/subnet with Kea 1.6.2 does not work
Describe the bug
Selecting pool or subnet by using "client-classes" in "reservations" section (global or not) does not work with DHCPv4 server.
Simply copying example from latest "Pool Selection with Client Class Reservations" section of the DHCPv4 Server documentation (and fixing syntax error there) does not work with stable ISC Kea 1.6.2.
Adopting similar example of class assignment for reservations from stable docs does not seem to work with current-stable Kea DHCPv4 server either.
(tried using global reservations, only-if-required/require-client-classes, shared networks and other variants, none of which seem to change the outcome)
To Reproduce
Steps to reproduce the behavior:
-
Save following configuration to e.g. kea.json file:
{ "Dhcp4": { // Added for a local setup "interfaces-config": {"interfaces": ["kea"]}, "loggers": [{ "name": "kea-dhcp4", "severity": "DEBUG", "debuglevel": 99, "output_options": [{"output": "stdout"}] }], // Example from docs, with fixed syntax and '"interface": "kea",' line added // https://kea.readthedocs.io/en/latest/arm/dhcp4-srv.html#pool-selection-with-client-class-reservations "client-classes": [ { "name": "reserved_class" }, { "name": "unreserved_class", "test": "not member('reserved_class')" } ], "subnet4": [ { "subnet": "192.0.2.0/24", "interface": "kea", "reservations": [{ "hw-address": "52:54:00:12:34:64", "client-classes": [ "reserved_class" ] }], "pools": [ { "pool": "192.0.2.10-192.0.2.20", "client-class": "reserved_class" }, { "pool": "192.0.2.30-192.0.2.40", "client-class": "unreserved_class" } ] } ] } }
-
Replace "52:54:00:12:34:64" MAC address in above configuration with MAC address of the DHCP client and "kea" with the name of the interface that kea should handle DHCP requests on.
-
Start Kea DHCPv4 daemon with this configuration file:
KEA_PIDFILE_DIR=/run KEA_LOCKFILE_DIR=/run/lock/kea kea-dhcp4 -c kea.json
-
Run DHCPv4 client on the same network, e.g. udhcpc from busybox:
busybox udhcpc -fi ens3
-
Observe logging output in terminal from both kea-dhcp4 and udhcpc, started in previous two steps.
Expected behavior
-
kea-dhcp4 responds with IP address from pool 192.0.2.10-192.0.2.20 to client with MAC address 52:54:00:12:34:64 (with verbatim config above).
-
kea-dhcp4 assigns "reserved_class" class to that client and logs it in debug output, same as it does with other classes.
Actual result
kea-dhcp4 responds with IP address from pool 192.0.2.30-192.0.2.40 and assigns "unreserved_class" to that client.
Verbose logging output has these lines:
2020-07-14 19:15:23.491 DEBUG [kea-dhcp4.packets/4807] DHCP4_BUFFER_RECEIVED received buffer from 0.0.0.0:68 to 255.255.255.255:67 over interface kea
2020-07-14 19:15:23.491 DEBUG [kea-dhcp4.options/4807] DHCP4_BUFFER_UNPACK parsing buffer received from 0.0.0.0 to 255.255.255.255 over interface kea
2020-07-14 19:15:23.492 DEBUG [kea-dhcp4.eval/4807] EVAL_DEBUG_MEMBER Checking membership of 'reserved_class', pushing result 'false'
2020-07-14 19:15:23.492 DEBUG [kea-dhcp4.eval/4807] EVAL_DEBUG_NOT Popping 'false' pushing 'true'
2020-07-14 19:15:23.492 INFO [kea-dhcp4.options/4807] EVAL_RESULT Expression unreserved_class evaluated to 1
...
2020-07-14 19:15:23.493 DEBUG [kea-dhcp4.packets/4807] DHCP4_PACKET_RECEIVED [hwtype=1 52:54:00:12:34:64], cid=[01:52:54:00:12:34:64], tid=0xbecc140b: DHCPDISCOVER (type 1) received from 0.0.0.0 to 255.255.255.255 on interface kea
...
2020-07-14 19:15:23.494 DEBUG [kea-dhcp4.hosts/4807] HOSTS_CFG_GET_ALL_IDENTIFIER get all hosts with reservations using identifier: hwaddr=525400123464
2020-07-14 19:15:23.494 DEBUG [kea-dhcp4.hosts/4807] HOSTS_CFG_GET_ALL_IDENTIFIER_HOST using identifier: hwaddr=525400123464, found host: hwaddr=525400123464 ipv4_subnet_id=1 hostname=(empty) ipv4_reservation=(no) siaddr=(no) sname=(empty) file=(empty) key=(empty) ipv6_reservations=(none) dhcp4_class0=reserved_class
...
2020-07-14 19:15:23.495 DEBUG [kea-dhcp4.dhcp4/4807] DHCP4_CLASS_ASSIGNED [hwtype=1 52:54:00:12:34:64], cid=[01:52:54:00:12:34:64], tid=0xbecc140b: client packet has been assigned to the following class(es): KNOWN
2020-07-14 19:15:23.495 DEBUG [kea-dhcp4.dhcp4/4807] DHCP4_CLASS_ASSIGNED [hwtype=1 52:54:00:12:34:64], cid=[01:52:54:00:12:34:64], tid=0xbecc140b: client packet has been assigned to the following class(es): ALL, VENDOR_CLASS_udhcp 1.31.1, unreserved_class, KNOWN
Last one in particular suggests that incorrect (unexpected) class gets assigned, and correct (expected) one does not.
Environment:
- Kea version: 1.6.2 compiled locally from .tar.gz release.
- OS: bult and ran on current Arch Linux
- "./configure" was used without any --enable or --with options. Full PKGBUILD script used (simple bash): http://ix.io/2rBN
- Configuration file above loads no extra hooks, as far as I know.
Additional Information
Full log file with debug options above from Kea when running udhcpc is attached.
As mentioned, also tried global reservations and moving them around in general to no avail.
Also tried delaying class evaluation with only-if-required and require-client-classes, couldn't get that to work either - no custom classes get evaluated/assigned there at all, despite being listed in "require-client-classes" in the "subnet4" section.
In a somewhat similar report - #1314 (closed) - issue seemed to be Kea not prioritizing class, but note that here it explicitly picks the wrong (unexpected) class.
Removing unreserved_class entirely makes allocation fail and denies service despite matching hw-address for reserved_class.
"kea" network interface in this testing setup uses VLAN tagging (created using ip link add link ens3 name kea type vlan id 1
).
hw-address match doesn't seem to mind that and matches MAC address part just fine.
Docs for stable Kea 1.6.2 ("Reserving Client Classes in DHCPv4" section) only have example for using such reserved-host classes for adding options, and suggest using delayed class rules evaluation with "only-if-required" and "require-client-classes" for selecting pool/subnet, but as mentioned, it doesn't seem to work either.
I'm not entirely sure if selecting pools/subnets from reservations is supposed to work at all, so maybe just a clear "not supported in 1.6.x" response would do here (and maybe should be more prominent in the docs as well, if that's the case).
It's not a production setup of any kind, just trying out Kea in a couple VMs, and can definitely try anything on it, if issue seem to be with this setup specifically - let me know.
Do plan to try Kea 1.7.x, see if maybe there's no such issue there, though if I understand Kea versioning correctly, it's more of a beta branch, not really intended for production use, so 1.6.x should probably have fixes from there too.
Thanks!