]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Display the query ID and remote IP when parsing fails 3356/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 10 Feb 2016 11:40:09 +0000 (12:40 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 10 Feb 2016 11:40:09 +0000 (12:40 +0100)
pdns/dnsdist.cc

index c87b8f1184f2595ff29466a595ce3e0818606ec0..d6cbd8b3ada23019985829163d8f8d936643174e 100644 (file)
@@ -537,6 +537,7 @@ try
   auto localDynBlock = g_dynblockNMG.getLocal();
   struct msghdr msgh;
   struct iovec iov;
+  uint16_t queryId = 0;
   /* used by HarvestDestinationAddress */
   char cbuf[256];
   remote.sin6.sin6_family=cs->local.sin6.sin6_family;
@@ -549,6 +550,7 @@ try
 #endif
       char* query = packet;
       ssize_t ret = recvmsg(cs->udpFD, &msgh, 0);
+      queryId = 0;
 
       cs->queries++;
       g_stats.queries++;
@@ -595,6 +597,7 @@ try
 #endif
 
       struct dnsheader* dh = (struct dnsheader*) query;
+      queryId = ntohs(dh->id);
 
       if(dh->qr) {   // don't respond to responses
        g_stats.nonCompliantQueries++;
@@ -775,7 +778,7 @@ try
       vinfolog("Got query from %s, relayed to %s", remote.toStringWithPort(), ss->getName());
     }
     catch(std::exception& e){
-      errlog("Got an error in UDP question thread: %s", e.what());
+      errlog("Got an error in UDP question thread while parsing a query from %s, id %d: %s", remote.toStringWithPort(), queryId, e.what());
     }
   }
   return 0;