svn commit: r219014 - head/sys/netinet

Michael Tuexen tuexen at FreeBSD.org
Thu Feb 24 22:58:16 UTC 2011


Author: tuexen
Date: Thu Feb 24 22:58:15 2011
New Revision: 219014
URL: http://svn.freebsd.org/changeset/base/219014

Log:
  * Fix several bugs where the scaled versions of srtt and rttvar
    where used incorrectly.
  * Use appropriate variable names for RTO instead of RTT.
  
  MFC after: 3 months.

Modified:
  head/sys/netinet/sctp_cc_functions.c
  head/sys/netinet/sctp_timer.c
  head/sys/netinet/sctp_usrreq.c

Modified: head/sys/netinet/sctp_cc_functions.c
==============================================================================
--- head/sys/netinet/sctp_cc_functions.c	Thu Feb 24 22:36:40 2011	(r219013)
+++ head/sys/netinet/sctp_cc_functions.c	Thu Feb 24 22:58:15 2011	(r219014)
@@ -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(st
 	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, st
 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;
 			}

Modified: head/sys/netinet/sctp_timer.c
==============================================================================
--- head/sys/netinet/sctp_timer.c	Thu Feb 24 22:36:40 2011	(r219013)
+++ head/sys/netinet/sctp_timer.c	Thu Feb 24 22:58:15 2011	(r219014)
@@ -61,24 +61,24 @@ sctp_early_fr_timer(struct sctp_inpcb *i
 {
 	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
 	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
 	 */
 	(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
 		    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
 		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);
 	}
 	/*

Modified: head/sys/netinet/sctp_usrreq.c
==============================================================================
--- head/sys/netinet/sctp_usrreq.c	Thu Feb 24 22:36:40 2011	(r219013)
+++ head/sys/netinet/sctp_usrreq.c	Thu Feb 24 22:58:15 2011	(r219014)
@@ -2401,7 +2401,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);
@@ -2478,7 +2478,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);


More information about the svn-src-all mailing list