From: Razvan Becheriu Date: Thu, 16 Apr 2020 11:42:34 +0000 (+0300) Subject: [#893] reverted changes X-Git-Tag: Kea-1.7.7~48 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f6fd99863b6b5b4f4ee4d06d8bddff57cea23ec6;p=thirdparty%2Fkea.git [#893] reverted changes --- diff --git a/src/bin/dhcp4/json_config_parser.cc b/src/bin/dhcp4/json_config_parser.cc index a234eee0d8..4b89918356 100644 --- a/src/bin/dhcp4/json_config_parser.cc +++ b/src/bin/dhcp4/json_config_parser.cc @@ -10,17 +10,16 @@ #include #include #include -#include -#include #include #include #include +#include +#include #include #include #include #include #include -#include #include #include #include @@ -33,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -40,20 +40,21 @@ #include #include -#include #include #include +#include -#include #include -#include +#include +#include #include #include +#include using namespace std; using namespace isc; -using namespace isc::data; using namespace isc::dhcp; +using namespace isc::data; using namespace isc::asiolink; using namespace isc::hooks; using namespace isc::process; @@ -335,13 +336,13 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set, // have to be restored to global storages. bool rollback = false; // config_pair holds the details of the current parser when iterating over - // the parsers. It is declared outside the loop so in case of error, the - // name of the failing parser can be retrieved within the "catch" clause. + // the parsers. It is declared outside the loops so in case of an error, + // the name of the failing parser can be retrieved in the "catch" clause. ConfigPair config_pair; ElementPtr mutable_cfg; SrvConfigPtr srv_cfg; try { - // Get the staging configuration. + // Get the staging configuration srv_cfg = CfgMgr::instance().getStagingCfg(); // This is a way to convert ConstElementPtr to ElementPtr. @@ -668,14 +669,12 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set, catch (const isc::Exception& ex) { LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_FAIL).arg(ex.what()); answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, ex.what()); - // An error occurred, so make sure to restore the original data. rollback = true; } catch (...) { // For things like bad_cast in boost::lexical_cast LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_EXCEPTION); answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, "undefined configuration" " parsing error"); - // An error occurred, so make sure to restore the original data. rollback = true; } } @@ -692,7 +691,6 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set, err << "during update from config backend database: " << ex.what(); LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_FAIL).arg(err.str()); answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str()); - // An error occurred, so make sure to restore the original data. rollback = true; } catch (...) { // For things like bad_cast in boost::lexical_cast @@ -701,7 +699,6 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set, << "undefined configuration parsing error"; LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_FAIL).arg(err.str()); answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str()); - // An error occurred, so make sure to restore the original data. rollback = true; } } diff --git a/src/lib/dhcpsrv/parsers/simple_parser4.cc b/src/lib/dhcpsrv/parsers/simple_parser4.cc index 4a6a3e03a1..d4e9b0cece 100644 --- a/src/lib/dhcpsrv/parsers/simple_parser4.cc +++ b/src/lib/dhcpsrv/parsers/simple_parser4.cc @@ -6,10 +6,10 @@ #include -#include #include - +#include #include +#include using namespace isc::data; @@ -244,7 +244,7 @@ const SimpleDefaults SimpleParser4::SUBNET4_DEFAULTS = { /// @brief This table defines default values for each IPv4 subnet that is /// part of a shared network /// -/// This is mostly the same as @ref SUBNET4_DEFAULTS, except the parameters +/// This is mostly the same as @ref SUBNET4_DEFAULTS, except two parameters /// that can be derived from shared-network, but cannot from global scope. /// Those are: interface and reservation-mode. const SimpleDefaults SimpleParser4::SHARED_SUBNET4_DEFAULTS = { @@ -254,7 +254,7 @@ const SimpleDefaults SimpleParser4::SHARED_SUBNET4_DEFAULTS = { { "4o6-subnet", Element::string, "" }, }; -/// @brief List of parameters that can be inherited from the global to subnet4 scope. +/// @brief List of parameters that can be inherited to subnet4 scope. /// /// Some parameters may be defined on both global (directly in Dhcp4) and /// subnet (Dhcp4/subnet4/...) scope. If not defined in the subnet scope, @@ -374,10 +374,12 @@ size_t SimpleParser4::setAllDefaults(ElementPtr global) { // Set global defaults first. cnt = setDefaults(global, GLOBAL4_DEFAULTS); - // Now set the defaults for each specified option definition + // Now set option definition defaults for each specified option definition ConstElementPtr option_defs = global->get("option-def"); if (option_defs) { - cnt += setListDefaults(option_defs, OPTION4_DEF_DEFAULTS); + BOOST_FOREACH(ElementPtr option_def, option_defs->listValue()) { + cnt += SimpleParser::setDefaults(option_def, OPTION4_DEF_DEFAULTS); + } } // Set the defaults for option data @@ -413,8 +415,8 @@ size_t SimpleParser4::setAllDefaults(ElementPtr global) { } } - // Set the defaults for dhcp-queue-control. If the element isn't there - // we'll add it. + // Set the defaults for dhcp-queue-control. If the element isn't + // there we'll add it. ConstElementPtr queue_control = global->get("dhcp-queue-control"); ElementPtr mutable_cfg; if (queue_control) { diff --git a/src/lib/dhcpsrv/parsers/simple_parser6.cc b/src/lib/dhcpsrv/parsers/simple_parser6.cc index e01bbf1a5f..f61fa3f964 100644 --- a/src/lib/dhcpsrv/parsers/simple_parser6.cc +++ b/src/lib/dhcpsrv/parsers/simple_parser6.cc @@ -389,13 +389,17 @@ size_t SimpleParser6::setAllDefaults(ElementPtr global) { // Now set the defaults for each specified option definition ConstElementPtr option_defs = global->get("option-def"); if (option_defs) { - cnt += setListDefaults(option_defs, OPTION6_DEF_DEFAULTS); + BOOST_FOREACH(ElementPtr option_def, option_defs->listValue()) { + cnt += SimpleParser::setDefaults(option_def, OPTION6_DEF_DEFAULTS); + } } // Set the defaults for option data ConstElementPtr options = global->get("option-data"); if (options) { - cnt += setListDefaults(options, OPTION6_DEFAULTS); + BOOST_FOREACH(ElementPtr single_option, options->listValue()) { + cnt += SimpleParser::setDefaults(single_option, OPTION6_DEFAULTS); + } } // Now set the defaults for defined subnets