From: Remi Gacogne Date: Thu, 24 Nov 2022 16:22:37 +0000 (+0100) Subject: dnsdist: Clean up unused fieds from the IDState X-Git-Tag: dnsdist-1.8.0-rc1~147^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa6a1009aaeb576512db9c757827e075f11b3ff9;p=thirdparty%2Fpdns.git dnsdist: Clean up unused fieds from the IDState --- diff --git a/pdns/dnsdist-idstate.hh b/pdns/dnsdist-idstate.hh index 0bbf87560d..98520c0f12 100644 --- a/pdns/dnsdist-idstate.hh +++ b/pdns/dnsdist-idstate.hh @@ -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{nullptr}; // 8 std::unique_ptr qTag{nullptr}; // 8 boost::optional 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 usageIndicator{unusedIndicator}; // set to unusedIndicator to indicate this state is empty // 8 std::atomic 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}; }; diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 7348fa95a0..99f5522b94 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -1419,7 +1419,7 @@ ProcessQueryResult processQuery(DNSQuestion& dq, ClientState& cs, LocalHolders& class UDPTCPCrossQuerySender : public TCPQuerySender { public: - UDPTCPCrossQuerySender(const ClientState& cs, std::shared_ptr& ds, uint16_t payloadSize): d_cs(cs), d_ds(ds), d_payloadSize(payloadSize) + UDPTCPCrossQuerySender(const ClientState& cs, const std::shared_ptr& 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 d_ds{nullptr}; + const std::shared_ptr 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)); diff --git a/pdns/dnsdistdist/doh.cc b/pdns/dnsdistdist/doh.cc index 088f618b74..5cdfe5e649 100644 --- a/pdns/dnsdistdist/doh.cc +++ b/pdns/dnsdistdist/doh.cc @@ -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;