class evaluation from db does not work
I've tried exactly the same class configuration in file and in db config backend. In configuration it worked correctly but there is an error when classes are pulled from database:
ERROR [kea-dhcp4.options/21088.139705724942080] EVAL_RESULT Expression modem evaluated to Incorrect stack order. Expected exactly 1 value at the end of evaluation, got 0
Scenario 1:
- configure kea with class in config file (subnets in db),
config-get
return:
{
"Dhcp4": {
"authoritative": false,
"boot-file-name": "",
"calculate-tee-times": false,
"client-classes": [
{
"boot-file-name": "",
"name": "modem",
"next-server": "0.0.0.0",
"option-data": [],
"option-def": [],
"server-hostname": "",
"test": "hexstring(pkt4.mac, ':') == '00:00:00:00:00:01'"
}
],
"config-control": {
"config-databases": [
{
"name": "keadb",
"password": "keapass",
"type": "mysql",
"user": "keauser"
}
]
},
"control-socket": {
"socket-name": "/home/wlodek/installed/git/var/run/kea/control_socket",
"socket-type": "unix"
},
"ddns-generated-prefix": "myhost",
"ddns-override-client-update": false,
"ddns-override-no-update": false,
"ddns-qualifying-suffix": "",
"ddns-replace-client-name": "never",
"ddns-send-updates": true,
"ddns-update-on-renew": false,
"ddns-use-conflict-resolution": true,
"decline-probation-period": 86400,
"dhcp-ddns": {
"enable-updates": false,
"max-queue-size": 1024,
"ncr-format": "JSON",
"ncr-protocol": "UDP",
"sender-ip": "0.0.0.0",
"sender-port": 0,
"server-ip": "127.0.0.1",
"server-port": 53001
},
"dhcp-queue-control": {
"capacity": 64,
"enable-queue": false,
"queue-type": "kea-ring4"
},
"dhcp4o6-port": 0,
"echo-client-id": true,
"expired-leases-processing": {
"flush-reclaimed-timer-wait-time": 25,
"hold-reclaimed-time": 3600,
"max-reclaim-leases": 100,
"max-reclaim-time": 250,
"reclaim-timer-wait-time": 10,
"unwarned-reclaim-cycles": 5
},
"hooks-libraries": [
{
"library": "/home/wlodek/installed/git/lib/kea/hooks/libdhcp_cb_cmds.so"
},
{
"library": "/home/wlodek/installed/git/lib/kea/hooks/libdhcp_mysql_cb.so"
}
],
"host-reservation-identifiers": [
"hw-address",
"duid",
"circuit-id",
"client-id"
],
"hostname-char-replacement": "",
"hostname-char-set": "[^A-Za-z0-9.-]",
"interfaces-config": {
"interfaces": [
"enp0s9"
],
"re-detect": true
},
"ip-reservations-unique": true,
"lease-database": {
"type": "memfile"
},
"loggers": [
{
"debuglevel": 99,
"name": "kea-dhcp4",
"output_options": [
{
"output": "/home/wlodek/installed/git/var/log/kea.log"
}
],
"severity": "DEBUG"
}
],
"match-client-id": true,
"multi-threading": {
"enable-multi-threading": true,
"packet-queue-size": 16,
"thread-pool-size": 2
},
"next-server": "0.0.0.0",
"option-data": [],
"option-def": [],
"reservations-global": false,
"reservations-in-subnet": true,
"reservations-out-of-pool": false,
"sanity-checks": {
"lease-checks": "warn"
},
"server-hostname": "",
"server-tag": "abc",
"shared-networks": [],
"statistic-default-sample-age": 0,
"statistic-default-sample-count": 20,
"store-extended-info": false,
"subnet4": [
{
"4o6-interface": "",
"4o6-interface-id": "",
"4o6-subnet": "",
"client-class": "modem",
"id": 1,
"interface": "enp0s9",
"option-data": [],
"pools": [
{
"option-data": [],
"pool": "192.168.50.1-192.168.50.100"
}
],
"relay": {
"ip-addresses": []
},
"reservations": [],
"subnet": "192.168.50.0/24"
}
],
"t1-percent": 0.5,
"t2-percent": 0.875,
"valid-lifetime": 7200
}
},
"result": 0
}
and logs for incoming pkt:
2021-09-15 10:29:24.078 DEBUG [kea-dhcp4.eval/10419.140439989733120] EVAL_DEBUG_PKT4 Pushing PKT4 field mac with value 0x000000000001
2021-09-15 10:29:24.078 DEBUG [kea-dhcp4.eval/10419.140439989733120] EVAL_DEBUG_STRING Pushing text string ':'
2021-09-15 10:29:24.078 DEBUG [kea-dhcp4.eval/10419.140439989733120] EVAL_DEBUG_TOHEXSTRING Popping binary value 0x000000000001 and separator :, pushing result 00:00:00:00:00:01
2021-09-15 10:29:24.078 DEBUG [kea-dhcp4.eval/10419.140439989733120] EVAL_DEBUG_STRING Pushing text string '00:00:00:00:00:01'
2021-09-15 10:29:24.078 DEBUG [kea-dhcp4.eval/10419.140439989733120] EVAL_DEBUG_EQUAL Popping 0x30303A30303A30303A30303A30303A3031 and 0x30303A30303A30303A30303A30303A3031 pushing result 'true'
2021-09-15 10:29:24.078 INFO [kea-dhcp4.options/10419.140439989733120] EVAL_RESULT Expression modem evaluated to 1
all is fine :)
Scenario 2: configure class in db backend:
{'arguments': {'client-classes': [{'boot-file-name': '',
'name': 'modem',
'next-server': '0.0.0.0',
'option-data': [],
'option-def': [],
'server-hostname': '',
'test': "hexstring(pkt4.mac, ':') == "
"'00:00:00:00:00:01'",
'valid-lifetime': 7200}], <<<<< in here I have to add value equal to default, forge limitation :(
'remote': {'type': 'mysql'},
'server-tags': ['all']},
'command': 'remote-class4-set',
'service': ['dhcp4']}
[
{
"arguments": {
"client-classes": [
{
"name": "modem"
}
]
},
"result": 0,
"text": "DHCPv4 client class successfully set."
}
]
config-get
return:
{'arguments': {}, 'command': 'config-get', 'service': ['dhcp4']}
[
{
"arguments": {
"Dhcp4": {
"authoritative": false,
"boot-file-name": "",
"calculate-tee-times": false,
"client-classes": [
{
"boot-file-name": "",
"name": "modem",
"next-server": "0.0.0.0",
"option-data": [],
"option-def": [],
"server-hostname": "",
"test": "hexstring(pkt4.mac, ':') == '00:00:00:00:00:01'",
"valid-lifetime": 7200
}
],
"config-control": {
"config-databases": [
{
"name": "keadb",
"password": "keapass",
"type": "mysql",
"user": "keauser"
}
]
},
"control-socket": {
"socket-name": "/home/wlodek/installed/git/var/run/kea/control_socket",
"socket-type": "unix"
},
"ddns-generated-prefix": "myhost",
"ddns-override-client-update": false,
"ddns-override-no-update": false,
"ddns-qualifying-suffix": "",
"ddns-replace-client-name": "never",
"ddns-send-updates": true,
"ddns-update-on-renew": false,
"ddns-use-conflict-resolution": true,
"decline-probation-period": 86400,
"dhcp-ddns": {
"enable-updates": false,
"max-queue-size": 1024,
"ncr-format": "JSON",
"ncr-protocol": "UDP",
"sender-ip": "0.0.0.0",
"sender-port": 0,
"server-ip": "127.0.0.1",
"server-port": 53001
},
"dhcp-queue-control": {
"capacity": 64,
"enable-queue": false,
"queue-type": "kea-ring4"
},
"dhcp4o6-port": 0,
"echo-client-id": true,
"expired-leases-processing": {
"flush-reclaimed-timer-wait-time": 25,
"hold-reclaimed-time": 3600,
"max-reclaim-leases": 100,
"max-reclaim-time": 250,
"reclaim-timer-wait-time": 10,
"unwarned-reclaim-cycles": 5
},
"hooks-libraries": [
{
"library": "/home/wlodek/installed/git/lib/kea/hooks/libdhcp_cb_cmds.so"
},
{
"library": "/home/wlodek/installed/git/lib/kea/hooks/libdhcp_mysql_cb.so"
}
],
"host-reservation-identifiers": [
"hw-address",
"duid",
"circuit-id",
"client-id"
],
"hostname-char-replacement": "",
"hostname-char-set": "[^A-Za-z0-9.-]",
"interfaces-config": {
"interfaces": [
"enp0s9"
],
"re-detect": true
},
"ip-reservations-unique": true,
"lease-database": {
"type": "memfile"
},
"loggers": [
{
"debuglevel": 99,
"name": "kea-dhcp4",
"output_options": [
{
"output": "/home/wlodek/installed/git/var/log/kea.log"
}
],
"severity": "DEBUG"
}
],
"match-client-id": true,
"multi-threading": {
"enable-multi-threading": true,
"packet-queue-size": 16,
"thread-pool-size": 2
},
"next-server": "0.0.0.0",
"option-data": [],
"option-def": [],
"reservations-global": false,
"reservations-in-subnet": true,
"reservations-out-of-pool": false,
"sanity-checks": {
"lease-checks": "warn"
},
"server-hostname": "",
"server-tag": "abc",
"shared-networks": [],
"statistic-default-sample-age": 0,
"statistic-default-sample-count": 20,
"store-extended-info": false,
"subnet4": [
{
"4o6-interface": "",
"4o6-interface-id": "",
"4o6-subnet": "",
"client-class": "modem",
"id": 1,
"interface": "enp0s9",
"option-data": [],
"pools": [
{
"option-data": [],
"pool": "192.168.50.1-192.168.50.100"
}
],
"relay": {
"ip-addresses": []
},
"reservations": [],
"subnet": "192.168.50.0/24"
}
],
"t1-percent": 0.5,
"t2-percent": 0.875,
"valid-lifetime": 7200
}
},
"result": 0
}
]
logs of evaluation:
2021-09-15 10:35:24.150 DEBUG [kea-dhcp4.options/27331.140580890797824] DHCP4_BUFFER_UNPACK parsing buffer received from 0.0.0.0 to 255.255.255.255 over interface enp0s9
2021-09-15 10:35:24.151 ERROR [kea-dhcp4.options/27331.140580890797824] EVAL_RESULT Expression modem evaluated to Incorrect stack order. Expected exactly 1 value at the end of evaluation, got 0
2021-09-15 10:35:24.151 DEBUG [kea-dhcp4.packets/27331.140580890797824] DHCP4_SUBNET_SELECTION_FAILED [hwtype=1 00:00:00:00:00:01], cid=[no info], tid=0x334954: failed to select subnet for the client
2021-09-15 10:35:24.151 DEBUG [kea-dhcp4.bad-packets/27331.140580890797824] DHCP4_PACKET_DROP_0002 [hwtype=1 00:00:00:00:00:01], cid=[no info], tid=0x334954, from interface enp0s9: no suitable subnet configured for a direct client
so yeah... didn't work for me :(