DHCP4 Vendor-Specific Options do not get encapsulated when using the DB Backend (mysql)
Describe the bug
While migrating a DHCP4 json-based configuration to the MySQL DB Backend I noticed that the Vendor-Specific Options (Code 43) do not get encapsulated and instead are transmitted as empty fields. The same configuration with json produces the correct encapsulated option 43.
To Reproduce Steps to reproduce the behavior:
- Configure KEA with the mysql configuration backend and some basic subnet and pool.
"Dhcp4": {
"server-tag": "DHCP",
"interfaces-config": {
"interfaces": [ "eth0" ]
},
"control-socket": {
"socket-type": "unix",
"socket-name": "/tmp/kea4-ctrl-socket"
},
"config-control": {
"config-databases": [{
"type": "mysql",
"name": "dhcp_db",
"host": "10.1.1.2",
"port": 3306,
"user": "kea",
"password": "<super secret pw>"
}],
"config-fetch-wait-time": 20
},
"hooks-libraries": [{
"library": "/usr/lib64/kea/hooks/libdhcp_mysql_cb.so"
}
],
"lease-database": {
"type": "mysql",
"name": "dhcp_db",
"host": "10.1.1.2",
"port": 3306,
"user": "kea",
"password": "<super secret pw>"
},
"hosts-database": {
"type": "mysql",
"name": "dhcp_db",
"host": "10.1.1.2",
"port": 3306,
"user": "kea",
"password": "<super secret pw>"
},
"expired-leases-processing": {
"reclaim-timer-wait-time": 10,
"flush-reclaimed-timer-wait-time": 25,
"hold-reclaimed-time": 3600,
"max-reclaim-leases": 100,
"max-reclaim-time": 250,
"unwarned-reclaim-cycles": 5
},
"renew-timer": 900,
"rebind-timer": 1800,
"valid-lifetime": 3600
}
- Insert the following data into the configuration database:
-- to make a fully working example, a subnet and pool
INSERT INTO dhcp4_subnet (subnet_id, subnet_prefix, relay) VALUES (2, '10.16.0.0/20', '["10.17.0.1"]');
INSERT INTO dhcp4_subnet_server (subnet_id, server_id) VALUES (2, 1);
INSERT INTO dhcp4_pool (id, start_address, end_address, subnet_id) VALUES
(5, INET_ATON('10.16.0.20'), INET_ATON('10.16.15.200'), 2);
-- now the relevant entries
INSERT INTO dhcp4_option_def (id, code, name, space, type, is_array, encapsulate) VALUES
(3, 1, 'acs_url', 'vendor-encapsulated-options-space', 14, 0, '');
INSERT INTO dhcp4_option_def_server (option_def_id, server_id) VALUES (3, 1);
INSERT INTO dhcp4_options (option_id, code, value, formatted_value, space, persistent, dhcp_client_class, dhcp4_subnet_id, host_id, scope_id, user_context, shared_network_name, pool_id) VALUES
(1, 43, NULL, NULL, 'dhcp4', 1, NULL, NULL, NULL, 0, NULL, NULL, NULL),
(2, 1, NULL, 'http://10.10.10.10:8000/', 'vendor-encapsulated-options-space', 1, NULL, NULL, NULL, 0, NULL, NULL, NULL),
(3, 3, NULL, '10.17.0.1', 'dhcp4', 0, NULL, 2, NULL, 1, NULL, NULL, NULL);
INSERT INTO dhcp4_options_server (option_id, server_id) VALUES (1, 1), (2, 1), (3, 1);
- After starting the server the DHCPOFFER contains for example the following data:
options:
type=001, len=004: 4294963200 (uint32)
type=003, len=004: 10.17.0.1
type=012, len=009: "fritz.box" (string)
type=043, len=000:
type=051, len=004: 3600 (uint32)
type=053, len=001: 2 (uint8)
type=054, len=004: 10.1.1.1
type=058, len=004: 900 (uint32)
type=059, len=004: 1800 (uint32)
- See that option 43 does not encapsulate the 'acs_url' sub-option, but remains empty.
Expected behavior
The server is supposed to respond with
options:
type=001, len=004: 4294963200 (uint32)
type=003, len=004: 10.17.0.1
type=012, len=009: "fritz.box" (string)
type=043, len=034:,
options:
type=001, len=032: "http://10.10.10.10:8000/" (string)
type=051, len=004: 3600 (uint32)
type=053, len=001: 2 (uint8)
type=054, len=004: 10.1.1.1
type=058, len=004: 900 (uint32)
type=059, len=004: 1800 (uint32)
which is exactly what the following json configuration (additions into the "Dhcp4" object above) produces:
"Dhcp4": {
"option-def": [
{
"name": "acs_url",
"code": 1,
"type": "string",
"array": false,
"record-types": "",
"space": "vendor-encapsulated-options-space",
"encapsulate": ""
}
],
"option-data": [
{
"name": "vendor-encapsulated-options",
"always-send": true
},
{
"name" : "acs_url",
"space" : "vendor-encapsulated-options-space",
"csv-format" : true,
"data" : "http://10.10.10.10:8000/",
"always-send": true
}
],
"subnet4": [
{
"subnet": "10.16.0.0/20",
"id" : 298,
"pools": [ { "pool": "10.16.0.20 - 10.16.15.200" } ],
"relay": {
"ip-address": "10.17.0.1"
},
"option-data": [
{
"name": "routers",
"space": "dhcp4",
"csv-format": true,
"data": "10.17.0.1"
}
]
}
]
}
Environment:
- Kea version: 2.2.0 (from Cloudsmith repo)
- OS: AlmaLinux release 8.8 (Sapphire Caracal)
- Which features were compiled in (in particular which backends)
- MySQL backend 14.0, library 3.1.21
- PostgreSQL backend 13.0, library 140008
- Memfile backend 2.1
- If/which hooks where loaded in
libdhcp_mysql_cb.so
Additional Information
Contacting you Please via GitLab message.
Edited by Josef Stöckl