From d714dfe8d8384e3798b00d30f0440e5d39cb40bb Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Wed, 17 Dec 2008 14:50:03 +0000 Subject: [PATCH] ipv6 counter in extended statistics. git-svn-id: file:///svn/unbound/trunk@1397 be551aaa-1e26-0410-a405-d3ace91eadb9 --- contrib/unbound_munin_ | 5 +++-- daemon/remote.c | 2 ++ daemon/stats.c | 6 +++++- daemon/stats.h | 9 +++++++-- daemon/worker.c | 2 +- doc/Changelog | 2 ++ doc/TODO | 1 - doc/unbound-control.8.in | 3 +++ 8 files changed, 23 insertions(+), 7 deletions(-) diff --git a/contrib/unbound_munin_ b/contrib/unbound_munin_ index 341f5071b..82ce8982c 100755 --- a/contrib/unbound_munin_ +++ b/contrib/unbound_munin_ @@ -226,6 +226,7 @@ if test "$1" = "config" ; then p_config "total.num.queries" "total queries from clients" p_config "total.num.cachehits" "cache hits" p_config "num.query.tcp" "TCP queries" + p_config "num.query.ipv6" "IPv6 queries" p_config "unwanted.queries" "queries that failed acl" p_config "unwanted.replies" "unwanted or unsolicited replies" echo "u_replies.warning $warn" @@ -412,8 +413,8 @@ hits) for x in thread0.num.queries thread1.num.queries thread2.num.queries \ thread3.num.queries thread4.num.queries thread5.num.queries \ thread6.num.queries thread7.num.queries total.num.queries \ - total.num.cachehits num.query.tcp unwanted.queries \ - unwanted.replies; do + total.num.cachehits num.query.tcp num.query.ipv6 \ + unwanted.queries unwanted.replies; do if grep "^"$x"=" $state >/dev/null 2>&1; then print_qps $x fi diff --git a/daemon/remote.c b/daemon/remote.c index df222c520..d82c1b4d8 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -773,6 +773,8 @@ print_ext(SSL* ssl, struct stats_info* s) /* transport */ if(!ssl_printf(ssl, "num.query.tcp"SQ"%u\n", (unsigned)s->svr.qtcp)) return 0; + if(!ssl_printf(ssl, "num.query.ipv6"SQ"%u\n", + (unsigned)s->svr.qipv6)) return 0; /* flags */ if(!ssl_printf(ssl, "num.query.flags.QR"SQ"%u\n", (unsigned)s->svr.qbit_QR)) return 0; diff --git a/daemon/stats.c b/daemon/stats.c index 6f67b46a7..5d88ec9fc 100644 --- a/daemon/stats.c +++ b/daemon/stats.c @@ -197,6 +197,7 @@ void server_stats_add(struct stats_info* total, struct stats_info* a) total->svr.qtype_big += a->svr.qtype_big; total->svr.qclass_big += a->svr.qclass_big; total->svr.qtcp += a->svr.qtcp; + total->svr.qipv6 += a->svr.qipv6; total->svr.qbit_QR += a->svr.qbit_QR; total->svr.qbit_AA += a->svr.qbit_AA; total->svr.qbit_TC += a->svr.qbit_TC; @@ -238,7 +239,8 @@ void server_stats_add(struct stats_info* total, struct stats_info* a) } void server_stats_insquery(struct server_stats* stats, struct comm_point* c, - uint16_t qtype, uint16_t qclass, struct edns_data* edns) + uint16_t qtype, uint16_t qclass, struct edns_data* edns, + struct comm_reply* repinfo) { uint16_t flags = ldns_buffer_read_u16_at(c->buffer, 2); if(qtype < STATS_QTYPE_NUM) @@ -250,6 +252,8 @@ void server_stats_insquery(struct server_stats* stats, struct comm_point* c, stats->qopcode[ LDNS_OPCODE_WIRE(ldns_buffer_begin(c->buffer)) ]++; if(c->type != comm_udp) stats->qtcp++; + if(repinfo && addr_is_ip6(&repinfo->addr, repinfo->addrlen)) + stats->qipv6++; if( (flags&BIT_QR) ) stats->qbit_QR++; if( (flags&BIT_AA) ) diff --git a/daemon/stats.h b/daemon/stats.h index d894e0292..0e339c3fd 100644 --- a/daemon/stats.h +++ b/daemon/stats.h @@ -46,6 +46,7 @@ struct worker; struct config_file; struct comm_point; +struct comm_reply; struct edns_data; /** number of qtype that is stored for in array */ @@ -87,6 +88,8 @@ struct server_stats { size_t qopcode[STATS_OPCODE_NUM]; /** number of queries over TCP */ size_t qtcp; + /** number of queries over IPv6 */ + size_t qipv6; /** number of queries with QR bit */ size_t qbit_QR; /** number of queries with AA bit */ @@ -113,7 +116,7 @@ struct server_stats { size_t ans_rcode_nodata; /** answers that were secure (AD) */ size_t ans_secure; - /** answers with bogus content */ + /** answers that were bogus (withheld as SERVFAIL) */ size_t ans_bogus; /** rrsets marked bogus by validator */ size_t rrset_bogus; @@ -204,9 +207,11 @@ void server_stats_add(struct stats_info* total, struct stats_info* a); * @param qtype: query type * @param qclass: query class * @param edns: edns record + * @param repinfo: reply info with remote address */ void server_stats_insquery(struct server_stats* stats, struct comm_point* c, - uint16_t qtype, uint16_t qclass, struct edns_data* edns); + uint16_t qtype, uint16_t qclass, struct edns_data* edns, + struct comm_reply* repinfo); /** * Add rcode for this query. diff --git a/daemon/worker.c b/daemon/worker.c index 911ad193e..2fe4f127e 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -816,7 +816,7 @@ worker_handle_request(struct comm_point* c, void* arg, int error, } if(worker->stats.extended) server_stats_insquery(&worker->stats, c, qinfo.qtype, - qinfo.qclass, &edns); + qinfo.qclass, &edns, repinfo); if(c->type != comm_udp) edns.udp_size = 65535; /* max size for TCP replies */ if(qinfo.qclass == LDNS_RR_CLASS_CH && answer_chaos(worker, &qinfo, diff --git a/doc/Changelog b/doc/Changelog index 103aadb4c..f6d454883 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,6 +1,8 @@ 17 December 2008: Wouter - follows ldns makedist.sh. -rc option. autom4te dir removed. - unbound-control status command. + - extended statistics has a number of ipv6 queries counter. + contrib/unbound_munin_ was updated to draw ipv6 in the hits graph. 16 December 2008: Wouter - follow makedist improvements from ldns, for maintainers prereleases. diff --git a/doc/TODO b/doc/TODO index 41eaadc13..53413582f 100644 --- a/doc/TODO +++ b/doc/TODO @@ -58,5 +58,4 @@ o local-zone directive with authority service, full authority server is a non-goal. o configure option to force use of builtin ldns tarball. o include /etc/pki/dnssec-keys/production/*.conf with wildcard support. -o add extended stat counter for num queries over ipv6, ipv6 usage. o make so revoke bit keys cannot verify signatures diff --git a/doc/unbound-control.8.in b/doc/unbound-control.8.in index 068abfb4a..ede6de346 100644 --- a/doc/unbound-control.8.in +++ b/doc/unbound-control.8.in @@ -259,6 +259,9 @@ Also printed for other opcodes, UPDATE, ... .I num.query.tcp Number of queries that were made using TCP towards the unbound server. .TP +.I num.query.ipv6 +Number of queries that were made using IPv6 towards the unbound server. +.TP .I num.query.flags.RD The number of queries that had the RD flag set in the header. Also printed for flags QR, AA, TC, RA, Z, AD, CD.