]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1232] Added a try and log
authorFrancis Dupont <fdupont@isc.org>
Sun, 24 May 2020 09:39:50 +0000 (11:39 +0200)
committerFrancis Dupont <fdupont@isc.org>
Thu, 11 Jun 2020 12:34:31 +0000 (14:34 +0200)
src/bin/dhcp4/dhcp4_messages.mes
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp6/dhcp6_messages.cc
src/bin/dhcp6/dhcp6_messages.mes
src/bin/dhcp6/dhcp6_srv.cc

index 7dce1374551efdffd1c9f8ef1a0b0bf3ce3377b7..52cd29ec6135cc7d7759a11ce870e60bc4507ab4 100644 (file)
@@ -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
index 0af7d0320fbf04cef8f1da2e1f71e487437ee3cd..d0684962ba3cdac03a7acb271b942b93715d7abb 100644 (file)
@@ -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.
index 2402b81d5c62832a6c0da632c3abf9c677cd4d9b..1b1a75b084411d68a031d9c6376091527eb35209 100644 (file)
@@ -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 <cstddef>
 #include <log/message_types.h>
@@ -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",
index 8a3142e8d02005923c23fe995faea41bf9192301..c04cebe0e54d603385a37d0f8ae84203cc3517e1 100644 (file)
@@ -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
index 065b33e192e3b0390b0603972ed6d5fe86014c32..2ed4dc274389f89a1840508c204a0659bbb34d28 100644 (file)
@@ -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