Browse Source

[2559] Add some debugging and error messages to the DHCP4/6 servers

Stephen Morris 12 years ago
parent
commit
aae75525fe

+ 13 - 1
src/bin/dhcp4/config_parser.cc

@@ -1373,14 +1373,17 @@ configureDhcp4Server(Dhcpv4Srv& , ConstElementPtr config_set) {
     // rollback informs whether error occured and original data
     // have to be restored to global storages.
     bool rollback = false;
-
+    string current_parser;  // For error messages
     try {
 
         // Iterate over all independent parsers first (all but subnet4)
         // and try to parse the data.
         BOOST_FOREACH(ConfigPair config_pair, config_set->mapValue()) {
             if (config_pair.first != "subnet4") {
+                current_parser = config_pair.first;
                 ParserPtr parser(createGlobalDhcp4ConfigParser(config_pair.first));
+                LOG_DEBUG(dhcp4_logger, DBG_DHCP4_DETAIL, DHCP4_PARSER_CREATED1)
+                          .arg(current_parser);
                 independent_parsers.push_back(parser);
                 parser->build(config_pair.second);
                 // The commit operation here may modify the global storage
@@ -1393,13 +1396,18 @@ configureDhcp4Server(Dhcpv4Srv& , ConstElementPtr config_set) {
         // Process dependent configuration data.
         BOOST_FOREACH(ConfigPair config_pair, config_set->mapValue()) {
             if (config_pair.first == "subnet4") {
+                current_parser = config_pair.first;
                 ParserPtr parser(createGlobalDhcp4ConfigParser(config_pair.first));
+                LOG_DEBUG(dhcp4_logger, DBG_DHCP4_DETAIL, DHCP4_PARSER_CREATED2)
+                          .arg(current_parser);
                 dependent_parsers.push_back(parser);
                 parser->build(config_pair.second);
             }
         }
 
     } catch (const isc::Exception& ex) {
+        LOG_ERROR(dhcp4_logger, DHCP4_PARSER_CREATE_FAIL).arg(current_parser)
+                  .arg(ex.what());
         answer =
             isc::config::createAnswer(1, string("Configuration parsing failed: ") + ex.what());
 
@@ -1408,6 +1416,8 @@ configureDhcp4Server(Dhcpv4Srv& , ConstElementPtr config_set) {
 
     } catch (...) {
         // for things like bad_cast in boost::lexical_cast
+        LOG_ERROR(dhcp4_logger, DHCP4_PARSER_CREATE_EXCEPTION)
+                  .arg(current_parser);
         answer =
             isc::config::createAnswer(1, string("Configuration parsing failed"));
 
@@ -1426,12 +1436,14 @@ configureDhcp4Server(Dhcpv4Srv& , ConstElementPtr config_set) {
             }
         }
         catch (const isc::Exception& ex) {
+            LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_FAIL).arg(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
+            LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_EXCEPTION);
             answer =
                 isc::config::createAnswer(2, string("Configuration commit failed"));
             rollback = true;

+ 35 - 0
src/bin/dhcp4/dhcp4_messages.mes

@@ -88,6 +88,41 @@ This error is output if the server failed to assemble the data to be
 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
+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
+
+% 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.
 

+ 13 - 0
src/bin/dhcp6/config_parser.cc

@@ -1411,12 +1411,16 @@ configureDhcp6Server(Dhcpv6Srv& , ConstElementPtr config_set) {
     // rollback informs whether error occured and original data
     // have to be restored to global storages.
     bool rollback = false;
+    string current_parser;  // For error messages
     try {
         // Iterate over all independent parsers first (all but subnet6)
         // and try to parse the data.
         BOOST_FOREACH(ConfigPair config_pair, config_set->mapValue()) {
             if (config_pair.first != "subnet6") {
+                current_parser = config_pair.first;
                 ParserPtr parser(createGlobalDhcpConfigParser(config_pair.first));
+                LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL, DHCP6_PARSER_CREATED1)
+                          .arg(current_parser);
                 independent_parsers.push_back(parser);
                 parser->build(config_pair.second);
                 // The commit operation here may modify the global storage
@@ -1429,13 +1433,18 @@ configureDhcp6Server(Dhcpv6Srv& , ConstElementPtr config_set) {
         // Process dependent configuration data.
         BOOST_FOREACH(ConfigPair config_pair, config_set->mapValue()) {
             if (config_pair.first == "subnet6") {
+                current_parser = config_pair.first;
                 ParserPtr parser(createGlobalDhcpConfigParser(config_pair.first));
+                LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL, DHCP6_PARSER_CREATED2)
+                          .arg(current_parser);
                 dependent_parsers.push_back(parser);
                 parser->build(config_pair.second);
             }
         }
 
     } catch (const isc::Exception& ex) {
+        LOG_ERROR(dhcp6_logger, DHCP6_PARSER_CREATE_FAIL).arg(current_parser)
+                  .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.
@@ -1443,6 +1452,8 @@ configureDhcp6Server(Dhcpv6Srv& , ConstElementPtr config_set) {
 
     } catch (...) {
         // for things like bad_cast in boost::lexical_cast
+        LOG_ERROR(dhcp6_logger, DHCP6_PARSER_CREATE_EXCEPTION)
+                  .arg(current_parser);
         answer =
             isc::config::createAnswer(1, string("Configuration parsing failed"));
         // An error occured, so make sure that we restore original data.
@@ -1460,6 +1471,7 @@ configureDhcp6Server(Dhcpv6Srv& , ConstElementPtr config_set) {
             }
         }
         catch (const isc::Exception& ex) {
+            LOG_ERROR(dhcp6_logger, DHCP6_PARSER_COMMIT_FAIL).arg(ex.what());
             answer =
                 isc::config::createAnswer(2, string("Configuration commit failed:") 
                                           + ex.what());
@@ -1467,6 +1479,7 @@ configureDhcp6Server(Dhcpv6Srv& , ConstElementPtr config_set) {
             rollback = true;
         } catch (...) {
             // for things like bad_cast in boost::lexical_cast
+            LOG_ERROR(dhcp6_logger, DHCP6_PARSER_COMMIT_EXCEPTION);
             answer =
                 isc::config::createAnswer(2, string("Configuration commit failed"));
             // An error occured, so make sure to restore the original data.

+ 40 - 0
src/bin/dhcp6/dhcp6_messages.mes

@@ -172,6 +172,46 @@ This error is output if the server failed to assemble the data to be
 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
+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
+
+% 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