Skip to content

Commit

Permalink
dnsdist: Handle HTTP/3 error responses
Browse files Browse the repository at this point in the history
  • Loading branch information
rgacogne committed Nov 23, 2023
1 parent c328edc commit 1c0f17a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
13 changes: 11 additions & 2 deletions pdns/dnsdistdist/doh3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 0 additions & 11 deletions pdns/dnsdistdist/doq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,17 +271,6 @@ class DOQCrossProtocolQuery : public CrossProtocolQuery

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()) {
Expand Down
12 changes: 12 additions & 0 deletions pdns/dnsdistdist/doq.hh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "iputils.hh"
#include "libssl.hh"
#include "noinitvector.hh"
#include "doq.hh"
#include "stat_t.hh"
#include "dnsdist-idstate.hh"

Expand All @@ -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();
Expand Down

0 comments on commit 1c0f17a

Please sign in to comment.