]> granicus.if.org Git - pdns/commitdiff
shave off 23 mallocs per cache miss
authorbert hubert <bert.hubert@powerdns.com>
Wed, 25 Nov 2015 13:55:01 +0000 (14:55 +0100)
committerbert hubert <bert.hubert@powerdns.com>
Wed, 25 Nov 2015 13:56:34 +0000 (14:56 +0100)
pdns/dnsparser.cc
pdns/pdns_recursor.cc
pdns/syncres.cc
pdns/syncres.hh

index a884b347a003fbabc162fe4a8c977bb3e1200efd..5589ad8ff705d3634f7c1185b5ef821cc579c9f6 100644 (file)
@@ -268,6 +268,7 @@ void MOADNSParser::init(const char *packet, unsigned int len)
     struct dnsrecordheader ah;
     vector<unsigned char> record;
     validPacket=true;
+    d_answers.reserve((unsigned int)(d_header.ancount + d_header.nscount + d_header.arcount));
     for(n=0;n < (unsigned int)(d_header.ancount + d_header.nscount + d_header.arcount); ++n) {
       DNSRecord dr;
       
index 9ad22f03bc82dba9b5680583c254caca3329cf9c..6e48f3e1c6464a81abc96268de7a008a0a934426 100644 (file)
@@ -2090,6 +2090,15 @@ void  parseEDNSSubnetWhitelist(const std::string& wlist)
   }
 }
 
+SuffixMatchNode g_delegationOnly;
+static void setupDelegationOnly()
+{
+  vector<string> parts;
+  stringtok(parts, ::arg()["delegation-only"], ", \t");
+  for(const auto& p : parts) {
+    g_delegationOnly.add(DNSName(p));
+  }
+}
 
 int serviceMain(int argc, char*argv[])
 {
@@ -2135,6 +2144,9 @@ int serviceMain(int argc, char*argv[])
       L<<Logger::Warning<<"PowerDNS Recursor itself will distribute queries over threads"<<endl;
   }
 
+  setupDelegationOnly();
+
+
   if(::arg()["trace"]=="fail") {
     SyncRes::setDefaultLogMode(SyncRes::Store);
   }
index b040e39c3d3ff30bf023ccd53fa194a9421142c9..7486083e45846bea9f0b924ceee1a9c0a7fe5f53 100644 (file)
@@ -1136,7 +1136,7 @@ int SyncRes::doResolveAt(set<DNSName> nameservers, DNSName auth, bool flawedNSSe
 
 
         if(rec.d_name.isPartOf(auth)) {
-          if(lwr.d_aabit && lwr.d_rcode==RCode::NoError && rec.d_place==DNSResourceRecord::ANSWER && ::arg().contains("delegation-only",auth.toString() /* ugh */)) {
+          if(lwr.d_aabit && lwr.d_rcode==RCode::NoError && rec.d_place==DNSResourceRecord::ANSWER && g_delegationOnly.check(auth)) {
             LOG("NO! Is from delegation-only zone"<<endl);
             s_nodelegated++;
             return RCode::NXDomain;
@@ -1153,7 +1153,6 @@ int SyncRes::doResolveAt(set<DNSName> nameservers, DNSName auth, bool flawedNSSe
             dr.d_place=DNSResourceRecord::ANSWER;
 
             dr.d_ttl += d_now.tv_sec;
-           // we should note the PLACE and not store ECS subnet details for non-answer records
             tcache[{rec.d_name,rec.d_type,rec.d_place}].records.push_back(dr);
           }
         }
index d3f39f425b6d17bcf637d6c43ff1a823f99c07b8..35c3a32d0c5720bf984922998a3e6983a7dc17bf 100644 (file)
@@ -632,7 +632,7 @@ string doTraceRegex(vector<string>::const_iterator begin, vector<string>::const_
 void parseACLs();
 extern RecursorStats g_stats;
 extern unsigned int g_numThreads;
-
+extern SuffixMatchNode g_delegationOnly;
 std::string reloadAuthAndForwards();
 ComboAddress parseIPAndPort(const std::string& input, uint16_t port);
 ComboAddress getQueryLocalAddress(int family, uint16_t port);