summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2020-10-20 15:05:06 -0400
committerDavid Goulet <dgoulet@torproject.org>2020-10-27 10:43:42 -0400
commit97731196c4141093f96b632ce38f440fec8db831 (patch)
tree83ef95e306fbbdf1070e08579b2775140407c5e6
parentc081bee38a428dda2bd9ee043f7cbab3cbd77393 (diff)
downloadtor-97731196c4141093f96b632ce38f440fec8db831.tar.gz
tor-97731196c4141093f96b632ce38f440fec8db831.zip
hs: Collect introduction circuit metrics
Tracks the total number of established introduction circuit. Related to #40063 Signed-off-by: David Goulet <dgoulet@torproject.org>
-rw-r--r--src/feature/hs/hs_metrics.h10
-rw-r--r--src/feature/hs/hs_metrics_entry.c6
-rw-r--r--src/feature/hs/hs_metrics_entry.h2
-rw-r--r--src/feature/hs/hs_service.c9
4 files changed, 27 insertions, 0 deletions
diff --git a/src/feature/hs/hs_metrics.h b/src/feature/hs/hs_metrics.h
index 21af42e01c..506831b3fd 100644
--- a/src/feature/hs/hs_metrics.h
+++ b/src/feature/hs/hs_metrics.h
@@ -57,4 +57,14 @@ void hs_metrics_update_by_service(const hs_metrics_key_t key,
#define hs_metrics_new_rdv(i) \
hs_metrics_update_by_ident(HS_METRICS_NUM_RDV, (i), 0, 1)
+/** New introduction circuit has been established. This is called when the
+ * INTRO_ESTABLISHED has been received by the service. */
+#define hs_metrics_new_established_intro(s) \
+ hs_metrics_update_by_service(HS_METRICS_NUM_ESTABLISHED_INTRO, (s), 0, 1)
+
+/** Established introduction circuit closes. This is called when
+ * INTRO_ESTABLISHED circuit is marked for close. */
+#define hs_metrics_close_established_intro(i) \
+ hs_metrics_update_by_ident(HS_METRICS_NUM_ESTABLISHED_INTRO, (i), 0, 1)
+
#endif /* !defined(TOR_FEATURE_HS_HS_METRICS_H) */
diff --git a/src/feature/hs/hs_metrics_entry.c b/src/feature/hs/hs_metrics_entry.c
index 78f5253327..e4da0921aa 100644
--- a/src/feature/hs/hs_metrics_entry.c
+++ b/src/feature/hs/hs_metrics_entry.c
@@ -53,6 +53,12 @@ const hs_metrics_entry_t base_metrics[] =
.name = "hs_rdv_num_total",
.help = "Total number of rendezvous circuit created",
},
+ {
+ .key = HS_METRICS_NUM_ESTABLISHED_INTRO,
+ .type = METRICS_TYPE_GAUGE,
+ .name = "hs_intro_established_count",
+ .help = "Total number of established introduction circuit",
+ },
};
/** Size of base_metrics array that is number of entries. */
diff --git a/src/feature/hs/hs_metrics_entry.h b/src/feature/hs/hs_metrics_entry.h
index 924696df4f..f68c1ab8e9 100644
--- a/src/feature/hs/hs_metrics_entry.h
+++ b/src/feature/hs/hs_metrics_entry.h
@@ -25,6 +25,8 @@ typedef enum {
HS_METRICS_NUM_ESTABLISHED_RDV = 3,
/** Number of rendezsvous circuits created. */
HS_METRICS_NUM_RDV = 4,
+ /** Number of established introducton points. */
+ HS_METRICS_NUM_ESTABLISHED_INTRO = 5,
} hs_metrics_key_t;
/** The metadata of an HS metrics. */
diff --git a/src/feature/hs/hs_service.c b/src/feature/hs/hs_service.c
index 6cf5257eb9..3d0e5dc1db 100644
--- a/src/feature/hs/hs_service.c
+++ b/src/feature/hs/hs_service.c
@@ -3451,6 +3451,9 @@ service_handle_intro_established(origin_circuit_t *circ,
goto err;
}
+ /* Update metrics. */
+ hs_metrics_new_established_intro(service);
+
log_info(LD_REND, "Successfully received an INTRO_ESTABLISHED cell "
"on circuit %u for service %s",
TO_CIRCUIT(circ)->n_circ_id,
@@ -3597,6 +3600,12 @@ hs_service_circuit_cleanup_on_close(const circuit_t *circ)
tor_assert(CIRCUIT_IS_ORIGIN(circ));
switch (circ->purpose) {
+ case CIRCUIT_PURPOSE_S_INTRO:
+ /* About to close an established introduction circuit. Update the metrics
+ * to reflect how many we have at the moment. */
+ hs_metrics_close_established_intro(
+ &CONST_TO_ORIGIN_CIRCUIT(circ)->hs_ident->identity_pk);
+ break;
case CIRCUIT_PURPOSE_S_REND_JOINED:
/* About to close an established rendezvous circuit. Update the metrics to
* reflect how many we have at the moment. */