]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
1715. [func] 'dig +trace' now randomly selects the next servers
authorMark Andrews <marka@isc.org>
Thu, 7 Oct 2004 02:21:48 +0000 (02:21 +0000)
committerMark Andrews <marka@isc.org>
Thu, 7 Oct 2004 02:21:48 +0000 (02:21 +0000)
                        to try.  Report if there is a bad delegation.

CHANGES
bin/dig/dighost.c
bin/dig/include/dig/dig.h

diff --git a/CHANGES b/CHANGES
index d3320356348587e5cbd1076646bc6daf22760cae..e85280eda52ba8c0cdad217f40e6782e59cc1716 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -64,7 +64,8 @@
 1716.  [doc]           named.conf(5) was being installed in the wrong
                        location.  [RT# 12441]
 
-1715.  [placeholder]   rt11681
+1715.  [func]          'dig +trace' now randomly selects the next servers
+                       to try.  Report if there is a bad delegation.
 
 1714.  [bug]           dig/host/nslookup were only trying the first
                        address when a nameserver was specified by name.
index a77a5a732b2faa898c49466dffd0934035ce85f6..8b3fe084075cb2a900a48cac8af73d09ddf324c9 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: dighost.c,v 1.269 2004/10/05 03:01:47 marka Exp $ */
+/* $Id: dighost.c,v 1.270 2004/10/07 02:21:48 marka Exp $ */
 
 /*
  * Notice to programmers:  Do not use this code as an example of how to
@@ -1405,6 +1405,7 @@ followup_lookup(dns_message_t *msg, dig_query_t *query, dns_section_t section)
        isc_result_t result;
        isc_boolean_t success = ISC_FALSE;
        int numLookups = 0;
+       dns_name_t *domain;
 
        INSIST(!free_now);
 
@@ -1431,6 +1432,20 @@ followup_lookup(dns_message_t *msg, dig_query_t *query, dns_section_t section)
 
                debug("found NS set");
 
+               if (query->lookup->trace && !query->lookup->trace_root) {
+                       dns_namereln_t namereln;
+                       unsigned int nlabels;
+                       int order;
+
+                       domain = dns_fixedname_name(&query->lookup->fdomain);
+                       namereln = dns_name_fullcompare(name, domain,
+                                                       &order, &nlabels);
+                       if (namereln == dns_namereln_equal)
+                               printf(";; BAD (HORIZONTAL) REFERRAL\n");
+                       else if (namereln != dns_namereln_subdomain)
+                               printf(";; BAD REFERRAL\n");
+               }
+
                for (result = dns_rdataset_first(rdataset);
                     result == ISC_R_SUCCESS;
                     result = dns_rdataset_next(rdataset)) {
@@ -1466,6 +1481,9 @@ followup_lookup(dns_message_t *msg, dig_query_t *query, dns_section_t section)
                                lookup->ns_search_only =
                                        query->lookup->ns_search_only;
                                lookup->trace_root = ISC_FALSE;
+                               dns_fixedname_init(&lookup->fdomain);
+                               domain = dns_fixedname_name(&lookup->fdomain);
+                               dns_name_copy(name, domain, NULL);
                        }
                        srv = make_server(namestr, namestr);
                        debug("adding server %s", srv->servername);
@@ -1479,7 +1497,29 @@ followup_lookup(dns_message_t *msg, dig_query_t *query, dns_section_t section)
            (query->lookup->trace || query->lookup->ns_search_only))
                return (followup_lookup(msg, query, DNS_SECTION_AUTHORITY));
 
-       return numLookups;
+       /*
+        * Randomize the order the nameserver will be tried.
+        */
+       if (numLookups > 1) {
+               isc_uint32_t i, j;
+               dig_serverlist_t my_server_list;
+
+               ISC_LIST_INIT(my_server_list);
+
+               for (i = numLookups; i > 0; i--) {
+                       isc_random_get(&j);
+                       j %= i;
+                       srv = ISC_LIST_HEAD(lookup->my_server_list);
+                       while (j-- > 0)
+                               srv = ISC_LIST_NEXT(srv, link);
+                       ISC_LIST_DEQUEUE(lookup->my_server_list, srv, link);
+                       ISC_LIST_APPEND(my_server_list, srv, link);
+               }
+               ISC_LIST_APPENDLIST(lookup->my_server_list,
+                                   my_server_list, link);
+       }
+
+       return (numLookups);
 }
 
 /*
index 555206c56a2a247f9dc05498699179a2f22c7003..b6b4a3945275f5617d3dc63c8db0deb26892d887 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: dig.h,v 1.86 2004/09/06 01:24:44 marka Exp $ */
+/* $Id: dig.h,v 1.87 2004/10/07 02:21:48 marka Exp $ */
 
 #ifndef DIG_H
 #define DIG_H
@@ -176,6 +176,7 @@ isc_boolean_t       sigchase;
        dst_context_t *tsigctx;
        isc_buffer_t *querysig;
        isc_uint32_t msgcounter;
+       dns_fixedname_t fdomain;
 };
 
 struct dig_query {