From 9b4ced98ec9ac964d6cd01219a1670b9c77aa492 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Fri, 11 Oct 2019 16:26:51 +0200 Subject: [PATCH] dnsdist: Don't call SO_BINDTODEVICE with an empty interface name --- pdns/dnsdist-tcp.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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); -- 2.47.2