]> granicus.if.org Git - pdns/commitdiff
save a ton of DNSName(".") and DNSName("*") instantiations. Even though these live...
authorbert hubert <bert.hubert@powerdns.com>
Fri, 26 Aug 2016 13:26:10 +0000 (15:26 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Sat, 27 Aug 2016 12:15:54 +0000 (14:15 +0200)
17 files changed:
pdns/dnsrecords.cc
pdns/dnssecinfra.cc
pdns/dnswriter.cc
pdns/filterpo.cc
pdns/nsec3dig.cc
pdns/packethandler.cc
pdns/pdns_recursor.cc
pdns/pdnsutil.cc
pdns/rec-lua-conf.cc
pdns/reczones.cc
pdns/rpzloader.cc
pdns/slavecommunicator.cc
pdns/syncres.cc
pdns/test-dnsname_cc.cc
pdns/toysdig.cc
pdns/validate.cc
pdns/zone2ldap.cc

index c29323dda0cef4d08126eed82dd1ff11c4f80f4a..ed0fa758686cca2ca9b8271043e8948ec7eac891 100644 (file)
@@ -557,7 +557,7 @@ DNSRecord makeOpt(int udpsize, int extRCode, int Z)
   static_assert(sizeof(EDNS0Record) == sizeof(dr.d_ttl), "sizeof(EDNS0Record) must match sizeof(DNSRecord.d_ttl)");
   memcpy(&dr.d_ttl, &stuff, sizeof(stuff));
   dr.d_ttl=ntohl(dr.d_ttl);
-  dr.d_name=DNSName(".");
+  dr.d_name=g_rootdnsname;
   dr.d_type = QType::OPT;
   dr.d_class=udpsize;
   dr.d_place=DNSResourceRecord::ADDITIONAL;
index 31174acd446727cc590a023b0d146c2803cc3ebd..6edc8297d83761709d7ff5a1bbb6dc5755ea7bb3 100644 (file)
@@ -338,7 +338,7 @@ DNSCryptoKeyEngine* DNSCryptoKeyEngine::makeFromPEMString(DNSKEYRecordContent& d
 
 bool sharedDNSSECCompare(const shared_ptr<DNSRecordContent>& a, const shared_ptr<DNSRecordContent>& b)
 {
-  return a->serialize(DNSName("."), true, true) < b->serialize(DNSName("."), true, true);
+  return a->serialize(g_rootdnsname, true, true) < b->serialize(g_rootdnsname, true, true);
 }
 
 /**
@@ -359,7 +359,7 @@ string getMessageForRRSET(const DNSName& qname, const RRSIGRecordContent& rrc, v
   sort(signRecords.begin(), signRecords.end(), sharedDNSSECCompare);
 
   string toHash;
-  toHash.append(const_cast<RRSIGRecordContent&>(rrc).serialize(DNSName("."), true, true));
+  toHash.append(const_cast<RRSIGRecordContent&>(rrc).serialize(g_rootdnsname, true, true));
   toHash.resize(toHash.size() - rrc.d_signature.length()); // chop off the end, don't sign the signature!
 
   string nameToHash(qname.toDNSStringLC());
@@ -389,7 +389,7 @@ string getMessageForRRSET(const DNSName& qname, const RRSIGRecordContent& rrc, v
     uint32_t ttl=htonl(rrc.d_originalttl);
     toHash.append((char*)&ttl, 4);
     // for NSEC signatures, we should not lowercase the rdata section
-    string rdata=add->serialize(DNSName("."), true, (add->getType() == QType::NSEC) ? false : true);  // RFC 6840, 5.1
+    string rdata=add->serialize(g_rootdnsname, true, (add->getType() == QType::NSEC) ? false : true);  // RFC 6840, 5.1
     tmp=htons(rdata.length());
     toHash.append((char*)&tmp, 2);
     toHash.append(rdata);
index 3e07a72894619fee4e4f0ce33dff0e243d13e75d..475ca41ba06f360265d49972c21cb865e208ae40 100644 (file)
@@ -127,7 +127,7 @@ void DNSPacketWriter::addOpt(uint16_t udpsize, int extRCode, int Z, const vector
 
   ttl=ntohl(ttl); // will be reversed later on
 
-  startRecord(DNSName("."), QType::OPT, ttl, udpsize, DNSResourceRecord::ADDITIONAL, false);
+  startRecord(g_rootdnsname, QType::OPT, ttl, udpsize, DNSResourceRecord::ADDITIONAL, false);
   for(optvect_t::const_iterator iter = options.begin(); iter != options.end(); ++iter) {
     xfr16BitInt(iter->first);
     xfr16BitInt(iter->second.length());
index 7e3f08266278d4aa1ca72004f53c286846469f8d..e17d20d41458b382c0238ec1ebe95aac7668b7dd 100644 (file)
@@ -48,7 +48,7 @@ bool findNamedPolicy(const map<DNSName, DNSFilterEngine::Policy>& polmap, const
   }
 
   while(s.chopOff()){
-    iter = polmap.find(DNSName("*")+s);
+    iter = polmap.find(g_wildcarddnsname+s);
     if(iter != polmap.end()) {
       pol=iter->second;
       return true;
index facec3ce1086881cdc04487e00e0a33f74fca12f..fc372dcff5f69a66e5ece6f3a3bb231af53a2182 100644 (file)
@@ -222,7 +222,7 @@ try
   for(const auto &n: namestocheck)
   {
     proveOrDeny(nsec3s, n, nsec3salt, nsec3iters, proven, denied);
-    proveOrDeny(nsec3s, DNSName("*")+n, nsec3salt, nsec3iters, proven, denied);
+    proveOrDeny(nsec3s, g_wildcarddnsname+n, nsec3salt, nsec3iters, proven, denied);
   }
 
   if(names.count(qname))
@@ -262,7 +262,7 @@ try
     {
       cout<<"next closer ("<<nextcloser.toString()<<") NOT denied"<<endl;
     }
-    DNSName wcplusencloser=DNSName("*")+encloser;
+    DNSName wcplusencloser=g_wildcarddnsname+encloser;
     if(denied.count(wcplusencloser))
     {
       cout<<"wildcard at encloser ("<<wcplusencloser.toString()<<") is denied correctly"<<endl;
index 651bc249889579ce4a3a3e4300d523bdbc5a8b38..c1a03b376f865903f0063d345a693fd899a0b6f1 100644 (file)
@@ -345,14 +345,14 @@ bool PacketHandler::getBestWildcard(DNSPacket *p, SOAData& sd, const DNSName &ta
   wildcard=subdomain;
   while( subdomain.chopOff() && !haveSomething )  {
     if (subdomain.empty()) {
-      B.lookup(QType(QType::ANY), DNSName("*"), p, sd.domain_id); 
+      B.lookup(QType(QType::ANY), g_wildcarddnsname, p, sd.domain_id); 
     } else {
-      B.lookup(QType(QType::ANY), DNSName("*")+subdomain, p, sd.domain_id);
+      B.lookup(QType(QType::ANY), g_wildcarddnsname+subdomain, p, sd.domain_id);
     }
     while(B.get(rr)) {
       if(rr.qtype == p->qtype || rr.qtype.getCode() == QType::CNAME || (p->qtype.getCode() == QType::ANY && rr.qtype.getCode() != QType::RRSIG))
         ret->push_back(rr);
-      wildcard=DNSName("*")+subdomain;
+      wildcard=g_wildcarddnsname+subdomain;
       haveSomething=true;
     }
 
@@ -676,7 +676,7 @@ void PacketHandler::addNSEC3(DNSPacket *p, DNSPacket *r, const DNSName& target,
 
   // wildcard denial
   if (mode == 2 || mode == 4) {
-    unhashed=DNSName("*")+closest;
+    unhashed=g_wildcarddnsname+closest;
 
     hashed=hashQNameWithSalt(ns3rc, unhashed);
     DLOG(L<<"3 hash: "<<toBase32Hex(hashed)<<" "<<unhashed<<endl);
index fa2b40c9c0db1d4554d1504da6593d6f667b4b9a..73d35b37f94f215371fa1d791c00374ae10d8664 100644 (file)
@@ -1892,7 +1892,7 @@ static void houseKeeping(void *)
       sr.setNoCache();
       int res=-1;
       try {
-       res=sr.beginResolve(DNSName("."), QType(QType::NS), 1, ret);
+       res=sr.beginResolve(g_rootdnsname, QType(QType::NS), 1, ret);
       }
       catch(PDNSException& e)
        {
index c2d72f86a1a6d072808a239085485c2386d5dac8..ac8555081d98f4627fd2b1cf5babe5c462c61179 100644 (file)
@@ -996,7 +996,7 @@ int editZone(DNSSECKeeper& dk, const DNSName &zone) {
     unixDie("Editing file with: '"+cmdline+"', perhaps set EDITOR variable");
   }
   cmdline.clear();
-  ZoneParserTNG zpt(tmpnam, DNSName("."));
+  ZoneParserTNG zpt(tmpnam, g_rootdnsname);
   map<pair<DNSName,uint16_t>, vector<DNSRecord> > grouped;
   while(zpt.get(rr)) {
     try {
index f8001bf9fafad2910dcb7289f1a84ebbd88d02f1..2f7e055d020c50252aa71ab344670cddc28c6cc5 100644 (file)
@@ -36,7 +36,7 @@ LuaConfigItems::LuaConfigItems()
 {
   for (const auto &dsRecord : rootDSs) {
     auto ds=unique_ptr<DSRecordContent>(dynamic_cast<DSRecordContent*>(DSRecordContent::make(dsRecord)));
-    dsAnchors[DNSName(".")].insert(*ds);
+    dsAnchors[g_rootdnsname].insert(*ds);
   }
 }
 
index 63ccb27e3b0745c310a39f345b2aba3beeb5fbf1..7901185146f0acb9eeb51f6b6bcb29164442c609 100644 (file)
@@ -46,7 +46,7 @@ void primeHints(void)
 
   if(::arg()["hint-file"].empty()) {
     DNSRecord arr, aaaarr, nsrr;
-    nsrr.d_name=DNSName(".");
+    nsrr.d_name=g_rootdnsname;
     arr.d_type=QType::A;
     aaaarr.d_type=QType::AAAA;
     nsrr.d_type=QType::NS;
@@ -94,7 +94,7 @@ void primeHints(void)
       }
     }
   }
-  t_RC->replace(time(0), DNSName("."), QType(QType::NS), nsset, vector<std::shared_ptr<RRSIGRecordContent>>(), true); // and stuff in the cache (auth)
+  t_RC->replace(time(0), g_rootdnsname, QType(QType::NS), nsset, vector<std::shared_ptr<RRSIGRecordContent>>(), true); // and stuff in the cache (auth)
 }
 
 static void makeNameToIPZone(SyncRes::domainmap_t* newMap, const DNSName& hostname, const string& ip)
index 8e4b3cb9b2a50bc04074f096bfda7eb90c77dc14..3d78b2a137ceca41fe001bc864fd348571a62e95 100644 (file)
@@ -82,7 +82,7 @@ void RPZRecordToPolicy(const DNSRecord& dr, DNSFilterEngine& target, bool addOrR
     else if(target.isRoot()) {
       // cerr<<"Wants NXDOMAIN for "<<dr.d_name<<": ";
       pol.d_kind = DNSFilterEngine::PolicyKind::NXDOMAIN;
-    } else if(target==DNSName("*")) {
+    } else if(target==g_wildcarddnsname) {
       // cerr<<"Wants NODATA for "<<dr.d_name<<": ";
       pol.d_kind = DNSFilterEngine::PolicyKind::NODATA;
     }
index 2828a7289ac2d397368499db3879e0682bafb169..6d483f66f1e1def136b22991daea821921fa6483 100644 (file)
@@ -102,7 +102,7 @@ void CommunicatorClass::ixfrSuck(const DNSName &domain, const TSIGTriplet& tt, c
     st.serial=di.serial;
 
     DNSRecord dr;
-    dr.d_content = std::make_shared<SOARecordContent>(DNSName("."), DNSName("."), st);
+    dr.d_content = std::make_shared<SOARecordContent>(g_rootdnsname, g_rootdnsname, st);
     auto deltas = getIXFRDeltas(remote, domain, dr, tt, laddr.sin4.sin_family ? &laddr : 0, ((size_t) ::arg().asNum("xfr-max-received-mbytes")) * 1024 * 1024);
     zs.numDeltas=deltas.size();
     //    cout<<"Got "<<deltas.size()<<" deltas from serial "<<di.serial<<", applying.."<<endl;
index 2894f1701dd995280b10cf6b3932060ea2139c5c..44e0332495105a551e4fc94568ea30f50ad2973a 100644 (file)
@@ -239,7 +239,7 @@ bool SyncRes::doOOBResolve(const DNSName &qname, const QType &qtype, vector<DNSR
   DNSName wcarddomain(qname);
   while(wcarddomain != iter->first && wcarddomain.chopOff()) {
     LOG(prefix<<qname<<": trying '*."<<wcarddomain<<"' in "<<authdomain<<endl);
-    range=iter->second.d_records.equal_range(boost::make_tuple(DNSName("*")+wcarddomain));
+    range=iter->second.d_records.equal_range(boost::make_tuple(g_wildcarddnsname+wcarddomain));
     if(range.first==range.second)
       continue;
 
@@ -1133,7 +1133,7 @@ int SyncRes::doResolveAt(NsSet &nameservers, DNSName auth, bool flawedNSSet, con
                t_sstorage->nsSpeeds[*tns].submit(*remoteIP, 1000000, &d_now); // 1 sec
 
                // code below makes sure we don't filter COM or the root
-                if (s_serverdownmaxfails > 0 && (auth != DNSName(".")) && t_sstorage->fails.incr(*remoteIP) >= s_serverdownmaxfails) {
+                if (s_serverdownmaxfails > 0 && (auth != g_rootdnsname) && t_sstorage->fails.incr(*remoteIP) >= s_serverdownmaxfails) {
                   LOG(prefix<<qname<<": Max fails reached resolving on "<< remoteIP->toString() <<". Going full throttle for "<< s_serverdownthrottletime <<" seconds" <<endl);
                   t_sstorage->throttle.throttle(d_now.tv_sec, boost::make_tuple(*remoteIP, "", 0), s_serverdownthrottletime, 10000); // mark server as down
                 } else if(resolveret==-1)
index 26f232ea8c939e5861dfa83b8337cb38859f4a65..dd7388cc6677a99cb3aef28a519b0556c15aa575 100644 (file)
@@ -286,7 +286,7 @@ BOOST_AUTO_TEST_CASE(test_PacketParse) {
   vector<unsigned char> packet;
   reportBasicTypes();
   DNSName root(".");
-  DNSPacketWriter dpw1(packet, DNSName("."), QType::AAAA);
+  DNSPacketWriter dpw1(packet, g_rootdnsname, QType::AAAA);
   DNSName p((char*)&packet[0], packet.size(), 12, false);
   BOOST_CHECK_EQUAL(p, root);
   unsigned char* buffer=&packet[0];
@@ -458,7 +458,7 @@ BOOST_AUTO_TEST_CASE(test_suffixmatch) {
 
   BOOST_CHECK(!smn.check(DNSName("www.news.gov.uk.")));
 
-  smn.add(DNSName(".")); // block the root
+  smn.add(g_rootdnsname); // block the root
   BOOST_CHECK(smn.check(DNSName("a.root-servers.net.")));
 }
 
@@ -503,9 +503,9 @@ BOOST_AUTO_TEST_CASE(test_compare_canonical) {
   BOOST_CHECK(!DNSName("www.BeRt.com").canonCompare(DNSName("WWW.berT.com")));
 
   CanonDNSNameCompare a;
-  BOOST_CHECK(a(DNSName("."), DNSName("www.powerdns.com")));
-  BOOST_CHECK(a(DNSName("."), DNSName("www.powerdns.net")));
-  BOOST_CHECK(!a(DNSName("www.powerdns.net"), DNSName(".")));
+  BOOST_CHECK(a(g_rootdnsname, DNSName("www.powerdns.com")));
+  BOOST_CHECK(a(g_rootdnsname, DNSName("www.powerdns.net")));
+  BOOST_CHECK(!a(DNSName("www.powerdns.net"), g_rootdnsname));
 
   vector<DNSName> vec;
   for(const std::string& a : {"bert.com.", "alpha.nl.", "articles.xxx.",
index 4992b05741d5fc96a79a72fbb979ea970b256bc9..1900183b476bd964af3ef3819a10be9fe037dc6d 100644 (file)
@@ -103,7 +103,7 @@ LuaConfigItems::LuaConfigItems()
 {
   for (const auto &dsRecord : rootDSs) {
     auto ds=unique_ptr<DSRecordContent>(dynamic_cast<DSRecordContent*>(DSRecordContent::make(dsRecord)));
-    dsAnchors[DNSName(".")].insert(*ds);
+    dsAnchors[g_rootdnsname].insert(*ds);
   }
 }
 
index 83f7b973a1183dfb83782875fac66b059446f059..9281118f35e434c1b6ba40a116c08af3015ffd21 100644 (file)
@@ -283,7 +283,7 @@ vState getKeysFor(DNSRecordOracle& dro, const DNSName& zone, keyset_t &keyset)
          LOG("DNSKEY did not match the DS, parent DS: "<<drc.getZoneRepresentation() << " ! = "<<dsrc2.getZoneRepresentation()<<endl);
        }
         // cout<<"    subgraph "<<dotEscape("cluster "+qname)<<" { "<<dotEscape("DS "+qname)<<" -> "<<dotEscape("DNSKEY "+qname)<<" [ label = \""<<dsrc.d_tag<<"/"<<static_cast<int>(dsrc.d_digesttype)<<"\" ]; label = \"zone: "<<qname<<"\"; }"<<endl;
-       dotEdge(DNSName("."), "DS", qname, "" /*std::to_string(dsrc.d_tag)*/, "DNSKEY", qname, std::to_string(drc.getTag()), isValid ? "green" : "red");
+       dotEdge(g_rootdnsname, "DS", qname, "" /*std::to_string(dsrc.d_tag)*/, "DNSKEY", qname, std::to_string(drc.getTag()), isValid ? "green" : "red");
         // dotNode("DNSKEY", qname, (boost::format("tag=%d, algo=%d") % drc.getTag() % static_cast<int>(drc.d_algorithm)).str());
       }
     }
