pdns icon indicating copy to clipboard operation
pdns copied to clipboard

dnsdist: ponder if we should do some caching for tc=1 responses over udp

Open phonedph1 opened this issue 1 year ago • 23 comments

  • Program: dnsdist
  • Issue type: Feature request

Short description

tc=1 responses when received over udp are not cached. Maybe they should be?

Usecase

Some operators see lots of requests for say txt apple.com which produces a tc=1 response.

Description

Perhaps cache for the temp failure ttl time, or perhaps this idea is stupid.

Similar to the below, but perhaps more performant :)

diff --git a/pdns/dnsdist-cache.cc b/pdns/dnsdist-cache.cc
index 67de6226a..c147652f9 100644
--- a/pdns/dnsdist-cache.cc
+++ b/pdns/dnsdist-cache.cc
@@ -128,7 +128,17 @@ void DNSDistPacketCache::insert(uint32_t key, const boost::optional<Netmask>& su
 
   uint32_t minTTL;
 
-  if (rcode == RCode::ServFail || rcode == RCode::Refused) {
+  bool cacheTC = false;
+
+  if(receivedOverUDP) {
+     dnsheader dh;
+     memcpy(&dh, response.data(), sizeof(dh));
+     if (dh.tc == 1) {
+       cacheTC = true;
+     }
+  }
+
+  if (rcode == RCode::ServFail || rcode == RCode::Refused || cacheTC) {
     minTTL = tempFailureTTL == boost::none ? d_tempFailureTTL : *tempFailureTTL;
     if (minTTL == 0) {
       return;

phonedph1 avatar Nov 23 '23 17:11 phonedph1