summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Perry <mikeperry-git@torproject.org>2022-12-15 22:03:26 +0000
committerDavid Goulet <dgoulet@torproject.org>2023-01-10 11:56:21 -0500
commit5ddd3a9069081c9a96d9beb1b0ef99f27636eef5 (patch)
tree11043ba8a6940018fca637ffc68ef46d44f79265
parenta9a27ffa3a2b134f7586d1259e2c077b0b6cb4f7 (diff)
downloadtor-5ddd3a9069081c9a96d9beb1b0ef99f27636eef5.tar.gz
tor-5ddd3a9069081c9a96d9beb1b0ef99f27636eef5.zip
Safety fixes to RFC3742
-rw-r--r--src/core/or/congestion_control_vegas.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/core/or/congestion_control_vegas.c b/src/core/or/congestion_control_vegas.c
index ae945e7e00..71ffde3061 100644
--- a/src/core/or/congestion_control_vegas.c
+++ b/src/core/or/congestion_control_vegas.c
@@ -283,8 +283,11 @@ rfc3742_ss_inc(const congestion_control_t *cc)
// => K = 2*cwnd/max_ssthresh
// cwnd += int(MSS/K);
// => cwnd += MSS*max_ssthresh/(2*cwnd)
- return ((uint64_t)cc->sendme_inc*cc->vegas_params.ss_cwnd_cap + cc->cwnd)/
- (2*cc->cwnd);
+ // Return at least 1 for inc.
+ return MAX(
+ ((uint64_t)cc->sendme_inc*cc->vegas_params.ss_cwnd_cap + cc->cwnd)/
+ (2*cc->cwnd),
+ 1);
}
}
@@ -447,8 +450,10 @@ congestion_control_vegas_process_sendme(congestion_control_t *cc,
cc->cwnd += inc;
// Check if inc is less than what we would do in steady-state
- // avoidance
- if (inc*SENDME_PER_CWND(cc) <= CWND_INC(cc)) {
+ // avoidance. Note that this is likely never to happen
+ // in practice, but we keep this block and the metrics to make
+ // sure.
+ if (inc*SENDME_PER_CWND(cc) <= CWND_INC(cc)*cc->cwnd_inc_rate) {
congestion_control_vegas_exit_slow_start(circ, cc);
cc_stats_vegas_below_ss_inc_floor++;