summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorMike Perry <mikeperry-git@torproject.org>2021-09-28 15:17:34 +0000
committerDavid Goulet <dgoulet@torproject.org>2021-10-04 10:45:46 -0400
commite9038dc5f2fe6a62af1a32e1e4c51d8b894998e1 (patch)
tree0069a02e8a1f945a236731c8b9e3b12177831811 /src/core
parent6dae9903b1d5fe3c5df712eb99076a9adf9d5c8b (diff)
downloadtor-e9038dc5f2fe6a62af1a32e1e4c51d8b894998e1.tar.gz
tor-e9038dc5f2fe6a62af1a32e1e4c51d8b894998e1.zip
Add a max cwnd consensus parameter and clamp.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/or/congestion_control_common.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/core/or/congestion_control_common.c b/src/core/or/congestion_control_common.c
index 393b79459d..4449d9bfd5 100644
--- a/src/core/or/congestion_control_common.c
+++ b/src/core/or/congestion_control_common.c
@@ -33,6 +33,7 @@
#define SENDME_INC_DFLT (50)
#define CWND_MIN_DFLT (MAX(100, SENDME_INC_DFLT))
+#define CWND_MAX_DFLT (INT32_MAX)
#define CWND_INC_DFLT (50)
@@ -82,6 +83,14 @@ congestion_control_new_consensus_params(const networkstatus_t *ns)
OR_CONN_LOWWATER_DFLT,
OR_CONN_LOWWATER_MIN,
OR_CONN_LOWWATER_MAX);
+
+#define CWND_MAX_MIN 500
+#define CWND_MAX_MAX (INT32_MAX)
+ cwnd_max =
+ networkstatus_get_param(NULL, "cc_cwnd_max",
+ CWND_MAX_DFLT,
+ CWND_MAX_MIN,
+ CWND_MAX_MAX);
}
/**
@@ -963,20 +972,32 @@ congestion_control_dispatch_cc_alg(congestion_control_t *cc,
const circuit_t *circ,
const crypt_path_t *layer_hint)
{
+ int ret = -END_CIRC_REASON_INTERNAL;
switch (cc->cc_alg) {
case CC_ALG_WESTWOOD:
- return congestion_control_westwood_process_sendme(cc, circ, layer_hint);
+ ret = congestion_control_westwood_process_sendme(cc, circ, layer_hint);
+ break;
case CC_ALG_VEGAS:
- return congestion_control_vegas_process_sendme(cc, circ, layer_hint);
+ ret = congestion_control_vegas_process_sendme(cc, circ, layer_hint);
+ break;
case CC_ALG_NOLA:
- return congestion_control_nola_process_sendme(cc, circ, layer_hint);
+ ret = congestion_control_nola_process_sendme(cc, circ, layer_hint);
+ break;
case CC_ALG_SENDME:
default:
tor_assert(0);
}
- return -END_CIRC_REASON_INTERNAL;
+ if (cc->cwnd > cwnd_max) {
+ static ratelim_t cwnd_limit = RATELIM_INIT(60);
+ log_fn_ratelim(&cwnd_limit, LOG_NOTICE, LD_CIRC,
+ "Congestion control cwnd %"PRIu64" exceeds max %d, clamping.",
+ cc->cwnd, cwnd_max);
+ cc->cwnd = cwnd_max;
+ }
+
+ return ret;
}