From fc202159bba4df949c41da6b85a2f33138d27167 Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Mon, 28 Jan 2013 10:16:01 +0000 Subject: [PATCH] add extended ghost domain test, plus (hackish) fix for it git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@3085 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- pdns/recursor_cache.cc | 16 +++++++++++++--- regression-tests.recursor/ghost-1/command | 13 +++++++++++++ regression-tests.recursor/ghost-1/description | 2 ++ .../ghost-1/expected_result | 15 +++++++++++++++ 4 files changed, 43 insertions(+), 3 deletions(-) create mode 100755 regression-tests.recursor/ghost-1/command create mode 100644 regression-tests.recursor/ghost-1/description create mode 100644 regression-tests.recursor/ghost-1/expected_result diff --git a/pdns/recursor_cache.cc b/pdns/recursor_cache.cc index c96fd2f4e..ece6b2dec 100644 --- a/pdns/recursor_cache.cc +++ b/pdns/recursor_cache.cc @@ -190,6 +190,7 @@ void MemRecursorCache::replace(time_t now, const string &qname, const QType& qt, d_cachecachevalid=false; tuple 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"<::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"<::const_iterator i=content.begin(); i != content.end(); ++i) { - // cerr<<"To store: "<content<ttl; + // cerr<<"To store: "<content<<" with ttl/ttd "<ttl<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 index 000000000..e9a7abc26 --- /dev/null +++ b/regression-tests.recursor/ghost-1/command @@ -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 index 000000000..30c9b3c70 --- /dev/null +++ b/regression-tests.recursor/ghost-1/description @@ -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 index 000000000..e1b941d56 --- /dev/null +++ b/regression-tests.recursor/ghost-1/expected_result @@ -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 -- 2.40.0