]> granicus.if.org Git - pdns/commitdiff
dnsdist: Set SO_BINDTODEVICE _before_ binding the health check socket
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 3 Oct 2019 13:10:05 +0000 (15:10 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 3 Oct 2019 13:10:05 +0000 (15:10 +0200)
pdns/dnsdist.cc

index fd553dfc72cb09ddd5bb43a01a02d275f638a609..de8f284a45e9a5b242a0ed1e7075dc83966b5328 100644 (file)
@@ -1855,7 +1855,6 @@ try
   sock.setNonBlocking();
   if (!IsAnyAddress(ds->sourceAddr)) {
     sock.setReuseAddr();
-    sock.bind(ds->sourceAddr);
     if (!ds->sourceItfName.empty()) {
 #ifdef SO_BINDTODEVICE
       int res = setsockopt(sock.getHandle(), SOL_SOCKET, SO_BINDTODEVICE, ds->sourceItfName.c_str(), ds->sourceItfName.length());
@@ -1864,6 +1863,7 @@ try
       }
 #endif
     }
+    sock.bind(ds->sourceAddr);
   }
   sock.connect(ds->remote);
   ssize_t sent = udpClientSendRequestToBackend(ds, sock.getHandle(), reinterpret_cast<char*>(&packet[0]), packet.size(), true);