From: Francis Dupont Date: Mon, 27 Jul 2026 14:22:49 +0000 (+0200) Subject: [#4555] Addressed comment X-Git-Tag: Kea-3.3.0^0 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=HEAD;p=thirdparty%2Fkea.git [#4555] Addressed comment --- diff --git a/src/bin/dhcp4/dhcp4_messages.cc b/src/bin/dhcp4/dhcp4_messages.cc index 7d5b6fddfa..b2b94a4418 100644 --- a/src/bin/dhcp4/dhcp4_messages.cc +++ b/src/bin/dhcp4/dhcp4_messages.cc @@ -362,7 +362,7 @@ const char* values[] = { "DHCP4_SECURITY_CHECKS_DISABLED", "Invoked with command line option -X, Security checks are disabled!!", "DHCP4_SERVER_FAILED", "server failed: %1", "DHCP4_SERVER_INITIATED_DECLINE", "%1: Lease for addr %2 has been found to be already in use. The lease will be unavailable for %3 seconds.", - "DHCP4_SERVER_INITIATED_DECLINE_ADD_FAILED", "%1: error adding a lease for address %2", + "DHCP4_SERVER_INITIATED_DECLINE_ADD_FAILED", "%1: error adding a lease for address %2: %3", "DHCP4_SERVER_INITIATED_DECLINE_RESOURCE_BUSY", "%1: error declining a lease for address %2", "DHCP4_SERVER_INITIATED_DECLINE_UPDATE_FAILED", "%1: error updating lease for address %2", "DHCP4_SHUTDOWN", "server shutdown", diff --git a/src/bin/dhcp4/dhcp4_messages.mes b/src/bin/dhcp4/dhcp4_messages.mes index 22d690b8d2..b8efaeb6d6 100644 --- a/src/bin/dhcp4/dhcp4_messages.mes +++ b/src/bin/dhcp4/dhcp4_messages.mes @@ -1137,11 +1137,11 @@ supposed to use. The server will fully recover from this situation, but if the underlying problem of a misconfigured or rogue device is not solved, this address may be declined again in the future. -% DHCP4_SERVER_INITIATED_DECLINE_ADD_FAILED %1: error adding a lease for address %2 +% DHCP4_SERVER_INITIATED_DECLINE_ADD_FAILED %1: error adding a lease for address %2: %3 This error message indicates that the server failed to add a DECLINED lease to the lease store. The first argument includes the client and the transaction identification information. The second argument holds the IPv4 address for which -the decline was attempted. +the decline was attempted, the last one the error message. % DHCP4_SERVER_INITIATED_DECLINE_RESOURCE_BUSY %1: error declining a lease for address %2 This error message indicates that while one server thread was attempting to mark diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index 9a8dc35a74..d6196164b7 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -4536,16 +4536,15 @@ Dhcpv4Srv::serverDecline(hooks::CalloutHandlePtr& callout_handle, Pkt4Ptr& query } if (!lease_exists) { - bool done; try { - done = LeaseMgrFactory::instance().addLease(lease); + if (!LeaseMgrFactory::instance().addLease(lease)) { + isc_throw(Unexpected, "lease already exists"); + } } catch (const Exception& ex) { - done = false; - } - if (!done) { LOG_ERROR(lease4_logger, DHCP4_SERVER_INITIATED_DECLINE_ADD_FAILED) .arg(query->getLabel()) - .arg(lease->addr_.toText()); + .arg(lease->addr_.toText()) + .arg(ex.what()); return; } }