From 91766237871c4e0044af49d2d839054373259d39 Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Wed, 5 Jul 2017 00:38:40 +0200 Subject: [PATCH] [3389a] Moved re-detect default to simple_parse[46] --- src/bin/dhcp4/json_config_parser.cc | 3 --- src/bin/dhcp4/simple_parser4.cc | 12 ++++++++++++ src/bin/dhcp4/simple_parser4.h | 1 + src/bin/dhcp6/json_config_parser.cc | 3 --- src/bin/dhcp6/simple_parser6.cc | 12 ++++++++++++ src/bin/dhcp6/simple_parser6.h | 1 + 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/bin/dhcp4/json_config_parser.cc b/src/bin/dhcp4/json_config_parser.cc index 35d3f41612..e015280ca4 100644 --- a/src/bin/dhcp4/json_config_parser.cc +++ b/src/bin/dhcp4/json_config_parser.cc @@ -488,9 +488,6 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set, if (check_only) { // No re-detection in check only mode ifaces_cfg->set("re-detect", Element::create(false)); - } else if (!ifaces_cfg->contains("re-detect")) { - // Else the default is to re-detect - ifaces_cfg->set("re-detect", Element::create(true)); } IfacesConfigParser parser(AF_INET); CfgIfacePtr cfg_iface = srv_cfg->getCfgIface(); diff --git a/src/bin/dhcp4/simple_parser4.cc b/src/bin/dhcp4/simple_parser4.cc index 5487c7913a..9dfec3f14f 100644 --- a/src/bin/dhcp4/simple_parser4.cc +++ b/src/bin/dhcp4/simple_parser4.cc @@ -75,6 +75,11 @@ const SimpleDefaults SimpleParser4::SUBNET4_DEFAULTS = { { "4o6-subnet", Element::string, "" }, }; +/// @brief This table defines default values for interfaces for DHCPv4. +const SimpleDefaults SimpleParser4::IFACE4_DEFAULTS = { + { "re-detect", Element::boolean, "true" } +}; + /// @brief List of parameters that can be inherited from the global to subnet4 scope. /// /// Some parameters may be defined on both global (directly in Dhcp4) and @@ -120,6 +125,13 @@ size_t SimpleParser4::setAllDefaults(isc::data::ElementPtr global) { cnt += setListDefaults(subnets, SUBNET4_DEFAULTS); } + // Set the defaults for interfaces config + ConstElementPtr ifaces_cfg = global->get("interfaces-config"); + if (ifaces_cfg) { + ElementPtr mutable_cfg = boost::const_pointer_cast(ifaces_cfg); + cnt += setDefaults(mutable_cfg, IFACE4_DEFAULTS); + } + return (cnt); } diff --git a/src/bin/dhcp4/simple_parser4.h b/src/bin/dhcp4/simple_parser4.h index ac612e9c5b..4e73e31204 100644 --- a/src/bin/dhcp4/simple_parser4.h +++ b/src/bin/dhcp4/simple_parser4.h @@ -41,6 +41,7 @@ public: static const isc::data::SimpleDefaults OPTION4_DEFAULTS; static const isc::data::SimpleDefaults GLOBAL4_DEFAULTS; static const isc::data::SimpleDefaults SUBNET4_DEFAULTS; + static const isc::data::SimpleDefaults IFACE4_DEFAULTS; static const isc::data::ParamsList INHERIT_GLOBAL_TO_SUBNET4; }; diff --git a/src/bin/dhcp6/json_config_parser.cc b/src/bin/dhcp6/json_config_parser.cc index cb733389bc..2646f55e48 100644 --- a/src/bin/dhcp6/json_config_parser.cc +++ b/src/bin/dhcp6/json_config_parser.cc @@ -699,9 +699,6 @@ configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set, if (check_only) { // No re-detection in check only mode ifaces_cfg->set("re-detect", Element::create(false)); - } else if (!ifaces_cfg->contains("re-detect")) { - // Else the default is to re-detect - ifaces_cfg->set("re-detect", Element::create(true)); } IfacesConfigParser parser(AF_INET6); CfgIfacePtr cfg_iface = srv_config->getCfgIface(); diff --git a/src/bin/dhcp6/simple_parser6.cc b/src/bin/dhcp6/simple_parser6.cc index c6883cd70d..89a14b5b06 100644 --- a/src/bin/dhcp6/simple_parser6.cc +++ b/src/bin/dhcp6/simple_parser6.cc @@ -72,6 +72,11 @@ const SimpleDefaults SimpleParser6::SUBNET6_DEFAULTS = { { "interface-id", Element::string, "" }, }; +/// @brief This table defines default values for interfaces for DHCPv6. +const SimpleDefaults SimpleParser6::IFACE6_DEFAULTS = { + { "re-detect", Element::boolean, "true" } +}; + /// @brief List of parameters that can be inherited from the global to subnet6 scope. /// /// Some parameters may be defined on both global (directly in Dhcp6) and @@ -119,6 +124,13 @@ size_t SimpleParser6::setAllDefaults(isc::data::ElementPtr global) { cnt += setListDefaults(subnets, SUBNET6_DEFAULTS); } + // Set the defaults for interfaces config + ConstElementPtr ifaces_cfg = global->get("interfaces-config"); + if (ifaces_cfg) { + ElementPtr mutable_cfg = boost::const_pointer_cast(ifaces_cfg); + cnt += setDefaults(mutable_cfg, IFACE6_DEFAULTS); + } + return (cnt); } diff --git a/src/bin/dhcp6/simple_parser6.h b/src/bin/dhcp6/simple_parser6.h index 590e11a5d2..755f0c2b86 100644 --- a/src/bin/dhcp6/simple_parser6.h +++ b/src/bin/dhcp6/simple_parser6.h @@ -42,6 +42,7 @@ public: static const isc::data::SimpleDefaults OPTION6_DEFAULTS; static const isc::data::SimpleDefaults GLOBAL6_DEFAULTS; static const isc::data::SimpleDefaults SUBNET6_DEFAULTS; + static const isc::data::SimpleDefaults IFACE6_DEFAULTS; static const isc::data::ParamsList INHERIT_GLOBAL_TO_SUBNET6; }; -- 2.47.2