Options with space dont get encapsulated from hosts database
Describe the bug
I have static option-definitions for ipxe namespace, from #2366 (comment 284084). Then, I have a few records for my host reservation in postgresql database, as the dump shows:
COPY public.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, modification_ts) FROM stdin;
18 175 \N \N \N f \N \N 4 3 \N \N \N 2023-04-01 13:15:54.656377+00
21 190 \\x69736373692d626f6f74 \N ipxe f \N \N 4 3 \N \N \N 2023-04-01 14:24:30.740714+00
22 191 \\x694b454d65784e6961663364 \N ipxe f \N \N 4 3 \N \N \N 2023-04-01 14:24:39.73297+00
23 203 \\x69716e2e323032322d30342e636c6f75642e6b776562733a6666 \N \N f \N \N 4 3 \N \N \N 2023-04-01 14:26:14.582959+00
24 17 \\x69736373693a3139322e3136382e382e36353a3a3a3a69716e2e323030352d31302e6f72672e667265656e61732e63746c3a69736373692d626f6f74 \N \N f \N \N 4 3 \N \N \N 2023-04-01 14:29:07.290341+00
25 176 \\x01 \N ipxe f \N \N 4 3 \N \N \N 2023-04-01 14:31:35.581516+00
\.
Howewer, options in space ipxe
dont get added, encapsulated.
To Reproduce Steps to reproduce the behavior:
-
Run Kea dhcpv4 with debug logging
-
Start up a vm with kvm without disk to boot with pxe
-
Observe debug output Expected behavior Expected the same behavior with the following static configuration snippet:
-
See that option 170 is requested, howewer the response contains an empty value for that option.
"reservations": [
{
"hw-address": "00:11:...",
"option-data": [
{
"code": 175
},
{
"code": 190,
"space": "ipxe",
"data": "iscsi-boot"
}
...
]
}
]
Environment:
- Kea version: 2.2.0
- OS: Debian 11
- Compiled with postgresql backend
- No hook libraries
Additional Information
Seems that this little patch would fix my issue:
diff --git a/src/lib/dhcpsrv/pgsql_host_data_source.cc b/src/lib/dhcpsrv/pgsql_host_data_source.cc
index a1251be692..5c438aac17 100644
--- a/src/lib/dhcpsrv/pgsql_host_data_source.cc
+++ b/src/lib/dhcpsrv/pgsql_host_data_source.cc
@@ -2530,6 +2530,11 @@ PgSqlHostDataSourceImpl::getHostCollection(PgSqlHostContextPtr& ctx,
<< tagged_statements[stindex].name);
}
}
+
+ for (auto& host : result) {
+ boost::const_pointer_cast<Host>(host)->getCfgOption4()->encapsulate();
+ boost::const_pointer_cast<Host>(host)->getCfgOption6()->encapsulate();
+ }
}
ConstHostPtr
Edited by Marcin Godzina