]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
WIP for researching #8697
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 3 Feb 2020 11:15:25 +0000 (12:15 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 3 Feb 2020 12:43:29 +0000 (13:43 +0100)
pdns/rec_channel_rec.cc
pdns/recursordist/docs/manpages/rec_control.1.rst
pdns/reczones.cc
pdns/syncres.cc
pdns/syncres.hh
pdns/ws-recursor.cc

index 5acc4185190ae82f909968e4a65f947cbc1e2951..a37d4cbc89ba2c50216bcd72998ddc9b4df7c45f 100644 (file)
@@ -394,14 +394,14 @@ static string doDumpFailedServers(T begin, T end)
   return "dumped "+std::to_string(total)+" records\n";
 }
 
-uint64_t* pleaseWipeCache(const DNSName& canon, bool subtree)
+uint64_t* pleaseWipeCache(const DNSName& canon, bool subtree, uint16_t qtype)
 {
-  return new uint64_t(t_RC->doWipeCache(canon, subtree));
+  return new uint64_t(t_RC->doWipeCache(canon, subtree, qtype));
 }
 
-uint64_t* pleaseWipePacketCache(const DNSName& canon, bool subtree)
+uint64_t* pleaseWipePacketCache(const DNSName& canon, bool subtree, uint16_t qtype)
 {
-  return new uint64_t(t_packetCache->doWipePacketCache(canon,0xffff, subtree));
+  return new uint64_t(t_packetCache->doWipePacketCache(canon, qtype, subtree));
 }
 
 
@@ -413,7 +413,7 @@ uint64_t* pleaseWipeAndCountNegCache(const DNSName& canon, bool subtree)
 
 
 template<typename T>
-static string doWipeCache(T begin, T end)
+static string doWipeCache(T begin, T end, uint16_t qtype)
 {
   vector<pair<DNSName, bool> > toWipe;
   for(T i=begin; i != end; ++i) {
@@ -435,8 +435,8 @@ static string doWipeCache(T begin, T end)
 
   int count=0, pcount=0, countNeg=0;
   for (auto wipe : toWipe) {
-    count+= broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeCache, wipe.first, wipe.second));
-    pcount+= broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, wipe.first, wipe.second));
+    count+= broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeCache, wipe.first, wipe.second, qtype));
+    pcount+= broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, wipe.first, wipe.second, qtype));
     countNeg+=broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeAndCountNegCache, wipe.first, wipe.second));
   }
 
@@ -538,8 +538,8 @@ static string doAddNTA(T begin, T end)
   g_luaconfs.modify([who, why](LuaConfigItems& lci) {
       lci.negAnchors[who] = why;
       });
-  broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeCache, who, true));
-  broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, who, true));
+  broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeCache, who, true, 0xffff));
+  broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, who, true, 0xffff));
   broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeAndCountNegCache, who, true));
   return "Added Negative Trust Anchor for " + who.toLogString() + " with reason '" + why + "'\n";
 }
@@ -586,8 +586,8 @@ static string doClearNTA(T begin, T end)
     g_luaconfs.modify([entry](LuaConfigItems& lci) {
         lci.negAnchors.erase(entry);
       });
-    broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeCache, entry, true));
-    broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, entry, true));
+    broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeCache, entry, true, 0xffff));
+    broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, entry, true, 0xffff));
     broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeAndCountNegCache, entry, true));
     if (!first) {
       first = false;
@@ -643,8 +643,8 @@ static string doAddTA(T begin, T end)
       auto ds=std::dynamic_pointer_cast<DSRecordContent>(DSRecordContent::make(what));
       lci.dsAnchors[who].insert(*ds);
       });
-    broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeCache, who, true));
-    broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, who, true));
+    broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeCache, who, true, 0xffff));
+    broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, who, true, 0xffff));
     broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeAndCountNegCache, who, true));
     g_log<<Logger::Warning<<endl;
     return "Added Trust Anchor for " + who.toStringRootDot() + " with data " + what + "\n";
@@ -689,8 +689,8 @@ static string doClearTA(T begin, T end)
     g_luaconfs.modify([entry](LuaConfigItems& lci) {
         lci.dsAnchors.erase(entry);
       });
