diff options
author | George Kadianakis <desnacked@riseup.net> | 2021-06-28 14:11:46 +0300 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2021-06-28 14:11:46 +0300 |
commit | 2b97c1dd341f71e6237c97ee73e0f02b7dc6d805 (patch) | |
tree | 1d2b91fad2acb67ff92c04cf43ca2b2743cf6652 /src/feature/stats | |
parent | 45b5987115b526b1966985db77eb5783670ac536 (diff) | |
parent | d4fbfb54d41d9b93fbdfab48c59f0e688dd7f645 (diff) | |
download | tor-2b97c1dd341f71e6237c97ee73e0f02b7dc6d805.tar.gz tor-2b97c1dd341f71e6237c97ee73e0f02b7dc6d805.zip |
Merge remote-tracking branch 'tor-gitlab/mr/385'
Diffstat (limited to 'src/feature/stats')
-rw-r--r-- | src/feature/stats/rephist.c | 33 | ||||
-rw-r--r-- | src/feature/stats/rephist.h | 7 |
2 files changed, 31 insertions, 9 deletions
diff --git a/src/feature/stats/rephist.c b/src/feature/stats/rephist.c index 59d5313cc8..cb3ccdc91e 100644 --- a/src/feature/stats/rephist.c +++ b/src/feature/stats/rephist.c @@ -1998,12 +1998,18 @@ rep_hist_note_desc_served(const char * desc) /** Internal statistics to track how many requests of each type of * handshake we've received, and how many we've assigned to cpuworkers. * Useful for seeing trends in cpu load. + * + * They are reset at every heartbeat. * @{ */ STATIC int onion_handshakes_requested[MAX_ONION_HANDSHAKE_TYPE+1] = {0}; STATIC int onion_handshakes_assigned[MAX_ONION_HANDSHAKE_TYPE+1] = {0}; -STATIC uint64_t onion_handshakes_dropped[MAX_ONION_HANDSHAKE_TYPE+1] = {0}; /**@}*/ +/** Counters keeping the same stats as above but for the entire duration of the + * process (not reset). */ +static uint64_t stats_n_onionskin_assigned[MAX_ONION_HANDSHAKE_TYPE+1] = {0}; +static uint64_t stats_n_onionskin_dropped[MAX_ONION_HANDSHAKE_TYPE+1] = {0}; + /** A new onionskin (using the <b>type</b> handshake) has arrived. */ void rep_hist_note_circuit_handshake_requested(uint16_t type) @@ -2017,8 +2023,10 @@ rep_hist_note_circuit_handshake_requested(uint16_t type) void rep_hist_note_circuit_handshake_assigned(uint16_t type) { - if (type <= MAX_ONION_HANDSHAKE_TYPE) + if (type <= MAX_ONION_HANDSHAKE_TYPE) { onion_handshakes_assigned[type]++; + stats_n_onionskin_assigned[type]++; + } } /** We've just drop an onionskin (using the <b>type</b> handshake) due to being @@ -2026,8 +2034,9 @@ rep_hist_note_circuit_handshake_assigned(uint16_t type) void rep_hist_note_circuit_handshake_dropped(uint16_t type) { - if (type <= MAX_ONION_HANDSHAKE_TYPE) - onion_handshakes_dropped[type]++; + if (type <= MAX_ONION_HANDSHAKE_TYPE) { + stats_n_onionskin_dropped[type]++; + } } /** Get the circuit handshake value that is requested. */ @@ -2050,14 +2059,24 @@ rep_hist_get_circuit_handshake_assigned, (uint16_t type)) return onion_handshakes_assigned[type]; } -/** Get the circuit handshake value that is dropped. */ +/** Get the total number of circuit handshake value that is assigned. */ +MOCK_IMPL(uint64_t, +rep_hist_get_circuit_n_handshake_assigned, (uint16_t type)) +{ + if (BUG(type > MAX_ONION_HANDSHAKE_TYPE)) { + return 0; + } + return stats_n_onionskin_assigned[type]; +} + +/** Get the total number of circuit handshake value that is dropped. */ MOCK_IMPL(uint64_t, -rep_hist_get_circuit_handshake_dropped, (uint16_t type)) +rep_hist_get_circuit_n_handshake_dropped, (uint16_t type)) { if (BUG(type > MAX_ONION_HANDSHAKE_TYPE)) { return 0; } - return onion_handshakes_dropped[type]; + return stats_n_onionskin_dropped[type]; } /** Log our onionskin statistics since the last time we were called. */ diff --git a/src/feature/stats/rephist.h b/src/feature/stats/rephist.h index ca305dfd8d..7f414de4c8 100644 --- a/src/feature/stats/rephist.h +++ b/src/feature/stats/rephist.h @@ -63,7 +63,11 @@ void rep_hist_log_circuit_handshake_stats(time_t now); MOCK_DECL(int, rep_hist_get_circuit_handshake_requested, (uint16_t type)); MOCK_DECL(int, rep_hist_get_circuit_handshake_assigned, (uint16_t type)); -MOCK_DECL(uint64_t, rep_hist_get_circuit_handshake_dropped, (uint16_t type)); + +MOCK_DECL(uint64_t, rep_hist_get_circuit_n_handshake_assigned, + (uint16_t type)); +MOCK_DECL(uint64_t, rep_hist_get_circuit_n_handshake_dropped, + (uint16_t type)); void rep_hist_hs_stats_init(time_t now); void rep_hist_hs_stats_term(void); @@ -90,7 +94,6 @@ extern uint32_t rephist_total_num; #ifdef TOR_UNIT_TESTS extern int onion_handshakes_requested[MAX_ONION_HANDSHAKE_TYPE+1]; extern int onion_handshakes_assigned[MAX_ONION_HANDSHAKE_TYPE+1]; -extern uint64_t onion_handshakes_dropped[MAX_ONION_HANDSHAKE_TYPE+1]; #endif #ifdef REPHIST_PRIVATE |