]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
4586. [func] dig, host and nslookup now use TCP for ANY queries.
authorMark Andrews <marka@isc.org>
Thu, 20 Apr 2017 03:20:41 +0000 (13:20 +1000)
committerMark Andrews <marka@isc.org>
Thu, 20 Apr 2017 03:20:41 +0000 (13:20 +1000)
                        [RT #44687]

CHANGES
bin/dig/dig.c
bin/dig/dig.docbook
bin/dig/host.c
bin/dig/host.docbook
bin/dig/nslookup.c
bin/dig/nslookup.docbook

diff --git a/CHANGES b/CHANGES
index 1adebfeb72211b746a3f651206ad3cc7786c224b..e9a50b55ed13b6e04b1936ded812456220ed7e02 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+4586.  [func]          dig, host and nslookup now use TCP for ANY queries.
+                       [RT #44687]
+
 4585.  [port]          win32: Set CompileAS value. [RT #42474]
 
 4584.  [bug]           A number of memory usage statistics were not properly
index 6e183d48f870841f9f665df32262193f0711c7e7..51dcfa8e639512ae240730b816a198c2deb8601b 100644 (file)
@@ -1744,6 +1744,9 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
                                if (rdtype == dns_rdatatype_axfr) {
                                        (*lookup)->section_question = plusquest;
                                        (*lookup)->comments = pluscomm;
+                               } else if (rdtype == dns_rdatatype_any) {
+                                       if (!(*lookup)->tcp_mode_set)
+                                               (*lookup)->tcp_mode = ISC_TRUE;
                                }
                                (*lookup)->ixfr_serial = ISC_FALSE;
                        }
@@ -2054,6 +2057,10 @@ parse_args(isc_boolean_t is_batchfile, isc_boolean_t config_only,
                                                                plusquest;
                                                    lookup->comments = pluscomm;
                                                }
+                                               if (rdtype ==
+                                                   dns_rdatatype_any &&
+                                                   !lookup->tcp_mode_set)
+                                                       lookup->tcp_mode = ISC_TRUE;
                                                lookup->ixfr_serial = ISC_FALSE;
                                        }
                                        continue;
index ce3a205beff6bfbdb4e1eef14a09fd92b2d722c7..e262d24a6e4fec9ed5241c366469fa692e2be569 100644 (file)
          <listitem>
            <para>
              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.
+             default behavior is to use UDP unless a type
+             <literal>any</literal> or <literal>ixfr=N</literal>
+             query is requested, in which case the default is TCP.
+             AXFR queries always use TCP.
            </para>
          </listitem>
        </varlistentry>
index 7d912503994e0c5f967037749609898272d6015d..ed075b3e47de92c3abbe8d6cde3e8952de0e775e 100644 (file)
@@ -602,7 +602,7 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
        return (result);
 }
 
-static const char * optstring = "46aAc:dilnm:rst:vVwCDN:R:TW:";
+static const char * optstring = "46aAc:dilnm:rst:vVwCDN:R:TUW:";
 
 /*% version */
 static void
@@ -743,6 +743,9 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
                                lookup->ixfr_serial = serial;
                                lookup->tcp_mode = ISC_TRUE;
                                list_type = rdtype;
