]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Fix the lack of IDState for XFR responses
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 10 Jun 2021 13:41:06 +0000 (15:41 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 10 Jun 2021 13:48:59 +0000 (15:48 +0200)
Since we now detect the end of a XFR and reset the is_XFR flag, we
can't rely on it anymore to skip the insertion of the response into
the ring buffer. Set the type of these responses to AXFR and use that
instead.
A better fix would be to make the IDState available even for XFR
responses, at the cost of doing a copy, and perhaps insert an entry
into the ring buffer for the last message.

pdns/dnsdist-tcp.cc
pdns/dnsdistdist/dnsdist-tcp-downstream.cc

index 69ecb90b431a3ecf6d8989c60ef6f599e9466cb1..6603a751910abfae04af91035ee8f7e00e69c96e 100644 (file)
@@ -370,7 +370,7 @@ static IOState sendQueuedResponses(std::shared_ptr<IncomingTCPConnectionState>&
 
 static void handleResponseSent(std::shared_ptr<IncomingTCPConnectionState>& state, const TCPResponse& currentResponse)
 {
-  if (state->d_isXFR) {
+  if (state->d_isXFR || currentResponse.d_idstate.qtype == QType::AXFR || currentResponse.d_idstate.qtype == QType::IXFR) {
     return;
   }
 
index cb76fa6fa17e6dc7a69dc6f6ec5696a2f1164c59..b3ad94801a3e04776a7f145bc9a4c966ce7d65dd 100644 (file)
@@ -483,13 +483,16 @@ IOState TCPConnectionToBackend::handleResponse(std::shared_ptr<TCPConnectionToBa
     TCPResponse response;
     response.d_buffer = std::move(d_responseBuffer);
     response.d_connection = conn;
+    /* could be a IXFR but that does not matter,
+       we only need to know that this is a AXFR or IXFR response */
+    response.d_idstate.qtype = QType::AXFR;
 
     done = isXFRFinished(response, clientConn);
 
     clientConn->handleXFRResponse(clientConn, now, std::move(response));
     if (done) {
       conn->d_usedForXFR = false;
-      d_clientConn->d_isXFR = false;
+      clientConn->d_isXFR = false;
       d_state = State::idle;
       d_clientConn.reset();
       return IOState::Done;