From 56c9fcf07580457442b80ac32bdb7c07aa0df870 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Wed, 4 Jan 2012 03:06:51 +0000 Subject: [PATCH] 3260. [bug] "rrset-order cyclic" could appear not to rotate for some query patterns. [RT #27170/27185] --- CHANGES | 4 +- bin/named/query.c | 27 +- .../system/rrsetorder/dig.out.cyclic.fixed1 | 4 - .../system/rrsetorder/dig.out.cyclic.fixed2 | 4 - .../system/rrsetorder/dig.out.cyclic.fixed3 | 4 - .../system/rrsetorder/dig.out.cyclic.fixed4 | 4 - .../system/rrsetorder/dig.out.cyclic.good1 | 4 - .../system/rrsetorder/dig.out.cyclic.good2 | 4 - .../system/rrsetorder/dig.out.cyclic.good3 | 4 - .../system/rrsetorder/dig.out.cyclic.good4 | 4 - bin/tests/system/rrsetorder/ns1/root.db | 10 +- bin/tests/system/rrsetorder/tests.sh | 372 ++++++++++-------- lib/dns/rbtdb.c | 12 +- 13 files changed, 238 insertions(+), 219 deletions(-) delete mode 100644 bin/tests/system/rrsetorder/dig.out.cyclic.fixed1 delete mode 100644 bin/tests/system/rrsetorder/dig.out.cyclic.fixed2 delete mode 100644 bin/tests/system/rrsetorder/dig.out.cyclic.fixed3 delete mode 100644 bin/tests/system/rrsetorder/dig.out.cyclic.fixed4 delete mode 100644 bin/tests/system/rrsetorder/dig.out.cyclic.good1 delete mode 100644 bin/tests/system/rrsetorder/dig.out.cyclic.good2 delete mode 100644 bin/tests/system/rrsetorder/dig.out.cyclic.good3 delete mode 100644 bin/tests/system/rrsetorder/dig.out.cyclic.good4 diff --git a/CHANGES b/CHANGES index 500853a5a2..e5d0d98c79 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,5 @@ -3260. [bug] "rrset-order cyclic" could appears to not rotate - for some query patterns. [RT #27170] +3260. [bug] "rrset-order cyclic" could appear not to rotate + for some query patterns. [RT #27170/27185] --- 9.9.0rc1 released --- diff --git a/bin/named/query.c b/bin/named/query.c index eef5799619..a51059742b 100644 --- a/bin/named/query.c +++ b/bin/named/query.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: query.c,v 1.378 2011/11/16 09:44:31 each Exp $ */ +/* $Id: query.c,v 1.379 2012/01/04 03:06:49 each Exp $ */ /*! \file */ @@ -1126,7 +1126,8 @@ query_isduplicate(ns_client_t *client, dns_name_t *name, if (name == mname) mname = NULL; - *mnamep = mname; + if (mnamep != NULL) + *mnamep = mname; CTRACE("query_isduplicate: false: done"); return (ISC_FALSE); @@ -1373,6 +1374,8 @@ query_addadditional(void *arg, dns_name_t *name, dns_rdatatype_t qtype) { if (sigrdataset == NULL) goto addname; } + if (query_isduplicate(client, fname, dns_rdatatype_a, NULL)) + goto aaaa_lookup; result = dns_db_findrdataset(db, node, version, dns_rdatatype_a, 0, client->now, @@ -1416,6 +1419,9 @@ query_addadditional(void *arg, dns_name_t *name, dns_rdatatype_t qtype) { dns_rdataset_disassociate(sigrdataset); } } + aaaa_lookup: + if (query_isduplicate(client, fname, dns_rdatatype_aaaa, NULL)) + goto addname; result = dns_db_findrdataset(db, node, version, dns_rdatatype_aaaa, 0, client->now, @@ -1583,7 +1589,13 @@ query_addadditional2(void *arg, dns_name_t *name, dns_rdatatype_t qtype) { dns_clientinfomethods_t cm; dns_clientinfo_t ci; - if (qtype != dns_rdatatype_a) { + /* + * If we don't have an additional cache call query_addadditional. + */ + client = additionalctx->client; + REQUIRE(NS_CLIENT_VALID(client)); + + if (qtype != dns_rdatatype_a || client->view->acache == NULL) { /* * This function is optimized for "address" types. For other * types, use a generic routine. @@ -1597,8 +1609,6 @@ query_addadditional2(void *arg, dns_name_t *name, dns_rdatatype_t qtype) { * Initialization. */ rdataset_base = additionalctx->rdataset; - client = additionalctx->client; - REQUIRE(NS_CLIENT_VALID(client)); eresult = ISC_R_SUCCESS; fname = NULL; rdataset = NULL; @@ -1857,6 +1867,9 @@ query_addadditional2(void *arg, dns_name_t *name, dns_rdatatype_t qtype) { if (sigrdataset == NULL) goto cleanup; + if (additionaltype == dns_rdatasetadditional_fromcache && + query_isduplicate(client, fname, dns_rdatatype_a, NULL)) + goto aaaa_lookup; /* * Find A RRset with sig RRset. Even if we don't find a sig RRset * for a client using DNSSEC, we'll continue the process to make a @@ -1901,6 +1914,10 @@ query_addadditional2(void *arg, dns_name_t *name, dns_rdatatype_t qtype) { } } + aaaa_lookup: + if (additionaltype == dns_rdatasetadditional_fromcache && + query_isduplicate(client, fname, dns_rdatatype_aaaa, NULL)) + goto foundcache; /* Find AAAA RRset with sig RRset */ result = dns_db_findrdataset(db, node, version, dns_rdatatype_aaaa, 0, client->now, rdataset, sigrdataset); diff --git a/bin/tests/system/rrsetorder/dig.out.cyclic.fixed1 b/bin/tests/system/rrsetorder/dig.out.cyclic.fixed1 deleted file mode 100644 index c25c75601e..0000000000 --- a/bin/tests/system/rrsetorder/dig.out.cyclic.fixed1 +++ /dev/null @@ -1,4 +0,0 @@ -1.2.3.4 -1.2.3.3 -1.2.3.2 -1.2.3.1 diff --git a/bin/tests/system/rrsetorder/dig.out.cyclic.fixed2 b/bin/tests/system/rrsetorder/dig.out.cyclic.fixed2 deleted file mode 100644 index e8deb6717d..0000000000 --- a/bin/tests/system/rrsetorder/dig.out.cyclic.fixed2 +++ /dev/null @@ -1,4 +0,0 @@ -1.2.3.3 -1.2.3.2 -1.2.3.1 -1.2.3.4 diff --git a/bin/tests/system/rrsetorder/dig.out.cyclic.fixed3 b/bin/tests/system/rrsetorder/dig.out.cyclic.fixed3 deleted file mode 100644 index 3b27693958..0000000000 --- a/bin/tests/system/rrsetorder/dig.out.cyclic.fixed3 +++ /dev/null @@ -1,4 +0,0 @@ -1.2.3.2 -1.2.3.1 -1.2.3.4 -1.2.3.3 diff --git a/bin/tests/system/rrsetorder/dig.out.cyclic.fixed4 b/bin/tests/system/rrsetorder/dig.out.cyclic.fixed4 deleted file mode 100644 index d2ca6fc366..0000000000 --- a/bin/tests/system/rrsetorder/dig.out.cyclic.fixed4 +++ /dev/null @@ -1,4 +0,0 @@ -1.2.3.1 -1.2.3.4 -1.2.3.3 -1.2.3.2 diff --git a/bin/tests/system/rrsetorder/dig.out.cyclic.good1 b/bin/tests/system/rrsetorder/dig.out.cyclic.good1 deleted file mode 100644 index c272c756e2..0000000000 --- a/bin/tests/system/rrsetorder/dig.out.cyclic.good1 +++ /dev/null @@ -1,4 +0,0 @@ -1.2.3.1 -1.2.3.2 -1.2.3.3 -1.2.3.4 diff --git a/bin/tests/system/rrsetorder/dig.out.cyclic.good2 b/bin/tests/system/rrsetorder/dig.out.cyclic.good2 deleted file mode 100644 index 6a39e3f3eb..0000000000 --- a/bin/tests/system/rrsetorder/dig.out.cyclic.good2 +++ /dev/null @@ -1,4 +0,0 @@ -1.2.3.2 -1.2.3.3 -1.2.3.4 -1.2.3.1 diff --git a/bin/tests/system/rrsetorder/dig.out.cyclic.good3 b/bin/tests/system/rrsetorder/dig.out.cyclic.good3 deleted file mode 100644 index 6082a255fc..0000000000 --- a/bin/tests/system/rrsetorder/dig.out.cyclic.good3 +++ /dev/null @@ -1,4 +0,0 @@ -1.2.3.3 -1.2.3.4 -1.2.3.1 -1.2.3.2 diff --git a/bin/tests/system/rrsetorder/dig.out.cyclic.good4 b/bin/tests/system/rrsetorder/dig.out.cyclic.good4 deleted file mode 100644 index a5530c658f..0000000000 --- a/bin/tests/system/rrsetorder/dig.out.cyclic.good4 +++ /dev/null @@ -1,4 +0,0 @@ -1.2.3.4 -1.2.3.1 -1.2.3.2 -1.2.3.3 diff --git a/bin/tests/system/rrsetorder/ns1/root.db b/bin/tests/system/rrsetorder/ns1/root.db index dd2f08f444..9401f10f70 100644 --- a/bin/tests/system/rrsetorder/ns1/root.db +++ b/bin/tests/system/rrsetorder/ns1/root.db @@ -12,7 +12,7 @@ ; OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR ; PERFORMANCE OF THIS SOFTWARE. -; $Id: root.db,v 1.4 2007/06/19 23:47:05 tbox Exp $ +; $Id: root.db,v 1.5 2012/01/04 03:06:51 each Exp $ $TTL 3600 . SOA hostmaster.isc.org. a.root-servers.nil. ( @@ -22,7 +22,8 @@ $TTL 3600 1200 600 ) . NS a.root-servers.nil. -a.root-servers.nil A 10.53.0.1 +. NS cyclic.example. +a.root-servers.nil. A 10.53.0.1 ; fixed.example. A 1.2.3.4 fixed.example. A 1.2.3.3 @@ -38,3 +39,8 @@ cyclic.example. A 1.2.3.4 cyclic.example. A 1.2.3.3 cyclic.example. A 1.2.3.2 cyclic.example. A 1.2.3.1 +; +cyclic2.example. A 1.2.3.4 +cyclic2.example. A 1.2.3.3 +cyclic2.example. A 1.2.3.2 +cyclic2.example. A 1.2.3.1 diff --git a/bin/tests/system/rrsetorder/tests.sh b/bin/tests/system/rrsetorder/tests.sh index 1f58e028da..61b330ce91 100644 --- a/bin/tests/system/rrsetorder/tests.sh +++ b/bin/tests/system/rrsetorder/tests.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2006-2008, 2011 Internet Systems Consortium, Inc. ("ISC") +# Copyright (C) 2006-2008 Internet Systems Consortium, Inc. ("ISC") # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -14,13 +14,12 @@ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -# $Id: tests.sh,v 1.11 2011/12/23 23:47:13 tbox Exp $ +# $Id: tests.sh,v 1.12 2012/01/04 03:06:50 each Exp $ SYSTEMTESTTOP=.. . $SYSTEMTESTTOP/conf.sh status=0 -n=0 if grep "^#define DNS_RDATASET_FIXED" $TOP/config.h > /dev/null 2>&1 ; then test_fixed=true @@ -32,65 +31,73 @@ fi # # # -n=`expr $n + 1` if $test_fixed; then - echo "I: Checking order fixed (master) ($n)" + echo "I: Checking order fixed (master)" + ret=0 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 do - ret=0 $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \ - -p 5300 @10.53.0.1 fixed.example > dig.out.test$n || ret=1 - cmp -s dig.out.test$n dig.out.fixed.good || ret=1 - [ $ret = 0 ] && break + -p 5300 @10.53.0.1 fixed.example > dig.out.fixed || ret=1 + cmp -s dig.out.fixed dig.out.fixed.good || ret=1 done if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` -else - echo "I: Skipped: Checking order fixed (master) ($n)" fi # # # -n=`expr $n + 1` -echo "I: Checking order cyclic (master) ($n)" +echo "I: Checking order cyclic (master + additional)" ret=0 -for i in 1 2 3 4 +matches=0 +for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 do - eval match$i=0 + j=`expr $i % 4` + $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \ + -p 5300 @10.53.0.1 cyclic.example > dig.out.cyclic || ret=1 + if [ $i -le 4 ]; then + cp dig.out.cyclic dig.out.$j + else + cmp -s dig.out.cyclic dig.out.$j && matches=`expr $matches + 1` + fi done -for i in a b c d e f g h -do -$DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \ - -p 5300 @10.53.0.1 cyclic.example > dig.out.cyclic || ret=1 - match=0 - for j in 1 2 3 4 - do - if $test_fixed; then - cmp -s dig.out.cyclic dig.out.cyclic.fixed$j && { - eval "match$j=1 match=1"; - } - else - cmp -s dig.out.cyclic dig.out.cyclic.good$j && { - eval "match$j=1 match=1"; - } - fi - if [ $match -eq 1 ]; then break; fi - done - if [ $match -eq 0 ]; then ret=1; echo "I:unexpected order"; cat dig.out.cyclic; fi -done -match=0 -for i in 1 2 3 4 -do - eval "match=\`expr \$match + \$match$i\`" -done -echo "I: Cyclic selection return $match of 4 possible orders in 8 samples" -if [ $match -ne 4 ]; then echo ret=1; fi +cmp -s dig.out.0 dig.out.1 && ret=1 +cmp -s dig.out.0 dig.out.2 && ret=1 +cmp -s dig.out.0 dig.out.3 && ret=1 +cmp -s dig.out.1 dig.out.2 && ret=1 +cmp -s dig.out.1 dig.out.3 && ret=1 +cmp -s dig.out.2 dig.out.3 && ret=1 +if [ $matches -ne 16 ]; then ret=1; fi if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` -n=`expr $n + 1` -echo "I: Checking order random (master) ($n)" +# +# +# +echo "I: Checking order cyclic (master)" +ret=0 +matches=0 +for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 +do + j=`expr $i % 4` + $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \ + -p 5300 @10.53.0.1 cyclic2.example > dig.out.cyclic2 || ret=1 + if [ $i -le 4 ]; then + cp dig.out.cyclic2 dig.out.$j + else + cmp -s dig.out.cyclic2 dig.out.$j && matches=`expr $matches + 1` + fi +done +cmp -s dig.out.0 dig.out.1 && ret=1 +cmp -s dig.out.0 dig.out.2 && ret=1 +cmp -s dig.out.0 dig.out.3 && ret=1 +cmp -s dig.out.1 dig.out.2 && ret=1 +cmp -s dig.out.1 dig.out.3 && ret=1 +cmp -s dig.out.2 dig.out.3 && ret=1 +if [ $matches -ne 16 ]; then ret=1; fi +if [ $ret != 0 ]; then echo "I:failed"; fi +status=`expr $status + $ret` +echo "I: Checking order random (master)" ret=0 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 do @@ -121,64 +128,74 @@ status=`expr $status + $ret` # # # -n=`expr $n + 1` if $test_fixed; then - echo "I: Checking order fixed (slave) ($n)" + echo "I: Checking order fixed (slave)" ret=0 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 do $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \ - -p 5300 @10.53.0.2 fixed.example > dig.out.test$n || ret=1 - cmp -s dig.out.test$n dig.out.fixed.good || ret=1 + -p 5300 @10.53.0.2 fixed.example > dig.out.fixed || ret=1 + cmp -s dig.out.fixed dig.out.fixed.good || ret=1 done if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` -else - echo "I: Skipped: Checking order fixed (slave) ($n)" fi # # # -n=`expr $n + 1` -echo "I: Checking order cyclic (slave) ($n)" +echo "I: Checking order cyclic (slave + additional)" ret=0 -for i in 1 2 3 4 +matches=0 +for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 do - eval match$i=0 + j=`expr $i % 4` + $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \ + -p 5300 @10.53.0.2 cyclic.example > dig.out.cyclic || ret=1 + if [ $i -le 4 ]; then + cp dig.out.cyclic dig.out.$j + else + cmp -s dig.out.cyclic dig.out.$j && matches=`expr $matches + 1` + fi done -for i in a b c d e f g h -do -$DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \ - -p 5300 @10.53.0.2 cyclic.example > dig.out.cyclic || ret=1 - match=0 - for j in 1 2 3 4 - do - if $test_fixed; then - cmp -s dig.out.cyclic dig.out.cyclic.fixed$j && { - eval "match$j=1 match=1"; - } - else - cmp -s dig.out.cyclic dig.out.cyclic.good$j && { - eval "match$j=1 match=1"; - } - fi - if [ $match -eq 1 ]; then break; fi - done - if [ $match -eq 0 ]; then ret=1; echo "I:unexpected order"; fi -done -match=0 -for i in 1 2 3 4 -do - eval "match=\`expr \$match + \$match$i\`" -done -echo "I: Cyclic selection return $match of 4 possible orders in 8 samples" -if [ $match -ne 4 ]; then echo ret=1; fi +cmp -s dig.out.0 dig.out.1 && ret=1 +cmp -s dig.out.0 dig.out.2 && ret=1 +cmp -s dig.out.0 dig.out.3 && ret=1 +cmp -s dig.out.1 dig.out.2 && ret=1 +cmp -s dig.out.1 dig.out.3 && ret=1 +cmp -s dig.out.2 dig.out.3 && ret=1 +if [ $matches -ne 16 ]; then ret=1; fi if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` -n=`expr $n + 1` -echo "I: Checking order random (slave) ($n)" +# +# +# +echo "I: Checking order cyclic (slave)" +ret=0 +matches=0 +for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 +do + j=`expr $i % 4` + $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \ + -p 5300 @10.53.0.2 cyclic2.example > dig.out.cyclic2 || ret=1 + if [ $i -le 4 ]; then + cp dig.out.cyclic2 dig.out.$j + else + cmp -s dig.out.cyclic2 dig.out.$j && matches=`expr $matches + 1` + fi +done +cmp -s dig.out.0 dig.out.1 && ret=1 +cmp -s dig.out.0 dig.out.2 && ret=1 +cmp -s dig.out.0 dig.out.3 && ret=1 +cmp -s dig.out.1 dig.out.2 && ret=1 +cmp -s dig.out.1 dig.out.3 && ret=1 +cmp -s dig.out.2 dig.out.3 && ret=1 +if [ $matches -ne 16 ]; then ret=1; fi +if [ $ret != 0 ]; then echo "I:failed"; fi +status=`expr $status + $ret` + +echo "I: Checking order random (slave)" ret=0 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 do @@ -210,8 +227,7 @@ echo "I: Shutting down slave" (cd ..; sh stop.sh rrsetorder ns2 ) -n=`expr $n + 1` -echo "I: Checking for slave's on disk copy of zone ($n)" +echo "I: Checking for slave's on disk copy of zone" if [ ! -f ns2/root.bk ] then @@ -226,67 +242,74 @@ echo "I: Re-starting slave" # # # -n=`expr $n + 1` if $test_fixed; then - echo "I: Checking order fixed (slave loaded from disk) ($n)" + echo "I: Checking order fixed (slave loaded from disk)" + ret=0 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 do - ret=0 $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \ - -p 5300 @10.53.0.2 fixed.example > dig.out.test$n || ret=1 - cmp -s dig.out.test$n dig.out.fixed.good || ret=1 - [ $ret = 0 ] && break - sleep 1 + -p 5300 @10.53.0.2 fixed.example > dig.out.fixed || ret=1 + cmp -s dig.out.fixed dig.out.fixed.good || ret=1 done if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` -else - echo "I: Skipped: Checking order fixed (slave loaded from disk) ($n)" - fi # # # -n=`expr $n + 1` -echo "I: Checking order cyclic (slave loaded from disk) ($n)" +echo "I: Checking order cyclic (slave + additional, loaded from disk)" ret=0 -for i in 1 2 3 4 +matches=0 +for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 do - eval match$i=0 + j=`expr $i % 4` + $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \ + -p 5300 @10.53.0.2 cyclic.example > dig.out.cyclic || ret=1 + if [ $i -le 4 ]; then + cp dig.out.cyclic dig.out.$j + else + cmp -s dig.out.cyclic dig.out.$j && matches=`expr $matches + 1` + fi done -for i in a b c d e f g h -do -$DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \ - -p 5300 @10.53.0.2 cyclic.example > dig.out.cyclic || ret=1 - match=0 - for j in 1 2 3 4 - do - if $test_fixed; then - cmp -s dig.out.cyclic dig.out.cyclic.fixed$j && { - eval "match$j=1 match=1"; - } - else - cmp -s dig.out.cyclic dig.out.cyclic.good$j && { - eval "match$j=1 match=1"; - } - fi - if [ $match -eq 1 ]; then break; fi - done - if [ $match -eq 0 ]; then ret=1; echo "I:unexpected order"; fi -done -match=0 -for i in 1 2 3 4 -do - eval "match=\`expr \$match + \$match$i\`" -done -echo "I: Cyclic selection return $match of 4 possible orders in 8 samples" -if [ $match -ne 4 ]; then echo ret=1; fi +cmp -s dig.out.0 dig.out.1 && ret=1 +cmp -s dig.out.0 dig.out.2 && ret=1 +cmp -s dig.out.0 dig.out.3 && ret=1 +cmp -s dig.out.1 dig.out.2 && ret=1 +cmp -s dig.out.1 dig.out.3 && ret=1 +cmp -s dig.out.2 dig.out.3 && ret=1 +if [ $matches -ne 16 ]; then ret=1; fi if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` -n=`expr $n + 1` -echo "I: Checking order random (slave loaded from disk) ($n)" +# +# +# +echo "I: Checking order cyclic (slave loaded from disk)" +ret=0 +matches=0 +for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 +do + j=`expr $i % 4` + $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \ + -p 5300 @10.53.0.2 cyclic2.example > dig.out.cyclic2 || ret=1 + if [ $i -le 4 ]; then + cp dig.out.cyclic2 dig.out.$j + else + cmp -s dig.out.cyclic2 dig.out.$j && matches=`expr $matches + 1` + fi +done +cmp -s dig.out.0 dig.out.1 && ret=1 +cmp -s dig.out.0 dig.out.2 && ret=1 +cmp -s dig.out.0 dig.out.3 && ret=1 +cmp -s dig.out.1 dig.out.2 && ret=1 +cmp -s dig.out.1 dig.out.3 && ret=1 +cmp -s dig.out.2 dig.out.3 && ret=1 +if [ $matches -ne 16 ]; then ret=1; fi +if [ $ret != 0 ]; then echo "I:failed"; fi +status=`expr $status + $ret` + +echo "I: Checking order random (slave loaded from disk)" ret=0 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 do @@ -317,65 +340,80 @@ status=`expr $status + $ret` # # # -n=`expr $n + 1` if $test_fixed; then - echo "I: Checking order fixed (cache) ($n)" + echo "I: Checking order fixed (cache)" ret=0 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 do $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \ - -p 5300 @10.53.0.3 fixed.example > dig.out.test$n || ret=1 - cmp -s dig.out.test$n dig.out.fixed.good || ret=1 + -p 5300 @10.53.0.3 fixed.example > dig.out.fixed || ret=1 + cmp -s dig.out.fixed dig.out.fixed.good || ret=1 done if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` -else - echo "I: Skipped: Checking order fixed (cache) ($n)" fi # # # -n=`expr $n + 1` -echo "I: Checking order cyclic (cache) ($n)" +echo "I: Checking order cyclic (cache + additional)" ret=0 -for i in 1 2 3 4 -do - eval match$i=0 -done -for i in a b c d e f g h -do +# prime acache $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \ - -p 5300 @10.53.0.3 cyclic.example > dig.out.cyclic || ret=1 - match=0 - for j in 1 2 3 4 - do - if $test_fixed; then - cmp -s dig.out.cyclic dig.out.cyclic.fixed$j && { - eval "match$j=1 match=1"; - } - else - cmp -s dig.out.cyclic dig.out.cyclic.good$j && { - eval "match$j=1 match=1"; - } - fi - if [ $match -eq 1 ]; then break; fi - done - if [ $match -eq 0 ]; then ret=1; echo "I:unexpected order"; fi -done -match=0 -for i in 1 2 3 4 + -p 5300 @10.53.0.3 cyclic.example > dig.out.cyclic || ret=1 +matches=0 +for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 do - eval "match=\`expr \$match + \$match$i\`" + j=`expr $i % 4` + $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \ + -p 5300 @10.53.0.3 cyclic.example > dig.out.cyclic || ret=1 + if [ $i -le 4 ]; then + cp dig.out.cyclic dig.out.$j + else + cmp -s dig.out.cyclic dig.out.$j && matches=`expr $matches + 1` + fi done -echo "I: Cyclic selection return $match of 4 possible orders in 8 samples" -if [ $match -ne 4 ]; then echo ret=1; fi +cmp -s dig.out.0 dig.out.1 && ret=1 +cmp -s dig.out.0 dig.out.2 && ret=1 +cmp -s dig.out.0 dig.out.3 && ret=1 +cmp -s dig.out.1 dig.out.2 && ret=1 +cmp -s dig.out.1 dig.out.3 && ret=1 +cmp -s dig.out.2 dig.out.3 && ret=1 +if [ $matches -ne 16 ]; then ret=1; fi if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` -n=`expr $n + 1` -n=`expr $n + 1` -echo "I: Checking order random (cache) ($n)" +# +# +# +echo "I: Checking order cyclic (cache)" +ret=0 +# prime acache +$DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \ + -p 5300 @10.53.0.3 cyclic2.example > dig.out.cyclic2 || ret=1 +matches=0 +for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 +do + j=`expr $i % 4` + $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \ + -p 5300 @10.53.0.3 cyclic2.example > dig.out.cyclic2 || ret=1 + if [ $i -le 4 ]; then + cp dig.out.cyclic2 dig.out.$j + else + cmp -s dig.out.cyclic2 dig.out.$j && matches=`expr $matches + 1` + fi +done +cmp -s dig.out.0 dig.out.1 && ret=1 +cmp -s dig.out.0 dig.out.2 && ret=1 +cmp -s dig.out.0 dig.out.3 && ret=1 +cmp -s dig.out.1 dig.out.2 && ret=1 +cmp -s dig.out.1 dig.out.3 && ret=1 +cmp -s dig.out.2 dig.out.3 && ret=1 +if [ $matches -ne 16 ]; then ret=1; fi +if [ $ret != 0 ]; then echo "I:failed"; fi +status=`expr $status + $ret` + +echo "I: Checking order random (cache)" ret=0 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 do diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index c346118c55..495a84486b 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rbtdb.c,v 1.324 2011/12/22 23:43:52 marka Exp $ */ +/* $Id: rbtdb.c,v 1.325 2012/01/04 03:06:51 each Exp $ */ /*! \file */ @@ -2744,14 +2744,6 @@ zone_zonecut_callback(dns_rbtnode_t *node, dns_name_t *name, void *arg) { return (result); } -static inline unsigned int -prand(isc_uint32_t val) { - val ^= val >> 16; - val ^= val >> 8; - val ^= val >> 4; - return (val & 0xf); -} - static inline void bind_rdataset(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node, rdatasetheader_t *header, isc_stdtime_t now, @@ -2791,8 +2783,6 @@ bind_rdataset(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node, raw = (unsigned char *)header + sizeof(*header); rdataset->private3 = raw; rdataset->count = header->count++; - /* Add a weak pseudo random value [0..15]. */ - header->count += prand(header->count); if (rdataset->count == ISC_UINT32_MAX) rdataset->count = 0;