From: Francis Dupont Date: Tue, 21 Jul 2020 15:35:01 +0000 (+0200) Subject: [#1166] Updated code X-Git-Tag: Kea-1.7.10~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d2edef7799d3dce313d589fe2382a3ea67f5c4f;p=thirdparty%2Fkea.git [#1166] Updated code --- diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.cc b/src/bin/dhcp4/ctrl_dhcp4_srv.cc index e18bdb90f5..f29e2cffa1 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.cc +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.cc @@ -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); diff --git a/src/bin/dhcp4/dhcp4_messages.cc b/src/bin/dhcp4/dhcp4_messages.cc index c2ae32a7bf..56da30e7e3 100644 --- a/src/bin/dhcp4/dhcp4_messages.cc +++ b/src/bin/dhcp4/dhcp4_messages.cc @@ -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 #include @@ -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", diff --git a/src/bin/dhcp4/dhcp4_messages.h b/src/bin/dhcp4/dhcp4_messages.h index 408924a064..5c04107235 100644 --- a/src/bin/dhcp4/dhcp4_messages.h +++ b/src/bin/dhcp4/dhcp4_messages.h @@ -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; diff --git a/src/bin/dhcp4/dhcp4_messages.mes b/src/bin/dhcp4/dhcp4_messages.mes index bfc6c372c9..d824406ebb 100644 --- a/src/bin/dhcp4/dhcp4_messages.mes +++ b/src/bin/dhcp4/dhcp4_messages.mes @@ -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 diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc index 20ea6cfe6b..ff9c637711 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc @@ -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); diff --git a/src/bin/dhcp6/dhcp6_messages.cc b/src/bin/dhcp6/dhcp6_messages.cc index 6a37909c17..002b915d5d 100644 --- a/src/bin/dhcp6/dhcp6_messages.cc +++ b/src/bin/dhcp6/dhcp6_messages.cc @@ -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 #include @@ -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)", diff --git a/src/bin/dhcp6/dhcp6_messages.h b/src/bin/dhcp6/dhcp6_messages.h index bb9bc10ab5..ebbc90cb5b 100644 --- a/src/bin/dhcp6/dhcp6_messages.h +++ b/src/bin/dhcp6/dhcp6_messages.h @@ -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; diff --git a/src/bin/dhcp6/dhcp6_messages.mes b/src/bin/dhcp6/dhcp6_messages.mes index 01496c95d6..215871ed3c 100644 --- a/src/bin/dhcp6/dhcp6_messages.mes +++ b/src/bin/dhcp6/dhcp6_messages.mes @@ -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