]> granicus.if.org Git - pdns/commitdiff
add extended ghost domain test, plus (hackish) fix for it
authorPeter van Dijk <peter.van.dijk@netherlabs.nl>
Mon, 28 Jan 2013 10:16:01 +0000 (10:16 +0000)
committerPeter van Dijk <peter.van.dijk@netherlabs.nl>
Mon, 28 Jan 2013 10:16:01 +0000 (10:16 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@3085 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/recursor_cache.cc
regression-tests.recursor/ghost-1/command [new file with mode: 0755]
regression-tests.recursor/ghost-1/description [new file with mode: 0644]
regression-tests.recursor/ghost-1/expected_result [new file with mode: 0644]

index c96fd2f4e86f345d533edd55ebefbe2a32ceb914..ece6b2dec9ee54f0a1468419b1ee7187c38f2336 100644 (file)
@@ -190,6 +190,7 @@ void MemRecursorCache::replace(time_t now, const string &qname, const QType& qt,
   d_cachecachevalid=false;
   tuple<string, uint16_t> key=make_tuple(qname, qt.getCode());
   cache_t::iterator stored=d_cache.find(key);
+  uint32_t maxTTD=UINT_MAX;
 
   bool isNew=false;
   if(stored == d_cache.end()) {
@@ -222,9 +223,18 @@ void MemRecursorCache::replace(time_t now, const string &qname, const QType& qt,
     }
   }
   
+  // limit TTL of auth->auth NSset update if needed, except for root
+  if(ce.d_auth && auth && qt.getCode()==QType::NS && !((qname.length()==1 && qname[0]=='.'))) {
+    // cerr<<"\tLimiting TTL of auth->auth NS set replace"<<endl;
+    vector<StoredRecord>::iterator j;
+    for(j = ce.d_records.begin() ; j != ce.d_records.end(); ++j) {
+      maxTTD=min(maxTTD, j->d_ttd);
+    }      
+  }
+
   // make sure that we CAN refresh the root
   if(auth && ((qname.length()==1 && qname[0]=='.') || !attemptToRefreshNSTTL(qt, content, ce) ) ) {
-    // cerr<<"\tGot auth data, and it was not refresh attempt of an NS record, nuking storage"<<endl;
+    // cerr<<"\tGot auth data, and it was not refresh attempt of an unchanged NS set, nuking storage"<<endl;
     ce.d_records.clear(); // clear non-auth data
     ce.d_auth = true;
     isNew=true;           // data should be sorted again
@@ -234,8 +244,8 @@ void MemRecursorCache::replace(time_t now, const string &qname, const QType& qt,
 
   // cerr<<"\tHave "<<content.size()<<" records to store\n";
   for(set<DNSResourceRecord>::const_iterator i=content.begin(); i != content.end(); ++i) {
-    // cerr<<"To store: "<<i->content<<endl;
-    dr.d_ttd=i->ttl;
+    // cerr<<"To store: "<<i->content<<" with ttl/ttd "<<i->ttl<<endl;
+    dr.d_ttd=min(maxTTD, i->ttl);
     dr.d_string=DNSRR2String(*i);
     
     if(isNew) 
diff --git a/regression-tests.recursor/ghost-1/command b/regression-tests.recursor/ghost-1/command
new file mode 100755 (executable)
index 0000000..e9a7abc
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+. vars
+rm configs/$PREFIX.17/drop-1
+cleandig a.www.1.ghost.example.net a | sed 's/\(.*\tIN\t[A-Z0-9]\+\t\)\([0-9]\+\)/\13600/'
+sleep 5
+touch configs/$PREFIX.17/drop-1
+cleandig b.www.1.ghost.example.net a | sed 's/\(.*\tIN\t[A-Z0-9]\+\t\)\([0-9]\+\)/\13600/'
+sleep 5
+cleandig c.www.1.ghost.example.net a | sed 's/\(.*\tIN\t[A-Z0-9]\+\t\)\([0-9]\+\)/\13600/'
+sleep 5
+cleandig d.www.1.ghost.example.net a | sed 's/\(.*\tIN\t[A-Z0-9]\+\t\)\([0-9]\+\)/\13600/'
+sleep 5
+cleandig e.www.1.ghost.example.net a | sed 's/\(.*\tIN\t[A-Z0-9]\+\t\)\([0-9]\+\)/\13600/'
diff --git a/regression-tests.recursor/ghost-1/description b/regression-tests.recursor/ghost-1/description
new file mode 100644 (file)
index 0000000..30c9b3c
--- /dev/null
@@ -0,0 +1,2 @@
+Extended ghost domain test - delegation is removed and receiver tries very
+hard to stay alive, by changing the NSset on every request.
diff --git a/regression-tests.recursor/ghost-1/expected_result b/regression-tests.recursor/ghost-1/expected_result
new file mode 100644 (file)
index 0000000..e1b941d
--- /dev/null
@@ -0,0 +1,15 @@
+0      a.www.1.ghost.example.net.      IN      A       3600    192.0.2.7
+Rcode: 0, RD: 1, QR: 1, TC: 0, AA: 0, opcode: 0
+Reply to question for qname='a.www.1.ghost.example.net.', qtype=A
+0      b.www.1.ghost.example.net.      IN      A       3600    192.0.2.7
+Rcode: 0, RD: 1, QR: 1, TC: 0, AA: 0, opcode: 0
+Reply to question for qname='b.www.1.ghost.example.net.', qtype=A
+0      c.www.1.ghost.example.net.      IN      A       3600    192.0.2.7
+Rcode: 0, RD: 1, QR: 1, TC: 0, AA: 0, opcode: 0
+Reply to question for qname='c.www.1.ghost.example.net.', qtype=A
+1      ghost.example.net.      IN      SOA     3600    ns.example.net. hostmaster.example.net. 1 3600 1800 1209600 300
+Rcode: 3, RD: 1, QR: 1, TC: 0, AA: 0, opcode: 0
+Reply to question for qname='d.www.1.ghost.example.net.', qtype=A
+1      ghost.example.net.      IN      SOA     3600    ns.example.net. hostmaster.example.net. 1 3600 1800 1209600 300
+Rcode: 3, RD: 1, QR: 1, TC: 0, AA: 0, opcode: 0
+Reply to question for qname='e.www.1.ghost.example.net.', qtype=A