From: Wouter Wijngaards Date: Fri, 4 May 2007 14:14:08 +0000 (+0000) Subject: test rrset ttl refresh. X-Git-Tag: release-0.3~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=841d09ff08020b3bb6f29493ac11e43d1d8dbdde;p=thirdparty%2Funbound.git test rrset ttl refresh. git-svn-id: file:///svn/unbound/trunk@287 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/doc/Changelog b/doc/Changelog index 5a175a185..78b90f872 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -11,6 +11,7 @@ - test for one rrset updated in the cache. - test for one rrset which is not updated, as it is not deemed trustworthy enough. + - test for TTL refreshed in rrset. 3 May 2007: Wouter - fill refs. Use new parse and encode to answer queries. diff --git a/testcode/ldns-testpkts.c b/testcode/ldns-testpkts.c index cf21d6c60..059d6e9d2 100644 --- a/testcode/ldns-testpkts.c +++ b/testcode/ldns-testpkts.c @@ -106,6 +106,8 @@ static void matchline(const char* line, struct entry* e) e->match_qname = true; } else if(str_keyword(&parse, "all")) { e->match_all = true; + } else if(str_keyword(&parse, "ttl")) { + e->match_ttl = true; } else if(str_keyword(&parse, "UDP")) { e->match_transport = transport_udp; } else if(str_keyword(&parse, "TCP")) { @@ -217,6 +219,7 @@ static struct entry* new_entry() e->match_qtype = false; e->match_qname = false; e->match_all = false; + e->match_ttl = false; e->match_serial = false; e->ixfr_soa_serial = 0; e->match_transport = transport_any; @@ -555,7 +558,7 @@ static uint32_t get_serial(ldns_pkt* p) /** match two rr lists */ static int -match_list(ldns_rr_list* q, ldns_rr_list *p) +match_list(ldns_rr_list* q, ldns_rr_list *p, bool mttl) { size_t i; if(ldns_rr_list_rr_count(q) != ldns_rr_list_rr_count(p)) @@ -567,6 +570,11 @@ match_list(ldns_rr_list* q, ldns_rr_list *p) verbose(3, "rr %d different", i); return 0; } + if(mttl && ldns_rr_ttl(ldns_rr_list_rr(q, i)) != + ldns_rr_ttl(ldns_rr_list_rr(p, i))) { + verbose(3, "rr %d ttl different", i); + return 0; + } } return 1; } @@ -583,7 +591,7 @@ cmp_bool(int x, int y) /** match all of the packet */ static int -match_all(ldns_pkt* q, ldns_pkt* p) +match_all(ldns_pkt* q, ldns_pkt* p, bool mttl) { if(ldns_pkt_get_opcode(q) != ldns_pkt_get_opcode(p)) { verbose(3, "allmatch: opcode different"); return 0;} @@ -613,13 +621,13 @@ match_all(ldns_pkt* q, ldns_pkt* p) { verbose(3, "allmatch: nscount different"); return 0;} if(ldns_pkt_arcount(q) != ldns_pkt_arcount(p)) { verbose(3, "allmatch: arcount different"); return 0;} - if(!match_list(ldns_pkt_question(q), ldns_pkt_question(p))) + if(!match_list(ldns_pkt_question(q), ldns_pkt_question(p), mttl)) { verbose(3, "allmatch: qd section different"); return 0;} - if(!match_list(ldns_pkt_answer(q), ldns_pkt_answer(p))) + if(!match_list(ldns_pkt_answer(q), ldns_pkt_answer(p), mttl)) { verbose(3, "allmatch: an section different"); return 0;} - if(!match_list(ldns_pkt_authority(q), ldns_pkt_authority(p))) + if(!match_list(ldns_pkt_authority(q), ldns_pkt_authority(p), mttl)) { verbose(3, "allmatch: ar section different"); return 0;} - if(!match_list(ldns_pkt_additional(q), ldns_pkt_additional(p))) + if(!match_list(ldns_pkt_additional(q), ldns_pkt_additional(p), mttl)) { verbose(3, "allmatch: ns section different"); return 0;} return 1; } @@ -659,7 +667,7 @@ find_match(struct entry* entries, ldns_pkt* query_pkt, verbose(3, "bad transport\n"); continue; } - if(p->match_all && !match_all(query_pkt, reply)) { + if(p->match_all && !match_all(query_pkt, reply, p->match_ttl)) { verbose(3, "bad allmatch\n"); continue; } diff --git a/testcode/ldns-testpkts.h b/testcode/ldns-testpkts.h index fde8e598a..95b2ca332 100644 --- a/testcode/ldns-testpkts.h +++ b/testcode/ldns-testpkts.h @@ -44,7 +44,8 @@ ; 'qname' makes the query match the qname from the reply ; 'serial=1023' makes the query match if ixfr serial is 1023. ; 'all' has to match header byte for byte and all rrs in packet. - MATCH [opcode] [qtype] [qname] [serial=] [all] + ; 'ttl' used with all, rrs in packet must also have matching TTLs. + MATCH [opcode] [qtype] [qname] [serial=] [all] [ttl] MATCH [UDP|TCP] MATCH ... ; Then the REPLY header is specified. @@ -157,6 +158,8 @@ struct entry { bool match_serial; /** match all of the packet */ bool match_all; + /** match ttls in the packet */ + bool match_ttl; /** match query serial with this value. */ uint32_t ixfr_soa_serial; /** match on UDP/TCP */ diff --git a/testdata/rrset_rettl.rpl b/testdata/rrset_rettl.rpl new file mode 100644 index 000000000..8177dcad1 --- /dev/null +++ b/testdata/rrset_rettl.rpl @@ -0,0 +1,119 @@ +; This is a comment. +; config options go here. +CONFIG_END + +SCENARIO_BEGIN RRset TTL is updated from message. + +STEP 1 QUERY +ENTRY_BEGIN + REPLY RD + SECTION QUESTION + www.example.com. IN A +ENTRY_END +; the query is sent to the forwarder - no cache yet. +STEP 2 CHECK_OUT_QUERY +ENTRY_BEGIN + MATCH qname qtype opcode + SECTION QUESTION + www.example.com. IN A +ENTRY_END +STEP 3 REPLY +ENTRY_BEGIN + MATCH opcode qtype qname + ADJUST copy_id + ; authoritative answer + REPLY QR AA RD RA NOERROR + SECTION QUESTION + www.example.com. IN A + SECTION ANSWER + www.example.com. IN A 10.20.30.40 + SECTION AUTHORITY + example.com. 100 IN NS ns.example.com. + SECTION ADDITIONAL + ns.example.com. IN A 10.20.30.50 +ENTRY_END +STEP 4 CHECK_ANSWER +ENTRY_BEGIN + MATCH all ttl + ; first reply, have AA set. + REPLY QR AA RD RA + SECTION QUESTION + www.example.com. IN A + SECTION ANSWER + www.example.com. IN A 10.20.30.40 + SECTION AUTHORITY + example.com. 100 IN NS ns.example.com. + SECTION ADDITIONAL + ns.example.com. IN A 10.20.30.50 +ENTRY_END + +; another query passes along +STEP 6 QUERY +ENTRY_BEGIN + REPLY RD + SECTION QUESTION + bla.example.com. IN A +ENTRY_END +STEP 7 CHECK_OUT_QUERY +ENTRY_BEGIN + MATCH qname qtype opcode + SECTION QUESTION + bla.example.com. IN A +ENTRY_END +STEP 8 REPLY +; This answer has a fresh TTL +ENTRY_BEGIN + MATCH opcode qtype qname + ADJUST copy_id + ; authoritative answer + REPLY QR AA RD RA NOERROR + SECTION QUESTION + bla.example.com. IN A + SECTION ANSWER + bla.example.com. IN A 10.20.30.140 + SECTION AUTHORITY + example.com. 200 IN NS ns.example.com. + SECTION ADDITIONAL + ns.example.com. IN A 10.20.30.50 +ENTRY_END +STEP 9 CHECK_ANSWER +ENTRY_BEGIN + MATCH all ttl + ; first reply, have AA set. + REPLY QR AA RD RA + SECTION QUESTION + bla.example.com. IN A + SECTION ANSWER + bla.example.com. IN A 10.20.30.140 + SECTION AUTHORITY + example.com. 200 IN NS ns.example.com. + SECTION ADDITIONAL + ns.example.com. IN A 10.20.30.50 +ENTRY_END + + +; original www.example.com query +STEP 10 QUERY +ENTRY_BEGIN + REPLY RD + SECTION QUESTION + www.example.com. IN A +ENTRY_END +; immediate answer without an OUT_QUERY happening (checked on exit) +; also, the answer does not have AA set +; NS rrset has been updated. +STEP 11 CHECK_ANSWER +ENTRY_BEGIN + MATCH all ttl + REPLY QR RD RA + SECTION QUESTION + www.example.com. IN A + SECTION ANSWER + www.example.com. IN A 10.20.30.40 + SECTION AUTHORITY + example.com. 200 IN NS ns.example.com. + SECTION ADDITIONAL + ns.example.com. IN A 10.20.30.50 +ENTRY_END + +SCENARIO_END