From: Remi Gacogne Date: Thu, 27 Jun 2024 14:07:20 +0000 (+0200) Subject: dnsdist: Handle Quiche >= 0.22.0 X-Git-Tag: rec-5.2.0-alpha1~211^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F14392%2Fhead;p=thirdparty%2Fpdns.git dnsdist: Handle Quiche >= 0.22.0 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. --- diff --git a/pdns/dnsdistdist/doq.cc b/pdns/dnsdistdist/doq.cc index e757b1a968..7e8a567aa8 100644 --- a/pdns/dnsdistdist/doq.cc +++ b/pdns/dnsdistdist/doq.cc @@ -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(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; diff --git a/pdns/dnsdistdist/m4/pdns_with_quiche.m4 b/pdns/dnsdistdist/m4/pdns_with_quiche.m4 index 5c3297bc78..672fe0f79f 100644 --- a/pdns/dnsdistdist/m4/pdns_with_quiche.m4 +++ b/pdns/dnsdistdist/m4/pdns_with_quiche.m4 @@ -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"])