]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix #704: [FR] Statistics counter for number of outgoing UDP queries
authorGeorge Thessalonikefs <george@nlnetlabs.nl>
Wed, 29 Jun 2022 08:51:54 +0000 (10:51 +0200)
committerGeorge Thessalonikefs <george@nlnetlabs.nl>
Wed, 29 Jun 2022 08:51:54 +0000 (10:51 +0200)
  sent; introduces 'num.query.udpout' to the 'unbound-control stats'
  command.

13 files changed:
contrib/metrics.awk
contrib/unbound_munin_
daemon/remote.c
daemon/stats.c
daemon/worker.c
doc/Changelog
doc/unbound-control.8.in
libunbound/unbound.h
services/outside_network.c
services/outside_network.h
smallapp/unbound-control.c
testdata/stat_values.tdir/stat_values.conf
testdata/stat_values.tdir/stat_values.test

index 5a7a2569c29a16f1d5e189113620deee14a77a5c..ca48c035aa0e522b81aa93ad115aeaccd7da4ca8 100644 (file)
@@ -28,6 +28,7 @@ END {
        print "unbound_hits_queries{type=\"total.num.prefetch\"} " val["total.num.prefetch"];
        print "unbound_hits_queries{type=\"num.query.tcp\"} " val["num.query.tcp"];
        print "unbound_hits_queries{type=\"num.query.tcpout\"} " val["num.query.tcpout"];
+       print "unbound_hits_queries{type=\"num.query.udpout\"} " val["num.query.udpout"];
        print "unbound_hits_queries{type=\"num.query.tls\"} " val["num.query.tls"];
        print "unbound_hits_queries{type=\"num.query.tls.resume\"} " val["num.query.tls.resume"];
        print "unbound_hits_queries{type=\"num.query.ipv6\"} " val["num.query.ipv6"];
index 5037527580e23205b523aec9243e781c5787bbcf..a756a5d1ca200ecded4749e25a83716aaa98386d 100755 (executable)
@@ -253,6 +253,7 @@ if test "$1" = "config" ; then
                p_config "total.num.prefetch" "cache prefetch" "ABSOLUTE"
                p_config "num.query.tcp" "TCP queries" "ABSOLUTE"
                p_config "num.query.tcpout" "TCP out queries" "ABSOLUTE"
+               p_config "num.query.udpout" "UDP out queries" "ABSOLUTE"
                p_config "num.query.tls" "TLS queries" "ABSOLUTE"
                p_config "num.query.tls.resume" "TLS resumes" "ABSOLUTE"
                p_config "num.query.ipv6" "IPv6 queries" "ABSOLUTE"
@@ -452,7 +453,7 @@ hits)
        for x in `grep "^thread[0-9][0-9]*\.num\.queries=" $state |
                sed -e 's/=.*//'` total.num.queries \
                total.num.cachehits total.num.prefetch num.query.tcp \
-               num.query.tcpout num.query.tls num.query.tls.resume \
+               num.query.tcpout num.query.udpout num.query.tls num.query.tls.resume \
                num.query.ipv6 unwanted.queries \
                unwanted.replies; do
                if grep "^"$x"=" $state >/dev/null 2>&1; then
index 675ef43970d1ff259ddc19d1fc768cdbbbbf9213..ec7a4d5d93f4b5d57ec427c2b1c1da9ae1659d11 100644 (file)
@@ -988,6 +988,8 @@ print_ext(RES* ssl, struct ub_stats_info* s)
                (unsigned long)s->svr.qtcp)) return 0;
        if(!ssl_printf(ssl, "num.query.tcpout"SQ"%lu\n", 
                (unsigned long)s->svr.qtcp_outgoing)) return 0;
