From: Stephen Morris Date: Mon, 21 Jan 2013 20:57:57 +0000 (+0000) Subject: [2559] Merge branch 'master' into trac2559 X-Git-Tag: bind10-1.0.0-rc-release~76^2~21^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d117d8720025b9e57fd1cd2eae7792c0700cdfff;p=thirdparty%2Fkea.git [2559] Merge branch 'master' into trac2559 Conflicts: src/bin/dhcp4/config_parser.cc src/bin/dhcp6/config_parser.cc src/bin/dhcp6/dhcp6_srv.h src/lib/dhcpsrv/dhcpsrv_messages.mes src/lib/dhcpsrv/tests/Makefile.am --- d117d8720025b9e57fd1cd2eae7792c0700cdfff diff --cc src/bin/dhcp4/config_parser.cc index c067a6feff,fdb4240375..6ce23f52ce --- a/src/bin/dhcp4/config_parser.cc +++ b/src/bin/dhcp4/config_parser.cc @@@ -18,8 -18,8 +18,9 @@@ #include #include #include +#include #include + #include #include #include #include @@@ -38,6 -38,20 +39,17 @@@ using namespace isc::asiolink namespace { + // Forward declarations of some of the parser classes. + // They are used to define pointer types for these classes. + class BooleanParser; + class StringParser; + class Uint32Parser; + + // Pointers to various parser objects. + typedef boost::shared_ptr BooleanParserPtr; + typedef boost::shared_ptr StringParserPtr; + typedef boost::shared_ptr Uint32ParserPtr; + -/// @brief auxiliary type used for storing element name and its parser -typedef pair ConfigPair; - /// @brief a factory method that will create a parser for a given element name typedef isc::dhcp::DhcpConfigParser* ParserFactory(const std::string& config_id); @@@ -1317,8 -1605,8 +1603,9 @@@ DhcpConfigParser* createGlobalDhcp4Conf factories["interface"] = InterfaceListConfigParser::factory; factories["subnet4"] = Subnets4ListConfigParser::factory; factories["option-data"] = OptionDataListParser::factory; + factories["option-def"] = OptionDefListParser::factory; factories["version"] = StringParser::factory; + factories["lease-database"] = DbAccessParser::factory; FactoryMap::iterator f = factories.find(config_id); if (f == factories.end()) { @@@ -1372,20 -1661,22 +1660,27 @@@ configureDhcp4Server(Dhcpv4Srv&, ConstE // rollback informs whether error occured and original data // have to be restored to global storages. bool rollback = false; - + // config_pair holds the details of the current parser when iterating over - // parser. 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. ++ // 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; try { + // Make parsers grouping. + const std::map& values_map = + config_set->mapValue(); - BOOST_FOREACH(ConfigPair config_pair, values_map) { ++ BOOST_FOREACH(config_pair, values_map) { + ParserPtr parser(createGlobalDhcp4ConfigParser(config_pair.first)); ++ LOG_DEBUG(dhcp4_logger, DBG_DHCP4_DETAIL, DHCP4_PARSER_CREATED) ++ .arg(config_pair.first); + if (config_pair.first == "subnet4") { + subnet_parser = parser; - // Iterate over all independent parsers first (all but subnet4) - // and try to parse the data. - BOOST_FOREACH(config_pair, config_set->mapValue()) { - if (config_pair.first != "subnet4") { - ParserPtr parser(createGlobalDhcp4ConfigParser( - config_pair.first)); - LOG_DEBUG(dhcp4_logger, DBG_DHCP4_DETAIL, DHCP4_PARSER_CREATED1) - .arg(config_pair.first); + } else if (config_pair.first == "option-data") { + option_parser = parser; + + } else { + // Those parsers should be started before other + // parsers so we can call build straight away. independent_parsers.push_back(parser); parser->build(config_pair.second); // The commit operation here may modify the global storage @@@ -1408,19 -1702,17 +1706,21 @@@ } } catch (const isc::Exception& ex) { - answer = - isc::config::createAnswer(1, string("Configuration parsing failed: ") + ex.what()); + LOG_ERROR(dhcp4_logger, DHCP4_PARSER_CREATE_FAIL) + .arg(config_pair.first).arg(ex.what()); + answer = isc::config::createAnswer(1, + string("Configuration parsing failed: ") + ex.what()); + // An error occured, so make sure that we restore original data. rollback = true; } catch (...) { // for things like bad_cast in boost::lexical_cast - answer = - isc::config::createAnswer(1, string("Configuration parsing failed")); + LOG_ERROR(dhcp4_logger, DHCP4_PARSER_CREATE_EXCEPTION) + .arg(config_pair.first); + answer = isc::config::createAnswer(1, + string("Configuration parsing failed")); + // An error occured, so make sure that we restore original data. rollback = true; } @@@ -1436,16 -1728,14 +1736,16 @@@ } } catch (const isc::Exception& ex) { - answer = - isc::config::createAnswer(2, string("Configuration commit failed: ") + ex.what()); + LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_FAIL).arg(ex.what()); - answer = - isc::config::createAnswer(2, string("Configuration commit failed: ") + ex.what()); ++ answer = isc::config::createAnswer(2, ++ string("Configuration commit failed: ") + ex.what()); rollback = true; } catch (...) { // for things like bad_cast in boost::lexical_cast - answer = - isc::config::createAnswer(2, string("Configuration commit failed")); + LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_EXCEPTION); - answer = - isc::config::createAnswer(2, string("Configuration commit failed")); ++ answer = isc::config::createAnswer(2, ++ string("Configuration commit failed")); rollback = true; } diff --cc src/bin/dhcp4/dhcp4_messages.mes index 8c305343c9,02ad0a075a..7f040abba5 --- a/src/bin/dhcp4/dhcp4_messages.mes +++ b/src/bin/dhcp4/dhcp4_messages.mes @@@ -88,41 -115,6 +115,36 @@@ This error is output if the server fail returned to the client into a valid packet. The cause is most likely to be a programming error: please raise a bug report. +% DHCP4_PARSER_COMMIT_EXCEPTION parser failed to commit changes +On receipt of message containing details to a change of the IPv4 DHCP +server configuration, a set of parsers were successfully created, but one +of them failed to commit its changes due to a low-level system exception +being raised. Additional messages may be output indicating the reason. + +% DHCP4_PARSER_COMMIT_FAIL parser failed to commit changes: %1 +On receipt of message containing details to a change of the IPv4 DHCP +server configuration, a set of parsers were successfully created, but +one of them failed to commit its changes. The reason for the failure +is given in the message. + - % DHCP4_PARSER_CREATED1 created parser for configuration element %1 - A debug message output during a configuration update of the IPv4 DHCP - server, notifying that the parser for the specified configuration element - has been successfully created in the first pass through creating parsers - - % DHCP4_PARSER_CREATED2 created parser for configuration element %1 ++% DHCP4_PARSER_CREATED created parser for configuration element %1 +A debug message output during a configuration update of the IPv4 DHCP +server, notifying that the parser for the specified configuration element - has been successfully created in the second pass through creating parsers ++has been successfully created. + +% DHCP4_PARSER_CREATE_FAIL failed to create parser for configuration element %1: %2 +On receipt of message containing details to a change of its configuration, +the IPv4 DHCP server failed to create a parser to decode the contents of the +named configuration element. The reason for the failure is given in the +message. + +% DHCP4_PARSER_CREATE_EXCEPTION failed to create parser for configuration element %1 +On receipt of message containing details to a change of its configuration, +the IPv4 DHCP server failed to create a parser to decode the contents +of the named configuration element. The message has been output in +response to a non-BIND 10 exception being raised. Additional messages +may give further information. + % DHCP4_QUERY_DATA received packet type %1, data is <%2> A debug message listing the data received from the client. diff --cc src/bin/dhcp6/config_parser.cc index 1ded503f16,f2eb34c55f..49cb73cf53 --- a/src/bin/dhcp6/config_parser.cc +++ b/src/bin/dhcp6/config_parser.cc @@@ -18,8 -18,8 +18,9 @@@ #include #include #include + #include #include +#include #include #include #include @@@ -47,6 -48,20 +49,17 @@@ using namespace isc::asiolink namespace { + // Forward declarations of some of the parser classes. + // They are used to define pointer types for these classes. + class BooleanParser; + class StringParser; + class Uint32Parser; + + // Pointers to various parser objects. + typedef boost::shared_ptr BooleanParserPtr; + typedef boost::shared_ptr StringParserPtr; + typedef boost::shared_ptr Uint32ParserPtr; + -/// @brief Auxiliary type used for storing an element name and its parser. -typedef pair ConfigPair; - /// @brief Factory method that will create a parser for a given element name typedef isc::dhcp::DhcpConfigParser* ParserFactory(const std::string& config_id); @@@ -1353,8 -1661,8 +1659,9 @@@ DhcpConfigParser* createGlobalDhcpConfi factories["interface"] = InterfaceListConfigParser::factory; factories["subnet6"] = Subnets6ListConfigParser::factory; factories["option-data"] = OptionDataListParser::factory; + factories["option-def"] = OptionDefListParser::factory; factories["version"] = StringParser::factory; + factories["lease-database"] = DbAccessParser::factory; FactoryMap::iterator f = factories.find(config_id); if (f == factories.end()) { @@@ -1408,19 -1717,22 +1716,28 @@@ configureDhcp6Server(Dhcpv6Srv&, ConstE // rollback informs whether error occured and original data // have to be restored to global storages. bool rollback = false; - // config_pair holds the details of the current parser when iterating over - // parser. 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. ++ // config_pair holds ther 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. + ConfigPair config_pair; try { - // Iterate over all independent parsers first (all but subnet6) - // and try to parse the data. - BOOST_FOREACH(config_pair, config_set->mapValue()) { - if (config_pair.first != "subnet6") { - ParserPtr parser(createGlobalDhcpConfigParser( - config_pair.first)); - LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL, DHCP6_PARSER_CREATED1) - .arg(config_pair.first); + + // Make parsers grouping. + const std::map& values_map = + config_set->mapValue(); - BOOST_FOREACH(ConfigPair config_pair, values_map) { ++ BOOST_FOREACH(config_pair, values_map) { + ParserPtr parser(createGlobalDhcpConfigParser(config_pair.first)); ++ LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL, DHCP6_PARSER_CREATED) ++ .arg(config_pair.first); + if (config_pair.first == "subnet6") { + subnet_parser = parser; + + } else if (config_pair.first == "option-data") { + option_parser = parser; + + } else { + // Those parsers should be started before other + // parsers so we can call build straight away. independent_parsers.push_back(parser); parser->build(config_pair.second); // The commit operation here may modify the global storage @@@ -1471,17 -1782,15 +1791,16 @@@ } } catch (const isc::Exception& ex) { - answer = - isc::config::createAnswer(2, string("Configuration commit failed:") - + ex.what()); + LOG_ERROR(dhcp6_logger, DHCP6_PARSER_COMMIT_FAIL).arg(ex.what()); - answer = - isc::config::createAnswer(2, string("Configuration commit failed:") - + ex.what()); ++ answer = isc::config::createAnswer(2, ++ string("Configuration commit failed:") + ex.what()); // An error occured, so make sure to restore the original data. rollback = true; } catch (...) { // for things like bad_cast in boost::lexical_cast - answer = - isc::config::createAnswer(2, string("Configuration commit failed")); + LOG_ERROR(dhcp6_logger, DHCP6_PARSER_COMMIT_EXCEPTION); - answer = - isc::config::createAnswer(2, string("Configuration commit failed")); ++ answer = isc::config::createAnswer(2, ++ string("Configuration commit failed")); // An error occured, so make sure to restore the original data. rollback = true; } diff --cc src/bin/dhcp6/dhcp6_messages.mes index f80af12e39,c38776ca45..63f5231e34 --- a/src/bin/dhcp6/dhcp6_messages.mes +++ b/src/bin/dhcp6/dhcp6_messages.mes @@@ -172,46 -172,6 +172,41 @@@ This error is output if the server fail returned to the client into a valid packet. The reason is most likely to be to a programming error: please raise a bug report. +% DHCP6_PARSER_COMMIT_EXCEPTION parser failed to commit changes +On receipt of message containing details to a change of the IPv6 DHCP +server configuration, a set of parsers were successfully created, but one +of them failed to commit its changes due to a low-level system exception +being raised. Additional messages may be output indicating the reason. + +% DHCP6_PARSER_COMMIT_FAIL parser failed to commit changes: %1 +On receipt of message containing details to a change of the IPv6 DHCP +server configuration, a set of parsers were successfully created, but +one of them failed to commit its changes. The reason for the failure +is given in the message. + - % DHCP6_PARSER_CREATED1 created parser for configuration element %1 ++% DHCP6_PARSER_CREATED created parser for configuration element %1 +A debug message output during a configuration update of the IPv6 DHCP +server, notifying that the parser for the specified configuration element - has been successfully created in the first pass through creating parsers - - % DHCP6_PARSER_CREATED2 created parser for configuration element %1 - A debug message output during a configuration update of the IPv6 DHCP - server, notifying that the parser for the specified configuration element - has been successfully created in the second pass through creating parsers ++has been successfully created. + +% DHCP6_PARSER_CREATE_FAIL failed to create parser for configuration element %1: %2 +On receipt of message containing details to a change of its configuration, +the IPv6 DHCP server failed to create a parser to decode the contents of the +named configuration element. The reason for the failure is given in the +message. + +% DHCP6_PARSER_CREATE_EXCEPTION failed to create parser for configuration element %1 +On receipt of message containing details to a change of its configuration, +the IPv6 DHCP server failed to create a parser to decode the contents +of the named configuration element. The message has been output in +response to a non-BIND 10 exception being raised. Additional messages +may give further information. + +The most likely cause of this is that the specification file for the server +(which details the allowable contents of the configuration) is not correct for +this version of BIND 10. This former may be the result of an interrupted +installation of an update to BIND 10. + % DHCP6_PROCESS_IA_NA_REQUEST server is processing IA_NA option (duid=%1, iaid=%2, hint=%3) This is a debug message that indicates a processing of received IA_NA option. It may optionally contain an address that may be used by the server diff --cc src/bin/dhcp6/dhcp6_srv.cc index cb943ecad8,e50950f836..1e0b4dae38 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@@ -69,8 -75,29 +75,23 @@@ Dhcpv6Srv::Dhcpv6Srv(uint16_t port IfaceMgr::instance().openSockets6(port); } - setServerID(); + string duid_file = CfgMgr::instance().getDataDir() + "/" + string(SERVER_DUID_FILE); + if (loadServerID(duid_file)) { + LOG_DEBUG(dhcp6_logger, DBG_DHCP6_START, DHCP6_SERVERID_LOADED) + .arg(duid_file); + } else { + generateServerID(); + LOG_INFO(dhcp6_logger, DHCP6_SERVERID_GENERATED) + .arg(duidToString(getServerID())) + .arg(duid_file); + + if (!writeServerID(duid_file)) { + LOG_WARN(dhcp6_logger, DHCP6_SERVERID_WRITE_FAIL) + .arg(duid_file); + } + + } - // Instantiate LeaseMgr - LeaseMgrFactory::create(dbconfig); - LOG_INFO(dhcp6_logger, DHCP6_DB_BACKEND_STARTED) - .arg(LeaseMgrFactory::instance().getType()) - .arg(LeaseMgrFactory::instance().getName()); - // Instantiate allocation engine alloc_engine_.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)); diff --cc src/lib/dhcpsrv/dhcpsrv_messages.mes index 0af1afb78b,8a7610b37a..bf4e1e11ca --- a/src/lib/dhcpsrv/dhcpsrv_messages.mes +++ b/src/lib/dhcpsrv/dhcpsrv_messages.mes @@@ -60,12 -60,11 +60,19 @@@ This is a debug message reporting that returned the specified IPv6 subnet when given the address hint specified as the address is within the subnet. + % DHCPSRV_CFGMGR_SUBNET6_IFACE selected subnet %1 for packet received over interface %2 -This is a debug message reporting that the DHCP configuration manager has -returned the specified IPv6 subnet for a packet received over given interface. -This particular subnet was selected, because it was specified as being directly -reachable over given interface. (see 'interface' parameter in subnet6 definition). ++This is a debug message reporting that the DHCP configuration manager ++has returned the specified IPv6 subnet for a packet received over ++given interface. This particular subnet was selected, because it ++was specified as being directly reachable over given interface. (see ++'interface' parameter in subnet6 definition). ++ +% DHCPSRV_CLOSE_DB closing currently open %1 database +This is a debug message, issued when the DHCP server closes the currently +open lease database. It is issued at program shutdown and whenever +the database access parameters are changed: in the latter case, the +server closes the currently open database, and opens a database using +the new parameters. % DHCPSRV_INVALID_ACCESS invalid database access string: %1 This is logged when an attempt has been made to parse a database access string diff --cc src/lib/dhcpsrv/tests/Makefile.am index 2f77518924,dfe3e785c5..00476c0ceb --- a/src/lib/dhcpsrv/tests/Makefile.am +++ b/src/lib/dhcpsrv/tests/Makefile.am @@@ -30,8 -30,6 +30,7 @@@ libdhcpsrv_unittests_SOURCES = run_uni libdhcpsrv_unittests_SOURCES += addr_utilities_unittest.cc libdhcpsrv_unittests_SOURCES += alloc_engine_unittest.cc libdhcpsrv_unittests_SOURCES += cfgmgr_unittest.cc +libdhcpsrv_unittests_SOURCES += dbaccess_parser_unittest.cc - libdhcpsrv_unittests_SOURCES += hwaddr_unittest.cc libdhcpsrv_unittests_SOURCES += lease_mgr_factory_unittest.cc libdhcpsrv_unittests_SOURCES += lease_mgr_unittest.cc libdhcpsrv_unittests_SOURCES += memfile_lease_mgr_unittest.cc