From: Evan Hunt Date: Mon, 1 Jul 2013 01:53:48 +0000 (-0700) Subject: [master] "flushtree -all" no longer optional X-Git-Tag: v9.10.0a1~250 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=9d4ec6d2c59bd5845ac8bca5a5d790be9a772862;p=thirdparty%2Fbind9.git [master] "flushtree -all" no longer optional 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] --- diff --git a/CHANGES b/CHANGES index b15040609c1..5bc74b5ce92 100644 --- 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] diff --git a/bin/named/server.c b/bin/named/server.c index bfbaea0a6e8..c3c9a4cb136 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -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, diff --git a/bin/rndc/rndc.docbook b/bin/rndc/rndc.docbook index 472a62f8ed9..1a14f7af014 100644 --- a/bin/rndc/rndc.docbook +++ b/bin/rndc/rndc.docbook @@ -522,11 +522,8 @@ Flushes the given name, and all of its subdomains, - from the server's DNS cache. By default, this does - not affect the server's address - database or bad-server cache. To eliminate matching - names from those databases as well, use - the option. + from the server's DNS cache, the address database, + and the bad server cache. diff --git a/bin/tests/system/cacheclean/tests.sh b/bin/tests/system/cacheclean/tests.sh index 86e318cc4e6..37d164b1ca0 100644 --- a/bin/tests/system/cacheclean/tests.sh +++ b/bin/tests/system/cacheclean/tests.sh @@ -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 diff --git a/lib/dns/include/dns/view.h b/lib/dns/include/dns/view.h index 3e9e2d6640b..b287869aef2 100644 --- a/lib/dns/include/dns/view.h +++ b/lib/dns/include/dns/view.h @@ -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. diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 13139ab0846..b52c0847149 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -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 diff --git a/lib/dns/view.c b/lib/dns/view.c index 45480c8f920..5ae96107e5b 100644 --- a/lib/dns/view.c +++ b/lib/dns/view.c @@ -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