diff --git a/CHANGES b/CHANGES index 2589110ae4..6b333c5681 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +3846. [bug] "dig +notcp ixfr=" should result in a UDP + ixfr query. [RT #35980] + 3845. [placeholder] 3844. [bug] Use the x64 version of the Microsoft Visual C++ diff --git a/bin/dig/dig.c b/bin/dig/dig.c index 295f366262..46775d8e37 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -1231,8 +1231,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"); @@ -1330,8 +1332,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: @@ -1549,7 +1553,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; @@ -1815,7 +1820,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 8af7873338..c3e32b95bf 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 3b26fb30e8..d4a13d737a 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -796,6 +796,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; @@ -886,6 +887,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 5a95890669..aeab0e5dfa 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 9651efddb0..22eccfdbba 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 c4e1bf5450..90baccbd8e 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