]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Also submit resolve task for NS name -> AAAA with QM off 13295/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 25 Sep 2023 06:53:48 +0000 (08:53 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 25 Sep 2023 06:53:48 +0000 (08:53 +0200)
pdns/recursordist/rec-taskqueue.cc
pdns/recursordist/rec-taskqueue.hh
pdns/recursordist/syncres.cc
pdns/recursordist/test-rec-taskqueue.cc

index 8526e8d4c9644e233aa05e3cb426652a5459db78..9997991455b491b72d793d394b007081b19411b6 100644 (file)
@@ -114,7 +114,8 @@ struct taskstats
 static struct taskstats s_almost_expired_tasks;
 static struct taskstats s_resolve_tasks;
 
-static void resolve(const struct timeval& now, bool logErrors, const pdns::ResolveTask& task) noexcept
+// forceNoQM is true means resolve using no qm, false means use default value
+static void resolveInternal(const struct timeval& now, bool logErrors, const pdns::ResolveTask& task, bool forceNoQM) noexcept
 {
   auto log = g_slog->withName("taskq")->withValues("name", Logging::Loggable(task.d_qname), "qtype", Logging::Loggable(QType(task.d_qtype).toString()), "netmask", Logging::Loggable(task.d_netmask.empty() ? "" : task.d_netmask.toString()));
   const string msg = "Exception while running a background ResolveTask";
@@ -122,6 +123,9 @@ static void resolve(const struct timeval& now, bool logErrors, const pdns::Resol
   vector<DNSRecord> ret;
   resolver.setRefreshAlmostExpired(task.d_refreshMode);
   resolver.setQuerySource(task.d_netmask);
+  if (forceNoQM) {
+    resolver.setQNameMinimization(false);
+  }
   bool exceptionOccurred = true;
   try {
     log->info(Logr::Debug, "resolving", "refresh", Logging::Loggable(task.d_refreshMode));
@@ -166,6 +170,16 @@ static void resolve(const struct timeval& now, bool logErrors, const pdns::Resol
   }
 }
 
+static void resolveForceNoQM(const struct timeval& now, bool logErrors, const pdns::ResolveTask& task) noexcept
+{
+  resolveInternal(now, logErrors, task, true);
+}
+
+static void resolve(const struct timeval& now, bool logErrors, const pdns::ResolveTask& task) noexcept
+{
+  resolveInternal(now, logErrors, task, false);
+}
+
 static void tryDoT(const struct timeval& now, bool logErrors, const pdns::ResolveTask& task) noexcept
 {
   auto log = g_slog->withName("taskq")->withValues("method", Logging::Loggable("tryDoT"), "name", Logging::Loggable(task.d_qname), "qtype", Logging::Loggable(QType(task.d_qtype).toString()), "ip", Logging::Loggable(task.d_ip));
@@ -247,14 +261,15 @@ 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)
+void pushResolveTask(const DNSName& qname, uint16_t qtype, time_t now, time_t deadline, bool forceQMOff)
 {
   if (SyncRes::isUnsupported(qtype)) {
     auto log = g_slog->withName("taskq")->withValues("name", Logging::Loggable(qname), "qtype", Logging::Loggable(QType(qtype).toString()));
     log->error(Logr::Error, "Cannot push task", "qtype unsupported");
     return;
   }
-  pdns::ResolveTask task{qname, qtype, deadline, false, resolve, {}, {}, {}};
+  auto func = forceQMOff ? resolveForceNoQM : resolve;
+  pdns::ResolveTask task{qname, qtype, deadline, false, func, {}, {}, {}};
   auto lock = s_taskQueue.lock();
   bool inserted = lock->rateLimitSet.insert(now, task);
   if (inserted) {
index 13658055c59d46b2411056ced74bed36ac91f892..e7bc855bd761a97eb0edb6aef8f142dc113d4fd1 100644 (file)
@@ -36,7 +36,7 @@ struct ResolveTask;
 void runTasks(size_t max, bool logErrors);
 bool runTaskOnce(bool logErrors);
 void pushAlmostExpiredTask(const DNSName& qname, uint16_t qtype, time_t deadline, const Netmask& netmask);
-void pushResolveTask(const DNSName& qname, uint16_t qtype, time_t now, time_t deadline);
+void pushResolveTask(const DNSName& qname, uint16_t qtype, time_t now, time_t deadline, bool forceQMOff);
 bool pushTryDoTTask(const DNSName& qname, uint16_t qtype, const ComboAddress& ipAddress, time_t deadline, const DNSName& nsname);
 void taskQueueClear();
 pdns::ResolveTask taskQueuePop();
index 780264ed907149487dfab7d36a9a4c7631451fa6..01cd9b8c6c460a3477a7be7a0c645b65eade3b21 100644 (file)
@@ -608,7 +608,7 @@ void SyncRes::resolveAdditionals(const DNSName& qname, QType qtype, AdditionalMo
       // There are a few cases where an answer is neither stored in the record cache nor in the neg cache.
       // An example is a SOA-less NODATA response. Rate limiting will kick in if those tasks are pushed too often.
       // We might want to fix these cases (and always either store positive or negative) some day.
-      pushResolveTask(qname, qtype, d_now.tv_sec, d_now.tv_sec + 60);
+      pushResolveTask(qname, qtype, d_now.tv_sec, d_now.tv_sec + 60, false);
       additionalsNotInCache = true;
     }
     break;
@@ -2151,7 +2151,7 @@ vector<ComboAddress> SyncRes::getAddrs(const DNSName& qname, unsigned int depth,
       NegCache::NegCacheEntry ne;
       bool inNegCache = g_negCache->get(qname, QType::AAAA, d_now, ne, false);
       if (!inNegCache) {
-        pushResolveTask(qname, QType::AAAA, d_now.tv_sec, d_now.tv_sec + 60);
+        pushResolveTask(qname, QType::AAAA, d_now.tv_sec, d_now.tv_sec + 60, true);
       }
     }
   }
index 17ad0be38b44454719e52e045bc455cdd5dc34a6..b025a40fe346ea9af28d2ceba80a17eb80bcbb94 100644 (file)
@@ -30,17 +30,17 @@ BOOST_AUTO_TEST_CASE(test_almostexpired_queue_no_dups)
 BOOST_AUTO_TEST_CASE(test_resolve_queue_rate_limit)
 {
   taskQueueClear();
-  pushResolveTask(DNSName("foo"), QType::AAAA, 0, 1);
+  pushResolveTask(DNSName("foo"), QType::AAAA, 0, 1, false);
   BOOST_CHECK_EQUAL(getTaskSize(), 1U);
   taskQueuePop();
   BOOST_CHECK_EQUAL(getTaskSize(), 0U);
 
   // Should hit rate limiting
-  pushResolveTask(DNSName("foo"), QType::AAAA, 0, 1);
+  pushResolveTask(DNSName("foo"), QType::AAAA, 0, 1, false);
   BOOST_CHECK_EQUAL(getTaskSize(), 0U);
 
   // Should not hit rate limiting as time has passed
-  pushResolveTask(DNSName("foo"), QType::AAAA, 61, 62);
+  pushResolveTask(DNSName("foo"), QType::AAAA, 61, 62, false);
   BOOST_CHECK_EQUAL(getTaskSize(), 1U);
 }