]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Use the correct outgoing protocol in our ring buffers 11545/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 15 Apr 2022 10:35:20 +0000 (12:35 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 15 Apr 2022 10:35:20 +0000 (12:35 +0200)
pdns/dnsdist-tcp.cc
pdns/dnsdistdist/doh.cc

index 57c079c4fa000c902cbacd97f10744001947b333..e0de9f35e6acd1c826518b0c04fbdbc34f2632cc 100644 (file)
@@ -257,7 +257,11 @@ static void handleResponseSent(std::shared_ptr<IncomingTCPConnectionState>& 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<unsigned int>(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<unsigned int>(currentResponse.d_buffer.size()), currentResponse.d_cleartextDH, backendProtocol);
 
     updateTCPLatency(ds, udiff);
   }
index a03e842a2c3c994f1e9568ab6be1412cbb1221c4..da1e8ef838cd99ccb1d129cb99e443b7690cb59f 100644 (file)
@@ -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) {