]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1166] Updated code
authorFrancis Dupont <fdupont@isc.org>
Tue, 21 Jul 2020 15:35:01 +0000 (17:35 +0200)
committerFrancis Dupont <fdupont@isc.org>
Thu, 23 Jul 2020 19:33:03 +0000 (21:33 +0200)
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp4/dhcp4_messages.cc
src/bin/dhcp4/dhcp4_messages.h
src/bin/dhcp4/dhcp4_messages.mes
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/bin/dhcp6/dhcp6_messages.cc
src/bin/dhcp6/dhcp6_messages.h
src/bin/dhcp6/dhcp6_messages.mes

index e18bdb90f5f68eb3f7423683dfe0b22d8cbc4152..f29e2cffa195be5d8ac02bf0723a7f8c89aaabed 100644 (file)
@@ -265,8 +265,8 @@ ControlledDhcpv4Srv::commandConfigReloadHandler(const string&,
     } catch (const std::exception& ex) {
         // Log the unsuccessful reconfiguration. The reason for failure
         // should be already logged. Don't rethrow an exception so as
-        // the server keeps working.
-        LOG_ERROR(dhcp4_logger, DHCP4_DYNAMIC_RECONFIGURATION_FAIL)
+        // the control channel perhaps keeps working.
+        LOG_FATAL(dhcp4_logger, DHCP4_DYNAMIC_RECONFIGURATION_FAIL)
             .arg(file);
         return (createAnswer(CONTROL_RESULT_ERROR,
                              "Config reload failed: " + string(ex.what())));
@@ -421,6 +421,13 @@ ControlledDhcpv4Srv::commandConfigSetHandler(const string&,
         // there were problems with the config. As such, we need to back off
         // and revert to the previous logging configuration.
         CfgMgr::instance().getCurrentCfg()->applyLoggingCfg();
+
+        if (CfgMgr::instance().getCurrentCfg()->getSequence() != 0) {
+            // Not initial configuration so someone can believe we reverted
+            // to the previous configuration. It is not the case so be clear
+            // about this.
+            LOG_FATAL(dhcp4_logger, DHCP4_CONFIG_UNRECOVERABLE_ERROR);
+        }
     }
 
     return (result);
index c2ae32a7bf9a34d89f2f4257683f3115f9bea133..56da30e7e307e41e3f1fc15672d17bcd97fa94bb 100644 (file)
@@ -1,4 +1,4 @@
-// File created from ../../../src/bin/dhcp4/dhcp4_messages.mes on Thu Jun 25 2020 13:36
+// File created from ../../../src/bin/dhcp4/dhcp4_messages.mes on Tue Jul 21 2020 17:10
 
 #include <cstddef>
 #include <log/message_types.h>
@@ -36,6 +36,7 @@ extern const isc::log::MessageID DHCP4_CONFIG_OPTION_DUPLICATE = "DHCP4_CONFIG_O
 extern const isc::log::MessageID DHCP4_CONFIG_PACKET_QUEUE = "DHCP4_CONFIG_PACKET_QUEUE";
 extern const isc::log::MessageID DHCP4_CONFIG_RECEIVED = "DHCP4_CONFIG_RECEIVED";
 extern const isc::log::MessageID DHCP4_CONFIG_START = "DHCP4_CONFIG_START";
+extern const isc::log::MessageID DHCP4_CONFIG_UNRECOVERABLE_ERROR = "DHCP4_CONFIG_UNRECOVERABLE_ERROR";
 extern const isc::log::MessageID DHCP4_CONFIG_UNSUPPORTED_OBJECT = "DHCP4_CONFIG_UNSUPPORTED_OBJECT";
 extern const isc::log::MessageID DHCP4_CONFIG_UPDATE = "DHCP4_CONFIG_UPDATE";
 extern const isc::log::MessageID DHCP4_DB_RECONNECT_ATTEMPT_FAILED = "DHCP4_DB_RECONNECT_ATTEMPT_FAILED";
@@ -187,6 +188,7 @@ const char* values[] = {
     "DHCP4_CONFIG_PACKET_QUEUE", "DHCPv4 packet queue info after configuration: %1",
     "DHCP4_CONFIG_RECEIVED", "received configuration %1",
     "DHCP4_CONFIG_START", "DHCPv4 server is processing the following configuration: %1",
+    "DHCP4_CONFIG_UNRECOVERABLE_ERROR", "DHCPv4 server new configuration failed with an error which cannot be recovered",
     "DHCP4_CONFIG_UNSUPPORTED_OBJECT", "DHCPv4 server configuration includes an unsupported object: %1",
     "DHCP4_CONFIG_UPDATE", "updated configuration received: %1",
     "DHCP4_DB_RECONNECT_ATTEMPT_FAILED", "database reconnect failed: %1",
index 408924a064e94fed19ad781998a445523e2840fd..5c04107235a98803fcc79d6fe7c200f24a383e89 100644 (file)
@@ -1,4 +1,4 @@
-// File created from ../../../src/bin/dhcp4/dhcp4_messages.mes on Thu Jun 25 2020 13:36
+// File created from ../../../src/bin/dhcp4/dhcp4_messages.mes on Tue Jul 21 2020 17:10
 
 #ifndef DHCP4_MESSAGES_H
 #define DHCP4_MESSAGES_H
@@ -37,6 +37,7 @@ extern const isc::log::MessageID DHCP4_CONFIG_OPTION_DUPLICATE;
 extern const isc::log::MessageID DHCP4_CONFIG_PACKET_QUEUE;
 extern const isc::log::MessageID DHCP4_CONFIG_RECEIVED;
 extern const isc::log::MessageID DHCP4_CONFIG_START;
+extern const isc::log::MessageID DHCP4_CONFIG_UNRECOVERABLE_ERROR;
 extern const isc::log::MessageID DHCP4_CONFIG_UNSUPPORTED_OBJECT;
 extern const isc::log::MessageID DHCP4_CONFIG_UPDATE;
 extern const isc::log::MessageID DHCP4_DB_RECONNECT_ATTEMPT_FAILED;
index bfc6c372c9e6a221c89882cdae116ee1630d88ff..d824406ebbc83b1c7cd548a9231c1ef147e49c98 100644 (file)
@@ -179,6 +179,11 @@ This is a debug message that is issued every time the server receives a
 configuration. That happens at start up and also when a server configuration
 change is committed by the administrator.
 
+% DHCP4_CONFIG_UNRECOVERABLE_ERROR DHCPv4 server new configuration failed with an error which cannot be recovered
+This fatal error message is issued when a new configuration raised an error
+which cannot be recovered. A correct configuration must be applied as soon
+as possible as the server is no longer working.
+
 % DHCP4_CONFIG_UNSUPPORTED_OBJECT DHCPv4 server configuration includes an unsupported object: %1
 This error message is issued when the configuration includes an unsupported
 object (i.e. a top level element).
@@ -308,7 +313,7 @@ This is the info message logged when the DHCPv4 server starts reconfiguration
 as a result of receiving SIGHUP signal or config-reload command.
 
 % DHCP4_DYNAMIC_RECONFIGURATION_FAIL dynamic server reconfiguration failed with file: %1
-This is an error message logged when the dynamic reconfiguration of the
+This is a fatal error message logged when the dynamic reconfiguration of the
 DHCP server failed.
 
 % DHCP4_EMPTY_HOSTNAME %1: received empty hostname from the client, skipping processing of this option
index 20ea6cfe6bb28fa943bd4c19c2630ea88557bbb6..ff9c637711e35a54f99452fa5059b5e987e03c91 100644 (file)
@@ -269,7 +269,7 @@ ControlledDhcpv6Srv::commandConfigReloadHandler(const string&,
         // Log the unsuccessful reconfiguration. The reason for failure
         // should be already logged. Don't rethrow an exception so as
         // the server keeps working.
-        LOG_ERROR(dhcp6_logger, DHCP6_DYNAMIC_RECONFIGURATION_FAIL)
+        LOG_FATAL(dhcp6_logger, DHCP6_DYNAMIC_RECONFIGURATION_FAIL)
             .arg(file);
         return (createAnswer(CONTROL_RESULT_ERROR,
                              "Config reload failed: " + string(ex.what())));
@@ -424,6 +424,13 @@ ControlledDhcpv6Srv::commandConfigSetHandler(const string&,
         // there were problems with the config. As such, we need to back off
         // and revert to the previous logging configuration.
         CfgMgr::instance().getCurrentCfg()->applyLoggingCfg();
+
+        if (CfgMgr::instance().getCurrentCfg()->getSequence() != 0) {
+            // Not initial configuration so someone can believe we reverted
+            // to the previous configuration. It is not the case so be clear
+            // about this.
+            LOG_FATAL(dhcp6_logger, DHCP6_CONFIG_UNRECOVERABLE_ERROR);
+        }
     }
 
     return (result);
index 6a37909c17cb4b1c84a7d6c6ec20c35f8e5debca..002b915d5d9845091707b74e5e44c8da1c26df9f 100644 (file)
@@ -1,4 +1,4 @@
-// File created from ../../../src/bin/dhcp6/dhcp6_messages.mes on Thu Jun 25 2020 14:35
+// File created from ../../../src/bin/dhcp6/dhcp6_messages.mes on Tue Jul 21 2020 17:17
 
 #include <cstddef>
 #include <log/message_types.h>
@@ -27,6 +27,7 @@ extern const isc::log::MessageID DHCP6_CONFIG_LOAD_FAIL = "DHCP6_CONFIG_LOAD_FAI
 extern const isc::log::MessageID DHCP6_CONFIG_PACKET_QUEUE = "DHCP6_CONFIG_PACKET_QUEUE";
 extern const isc::log::MessageID DHCP6_CONFIG_RECEIVED = "DHCP6_CONFIG_RECEIVED";
 extern const isc::log::MessageID DHCP6_CONFIG_START = "DHCP6_CONFIG_START";
+extern const isc::log::MessageID DHCP6_CONFIG_UNRECOVERABLE_ERROR = "DHCP6_CONFIG_UNRECOVERABLE_ERROR";
 extern const isc::log::MessageID DHCP6_CONFIG_UNSUPPORTED_OBJECT = "DHCP6_CONFIG_UNSUPPORTED_OBJECT";
 extern const isc::log::MessageID DHCP6_CONFIG_UPDATE = "DHCP6_CONFIG_UPDATE";
 extern const isc::log::MessageID DHCP6_DB_BACKEND_STARTED = "DHCP6_DB_BACKEND_STARTED";
@@ -178,6 +179,7 @@ const char* values[] = {
     "DHCP6_CONFIG_PACKET_QUEUE", "DHCPv6 packet queue info after configuration: %1",
     "DHCP6_CONFIG_RECEIVED", "received configuration: %1",
     "DHCP6_CONFIG_START", "DHCPv6 server is processing the following configuration: %1",
+    "DHCP6_CONFIG_UNRECOVERABLE_ERROR", "DHCPv6 server new configuration failed with an error which cannot be recovered",
     "DHCP6_CONFIG_UNSUPPORTED_OBJECT", "DHCPv6 server configuration includes an unsupported object: %1",
     "DHCP6_CONFIG_UPDATE", "updated configuration received: %1",
     "DHCP6_DB_BACKEND_STARTED", "lease database started (type: %1, name: %2)",
index bb9bc10ab5a697e5cd28417ebfbd3ef23e0c30ee..ebbc90cb5bcbf0339b612a54c6b55a4050d82f01 100644 (file)
@@ -1,4 +1,4 @@
-// File created from ../../../src/bin/dhcp6/dhcp6_messages.mes on Thu Jun 25 2020 14:35
+// File created from ../../../src/bin/dhcp6/dhcp6_messages.mes on Tue Jul 21 2020 17:17
 
 #ifndef DHCP6_MESSAGES_H
 #define DHCP6_MESSAGES_H
@@ -28,6 +28,7 @@ extern const isc::log::MessageID DHCP6_CONFIG_LOAD_FAIL;
 extern const isc::log::MessageID DHCP6_CONFIG_PACKET_QUEUE;
 extern const isc::log::MessageID DHCP6_CONFIG_RECEIVED;
 extern const isc::log::MessageID DHCP6_CONFIG_START;
+extern const isc::log::MessageID DHCP6_CONFIG_UNRECOVERABLE_ERROR;
 extern const isc::log::MessageID DHCP6_CONFIG_UNSUPPORTED_OBJECT;
 extern const isc::log::MessageID DHCP6_CONFIG_UPDATE;
 extern const isc::log::MessageID DHCP6_DB_BACKEND_STARTED;
index 01496c95d673ea85698e01831c56eb6b9d05e37c..215871ed3c67c296ea591d1bb646954188917a63 100644 (file)
@@ -124,6 +124,11 @@ This is a debug message that is issued every time the server receives a
 configuration. That happens start up and also when a server configuration
 change is committed by the administrator.
 
+% DHCP6_CONFIG_UNRECOVERABLE_ERROR DHCPv6 server new configuration failed with an error which cannot be recovered
+This fatal error message is issued when a new configuration raised an error
+which cannot be recovered. A correct configuration must be applied as soon
+as possible as the server is no longer working.
+
 % DHCP6_CONFIG_UNSUPPORTED_OBJECT DHCPv6 server configuration includes an unsupported object: %1
 This error message is issued when the configuration includes an unsupported
 object (i.e. a top level element).
@@ -305,7 +310,7 @@ This is the info message logged when the DHCPv6 server starts reconfiguration
 as a result of receiving SIGHUP signal or config-reload command.
 
 % DHCP6_DYNAMIC_RECONFIGURATION_FAIL dynamic server reconfiguration failed with file: %1
-This is an error message logged when the dynamic reconfiguration of the
+This is a fatal error message logged when the dynamic reconfiguration of the
 DHCP server failed.
 
 % DHCP6_FLEX_ID flexible identifier generated for incoming packet: %1