From 8a8f6e58a371bae661273d39ed0eb307cfc84190 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Fri, 4 Oct 2019 10:44:33 +0200 Subject: [PATCH] dnsdist: Also apply SO_BINDTODEVICE to TCP sockets --- pdns/dnsdist-tcp.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index 403fbf6017..a387bee4e7 100644 --- a/pdns/dnsdist-tcp.cc +++ b/pdns/dnsdist-tcp.cc @@ -79,6 +79,12 @@ static std::unique_ptr setupTCPDownstream(shared_ptr& d if (ds->ipBindAddrNoPort) { SSetsockopt(result->getHandle(), SOL_IP, IP_BIND_ADDRESS_NO_PORT, 1); } +#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()); + } #endif result->bind(ds->sourceAddr, false); } -- 2.47.2