]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
count how many times we *start* serving too
authorRoger Dingledine <arma@torproject.org>
Thu, 8 Jan 2026 05:50:12 +0000 (00:50 -0500)
committerRoger Dingledine <arma@torproject.org>
Fri, 9 Jan 2026 08:29:09 +0000 (03:29 -0500)
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.

changes/bug41192b [new file with mode: 0644]
src/feature/dircache/dircache.c
src/feature/stats/geoip_stats.c
src/feature/stats/geoip_stats.h
src/test/test_geoip.c

diff --git a/changes/bug41192b b/changes/bug41192b
new file mode 100644 (file)
index 0000000..a780808
--- /dev/null
@@ -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.
index 31a806eea1f43a9b77de565feb369600afcdf52f..aee047c1059112a44e849d203de16d22166c2410 100644 (file)
@@ -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;
index a0fe8597c18aeba313b8d973956584e1c0c09c6d..2741f4ec143a5b0e1a217589877aeb1c2772672f 100644 (file)
@@ -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],
index 3a455b2705a4620ecbee54a534205f7a467314df..d4121ec43ad66a709a785fb84c9219ede70b0fa0 100644 (file)
@@ -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. */
index b980f100968cc5868372c6c2fb2de4a27c8580bf..829de5dbacac64b7830399c4661c6eb95e92febc 100644 (file)
@@ -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);