commit 87e820a0c54e57fc282bb5d2472ef775504be8e0
parent 619dd35321c13684d5496b660a3404d2d3fe2827
Author: David Goulet <dgoulet@torproject.org>
Date: Thu, 3 Nov 2022 09:37:38 -0400
metrics: Add stats for num circ reaching max cell outq
Part of #40708
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat:
3 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/core/or/relay.c b/src/core/or/relay.c
@@ -128,6 +128,7 @@ uint64_t stats_n_relay_cells_delivered = 0;
/** Stats: how many circuits have we closed due to the cell queue limit being
* reached (see append_cell_to_circuit_queue()) */
uint64_t stats_n_circ_max_cell_reached = 0;
+uint64_t stats_n_circ_max_cell_outq_reached = 0;
/**
* Update channel usage state based on the type of relay cell and
@@ -3252,6 +3253,7 @@ append_cell_to_circuit_queue(circuit_t *circ, channel_t *chan,
/* This DoS defense only applies at the Guard as in the p_chan is likely
* a client IP attacking the network. */
if (exitward && CIRCUIT_IS_ORCIRC(circ)) {
+ stats_n_circ_max_cell_outq_reached++;
dos_note_circ_max_outq(CONST_TO_OR_CIRCUIT(circ)->p_chan);
}
diff --git a/src/core/or/relay.h b/src/core/or/relay.h
@@ -15,6 +15,7 @@
extern uint64_t stats_n_relay_cells_relayed;
extern uint64_t stats_n_relay_cells_delivered;
extern uint64_t stats_n_circ_max_cell_reached;
+extern uint64_t stats_n_circ_max_cell_outq_reached;
const char *relay_command_to_string(uint8_t command);
diff --git a/src/feature/relay/relay_metrics.c b/src/feature/relay/relay_metrics.c
@@ -317,6 +317,12 @@ fill_dos_values(void)
sentry = metrics_store_add(the_store, rentry->type, rentry->name,
rentry->help);
metrics_store_entry_add_label(sentry,
+ metrics_format_label("type", "circuit_killed_max_cell_outq"));
+ metrics_store_entry_update(sentry, stats_n_circ_max_cell_outq_reached);
+
+ sentry = metrics_store_add(the_store, rentry->type, rentry->name,
+ rentry->help);
+ metrics_store_entry_add_label(sentry,
metrics_format_label("type", "marked_address"));
metrics_store_entry_update(sentry, dos_get_num_cc_marked_addr());