]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
doq: spell checking, formating, comments cleaning
authorCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Tue, 19 Sep 2023 16:51:30 +0000 (18:51 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 9 Oct 2023 11:36:47 +0000 (13:36 +0200)
.github/actions/spell-check/allow.txt
pdns/dnsdist-idstate.hh
pdns/dnsdistdist/doq.cc
pdns/dnsdistdist/doq.hh

index d51b7970d3a8fce7a757ab8dc017de279d2240d4..a902870fb4cbc1fa6dc45c00a16699b558b957b6 100644 (file)
@@ -829,6 +829,7 @@ dontdrop
 dontinclude
 dontqueries
 DONTWAIT
+DOQ
 doquery
 dosec
 dotests
index ddc69475401d62f8a74df927b3f9ada0e6de4f6c..63daead6026509f6d97718d2dd7127b1477e7c52 100644 (file)
@@ -131,7 +131,6 @@ struct InternalQueryState
   std::unique_ptr<ProtoBufData> d_protoBufData{nullptr};
   boost::optional<uint32_t> tempFailureTTL{boost::none}; // 8
   ClientState* cs{nullptr}; // 8
-
   std::unique_ptr<DOHUnitInterface> du; // 8
   size_t d_proxyProtocolPayloadSize{0}; // 8
   int32_t d_streamID{-1}; // 4
index d56059273cbb4df2a5b481651ead16897c89cd54..8d704a17dca29dd02908841d8c69613c12f34bbb 100644 (file)
@@ -32,7 +32,6 @@
 #include "dnsdist-ecs.hh"
 #include "dnsdist-proxy-protocol.hh"
 
-
 static void sendBackDOQUnit(DOQUnitUniquePtr&& du, const char* description);
 class DOQServerConfig
 {
@@ -55,7 +54,7 @@ public:
 
 #if 0
 #define DEBUGLOG_ENABLED
-#define DEBUGLOG(x) std::cerr<<x<<std::endl;
+#define DEBUGLOG(x) std::cerr << x << std::endl;
 #else
 #define DEBUGLOG(x)
 #endif
@@ -100,7 +99,6 @@ public:
 
       dr.ids.doqu = std::move(du);
 
-
       if (!processResponse(dr.ids.doqu->response, *localRespRuleActions, *localCacheInsertedRespRuleActions, dr, false)) {
         if (dr.ids.doqu) {
 
@@ -197,7 +195,7 @@ public:
     auto& ids = query.d_idstate;
     DNSResponse dr(ids, query.d_buffer, downstream);
     return dr;
-   }
+  }
 
   DOQUnitUniquePtr&& releaseDU()
   {
@@ -210,14 +208,14 @@ private:
 
 std::shared_ptr<DOQTCPCrossQuerySender> DOQCrossProtocolQuery::s_sender = std::make_shared<DOQTCPCrossQuerySender>();
 
-/* Always called from the main DoQ thread */
 static void handleResponse(DOQFrontend& df, Connection& conn, const uint64_t streamID, const PacketBuffer& response)
 {
   if (response.size() == 0) {
     quiche_conn_stream_shutdown(conn.d_conn.get(), streamID, QUICHE_SHUTDOWN_WRITE, 0x5);
-  } else {
+  }
+  else {
     uint16_t responseSize = static_cast<uint16_t>(response.size());
-    const uint8_t sizeBytes[] = { static_cast<uint8_t>(responseSize / 256), static_cast<uint8_t>(responseSize % 256) };
+    const uint8_t sizeBytes[] = {static_cast<uint8_t>(responseSize / 256), static_cast<uint8_t>(responseSize % 256)};
     auto res = quiche_conn_stream_send(conn.d_conn.get(), streamID, sizeBytes, sizeof(sizeBytes), false);
     if (res == sizeof(sizeBytes)) {
       res = quiche_conn_stream_send(conn.d_conn.get(), streamID, response.data(), response.size(), true);
@@ -270,7 +268,6 @@ static std::optional<PacketBuffer> getCID()
   int rng = open("/dev/urandom", O_RDONLY);
   if (rng < 0) {
     return std::nullopt;
-
   }
   PacketBuffer buffer;
   buffer.resize(LOCAL_CONN_ID_LEN);
@@ -374,17 +371,19 @@ static std::optional<std::reference_wrapper<Connection>> createConnection(Quiche
 {
   auto quicheConn = QuicheConnection(quiche_accept(serverSideID.data(), serverSideID.size(),
                                                    originalDestinationID.data(), originalDestinationID.size(),
-                                                   (struct sockaddr*) &local,
+                                                   (struct sockaddr*)&local,
                                                    local.getSocklen(),
-                                                   (struct sockaddr*) &peer,
+                                                   (struct sockaddr*)&peer,
                                                    peer.getSocklen(),
-                                                   config.get()), quiche_conn_free);
+                                                   config.get()),
+                                     quiche_conn_free);
   auto conn = Connection(peer, std::move(quicheConn));
-  auto pair = s_connections.emplace(serverSideID,  std::move(conn));
+  auto pair = s_connections.emplace(serverSideID, std::move(conn));
   return pair.first->second;
 }
 
-static void flushEgress(Socket& sock, Connection& conn) {
+static void flushEgress(Socket& sock, Connection& conn)
+{
   std::array<uint8_t, MAX_DATAGRAM_SIZE> out;
   quiche_send_info send_info;
 
@@ -398,11 +397,9 @@ static void flushEgress(Socket& sock, Connection& conn) {
     if (written < 0) {
       return;
     }
-
+    // FIXME pacing (as send_info.at should tell us when to send the packet) ?
     sock.sendTo(reinterpret_cast<const char*>(out.data()), written, conn.d_peer);
   }
-
-  // FIXME: update timers
 }
 
 std::unique_ptr<CrossProtocolQuery> getDOQCrossProtocolQueryFromDQ(DNSQuestion& dq, bool isResponse)
@@ -413,7 +410,7 @@ std::unique_ptr<CrossProtocolQuery> getDOQCrossProtocolQueryFromDQ(DNSQuestion&
 
   auto du = std::move(dq.ids.doqu);
   if (&dq.ids != &du->ids) {
-   du->ids = std::move(dq.ids);
+    du->ids = std::move(dq.ids);
   }
 
   du->ids.origID = dq.getHeader()->id;
@@ -439,11 +436,9 @@ static void processDOQQuery(DOQUnitUniquePtr&& unit)
 {
   const auto handleImmediateResponse = [](DOQUnitUniquePtr&& du, const char* reason) {
     DEBUGLOG("handleImmediateResponse() reason=" << reason);
-      auto conn = getConnection(du->serverConnID);
-      handleResponse(*du->dsc->df, *conn, du->streamID, du->response);
-      /* so the unique pointer is stored in the InternalState which itself is stored in the unique pointer itself. We likely need
-         a better design, but for now let's just reset the internal one since we know it is no longer needed. */
-      du->ids.doqu.reset();
+    auto conn = getConnection(du->serverConnID);
+    handleResponse(*du->dsc->df, *conn, du->streamID, du->response);
+    du->ids.doqu.reset();
   };
 
   auto& ids = unit->ids;
@@ -460,8 +455,8 @@ static void processDOQQuery(DOQUnitUniquePtr&& unit)
     ClientState& cs = *dsc->cs;
 
     if (du->query.size() < sizeof(dnsheader)) {
-      // ++dnsdist::metrics::g_stats.nonCompliantQueries;
-      // ++cs.nonCompliantQueries;
+      ++dnsdist::metrics::g_stats.nonCompliantQueries;
+      ++cs.nonCompliantQueries;
       struct dnsheader* dh = reinterpret_cast<struct dnsheader*>(du->query.data());
       dh->rcode = RCode::ServFail;
       dh->qr = true;
@@ -471,8 +466,8 @@ static void processDOQQuery(DOQUnitUniquePtr&& unit)
       return;
     }
 
-    // ++cs.queries;
-    // ++dnsdist::metrics::g_stats.queries;
+    ++cs.queries;
+    ++dnsdist::metrics::g_stats.queries;
     du->ids.queryRealTime.start();
 
     {
@@ -528,6 +523,11 @@ static void processDOQQuery(DOQUnitUniquePtr&& unit)
       return;
     }
 
+    ++dnsdist::metrics::g_stats.responses;
+    if (du->ids.cs != nullptr) {
+      ++du->ids.cs->responses;
+    }
+
     if (result != ProcessQueryResult::PassToBackend) {
       handleImmediateResponse(std::move(du), "DoQ no backend available");
       return;
@@ -711,10 +711,8 @@ void doqThread(ClientState* cs)
         else {
           DEBUGLOG("Connection not established");
         }
-        /* FIXME: we should handle timeouts */
-        // pacing QUIC ?
-        // quiche_send_info.at Queue avec les paquets a envoyer par date.
       }
+
       for (auto conn = s_connections.begin(); conn != s_connections.end();) {
         quiche_conn_on_timeout(conn->second.d_conn.get());
 
@@ -728,10 +726,11 @@ void doqThread(ClientState* cs)
           quiche_conn_stats(conn->second.d_conn.get(), &stats);
           quiche_conn_path_stats(conn->second.d_conn.get(), 0, &path_stats);
 
-          DEBUGLOG("Connection closed, recv="<<stats.recv<<" sent="<<stats.sent<<" lost="<<stats.lost<<" rtt="<<path_stats.rtt<<"ns cwnd="<<path_stats.cwnd);
+          DEBUGLOG("Connection closed, recv=" << stats.recv << " sent=" << stats.sent << " lost=" << stats.lost << " rtt=" << path_stats.rtt << "ns cwnd=" << path_stats.cwnd);
 #endif
           conn = s_connections.erase(conn);
-        } else {
+        }
+        else {
           ++conn;
         }
       }
index 461f09fbd182a8cae902ad92d5baccc5497b7262..8761e04ca85bfadb8f21d725c7fe53f5f0c95c54 100644 (file)
@@ -41,8 +41,8 @@ class Connection
 public:
   Connection(const ComboAddress& peer, std::unique_ptr<quiche_conn, decltype(&quiche_conn_free)>&& conn) :
     d_peer(peer), d_conn(std::move(conn))
-    {
-    }
+  {
+  }
   Connection(const Connection&) = delete;
   Connection(Connection&&) = default;
   Connection& operator=(const Connection&) = delete;
@@ -63,8 +63,8 @@ struct DownstreamState;
 struct DOQFrontend
 {
   DOQFrontend()
-    {
-    }
+  {
+  }
 
   std::shared_ptr<DOQServerConfig> d_server_config{nullptr};
   TLSConfig d_tlsConfig;
@@ -75,7 +75,8 @@ struct DOQFrontend
 
 struct DOQUnit
 {
-  DOQUnit(PacketBuffer&& q): query(std::move(q))
+  DOQUnit(PacketBuffer&& q) :
+    query(std::move(q))
   {
     ids.ednsAdded = false;
   }
@@ -105,6 +106,7 @@ struct DNSQuestion;
 std::unique_ptr<CrossProtocolQuery> getDOQCrossProtocolQueryFromDQ(DNSQuestion& dq, bool isResponse);
 
 #else
+
 struct DOQUnit
 {
 };
@@ -112,12 +114,11 @@ struct DOQUnit
 struct DOQFrontend
 {
   DOQFrontend()
-    {
-    }
+  {
+  }
   void setup()
-    {
-
-    }
+  {
+  }
 };
 
 #endif