From 592d0371ddf42dcbd3c59faec25d4de33ebb2292 Mon Sep 17 00:00:00 2001 From: tuexen Date: Fri, 10 Feb 2012 20:09:23 +0000 Subject: [PATCH] MFC r219014: * Fix several bugs where the scaled versions of srtt and rttvar where used incorrectly. * Use appropriate variable names for RTO instead of RTT. git-svn-id: svn://svn.freebsd.org/base/stable/8@231422 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/netinet/sctp_cc_functions.c | 12 ++++++------ sys/netinet/sctp_timer.c | 30 +++++++++++++++--------------- sys/netinet/sctp_usrreq.c | 4 ++-- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/sys/netinet/sctp_cc_functions.c b/sys/netinet/sctp_cc_functions.c index ffa4c792d..ca191e47a 100644 --- a/sys/netinet/sctp_cc_functions.c +++ b/sys/netinet/sctp_cc_functions.c @@ -428,7 +428,7 @@ skip_cwnd_update: */ if (net->net_ack2) { /* restore any doubled timers */ - net->RTO = ((net->lastsa >> 2) + net->lastsv) >> 1; + net->RTO = (net->lastsa >> SCTP_RTT_SHIFT) + net->lastsv; if (net->RTO < stcb->asoc.minrto) { net->RTO = stcb->asoc.minrto; } @@ -518,8 +518,8 @@ sctp_cwnd_update_after_packet_dropped(struct sctp_tcb *stcb, unsigned int incr; int old_cwnd = net->cwnd; - /* need real RTT for this calc */ - rtt = ((net->lastsa >> 2) + net->lastsv) >> 1; + /* need real RTT in msd for this calc */ + rtt = net->rtt / 1000; /* get bottle neck bw */ *bottle_bw = ntohl(cp->bottle_bw); /* and whats on queue */ @@ -1079,7 +1079,7 @@ skip_cwnd_update: */ if (net->net_ack2) { /* restore any doubled timers */ - net->RTO = ((net->lastsa >> 2) + net->lastsv) >> 1; + net->RTO = (net->lastsa >> SCTP_RTT_SHIFT) + net->lastsv; if (net->RTO < stcb->asoc.minrto) { net->RTO = stcb->asoc.minrto; } @@ -1146,7 +1146,7 @@ htcp_cwnd_undo(struct sctp_tcb *stcb, struct sctp_nets *net) static inline void measure_rtt(struct sctp_tcb *stcb, struct sctp_nets *net) { - uint32_t srtt = net->lastsa >> 3; + uint32_t srtt = net->lastsa >> SCTP_RTT_SHIFT; /* keep track of minimum RTT seen so far, minRTT is zero at first */ if (net->htcp_ca.minRTT > srtt || !net->htcp_ca.minRTT) @@ -1532,7 +1532,7 @@ skip_cwnd_update: */ if (net->net_ack2) { /* restore any doubled timers */ - net->RTO = ((net->lastsa >> 2) + net->lastsv) >> 1; + net->RTO = (net->lastsa >> SCTP_RTT_SHIFT) + net->lastsv; if (net->RTO < stcb->asoc.minrto) { net->RTO = stcb->asoc.minrto; } diff --git a/sys/netinet/sctp_timer.c b/sys/netinet/sctp_timer.c index c0a76e632..50f1f7423 100644 --- a/sys/netinet/sctp_timer.c +++ b/sys/netinet/sctp_timer.c @@ -61,24 +61,24 @@ sctp_early_fr_timer(struct sctp_inpcb *inp, { struct sctp_tmit_chunk *chk, *pchk; struct timeval now, min_wait, tv; - unsigned int cur_rtt, cnt = 0, cnt_resend = 0; + unsigned int cur_rto, cnt = 0, cnt_resend = 0; /* an early FR is occuring. */ (void)SCTP_GETTIME_TIMEVAL(&now); /* get cur rto in micro-seconds */ if (net->lastsa == 0) { /* Hmm no rtt estimate yet? */ - cur_rtt = stcb->asoc.initial_rto >> 2; + cur_rto = stcb->asoc.initial_rto >> 2; } else { - cur_rtt = ((net->lastsa >> 2) + net->lastsv) >> 1; + cur_rto = (net->lastsa >> SCTP_RTT_SHIFT) + net->lastsv; } - if (cur_rtt < SCTP_BASE_SYSCTL(sctp_early_fr_msec)) { - cur_rtt = SCTP_BASE_SYSCTL(sctp_early_fr_msec); + if (cur_rto < SCTP_BASE_SYSCTL(sctp_early_fr_msec)) { + cur_rto = SCTP_BASE_SYSCTL(sctp_early_fr_msec); } - cur_rtt *= 1000; - tv.tv_sec = cur_rtt / 1000000; - tv.tv_usec = cur_rtt % 1000000; + cur_rto *= 1000; + tv.tv_sec = cur_rto / 1000000; + tv.tv_usec = cur_rto % 1000000; min_wait = now; timevalsub(&min_wait, &tv); if (min_wait.tv_sec < 0 || min_wait.tv_usec < 0) { @@ -626,7 +626,7 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb, struct sctp_tmit_chunk *chk, *nchk; struct sctp_nets *lnets; struct timeval now, min_wait, tv; - int cur_rtt; + int cur_rto; int cnt_abandoned; int audit_tf, num_mk, fir; unsigned int cnt_mk; @@ -644,10 +644,10 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb, */ (void)SCTP_GETTIME_TIMEVAL(&now); /* get cur rto in micro-seconds */ - cur_rtt = (((net->lastsa >> 2) + net->lastsv) >> 1); - cur_rtt *= 1000; + cur_rto = (net->lastsa >> SCTP_RTT_SHIFT) + net->lastsv; + cur_rto *= 1000; if (SCTP_BASE_SYSCTL(sctp_logging_level) & (SCTP_EARLYFR_LOGGING_ENABLE | SCTP_FR_LOGGING_ENABLE)) { - sctp_log_fr(cur_rtt, + sctp_log_fr(cur_rto, stcb->asoc.peers_rwnd, window_probe, SCTP_FR_T3_MARK_TIME); @@ -657,8 +657,8 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb, SCTP_FR_CWND_REPORT); sctp_log_fr(net->flight_size, net->cwnd, stcb->asoc.total_flight, SCTP_FR_CWND_REPORT); } - tv.tv_sec = cur_rtt / 1000000; - tv.tv_usec = cur_rtt % 1000000; + tv.tv_sec = cur_rto / 1000000; + tv.tv_usec = cur_rto % 1000000; min_wait = now; timevalsub(&min_wait, &tv); if (min_wait.tv_sec < 0 || min_wait.tv_usec < 0) { @@ -671,7 +671,7 @@ sctp_mark_all_for_resend(struct sctp_tcb *stcb, min_wait.tv_sec = min_wait.tv_usec = 0; } if (SCTP_BASE_SYSCTL(sctp_logging_level) & (SCTP_EARLYFR_LOGGING_ENABLE | SCTP_FR_LOGGING_ENABLE)) { - sctp_log_fr(cur_rtt, now.tv_sec, now.tv_usec, SCTP_FR_T3_MARK_TIME); + sctp_log_fr(cur_rto, now.tv_sec, now.tv_usec, SCTP_FR_T3_MARK_TIME); sctp_log_fr(0, min_wait.tv_sec, min_wait.tv_usec, SCTP_FR_T3_MARK_TIME); } /* diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c index 9a827f33c..ef22097dd 100644 --- a/sys/netinet/sctp_usrreq.c +++ b/sys/netinet/sctp_usrreq.c @@ -2398,7 +2398,7 @@ flags_out: paddri->spinfo_state = SCTP_INACTIVE; } paddri->spinfo_cwnd = net->cwnd; - paddri->spinfo_srtt = ((net->lastsa >> 2) + net->lastsv) >> 1; + paddri->spinfo_srtt = net->lastsa >> SCTP_RTT_SHIFT; paddri->spinfo_rto = net->RTO; paddri->spinfo_assoc_id = sctp_get_associd(stcb); SCTP_TCB_UNLOCK(stcb); @@ -2475,7 +2475,7 @@ flags_out: sstat->sstat_primary.spinfo_state = SCTP_INACTIVE; } sstat->sstat_primary.spinfo_cwnd = net->cwnd; - sstat->sstat_primary.spinfo_srtt = net->lastsa; + sstat->sstat_primary.spinfo_srtt = net->lastsa >> SCTP_RTT_SHIFT; sstat->sstat_primary.spinfo_rto = net->RTO; sstat->sstat_primary.spinfo_mtu = net->mtu; sstat->sstat_primary.spinfo_assoc_id = sctp_get_associd(stcb); -- 2.45.0