+                       } else if (rdtype == dns_rdatatype_any) {
+                               if (!lookup->tcp_mode_set)
+                                       lookup->tcp_mode = ISC_TRUE;
 #ifdef WITH_IDN
                        } else if (rdtype == dns_rdatatype_a ||
                                   rdtype == dns_rdatatype_aaaa ||
@@ -815,6 +818,11 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
                        break;
                case 'T':
                        lookup->tcp_mode = ISC_TRUE;
+                       lookup->tcp_mode_set = ISC_TRUE;
+                       break;
+               case 'U':
+                       lookup->tcp_mode = ISC_FALSE;
+                       lookup->tcp_mode_set = ISC_TRUE;
                        break;
                case 'C':
                        debug("showing all SOAs");
index 7578b07a8ad1c9745da7b1c9808067d89d0038e0..18fc605faf400dd856187af109e221c181804e1f 100644 (file)
@@ -50,7 +50,7 @@
   <refsynopsisdiv>
     <cmdsynopsis sepchar=" ">
       <command>host</command>
-      <arg choice="opt" rep="norepeat"><option>-aACdlnrsTwv</option></arg>
+      <arg choice="opt" rep="norepeat"><option>-aACdlnrsTUwv</option></arg>
       <arg choice="opt" rep="norepeat"><option>-c <replaceable class="parameter">class</replaceable></option></arg>
       <arg choice="opt" rep="norepeat"><option>-N <replaceable class="parameter">ndots</replaceable></option></arg>
       <arg choice="opt" rep="norepeat"><option>-R <replaceable class="parameter">number</replaceable></option></arg>
 
       <varlistentry>
        <term>-T</term>
+       <term>-U</term>
        <listitem>
          <para>
-           TCP:
+           TCP/UDP:
            By default, <command>host</command> uses UDP when making
            queries. The <option>-T</option> option makes it use a TCP
            connection when querying the name server. TCP will be
            automatically selected for queries that require it, such
-           as zone transfer (AXFR) requests.
+           as zone transfer (AXFR) requests.  Type ANY queries default
+           to TCP but can be forced to UDP initially using <option>-U</option>.
          </para>
        </listitem>
       </varlistentry>
index 951a13875e61e9ba62dee3f54bda381c790457e0..e8b3940894d29120495dd399c69e93f4e9a8239f 100644 (file)
@@ -51,7 +51,7 @@
 #endif
 
 static isc_boolean_t short_form = ISC_TRUE,
-       tcpmode = ISC_FALSE,
+       tcpmode = ISC_FALSE, tcpmode_set = ISC_FALSE,
        identify = ISC_FALSE, stats = ISC_TRUE,
        comments = ISC_TRUE, section_question = ISC_TRUE,
        section_answer = ISC_TRUE, section_authority = ISC_TRUE,
@@ -718,8 +718,10 @@ setoption(char *opt) {
                usesearch = ISC_FALSE;
        } else if (strncasecmp(opt, "vc", 3) == 0) {
                tcpmode = ISC_TRUE;
+               tcpmode_set = ISC_TRUE;
        } else if (strncasecmp(opt, "novc", 5) == 0) {
                tcpmode = ISC_FALSE;
+               tcpmode_set = ISC_TRUE;
        } else if (strncasecmp(opt, "deb", 3) == 0) {
                short_form = ISC_FALSE;
                showsearch = ISC_TRUE;
@@ -796,7 +798,10 @@ addlookup(char *opt) {
        lookup->retries = tries;
        lookup->udpsize = 0;
        lookup->comments = comments;
-       lookup->tcp_mode = tcpmode;
+       if (lookup->rdtype == dns_rdatatype_any && !tcpmode_set)
+               lookup->tcp_mode = ISC_TRUE;
+       else
+               lookup->tcp_mode = tcpmode;
        lookup->stats = stats;
        lookup->section_question = section_question;
        lookup->section_answer = section_answer;
index c2a8668adc0cc953bad237e111ce1344f3cd7c6d..26d8cd9a6631f4df96f8f795aceb69e9cc432575 100644 (file)
@@ -308,8 +308,7 @@ nslookup -query=hinfo  -timeout=10
               </varlistentry>
 
               <varlistentry>
-                <term><constant>
-                    <replaceable><optional>no</optional></replaceable>debug</constant></term>
+                <term><constant><replaceable><optional>no</optional></replaceable>debug</constant></term>
                 <listitem>
                   <para>
                    Turn on or off the display of the full response packet and
@@ -322,8 +321,7 @@ nslookup -query=hinfo  -timeout=10
               </varlistentry>
 
               <varlistentry>
-                <term><constant>
-                    <replaceable><optional>no</optional></replaceable>d2</constant></term>
+                <term><constant><replaceable><optional>no</optional></replaceable>d2</constant></term>
                 <listitem>
                   <para>
                     Turn debugging mode on or off.  This displays more about
@@ -345,8 +343,7 @@ nslookup -query=hinfo  -timeout=10
               </varlistentry>
 
               <varlistentry>
-                <term><constant>
-                    <replaceable><optional>no</optional></replaceable>search</constant></term>
+                <term><constant><replaceable><optional>no</optional></replaceable>search</constant></term>
                 <listitem>
                   <para>
                     If the lookup request contains at least one period but
@@ -392,8 +389,7 @@ nslookup -query=hinfo  -timeout=10
               </varlistentry>
 
               <varlistentry>
-                <term><constant>
-                    <replaceable><optional>no</optional></replaceable>recurse</constant></term>
+                <term><constant><replaceable><optional>no</optional></replaceable>recurse</constant></term>
                 <listitem>
                   <para>
                     Tell the name server to query other servers if it does not
@@ -437,8 +433,7 @@ nslookup -query=hinfo  -timeout=10
               </varlistentry>
 
               <varlistentry>
-                <term><constant>
-                    <replaceable><optional>no</optional></replaceable>vc</constant></term>
+                <term><constant><replaceable><optional>no</optional></replaceable>vc</constant></term>
                 <listitem>
                   <para>
                     Always use a virtual circuit when sending requests to the
@@ -451,8 +446,7 @@ nslookup -query=hinfo  -timeout=10
               </varlistentry>
 
               <varlistentry>
-                <term><constant>
-                    <replaceable><optional>no</optional></replaceable>fail</constant></term>
+                <term><constant><replaceable><optional>no</optional></replaceable>fail</constant></term>
                 <listitem>
                   <para>
                    Try the next nameserver if a nameserver responds with