]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[v9_9] better zone-statistics syntax
authorEvan Hunt <each@isc.org>
Wed, 27 Feb 2013 20:03:29 +0000 (12:03 -0800)
committerEvan Hunt <each@isc.org>
Wed, 27 Feb 2013 20:03:29 +0000 (12:03 -0800)
3501. [func] zone-statistics now takes three options: full,
terse, and none. "yes" and "no" are retained as
synonyms for full and terse, respectively. [RT #29165]
(cherry picked from commit 40a7e85f3ee3bd66a8f87bf8af674e1e48b05396)

CHANGES
bin/named/config.c
bin/named/server.c
bin/named/statschannel.c
bin/named/zoneconf.c
bin/tests/system/checkconf/good.conf
doc/arm/Bv9ARM-book.xml
lib/dns/include/dns/zone.h
lib/dns/win32/libdns.def
lib/dns/zone.c
lib/isccfg/namedconf.c

diff --git a/CHANGES b/CHANGES
index b7ecca90679d38db939eb2f3cc43a94b9dc6bf03..3df946f4b7b6ae81d8ed6cdc5dcb0ad0c7802fc7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+3501.  [func]          zone-statistics now takes three options: full,
+                       terse, and none. "yes" and "no" are retained as
+                       synonyms for full and terse, respectively. [RT #29165]
+
 3500.  [port]          Support NAPTR regular expression validation on
                        all platforms.  [RT #32688]
 
index 5626e118efb66053d58c0a88e6892dc900bc6427..4b55aea1e79c7f48cf410bd85bbb062383a3b046 100644 (file)
@@ -201,7 +201,7 @@ options {\n\
        sig-signing-signatures 10;\n\
        sig-signing-type 65534;\n\
        inline-signing no;\n\
-       zone-statistics false;\n\
+       zone-statistics terse;\n\
        max-journal-size unlimited;\n\
        ixfr-from-differences false;\n\
        check-wildcard yes;\n\
index ab4bf4999a56efbb4d30f3db9fde5fd9ac1dfbd1..1df6414d88aef3826352e36114ad091d5881d08b 100644 (file)
@@ -1344,12 +1344,14 @@ check_dbtype(dns_zone_t **zonep, unsigned int dbtypec, const char **dbargv,
 }
 
 static isc_result_t
-setquerystats(dns_zone_t *zone, isc_mem_t *mctx, isc_boolean_t on) {
+setquerystats(dns_zone_t *zone, isc_mem_t *mctx, dns_zonestat_level_t level) {
        isc_result_t result;
        isc_stats_t *zoneqrystats;
 
+       dns_zone_setstatlevel(zone, level);
+
        zoneqrystats = NULL;
-       if (on) {
+       if (level == dns_zonestat_full) {
                result = isc_stats_create(mctx, &zoneqrystats,
                                          dns_nsstatscounter_max);
                if (result != ISC_R_SUCCESS)
@@ -1503,7 +1505,7 @@ dns64_reverse(dns_view_t *view, isc_mem_t *mctx, isc_netaddr_t *na,
        dns_zone_setdialup(zone, dns_dialuptype_no);
        dns_zone_setnotifytype(zone, dns_notifytype_no);
        dns_zone_setoption(zone, DNS_ZONEOPT_NOCHECKNS, ISC_TRUE);
-       CHECK(setquerystats(zone, mctx, ISC_FALSE));    /* XXXMPA */
+       CHECK(setquerystats(zone, mctx, dns_zonestat_none));    /* XXXMPA */
        CHECK(dns_view_addzone(view, zone));
        isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
                      ISC_LOG_INFO, "dns64 reverse zone%s%s: %s", sep,
@@ -2888,7 +2890,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
                const char *empty_dbtype[4] =
                                    { "_builtin", "empty", NULL, NULL };
                int empty_dbtypec = 4;
-               isc_boolean_t zonestats_on;
+               dns_zonestat_level_t statlevel;
 
                dns_fixedname_init(&fixed);
                name = dns_fixedname_name(&fixed);
@@ -2926,7 +2928,22 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
                obj = NULL;
                result = ns_config_get(maps, "zone-statistics", &obj);
                INSIST(result == ISC_R_SUCCESS);
-               zonestats_on = cfg_obj_asboolean(obj);
+               if (cfg_obj_isboolean(obj)) {
+                       if (cfg_obj_asboolean(obj))
+                               statlevel = dns_zonestat_full;
+                       else
+                               statlevel = dns_zonestat_terse; /* XXX */
+               } else {
+                       const char *levelstr = cfg_obj_asstring(obj);
+                       if (strcasecmp(levelstr, "full") == 0)
+                               statlevel = dns_zonestat_full;
+                       else if (strcasecmp(levelstr, "terse") == 0)
+                               statlevel = dns_zonestat_terse;
+                       else if (strcasecmp(levelstr, "none") == 0)
+                               statlevel = dns_zonestat_none;
+                       else
+                               INSIST(0);
+               }
 
                for (empty = empty_zones[empty_zone];
                     empty != NULL;
@@ -2985,7 +3002,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
                                        dns_zone_setview(zone, view);
                                        CHECK(dns_view_addzone(view, zone));
                                        CHECK(setquerystats(zone, mctx,
-                                                           zonestats_on));
+                                                           statlevel));
                                        dns_zone_detach(&zone);
                                        continue;
                                }
@@ -3010,7 +3027,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
                        dns_zone_setnotifytype(zone, dns_notifytype_no);
                        dns_zone_setoption(zone, DNS_ZONEOPT_NOCHECKNS,
                                           ISC_TRUE);
-                       CHECK(setquerystats(zone, mctx, zonestats_on));
+                       CHECK(setquerystats(zone, mctx, statlevel));
                        CHECK(dns_view_addzone(view, zone));
                        isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
                                      NS_LOGMODULE_SERVER, ISC_LOG_INFO,
@@ -3753,7 +3770,7 @@ add_keydata_zone(dns_view_t *view, const char *directory, isc_mem_t *mctx) {
        dns_zone_setjournalsize(zone, 0);
 
        dns_zone_setstats(zone, ns_g_server->zonestats);
-       CHECK(setquerystats(zone, mctx, ISC_FALSE));
+       CHECK(setquerystats(zone, mctx, dns_zonestat_none));
 
        if (view->managed_keys != NULL)
                dns_zone_detach(&view->managed_keys);
index 335b600275254024a3591c6edf6d6c739f4f1db0..b3135584209bb4a94fa913abbe61dd14d0cca298 100644 (file)
@@ -884,7 +884,7 @@ opcodestat_dump(dns_opcode_t code, isc_uint64_t val, void *arg) {
 #ifdef NEWSTATS
 static isc_result_t
 zone_xmlrender(dns_zone_t *zone, void *arg) {
-
+       isc_result_t result;
        char buf[1024 + 32];    /* sufficiently large for zone name and class */
        char *zone_name_only = NULL;
        dns_rdataclass_t rdclass;
@@ -892,26 +892,27 @@ zone_xmlrender(dns_zone_t *zone, void *arg) {
        xmlTextWriterPtr writer = arg;
        isc_stats_t *zonestats;
        dns_stats_t *rcvquerystats;
-
+       dns_zonestat_level_t statlevel;
        isc_uint64_t nsstat_values[dns_nsstatscounter_max];
        int xmlrc;
-       isc_result_t result;
+
+       statlevel = dns_zone_getstatlevel(zone);
+       if (statlevel == dns_zonestat_none)
+               return (ISC_R_SUCCESS);
 
        stats_dumparg_t dumparg;
 
        dumparg.type = statsformat_xml;
        dumparg.arg = writer;
 
-
        TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "zone"));
        dns_zone_name(zone, buf, sizeof(buf));
        zone_name_only = strtok(buf, "/");
-       if(zone_name_only == NULL){
+       if(zone_name_only == NULL)
                zone_name_only = buf;
-       }
+
        TRY0(xmlTextWriterWriteAttribute(writer, ISC_XMLCHAR "name",
                                         ISC_XMLCHAR zone_name_only));
-
        rdclass = dns_zone_getclass(zone);
        dns_rdataclass_format(rdclass, buf, sizeof(buf));
        TRY0(xmlTextWriterWriteAttribute(writer, ISC_XMLCHAR "rdataclass",
@@ -926,7 +927,7 @@ zone_xmlrender(dns_zone_t *zone, void *arg) {
 
        zonestats = dns_zone_getrequeststats(zone);
        rcvquerystats = dns_zone_getrcvquerystats(zone);
-       if (zonestats != NULL ) {
+       if (statlevel == dns_zonestat_full && zonestats != NULL) {
                TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "counters"));
                TRY0(xmlTextWriterWriteAttribute(writer, ISC_XMLCHAR "type",
                                                 ISC_XMLCHAR "rcode"));
@@ -941,7 +942,7 @@ zone_xmlrender(dns_zone_t *zone, void *arg) {
                TRY0(xmlTextWriterEndElement(writer));
        }
 
-       if(rcvquerystats != NULL){
+       if (statlevel == dns_zonestat_full && rcvquerystats != NULL) {
                TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "counters"));
                TRY0(xmlTextWriterWriteAttribute(writer, ISC_XMLCHAR "type",
                                                 ISC_XMLCHAR "qtype"));
index 5aa30c1f2089ae6d8abbc804ab7b816991c9f296..839312c13d7eb62a2108e2ab83ecbd1a8d3cf029 100644 (file)
@@ -827,7 +827,7 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
 #ifdef NEWSTATS
        dns_stats_t *rcvquerystats;
 #endif
-       isc_boolean_t zonestats_on;
+       dns_zonestat_level_t statlevel;
        int seconds;
        dns_zone_t *mayberaw = (raw != NULL) ? raw : zone;
 
@@ -1009,13 +1009,29 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
        obj = NULL;
        result = ns_config_get(maps, "zone-statistics", &obj);
        INSIST(result == ISC_R_SUCCESS && obj != NULL);
-       zonestats_on = cfg_obj_asboolean(obj);
+       if (cfg_obj_isboolean(obj)) {
+               if (cfg_obj_asboolean(obj))
+                       statlevel = dns_zonestat_full;
+               else
+                       statlevel = dns_zonestat_terse; /* XXX */
+       } else {
+               const char *levelstr = cfg_obj_asstring(obj);
+               if (strcasecmp(levelstr, "full") == 0)
+                       statlevel = dns_zonestat_full;
+               else if (strcasecmp(levelstr, "terse") == 0)
+                       statlevel = dns_zonestat_terse;
+               else if (strcasecmp(levelstr, "none") == 0)
+                       statlevel = dns_zonestat_none;
+               else
+                       INSIST(0);
+       }
+       dns_zone_setstatlevel(zone, statlevel);
 
        zoneqrystats  = NULL;
 #ifdef NEWSTATS
        rcvquerystats = NULL;
 #endif
-       if (zonestats_on) {
+       if (statlevel == dns_zonestat_full) {
                RETERR(isc_stats_create(mctx, &zoneqrystats,
                                        dns_nsstatscounter_max));
 #ifdef NEWSTATS
index 4ff0c1a731d0811279992cab93dd70b338b1c906..2b973a86255bc95e44df5da20a56a22fa9193ae8 100644 (file)
@@ -66,6 +66,7 @@ options {
        serial-queries 10;
        serial-query-rate 100;
        server-id none;
+       zone-statistics none;
 };
 view "first" {
        match-clients {
@@ -78,6 +79,7 @@ view "first" {
        };
        dnssec-lookaside auto;
        dnssec-validation auto;
+       zone-statistics terse;
 };
 view "second" {
        match-clients {
@@ -87,6 +89,7 @@ view "second" {
                type master;
                file "yyy";
                update-policy local;
+               zone-statistics yes;
        };
        zone "example2" {
                type static-stub;
@@ -94,7 +97,9 @@ view "second" {
                forwarders {
                        10.53.0.4;
                };
+               zone-statistics no;
        };
        dnssec-lookaside "." trust-anchor "dlv.isc.org.";
        dnssec-validation auto;
+       zone-statistics full;
 };
index b4ebacb408103e1bade109ad99ce4909382183ba..c54ec0b1e4ea62a343a6dcc0547e6ae948a30e54 100644 (file)
@@ -5162,7 +5162,7 @@ badresp:1,adberr:0,findfail:0,valfail:0]
     <optional> pid-file <replaceable>path_name</replaceable>; </optional>
     <optional> recursing-file <replaceable>path_name</replaceable>; </optional>
     <optional> statistics-file <replaceable>path_name</replaceable>; </optional>
-    <optional> zone-statistics <replaceable>yes_or_no</replaceable>; </optional>
+    <optional> zone-statistics <replaceable>full</replaceable> | <replaceable>terse</replaceable> | <replaceable>none</replaceable>; </optional>
     <optional> auth-nxdomain <replaceable>yes_or_no</replaceable>; </optional>
     <optional> deallocate-on-exit <replaceable>yes_or_no</replaceable>; </optional>
     <optional> dialup <replaceable>dialup_option</replaceable>; </optional>
@@ -6045,7 +6045,39 @@ options {
            </listitem>
          </varlistentry>
 
-
+          <varlistentry>
+            <term><command>zone-statistics</command></term>
+            <listitem>
+              <para>
+                If <userinput>full</userinput>, the server will collect
+                statistical data on all zones (unless specifically
+                turned off on a per-zone basis by specifying
+                <command>zone-statistics terse</command> or
+                <command>zone-statistics none</command>
+                in the <command>zone</command> statement).
+                The default is <userinput>terse</userinput>, providing
+                minimal statistics on zones (including name and
+                current serial number, but not query type
+                counters).
+              </para>
+              <para>
+                These statistics may be accessed via the
+                <command>statistics-channel</command> or
+                using <command>rndc stats</command>, which
+                will dump them to the file listed
+                in the <command>statistics-file</command>.  See
+                also <xref linkend="statsfile"/>.
+              </para>
+              <para>
+                For backward compatibility with earlier versions
+                of BIND 9, the <command>zone-statistics</command>
+                option can also accept <userinput>yes</userinput>
+                or <userinput>no</userinput>, which have the same
+                effect as <userinput>full</userinput> and
+                <userinput>terse</userinput>, respectively.
+              </para>
+            </listitem>
+          </varlistentry>
         </variablelist>
 
         <sect3 id="boolean_options">
@@ -6543,25 +6575,6 @@ options {
               </listitem>
             </varlistentry>
 
-            <varlistentry>
-              <term><command>zone-statistics</command></term>
-              <listitem>
-                <para>
-                  If <userinput>yes</userinput>, the server will collect
-                  statistical data on all zones (unless specifically turned
-                  off
-                  on a per-zone basis by specifying <command>zone-statistics no</command>
-                  in the <command>zone</command> statement).
-                  The default is <userinput>no</userinput>.
-                  These statistics may be accessed
-                  using <command>rndc stats</command>, which will
-                  dump them to the file listed
-                  in the <command>statistics-file</command>.  See
-                  also <xref linkend="statsfile"/>.
-                </para>
-              </listitem>
-            </varlistentry>
-
             <varlistentry>
               <term><command>use-ixfr</command></term>
               <listitem>
@@ -10476,7 +10489,7 @@ view "external" {
     <optional> pubkey <replaceable>number</replaceable> <replaceable>number</replaceable> <replaceable>number</replaceable> <replaceable>string</replaceable> ; </optional>
     <optional> notify-source (<replaceable>ip4_addr</replaceable> | <constant>*</constant>) <optional>port <replaceable>ip_port</replaceable></optional> ; </optional>
     <optional> notify-source-v6 (<replaceable>ip6_addr</replaceable> | <constant>*</constant>) <optional>port <replaceable>ip_port</replaceable></optional> ; </optional>
-    <optional> zone-statistics <replaceable>yes_or_no</replaceable> ; </optional>
+    <optional> zone-statistics <replaceable>full</replaceable> | <replaceable>terse</replaceable> | <replaceable>none</replaceable>; </optional>
     <optional> sig-validity-interval <replaceable>number</replaceable> <optional><replaceable>number</replaceable></optional> ; </optional>
     <optional> sig-signing-nodes <replaceable>number</replaceable> ; </optional>
     <optional> sig-signing-signatures <replaceable>number</replaceable> ; </optional>
@@ -10541,7 +10554,7 @@ zone <replaceable>zone_name</replaceable> <optional><replaceable>class</replacea
     <optional> use-alt-transfer-source <replaceable>yes_or_no</replaceable>; </optional>
     <optional> notify-source (<replaceable>ip4_addr</replaceable> | <constant>*</constant>) <optional>port <replaceable>ip_port</replaceable></optional> ; </optional>
     <optional> notify-source-v6 (<replaceable>ip6_addr</replaceable> | <constant>*</constant>) <optional>port <replaceable>ip_port</replaceable></optional> ; </optional>
-    <optional> zone-statistics <replaceable>yes_or_no</replaceable> ; </optional>
+    <optional> zone-statistics <replaceable>full</replaceable> | <replaceable>terse</replaceable> | <replaceable>none</replaceable>; </optional>
     <optional> sig-validity-interval <replaceable>number</replaceable> <optional><replaceable>number</replaceable></optional> ; </optional>
     <optional> sig-signing-nodes <replaceable>number</replaceable> ; </optional>
     <optional> sig-signing-signatures <replaceable>number</replaceable> ; </optional>
index b83497b181c438a87ac8358a5d2a2dd4ded2b65e..326d920fe32978870a1a1d29f898e194c8da5ac2 100644 (file)
@@ -50,6 +50,12 @@ typedef enum {
        dns_zone_redirect
 } dns_zonetype_t;
 
+typedef enum {
+       dns_zonestat_none = 0,
+       dns_zonestat_terse,
+       dns_zonestat_full
+} dns_zonestat_level_t;
+
 #define DNS_ZONEOPT_SERVERS      0x00000001U   /*%< perform server checks */
 #define DNS_ZONEOPT_PARENTS      0x00000002U   /*%< perform parent checks */
 #define DNS_ZONEOPT_CHILDREN     0x00000004U   /*%< perform child checks */
@@ -1704,9 +1710,13 @@ dns_zone_setstats(dns_zone_t *zone, isc_stats_t *stats);
 
 void
 dns_zone_setrequeststats(dns_zone_t *zone, isc_stats_t *stats);
+
+void
+dns_zone_setrcvquerystats(dns_zone_t *zone, dns_stats_t *stats);
 /*%<
- * Set an additional statistics set to zone.  It is attached in the zone
- * but is not counted in the zone module; only the caller updates the counters.
+ * Set additional statistics sets to zone.  These are attached to the zone
+ * but are not counted in the zone module; only the caller updates the
+ * counters.
  *
  * Requires:
  * \li 'zone' to be a valid zone.
@@ -2078,6 +2088,16 @@ dns_zone_rpz_enable(dns_zone_t *zone);
 isc_boolean_t
 dns_zone_get_rpz(dns_zone_t *zone);
 
+void
+dns_zone_setstatlevel(dns_zone_t *zone, dns_zonestat_level_t level);
+
+dns_zonestat_level_t
+dns_zone_getstatlevel(dns_zone_t *zone);
+/*%
+ * Set and get the statistics reporting level for the zone;
+ * full, terse, or none.
+ */
+
 ISC_LANG_ENDDECLS
 
 #endif /* DNS_ZONE_H */
index b590a0b0993f192ef644669cafeb0d4e8a00e703..e3351f33fb410cd435b6356a515ef907fd4f3e8c 100644 (file)
@@ -839,6 +839,7 @@ dns_zone_getserialupdatemethod
 dns_zone_getsigresigninginterval
 dns_zone_getsigvalidityinterval
 dns_zone_getssutable
+dns_zone_getstatlevel
 dns_zone_getstatscounters
 dns_zone_gettask
 dns_zone_gettype
@@ -925,6 +926,7 @@ dns_zone_setsigresigninginterval
 dns_zone_setsigvalidityinterval
 dns_zone_setssutable
 dns_zone_setstatistics
+dns_zone_setstatlevel
 dns_zone_setstats
 dns_zone_settask
 dns_zone_settype
index ad67b30d9931eedc8e2546f9d83dd598bc017852..90b33b476493af671f2a0997671055aa6968f176 100644 (file)
@@ -306,6 +306,7 @@ struct dns_zone {
         * Optional per-zone statistics counters.  Counted outside of this
         * module.
         */
+       dns_zonestat_level_t    statlevel;
        isc_boolean_t           requeststats_on;
        isc_stats_t             *requeststats;
        dns_stats_t             *rcvquerystats;
@@ -904,6 +905,7 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) {
        zone->statelist = NULL;
        zone->stats = NULL;
        zone->requeststats_on = ISC_FALSE;
+       zone->statlevel = dns_zonestat_none;
        zone->requeststats = NULL;
        zone->rcvquerystats = NULL;
        zone->notifydelay = 5;
@@ -16635,3 +16637,17 @@ dns_zone_setnsec3param(dns_zone_t *zone, isc_uint8_t hash, isc_uint8_t flags,
        UNLOCK_ZONE(zone);
        return (result);
 }
+
+void
+dns_zone_setstatlevel(dns_zone_t *zone, dns_zonestat_level_t level) {
+       REQUIRE(DNS_ZONE_VALID(zone));
+
+       zone->statlevel = level;
+}
+
+dns_zonestat_level_t
+dns_zone_getstatlevel(dns_zone_t *zone) {
+       REQUIRE(DNS_ZONE_VALID(zone));
+
+       return (zone->statlevel);
+}
index f5062e86c0141fa86c8c45abda9531274a6ca10d..854d1b4e5081c4330ab9d93629229b7451db5f71 100644 (file)
@@ -54,6 +54,9 @@ static isc_result_t
 parse_enum_or_other(cfg_parser_t *pctx, const cfg_type_t *enumtype,
                    const cfg_type_t *othertype, cfg_obj_t **ret);
 
+static void
+doc_enum_or_other(cfg_printer_t *pctx, const cfg_type_t *type);
+
 static isc_result_t
 parse_keyvalue(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
 
@@ -559,6 +562,23 @@ static cfg_type_t cfg_type_updatemethod = {
        &cfg_rep_string, &updatemethods_enums
 };
 
+/*
+ * zone-statistics: full, terse, or none.
+ *
+ * for backward compatibility, we also support boolean values.
+ * yes represents "full", no represents "terse". in the future we
+ * may change no to mean "none".
+ */
+static const char *zonestat_enums[] = { "full", "terse", "none", NULL };
+static isc_result_t
+parse_zonestat(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
+       return (parse_enum_or_other(pctx, type, &cfg_type_boolean, ret));
+}
+static cfg_type_t cfg_type_zonestat = {
+       "zonestat", parse_zonestat, cfg_print_ustring, doc_enum_or_other,
+       &cfg_rep_string, zonestat_enums
+};
+
 static cfg_type_t cfg_type_rrsetorder = {
        "rrsetorder", cfg_parse_bracketed_list, cfg_print_bracketed_list, cfg_doc_bracketed_list,
        &cfg_rep_list, &cfg_type_rrsetorderingelement
@@ -1515,7 +1535,7 @@ zone_clauses[] = {
        { "update-check-ksk", &cfg_type_boolean, 0 },
        { "use-alt-transfer-source", &cfg_type_boolean, 0 },
        { "zero-no-soa-ttl", &cfg_type_boolean, 0 },
-       { "zone-statistics", &cfg_type_boolean, 0 },
+       { "zone-statistics", &cfg_type_zonestat, 0 },
        { NULL, NULL, 0 }
 };