diff -r 0282451f68fd sys/netinet/cc/cc_cubic.c --- a/sys/netinet/cc/cc_cubic.c Wed Jan 19 17:08:25 2011 +1100 +++ b/sys/netinet/cc/cc_cubic.c Thu Jan 20 15:35:23 2011 +1100 @@ -328,7 +328,8 @@ cubic_data->t_last_cong = ticks; /* Calculate the average RTT between congestion epochs. */ - if (cubic_data->epoch_ack_count > 0 && cubic_data->sum_rtt_ticks > 0) + if (cubic_data->epoch_ack_count > 0 && + cubic_data->sum_rtt_ticks >= cubic_data->epoch_ack_count) cubic_data->mean_rtt_ticks = (int)(cubic_data->sum_rtt_ticks / cubic_data->epoch_ack_count); else @@ -362,9 +363,21 @@ * XXXLAS: Should there be some hysteresis for minrtt? */ if ((t_srtt_ticks < cubic_data->min_rtt_ticks || - cubic_data->min_rtt_ticks == TCPTV_SRTTBASE)) + cubic_data->min_rtt_ticks == TCPTV_SRTTBASE)) { cubic_data->min_rtt_ticks = max(1, t_srtt_ticks); + /* + * If the connection is within its first congestion + * epoch, ensure we prime mean_rtt_ticks with a + * reasonable value until the epoch average RTT is + * calculated in cubic_post_recovery(). + */ + if (cubic_data->min_rtt_ticks > + cubic_data->mean_rtt_ticks) + cubic_data->mean_rtt_ticks = + cubic_data->min_rtt_ticks; + } + /* Sum samples for epoch average RTT calculation. */ cubic_data->sum_rtt_ticks += t_srtt_ticks; cubic_data->epoch_ack_count++;