2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 13:37:55 +00:00

[#1405] disable reservatio modes flags if any is explicitly configured

This commit is contained in:
Razvan Becheriu
2020-10-15 18:43:46 +03:00
parent de7ab52458
commit 298be5ee54
2 changed files with 52 additions and 26 deletions

View File

@@ -367,22 +367,22 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
// default values and will insert derived values as well.
mutable_cfg = boost::const_pointer_cast<Element>(config_set);
bool found = false;
ConstElementPtr reservations_out_of_pool = mutable_cfg->get("reservations-out-of-pool");
if (reservations_out_of_pool) {
found = true;
}
ConstElementPtr reservations_in_subnet = mutable_cfg->get("reservations-in-subnet");
if (reservations_in_subnet) {
found = true;
}
ConstElementPtr reservations_global = mutable_cfg->get("reservations-global");
if (reservations_global) {
found = true;
}
ConstElementPtr reservation_mode = mutable_cfg->get("reservation-mode");
if (reservation_mode) {
// log warning for deprecated option
bool found = false;
reservation_mode = mutable_cfg->get("reservations-out-of-pool");
if (reservation_mode) {
found = true;
}
reservation_mode = mutable_cfg->get("reservations-in-subnet");
if (reservation_mode) {
found = true;
}
reservation_mode = mutable_cfg->get("reservations-global");
if (reservation_mode) {
found = true;
}
if (found) {
isc_throw(DhcpConfigError, "invalid use of both 'reservation-mode'"
" and one of 'reservations-out-of-pool'"
@@ -391,6 +391,19 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
}
}
// reset all other reservation flags to overwrite default values.
if (found) {
if (!reservations_out_of_pool) {
mutable_cfg->set("reservations-out-of-pool", Element::create(false));
}
if (!reservations_in_subnet) {
mutable_cfg->set("reservations-in-subnet", Element::create(false));
}
if (!reservations_global) {
mutable_cfg->set("reservations-global", Element::create(false));
}
}
// Relocate dhcp-ddns parameters that have moved to global scope.
// Rule is that a global value overrides the dhcp-ddns value, so
// we need to do this before we apply global defaults.

View File

@@ -468,22 +468,22 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
// default values and will insert derived values as well.
mutable_cfg = boost::const_pointer_cast<Element>(config_set);
bool found = false;
ConstElementPtr reservations_out_of_pool = mutable_cfg->get("reservations-out-of-pool");
if (reservations_out_of_pool) {
found = true;
}
ConstElementPtr reservations_in_subnet = mutable_cfg->get("reservations-in-subnet");
if (reservations_in_subnet) {
found = true;
}
ConstElementPtr reservations_global = mutable_cfg->get("reservations-global");
if (reservations_global) {
found = true;
}
ConstElementPtr reservation_mode = mutable_cfg->get("reservation-mode");
if (reservation_mode) {
// log warning for deprecated option
bool found = false;
reservation_mode = mutable_cfg->get("reservations-out-of-pool");
if (reservation_mode) {
found = true;
}
reservation_mode = mutable_cfg->get("reservations-in-subnet");
if (reservation_mode) {
found = true;
}
reservation_mode = mutable_cfg->get("reservations-global");
if (reservation_mode) {
found = true;
}
if (found) {
isc_throw(DhcpConfigError, "invalid use of both 'reservation-mode'"
" and one of 'reservations-out-of-pool'"
@@ -492,6 +492,19 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
}
}
// reset all other reservation flags to overwrite default values.
if (found) {
if (!reservations_out_of_pool) {
mutable_cfg->set("reservations-out-of-pool", Element::create(false));
}
if (!reservations_in_subnet) {
mutable_cfg->set("reservations-in-subnet", Element::create(false));
}
if (!reservations_global) {
mutable_cfg->set("reservations-global", Element::create(false));
}
}
// Relocate dhcp-ddns parameters that have moved to global scope.
// Rule is that a global value overrides the dhcp-ddns value, so
// we need to do this before we apply global defaults.