1.5.0-P1: configuration error - Attempt to parse truncated vendor option
name: 1.5.0-P1: configuration error - Attempt to parse truncated vendor option
Describe the bug
The following configuration error is generated when defining option 125 encapsulated option space:
2020-12-02 00:20:23.376 ERROR [kea-dhcp4.dhcp4/130] DHCP4_CONFIG_LOAD_FAIL configuration error using file: kea-dhcp4.conf.test, reason: option data does not match option definition (space: vendor-encapsulated-options-space, code: 125): Attempt to parse truncated vendor option (kea-dhcp4.conf.test:42:19)
2020-12-02 00:20:23.376 ERROR [kea-dhcp4.dhcp4/130] DHCP4_INIT_FAIL failed to initialize Kea server: configuration error using file 'kea-dhcp4.conf.test': option data does not match option definition (space: vendor-encapsulated-options-space, code: 125): Attempt to parse truncated vendor option (kea-dhcp4.conf.test:42:19)
Customer reports that on investigation the problem occurs at:
src/lib/dhcp/libdhcp++.cc source, function unpackVendorOptions4 when parsing option value.
It would appear that for some reason 43.125 is treated as just 125 (parent option) and the vendor ID (4-byte unsigned integer) + length octet + data is expected – and that is where error is thrown. This function is called from OptionVendor class, method unpack in option_vendor.cc source.
See RT #17358
To Reproduce
The following configuration:
{
"Dhcp4": {
"valid-lifetime": 3600,
"echo-client-id": true,
"interfaces-config": {
"interfaces": [
"*"
],
"re-detect": true,
"dhcp-socket-type": "raw",
"outbound-interface": "same-as-inbound"
},
"control-socket": {
"socket-type": "unix",
"socket-name": "/tmp/kea4_command"
},
"lease-database": {
"type": "memfile",
"persist": true,
"name": "/tmp/dhcp4.leases",
"lfc-interval": 3600
},
"sanity-checks": {
"lease-checks": "fix"
},
"subnet4": [
{
"subnet": "10.0.20.0/24",
"match-client-id": true
}
],
"option-def": [
{
"name": "cookie",
"code": 125,
"type": "string",
"space": "ABC"
}
],
"client-classes": [
{
"name": "ABC",
"test": "(option[vendor-class-identifier].text == 'ABC')",
"option-def": [
{
"name": "vendor-encapsulated-options",
"code": 43,
"type": "empty",
"encapsulate": "ABC"
}
],
"option-data": [
{
"name": "cookie",
"space": "ABC",
"data": "1ABCDE"
},
{
"name": "vendor-encapsulated-options"
}
]
}
]
},
"Logging": {
"loggers": [
{
"name": "kea-dhcp4",
"output_options": [
{
"output": "/tmp/kea_log"
}
],
"severity": "DEBUG",
"debuglevel": 99
}
]
}
}
Also note that using a 4 byte string (for example "1APC") does allow Kea to start up