Browse Source

[3806] Added more traces to the Dhcpv4Srv class.

Marcin Siodelski 10 years ago
parent
commit
ab4d7ad3e7
2 changed files with 50 additions and 42 deletions
  1. 20 10
      src/bin/dhcp4/dhcp4_messages.mes
  2. 30 32
      src/bin/dhcp4/dhcp4_srv.cc

+ 20 - 10
src/bin/dhcp4/dhcp4_messages.mes

@@ -175,7 +175,7 @@ setting of the flag by a callout instructs the server to drop the packet.
 Server completed all the processing (e.g. may have assigned, updated
 or released leases), but the response will not be send to the client.
 
-% DHCP4_HOOK_LEASE4_RELEASE_SKIP DHCPv4 lease was not released because a callout set the skip flag.
+% DHCP4_HOOK_LEASE4_RELEASE_SKIP %1: lease was not released because a callout set the skip flag.
 This debug message is printed when a callout installed on lease4_release
 hook point set the skip flag. For this particular hook point, the
 setting of the flag by a callout instructs the server to not release
@@ -204,6 +204,12 @@ will be only able to offer global options - no addresses will be assigned.
 This debug message means that the server processing that is unique for each
 client class has reported a failure. The response packet will not be sent.
 
+% DHCP4_INFORM_DIRECT_REPLY %1: DHCPACK in reply to the DHCPINFORM will be sent directly to %2
+This debug message is issued when the DHCPACK will be sent directly to the
+client, rather than via a relay. The first argument contains the client
+and transaction identification information. The second argument contains
+the client's address to which the response will be sent.
+
 % DHCP4_INIT_FAIL failed to initialize Kea server: %1
 The server has failed to initialize. This may be because the configuration
 was not successful, or it encountered any other critical error on startup.
@@ -402,18 +408,18 @@ 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.
 
-% DHCP4_RELEASE address %1 belonging to client-id %2, hwaddr %3 was released properly.
+% DHCP4_RELEASE %1: address %2 was released properly.
 This debug message indicates that an address was released properly. It
 is a normal operation during client shutdown.
 
-% DHCP4_RELEASE_EXCEPTION exception %1 while trying to release address %2
+% DHCP4_RELEASE_EXCEPTION %1: while trying to release address %2 an exception occured: %3
 This message is output when an error was encountered during an attempt
 to process a RELEASE message. The error will not affect the client,
 which does not expect any response from the server for RELEASE
 messages. Depending on the nature of problem, it may affect future
 server operation.
 
-% DHCP4_RELEASE_FAIL failed to remove lease for address %1 for duid %2, hwaddr %3
+% DHCP4_RELEASE_FAIL %1: failed to remove lease for address %2
 This error message indicates that the software failed to remove a
 lease from the lease database. It is probably due to an error during a
 database operation: resolution will most likely require administrator
@@ -421,18 +427,20 @@ intervention (e.g. check if DHCP process has sufficient privileges to
 update the database). It may also be triggered if a lease was manually
 removed from the database during RELEASE message processing.
 
-% DHCP4_RELEASE_FAIL_NO_LEASE client (client-id %1, hwaddr %2) tried to release address, %3, but there is no such lease.
-This warning message is printed when client attempts to release a lease,
-but no such lease is known to the server.
+% DHCP4_RELEASE_FAIL_NO_LEASE %1: client is trying to release non-existing lease %2
+This debug message is printed when client attempts to release a lease,
+but no such lease is known to the server. The first argument contains
+the client and transaction identification information. The second
+argument contains the address which the client is trying to release.
 
-% DHCP4_RELEASE_FAIL_WRONG_CLIENT_ID client (client-id %2) tried to release address %1, but it belongs to client (client-id %3)
+% DHCP4_RELEASE_FAIL_WRONG_CLIENT_ID %1: client tried to release address %2, but this address is leased to different client using client id %3
 This warning message indicates that client tried to release an address
 that belongs to a different client. This should not happen in normal
 circumstances and may indicate a misconfiguration of the client.  However,
 since the client releasing the address will stop using it anyway, there
 is a good chance that the situation will correct itself.
 
