From: Francis Dupont Date: Sun, 24 May 2020 09:39:50 +0000 (+0200) Subject: [#1232] Added a try and log X-Git-Tag: Kea-1.7.9~92 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfff71f89e2d34650c7c07b5eee5ac6d5754b7d4;p=thirdparty%2Fkea.git [#1232] Added a try and log --- diff --git a/src/bin/dhcp4/dhcp4_messages.mes b/src/bin/dhcp4/dhcp4_messages.mes index 7dce137455..52cd29ec61 100644 --- a/src/bin/dhcp4/dhcp4_messages.mes +++ b/src/bin/dhcp4/dhcp4_messages.mes @@ -224,6 +224,14 @@ This message is printed when DHCPv4 server disables an interface from being used to receive DHCPv4 traffic. Sockets on this interface will not be opened by the Interface Manager until interface is enabled. +% DHCP4_DECLINE_FAIL %1: error on decline lease for address %2: %3 +This error message indicates that the software failed to deline a +lease from the lease database due to an error during a database +operation. The first argument includes the client and the transaction +identification information. The second argument holds the IPv4 address +which decline was attempted. The last one contains the reason for +failure. + % DHCP4_DECLINE_LEASE Received DHCPDECLINE for addr %1 from client %2. The lease will be unavailable for %3 seconds. This informational message is printed when a client received an address, but discovered that it is being used by some other device and notified the server by diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index 0af7d0320f..d0684962ba 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -3301,7 +3301,16 @@ Dhcpv4Srv::declineLease(const Lease4Ptr& lease, const Pkt4Ptr& decline, // way. lease->decline(CfgMgr::instance().getCurrentCfg()->getDeclinePeriod()); - LeaseMgrFactory::instance().updateLease4(lease); + try { + LeaseMgrFactory::instance().updateLease4(lease); + } catch (const Exception& ex) { + // Update failed. + LOG_ERROR(lease4_logger, DHCP4_DECLINE_FAIL) + .arg(decline->getLabel()) + .arg(lease->addr_.toText()) + .arg(ex.what()); + return; + } // Remove existing DNS entries for the lease, if any. // queueNCR will do the necessary checks and will skip the update, if not needed. diff --git a/src/bin/dhcp6/dhcp6_messages.cc b/src/bin/dhcp6/dhcp6_messages.cc index 2402b81d5c..1b1a75b084 100644 --- a/src/bin/dhcp6/dhcp6_messages.cc +++ b/src/bin/dhcp6/dhcp6_messages.cc @@ -1,4 +1,8 @@ +<<<<<<< HEAD // File created from ../../../src/bin/dhcp6/dhcp6_messages.mes on Thu May 21 2020 12:11 +======= +// File created from ../../../src/bin/dhcp6/dhcp6_messages.mes on Sun May 24 2020 11:35 +>>>>>>> [#1232] Added a try and log #include #include @@ -45,6 +49,7 @@ extern const isc::log::MessageID DHCP6_DDNS_REQUEST_SEND_FAILED = "DHCP6_DDNS_RE extern const isc::log::MessageID DHCP6_DDNS_RESPONSE_FQDN_DATA = "DHCP6_DDNS_RESPONSE_FQDN_DATA"; extern const isc::log::MessageID DHCP6_DDNS_SEND_FQDN = "DHCP6_DDNS_SEND_FQDN"; extern const isc::log::MessageID DHCP6_DEACTIVATE_INTERFACE = "DHCP6_DEACTIVATE_INTERFACE"; +extern const isc::log::MessageID DHCP6_DECLINE_FAIL = "DHCP6_DECLINE_FAIL"; extern const isc::log::MessageID DHCP6_DECLINE_FAIL_DUID_MISMATCH = "DHCP6_DECLINE_FAIL_DUID_MISMATCH"; extern const isc::log::MessageID DHCP6_DECLINE_FAIL_IAID_MISMATCH = "DHCP6_DECLINE_FAIL_IAID_MISMATCH"; extern const isc::log::MessageID DHCP6_DECLINE_FAIL_LEASE_WITHOUT_DUID = "DHCP6_DECLINE_FAIL_LEASE_WITHOUT_DUID"; @@ -194,6 +199,7 @@ const char* values[] = { "DHCP6_DDNS_RESPONSE_FQDN_DATA", "%1: including FQDN option in the server's response: %2", "DHCP6_DDNS_SEND_FQDN", "sending DHCPv6 Client FQDN Option to the client: %1", "DHCP6_DEACTIVATE_INTERFACE", "deactivate interface %1", + "DHCP6_DECLINE_FAIL", "%1: error on decline lease for address %2: %3", "DHCP6_DECLINE_FAIL_DUID_MISMATCH", "Client %1 sent DECLINE for address %2, but it belongs to client with DUID %3", "DHCP6_DECLINE_FAIL_IAID_MISMATCH", "Client %1 sent DECLINE for address %2, but used a wrong IAID (%3), instead of expected %4", "DHCP6_DECLINE_FAIL_LEASE_WITHOUT_DUID", "Client %1 sent DECLINE for address %2, but the associated lease has no DUID", diff --git a/src/bin/dhcp6/dhcp6_messages.mes b/src/bin/dhcp6/dhcp6_messages.mes index 8a3142e8d0..c04cebe0e5 100644 --- a/src/bin/dhcp6/dhcp6_messages.mes +++ b/src/bin/dhcp6/dhcp6_messages.mes @@ -227,6 +227,14 @@ This message is printed when DHCPv6 server disables an interface from being used to receive DHCPv6 traffic. Sockets on this interface will not be opened by the Interface Manager until interface is enabled. +% DHCP6_DECLINE_FAIL %1: error on decline lease for address %2: %3 +This error message indicates that the software failed to deline a +lease from the lease database due to an error during a database +operation. The first argument includes the client and the transaction +identification information. The second argument holds the IPv6 address +which decline was attempted. The last one contains the reason for +failure. + % DHCP6_DECLINE_FAIL_DUID_MISMATCH Client %1 sent DECLINE for address %2, but it belongs to client with DUID %3 This informational message is printed when a client attempts to decline a lease, but that lease belongs to a different client. The decline request diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 065b33e192..2ed4dc2743 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -3566,7 +3566,16 @@ Dhcpv6Srv::declineLease(const Pkt6Ptr& decline, const Lease6Ptr lease, // way. lease->decline(CfgMgr::instance().getCurrentCfg()->getDeclinePeriod()); - LeaseMgrFactory::instance().updateLease6(lease); + try { + LeaseMgrFactory::instance().updateLease6(lease); + } catch (const Exception& ex) { + // Update failed. + LOG_ERROR(lease6_logger, DHCP6_DECLINE_FAIL) + .arg(decline->getLabel()) + .arg(lease->addr_.toText()) + .arg(ex.what()); + return (false); + } // Check if a lease has flags indicating that the FQDN update has // been performed. If so, create NameChangeRequest which removes