]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Update query counts in a single place, count all ipv6 queries
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 20 Nov 2023 09:18:21 +0000 (10:18 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 20 Nov 2023 09:18:21 +0000 (10:18 +0100)
pdns/recursordist/lwres.cc
pdns/recursordist/syncres.cc
pdns/recursordist/syncres.hh

index d02e51eb54e3f4ed4260b633fcd83cf11278e6ae..5b255b298072f81f479a6c159b216ff15d1d3591 100644 (file)
@@ -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);
 
index 9f2964fffb823b516a6def96b5c362a836d8210c..e7b82e9a01ee34f470c3545ecfb48094afd32e35 100644 (file)
@@ -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<Netmask>& 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<EDNSExtendedError>& 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<uint16_t>(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<Netmask>& 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<EDNSExtendedError>& 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<uint16_t>(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) {
index 9fe98262ac767acb1bad60646552b7f5bd9b4e5a..5134cd3e4c1f152e2ebff5b4ed86b1ab02ea2b3a 100644 (file)
@@ -616,6 +616,7 @@ private:
   bool addAdditionals(QType qtype, vector<DNSRecord>& 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<DNSRecord>& ret,
                   unsigned int depth, const string& prefix, set<GetBestNSAnswer>& beenthere, Context& context, StopAtDelegation* stopAtDelegation,
                   std::map<DNSName, std::vector<ComboAddress>>* fallback);