-    broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeCache, entry, true));
-    broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, entry, true));
+    broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeCache, entry, true, 0xffff));
+    broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, entry, true, 0xffff));
     broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeAndCountNegCache, entry, true));
     if (!first) {
       first = false;
@@ -1690,7 +1690,8 @@ string RecursorControlParser::getAnswer(const string& question, RecursorControlP
 "top-bogus-remotes                show top remotes receiving bogus answers\n"
 "unload-lua-script                unload Lua script\n"
 "version                          return Recursor version number\n"
-"wipe-cache domain0 [domain1] ..  wipe domain data from cache\n";
+"wipe-cache domain0 [domain1] ..  wipe domain data from cache\n"
+"wipe-cache-typed type domain0 [domain1] ..  wipe domain data with qtype from cache\n";
 
   if(cmd=="get-all")
     return getAllStats();
@@ -1735,7 +1736,13 @@ string RecursorControlParser::getAnswer(const string& question, RecursorControlP
    return doDumpThrottleMap(begin, end);
 
   if(cmd=="wipe-cache" || cmd=="flushname")
-    return doWipeCache(begin, end);
+    return doWipeCache(begin, end, 0xffff);
+
+  if(cmd=="wipe-cache-typed") {
+    uint16_t qtype = QType::chartocode(begin->c_str());
+    ++begin;
+    return doWipeCache(begin, end, qtype);
+  }
 
   if(cmd=="reload-lua-script")
     return doQueueReloadLuaScript(begin, end);
index 2217adc163caa3bb2641df03add28a3054b547e6..c9f95b41834f675d22fcec3ef71bc1af50ce9694 100644 (file)
@@ -332,6 +332,9 @@ wipe-cache *DOMAIN* [*DOMAIN*] [...]
     **Warning**: Don't just wipe "www.somedomain.com", its NS records or CNAME
     target may still be undesired, so wipe "somedomain.com" as well.
 
+wipe-cache-typed qtype *DOMAIN* [*DOMAIN*] [...]
+    Same as wip-cache, but only wipe records of type *qtype*.
+
 See also
 --------
 :manpage:`pdns_recursor(1)`
index cade82750ace6102a2bc8aaef17448395eccb17e..6cba83b5e0623551e8fdec1ca594065458325382 100644 (file)
@@ -341,9 +341,9 @@ string reloadAuthAndForwards()
     }
 
     for(const auto i : oldAndNewDomains) {
-        broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeCache, i, true));
-        broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, i, true));
-        broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeAndCountNegCache, i, true));
+      broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeCache, i, true, 0xffff));
+      broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, i, true, 0xffff));
+      broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeAndCountNegCache, i, true));
     }
 
     broadcastFunction(boost::bind(pleaseUseNewSDomainsMap, newDomainMap));
index 06a9b2f0287b52b94e85bf309807d78facab36bb..83cd882205d34bb2e2e1dfd323498aa5a071482c 100644 (file)
@@ -685,12 +685,16 @@ int SyncRes::doResolve(const DNSName &qname, const QType &qtype, vector<DNSRecor
 
     // Step 1
     vector<DNSRecord> bestns;
+    DNSName nsdomain(qname);
+    if (qtype == QType::DS) {
+      nsdomain.chopOff();
+    }
     // the two retries allow getBestNSFromCache&co to reprime the root
     // hints, in case they ever go missing
     for (int tries = 0; tries < 2 && bestns.empty(); ++tries) {
       bool flawedNSSet = false;
       set<GetBestNSAnswer> beenthereIgnored;
-      getBestNSFromCache(qname, qtype, bestns, &flawedNSSet, depth + 1, beenthereIgnored);
+      getBestNSFromCache(nsdomain, qtype, bestns, &flawedNSSet, depth + 1, beenthereIgnored);
     }
 
     if (bestns.size() == 0) {
index 411ad3dd9e6af3e1a5b3bfac00d1f229805d19ab..3b8cc14e735a59e58f58c952c56fd551b50dd5b8 100644 (file)
@@ -1099,8 +1099,8 @@ uint64_t* pleaseGetConcurrentQueries();
 uint64_t* pleaseGetThrottleSize();
 uint64_t* pleaseGetPacketCacheHits();
 uint64_t* pleaseGetPacketCacheSize();
-uint64_t* pleaseWipeCache(const DNSName& canon, bool subtree=false);
-uint64_t* pleaseWipePacketCache(const DNSName& canon, bool subtree);
+uint64_t* pleaseWipeCache(const DNSName& canon, bool subtree=false, uint16_t qtype=0xffff);
+uint64_t* pleaseWipePacketCache(const DNSName& canon, bool subtree, uint16_t qtype=0xffff);
 uint64_t* pleaseWipeAndCountNegCache(const DNSName& canon, bool subtree=false);
 void doCarbonDump(void*);
 void primeHints(void);
index 81651ab88072b4d8582d2d6c12ffef2fc3ac3c2d..8a0977495bda22314d3df0cb96b784a49539d9bf 100644 (file)
@@ -382,8 +382,8 @@ static void apiServerCacheFlush(HttpRequest* req, HttpResponse* resp) {
   DNSName canon = apiNameToDNSName(req->getvars["domain"]);
   bool subtree = (req->getvars.count("subtree") > 0 && req->getvars["subtree"].compare("true") == 0);
 
-  int count = broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeCache, canon, subtree));
-  count += broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, canon, subtree));
+  int count = broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeCache, canon, subtree, 0xffff));
+  count += broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, canon, subtree, 0xffff));
   count += broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeAndCountNegCache, canon, subtree));
   resp->setBody(Json::object {
     { "count", count },