]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Appease the formatting gods
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 3 Jun 2021 16:20:33 +0000 (18:20 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 26 Aug 2021 14:30:27 +0000 (16:30 +0200)
pdns/dnsdist-idstate.hh
pdns/dnsdistdist/dnsdist-session-cache.cc
pdns/dnsdistdist/dnsdist-tcp.hh

index 580db0d9d2ce12f5961b4bd11cb83a0d57d0a4d5..76afc52df8f39b04783c0378d79cf23f0b87528c 100644 (file)
@@ -37,41 +37,50 @@ using QTag = std::unordered_map<string, string>;
 
 struct StopWatch
 {
-  StopWatch(bool realTime=false): d_needRealTime(realTime)
+  StopWatch(bool realTime = false) :
+    d_needRealTime(realTime)
   {
   }
 
-  void start() {
+  void start()
+  {
     if (gettime(&d_start, d_needRealTime) < 0) {
       unixDie("Getting timestamp");
     }
   }
 
-  void set(const struct timespec& from) {
+  void set(const struct timespec& from)
+  {
     d_start = from;
   }
 
-  double udiff() const {
+  double udiff() const
+  {
     struct timespec now;
     if (gettime(&now, d_needRealTime) < 0) {
       unixDie("Getting timestamp");
     }
 
-    return 1000000.0*(now.tv_sec - d_start.tv_sec) + (now.tv_nsec - d_start.tv_nsec)/1000.0;
+    return 1000000.0 * (now.tv_sec - d_start.tv_sec) + (now.tv_nsec - d_start.tv_nsec) / 1000.0;
   }
 
-  double udiffAndSet() {
+  double udiffAndSet()
+  {
     struct timespec now;
     if (gettime(&now, d_needRealTime) < 0) {
       unixDie("Getting timestamp");
     }
 
-    auto ret= 1000000.0*(now.tv_sec - d_start.tv_sec) + (now.tv_nsec - d_start.tv_nsec)/1000.0;
+    auto ret = 1000000.0 * (now.tv_sec - d_start.tv_sec) + (now.tv_nsec - d_start.tv_nsec) / 1000.0;
     d_start = now;
     return ret;
   }
 
-  struct timespec d_start{0,0};
+  struct timespec d_start
+  {
+    0, 0
+  };
+
 private:
   bool d_needRealTime{false};
 };
@@ -87,9 +96,11 @@ private:
 
 struct IDState
 {
-  IDState(): sentTime(true), tempFailureTTL(boost::none) { origDest.sin4.sin_family = 0;}
+  IDState() :
+    sentTime(true), tempFailureTTL(boost::none) { origDest.sin4.sin_family = 0; }
   IDState(const IDState& orig) = delete;
-  IDState(IDState&& rhs): subnet(rhs.subnet), origRemote(rhs.origRemote), origDest(rhs.origDest), hopRemote(rhs.hopRemote), hopLocal(rhs.hopLocal), qname(std::move(rhs.qname)), sentTime(rhs.sentTime), dnsCryptQuery(std::move(rhs.dnsCryptQuery)), packetCache(std::move(rhs.packetCache)), qTag(std::move(rhs.qTag)), tempFailureTTL(rhs.tempFailureTTL), cs(rhs.cs), du(std::move(rhs.du)), cacheKey(rhs.cacheKey), cacheKeyNoECS(rhs.cacheKeyNoECS), cacheKeyUDP(rhs.cacheKeyUDP), origFD(rhs.origFD), delayMsec(rhs.delayMsec), qtype(rhs.qtype), qclass(rhs.qclass), origID(rhs.origID), origFlags(rhs.origFlags), cacheFlags(rhs.cacheFlags), protocol(rhs.protocol), ednsAdded(rhs.ednsAdded), ecsAdded(rhs.ecsAdded), skipCache(rhs.skipCache), destHarvested(rhs.destHarvested), dnssecOK(rhs.dnssecOK), useZeroScope(rhs.useZeroScope)
+  IDState(IDState&& rhs) :
+    subnet(rhs.subnet), origRemote(rhs.origRemote), origDest(rhs.origDest), hopRemote(rhs.hopRemote), hopLocal(rhs.hopLocal), qname(std::move(rhs.qname)), sentTime(rhs.sentTime), dnsCryptQuery(std::move(rhs.dnsCryptQuery)), packetCache(std::move(rhs.packetCache)), qTag(std::move(rhs.qTag)), tempFailureTTL(rhs.tempFailureTTL), cs(rhs.cs), du(std::move(rhs.du)), cacheKey(rhs.cacheKey), cacheKeyNoECS(rhs.cacheKeyNoECS), cacheKeyUDP(rhs.cacheKeyUDP), origFD(rhs.origFD), delayMsec(rhs.delayMsec), qtype(rhs.qtype), qclass(rhs.qclass), origID(rhs.origID), origFlags(rhs.origFlags), cacheFlags(rhs.cacheFlags), protocol(rhs.protocol), ednsAdded(rhs.ednsAdded), ecsAdded(rhs.ecsAdded), skipCache(rhs.skipCache), destHarvested(rhs.destHarvested), dnssecOK(rhs.dnssecOK), useZeroScope(rhs.useZeroScope)
   {
     if (rhs.isInUse()) {
       throw std::runtime_error("Trying to move an in-use IDState");
@@ -219,39 +230,39 @@ struct IDState
      wrapping around if necessary, and we set an atomic signed 64-bit value, so that we still have -1
      when the state is unused and the value of our counter otherwise.
   */
-  boost::optional<Netmask> subnet{boost::none};               // 40
-  ComboAddress origRemote;                                    // 28
-  ComboAddress origDest;                                      // 28
+  boost::optional<Netmask> subnet{boost::none}; // 40
+  ComboAddress origRemote; // 28
+  ComboAddress origDest; // 28
   ComboAddress hopRemote;
   ComboAddress hopLocal;
-  DNSName qname;                                              // 24
-  StopWatch sentTime;                                         // 16
-  std::shared_ptr<DNSCryptQuery> dnsCryptQuery{nullptr};      // 16
-  std::shared_ptr<DNSDistPacketCache> packetCache{nullptr};   // 16
-  std::shared_ptr<QTag> qTag{nullptr};                        // 16
-  boost::optional<uint32_t> tempFailureTTL;                   // 8
-  const ClientState* cs{nullptr};                             // 8
-  DOHUnit* du{nullptr};                                       // 8
-  std::atomic<int64_t> usageIndicator{unusedIndicator};  // set to unusedIndicator to indicate this state is empty   // 8
+  DNSName qname; // 24
+  StopWatch sentTime; // 16
+  std::shared_ptr<DNSCryptQuery> dnsCryptQuery{nullptr}; // 16
+  std::shared_ptr<DNSDistPacketCache> packetCache{nullptr}; // 16
+  std::shared_ptr<QTag> qTag{nullptr}; // 16
+  boost::optional<uint32_t> tempFailureTTL; // 8
+  const ClientState* cs{nullptr}; // 8
+  DOHUnit* du{nullptr}; // 8
+  std::atomic<int64_t> usageIndicator{unusedIndicator}; // set to unusedIndicator to indicate this state is empty   // 8
   std::atomic<uint32_t> generation{0}; // increased every time a state is used, to be able to detect an ABA issue    // 4
-  uint32_t cacheKey{0};                                       // 4
-  uint32_t cacheKeyNoECS{0};                                  // 4
+  uint32_t cacheKey{0}; // 4
+  uint32_t cacheKeyNoECS{0}; // 4
   // DoH-only */
-  uint32_t cacheKeyUDP{0};                                    // 4
-  int origFD{-1};                                             // 4
+  uint32_t cacheKeyUDP{0}; // 4
+  int origFD{-1}; // 4
   int delayMsec{0};
 #ifdef __SANITIZE_THREAD__
   std::atomic<uint16_t> age{0};
 #else
-  uint16_t age{0};                                            // 2
+  uint16_t age{0}; // 2
 #endif
-  uint16_t qtype{0};                                          // 2
-  uint16_t qclass{0};                                         // 2
-  uint16_t origID{0};                                         // 2
-  uint16_t origFlags{0};                                      // 2
+  uint16_t qtype{0}; // 2
+  uint16_t qclass{0}; // 2
+  uint16_t origID{0}; // 2
+  uint16_t origFlags{0}; // 2
   uint16_t cacheFlags{0}; // DNS flags as sent to the backend // 2
-  dnsdist::Protocol protocol;                                 // 1
-  boost::optional<boost::uuids::uuid> uniqueId{boost::none};  // 17 (placed here to reduce the space lost to padding)
+  dnsdist::Protocol protocol; // 1
+  boost::optional<boost::uuids::uuid> uniqueId{boost::none}; // 17 (placed here to reduce the space lost to padding)
   bool ednsAdded{false};
   bool ecsAdded{false};
   bool skipCache{false};
index ff7e8f6c38af7ea4c10ffb8c65e55f781d283ae2..be67c925d600d3f22b6e4d285e32cedb7554d8d6 100644 (file)
@@ -26,13 +26,11 @@ TLSSessionCache g_sessionCache;
 time_t const TLSSessionCache::s_cleanupDelay{60};
 time_t const TLSSessionCache::s_sessionValidity{600};
 
-
 void TLSSessionCache::cleanup(time_t now, const std::lock_guard<std::mutex>& lock)
 {
   time_t cutOff = now + s_sessionValidity;
 
-  for (auto it = d_sessions.begin(); it != d_sessions.end(); )
-  {
+  for (auto it = d_sessions.begin(); it != d_sessions.end();) {
     if (it->second.d_lastUsed > cutOff || it->second.d_sessions.size() == 0) {
       it = d_sessions.erase(it);
     }
index 02581e68745934bb14e33fff619158136938042c..99da15c094350f6a9b9a92140fd65ee6d4b93433 100644 (file)
 
 struct ConnectionInfo
 {
-  ConnectionInfo(ClientState* cs_): cs(cs_), fd(-1)
+  ConnectionInfo(ClientState* cs_) :
+    cs(cs_), fd(-1)
   {
   }
-  ConnectionInfo(ConnectionInfo&& rhs): remote(rhs.remote), cs(rhs.cs), fd(rhs.fd)
+  ConnectionInfo(ConnectionInfo&& rhs) :
+    remote(rhs.remote), cs(rhs.cs), fd(rhs.fd)
   {
     rhs.cs = nullptr;
     rhs.fd = -1;
@@ -68,7 +70,8 @@ struct InternalQuery
   {
   }
 
-  InternalQuery(PacketBuffer&& buffer, IDState&& state): d_idstate(std::move(state)), d_buffer(std::move(buffer))
+  InternalQuery(PacketBuffer&& buffer, IDState&& state) :
+    d_idstate(std::move(state)), d_buffer(std::move(buffer))
   {
   }
 
@@ -118,7 +121,8 @@ struct TCPResponse : public TCPQuery
     memset(&d_cleartextDH, 0, sizeof(d_cleartextDH));
   }
 
-  TCPResponse(PacketBuffer&& buffer, IDState&& state, std::shared_ptr<TCPConnectionToBackend> conn): TCPQuery(std::move(buffer), std::move(state)), d_connection(conn)
+  TCPResponse(PacketBuffer&& buffer, IDState&& state, std::shared_ptr<TCPConnectionToBackend> conn) :
+    TCPQuery(std::move(buffer), std::move(state)), d_connection(conn)
   {
     memset(&d_cleartextDH, 0, sizeof(d_cleartextDH));
   }
@@ -147,6 +151,7 @@ public:
   {
     return d_releaseConnection;
   }
+
 protected:
   bool d_releaseConnection{true};
 };
@@ -170,7 +175,8 @@ struct CrossProtocolQuery
   bool isXFR{false};
 };
 
-class TCPClientCollection {
+class TCPClientCollection
+{
 public:
   TCPClientCollection(size_t maxThreads);
 
@@ -252,11 +258,13 @@ private:
     {
     }
 
-    TCPWorkerThread(int newConnPipe, int crossProtocolPipe): d_newConnectionPipe(newConnPipe), d_crossProtocolQueryPipe(crossProtocolPipe)
+    TCPWorkerThread(int newConnPipe, int crossProtocolPipe) :
+      d_newConnectionPipe(newConnPipe), d_crossProtocolQueryPipe(crossProtocolPipe)
     {
     }
 
-    TCPWorkerThread(TCPWorkerThread&& rhs): d_newConnectionPipe(rhs.d_newConnectionPipe), d_crossProtocolQueryPipe(rhs.d_crossProtocolQueryPipe)
+    TCPWorkerThread(TCPWorkerThread&& rhs) :
+      d_newConnectionPipe(rhs.d_newConnectionPipe), d_crossProtocolQueryPipe(rhs.d_crossProtocolQueryPipe)
     {
       rhs.d_newConnectionPipe = -1;
       rhs.d_crossProtocolQueryPipe = -1;