From: Remi Gacogne Date: Fri, 11 Oct 2019 14:26:51 +0000 (+0200) Subject: dnsdist: Don't call SO_BINDTODEVICE with an empty interface name X-Git-Tag: dnsdist-1.4.0-rc4~27^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F8372%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Don't call SO_BINDTODEVICE with an empty interface name --- diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index a387bee4e7..c3906a49aa 100644 --- a/pdns/dnsdist-tcp.cc +++ b/pdns/dnsdist-tcp.cc @@ -81,9 +81,11 @@ static std::unique_ptr setupTCPDownstream(shared_ptr& 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);