]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
spread support for reporting udp packet drops from auth to recursor - needs documenta...
authorbert hubert <bert.hubert@netherlabs.nl>
Thu, 28 May 2015 12:34:59 +0000 (14:34 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Thu, 28 May 2015 12:34:59 +0000 (14:34 +0200)
pdns/dynhandler.cc
pdns/misc.cc
pdns/misc.hh
pdns/rec_channel_rec.cc

index fa7651ac60a8721dea454fbb8c14eab11133e3ba..b0e8d012697a70bb0acae341036c1b143b5c1bfc 100644 (file)
@@ -324,32 +324,6 @@ string DLReloadHandler(const vector<string>&parts, Utility::pid_t ppid)
   return "Ok";
 }
 
-uint64_t udpErrorStats(const std::string& str)
-{
-  ifstream ifs("/proc/net/snmp");
-  if(!ifs)
-    return 0;
-  string line;
-  vector<string> parts;
-  while(getline(ifs,line)) {
-    if(boost::starts_with(line, "Udp: ") && isdigit(line[5])) {
-      stringtok(parts, line, " \n\t\r");
-      if(parts.size() < 7)
-       break;
-      if(str=="udp-rcvbuf-errors")
-       return boost::lexical_cast<uint64_t>(parts[5]);
-      else if(str=="udp-sndbuf-errors")
-       return boost::lexical_cast<uint64_t>(parts[6]);
-      else if(str=="udp-noport-errors")
-       return boost::lexical_cast<uint64_t>(parts[2]);
-      else if(str=="udp-in-errors")
-       return boost::lexical_cast<uint64_t>(parts[3]);
-      else
-       return 0;
-    }
-  }
-  return 0;
-}
 
 string DLListZones(const vector<string>&parts, Utility::pid_t ppid)
 {
index 8d3a8b4ba22b920fb68ae1f0a088c0a5cf3cf07d..77461b987470787bd5d2270dffe7945fcd740d4a 100644 (file)
@@ -33,6 +33,7 @@
 #include <netinet/in.h>
 #include <sys/un.h>
 #include <unistd.h>
+#include <fstream>
 #include "misc.hh"
 #include <vector>
 #include <sstream>
@@ -971,3 +972,32 @@ bool setCloseOnExec(int sock)
   return true;
 }
 
+// please feel free to add other operating systems here. What we need are stats on dropped UDP packets
+uint64_t udpErrorStats(const std::string& str)
+{
+#ifdef __linux__
+  ifstream ifs("/proc/net/snmp");
+  if(!ifs)
+    return 0;
+  string line;
+  vector<string> parts;
+  while(getline(ifs,line)) {
+    if(boost::starts_with(line, "Udp: ") && isdigit(line[5])) {
+      stringtok(parts, line, " \n\t\r");
+      if(parts.size() < 7)
+       break;
+      if(str=="udp-rcvbuf-errors")
+       return boost::lexical_cast<uint64_t>(parts[5]);
+      else if(str=="udp-sndbuf-errors")
+       return boost::lexical_cast<uint64_t>(parts[6]);
+      else if(str=="udp-noport-errors")
+       return boost::lexical_cast<uint64_t>(parts[2]);
+      else if(str=="udp-in-errors")
+       return boost::lexical_cast<uint64_t>(parts[3]);
+      else
+       return 0;
+    }
+  }
+#endif
+  return 0;
+}
index 99632853d53cd256e8c9f7922373bfbabab694b2..6cd29f34dc150941555e2915e29a30fccedfe0b4 100644 (file)
@@ -553,4 +553,5 @@ bool setBlocking( int sock );
 bool setNonBlocking( int sock );
 int closesocket(int fd);
 bool setCloseOnExec(int sock);
+uint64_t udpErrorStats(const std::string& str);
 #endif
index 1a1da6d9e4565b3dfe824aa08aa7708ceadc9da4..e61066417fb93feeb50c74c9c51d6f168baa25a4 100644 (file)
@@ -556,6 +556,13 @@ RecursorControlParser::RecursorControlParser()
   addGetStat("chain-resends", &g_stats.chainResends);
   addGetStat("tcp-clients", boost::bind(TCPConnection::getCurrentConnections));
 
+#ifdef __linux__
+  addGetStat("udp-recvbuf-errors", boost::bind(udpErrorStats, "udp-recvbuf-errors"));
+  addGetStat("udp-sndbuf-errors", boost::bind(udpErrorStats, "udp-sndbuf-errors"));
+  addGetStat("udp-noport-errors", boost::bind(udpErrorStats, "udp-noport-errors"));
+  addGetStat("udp-in-errors", boost::bind(udpErrorStats, "udp-in-errors"));
+#endif
+
   addGetStat("edns-ping-matches", &g_stats.ednsPingMatches);
   addGetStat("edns-ping-mismatches", &g_stats.ednsPingMismatches);