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: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9b4ced98ec9ac964d6cd01219a1670b9c77aa492;p=pdns dnsdist: Don't call SO_BINDTODEVICE with an empty interface name --- diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index a387bee4e..c3906a49a 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);