tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

commit 802b1c39111db1398ef925fb422c69d624fce09d
parent 49a410d5c1568cde733502478defe751f9940a8a
Author: Roger Dingledine <arma@torproject.org>
Date:   Thu,  8 Jan 2026 00:50:12 -0500

count how many times we *start* serving too

Track how many times directory servers begin serving networkstatus
documents, so we can compare it to the number of times we finish
serving them.

Motivated by the fixes in bug 41192.

Diffstat:
Achanges/bug41192b | 4++++
Msrc/feature/dircache/dircache.c | 1+
Msrc/feature/stats/geoip_stats.c | 8+++++---
Msrc/feature/stats/geoip_stats.h | 7+++++--
Msrc/test/test_geoip.c | 13+++++++++----
5 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/changes/bug41192b b/changes/bug41192b @@ -0,0 +1,4 @@ + o Minor features (directory servers): + - Track how many times directory servers begin serving networkstatus + documents, so we can compare it to the number of times we finish + serving them. Motivated by the fixes in ticket 41192. diff --git a/src/feature/dircache/dircache.c b/src/feature/dircache/dircache.c @@ -969,6 +969,7 @@ handle_get_current_consensus(dir_connection_t *conn, } /* Success: we are going to try serving it. */ + geoip_note_ns_response(GEOIP_SERVED); conn->should_count_geoip_when_finished = 1; tor_addr_t addr; diff --git a/src/feature/stats/geoip_stats.c b/src/feature/stats/geoip_stats.c @@ -389,8 +389,8 @@ geoip_client_cache_total_allocation(void) * statuses? */ static uint32_t ns_v3_responses[GEOIP_NS_RESPONSE_NUM]; -/** Note that we've rejected a client's request for a v3 network status - * for reason <b>reason</b> at time <b>now</b>. */ +/** Note how we have handled a client's request for a v3 network status: + * with <b>reason</b> at time <b>now</b>. */ void geoip_note_ns_response(geoip_ns_response_t response) { @@ -996,7 +996,8 @@ geoip_format_dirreq_stats(time_t now) tor_asprintf(&result, "dirreq-stats-end %s (%d s)\n" "dirreq-v3-ips %s\n" "dirreq-v3-reqs %s\n" - "dirreq-v3-resp ok=%u,not-enough-sigs=%u,unavailable=%u," + "dirreq-v3-resp " + "served=%u,ok=%u,not-enough-sigs=%u,unavailable=%u," "not-found=%u,not-modified=%u,busy=%u\n" "dirreq-v3-direct-dl %s\n" "dirreq-v3-tunneled-dl %s\n", @@ -1004,6 +1005,7 @@ geoip_format_dirreq_stats(time_t now) (unsigned) (now - start_of_dirreq_stats_interval), v3_ips_string ? v3_ips_string : "", v3_reqs_string ? v3_reqs_string : "", + ns_v3_responses[GEOIP_SERVED], ns_v3_responses[GEOIP_SUCCESS], ns_v3_responses[GEOIP_REJECT_NOT_ENOUGH_SIGS], ns_v3_responses[GEOIP_REJECT_UNAVAILABLE], diff --git a/src/feature/stats/geoip_stats.h b/src/feature/stats/geoip_stats.h @@ -25,7 +25,7 @@ typedef enum { /** We've served a networkstatus consensus as a directory server. */ GEOIP_CLIENT_NETWORKSTATUS = 1, } geoip_client_action_t; -/** Indicates either a positive reply or a reason for rejectng a network +/** Indicates either a positive reply or a reason for rejecting a network * status request that will be included in geoip statistics. */ typedef enum { /** Request is answered successfully. */ @@ -41,8 +41,11 @@ typedef enum { GEOIP_REJECT_NOT_MODIFIED = 4, /** Directory is busy. */ GEOIP_REJECT_BUSY = 5, + /** We began to serve the request, and when we feel we have finished + * serving it we will note this with a GEOIP_SUCCESS call too. */ + GEOIP_SERVED = 6, } geoip_ns_response_t; -#define GEOIP_NS_RESPONSE_NUM 6 +#define GEOIP_NS_RESPONSE_NUM 7 /** Directory requests that we are measuring can be either direct or * tunneled. */ diff --git a/src/test/test_geoip.c b/src/test/test_geoip.c @@ -58,7 +58,8 @@ test_geoip(void *arg) "dirreq-stats-end 2010-08-12 13:27:30 (86400 s)\n" "dirreq-v3-ips ab=8\n" "dirreq-v3-reqs ab=8\n" - "dirreq-v3-resp ok=0,not-enough-sigs=0,unavailable=0,not-found=0," + "dirreq-v3-resp " + "served=0,ok=0,not-enough-sigs=0,unavailable=0,not-found=0," "not-modified=0,busy=0\n" "dirreq-v3-direct-dl complete=0,timeout=0,running=0\n" "dirreq-v3-tunneled-dl complete=0,timeout=0,running=0\n", @@ -66,7 +67,8 @@ test_geoip(void *arg) "dirreq-stats-end 2010-08-12 13:27:30 (86400 s)\n" "dirreq-v3-ips \n" "dirreq-v3-reqs \n" - "dirreq-v3-resp ok=0,not-enough-sigs=0,unavailable=0,not-found=0," + "dirreq-v3-resp " + "served=0,ok=0,not-enough-sigs=0,unavailable=0,not-found=0," "not-modified=0,busy=0\n" "dirreq-v3-direct-dl complete=0,timeout=0,running=0\n" "dirreq-v3-tunneled-dl complete=0,timeout=0,running=0\n", @@ -74,7 +76,8 @@ test_geoip(void *arg) "dirreq-stats-end 2010-08-12 13:27:30 (86400 s)\n" "dirreq-v3-ips \n" "dirreq-v3-reqs \n" - "dirreq-v3-resp ok=8,not-enough-sigs=0,unavailable=0,not-found=0," + "dirreq-v3-resp " + "served=8,ok=8,not-enough-sigs=0,unavailable=0,not-found=0," "not-modified=0,busy=0\n" "dirreq-v3-direct-dl complete=0,timeout=0,running=0\n" "dirreq-v3-tunneled-dl complete=0,timeout=0,running=0\n", @@ -82,7 +85,8 @@ test_geoip(void *arg) "dirreq-stats-end 2010-08-12 13:27:30 (86400 s)\n" "dirreq-v3-ips \n" "dirreq-v3-reqs \n" - "dirreq-v3-resp ok=8,not-enough-sigs=0,unavailable=0,not-found=0," + "dirreq-v3-resp " + "served=8,ok=8,not-enough-sigs=0,unavailable=0,not-found=0," "not-modified=0,busy=0\n" "dirreq-v3-direct-dl complete=0,timeout=0,running=0\n" "dirreq-v3-tunneled-dl complete=0,timeout=0,running=4\n", @@ -230,6 +234,7 @@ test_geoip(void *arg) /* Note a successful network status response and make sure that it * appears in the history string. */ + geoip_note_ns_response(GEOIP_SERVED); geoip_note_ns_response(GEOIP_SUCCESS); s = geoip_format_dirreq_stats(now + 86400); tt_str_op(dirreq_stats_3,OP_EQ, s);