]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- #4146: num.query.subnet and num.query.subnet_cache counters.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 21 Aug 2018 14:14:28 +0000 (14:14 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 21 Aug 2018 14:14:28 +0000 (14:14 +0000)
git-svn-id: file:///svn/unbound/trunk@4867 be551aaa-1e26-0410-a405-d3ace91eadb9

daemon/remote.c
daemon/stats.c
doc/Changelog
doc/unbound-control.8.in
edns-subnet/subnetmod.c
edns-subnet/subnetmod.h
libunbound/unbound.h
smallapp/unbound-control.c

index 07aa579e5a88341c7dfcca9aa5790c0d164d5a1f..6c14a57f6498a30d45e021ae9945e6a958a06854 100644 (file)
@@ -1052,6 +1052,12 @@ print_ext(RES* ssl, struct ub_stats_info* s)
                (unsigned long)s->svr.num_query_authzone_up)) return 0;
        if(!ssl_printf(ssl, "num.query.authzone.down"SQ"%lu\n",
                (unsigned long)s->svr.num_query_authzone_down)) return 0;
+#ifdef CLIENT_SUBNET
+       if(!ssl_printf(ssl, "num.query.subnet"SQ"%lu\n",
+               (unsigned long)s->svr.num_query_subnet)) return 0;
+       if(!ssl_printf(ssl, "num.query.subnet_cache"SQ"%lu\n",
+               (unsigned long)s->svr.num_query_subnet_cache)) return 0;
+#endif /* CLIENT_SUBNET */
        return 1;
 }
 
index d9e769426d9d0f3ff452a1963c62175f4432fe47..cff01d90342fcc022b0524f82d17fec959a0e017 100644 (file)
@@ -63,6 +63,9 @@
 #include "services/authzone.h"
 #include "validator/val_kcache.h"
 #include "validator/val_neg.h"
+#ifdef CLIENT_SUBNET
+#include "edns-subnet/subnetmod.h"
+#endif
 
 /** add timers and the values do not overflow or become negative */
 static void
@@ -124,6 +127,33 @@ void server_stats_log(struct ub_server_stats* stats, struct worker* worker,
                (unsigned)worker->env.mesh->stats_jostled);
 }
 
