From fd3e11d169254c5d5567396d1889150b4ff57215 Mon Sep 17 00:00:00 2001 From: Marcin Siodelski Date: Wed, 21 Oct 2015 12:25:04 +0200 Subject: [PATCH] [3977] Improved logging in methods queueing NCRs and reclaiming leases. --- src/lib/dhcpsrv/alloc_engine.cc | 16 +++++++++++++++- src/lib/dhcpsrv/alloc_engine_messages.mes | 12 ++++++++++++ src/lib/dhcpsrv/dhcpsrv_messages.mes | 9 +++++---- src/lib/dhcpsrv/ncr_generator.cc | 14 ++++++++++---- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc index f930244d4d..12d72856ce 100644 --- a/src/lib/dhcpsrv/alloc_engine.cc +++ b/src/lib/dhcpsrv/alloc_engine.cc @@ -14,6 +14,9 @@ #include +#include +#include +#include #include #include #include @@ -22,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -1600,6 +1602,13 @@ void AllocEngine::reclaimExpiredLease(const Lease6Ptr& lease, const DbReclaimMode& reclaim_mode, const CalloutHandlePtr& callout_handle) { + + LOG_DEBUG(alloc_engine_logger, ALLOC_ENGINE_DBG_TRACE, + ALLOC_ENGINE_V6_LEASE_RECLAIM) + .arg(Pkt6::makeLabel(lease->duid_, lease->hwaddr_)) + .arg(lease->addr_.toText()) + .arg(static_cast(lease->prefixlen_)); + // The skip flag indicates if the callouts have taken responsibility // for reclaiming the lease. The callout will set this to true if // it reclaims the lease itself. In this case the reclamation routine @@ -1688,6 +1697,11 @@ AllocEngine::reclaimExpiredLease(const Lease4Ptr& lease, const DbReclaimMode& reclaim_mode, const CalloutHandlePtr& callout_handle) { + LOG_DEBUG(alloc_engine_logger, ALLOC_ENGINE_DBG_TRACE, + ALLOC_ENGINE_V4_LEASE_RECLAIM) + .arg(Pkt4::makeLabel(lease->hwaddr_, lease->client_id_)) + .arg(lease->addr_.toText()); + // The skip flag indicates if the callouts have taken responsibility // for reclaiming the lease. The callout will set this to true if // it reclaims the lease itself. In this case the reclamation routine diff --git a/src/lib/dhcpsrv/alloc_engine_messages.mes b/src/lib/dhcpsrv/alloc_engine_messages.mes index 885f9e273e..d3f03f4526 100644 --- a/src/lib/dhcpsrv/alloc_engine_messages.mes +++ b/src/lib/dhcpsrv/alloc_engine_messages.mes @@ -75,6 +75,11 @@ client sending the DHCPDISCOVER has a reservation for the specified address. The allocation engine will try to offer this address to the client. +% ALLOC_ENGINE_V4_LEASE_RECLAIM %1: reclaiming expired lease for address %2 +This debug message is issued when the server begins reclamation of the +expired DHCPv4 lease. The first argument specifies the client identification +information. The second argument holds the leased IPv4 address. + % ALLOC_ENGINE_V4_LEASE_RECLAMATION_FAILED failed to reclaim the lease %1: %2 This error message is logged when the allocation engine fails to reclaim an expired lease. The reason for the failure is included in the @@ -340,6 +345,13 @@ reserved for it. This informational message signals that the specified client was assigned the prefix reserved for it. +% ALLOC_ENGINE_V6_LEASE_RECLAIM %1: reclaiming expired lease for prefix %2/%3 +This debug message is issued when the server begins reclamation of the +expired DHCPv6 lease. The reclaimed lease may either be an address lease +or delegated prefix. The first argument provides the client identification +information. The other arguments specify the prefix and the prefix length +for the lease. The prefix length for address lease is equal to. + % ALLOC_ENGINE_V6_LEASE_RECLAMATION_FAILED failed to reclaim the lease %1: %2 This error message is logged when the allocation engine fails to reclaim an expired lease. The reason for the failure is included in the diff --git a/src/lib/dhcpsrv/dhcpsrv_messages.mes b/src/lib/dhcpsrv/dhcpsrv_messages.mes index 367d1ba28a..1fc4956932 100644 --- a/src/lib/dhcpsrv/dhcpsrv_messages.mes +++ b/src/lib/dhcpsrv/dhcpsrv_messages.mes @@ -587,11 +587,12 @@ lease from the PostgreSQL database for the specified address. A debug message issued when the server is attempting to update IPv6 lease from the PostgreSQL database for the specified address. -% DHCPSRV_QUEUE_NCR name change request to %1 DNS entry queued: %2 +% DHCPSRV_QUEUE_NCR %1: name change request to %2 DNS entry queued: %3 A debug message which is logged when the NameChangeRequest to add or remove -a DNS entries for a particular lease has been queued. The first parameter of -this log message indicates whether the DNS entry is to be added or removed. -The second parameter carries the details of the NameChangeRequest. +a DNS entries for a particular lease has been queued. The first parameter +includes the client identification information. The second parameter of +indicates whether the DNS entry is to be added or removed. The second +parameter carries the details of the NameChangeRequest. % DHCPSRV_QUEUE_NCR_FAILED queueing %1 name change request failed for lease %2: %3 This error message is logged when sending a name change request diff --git a/src/lib/dhcpsrv/ncr_generator.cc b/src/lib/dhcpsrv/ncr_generator.cc index b408c19c13..4ba96ce7aa 100644 --- a/src/lib/dhcpsrv/ncr_generator.cc +++ b/src/lib/dhcpsrv/ncr_generator.cc @@ -34,12 +34,14 @@ namespace { /// @param identifier Identifier to be used to generate DHCID for /// the DNS update. For DHCPv4 it will be hardware address or client /// identifier. For DHCPv6 it will be a DUID. +/// @param label Client identification information in the textual format. +/// This is used for logging purposes. /// /// @tparam LeasePtrType Pointer to a lease. /// @tparam IdentifierType HW Address, Client Identifier or DUID. template void queueNCRCommon(const NameChangeType& chg_type, const LeasePtrType& lease, - const IdentifierType& identifier) { + const IdentifierType& identifier, const std::string& label) { // Check if there is a need for update. if (!lease || lease->hostname_.empty() || (!lease->fqdn_fwd_ && !lease->fqdn_rev_) @@ -61,6 +63,7 @@ void queueNCRCommon(const NameChangeType& chg_type, const LeasePtrType& lease, lease->valid_lft_)); LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL_DATA, DHCPSRV_QUEUE_NCR) + .arg(label) .arg(chg_type == CHG_ADD ? "add" : "remove") .arg(ncr->toText()); @@ -84,12 +87,14 @@ void queueNCR(const NameChangeType& chg_type, const Lease4Ptr& lease) { if (lease) { // Client id takes precedence over HW address. if (lease->client_id_) { - queueNCRCommon(chg_type, lease, lease->client_id_->getClientId()); + queueNCRCommon(chg_type, lease, lease->client_id_->getClientId(), + Pkt4::makeLabel(lease->hwaddr_, lease->client_id_)); } else { // Client id is not specified for the lease. Use HW address // instead. - queueNCRCommon(chg_type, lease, lease->hwaddr_); + queueNCRCommon(chg_type, lease, lease->hwaddr_, + Pkt4::makeLabel(lease->hwaddr_, lease->client_id_)); } } } @@ -97,7 +102,8 @@ void queueNCR(const NameChangeType& chg_type, const Lease4Ptr& lease) { void queueNCR(const NameChangeType& chg_type, const Lease6Ptr& lease) { // DUID is required to generate NCR. if (lease && lease->duid_) { - queueNCRCommon(chg_type, lease, *(lease->duid_)); + queueNCRCommon(chg_type, lease, *(lease->duid_), + Pkt6::makeLabel(lease->duid_, lease->hwaddr_)); } } -- 2.47.2