From: Remi Gacogne Date: Wed, 4 Mar 2020 13:03:32 +0000 (+0100) Subject: dnsdist: Only reuse an existing TCP connection if the same server was selected X-Git-Tag: dnsdist-1.5.0-alpha1~12^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c9608387e51f374089ad8441af5a86e34c168b53;p=thirdparty%2Fpdns.git dnsdist: Only reuse an existing TCP connection if the same server was selected --- diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index 32f3279151..4ae3199e08 100644 --- a/pdns/dnsdist-tcp.cc +++ b/pdns/dnsdist-tcp.cc @@ -186,6 +186,14 @@ public: return true; } + bool matches(const std::shared_ptr& ds) const + { + if (!ds || !d_ds) { + return false; + } + return ds == d_ds; + } + private: std::unique_ptr d_socket{nullptr}; std::shared_ptr d_ds{nullptr}; @@ -953,7 +961,7 @@ static void handleQuery(std::shared_ptr& state, stru state->d_proxyProtocolPayloadHasTLV = dq.proxyProtocolValues && !dq.proxyProtocolValues->empty(); } - if (state->d_downstreamConnection && !state->d_proxyProtocolPayloadHasTLV) { + if (state->d_downstreamConnection && !state->d_proxyProtocolPayloadHasTLV && state->d_downstreamConnection->matches(state->d_ds)) { /* we have an existing connection, on which we already sent a Proxy Protocol header with no values (in the previous query had TLV values we would have reset the connection afterwards), so let's reuse it as long as we still don't have any values */