+
+#ifdef CLIENT_SUBNET
+/** Set the EDNS Subnet stats. */
+static void
+set_subnet_stats(struct worker* worker, struct ub_server_stats* svr,
+       int reset)
+{
+       int m = modstack_find(&worker->env.mesh->mods, "subnet");
+       struct subnet_env* sne;
+       if(m == -1)
+               return;
+       sne = (struct subnet_env*)worker->env.modinfo[m];
+       if(reset && !worker->env.cfg->stat_cumulative) {
+               lock_rw_wrlock(&sne->biglock);
+       } else {
+               lock_rw_rdlock(&sne->biglock);
+       }
+       svr->num_query_subnet = (long long)(sne->num_msg_nocache + sne->num_msg_cache);
+       svr->num_query_subnet_cache = (long long)sne->num_msg_cache;
+       if(reset && !worker->env.cfg->stat_cumulative) {
+               sne->num_msg_cache = 0;
+               sne->num_msg_nocache = 0;
+       }
+       lock_rw_unlock(&sne->biglock);
+}
+#endif /* CLIENT_SUBNET */
+
 /** Set the neg cache stats. */
 static void
 set_neg_cache_stats(struct worker* worker, struct ub_server_stats* svr,
@@ -301,6 +331,13 @@ server_stats_compile(struct worker* worker, struct ub_stats_info* s, int reset)
 
        /* Set neg cache usage numbers */
        set_neg_cache_stats(worker, &s->svr, reset);
+#ifdef CLIENT_SUBNET
+       /* EDNS Subnet usage numbers */
+       set_subnet_stats(worker, &s->svr, reset);
+#else
+       s->svr.num_query_subnet = 0;
+       s->svr.num_query_subnet_cache = 0;
+#endif
 
        /* get tcp accept usage */
        s->svr.tcp_accept_usage = 0;
index 2e57818da3ef40ec814eaa5cf388b2197cc22aad..9328948999074b157968747df4147510dfbe524d 100644 (file)
@@ -1,6 +1,7 @@
 21 August 2018: Wouter
        - log-local-actions: yes option for unbound.conf that logs all the
          local zone actions, a patch from Saksham Manchanda (Secure64).
+       - #4146: num.query.subnet and num.query.subnet_cache counters.
 
 17 August 2018: Ralph
        - Fix classification for QTYPE=CNAME queries when QNAME minimisation is
index 01e028f1520696079e22cd2eded4cdb36b98c608..ce64dc739ed46514a57fc09bb6d79b862f65257e 100644 (file)
@@ -641,6 +641,14 @@ answered using cached data.
 The number of queries answered using cached NSEC records with NXDOMAIN RCODE.
 These queries would otherwise have been sent to the internet, but are now
 answered using cached data.
+.TP
+.I num.query.subnet
+Number of queries that got an answer that contained EDNS client subnet data.
+.TP
+.I num.query.subnet_cache
+Number of queries answered from the edns client subnet cache.  These are
+counted as cachemiss by the main counters, but hit the client subnet
+specific cache, after getting processed by the edns client subnet module.
 .SH "FILES"
 .TP
 .I @ub_conf_file@
index ae2523b86c2343eb957ace784c4aa6e038addcbe..7793f0a4e7135d7fc3863b0e67f2daad0ce0cfd0 100644 (file)
@@ -511,6 +511,7 @@ eval_response(struct module_qstate *qstate, int id, struct subnet_qstate *sq)
 
        lock_rw_wrlock(&sne->biglock);
        update_cache(qstate, id);
+       sne->num_msg_nocache++;
        lock_rw_unlock(&sne->biglock);
        
        if (sq->subnet_downstream) {
@@ -693,6 +694,7 @@ subnetmod_operate(struct module_qstate *qstate, enum module_ev event,
 
                lock_rw_wrlock(&sne->biglock);
                if (lookup_and_reply(qstate, id, sq)) {
+                       sne->num_msg_cache++;
                        lock_rw_unlock(&sne->biglock);
                        verbose(VERB_QUERY, "subnet: answered from cache");
                        qstate->ext_state[id] = module_finished;
index c7f56327f9d2a3ac4030a026604bc9068eb0472f..f417a64a45b0682e6831effb793c6e298163c85a 100644 (file)
@@ -61,6 +61,10 @@ struct subnet_env {
        /** allocation service */
        struct alloc_cache alloc;
        lock_rw_type biglock;
+       /** number of messages from cache */
+       size_t num_msg_cache;
+       /** number of messages not from cache */
+       size_t num_msg_nocache;
 };
 
 struct subnet_msg_cache_data {
index 6bb0ef224b9da94e4de41895521433bf73e79b61..90766b0623636e95482a958f027777804aae4315 100644 (file)
@@ -765,6 +765,11 @@ struct ub_server_stats {
        /** number of times neg cache records were used to generate NXDOMAIN
         * responses. */
        long long num_neg_cache_nxdomain;
+       /** number of queries answered from edns-subnet specific data */
+       long long num_query_subnet;
+       /** number of queries answered from edns-subnet specific data, and
+        * the answer was from the edns-subnet cache. */
+       long long num_query_subnet_cache;
 };
 
 /** 
index f6597b79a2fefe496684b96d848220e743732ad7..9e4c006f3b5d4aa48bb7400aa850741df179c751 100644 (file)
@@ -374,6 +374,10 @@ static void print_extended(struct ub_stats_info* s)
 #endif /* USE_DNSCRYPT */
        PR_UL("num.query.authzone.up", s->svr.num_query_authzone_up);
        PR_UL("num.query.authzone.down", s->svr.num_query_authzone_down);
+#ifdef CLIENT_SUBNET
+       PR_UL("num.query.subnet", s->svr.num_query_subnet);
+       PR_UL("num.query.subnet_cache", s->svr.num_query_subnet_cache);
+#endif
 }
 
 /** print statistics out of memory structures */