diff --git a/CHANGES b/CHANGES index 9290568f70..734e1f73dd 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +3846. [bug] "dig +notcp ixfr=" should result in a UDP + ixfr query. [RT #35980] + 3844. [bug] Use the x64 version of the Microsoft Visual C++ Redistributable when built for 64 bit Windows. (Thanks to Giovanni Paterno.) [RT #35973] diff --git a/bin/dig/dig.c b/bin/dig/dig.c index 45928e6a6d..27fe22a4de 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -1051,8 +1051,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"); @@ -1130,8 +1132,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: @@ -1346,7 +1350,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; @@ -1610,7 +1615,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; diff --git a/bin/dig/dig.docbook b/bin/dig/dig.docbook index 9f364ef5b1..5ca0884ac9 100644 --- a/bin/dig/dig.docbook +++ b/bin/dig/dig.docbook @@ -365,10 +365,11 @@ - 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 ixfr=N query is requested, in + which case the default is TCP. + AXFR queries always use TCP. diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 01517f86e9..412bb79e87 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -793,6 +793,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; @@ -870,6 +871,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; diff --git a/bin/dig/include/dig/dig.h b/bin/dig/include/dig/dig.h index 6d63423edb..ed6fc3ae04 100644 --- a/bin/dig/include/dig/dig.h +++ b/bin/dig/include/dig/dig.h @@ -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, diff --git a/bin/tests/system/ixfr/clean.sh b/bin/tests/system/ixfr/clean.sh index 15f5265c95..54f9559505 100644 --- a/bin/tests/system/ixfr/clean.sh +++ b/bin/tests/system/ixfr/clean.sh @@ -19,5 +19,5 @@ rm -f ns1/named.conf ns1/myftp.db rm -f */named.memstats -rm -f dig.out +rm -f dig.out dig.out1 dig.out2 dig.out3 rm -f ns3/large.db diff --git a/bin/tests/system/ixfr/tests.sh b/bin/tests/system/ixfr/tests.sh index 7408ccb666..ad2bcf25de 100644 --- a/bin/tests/system/ixfr/tests.sh +++ b/bin/tests/system/ixfr/tests.sh @@ -149,5 +149,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=' vs 'dig ixfr= +notcp' vs 'dig ixfr='" +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