diff options
author | Mike Perry <mikeperry-git@torproject.org> | 2022-05-11 18:02:54 +0000 |
---|---|---|
committer | Mike Perry <mikeperry-git@torproject.org> | 2023-06-23 15:08:57 +0000 |
commit | 53748705f7e70128e2b472e8d598c941ef2adafd (patch) | |
tree | 1119d5d8b76fb6ff5648b0a7ead85bd9de03f400 /src/core | |
parent | 155343708d8f8beda11de3baca65ead9d51b711f (diff) | |
download | tor-53748705f7e70128e2b472e8d598c941ef2adafd.tar.gz tor-53748705f7e70128e2b472e8d598c941ef2adafd.zip |
Export variables and functions for CC unit tests.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/or/congestion_control_common.c | 24 | ||||
-rw-r--r-- | src/core/or/congestion_control_common.h | 10 |
2 files changed, 22 insertions, 12 deletions
diff --git a/src/core/or/congestion_control_common.c b/src/core/or/congestion_control_common.c index 6ef29ba637..f747987957 100644 --- a/src/core/or/congestion_control_common.c +++ b/src/core/or/congestion_control_common.c @@ -7,6 +7,7 @@ */ #define TOR_CONGESTION_CONTROL_COMMON_PRIVATE +#define TOR_CONGESTION_CONTROL_PRIVATE #include "core/or/or.h" @@ -18,6 +19,7 @@ #include "core/or/channel.h" #include "core/mainloop/connection.h" #include "core/or/sendme.h" +#include "core/or/congestion_control_st.h" #include "core/or/congestion_control_common.h" #include "core/or/congestion_control_vegas.h" #include "core/or/congestion_control_nola.h" @@ -84,8 +86,6 @@ #define CELL_QUEUE_LOW_DFLT (10) #define CELL_QUEUE_HIGH_DFLT (256) -static uint64_t congestion_control_update_circuit_rtt(congestion_control_t *, - uint64_t); static bool congestion_control_update_circuit_bdp(congestion_control_t *, const circuit_t *, const crypt_path_t *, @@ -103,33 +103,33 @@ int32_t cell_queue_low = CELL_QUEUE_LOW_DFLT; uint32_t or_conn_highwater = OR_CONN_HIGHWATER_DFLT; uint32_t or_conn_lowwater = OR_CONN_LOWWATER_DFLT; uint8_t cc_sendme_inc = SENDME_INC_DFLT; -static cc_alg_t cc_alg = CC_ALG_DFLT; +STATIC cc_alg_t cc_alg = CC_ALG_DFLT; /** * Number of cwnd worth of sendme acks to smooth RTT and BDP with, * using N_EWMA */ -static uint8_t n_ewma_cwnd_pct; +static uint8_t n_ewma_cwnd_pct = N_EWMA_CWND_PCT_DFLT; /** * Maximum number N for the N-count EWMA averaging of RTT and BDP. */ -static uint8_t n_ewma_max; +static uint8_t n_ewma_max = N_EWMA_MAX_DFLT; /** * Maximum number N for the N-count EWMA averaging of RTT in Slow Start. */ -static uint8_t n_ewma_ss; +static uint8_t n_ewma_ss = N_EWMA_SS_DFLT; /** * Minimum number of sendmes before we begin BDP estimates */ -static uint8_t bwe_sendme_min; +static uint8_t bwe_sendme_min = BWE_SENDME_MIN_DFLT; /** * Percentage of the current RTT to use when resetting the minimum RTT * for a circuit. (RTT is reset when the cwnd hits cwnd_min). */ -static uint8_t rtt_reset_pct; +static uint8_t rtt_reset_pct = RTT_RESET_PCT_DFLT; /** Metric to count the number of congestion control circuits **/ uint64_t cc_stats_circs_created = 0; @@ -461,7 +461,7 @@ congestion_control_free_(congestion_control_t *cc) /** * Enqueue a u64 timestamp to the end of a queue of timestamps. */ -static inline void +STATIC inline void enqueue_timestamp(smartlist_t *timestamps_u64, uint64_t timestamp_usec) { uint64_t *timestamp_ptr = tor_malloc(sizeof(uint64_t)); @@ -788,7 +788,7 @@ time_delta_should_use_heuristics(const congestion_control_t *cc) return false; } -static bool is_monotime_clock_broken = false; +STATIC bool is_monotime_clock_broken = false; /** * Returns true if the monotime delta is 0, or is significantly @@ -799,7 +799,7 @@ static bool is_monotime_clock_broken = false; * so we can also provide a is_monotime_clock_reliable() function, * used by flow control rate timing. */ -static bool +STATIC bool time_delta_stalled_or_jumped(const congestion_control_t *cc, uint64_t old_delta, uint64_t new_delta) { @@ -881,7 +881,7 @@ is_monotime_clock_reliable(void) * Returns the current circuit RTT in usecs, or 0 if it could not be * measured (due to clock jump, stall, etc). */ -static uint64_t +STATIC uint64_t congestion_control_update_circuit_rtt(congestion_control_t *cc, uint64_t now_usec) { diff --git a/src/core/or/congestion_control_common.h b/src/core/or/congestion_control_common.h index 767e4c52e6..92c78c5ebd 100644 --- a/src/core/or/congestion_control_common.h +++ b/src/core/or/congestion_control_common.h @@ -175,12 +175,22 @@ percent_max_mix(uint64_t a, uint64_t b, uint8_t pct_max) /* Private section starts. */ #ifdef TOR_CONGESTION_CONTROL_COMMON_PRIVATE +STATIC uint64_t congestion_control_update_circuit_rtt(congestion_control_t *, + uint64_t); + +STATIC bool time_delta_stalled_or_jumped(const congestion_control_t *cc, + uint64_t old_delta, uint64_t new_delta); + +STATIC void enqueue_timestamp(smartlist_t *timestamps_u64, + uint64_t timestamp_usec); /* * Unit tests declaractions. */ #ifdef TOR_UNIT_TESTS +extern bool is_monotime_clock_broken; +extern cc_alg_t cc_alg; void congestion_control_set_cc_enabled(void); void congestion_control_set_cc_disabled(void); |