-% DHCP4_RELEASE_FAIL_WRONG_HWADDR client (client-id %2) tried to release address %1, but sent from a wrong hardware address (%3)
+% DHCP4_RELEASE_FAIL_WRONG_HWADDR %1: client tried to release address %2, but this address is leased to different client using HW address %3
 This warning message indicates that client tried to release an address
 that does belong to it, but the lease information was associated with
 a different hardware address. One possible reason for using different
@@ -463,9 +471,11 @@ supplied its hostname. The first argument includes the client and the
 transaction identification information. The second argument holds the
 generated hostname.
 
-% DHCP4_REQUEST_CLASS_PROCESSING_FAILED client class specific processing failed for DHCPREQUEST
+% DHCP4_REQUEST_CLASS_PROCESSING_FAILED %1: client class specific processing failed for DHCPREQUEST
 This debug message means that the server processing that is unique for each
 client class has reported a failure. The response packet will not be sent.
+The argument contains the client and transaction identification
+information.
 
 % DHCP4_RESPONSE_DATA %1: responding with packet type %2, packet details: "%3"
 A debug message including the detailed data about the packet being sent

+ 30 - 32
src/bin/dhcp4/dhcp4_srv.cc

@@ -1662,34 +1662,30 @@ Dhcpv4Srv::processRelease(Pkt4Ptr& release) {
 
         if (!lease) {
             // No such lease - bogus release
-            LOG_DEBUG(dhcp4_logger, DBG_DHCP4_DETAIL,
-                      DHCP4_RELEASE_FAIL_NO_LEASE)
-                      .arg(client_id ? client_id->toText() : "(no client-id)")
-                      .arg(release->getHWAddr() ?
-                           release->getHWAddr()->toText() : "(no hwaddr info)")
-                      .arg(release->getCiaddr().toText());
+            LOG_DEBUG(lease_logger, DBG_DHCP4_DETAIL, DHCP4_RELEASE_FAIL_NO_LEASE)
+                .arg(release->getLabel())
+                .arg(release->getCiaddr().toText());
             return;
         }
 
         // Does the hardware address match? We don't want one client releasing
-        // second client's leases. Note that we're comparing the hardware
+        // another client's leases. Note that we're comparing the hardware
         // addresses only, not hardware types or sources of the hardware
         // addresses. Thus we don't use HWAddr::equals().
         if (lease->hwaddr_->hwaddr_ != release->getHWAddr()->hwaddr_) {
-            /// @todo: Print hwaddr from lease as part of ticket #2589
-            LOG_DEBUG(dhcp4_logger, DBG_DHCP4_DETAIL, DHCP4_RELEASE_FAIL_WRONG_HWADDR)
+            LOG_DEBUG(lease_logger, DBG_DHCP4_DETAIL, DHCP4_RELEASE_FAIL_WRONG_HWADDR)
+                .arg(release->getLabel())
                 .arg(release->getCiaddr().toText())
-                .arg(client_id ? client_id->toText() : "(no client-id)")
-                .arg(release->getHWAddr()->toText());
+                .arg(lease->hwaddr_->toText(false));
             return;
         }
 
         // Does the lease have client-id info? If it has, then check it with what
         // the client sent us.
         if (lease->client_id_ && client_id && *lease->client_id_ != *client_id) {
-            LOG_DEBUG(dhcp4_logger, DBG_DHCP4_DETAIL, DHCP4_RELEASE_FAIL_WRONG_CLIENT_ID)
+            LOG_DEBUG(lease_logger, DBG_DHCP4_DETAIL, DHCP4_RELEASE_FAIL_WRONG_CLIENT_ID)
+                .arg(release->getLabel())
                 .arg(release->getCiaddr().toText())
-                .arg(client_id->toText())
                 .arg(lease->client_id_->toText());
             return;
         }
@@ -1718,41 +1714,40 @@ Dhcpv4Srv::processRelease(Pkt4Ptr& release) {
             // stage means "drop response".
             if (callout_handle->getSkip()) {
                 skip = true;
-                LOG_DEBUG(dhcp4_logger, DBG_DHCP4_HOOKS,
-                          DHCP4_HOOK_LEASE4_RELEASE_SKIP);
+                LOG_DEBUG(srv_hooks_logger, DBG_DHCP4_HOOKS,
+                          DHCP4_HOOK_LEASE4_RELEASE_SKIP)
+                    .arg(release->getLabel());
             }
         }
 
-        // Ok, hw and client-id match - let's release the lease.
+        // Callout didn't indicate to skip the release process. Let's release
+        // the lease.
         if (!skip) {
             bool success = LeaseMgrFactory::instance().deleteLease(lease->addr_);
 
             if (success) {
                 // Release successful
-                LOG_DEBUG(dhcp4_logger, DBG_DHCP4_DETAIL, DHCP4_RELEASE)
-                    .arg(lease->addr_.toText())
-                    .arg(client_id ? client_id->toText() : "(no client-id)")
-                    .arg(release->getHWAddr()->toText());
+                LOG_DEBUG(lease_logger, DBG_DHCP4_DETAIL, DHCP4_RELEASE)
+                    .arg(release->getLabel())
+                    .arg(lease->addr_.toText());
 
                 if (CfgMgr::instance().ddnsEnabled()) {
                     // Remove existing DNS entries for the lease, if any.
                     queueNameChangeRequest(isc::dhcp_ddns::CHG_REMOVE, lease);
                 }
             } else {
-                // Release failed -
-                LOG_ERROR(dhcp4_logger, DHCP4_RELEASE_FAIL)
-                    .arg(lease->addr_.toText())
-                .arg(client_id ? client_id->toText() : "(no client-id)")
-                    .arg(release->getHWAddr()->toText());
+                // Release failed
+                LOG_ERROR(lease_logger, DHCP4_RELEASE_FAIL)
+                    .arg(release->getLabel())
+                    .arg(lease->addr_.toText());
             }
         }
     } catch (const isc::Exception& ex) {
-        // Rethrow the exception with a bit more data.
-        LOG_ERROR(dhcp4_logger, DHCP4_RELEASE_EXCEPTION)
-            .arg(ex.what())
-            .arg(release->getYiaddr());
+        LOG_ERROR(lease_logger, DHCP4_RELEASE_EXCEPTION)
+            .arg(release->getLabel())
+            .arg(release->getCiaddr())
+            .arg(ex.what());
     }
