]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Process review comments: use correct auth and nsname for task
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 12 Apr 2022 08:12:37 +0000 (10:12 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 12 Apr 2022 11:39:43 +0000 (13:39 +0200)
pdns/rec_control.cc
pdns/recursordist/docs/settings.rst
pdns/recursordist/rec-taskqueue.cc
pdns/recursordist/rec-taskqueue.hh
pdns/recursordist/taskqueue.hh
pdns/syncres.cc
pdns/syncres.hh

index 0bcf476e10a37b370d0e3b03b0aec96a0f23ae81..2cbd70bc5a8d6cdbbfddb2e121166c048a0add16 100644 (file)
@@ -97,7 +97,8 @@ int main(int argc, char** argv)
     "dump-throttlemap",
     "dump-non-resolving",
     "dump-saved-parent-ns-sets",
-    "dump-dot-probe-map"};
+    "dump-dot-probe-map",
+  };
   try {
     initArguments(argc, argv);
     string sockname = "pdns_recursor";
index 8c72a3e531b68100cb1c71bc6d4ee17f449eadf1..7773ac9b84134efe88f13f4a9e84af001ccc720c 100644 (file)
@@ -1082,8 +1082,7 @@ DoT probes are used to check if an authoritative server's IP address supports Do
 If the probe determines an IP address supports DoT, the Recursor will use DoT to contact it for subsequent queries.
 The results of probes are remembered and can be viewed by the ``rec_control dump-dot-probe-map`` command.
 If the maximum number of pending probes is reached, no probes will be scheduled, even if no DoT status is known for an address.
-If the result of a probe is not yet available, the Recursor will contact the authoritative server in the regular way,
-unless an authoritative server is configured to be contacted over DoT always using :ref:`setting-dot-to-auth-names`.
+If the result of a probe is not yet available, the Recursor will contact the authoritative server in the regular way, unless an authoritative server is configured to be contacted over DoT always using :ref:`setting-dot-to-auth-names`.
 In that case no probe will be scheduled.
 
 Note::
index b56e404ffb1a0b037fb2e0b22ad5f6ecbb98eb85..a4ba8f88aefb78847f8e52b39cbda5d438d41a2f 100644 (file)
@@ -173,7 +173,7 @@ static void tryDoT(const struct timeval& now, bool logErrors, const pdns::Resolv
   bool ex = true;
   try {
     log->info(Logr::Warning, "trying DoT");
-    bool ok = sr.tryDoT(task.d_qname, QType(task.d_qtype), DNSName("auth"), DNSName("ns"), task.d_ip, now.tv_sec);
+    bool ok = sr.tryDoT(task.d_qname, QType(task.d_qtype), task.d_nsname, task.d_ip, now.tv_sec);
     ex = false;
     log->info(Logr::Warning, "done", "ok", Logging::Loggable(ok));
   }
@@ -245,7 +245,7 @@ void pushAlmostExpiredTask(const DNSName& qname, uint16_t qtype, time_t deadline
     log->error(Logr::Error, "Cannot push task", "qtype unsupported");
     return;
   }
-  pdns::ResolveTask task{qname, qtype, deadline, true, resolve, {}};
+  pdns::ResolveTask task{qname, qtype, deadline, true, resolve, {}, {}};
   if (s_taskQueue.lock()->queue.push(std::move(task))) {
     ++s_almost_expired_tasks.pushed;
   }
@@ -258,7 +258,7 @@ void pushResolveTask(const DNSName& qname, uint16_t qtype, time_t now, time_t de
     log->error(Logr::Error, "Cannot push task", "qtype unsupported");
     return;
   }
-  pdns::ResolveTask task{qname, qtype, deadline, false, resolve, {}};
+  pdns::ResolveTask task{qname, qtype, deadline, false, resolve, {}, {}};
   auto lock = s_taskQueue.lock();
   bool inserted = lock->rateLimitSet.insert(now, task);
   if (inserted) {
@@ -268,7 +268,7 @@ void pushResolveTask(const DNSName& qname, uint16_t qtype, time_t now, time_t de
   }
 }
 
-bool pushTryDoTTask(const DNSName& qname, uint16_t qtype, const ComboAddress& ip, time_t deadline)
+bool pushTryDoTTask(const DNSName& qname, uint16_t qtype, const ComboAddress& ip, time_t deadline, const DNSName& nsname)
 {
   if (SyncRes::isUnsupported(qtype)) {
     auto log = g_slog->withName("taskq")->withValues("name", Logging::Loggable(qname), "qtype", Logging::Loggable(QType(qtype).toString()));
@@ -276,7 +276,7 @@ bool pushTryDoTTask(const DNSName& qname, uint16_t qtype, const ComboAddress& ip
     return false;
   }
 
-  pdns::ResolveTask task{qname, qtype, deadline, false, tryDoT, ip};
+  pdns::ResolveTask task{qname, qtype, deadline, false, tryDoT, ip, nsname};
   bool pushed = s_taskQueue.lock()->queue.push(std::move(task));
   if (pushed) {
     ++s_almost_expired_tasks.pushed;
index 06633b2f08bea973c48924a1d301b4741daac293..cb9e71bf85a68548663481b73dea8548bd4dfc62 100644 (file)
@@ -35,7 +35,7 @@ void runTasks(size_t max, bool logErrors);
 void runTaskOnce(bool logErrors);
 void pushAlmostExpiredTask(const DNSName& qname, uint16_t qtype, time_t deadline);
 void pushResolveTask(const DNSName& qname, uint16_t qtype, time_t now, time_t deadline);
-bool pushTryDoTTask(const DNSName& qname, uint16_t qtype, const ComboAddress& ip, time_t deadline);
+bool pushTryDoTTask(const DNSName& qname, uint16_t qtype, const ComboAddress& ip, time_t deadline, const DNSName& nsname);
 void taskQueueClear();
 pdns::ResolveTask taskQueuePop();
 
index 8740130f7e176b3dbee6acd486e7a3872d3b1e73..92e3f176d12b3e4000ec9aeb1f160c0bc22489a9 100644 (file)
@@ -59,6 +59,8 @@ struct ResolveTask
   TaskFunction d_func;
   // IP used by DoT probe tasks
   ComboAddress d_ip;
+  // NS name used by DoT probe task
+  DNSName d_nsname;
 
   bool operator<(const ResolveTask& a) const
   {
index 9f868d0f0868f59429543b24c348b212afed7ac8..1cfe5aadf372ea03e2744ec8d0286c6486134164 100644 (file)
@@ -4735,7 +4735,7 @@ bool SyncRes::processRecords(const std::string& prefix, const DNSName& qname, co
 }
 
 
-static void submitTryDotTask(ComboAddress address, const DNSName& auth, time_t now)
+static void submitTryDotTask(ComboAddress address, const DNSName& auth, const DNSName nsname, time_t now)
 {
   if (address.getPort() == 853) {
     return;
@@ -4762,7 +4762,7 @@ static void submitTryDotTask(ComboAddress address, const DNSName& auth, time_t n
     }
   }
   lock->d_map.modify(it, [=] (DoTStatus& st){ st.d_ttd = now + dotFailWait; });
-  bool pushed = pushTryDoTTask(auth, QType::SOA, address, std::numeric_limits<time_t>::max());
+  bool pushed = pushTryDoTTask(auth, QType::SOA, address, std::numeric_limits<time_t>::max(), nsname);
   if (pushed) {
     it->d_status = DoTStatus::Busy;
     ++lock->d_numBusy;
@@ -4784,7 +4784,7 @@ static bool shouldDoDoT(ComboAddress address, time_t now)
   return false;
 }
 
-static void updateDoTStatus(ComboAddress address, const DNSName auth, DoTStatus::Status status, time_t time, bool updateBusy = false)
+static void updateDoTStatus(ComboAddress address, DoTStatus::Status status, time_t time, bool updateBusy = false)
 {
   address.setPort(853);
   auto lock = s_dotMap.lock();
@@ -4798,17 +4798,18 @@ static void updateDoTStatus(ComboAddress address, const DNSName auth, DoTStatus:
   }
 }
 
-bool SyncRes::tryDoT(const DNSName& qname, const QType qtype, const DNSName& auth, const DNSName& nsName, ComboAddress address, time_t now)
+bool SyncRes::tryDoT(const DNSName& qname, const QType qtype, const DNSName& nsName, ComboAddress address, time_t now)
 {
   LWResult lwr;
   bool truncated;
   bool spoofed;
   boost::optional<Netmask> nm;
   address.setPort(853);
-  bool ok = doResolveAtThisIP("", qname, qtype, lwr, nm, auth, false, false, nsName, address, true, true, truncated, spoofed);
+  // We use the fact that qname equals auth
+  bool ok = doResolveAtThisIP("", qname, qtype, lwr, nm, qname, false, false, nsName, address, true, true, truncated, spoofed);
   ok = ok && lwr.d_rcode == RCode::NoError && lwr.d_records.size() > 0;
 
-  updateDoTStatus(address, auth, ok ? DoTStatus::Good : DoTStatus::Bad, now + (ok ? dotSuccessWait : dotFailWait), true);
+  updateDoTStatus(address, ok ? DoTStatus::Good : DoTStatus::Bad, now + (ok ? dotSuccessWait : dotFailWait), true);
   return ok;
 }
 
@@ -5354,7 +5355,7 @@ int SyncRes::doResolveAt(NsSet &nameservers, DNSName auth, bool flawedNSSet, con
           bool forceTCP = doDoT;
 
           if (!doDoT && s_max_busy_dot_probes > 0) {
-            submitTryDotTask(*remoteIP, auth, d_now.tv_sec);
+            submitTryDotTask(*remoteIP, auth, tns->first, d_now.tv_sec);
           }
           if (!forceTCP) {
             gotAnswer = doResolveAtThisIP(prefix, qname, qtype, lwr, ednsmask, auth, sendRDQuery, wasForwarded,
@@ -5369,7 +5370,7 @@ int SyncRes::doResolveAt(NsSet &nameservers, DNSName auth, bool flawedNSSet, con
           if (!gotAnswer) {
             if (doDoT && s_max_busy_dot_probes > 0) {
               // This is quite pessimistic...
-              updateDoTStatus(*remoteIP, auth, DoTStatus::Bad, d_now.tv_sec + dotFailWait);
+              updateDoTStatus(*remoteIP, DoTStatus::Bad, d_now.tv_sec + dotFailWait);
             }
             continue;
           }
@@ -5377,7 +5378,7 @@ int SyncRes::doResolveAt(NsSet &nameservers, DNSName auth, bool flawedNSSet, con
           LOG(prefix<<qname<<": Got "<<(unsigned int)lwr.d_records.size()<<" answers from "<<tns->first<<" ("<< remoteIP->toString() <<"), rcode="<<lwr.d_rcode<<" ("<<RCode::to_s(lwr.d_rcode)<<"), aa="<<lwr.d_aabit<<", in "<<lwr.d_usec/1000<<"ms"<<endl);
 
           if (doDoT && s_max_busy_dot_probes > 0) {
-            updateDoTStatus(*remoteIP, auth, DoTStatus::Good, d_now.tv_sec + dotSuccessWait);
+            updateDoTStatus(*remoteIP, DoTStatus::Good, d_now.tv_sec + dotSuccessWait);
           }
           /*  // for you IPv6 fanatics :-)
               if(remoteIP->sin4.sin_family==AF_INET6)
index 2f0de9b969cfe7bc14563112220a1345cd3a33a2..ef62a591f19a6b9036d9d955de9e02fd8cfd3317 100644 (file)
@@ -398,7 +398,7 @@ public:
   explicit SyncRes(const struct timeval& now);
 
   int beginResolve(const DNSName &qname, QType qtype, QClass qclass, vector<DNSRecord>&ret, unsigned int depth = 0);
-  bool tryDoT(const DNSName& qname, QType qtype, const DNSName& auth, const DNSName& nsName, ComboAddress address, time_t);
+  bool tryDoT(const DNSName& qname, QType qtype, const DNSName& nsName, ComboAddress address, time_t);
 
   void setId(int id)
   {