diff --git a/sys/netinet/cc/cc_cubic.c b/sys/netinet/cc/cc_cubic.c --- a/sys/netinet/cc/cc_cubic.c +++ b/sys/netinet/cc/cc_cubic.c @@ -88,6 +88,7 @@ static void cubic_newround(struct cc_var *ccv, uint32_t round_cnt); static void cubic_rttsample(struct cc_var *ccv, uint32_t usec_rtt, uint32_t rxtcnt, uint32_t fas); +static unsigned long cubic_compute_pipe(struct cc_var *ccv); struct cc_algo cubic_cc_algo = { .name = "cubic", @@ -424,6 +425,7 @@ static void cubic_cong_signal(struct cc_var *ccv, uint32_t type) { + unsigned long pipe; struct cubic *cubic_data; u_int mss; @@ -456,10 +458,12 @@ cubic_log_hystart_event(ccv, cubic_data, 9, CCV(ccv, snd_ssthresh)); } if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) { + pipe = cubic_compute_pipe(ccv); cubic_ssthresh_update(ccv, mss); + CCV(ccv, snd_cwnd) = ulmax((pipe * CUBIC_BETA) >> CUBIC_SHIFT, + CCV(ccv, snd_ssthresh)); cubic_data->num_cong_events++; cubic_data->t_epoch = 0; /* This will recalculate K */ - CCV(ccv, snd_cwnd) = CCV(ccv, snd_ssthresh); ENTER_CONGRECOVERY(CCV(ccv, t_flags)); } break; @@ -529,7 +533,7 @@ cubic_post_recovery(struct cc_var *ccv) { struct cubic *cubic_data; - int pipe; + unsigned long pipe; cubic_data = ccv->cc_data; pipe = 0; @@ -542,10 +546,7 @@ * * XXXLAS: Find a way to do this without needing curack */ - if (V_tcp_do_newsack) - pipe = tcp_compute_pipe(ccv->ccvc.tcp); - else - pipe = CCV(ccv, snd_max) - ccv->curack; + pipe = cubic_compute_pipe(ccv); if (pipe < CCV(ccv, snd_ssthresh)) /* @@ -627,11 +628,16 @@ struct cubic *cubic_data; uint32_t ssthresh; uint32_t cwnd; + unsigned long pipe; cubic_data = ccv->cc_data; cwnd = CCV(ccv, snd_cwnd); + cubic_data->cwnd_prior = cwnd; - /* Fast convergence heuristic. */ + /* + * draft-ietf-tcpm-rfc8312bis-15 Section 4.7: + * Fast convergence heuristic + */ if (cwnd < cubic_data->W_max) { cwnd = ((uint64_t)cwnd * CUBIC_FC_FACTOR) >> CUBIC_SHIFT; } @@ -639,19 +645,11 @@ cubic_data->W_max = cwnd; /* - * On the first congestion event, set ssthresh to cwnd * 0.5 - * and reduce W_max to cwnd * beta. This aligns the cubic concave - * region appropriately. On subsequent congestion events, set - * ssthresh to cwnd * beta. + * draft-ietf-tcpm-rfc8312bis-15 Section 4.6: + * Calculate the ssthresh using the outstanding unacknowledged data */ - if ((cubic_data->flags & CUBICFLAG_CONG_EVENT) == 0) { - ssthresh = cwnd >> 1; - cubic_data->W_max = ((uint64_t)cwnd * - CUBIC_BETA) >> CUBIC_SHIFT; - } else { - ssthresh = ((uint64_t)cwnd * - CUBIC_BETA) >> CUBIC_SHIFT; - } + pipe = cubic_compute_pipe(ccv); + ssthresh = (pipe * CUBIC_BETA) >> CUBIC_SHIFT; CCV(ccv, snd_ssthresh) = max(ssthresh, 2 * maxseg); } @@ -730,5 +728,17 @@ cubic_log_hystart_event(ccv, cubicd, 4, round_cnt); } +static unsigned long +cubic_compute_pipe(struct cc_var *ccv) +{ + unsigned long pipe; + + if (V_tcp_do_newsack) + pipe = tcp_compute_pipe(ccv->ccvc.tcp); + else + pipe = CCV(ccv, snd_max) - ccv->curack; + return pipe; +} + DECLARE_CC_MODULE(cubic, &cubic_cc_algo); MODULE_VERSION(cubic, 2);