-
 }
 
 void
@@ -1780,6 +1775,9 @@ Dhcpv4Srv::processInform(Pkt4Ptr& inform) {
     // be cleared (these fields were copied by the copyDefaultFields function).
     // Also Relay Agent Options should be removed if present.
     if (ack->getRemoteAddr() != inform->getGiaddr()) {
+        LOG_DEBUG(packet_logger, DBG_DHCP4_DETAIL, DHCP4_INFORM_DIRECT_REPLY)
+            .arg(inform->getLabel())
+            .arg(ack->getRemoteAddr());
         ack->setHops(0);
         ack->setGiaddr(IOAddress::IPV4_ZERO_ADDRESS());
         ack->delOption(DHO_DHCP_AGENT_OPTIONS);
@@ -1791,8 +1789,8 @@ Dhcpv4Srv::processInform(Pkt4Ptr& inform) {
     /// @todo: decide whether we want to add a new hook point for
     /// doing class specific processing.
     if (!classSpecificProcessing(ex)) {
-        /// @todo add more verbosity here
-        LOG_DEBUG(dhcp4_logger, DBG_DHCP4_BASIC, DHCP4_INFORM_CLASS_PROCESSING_FAILED);
+        LOG_DEBUG(dhcp4_logger, DBG_DHCP4_BASIC, DHCP4_INFORM_CLASS_PROCESSING_FAILED)
+            .arg(inform->getLabel());
     }
 
     return (ex.getResponse());