]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Handle Quiche >= 0.22.0 14392/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 27 Jun 2024 14:07:20 +0000 (16:07 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 27 Jun 2024 14:07:20 +0000 (16:07 +0200)
Quiche broke its existing API in 0.22.0: https://github.com/cloudflare/quiche/pull/1726
This pull request adds m4 code to detect whether the Quiche version
we are building against is >= 0.22.0, and if it is defines
`HAVE_QUICHE_STREAM_ERROR_CODES` which is later used by the code
using Quiche to know which version of the API to use.

pdns/dnsdistdist/doq.cc
pdns/dnsdistdist/m4/pdns_with_quiche.m4

index e757b1a96883474b5954e7315c32b54e2379459d..7e8a567aa8b6e494564916497fb31458ebada574 100644 (file)
@@ -267,7 +267,12 @@ static bool tryWriteResponse(Connection& conn, const uint64_t streamID, PacketBu
 {
   size_t pos = 0;
   while (pos < response.size()) {
+#ifdef HAVE_QUICHE_STREAM_ERROR_CODES
+    uint64_t quicheErrorCode{0};
+    auto res = quiche_conn_stream_send(conn.d_conn.get(), streamID, &response.at(pos), response.size() - pos, true, &quicheErrorCode);
+#else
     auto res = quiche_conn_stream_send(conn.d_conn.get(), streamID, &response.at(pos), response.size() - pos, true);
+#endif
     if (res == QUICHE_ERR_DONE) {
       response.erase(response.begin(), response.begin() + static_cast<ssize_t>(pos));
       return false;
@@ -606,9 +611,17 @@ static void handleReadableStream(DOQFrontend& frontend, ClientState& clientState
     bool fin = false;
     auto existingLength = streamBuffer.size();
     streamBuffer.resize(existingLength + 512);
+#ifdef HAVE_QUICHE_STREAM_ERROR_CODES
+    uint64_t quicheErrorCode{0};
+    auto received = quiche_conn_stream_recv(conn.d_conn.get(), streamID,
+                                            &streamBuffer.at(existingLength), 512,
+                                            &fin,
+                                            &quicheErrorCode);
+#else
     auto received = quiche_conn_stream_recv(conn.d_conn.get(), streamID,
                                             &streamBuffer.at(existingLength), 512,
                                             &fin);
+#endif
     if (received == 0 || received == QUICHE_ERR_DONE) {
       streamBuffer.resize(existingLength);
       return;
index 5c3297bc7821f45861a1788832a22b93c156d29d..672fe0f79f225c0e4ec30648bf464ed05906e581 100644 (file)
@@ -10,10 +10,17 @@ AC_DEFUN([PDNS_WITH_QUICHE], [
 
   AS_IF([test "x$with_quiche" != "xno"], [
     AS_IF([test "x$with_quiche" = "xyes" -o "x$with_quiche" = "xauto"], [
-      PKG_CHECK_MODULES([QUICHE], [quiche >= 0.15.0], [
+      PKG_CHECK_MODULES([QUICHE], [quiche >= 0.22.0], [
         [HAVE_QUICHE=1]
         AC_DEFINE([HAVE_QUICHE], [1], [Define to 1 if you have quiche])
-      ], [ : ])
+        AC_DEFINE([HAVE_QUICHE_STREAM_ERROR_CODES], [1], [Define to 1 if the Quiche API includes error code in quiche_conn_stream_recv and quiche_conn_stream_send])
+      ], [
+        # Quiche is older than 0.22.0, or no Quiche at all
+        PKG_CHECK_MODULES([QUICHE], [quiche >= 0.15.0], [
+          [HAVE_QUICHE=1]
+          AC_DEFINE([HAVE_QUICHE], [1], [Define to 1 if you have quiche])
+        ], [ : ])
+      ])
     ])
   ])
   AM_CONDITIONAL([HAVE_QUICHE], [test "x$QUICHE_LIBS" != "x"])