]> granicus.if.org Git - pdns/commitdiff
dnsdist: Don't call SO_BINDTODEVICE with an empty interface name
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 11 Oct 2019 14:26:51 +0000 (16:26 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 11 Oct 2019 14:26:51 +0000 (16:26 +0200)
pdns/dnsdist-tcp.cc

index a387bee4e7f9c9f1c2de9c86c598e0432a8505df..c3906a49aa900778a3269ec038e5125cfc0c7578 100644 (file)
@@ -81,9 +81,11 @@ static std::unique_ptr<Socket> setupTCPDownstream(shared_ptr<DownstreamState>& d
         }
 #endif
 #ifdef SO_BINDTODEVICE
-        int res = setsockopt(result->getHandle(), SOL_SOCKET, SO_BINDTODEVICE, ds->sourceItfName.c_str(), ds->sourceItfName.length());
-        if (res != 0) {
-          vinfolog("Error setting up the interface on backend TCP socket '%s': %s", ds->getNameWithAddr(), stringerror());
+        if (!ds->sourceItfName.empty()) {
+          int res = setsockopt(result->getHandle(), SOL_SOCKET, SO_BINDTODEVICE, ds->sourceItfName.c_str(), ds->sourceItfName.length());
+          if (res != 0) {
+            vinfolog("Error setting up the interface on backend TCP socket '%s': %s", ds->getNameWithAddr(), stringerror());
+          }
         }
 #endif
         result->bind(ds->sourceAddr, false);