From: Mark Andrews Date: Wed, 25 Jun 2014 03:17:03 +0000 (+1000) Subject: 3888. [func] 'rndc status' now reports the number of automatic X-Git-Tag: v9.11.0a1~1497 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=33399d6a143403bc4a9ccb9307af43ef04ab7633;p=thirdparty%2Fbind9.git 3888. [func] 'rndc status' now reports the number of automatic zones. [RT #36015] --- diff --git a/CHANGES b/CHANGES index c0f6fb61beb..594b826710a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +3888. [func] 'rndc status' now reports the number of automatic + zones. [RT #36015] + 3887. [cleanup] Make all static symbols in rbtdb64 end in "64" so they are easier to use in a debugger. [RT #36373] diff --git a/bin/named/server.c b/bin/named/server.c index ed62f49d845..a0e774f7ff5 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -2259,6 +2259,7 @@ create_empty_zone(dns_zone_t *zone, dns_name_t *name, dns_view_t *view, dns_zone_setoption(zone, DNS_ZONEOPT_NOCHECKNS, ISC_TRUE); dns_zone_setnotifytype(zone, dns_notifytype_no); dns_zone_setdialup(zone, dns_dialuptype_no); + dns_zone_setautomatic(zone, ISC_TRUE); if (view->queryacl) dns_zone_setqueryacl(zone, view->queryacl); else @@ -8227,7 +8228,8 @@ ns_server_flushnode(ns_server_t *server, char *args, isc_boolean_t tree) { isc_result_t ns_server_status(ns_server_t *server, isc_buffer_t *text) { - int zonecount, xferrunning, xferdeferred, soaqueries; + unsigned int zonecount, xferrunning, xferdeferred, soaqueries; + unsigned int automatic; unsigned int n; const char *ob = "", *cb = "", *alt = ""; char boottime[80], configtime[80]; @@ -8247,6 +8249,8 @@ ns_server_status(ns_server_t *server, isc_buffer_t *text) { DNS_ZONESTATE_XFERDEFERRED); soaqueries = dns_zonemgr_getcount(server->zonemgr, DNS_ZONESTATE_SOAQUERY); + automatic = dns_zonemgr_getcount(server->zonemgr, + DNS_ZONESTATE_AUTOMATIC); isc_time_formathttptimestamp(&ns_g_boottime, boottime, sizeof(boottime)); @@ -8263,7 +8267,7 @@ ns_server_status(ns_server_t *server, isc_buffer_t *text) { "worker threads: %u\n" "UDP listeners per interface: %u\n" #endif - "number of zones: %u\n" + "number of zones: %u (%u automatic)\n" "debug level: %d\n" "xfers running: %u\n" "xfers deferred: %u\n" @@ -8277,8 +8281,9 @@ ns_server_status(ns_server_t *server, isc_buffer_t *text) { #ifdef ISC_PLATFORM_USETHREADS ns_g_cpus_detected, ns_g_cpus, ns_g_udpdisp, #endif - zonecount, ns_g_debuglevel, xferrunning, xferdeferred, - soaqueries, server->log_queries ? "ON" : "OFF", + zonecount, automatic, ns_g_debuglevel, xferrunning, + xferdeferred, soaqueries, + server->log_queries ? "ON" : "OFF", server->recursionquota.used, server->recursionquota.soft, server->recursionquota.max, server->tcpquota.used, server->tcpquota.max); diff --git a/bin/tests/system/rndc/clean.sh b/bin/tests/system/rndc/clean.sh index 72cc8de2134..a7b321637e3 100644 --- a/bin/tests/system/rndc/clean.sh +++ b/bin/tests/system/rndc/clean.sh @@ -21,3 +21,4 @@ rm -f ns3/named_dump.db rm -f ns*/named.memstats rm -f ns*/named.run rm -f ns4/*.conf +rm -f rndc.status diff --git a/bin/tests/system/rndc/ns4/named.conf.in b/bin/tests/system/rndc/ns4/named.conf.in index bf66a8878c1..6b03bfa56ad 100644 --- a/bin/tests/system/rndc/ns4/named.conf.in +++ b/bin/tests/system/rndc/ns4/named.conf.in @@ -23,6 +23,6 @@ options { pid-file "named.pid"; listen-on { 10.53.0.4; }; listen-on-v6 { none; }; - recursion no; + recursion yes; }; diff --git a/bin/tests/system/rndc/tests.sh b/bin/tests/system/rndc/tests.sh index 6e14a470e10..576a160df3e 100644 --- a/bin/tests/system/rndc/tests.sh +++ b/bin/tests/system/rndc/tests.sh @@ -341,5 +341,12 @@ done if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` +echo "I:testing automatic zones are reported" +ret=0 +$RNDC -s 10.53.0.4 -p 9956 -c ns4/key6.conf status > rndc.status || ret=1 +grep "number of zones: 98 (97 automatic)" rndc.status > /dev/null || ret=1 +if [ $ret != 0 ]; then echo "I:failed"; fi +status=`expr $status + $ret` + echo "I:exit status: $status" exit $status diff --git a/lib/dns/include/dns/zone.h b/lib/dns/include/dns/zone.h index b36546a26c1..5a103636ea0 100644 --- a/lib/dns/include/dns/zone.h +++ b/lib/dns/include/dns/zone.h @@ -135,6 +135,7 @@ typedef enum { #define DNS_ZONESTATE_XFERDEFERRED 2 #define DNS_ZONESTATE_SOAQUERY 3 #define DNS_ZONESTATE_ANY 4 +#define DNS_ZONESTATE_AUTOMATIC 5 ISC_LANG_BEGINDECLS @@ -2128,6 +2129,25 @@ dns_zone_getadded(dns_zone_t *zone); * \li 'zone' to be valid. */ +void +dns_zone_setautomatic(dns_zone_t *zone, isc_boolean_t automatic); +/*% + * Sets the value of zone->automatic, which should be ISC_TRUE for + * zones that were automatically added by named. + * + * Requires: + * \li 'zone' to be valid. + */ + +isc_boolean_t +dns_zone_getautomatic(dns_zone_t *zone); +/*% + * Returns ISC_TRUE if the zone was added automatically by named. + * + * Requires: + * \li 'zone' to be valid. + */ + isc_result_t dns_zone_dlzpostload(dns_zone_t *zone, dns_db_t *db); /*% diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in index 740a3544248..862b2b03feb 100644 --- a/lib/dns/win32/libdns.def.in +++ b/lib/dns/win32/libdns.def.in @@ -893,6 +893,7 @@ dns_zone_get_rpz_num dns_zone_getadded dns_zone_getaltxfrsource4dscp dns_zone_getaltxfrsource6dscp +dns_zone_getautomatic dns_zone_getchecknames dns_zone_getclass dns_zone_getdb @@ -978,6 +979,7 @@ dns_zone_setaltxfrsource4 dns_zone_setaltxfrsource4dscp dns_zone_setaltxfrsource6 dns_zone_setaltxfrsource6dscp +dns_zone_setautomatic dns_zone_setcheckmx dns_zone_setchecknames dns_zone_setcheckns diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 2e4a0a37921..04d2239680e 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -371,6 +371,11 @@ struct dns_zone { */ isc_boolean_t added; + /*% + * True if added by automatically by named. + */ + isc_boolean_t automatic; + /*% * response policy data to be relayed to the database */ @@ -986,6 +991,7 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) { zone->nodes = 100; zone->privatetype = (dns_rdatatype_t)0xffffU; zone->added = ISC_FALSE; + zone->automatic = ISC_FALSE; zone->rpzs = NULL; zone->rpz_num = DNS_RPZ_INVALID_NUM; ISC_LIST_INIT(zone->forwards); @@ -16192,6 +16198,17 @@ dns_zonemgr_getcount(dns_zonemgr_t *zmgr, int state) { count++; } break; + case DNS_ZONESTATE_AUTOMATIC: + for (zone = ISC_LIST_HEAD(zmgr->zones); + zone != NULL; + zone = ISC_LIST_NEXT(zone, link)) { + dns_view_t *view = zone->view; + if (view != NULL && strcmp(view->name, "_bind") == 0) + continue; + if (zone->automatic) + count++; + } + break; default: INSIST(0); } @@ -17198,6 +17215,21 @@ dns_zone_nscheck(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *version, return (result); } +void +dns_zone_setautomatic(dns_zone_t *zone, isc_boolean_t automatic) { + REQUIRE(DNS_ZONE_VALID(zone)); + + LOCK_ZONE(zone); + zone->automatic = automatic; + UNLOCK_ZONE(zone); +} + +isc_boolean_t +dns_zone_getautomatic(dns_zone_t *zone) { + REQUIRE(DNS_ZONE_VALID(zone)); + return (zone->automatic); +} + void dns_zone_setadded(dns_zone_t *zone, isc_boolean_t added) { REQUIRE(DNS_ZONE_VALID(zone));