@@ -486,13 +486,13 @@ void dotEdge(DNSName zone, string type1, DNSName name1, string tag1, string type
 {
 #ifdef GRAPHVIZ
   cout<<"    ";
-  if(zone != DNSName(".")) cout<<"subgraph "<<dotEscape("cluster "+zone.toString())<<" { ";
+  if(zone != g_rootdnsname) cout<<"subgraph "<<dotEscape("cluster "+zone.toString())<<" { ";
   cout<<dotEscape(dotName(type1, name1, tag1))
       <<" -> "
       <<dotEscape(dotName(type2, name2, tag2));
   if(color != "") cout<<" [ color=\""<<color<<"\" ]; ";
   else cout<<"; ";
-  if(zone != DNSName(".")) cout<<"label = "<<dotEscape("zone: "+zone.toString())<<";"<<"}";
+  if(zone != g_rootdnsname) cout<<"label = "<<dotEscape("zone: "+zone.toString())<<";"<<"}";
   cout<<endl;
 #endif
 }
index d2d44ab305469eab8a6dd1d174dcfe9de77792a3..bbb65f2fee211f87cb95f11bdfd114b76d8109a6 100644 (file)
@@ -210,7 +210,7 @@ int main( int argc, char* argv[] )
                                         }
                                 try
                                 {
-                                 if( i->name != DNSName(".") && i->name != DNSName("localhost") && i->name != DNSName("0.0.127.in-addr.arpa") )
+                                 if( i->name != g_rootdnsname && i->name != DNSName("localhost") && i->name != DNSName("0.0.127.in-addr.arpa") )
                                         {
                                                 cerr << "Parsing file: " << i->filename << ", domain: " << i->name << endl;
                                                 g_zonename = i->name;