diff --git a/CHANGES b/CHANGES index 55bd96ed00..6b22362547 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 973818b65d..8a5fead008 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -1106,8 +1106,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"); @@ -1187,8 +1189,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: @@ -1403,7 +1407,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; @@ -1669,7 +1674,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 1052bf592f..2436f71ce0 100644 --- a/bin/dig/dig.docbook +++ b/bin/dig/dig.docbook @@ -366,10 +366,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 72a5f3c91d..85fc7c7595 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -791,6 +791,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; @@ -868,6 +869,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 0150d11dfb..6139024ee1 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 ac5b8279a6..900c1c133b 100644 --- a/bin/tests/system/ixfr/clean.sh +++ b/bin/tests/system/ixfr/clean.sh @@ -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 diff --git a/bin/tests/system/ixfr/tests.sh b/bin/tests/system/ixfr/tests.sh index c6049ad5a0..8e3ed15e33 100644 --- a/bin/tests/system/ixfr/tests.sh +++ b/bin/tests/system/ixfr/tests.sh @@ -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=' 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