Client class level options specified in the config backend have empty values on the wire
Suppose the option-data is specified for a class in the Config Backend and it csv-format setting is set to true. The option data is correctly fetched by the DHCP servers from the config backend and the config-get command returns valid option-data setting. However, when a DHCP client asks for this option the server returns it with empty payload (length of 0).
The issue is in the cb_ctl_dhcp4.cc
(and cb_ctl_dhcp6.cc
). The following code fetches updated client classes from the config backend and applies to the runtime server configuration:
if (audit_entries.empty() || !updated_entries.empty()) {
ClientClassDictionary client_classes = getMgr().getPool()->getAllClientClasses4(backend_selector,
server_selector);
// Match expressions are not initialized for classes returned from the config backend.
// We have to ensure to initialize them before they can be used by the server.
client_classes.initMatchExpr(AF_INET);
external_cfg->setClientClassDictionary(boost::make_shared<ClientClassDictionary>(client_classes));
}
That call sets the new dictionary with many classes, each class having cfg_option_
instance. For each such instance we should call createOption()
using appropriate option definitions to prepare on-wire data for these options. Note that we already do it for subnet-level, shared-network-level and other options. For example, see CfgSubnets4::merge
:
// Create the subnet's options based on the given definitions.
(*other_subnet)->getCfgOption()->createOptions(cfg_def);
for (auto pool : (*other_subnet)->getPoolsWritable(Lease::TYPE_V4)) {
pool->getCfgOption()->createOptions(cfg_def);
}
Therefore, we don't observe this issue for option-data other than defined at the client class level.
It is also worth mentioning that a workaround exists for this problem. The option-data at the client class level should be specified with the "csv-format": false
setting and the "data"
should be in the hex format.