summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Perry <mikeperry-git@torproject.org>2022-05-11 18:02:54 +0000
committerMike Perry <mikeperry-git@torproject.org>2023-06-23 15:08:57 +0000
commit53748705f7e70128e2b472e8d598c941ef2adafd (patch)
tree1119d5d8b76fb6ff5648b0a7ead85bd9de03f400
parent155343708d8f8beda11de3baca65ead9d51b711f (diff)
downloadtor-53748705f7e70128e2b472e8d598c941ef2adafd.tar.gz
tor-53748705f7e70128e2b472e8d598c941ef2adafd.zip
Export variables and functions for CC unit tests.
-rw-r--r--src/core/or/congestion_control_common.c24
-rw-r--r--src/core/or/congestion_control_common.h10
-rw-r--r--src/test/test_hs_client.c1
-rw-r--r--src/test/test_hs_descriptor.c2
-rw-r--r--src/test/test_ntor_v3.c2
5 files changed, 27 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);
diff --git a/src/test/test_hs_client.c b/src/test/test_hs_client.c
index be74da1198..a02dca1b60 100644
--- a/src/test/test_hs_client.c
+++ b/src/test/test_hs_client.c
@@ -55,6 +55,7 @@
#include "core/or/origin_circuit_st.h"
#include "core/or/socks_request_st.h"
+#include "core/or/congestion_control_st.h"
#include "core/or/congestion_control_common.h"
static int
diff --git a/src/test/test_hs_descriptor.c b/src/test/test_hs_descriptor.c
index 3b715863ad..89815f4858 100644
--- a/src/test/test_hs_descriptor.c
+++ b/src/test/test_hs_descriptor.c
@@ -25,6 +25,8 @@
#include "test/log_test_helpers.h"
#include "test/rng_test_helpers.h"
+#define TOR_CONGESTION_CONTROL_PRIVATE
+#include "core/or/congestion_control_st.h"
#include "core/or/congestion_control_common.h"
#ifdef HAVE_CFLAG_WOVERLENGTH_STRINGS
diff --git a/src/test/test_ntor_v3.c b/src/test/test_ntor_v3.c
index c4a7d04deb..0d51c684a0 100644
--- a/src/test/test_ntor_v3.c
+++ b/src/test/test_ntor_v3.c
@@ -13,7 +13,9 @@
#include "core/crypto/onion_crypto.h"
#include "core/or/extend_info_st.h"
#include "core/or/crypt_path_st.h"
+#define TOR_CONGESTION_CONTROL_PRIVATE
#define TOR_CONGESTION_CONTROL_COMMON_PRIVATE
+#include "core/or/congestion_control_st.h"
#include "core/or/congestion_control_common.h"
#include "app/config/config.h"