diff options
author | David Goulet <dgoulet@torproject.org> | 2021-05-06 11:17:26 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2021-05-12 11:58:25 -0400 |
commit | 22861c2f4083e7e29a732a4907c2dcadd6a6a4db (patch) | |
tree | 09b188e0d1e4b97322f9601fc2dee18fab7ca0b2 /src/feature/stats | |
parent | c6f41d6038752d847b2c60cf6dfd7fbcb163c345 (diff) | |
download | tor-22861c2f4083e7e29a732a4907c2dcadd6a6a4db.tar.gz tor-22861c2f4083e7e29a732a4907c2dcadd6a6a4db.zip |
relay: Add TCP port exhaustion metrics
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/feature/stats')
-rw-r--r-- | src/feature/stats/rephist.c | 19 | ||||
-rw-r--r-- | src/feature/stats/rephist.h | 3 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/feature/stats/rephist.c b/src/feature/stats/rephist.c index 7481b2f0a8..01fa644b9e 100644 --- a/src/feature/stats/rephist.c +++ b/src/feature/stats/rephist.c @@ -214,6 +214,9 @@ static overload_stats_t overload_stats; static uint64_t stats_n_read_limit_reached = 0; static uint64_t stats_n_write_limit_reached = 0; +/** Total number of times we've reached TCP port exhaustion. */ +static uint64_t stats_n_tcp_exhaustion = 0; + /***** DNS statistics *****/ /** Represents the statistics of DNS queries seen if it is an Exit. */ @@ -512,6 +515,22 @@ rep_hist_note_overload(overload_type_t overload) } } +/** Note down that we've reached a TCP port exhaustion. This triggers an + * overload general event. */ +void +rep_hist_note_tcp_exhaustion(void) +{ + stats_n_tcp_exhaustion++; + rep_hist_note_overload(OVERLOAD_GENERAL); +} + +/** Return the total number of TCP exhaustion times we've reached. */ +uint64_t +rep_hist_get_n_tcp_exhaustion(void) +{ + return stats_n_tcp_exhaustion; +} + /** Return the or_history_t for the OR with identity digest <b>id</b>, * creating it if necessary. */ static or_history_t * diff --git a/src/feature/stats/rephist.h b/src/feature/stats/rephist.h index 9d2e457b4b..ca305dfd8d 100644 --- a/src/feature/stats/rephist.h +++ b/src/feature/stats/rephist.h @@ -167,6 +167,9 @@ void rep_hist_note_overload(overload_type_t overload); char *rep_hist_get_overload_general_line(void); char *rep_hist_get_overload_stats_lines(void); +void rep_hist_note_tcp_exhaustion(void); +uint64_t rep_hist_get_n_tcp_exhaustion(void); + uint64_t rep_hist_get_n_read_limit_reached(void); uint64_t rep_hist_get_n_write_limit_reached(void); |