]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
3846. [bug] "dig +notcp ixfr=<serial>" should result in a UDP
authorMark Andrews <marka@isc.org>
Tue, 13 May 2014 23:59:02 +0000 (09:59 +1000)
committerMark Andrews <marka@isc.org>
Wed, 14 May 2014 00:00:03 +0000 (10:00 +1000)
                        ixfr query. [RT #35980]

(cherry picked from commit 05816676bb82a5657a741ef4d378c7fb83912cfc)

CHANGES
bin/dig/dig.c
bin/dig/dig.docbook
bin/dig/dighost.c
bin/dig/include/dig/dig.h
bin/tests/system/ixfr/clean.sh
bin/tests/system/ixfr/tests.sh

diff --git a/CHANGES b/CHANGES
index d999eeca345876748ad188f5026170624aa09e6e..c9c81da50c3f083993737500030f233143af7750 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+3846.  [bug]           "dig +notcp ixfr=<serial>" should result in a UDP
+                       ixfr query. [RT #35980]
+
 3845.  [doc]           Remove documention for yet to be committed RRL
                        changes. [RT #35897]
 
index 007bcdd76788921c1449c2a34405740935512528..dc26c098b87c9e2254dd87e3bbbb1d28af0642b8 100644 (file)
@@ -1193,8 +1193,10 @@ plus_option(char *option, isc_boolean_t is_batchfile,
                switch (cmd[1]) {
                case 'c': /* tcp */
                        FULLCHECK("tcp");
-                       if (!is_batchfile)
+                       if (!is_batchfile) {
                                lookup->tcp_mode = state;
+                               lookup->tcp_mode_set = ISC_TRUE;
+                       }
                        break;
                case 'i': /* timeout */
                        FULLCHECK("timeout");
@@ -1274,8 +1276,10 @@ plus_option(char *option, isc_boolean_t is_batchfile,
                break;
        case 'v':
                FULLCHECK("vc");
-               if (!is_batchfile)
+               if (!is_batchfile) {
                        lookup->tcp_mode = state;
+                       lookup->tcp_mode_set = ISC_TRUE;
+               }
                break;
        default:
        invalid_option:
@@ -1493,7 +1497,8 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
                                (*lookup)->ixfr_serial = serial;
                                (*lookup)->section_question = plusquest;
                                (*lookup)->comments = pluscomm;
-                               (*lookup)->tcp_mode = ISC_TRUE;
+                               if (!(*lookup)->tcp_mode_set)
+                                       (*lookup)->tcp_mode = ISC_TRUE;
                        } else {
                                (*lookup)->rdtype = rdtype;
                                (*lookup)->rdtypeset = ISC_TRUE;
@@ -1759,7 +1764,8 @@ parse_args(isc_boolean_t is_batchfile, isc_boolean_t config_only,
                                                lookup->section_question =
                                                        plusquest;
                                                lookup->comments = pluscomm;
-                                               lookup->tcp_mode = ISC_TRUE;
+                                               if (!lookup->tcp_mode_set)
+                                                       lookup->tcp_mode = ISC_TRUE;
                                        } else {
                                                lookup->rdtype = rdtype;
                                                lookup->rdtypeset = ISC_TRUE;
index 999a5609a47c21a697602a4e55f341e99d9aa7f5..7ccfc5d859a1ec39f33284c89fb76037c8d73496 100644 (file)
           <term><option>+[no]tcp</option></term>
           <listitem>
             <para>
-              Use [do not use] TCP when querying name servers.  The default
-              behavior is to use UDP unless an AXFR or IXFR query is
-              requested, in
-              which case a TCP connection is used.
+              Use [do not use] TCP when querying name servers. The
+              default behavior is to use UDP unless
+              an <literal>ixfr=N</literal> query is requested, in
+              which case the default is TCP.
+              AXFR queries always use TCP.
             </para>
           </listitem>
         </varlistentry>
index 3bc81aff45d26769b10029d56303506f78f6a680..933972b4f6ca69bbf1f44cb6c54c8b1f19c052a1 100644 (file)
@@ -797,6 +797,7 @@ make_empty_lookup(void) {
        looknew->retries = tries;
        looknew->nsfound = 0;
        looknew->tcp_mode = ISC_FALSE;
+       looknew->tcp_mode_set = ISC_FALSE;
        looknew->ip6_int = ISC_FALSE;
        looknew->comments = ISC_TRUE;
        looknew->stats = ISC_TRUE;
@@ -883,6 +884,7 @@ clone_lookup(dig_lookup_t *lookold, isc_boolean_t servers) {
        looknew->cdflag = lookold->cdflag;
        looknew->ns_search_only = lookold->ns_search_only;
        looknew->tcp_mode = lookold->tcp_mode;
+       looknew->tcp_mode_set = lookold->tcp_mode_set;
        looknew->comments = lookold->comments;
        looknew->stats = lookold->stats;
        looknew->section_question = lookold->section_question;
index 205e6cd2aeb0f6acdef1344192792ce985facab8..6d491691c2821efdfab2b9ca2b597b9438d553aa 100644 (file)
@@ -117,6 +117,7 @@ struct dig_lookup {
                trace, /*% dig +trace */
                trace_root, /*% initial query for either +trace or +nssearch */
                tcp_mode,
+               tcp_mode_set,
                ip6_int,
                comments,
                stats,
index 9651efddb0dbe2bedbf92b29c947f2bc706d653c..22eccfdbba56ecf51d732addbb4c9a851024af62 100644 (file)
@@ -21,5 +21,5 @@ rm -f ns1/named.conf ns1/myftp.db
 rm -f ns3/*.jnl ns3/mytest.db ns3/subtest.db
 rm -f ns4/*.jnl ns4/*.db
 rm -f */named.memstats
-rm -f dig.out
+rm -f dig.out dig.out1 dig.out2 dig.out3
 rm -f ns3/large.db
index c4e1bf545012a38a7b475118cf6fc8095f88c51e..90baccbd8e9bb17e318749afbdb7c7212cd9399e 100644 (file)
@@ -249,5 +249,21 @@ test ${lines:-0} -eq 2 || { echo "I:failed"; status=1; }
 messages=`sed -n 's/^;;.*messages \([0-9]*\),.*/\1/p' dig.out`
 test ${messages:-0} -gt 1 || { echo "I:failed"; status=1; }
 
+echo "I:test 'dig +notcp ixfr=<value>' vs 'dig ixfr=<value> +notcp' vs 'dig ixfr=<value>'"
+ret=0
+# Should be "switch to TCP" response
+$DIG +notcp ixfr=1 test -p 5300 @10.53.0.4 > dig.out1 || ret=1
+$DIG ixfr=1 +notcp test -p 5300 @10.53.0.4 > dig.out2 || ret=1
+$PERL ../digcomp.pl dig.out1 dig.out2 || ret=1
+awk '$4 == "SOA" { soacnt++} END {exit(soacnt == 1 ? 0 : 1);}' dig.out1 || ret=1
+awk '$4 == "SOA" { exit($7 == 4 ? 0 : 1);}' dig.out1 || ret=1
+# Should be incremental transfer.
+$DIG ixfr=1 test -p 5300 @10.53.0.4 > dig.out3 || ret=1
+awk '$4 == "SOA" { soacnt++} END {exit(soacnt == 6 ? 0 : 1);}' dig.out3 || ret=1
+if [ ${ret} != 0 ]; then
+       echo "I:failed";
+       status=1;
+fi
+
 echo "I:exit status: $status"
 exit $status