evaluation error on CB class test expressions
- Start a Kea with CB and debug logging kea-dhcp4.conf.
- Start a kea-ctrl-agent kea-ctrl-agent.conf.
- Create a class that tests the equality operator between an option substring and a literal string:
$ curl -X POST 10.1.0.2:8080 -H 'Content-Type: application/json' -d "$(cat <<HERE_DOCUMENT
{
"arguments": {
"client-classes": [
{
"name": "my-class",
"test": "substring(option[1].hex, 0, 8) == 'my-value'"
}
],
"remote": {
"type": "mysql"
},
"server-tags": [
"all"
]
},
"command": "remote-class4-set",
"service": [
"dhcp4"
]
}
HERE_DOCUMENT
)"
[ { "arguments": { "client-classes": [ { "name": "my-class" } ] }, "result": 0, "text": "DHCPv4 client class successfully set." } ]
- Wait for Kea to pull configuration signaled through the log message:
DEBUG MYSQL_CB_GET_ALL_CLIENT_CLASSES4_RESULT retrieving: 1 elements
- Send perfdhcp traffic:
perfdhcp -4 -l vethclient -r 1 -t 1
. - Observe error log message:
ERROR EVAL_RESULT Expression my-class evaluated to Incorrect stack order. Expected exactly 1 value at the end of evaluation, got 0
.
Expected result: the my-class expression gets succesfully evaluated to either true or false.
Alternative scenario: configuring the client class in the file configuration evalutes the expression succesfully to true or false.
"client-classes": [
{
"name": "my-class",
"test": "substring(option[1].hex, 0, 8) == 'my-value'"
}
]
DEBUG EVAL_DEBUG_OPTION Pushing option 1 with value 0x
DEBUG EVAL_DEBUG_STRING Pushing text string '0'
DEBUG EVAL_DEBUG_STRING Pushing text string '8'
DEBUG EVAL_DEBUG_SUBSTRING_EMPTY Popping length 8, start 0, string 0x pushing result 0x
DEBUG EVAL_DEBUG_STRING Pushing text string 'my-value'
DEBUG EVAL_DEBUG_EQUAL Popping 0x6D792D76616C7565 and 0x pushing result 'false'
DEBUG EVAL_RESULT Expression my-class evaluated to 0
Hint: in CB's case, EVAL_DEBUG_*
messages are missing from the logs. I would suggest logging them in this MR if the estimated effort is minimal.
Edited by Peter Davies