]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Handle HTTP/3 error responses
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 23 Nov 2023 13:36:48 +0000 (14:36 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 8 Dec 2023 07:55:07 +0000 (08:55 +0100)
pdns/dnsdistdist/doh3.cc
pdns/dnsdistdist/doq.cc
pdns/dnsdistdist/doq.hh

index 640d0738fdfaad6f2ed006630d82c370bba3b0fb..1a61509110716d9759c66bf4d3140a626bf357f5 100644 (file)
@@ -298,7 +298,11 @@ static void h3_send_response(quiche_conn* quic_conn, quiche_h3_conn* conn, const
     },
   };
   quiche_h3_send_response(conn, quic_conn,
-                          streamID, headers, 2, false);
+                          streamID, headers, 2, len == 0);
+
+  if (len == 0) {
+    return;
+  }
 
   size_t pos = 0;
   while (pos < len) {
@@ -330,7 +334,12 @@ static void handleResponse(DOH3Frontend& frontend, H3Connection& conn, const uin
   else {
     ++frontend.d_errorResponses;
   }
-  h3_send_response(conn, streamID, statusCode, &response.at(0), response.size());
+  if (response.empty()) {
+    quiche_conn_stream_shutdown(conn.d_conn.get(), streamID, QUICHE_SHUTDOWN_WRITE, static_cast<uint64_t>(DOQ_Error_Codes::DOQ_UNSPECIFIED_ERROR));
+  }
+  else {
+    h3_send_response(conn, streamID, statusCode, &response.at(0), response.size());
+  }
 }
 
 static void fillRandom(PacketBuffer& buffer, size_t size)
index e2fc597d132ec43e8bc2dc5bcbde422fce10a2bf..521314f6e5071e4d23a9d8fb6bc0cae6ea849ec5 100644 (file)
@@ -271,17 +271,6 @@ private:
 
 std::shared_ptr<DOQTCPCrossQuerySender> DOQCrossProtocolQuery::s_sender = std::make_shared<DOQTCPCrossQuerySender>();
 
-/* from rfc9250 section-4.3 */
-enum class DOQ_Error_Codes : uint64_t
-{
-  DOQ_NO_ERROR = 0,
-  DOQ_INTERNAL_ERROR = 1,
-  DOQ_PROTOCOL_ERROR = 2,
-  DOQ_REQUEST_CANCELLED = 3,
-  DOQ_EXCESSIVE_LOAD = 4,
-  DOQ_UNSPECIFIED_ERROR = 5
-};
-
 static void handleResponse(DOQFrontend& frontend, Connection& conn, const uint64_t streamID, const PacketBuffer& response)
 {
   if (response.empty()) {
index 64d080bfd11318f6086c6634b6e90f0fc0fb9740..efc50ef218f657e64d2d44d661f7685317ec373d 100644 (file)
@@ -28,6 +28,7 @@
 #include "iputils.hh"
 #include "libssl.hh"
 #include "noinitvector.hh"
+#include "doq.hh"
 #include "stat_t.hh"
 #include "dnsdist-idstate.hh"
 
@@ -36,6 +37,17 @@ struct DownstreamState;
 
 #ifdef HAVE_DNS_OVER_QUIC
 
+/* from rfc9250 section-4.3 */
+enum class DOQ_Error_Codes : uint64_t
+{
+  DOQ_NO_ERROR = 0,
+  DOQ_INTERNAL_ERROR = 1,
+  DOQ_PROTOCOL_ERROR = 2,
+  DOQ_REQUEST_CANCELLED = 3,
+  DOQ_EXCESSIVE_LOAD = 4,
+  DOQ_UNSPECIFIED_ERROR = 5
+};
+
 struct DOQFrontend
 {
   DOQFrontend();