Parcourir la source

[2977] Log debug message if the received DNS Update response is invalid.

Marcin Siodelski il y a 12 ans
Parent
commit
64b9c90846
2 fichiers modifiés avec 15 ajouts et 4 suppressions
  1. 5 0
      src/bin/d2/d2_messages.mes
  2. 10 4
      src/bin/d2/dns_client.cc

+ 5 - 0
src/bin/d2/d2_messages.mes

@@ -96,6 +96,11 @@ has been invoked.
 This is a debug message issued when the Dhcp-Ddns application encounters an
 unrecoverable error from within the event loop.
 
+% DHCP_DDNS_INVALID_RESPONSE received response to DNS Update message is malformed: %1
+This is a debug message issued when the DHCP-DDNS application encountered an error
+while decoding a response to DNS Update message. Typically, this error will be
+encountered when a response message is malformed.
+
 % DHCP_DDNS_PROCESS_INIT application init invoked
 This is a debug message issued when the Dhcp-Ddns application enters
 its init method.

+ 10 - 4
src/bin/d2/dns_client.cc

@@ -13,6 +13,7 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 #include <d2/dns_client.h>
+#include <d2/d2_log.h>
 #include <dns/messagerenderer.h>
 
 namespace isc {
@@ -82,17 +83,22 @@ DNSClientImpl::~DNSClientImpl() {
 
 void
 DNSClientImpl::operator()(asiodns::IOFetch::Result result) {
-    // @todo More sanity checks here. Also, there is a question, what happens if
-    // the exception is thrown here.
-
+    // Get the status from IO. If no success, we just call user's callback
+    // and pass the status code.
     DNSClient::Status status = getStatus(result);
-
     if (status == DNSClient::SUCCESS) {
         InputBuffer response_buf(in_buf_->getData(), in_buf_->getLength());
+        // Server's response may be corrupted. In such case, fromWire will
+        // throw an exception. We want to catch this exception to return
+        // appropriate status code to the caller and log this event.
         try {
             response_->fromWire(response_buf);
+
         } catch (const Exception& ex) {
             status = DNSClient::INVALID_RESPONSE;
+            LOG_DEBUG(dctl_logger, DBGLVL_TRACE_DETAIL,
+                      DHCP_DDNS_INVALID_RESPONSE).arg(ex.what());
+
         }
     }