]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add test for reduction in number of fetches
authorStephen Morris <stephen@isc.org>
Thu, 5 Mar 2020 18:46:46 +0000 (18:46 +0000)
committerMichał Kępień <michal@isc.org>
Tue, 19 May 2020 12:24:53 +0000 (14:24 +0200)
Add a system test that counts how many address fetches are made
for different numbers of NS records and checks that the number
are successfully limited.

bin/tests/system/resolver/clean.sh
bin/tests/system/resolver/ns4/named.conf.in
bin/tests/system/resolver/ns4/root.db
bin/tests/system/resolver/ns4/sourcens.db [new file with mode: 0644]
bin/tests/system/resolver/ns5/named.conf.in
bin/tests/system/resolver/ns6/named.conf.in
bin/tests/system/resolver/ns6/targetns.db [new file with mode: 0644]
bin/tests/system/resolver/tests.sh
util/copyrights

index 4dfde1f3e7246b508f0059805762bc454371b13a..b3e4bc0b5d2812a71782affc75a329ba6d34e7bb 100644 (file)
@@ -17,8 +17,7 @@ rm -f */named.memstats
 rm -f */named.run
 rm -f */ans.run
 rm -f */*.jdb
-rm -f dig.out dig.out.*
-rm -f dig.*.out.*
+rm -f dig.out dig.out.* dig.*.out.*
 rm -f dig.*.foo.*
 rm -f dig.*.bar.*
 rm -f dig.*.prime.*
@@ -28,6 +27,7 @@ rm -f ns6/example.net.db.signed ns6/example.net.db
 rm -f ns6/ds.example.net.db.signed ns6/ds.example.net.db
 rm -f ns6/dsset-ds.example.net*
 rm -f ns6/dsset-example.net* ns6/example.net.db.signed.jnl
+rm -f ns6/named.stats*
 rm -f ns6/to-be-removed.tld.db ns6/to-be-removed.tld.db.jnl
 rm -f ns7/server.db ns7/server.db.jnl
 rm -f resolve.out.*.test*
index c679dc31515a4a971b61093684d51911c1ede3da..56fe5d0dd8c74f77ae122ec7a8a00c3bb5c60702 100644 (file)
@@ -50,6 +50,11 @@ zone "broken" {
        file "broken.db";
 };
 
+zone "sourcens" {
+    type master;
+    file "sourcens.db";
+};
+
 key rndc_key {
        secret "1234abcd8765";
        algorithm hmac-sha256;
index 721765d1be7146b627ac5c3989c24c6c252dd015..ae541340da8f4ce2138dd14beb8ea1b76f0784ce 100644 (file)
@@ -24,3 +24,7 @@ example.net.          NS      ns.example.net.
 ns.example.net.                A       10.53.0.6
 no-questions.          NS      ns.no-questions.
 ns.no-questions.       A       10.53.0.8
+sourcens.              NS      ns.sourcens.
+ns.sourcens.           A       10.53.0.4
+targetns.              NS      ns.targetns.
+ns.targetns.           A       10.53.0.6
diff --git a/bin/tests/system/resolver/ns4/sourcens.db b/bin/tests/system/resolver/ns4/sourcens.db
new file mode 100644 (file)
index 0000000..b02cc6e
--- /dev/null
@@ -0,0 +1,89 @@
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+;
+; This Source Code Form is subject to the terms of the Mozilla Public
+; License, v. 2.0. If a copy of the MPL was not distributed with this
+; file, You can obtain one at http://mozilla.org/MPL/2.0/.
+;
+; See the COPYRIGHT file distributed with this work for additional
+; information regarding copyright ownership.
+
+; This zone contains a set of delegations with varying numbers of NS
+; records.  This is used to check that BIND is limiting the number of
+; NS records it follows when resolving a delegation.  It tests all
+; numbers of NS records up to twice the number followed.
+
+$TTL 60
+@                      IN SOA  marka.isc.org. ns.server. (
+                               2010    ; serial
+                               600             ; refresh
+                               600             ; retry
+                               1200            ; expire
+                               600             ; minimum
+                               )
+@                      NS      ns
+ns                     A       10.53.0.4
+
+target1                NS      ns.fake11.targetns.
+
+target2                NS      ns.fake21.targetns.
+                       NS      ns.fake22.targetns.
+
+target3                NS      ns.fake31.targetns.
+                       NS      ns.fake32.targetns.
+                       NS      ns.fake33.targetns.
+
+target4                NS      ns.fake41.targetns.
+                       NS      ns.fake42.targetns.
+                       NS      ns.fake43.targetns.
+                       NS      ns.fake44.targetns.
+
+target5                NS      ns.fake51.targetns.
+                       NS      ns.fake52.targetns.
+                       NS      ns.fake53.targetns.
+                       NS      ns.fake54.targetns.
+                       NS      ns.fake55.targetns.
+
+target6                NS      ns.fake61.targetns.
+                       NS      ns.fake62.targetns.
+                       NS      ns.fake63.targetns.
+                       NS      ns.fake64.targetns.
+                       NS      ns.fake65.targetns.
+                       NS      ns.fake66.targetns.
+
+target7                NS      ns.fake71.targetns.
+                       NS      ns.fake72.targetns.
+                       NS      ns.fake73.targetns.
+                       NS      ns.fake74.targetns.
+                       NS      ns.fake75.targetns.
+                       NS      ns.fake76.targetns.
+                       NS      ns.fake77.targetns.
+
+target8                NS      ns.fake81.targetns.
+                       NS      ns.fake82.targetns.
+                       NS      ns.fake83.targetns.
+                       NS      ns.fake84.targetns.
+                       NS      ns.fake85.targetns.
+                       NS      ns.fake86.targetns.
+                       NS      ns.fake87.targetns.
+                       NS      ns.fake88.targetns.
+
+target9                NS      ns.fake91.targetns.
+                       NS      ns.fake92.targetns.
+                       NS      ns.fake93.targetns.
+                       NS      ns.fake94.targetns.
+                       NS      ns.fake95.targetns.
+                       NS      ns.fake96.targetns.
+                       NS      ns.fake97.targetns.
+                       NS      ns.fake98.targetns.
+                       NS      ns.fake99.targetns.
+
+target10               NS      ns.fake101.targetns.
+                       NS      ns.fake102.targetns.
+                       NS      ns.fake103.targetns.
+                       NS      ns.fake104.targetns.
+                       NS      ns.fake105.targetns.
+                       NS      ns.fake106.targetns.
+                       NS      ns.fake107.targetns.
+                       NS      ns.fake108.targetns.
+                       NS      ns.fake109.targetns.
+                       NS      ns.fake1010.targetns.
index f6f96f3fc4d23762e4d008eda6d8dc4024d15f5e..517cee1fa441b63d02e633115a7dd3b9a1950153 100644 (file)
@@ -47,4 +47,11 @@ zone "delegation-only" {
        type delegation-only;
 };
 
-include "trusted.conf";
+key rndc_key {
+       secret "1234abcd8765";
+       algorithm hmac-sha256;
+};
+
+controls {
+       inet 10.53.0.5 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
+};
index 7df48558b8800be4ab67f8d12fb4743fa86e9d9a..4b01f9ba14ced161c4624c68f377686acc546fed 100644 (file)
@@ -22,6 +22,7 @@ options {
        recursion no;
        // minimal-responses yes;
        querylog yes;
+       statistics-file "named.stats";
        /*
         * test that named loads with root-delegation-only that
         * has a exclude list.
@@ -67,3 +68,17 @@ zone "delegation-only" {
        type master;
        file "delegation-only.db";
 };
+
+zone "targetns" {
+       type master;
+       file "targetns.db";
+};
+
+key rndc_key {
+       secret "1234abcd8765";
+       algorithm hmac-sha256;
+};
+
+controls {
+       inet 10.53.0.6 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
+};
diff --git a/bin/tests/system/resolver/ns6/targetns.db b/bin/tests/system/resolver/ns6/targetns.db
new file mode 100644 (file)
index 0000000..036e645
--- /dev/null
@@ -0,0 +1,23 @@
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+;
+; This Source Code Form is subject to the terms of the Mozilla Public
+; License, v. 2.0. If a copy of the MPL was not distributed with this
+; file, You can obtain one at http://mozilla.org/MPL/2.0/.
+;
+; See the COPYRIGHT file distributed with this work for additional
+; information regarding copyright ownership.
+
+; In the test for checking how many NS records BIND will follow, this
+; zone marks the server as the one to which the NS lookups will be
+; directed.
+
+$TTL 300
+@                      IN SOA  marka.isc.org. ns.server. (
+                               2010    ; serial
+                               600             ; refresh
+                               600             ; retry
+                               1200            ; expire
+                               600             ; minimum
+                               )
+                       NS      ns
+ns                     A       10.53.0.6
index 7fd8ed744832e0c784a4726b9bf749c35311aaf3..f2a3103ad1cd1f2bd8c3edc57be00c5b391be4f6 100755 (executable)
@@ -247,6 +247,40 @@ if [ -x ${RESOLVE} ] ; then
     status=`expr $status + $ret`
 fi
 
+n=`expr $n + 1`
+echo_i "check that the resolver limits the number of NS records it follows in a referral response ($n)"
+# ns5 is the recusor being tested.  ns4 holds the sourcens zone containing names with varying numbers of NS
+# records pointing to non-existent nameservers in the targetns zone on ns6.
+ret=0
+$RNDCCMD 10.53.0.5 flush || ret=1   # Ensure cache is empty before doing this test
+for nscount in 1 2 3 4 5 6 7 8 9 10
+do
+        # Verify number of NS records at source server
+        $DIG $DIGOPTS +norecurse @10.53.0.4 target${nscount}.sourcens ns > dig.ns4.out.${nscount}.${n}
+        sourcerecs=`grep NS dig.ns4.out.${nscount}.${n} | grep -v ';' | wc -l`
+        test $sourcerecs -eq $nscount || ret=1
+        test $sourcerecs -eq $nscount || echo_i "NS count incorrect for target${nscount}.sourcens"
+        # Expected queries = 2 * number of NS records, up to a maximum of 10.
+        expected=`expr 2 \* $nscount`
+        if [ $expected -gt 10 ]; then expected=10; fi
+        # Work out the queries made by checking statistics on the target before and after the test
+        $RNDCCMD 10.53.0.6 stats || ret=1
+        initial_count=`awk '/responses sent/ {print $1}' ns6/named.stats`
+        mv ns6/named.stats ns6/named.stats.initial.${nscount}.${n}
+        $DIG $DIGOPTS @10.53.0.5 target${nscount}.sourcens A > dig.ns5.out.${nscount}.${n} || ret=1
+        $RNDCCMD 10.53.0.6 stats || ret=1
+        final_count=`awk '/responses sent/ {print $1}' ns6/named.stats`
+        mv ns6/named.stats ns6/named.stats.final.${nscount}.${n}
+        # Check number of queries during the test is as expected
+        actual=`expr $final_count - $initial_count`
+        if [ $actual -ne $expected ]; then
+                echo_i "query count error: $nscount NS records: expected queries $expected, actual $actual"
+                ret=1
+        fi
+done
+if [ $ret != 0 ]; then echo_i "failed"; fi
+status=`expr $status + $ret`
+
 n=`expr $n + 1`
 echo_i "RT21594 regression test check setup ($n)"
 ret=0
index 45229f12ac7624e65105b1131e122e77d03fd323..20672c1bdc790bb4e92c7c9a7dc006b3cccf8124 100644 (file)
 ./bin/tests/system/resolver/ns4/named.conf.in  CONF-C  2018,2019,2020
 ./bin/tests/system/resolver/ns4/named.noaa     TXT.BRIEF       2010,2016,2018,2019,2020
 ./bin/tests/system/resolver/ns4/root.db                ZONE    2010,2014,2015,2016,2017,2018,2019,2020
+./bin/tests/system/resolver/ns4/sourcens.db    ZONE    2020
 ./bin/tests/system/resolver/ns4/tld1.db                ZONE    2012,2014,2016,2018,2019,2020
 ./bin/tests/system/resolver/ns4/tld2.db                ZONE    2012,2014,2016,2018,2019,2020
 ./bin/tests/system/resolver/ns5/child.server.db        ZONE    2011,2016,2018,2019,2020
 ./bin/tests/system/resolver/ns6/named.conf.in  CONF-C  2018,2019,2020
 ./bin/tests/system/resolver/ns6/no-edns-version.tld.db ZONE    2014,2016,2018,2019,2020
 ./bin/tests/system/resolver/ns6/root.db                ZONE    2010,2011,2014,2016,2018,2019,2020
+./bin/tests/system/resolver/ns6/targetns.db    ZONE    2020
 ./bin/tests/system/resolver/ns6/to-be-removed.tld.db.in        ZONE    2012,2016,2018,2019,2020
 ./bin/tests/system/resolver/ns7/all-cnames.db  ZONE    2014,2016,2018,2019,2020
 ./bin/tests/system/resolver/ns7/edns-version.tld.db    ZONE    2014,2016,2018,2019,2020