]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Drop queries with packet types we do not like.
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 21 Feb 2022 15:11:37 +0000 (16:11 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 23 Feb 2022 06:31:10 +0000 (07:31 +0100)
While working on this, I noticed inconsistencies between UDP and TDP logging:
1 uses g_quiet, the other g_logCommonErrors. This needs to be revisited.

Also: the use of MT->getTid() seems strange, as it is used in places where
no mthread has been started yet in doProcessUDPQuestion() and handleRunningTCPQuestion().
That is, unless I'm missing something.

pdns/pdns_recursor.cc
pdns/recursordist/rec-taskqueue.cc
pdns/recursordist/rec-tcp.cc
pdns/syncres.hh

index 8d07675df70828f20ed656ac59bf163301fc62e5..2e7093995c51176035394286b4d3de49651df3c7 100644 (file)
@@ -1999,6 +1999,16 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr
   }
 
   auto dc = std::make_unique<DNSComboWriter>(question, g_now, std::move(policyTags), t_pdl, std::move(data), std::move(records));
+
+  if (SyncRes::isUnsupported(dc->d_mdp.d_qtype)) {
+    g_stats.ignoredCount++;
+    if (!g_quiet) {
+      g_log << Logger::Notice << RecThreadInfo::id() << " Unsupported qtype " << dc->d_mdp.d_qtype << " from " << source.toStringWithPort() << (source != fromaddr ? " (via " + fromaddr.toStringWithPort() + ")" : "") << endl;
+    }
+
+    return 0;
+  }
+
   dc->setSocket(fd);
   dc->d_tag = ctag;
   dc->d_qhash = qhash;
index 1e6593006af1961d13056e9292d0e7bd354f829b..883b26087d10db0ac1e8012c60705a96853368ec 100644 (file)
@@ -181,13 +181,8 @@ void runTaskOnce(bool logErrors)
 
 void pushAlmostExpiredTask(const DNSName& qname, uint16_t qtype, time_t deadline)
 {
-  switch (qtype) {
-    // Internal types
-  case QType::ENT:
-  case QType::ADDR:
-  case QType::ALIAS:
-  case QType::LUA:
-    g_log << Logger::Debug << "Cannot push task for " << QType(qtype).toString() << endl;
+  if (SyncRes::isUnsupported(qtype)) {
+    g_log << Logger::Error << "Cannot push task for " << QType(qtype).toString() << endl;
     return;
   }
   pdns::ResolveTask task{qname, qtype, deadline, true, resolve};
index 807b3dce1c8276d1b6e385941f52e82b0188743f..9e46bf7c1e5c61ab7fba1edf20e6480dd58c9124 100644 (file)
@@ -338,6 +338,14 @@ static void handleRunningTCPQuestion(int fd, FDMultiplexer::funcparam_t& var)
         }
         return;
       }
+      if (SyncRes::isUnsupported(dc->d_mdp.d_qtype)) {
+        g_stats.ignoredCount++;
+        if (g_logCommonErrors) {
+          g_log << Logger::Error << "Unsupported qtype " << dc->d_mdp.d_qtype << " from TCP client " << conn->d_remote.toStringWithPort() << endl;
+        }
+        return;
+      }
+
       dc->d_tcpConnection = conn; // carry the torch
       dc->setSocket(conn->getFD()); // this is the only time a copy is made of the actual fd
       dc->d_tcp = true;
index dddf299e9529f12756f92a4c503d78936573a49c..815724e3559583404c819cd0215ce9a9ba164b5a 100644 (file)
@@ -736,6 +736,19 @@ public:
     d_queryReceivedOverTCP = tcp;
   }
 
+  static bool isUnsupported(QType qtype)
+  {
+    switch (qtype.getCode()) {
+      // Internal types
+    case QType::ENT:
+    case QType::ADDR:
+    case QType::ALIAS:
+    case QType::LUA:
+      return true;
+    }
+    return false;
+  }
+
   static thread_local ThreadLocalStorage t_sstorage;
 
   static pdns::stat_t s_queries;