From: Otto Moerbeek Date: Mon, 20 Nov 2023 09:18:21 +0000 (+0100) Subject: Update query counts in a single place, count all ipv6 queries X-Git-Tag: rec-5.0.0-rc1~32^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0fd1030fc12505d7e79ef54ffb696fae4a2e4756;p=thirdparty%2Fpdns.git Update query counts in a single place, count all ipv6 queries --- diff --git a/pdns/recursordist/lwres.cc b/pdns/recursordist/lwres.cc index d02e51eb54..5b255b2980 100644 --- a/pdns/recursordist/lwres.cc +++ b/pdns/recursordist/lwres.cc @@ -468,9 +468,6 @@ static LWResult::Result asyncresolve(const ComboAddress& address, const DNSName& if (!doTCP) { int queryfd; - if (address.sin4.sin_family == AF_INET6) { - t_Counters.at(rec::Counter::ipv6queries)++; - } ret = asendto(vpacket.data(), vpacket.size(), 0, address, qid, domain, type, weWantEDNSSubnet, &queryfd); diff --git a/pdns/recursordist/syncres.cc b/pdns/recursordist/syncres.cc index 9f2964fffb..e7b82e9a01 100644 --- a/pdns/recursordist/syncres.cc +++ b/pdns/recursordist/syncres.cc @@ -5213,33 +5213,39 @@ bool SyncRes::tryDoT(const DNSName& qname, const QType qtype, const DNSName& nsN return ok; } -bool SyncRes::doResolveAtThisIP(const std::string& prefix, const DNSName& qname, const QType qtype, LWResult& lwr, boost::optional& ednsmask, const DNSName& auth, bool const sendRDQuery, const bool wasForwarded, const DNSName& nsName, const ComboAddress& remoteIP, bool doTCP, bool doDoT, bool& truncated, bool& spoofed, boost::optional& extendedError, bool dontThrottle) +void SyncRes::updateQueryCounts(const string& prefix, const DNSName& qname, const ComboAddress& address, bool doTCP, bool doDoT) { - bool chained = false; - LWResult::Result resolveret = LWResult::Result::Success; t_Counters.at(rec::Counter::outqueries)++; d_outqueries++; checkMaxQperQ(qname); - - if (s_maxtotusec && d_totUsec > s_maxtotusec) { - if (s_addExtendedResolutionDNSErrors) { - extendedError = EDNSExtendedError{static_cast(EDNSExtendedError::code::NoReachableAuthority), "Timeout waiting for answer(s)"}; - } - throw ImmediateServFailException("Too much time waiting for " + qname.toLogString() + "|" + qtype.toString() + ", timeouts: " + std::to_string(d_timeouts) + ", throttles: " + std::to_string(d_throttledqueries) + ", queries: " + std::to_string(d_outqueries) + ", " + std::to_string(d_totUsec / 1000) + " ms"); + if (address.sin4.sin_family == AF_INET6) { + t_Counters.at(rec::Counter::ipv6queries)++; } - if (doTCP) { if (doDoT) { - LOG(prefix << qname << ": Using DoT with " << remoteIP.toStringWithPort() << endl); + LOG(prefix << qname << ": Using DoT with " << address.toStringWithPort() << endl); t_Counters.at(rec::Counter::dotoutqueries)++; d_dotoutqueries++; } else { - LOG(prefix << qname << ": Using TCP with " << remoteIP.toStringWithPort() << endl); + LOG(prefix << qname << ": Using TCP with " << address.toStringWithPort() << endl); t_Counters.at(rec::Counter::tcpoutqueries)++; d_tcpoutqueries++; } } +} + +bool SyncRes::doResolveAtThisIP(const std::string& prefix, const DNSName& qname, const QType qtype, LWResult& lwr, boost::optional& ednsmask, const DNSName& auth, bool const sendRDQuery, const bool wasForwarded, const DNSName& nsName, const ComboAddress& remoteIP, bool doTCP, bool doDoT, bool& truncated, bool& spoofed, boost::optional& extendedError, bool dontThrottle) +{ + bool chained = false; + LWResult::Result resolveret = LWResult::Result::Success; + + if (s_maxtotusec && d_totUsec > s_maxtotusec) { + if (s_addExtendedResolutionDNSErrors) { + extendedError = EDNSExtendedError{static_cast(EDNSExtendedError::code::NoReachableAuthority), "Timeout waiting for answer(s)"}; + } + throw ImmediateServFailException("Too much time waiting for " + qname.toLogString() + "|" + qtype.toString() + ", timeouts: " + std::to_string(d_timeouts) + ", throttles: " + std::to_string(d_throttledqueries) + ", queries: " + std::to_string(d_outqueries) + ", " + std::to_string(d_totUsec / 1000) + " ms"); + } int preOutQueryRet = RCode::NoError; if (d_pdl && d_pdl->preoutquery(remoteIP, d_requestor, qname, qtype, doTCP, lwr.d_records, preOutQueryRet, d_eventTrace, timeval{0, 0})) { @@ -5251,6 +5257,7 @@ bool SyncRes::doResolveAtThisIP(const std::string& prefix, const DNSName& qname, LOG(prefix << qname << ": Adding EDNS Client Subnet Mask " << ednsmask->toString() << " to query" << endl); s_ecsqueries++; } + updateQueryCounts(prefix, qname, remoteIP, doTCP, doDoT); resolveret = asyncresolveWrapper(remoteIP, d_doDNSSEC, qname, auth, qtype.getCode(), doTCP, sendRDQuery, &d_now, ednsmask, &lwr, &chained, nsName); // <- we go out on the wire! if (ednsmask) { diff --git a/pdns/recursordist/syncres.hh b/pdns/recursordist/syncres.hh index 9fe98262ac..5134cd3e4c 100644 --- a/pdns/recursordist/syncres.hh +++ b/pdns/recursordist/syncres.hh @@ -616,6 +616,7 @@ private: bool addAdditionals(QType qtype, vector& ret, unsigned int depth); bool doDoTtoAuth(const DNSName& ns) const; + void updateQueryCounts(const string& prefix, const DNSName& qname, const ComboAddress& address, bool doTCP, bool doDoT); int doResolveAt(NsSet& nameservers, DNSName auth, bool flawedNSSet, const DNSName& qname, QType qtype, vector& ret, unsigned int depth, const string& prefix, set& beenthere, Context& context, StopAtDelegation* stopAtDelegation, std::map>* fallback);