Skip to content

Commit

Permalink
prevent cwnd overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
AloysAugustin committed Apr 3, 2020
1 parent d8b9fbe commit 7217e1b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/cc-reno.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ void quicly_cc_on_acked(quicly_cc_t *cc, uint32_t bytes, uint64_t largest_acked,

// slow start
if (cc->cwnd < cc->ssthresh) {
cc->cwnd += bytes;
if (cc->cwnd > UINT32_MAX - bytes)
cc->cwnd = UINT32_MAX;
else
cc->cwnd += bytes;
return;
}
// congestion avoidance
Expand All @@ -53,7 +56,11 @@ void quicly_cc_on_acked(quicly_cc_t *cc, uint32_t bytes, uint64_t largest_acked,
// increase cwnd by 1 MSS per cwnd acked
uint32_t count = cc->stash / cc->cwnd;
cc->stash -= count * cc->cwnd;
cc->cwnd += count * QUICLY_MAX_PACKET_SIZE;
uint32_t increase = count * QUICLY_MAX_PACKET_SIZE;
if (cc->cwnd < UINT32_MAX - increase)
cc->cwnd += increase;
else
cc->cwnd = UINT32_MAX;
}

void quicly_cc_on_lost(quicly_cc_t *cc, uint32_t bytes, uint64_t lost_pn, uint64_t next_pn)
Expand Down

0 comments on commit 7217e1b

Please sign in to comment.