From: Remi Gacogne Date: Fri, 15 Apr 2022 10:35:20 +0000 (+0200) Subject: dnsdist: Use the correct outgoing protocol in our ring buffers X-Git-Tag: auth-4.8.0-alpha0~131^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F11545%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Use the correct outgoing protocol in our ring buffers --- diff --git a/pdns/dnsdist-tcp.cc b/pdns/dnsdist-tcp.cc index 57c079c4fa..e0de9f35e6 100644 --- a/pdns/dnsdist-tcp.cc +++ b/pdns/dnsdist-tcp.cc @@ -257,7 +257,11 @@ static void handleResponseSent(std::shared_ptr& stat double udiff = ids.sentTime.udiff(); vinfolog("Got answer from %s, relayed to %s (%s, %d bytes), took %f usec", ds->d_config.remote.toStringWithPort(), ids.origRemote.toStringWithPort(), (state->d_handler.isTLS() ? "DoT" : "TCP"), currentResponse.d_buffer.size(), udiff); - ::handleResponseSent(ids, udiff, state->d_ci.remote, ds->d_config.remote, static_cast(currentResponse.d_buffer.size()), currentResponse.d_cleartextDH, ds->getProtocol()); + auto backendProtocol = ds->getProtocol(); + if (backendProtocol == dnsdist::Protocol::DoUDP) { + backendProtocol = dnsdist::Protocol::DoTCP; + } + ::handleResponseSent(ids, udiff, state->d_ci.remote, ds->d_config.remote, static_cast(currentResponse.d_buffer.size()), currentResponse.d_cleartextDH, backendProtocol); updateTCPLatency(ds, udiff); } diff --git a/pdns/dnsdistdist/doh.cc b/pdns/dnsdistdist/doh.cc index a03e842a2c..da1e8ef838 100644 --- a/pdns/dnsdistdist/doh.cc +++ b/pdns/dnsdistdist/doh.cc @@ -469,7 +469,11 @@ public: double udiff = du->ids.sentTime.udiff(); vinfolog("Got answer from %s, relayed to %s (https), took %f usec", du->downstream->d_config.remote.toStringWithPort(), du->ids.origRemote.toStringWithPort(), udiff); - handleResponseSent(du->ids, udiff, *dr.remote, du->downstream->d_config.remote, du->response.size(), cleartextDH, du->downstream->getProtocol()); + auto backendProtocol = du->downstream->getProtocol(); + if (backendProtocol == dnsdist::Protocol::DoUDP && du->tcp) { + backendProtocol = dnsdist::Protocol::DoTCP; + } + handleResponseSent(du->ids, udiff, *dr.remote, du->downstream->d_config.remote, du->response.size(), cleartextDH, backendProtocol); ++g_stats.responses; if (du->ids.cs) {