Wrong format of a complex DHCP option with suboptions stored in the host database
I am sending the reservation-add command to Kea (from Stork) with the following arguments:
{ "reservation": { "hw-address": "23212345", "option-data": [ { "code": 93, "csv-format": true, "data": "1,12/12", "space": "s46-rule-options" }, { "code": 89, "csv-format": true, "data": "1,2,3,192.0.2.1,3000::/64", "space": "s46-cont-mape-options" }, { "code": 94, "csv-format": true, "space": "dhcp6" } ], "subnet-id": 1 } }
Next, when I get this reservation from the database.
"option-data": [ { "always-send": false, "code": 94, "csv-format": false, "data": "00590018010203C0000201403000000000000000005D0004010C00C0", "name": "s46-cont-mape", "space": "dhcp6" }, { "always-send": false, "code": 89, "csv-format": true, "data": "1,2,3,192.0.2.1,3000::/64", "name": "s46-rule", "space": "s46-cont-mape-options" }, { "always-send": false, "code": 93, "csv-format": true, "data": "1,12/12", "name": "s46-portparams", "space": "s46-rule-options" } ]
Option 94 is an empty option, but in this scenario it has a payload of 00590018010203C0000201403000000000000000005D0004010C00C0
. I presume this is the hexadecimal representation of the suboptions.
From the first look, it comes from the following function:
void OptionDataListParser::parse(const CfgOptionPtr& cfg,
isc::data::ConstElementPtr option_data_list) {
auto option_parser = createOptionDataParser();
BOOST_FOREACH(ConstElementPtr data, option_data_list->listValue()) {
std::pair<OptionDescriptor, std::string> option =
option_parser->parse(data);
// Use the option description to keep the formatted value
cfg->add(option.first, option.second);
cfg->encapsulate();
}
}
It calls cfg->encapsulate()
which appends suboptions to the option. Next, it serializes the option with its suboptions and stores it in the database.