]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Clean up unused fieds from the IDState
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 24 Nov 2022 16:22:37 +0000 (17:22 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 14 Dec 2022 15:25:57 +0000 (16:25 +0100)
pdns/dnsdist-idstate.hh
pdns/dnsdist.cc
pdns/dnsdistdist/doh.cc

index 0bbf87560da525ae623855af577961748cf8bff3..98520c0f12558629b7ef0487467599bc03e4f846 100644 (file)
@@ -99,7 +99,7 @@ struct 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), packetCache(std::move(rhs.packetCache)), dnsCryptQuery(std::move(rhs.dnsCryptQuery)), 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), backendFD(rhs.backendFD), 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)
+    subnet(rhs.subnet), origRemote(rhs.origRemote), origDest(rhs.origDest), hopRemote(rhs.hopRemote), hopLocal(rhs.hopLocal), qname(std::move(rhs.qname)), sentTime(rhs.sentTime), packetCache(std::move(rhs.packetCache)), dnsCryptQuery(std::move(rhs.dnsCryptQuery)), 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), backendFD(rhs.backendFD), 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), dnssecOK(rhs.dnssecOK), useZeroScope(rhs.useZeroScope)
   {
     if (rhs.isInUse()) {
       throw std::runtime_error("Trying to move an in-use IDState");
@@ -139,7 +139,6 @@ struct IDState
     cacheKey = rhs.cacheKey;
     cacheKeyNoECS = rhs.cacheKeyNoECS;
     cacheKeyUDP = rhs.cacheKeyUDP;
-    origFD = rhs.origFD;
     backendFD = rhs.backendFD;
     delayMsec = rhs.delayMsec;
 #ifdef __SANITIZE_THREAD__
@@ -157,7 +156,6 @@ struct IDState
     ednsAdded = rhs.ednsAdded;
     ecsAdded = rhs.ecsAdded;
     skipCache = rhs.skipCache;
-    destHarvested = rhs.destHarvested;
     dnssecOK = rhs.dnssecOK;
     useZeroScope = rhs.useZeroScope;
 
@@ -241,7 +239,7 @@ struct IDState
   std::unique_ptr<DNSCryptQuery> dnsCryptQuery{nullptr}; // 8
   std::unique_ptr<QTag> qTag{nullptr}; // 8
   boost::optional<uint32_t> tempFailureTTL; // 8
-  const ClientState* cs{nullptr}; // 8
+  ClientState* cs{nullptr}; // 8
   DOHUnit* du{nullptr}; // 8 (not a unique_ptr because we currently need to be able to peek at it without taking ownership until later)
   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
@@ -249,7 +247,6 @@ struct IDState
   uint32_t cacheKeyNoECS{0}; // 4
   // DoH-only */
   uint32_t cacheKeyUDP{0}; // 4
-  int origFD{-1}; // 4
   int backendFD{-1}; // 4
   int delayMsec{0};
 #ifdef __SANITIZE_THREAD__
@@ -268,7 +265,6 @@ struct IDState
   bool ednsAdded{false};
   bool ecsAdded{false};
   bool skipCache{false};
-  bool destHarvested{false}; // if true, origDest holds the original dest addr, otherwise the listening addr
   bool dnssecOK{false};
   bool useZeroScope{false};
 };
index 7348fa95a0adba8e33a4aa2e8043b7b62981d0a2..99f5522b94099dddec366f69d036837b94423162 100644 (file)
@@ -1419,7 +1419,7 @@ ProcessQueryResult processQuery(DNSQuestion& dq, ClientState& cs, LocalHolders&
 class UDPTCPCrossQuerySender : public TCPQuerySender
 {
 public:
-  UDPTCPCrossQuerySender(const ClientState& cs, std::shared_ptr<DownstreamState>& ds, uint16_t payloadSize): d_cs(cs), d_ds(ds), d_payloadSize(payloadSize)
+  UDPTCPCrossQuerySender(const ClientState& cs, const std::shared_ptr<DownstreamState>& ds, uint16_t payloadSize): d_cs(cs), d_ds(ds), d_payloadSize(payloadSize)
   {
   }
 
@@ -1467,7 +1467,7 @@ public:
   }
 private:
   const ClientState& d_cs;
-  std::shared_ptr<DownstreamState> d_ds{nullptr};
+  const std::shared_ptr<DownstreamState> d_ds{nullptr};
   uint16_t d_payloadSize{0};
 };
 
@@ -1601,7 +1601,6 @@ static void processUDPQuery(ClientState& cs, LocalHolders& holders, const struct
 
       IDState ids;
       ids.cs = &cs;
-      ids.origFD = cs.udpFD;
       ids.origID = dh->id;
       setIDStateFromDNSQuestion(ids, dq, std::move(qname));
       if (dest.sin4.sin_family != 0) {
@@ -1622,7 +1621,6 @@ static void processUDPQuery(ClientState& cs, LocalHolders& holders, const struct
     IDState* ids = ss->getIDState(idOffset, generation);
 
     ids->cs = &cs;
-    ids->origFD = cs.udpFD;
     ids->origID = dh->id;
     setIDStateFromDNSQuestion(*ids, dq, std::move(qname));
 
index 088f618b740ec93d4cae03ca27d122bc24be9794..5cdfe5e6492d415d623f4a463f3b3c8a8999dd96 100644 (file)
@@ -678,7 +678,6 @@ static void processDOHQuery(DOHUnitUniquePtr&& du)
     int64_t generation;
     IDState* ids = du->downstream->getIDState(idOffset, generation);
 
-    ids->origFD = 0;
     /* increase the ref count since we are about to store the pointer */
     du->get();
     duRefCountIncremented = true;
@@ -699,11 +698,9 @@ static void processDOHQuery(DOHUnitUniquePtr&& du)
     */
     if (dest.sin4.sin_family != 0) {
       ids->origDest = dest;
-      ids->destHarvested = true;
     }
     else {
       ids->origDest = cs.local;
-      ids->destHarvested = false;
     }
 
     bool failed = false;