rec: Drop queries truncated because they were larger than our buffer
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 18 May 2018 13:57:06 +0000 (15:57 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 8 Jun 2018 06:04:32 +0000 (08:04 +0200)
pdns/pdns_recursor.cc
pdns/rec-snmp.cc
pdns/rec_channel_rec.cc
pdns/recursordist/RECURSOR-MIB.txt
pdns/recursordist/docs/metrics.rst
pdns/syncres.hh

index 133534652fcd4ee68e3d144834f0b013c1cfcdc3..d469a0eb6db5499cf24f3d3d841e30db30b5774f 100644 (file)
@@ -2035,6 +2035,14 @@ static void handleNewUDPQuestion(int fd, FDMultiplexer::funcparam_t& var)
       return;
     }
 
+    if (msgh.msg_flags & MSG_TRUNC) {
+      g_stats.truncatedDrops++;
+      if (!g_quiet) {
+        g_log<<Logger::Error<<"Ignoring truncated query from "<<fromaddr.toString()<<endl;
+      }
+      return;
+    }
+
     if(t_remotes)
       t_remotes->push_back(fromaddr);
 
index f240550f0d1e12bf435a49cea23cdb7fac9d11ea..b5884a8110b3d19c739a5ddf457a082e3f7e1d2d 100644 (file)
@@ -108,6 +108,7 @@ static const oid policyResultNodataOID[] = { RECURSOR_STATS_OID, 89 };
 static const oid policyResultTruncateOID[] = { RECURSOR_STATS_OID, 90 };
 static const oid policyResultCustomOID[] = { RECURSOR_STATS_OID, 91 };
 static const oid queryPipeFullDropsOID[] = { RECURSOR_STATS_OID, 92 };
+static const oid truncatedDropsOID[] = { RECURSOR_STATS_OID, 93 };
 
 static std::unordered_map<oid, std::string> s_statsMap;
 
@@ -220,6 +221,7 @@ RecursorSNMPAgent::RecursorSNMPAgent(const std::string& name, const std::string&
   registerCounter64Stat("server-parse-errors", serverParseErrorsOID, OID_LENGTH(serverParseErrorsOID));
   registerCounter64Stat("too-old-drops", tooOldDropsOID, OID_LENGTH(tooOldDropsOID));
   registerCounter64Stat("query-pipe-full-drops", queryPipeFullDropsOID, OID_LENGTH(queryPipeFullDropsOID));
+  registerCounter64Stat("truncated-drops", truncatedDropsOID, OID_LENGTH(truncatedDropsOID));
   registerCounter64Stat("answers0-1", answers01OID, OID_LENGTH(answers01OID));
   registerCounter64Stat("answers1-10", answers110OID, OID_LENGTH(answers110OID));
   registerCounter64Stat("answers10-100", answers10100OID, OID_LENGTH(answers10100OID));
index 3215c497bb16d424ffa35b5c81d4c4cf172b742e..9affdfd2785c01435194f224cc088bc631bdf60d 100644 (file)
@@ -870,6 +870,7 @@ void registerAllStats()
   addGetStat("client-parse-errors", &g_stats.clientParseError);
   addGetStat("server-parse-errors", &g_stats.serverParseError);
   addGetStat("too-old-drops", &g_stats.tooOldDrops);
+  addGetStat("truncated-drops", &g_stats.truncatedDrops);
   addGetStat("query-pipe-full-drops", &g_stats.queryPipeFullDrops);
 
   addGetStat("answers0-1", &g_stats.answers0_1);
index 2f8bb527631abca53244383e41fbdadebc907636..aecea2b1e0a45ab1fedaf0568f02cce89b7eecc3 100644 (file)
@@ -766,6 +766,14 @@ queryPipeFullDrops OBJECT-TYPE
         "Number of queries dropped because the query distribution pipe was full"
     ::= { stats 92 }
 
+truncatedDrops OBJECT-TYPE
+    SYNTAX Counter64
+    MAX-ACCESS read-only
+    STATUS current
+    DESCRIPTION
+        "Number of queries dropped because they were larger than 1500 bytes"
+    ::= { stats 93 }
+
 ---
 --- Traps / Notifications
 ---
@@ -900,6 +908,7 @@ recGroup OBJECT-GROUP
         policyResultTruncate,
         policyResultCustom,
         queryPipeFullDrops,
+        truncatedDrops,
         trapReason
     }
     STATUS current
index f10cec03888669aa31574e83372140ceb04e6a80..309fbbf8c9644f678bc2d8879774372793a8904f 100644 (file)
@@ -426,6 +426,12 @@ too-old-drops
 ^^^^^^^^^^^^^
 questions dropped that were too old
 
+truncated-drops
+^^^^^^^^^^^^^^^
+.. versionadded:: 4.2
+
+questions dropped because they were larger than 1500 bytes
+
 unauthorized-tcp
 ^^^^^^^^^^^^^^^^
 number of TCP questions denied because of   allow-from restrictions
index d912e95949a06d20bbd7dfd83ec8f12a275630d4..11ecb698ab7a84a658a8a245f93ee2849ee9ae01 100644 (file)
@@ -905,6 +905,7 @@ struct RecursorStats
   std::atomic<uint64_t> clientParseError;
   std::atomic<uint64_t> serverParseError;
   std::atomic<uint64_t> tooOldDrops;
+  std::atomic<uint64_t> truncatedDrops;
   std::atomic<uint64_t> queryPipeFullDrops;
   std::atomic<uint64_t> unexpectedCount;
   std::atomic<uint64_t> caseMismatchCount;