Browse Source

[3977] Improved logging in methods queueing NCRs and reclaiming leases.

Marcin Siodelski 9 years ago
parent
commit
fd3e11d169

+ 15 - 1
src/lib/dhcpsrv/alloc_engine.cc

@@ -14,6 +14,9 @@
 
 #include <config.h>
 
+#include <dhcp/dhcp6.h>
+#include <dhcp/pkt4.h>
+#include <dhcp/pkt6.h>
 #include <dhcp_ddns/ncr_msg.h>
 #include <dhcpsrv/alloc_engine.h>
 #include <dhcpsrv/alloc_engine_log.h>
@@ -22,7 +25,6 @@
 #include <dhcpsrv/host.h>
 #include <dhcpsrv/lease_mgr_factory.h>
 #include <dhcpsrv/ncr_generator.h>
-#include <dhcp/dhcp6.h>
 #include <hooks/callout_handle.h>
 #include <hooks/hooks_manager.h>
 #include <stats/stats_mgr.h>
@@ -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<int>(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

+ 12 - 0
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

+ 5 - 4
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

+ 10 - 4
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<typename LeasePtrType, typename IdentifierType>
 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_));
     }
 }