+       if(!ssl_printf(ssl, "num.query.udpout"SQ"%lu\n",
+               (unsigned long)s->svr.qudp_outgoing)) return 0;
        if(!ssl_printf(ssl, "num.query.tls"SQ"%lu\n", 
                (unsigned long)s->svr.qtls)) return 0;
        if(!ssl_printf(ssl, "num.query.tls.resume"SQ"%lu\n", 
index d08f18dbb1376ad4deaf5d66056782ffdda48a6d..57c42827161c3dd94a2e9b1df4e89d882d27a3b0 100644 (file)
@@ -281,6 +281,7 @@ server_stats_compile(struct worker* worker, struct ub_stats_info* s, int reset)
        /* values from outside network */
        s->svr.unwanted_replies = (long long)worker->back->unwanted_replies;
        s->svr.qtcp_outgoing = (long long)worker->back->num_tcp_outgoing;
+       s->svr.qudp_outgoing = (long long)worker->back->num_udp_outgoing;
 
        /* get and reset validator rrset bogus number */
        s->svr.rrset_bogus = (long long)get_rrset_bogus(worker, reset);
@@ -424,6 +425,7 @@ void server_stats_add(struct ub_stats_info* total, struct ub_stats_info* a)
                total->svr.qclass_big += a->svr.qclass_big;
                total->svr.qtcp += a->svr.qtcp;
                total->svr.qtcp_outgoing += a->svr.qtcp_outgoing;
+               total->svr.qudp_outgoing += a->svr.qudp_outgoing;
                total->svr.qtls += a->svr.qtls;
                total->svr.qtls_resume += a->svr.qtls_resume;
                total->svr.qhttps += a->svr.qhttps;
index c41ab02f20edb802bd2ea53734be6c7844e0a301..27626ce938ca202aab95fb3530c01d26935891b1 100644 (file)
@@ -2217,6 +2217,7 @@ void worker_stats_clear(struct worker* worker)
        mesh_stats_clear(worker->env.mesh);
        worker->back->unwanted_replies = 0;
        worker->back->num_tcp_outgoing = 0;
+       worker->back->num_udp_outgoing = 0;
 }
 
 void worker_start_accept(void* arg)
index bad7ca4327ed81d35ee862f83bc3eced718605d3..60909ddedfb9ca78500a18e0d196ce1ee4a5cdbe 100644 (file)
@@ -3,6 +3,9 @@
 
 29 June 2022: George
        - Add debug option to the mini_tdir.sh test code.
+       - Fix #704: [FR] Statistics counter for number of outgoing UDP queries
+         sent; introduces 'num.query.udpout' to the 'unbound-control stats'
+         command.
 
 28 June 2022: George
        - Show the output of the exact .rpl run that failed with 'make test'.
index b15ab79d0da2e12d73c827689bfba7f121f7bc42..d3147be6f57e60309e9ac354768aa7fb14dedc89 100644 (file)
@@ -552,6 +552,10 @@ Number of queries that were made using TCP towards the Unbound server.
 Number of queries that the Unbound server made using TCP outgoing towards
 other servers.
 .TP
+.I num.query.udpout
+Number of queries that the Unbound server made using UDP outgoing towards
+other servers.
+.TP
 .I num.query.tls
 Number of queries that were made using TLS towards the Unbound server.
 These are also counted in num.query.tcp, because TLS uses TCP.
index ee8558759065d4fc8f723217281cde7d55a0cd03..c779d183e38561b02954a6bfe39d0c9b533c14cf 100644 (file)
@@ -725,6 +725,8 @@ struct ub_server_stats {
        long long qtcp;
        /** number of outgoing queries over TCP */
        long long qtcp_outgoing;
+       /** number of outgoing queries over UDP */
+       long long qudp_outgoing;
        /** number of queries over (DNS over) TLS */
        long long qtls;
        /** number of queries over (DNS over) HTTPS */
index ec37a4a80d714acfbe079ec6e691c85fae487831..edb8ca13af400c3fd59ba86d03c23d2b0b03f0a0 100644 (file)
@@ -1608,6 +1608,7 @@ outside_network_create(struct comm_base *base, size_t bufsize,
        outnet->tcp_reuse_timeout= tcp_reuse_timeout;
        outnet->tcp_auth_query_timeout = tcp_auth_query_timeout;
        outnet->num_tcp_outgoing = 0;
+       outnet->num_udp_outgoing = 0;
        outnet->infra = infra;
        outnet->rnd = rnd;
        outnet->sslctx = sslctx;
@@ -2142,6 +2143,7 @@ randomize_and_send_udp(struct pending* pend, sldns_buffer* packet, int timeout)
                portcomm_loweruse(outnet, pend->pc);
                return 0;
        }
+       outnet->num_udp_outgoing++;
 
        /* system calls to set timeout after sending UDP to make roundtrip
           smaller. */
index 4c5b96f8342411d76d06445564abd5062869cda5..c383b8f09e24a4843c8bc58e7c3e7d4bfa77d586 100644 (file)
@@ -113,6 +113,8 @@ struct outside_network {
        /** if we perform udp-connect, connect() for UDP socket to mitigate
         * ICMP side channel leakage */
        int udp_connect;
+       /** number of udp packets sent. */
+       size_t num_udp_outgoing;
 
        /** array of outgoing IP4 interfaces */
        struct port_if* ip4_ifs;
index 89543e45de7cfbbcf67d9e452be6ccb477a36742..d85eee3a4c1ba384cffe9924c82c9245c10bd0d6 100644 (file)
@@ -354,6 +354,7 @@ static void print_extended(struct ub_stats_info* s)
        /* transport */
        PR_UL("num.query.tcp", s->svr.qtcp);
        PR_UL("num.query.tcpout", s->svr.qtcp_outgoing);
+       PR_UL("num.query.udpout", s->svr.qudp_outgoing);
        PR_UL("num.query.tls", s->svr.qtls);
        PR_UL("num.query.tls_resume", s->svr.qtls_resume);
        PR_UL("num.query.ipv6", s->svr.qipv6);
index 5cec691f589da0c364691a8aca4c39c6eca55c72..dc45539206359575ca9b7f2fc8d3174172d21378 100644 (file)
@@ -1,5 +1,5 @@
 server:
-       verbosity: 2
+       verbosity: 5
        num-threads: 1
        interface: 127.0.0.1
        port: @PORT@
@@ -11,6 +11,9 @@ server:
        do-not-query-localhost: no
        extended-statistics: yes
        identity: "stat_values"
+       outbound-msg-retry: 0
+       root-key-sentinel: no
+       trust-anchor-signaling: no
 
        local-zone: local.zone static
        local-data: "www.local.zone A 192.0.2.1"
index 1cd19fa2b43e9ee62b0274312d6bdc9348caabf4..ef86a0471d60673ce4e21a1fd956a8b2d7bb2a98 100644 (file)
@@ -186,6 +186,7 @@ num.query.opcode.QUERY=1
 num.query.flags.RD=1
 num.query.flags.AD=1
 num.query.edns.present=1
+num.query.udpout=1
 msg.cache.count=1
 rrset.cache.count=1
 infra.cache.count=1
@@ -223,6 +224,7 @@ num.query.flags.AD=1
 num.query.flags.RD=1
 num.query.opcode.QUERY=1
 num.query.type.A=1
+num.query.udpout=1
 msg.cache.count=1
 rrset.cache.count=1
 infra.cache.count=1"
@@ -249,6 +251,7 @@ num.query.opcode.QUERY=1
 num.query.flags.RD=1
 num.query.flags.AD=1
 num.query.edns.present=1
+num.query.udpout=1
 msg.cache.count=2
 rrset.cache.count=2
 infra.cache.count=2
@@ -263,6 +266,7 @@ if grep "192.0.2.1" outfile; then
 else
        end 1
 fi
+sleep 1  # make sure the outgoing UDP (and the edns1xx0 retry) are accounted for.
 check_stats "\
 total.num.queries=1
 total.num.expired=1
@@ -274,6 +278,7 @@ num.query.flags.AD=1
 num.query.flags.RD=1
 num.query.opcode.QUERY=1
 num.query.type.A=1
+num.query.udpout=2
 total.num.cachemiss=1
 msg.cache.count=2
 rrset.cache.count=2
@@ -327,6 +332,7 @@ num.query.edns.present=1
 num.query.flags.RD=1
 num.query.opcode.QUERY=1
 num.query.type.A=1
+num.query.udpout=1
 total.num.queries=1
 total.num.recursivereplies=1
 msg.cache.count=3