- tp->t_ccstate->cub_tcp_bytes_acked +=
- BYTES_ACKED(th, tp);
- if (tp->t_ccstate->cub_tcp_bytes_acked >=
- tp->t_ccstate->cub_tcp_win) {
- tp->t_ccstate->cub_tcp_bytes_acked -=
- tp->t_ccstate->cub_tcp_win;
- tp->t_ccstate->cub_tcp_win += tp->t_maxseg;
+ tp->t_ccstate->cub_tcp_bytes_acked += BYTES_ACKED(th, tp);
+
+ if (tcp_cubic_minor_fixes) {
+ /*
+ * Increase by ai_factor * MSS, once per RTT. Counting bytes_acked
+ * against the snd_cwnd represents exactly one RTT at full rate.
+ */
+ while (tp->t_ccstate->cub_tcp_bytes_acked >= tp->snd_cwnd) {
+ /* Enough bytes have been ACK'd for TCP to do AIMD*/
+ tp->t_ccstate->cub_tcp_bytes_acked -= tp->snd_cwnd;
+
+ if (tp->snd_cwnd >= tp->t_ccstate->cub_last_max || !tcp_cubic_rfc_compliant) {
+ tp->t_ccstate->cub_tcp_win += tp->t_maxseg;
+ } else {
+ /* Increase-rate from Section 4.2, RFC 8312 */
+ float ai_factor = (float)3 * (1 - tcp_cubic_beta) / (1 + tcp_cubic_beta);
+
+ tp->t_ccstate->cub_tcp_win += (uint32_t)(tp->t_maxseg * ai_factor);
+ }
+ }
+ } else {
+ if (tp->t_ccstate->cub_tcp_bytes_acked >= tp->t_ccstate->cub_tcp_win) {
+ tp->t_ccstate->cub_tcp_bytes_acked -= tp->t_ccstate->cub_tcp_win;
+ tp->t_ccstate->cub_tcp_win += tp->t_maxseg;
+ }