]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[master] "flushtree -all" no longer optional
authorEvan Hunt <each@isc.org>
Mon, 1 Jul 2013 01:53:48 +0000 (18:53 -0700)
committerEvan Hunt <each@isc.org>
Mon, 1 Jul 2013 01:53:48 +0000 (18:53 -0700)
Updated CHANGES note:
3606. [func] "rndc flushtree" now flushes matching
records in the address database and bad cache
                        as well as the DNS cache. (Previously only the
                        DNS cache was flushed.) [RT #33970]

CHANGES
bin/named/server.c
bin/rndc/rndc.docbook
bin/tests/system/cacheclean/tests.sh
lib/dns/include/dns/view.h
lib/dns/resolver.c
lib/dns/view.c

diff --git a/CHANGES b/CHANGES
index b15040609c1565d53d4c78f395b7981f998f6ae4..5bc74b5ce920368df800af4ea26c30bc14df00cf 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,8 +1,7 @@
-3606.  [func]          "rndc flushtree -all" flushes matching
-                       records in the ADB and bad cache as well as
-                       the DNS cache.  (Without the "-all" option,
-                       flushtree will still only flush records from
-                       the DNS cache.) [RT #33970]
+3606.  [func]          "rndc flushtree" now flushes matching
+                       records in the address database and bad cache
+                        as well as the DNS cache. (Previously only the
+                        DNS cache was flushed.) [RT #33970]
 
 3605.  [port]          win32: Addressed several compatibility issues
                        with newer versions of Visual Studio. [RT #33916]
index bfbaea0a6e88c49d906a204e3ab36c17c7737034..c3c9a4cb13619b8246120ec6293117979b3ede79 100644 (file)
@@ -7617,7 +7617,7 @@ ns_server_flushnode(ns_server_t *server, char *args, isc_boolean_t tree) {
        char *target, *viewname;
        dns_view_t *view;
        isc_boolean_t flushed;
-       isc_boolean_t found, all = ISC_FALSE;
+       isc_boolean_t found;
        isc_result_t result;
        isc_buffer_t b;
        dns_fixedname_t fixed;
@@ -7628,16 +7628,8 @@ ns_server_flushnode(ns_server_t *server, char *args, isc_boolean_t tree) {
        if (target == NULL)
                return (ISC_R_UNEXPECTEDEND);
 
-       target = next_token(&args, " \t");
-       if (target == NULL)
-               return (ISC_R_UNEXPECTEDEND);
-
-       if (strcmp(target, "-all") == 0) {
-               all = ISC_TRUE;
-               target = next_token(&args, " \t");
-       }
-
        /* Find the domain name to flush. */
+       target = next_token(&args, " \t");
        if (target == NULL)
                return (ISC_R_UNEXPECTEDEND);
 
@@ -7668,7 +7660,7 @@ ns_server_flushnode(ns_server_t *server, char *args, isc_boolean_t tree) {
                 * if some of the views share a single cache.  But since the
                 * operation is lightweight we prefer simplicity here.
                 */
-               result = dns_view_flushnode(view, name, tree, all);
+               result = dns_view_flushnode(view, name, tree);
                if (result != ISC_R_SUCCESS) {
                        flushed = ISC_FALSE;
                        isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
index 472a62f8ed9e773e5a22e64501a1d7df15e5cba6..1a14f7af01485120e9887ea285a5845339f75839 100644 (file)
         <listitem>
           <para>
             Flushes the given name, and all of its subdomains,
-            from the server's DNS cache.  By default, this does
-            <emphasis>not</emphasis> affect the server's address
-            database or bad-server cache.  To eliminate matching
-            names from those databases as well, use
-            the <option>-all</option> option.  
+            from the server's DNS cache, the address database,
+            and the bad server cache.
           </para>
         </listitem>
       </varlistentry>
index 86e318cc4e6014c3d338edf95800e29d0593674e..37d164b1ca0f6be01a00d72d1c40dc10f5560e00 100644 (file)
@@ -185,12 +185,12 @@ nrecords=`grep flushtest.example ns2/named_dump.db | grep -v '^;' | grep -Ew '(T
 if [ $ret != 0 ]; then echo "I:failed"; fi
 status=`expr $status + $ret`
 
-echo "I:check flushtree -all clears adb correctly"
+echo "I:check flushtree clears adb correctly"
 ret=0
 load_cache
 dump_cache
 awk '/Address database/ {getline; getline; if ($2 == "ns.flushtest.example") exit(0); exit(1); }' ns2/named_dump.db || ret=1
-$RNDC $RNDCOPTS flushtree -all flushtest.example || ret=1
+$RNDC $RNDCOPTS flushtree flushtest.example || ret=1
 dump_cache
 awk '/Address database/ {getline; getline; if ($2 == "ns.flushtest.example") exit(1); exit(0); }' ns2/named_dump.db || ret=1
 if [ $ret != 0 ]; then echo "I:failed"; fi
index 3e9e2d6640b302ec6d38a5b5ca9d2c3c738becb7..b287869aef2e3114e5b14fc7ec91734534277dfc 100644 (file)
@@ -875,18 +875,12 @@ dns_view_flushcache2(dns_view_t *view, isc_boolean_t fixuponly);
  */
 
 isc_result_t
-dns_view_flushnode(dns_view_t *view, dns_name_t *name,
-                  isc_boolean_t cachetree, isc_boolean_t all);
+dns_view_flushnode(dns_view_t *view, dns_name_t *name, isc_boolean_t tree);
 /*%<
  * Flush the given name from the view's cache (and optionally ADB/badcache).
  *
- * If 'cachetree' or 'all' is true, flush 'name' and all names below it
- * from the cache.
- * If 'all' is true, flush 'name' and all names below it from the ADB
- * and badcache.
- *
- * If 'cachetree' and 'all' are false, flush 'name' from both the
- * cache and ADB, but do not touch any other nodes.
+ * Flush the given name from the cache, ADB, and bad cache.  If 'tree'
+ * is true, also flush all subdomains of 'name'.
  *
  * Requires:
  *\li  'view' is valid.
index 13139ab084609eee39bf5de48261539caaa79a25..b52c08471497633c8f7883b2f4e25ec7409965dc 100644 (file)
@@ -8744,13 +8744,15 @@ dns_resolver_flushbadcache(dns_resolver_t *resolver, dns_name_t *name) {
 
  unlock:
        UNLOCK(&resolver->lock);
-
 }
 
 void
 dns_resolver_flushbadnames(dns_resolver_t *resolver, dns_name_t *name) {
        dns_badcache_t *bad, *prev, *next;
        unsigned int i;
+       int n;
+       isc_time_t now;
+       isc_result_t result;
 
        REQUIRE(VALID_RESOLVER(resolver));
        REQUIRE(name != NULL);
@@ -8759,11 +8761,16 @@ dns_resolver_flushbadnames(dns_resolver_t *resolver, dns_name_t *name) {
        if (resolver->badcache == NULL)
                goto unlock;
 
+       result = isc_time_now(&now);
+       if (result != ISC_R_SUCCESS)
+               isc_time_settoepoch(&now);
+
        for (i = 0; i < resolver->badhash; i++) {
                prev = NULL;
                for (bad = resolver->badcache[i]; bad != NULL; bad = next) {
                        next = bad->next;
-                       if (dns_name_issubdomain(&bad->name, name)) {
+                       n = isc_time_compare(&bad->expire, &now);
+                       if (n < 0 || dns_name_issubdomain(&bad->name, name)) {
                                if (prev == NULL)
                                        resolver->badcache[i] = bad->next;
                                else
@@ -8778,7 +8785,6 @@ dns_resolver_flushbadnames(dns_resolver_t *resolver, dns_name_t *name) {
 
  unlock:
        UNLOCK(&resolver->lock);
-
 }
 
 static void
index 45480c8f920c2829d5679e3ba42d43faac53f324..5ae96107e5b47d2bf07f5aad7dfb6582033ee1da 100644 (file)
@@ -1556,31 +1556,31 @@ dns_view_flushcache2(dns_view_t *view, isc_boolean_t fixuponly) {
 
 isc_result_t
 dns_view_flushname(dns_view_t *view, dns_name_t *name) {
-       return (dns_view_flushnode(view, name, ISC_FALSE, ISC_FALSE));
+       return (dns_view_flushnode(view, name, ISC_FALSE));
 }
 
 isc_result_t
-dns_view_flushnode(dns_view_t *view, dns_name_t *name,
-                  isc_boolean_t cachetree, isc_boolean_t all)
-{
+dns_view_flushnode(dns_view_t *view, dns_name_t *name, isc_boolean_t tree) {
+       isc_result_t result = ISC_R_SUCCESS;
 
        REQUIRE(DNS_VIEW_VALID(view));
 
-       if (all) {
+       if (tree) {
                if (view->adb != NULL)
                        dns_adb_flushnames(view->adb, name);
                if (view->resolver != NULL)
                        dns_resolver_flushbadnames(view->resolver, name);
-       } else if (!cachetree) {
+       } else {
                if (view->adb != NULL)
                        dns_adb_flushname(view->adb, name);
-               if (view->cache == NULL)
-                       return (ISC_R_SUCCESS);
                if (view->resolver != NULL)
                        dns_resolver_flushbadcache(view->resolver, name);
        }
 
-       return (dns_cache_flushnode(view->cache, name, cachetree || all));
+       if (view->cache != NULL)
+               result = dns_cache_flushnode(view->cache, name, tree);
+
+       return (result);
 }
 
 isc_result_t