]> granicus.if.org Git - pdns/commitdiff
dnsdist: Mark the remote member of DownstreamState as const
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 28 May 2018 16:29:58 +0000 (18:29 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 28 May 2018 16:29:58 +0000 (18:29 +0200)
pdns/dnsdist.cc
pdns/dnsdist.hh

index 44ec64f42c3b0ca4d3b64c41c99c6a93c5deb46d..c8e0ead05374852f02123fdd08463964263783c7 100644 (file)
@@ -1074,7 +1074,8 @@ static ssize_t udpClientSendRequestToBackend(DownstreamState* ss, const int sd,
     struct msghdr msgh;
     struct iovec iov;
     char cbuf[256];
-    fillMSGHdr(&msgh, &iov, cbuf, sizeof(cbuf), const_cast<char*>(request), requestLen, &ss->remote);
+    ComboAddress remote(ss->remote);
+    fillMSGHdr(&msgh, &iov, cbuf, sizeof(cbuf), const_cast<char*>(request), requestLen, &remote);
     addCMsgSrcAddr(&msgh, cbuf, &ss->sourceAddr, ss->sourceItf);
     result = sendmsg(sd, &msgh, 0);
   }
@@ -1688,7 +1689,15 @@ try
   }
 
   string reply;
-  sock.recvFrom(reply, ds.remote);
+  ComboAddress from;
+  sock.recvFrom(reply, from);
+
+  /* we are using a connected socket but hey.. */
+  if (from != ds.remote) {
+    if (g_verboseHealthChecks)
+      infolog("Invalid health check response received from %s, expecting one from %s", from.toStringWithPort(), ds.remote.toStringWithPort());
+    return false;
+  }
 
   const dnsheader * responseHeader = reinterpret_cast<const dnsheader *>(reply.c_str());
 
index 96a050b8dea1db310a1f031d9bf58fceda5f0c8d..e478a09cf656ad9b49426d76431f12beef8421e8 100644 (file)
@@ -503,7 +503,7 @@ struct DownstreamState
   std::mutex socketsLock;
   std::unique_ptr<FDMultiplexer> mplexer{nullptr};
   std::thread tid;
-  ComboAddress remote;
+  const ComboAddress remote;
   QPSLimiter qps;
   vector<IDState> idStates;
   ComboAddress sourceAddr;