Commit be4c905d authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[trac4000] Exception handling in DHCPv6 improved

 - std::exception is now caught
 - try/catch clause added around handleSignal
parent f71885fb
...@@ -242,6 +242,14 @@ probable if you see many such messages. Clients will recover from this, ...@@ -242,6 +242,14 @@ probable if you see many such messages. Clients will recover from this,
but they will most likely get a different IP addresses and experience but they will most likely get a different IP addresses and experience
a brief service interruption. a brief service interruption.
% DHCP6_HANDLE_SIGNAL_EXCEPTION_ISC An ISC exception was thrown while handing signal: %1
This error message is printed when an ISC exception was raised during signal
processing. This likely indicates a coding error and should be reported to ISC.
% DHCP6_HANDLE_SIGNAL_EXCEPTION_STD An standard exception was thrown while handing signal: %1
This error message is printed when a standard type exception was raised during signal
processing. This likely indicates a coding error and should be reported to ISC.
% DHCP6_HOOKS_LIBS_RELOAD_FAIL reload of hooks libraries failed % DHCP6_HOOKS_LIBS_RELOAD_FAIL reload of hooks libraries failed
A "libreload" command was issued to reload the hooks libraries but for A "libreload" command was issued to reload the hooks libraries but for
some reason the reload failed. Other error messages issued from the some reason the reload failed. Other error messages issued from the
......
...@@ -382,7 +382,24 @@ bool Dhcpv6Srv::run() { ...@@ -382,7 +382,24 @@ bool Dhcpv6Srv::run() {
// is called. If the function was called before receivePacket the // is called. If the function was called before receivePacket the
// process could wait up to the duration of timeout of select() to // process could wait up to the duration of timeout of select() to
// terminate. // terminate.
handleSignal(); try {
handleSignal();
} catch (const isc::Exception& e) {
// ISC-derived exception occurred. The nature of this exception
// indicates that it originated from ISC code. If this happens,
// it will be easy to fix as it is in the code that is under
// ISC control.
LOG_ERROR(dhcp6_logger, DHCP6_HANDLE_SIGNAL_EXCEPTION_ISC)
.arg(e.what());
} catch (const std::exception& e) {
// Standard exception occurred. The nature of this exception
// indicates that it was caused in non-ISC code. Fixing this
// issue will be somewhat more difficult than the one caused
// by ISC code.
LOG_ERROR(dhcp6_logger, DHCP6_HANDLE_SIGNAL_EXCEPTION_STD)
.arg(e.what());
}
// Execute ready timers for the lease database, e.g. Lease File Cleanup. // Execute ready timers for the lease database, e.g. Lease File Cleanup.
try { try {
...@@ -585,11 +602,12 @@ bool Dhcpv6Srv::run() { ...@@ -585,11 +602,12 @@ bool Dhcpv6Srv::run() {
// Increase the statistic of dropped packets. // Increase the statistic of dropped packets.
StatsMgr::instance().addValue("pkt6-receive-drop", static_cast<int64_t>(1)); StatsMgr::instance().addValue("pkt6-receive-drop", static_cast<int64_t>(1));
} catch (const isc::Exception& e) { } catch (const std::exception& e) {
// Catch-all exception (at least for ones based on the isc Exception // Catch-all exception (at least for ones based on the isc Exception
// class, which covers more or less all that are explicitly raised // class, which covers more or less all that are explicitly raised
// in the Kea code). Just log the problem and ignore the packet. // in the Kea code), but also the standard one, which may possibly be
// thrown from boost code. Just log the problem and ignore the packet.
// (The problem is logged as a debug message because debug is // (The problem is logged as a debug message because debug is
// disabled by default - it prevents a DDOS attack based on the // disabled by default - it prevents a DDOS attack based on the
// sending of problem packets.) // sending of problem packets.)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment