Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Jul 2011 07:11:07 GMT
From:      Catalin Nicutar <cnicutar@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 196134 for review
Message-ID:  <201107140711.p6E7B77Y070434@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@196134?ac=10

Change 196134 by cnicutar@cnicutar_cronos on 2011/07/14 07:10:33

	Record the exact UTO value received, whether or not the user chose
	to accept it. The TF_RCV_UTO flag will later tell if ne need to use
	it or not.

Affected files ...

.. //depot/projects/soc2011/cnicutar_tcputo_8/src/sys/netinet/tcp_input.c#5 edit
.. //depot/projects/soc2011/cnicutar_tcputo_8/src/sys/netinet/tcp_timer.c#7 edit

Differences ...

==== //depot/projects/soc2011/cnicutar_tcputo_8/src/sys/netinet/tcp_input.c#5 (text+ko) ====

@@ -1091,14 +1091,12 @@
 		tcp_dooptions(&to, optp, optlen, TO_SYN);
 
 		if (to.to_flags & TOF_UTO) {
-			if (tp->t_flags & TF_RCV_UTO) {
-				tp->rcv_uto = (to.to_uto & UTO_MINS) ?
-				    (to.to_uto & ~(UTO_MINS)) * 60 : to.to_uto;
-				/* silently make it fit between min-max */
-				tp->rcv_uto = min(V_uto_max_timeout,
-				    max(V_uto_min_timeout, tp->rcv_uto));
-			}
-
+			/*
+			 * Storing the value even if the user might not
+			 * accept it. Also, not clamping it just yet.
+			 */
+			tp->rcv_uto = (to.to_uto & UTO_MINS) ?
+			    (to.to_uto & ~(UTO_MINS)) * 60 : to.to_uto;
 			/*
 			 * XXX-CN Using option both for send and receive.
 			 * Clear it for syncache.
@@ -1288,13 +1286,16 @@
 	    (th->th_off << 2) - sizeof(struct tcphdr),
 	    (thflags & TH_SYN) ? TO_SYN : 0);
 
-	/* Processing received UTO. */
-	if ((to.to_flags & TOF_UTO) && (tp->t_flags & TF_RCV_UTO)) {
-		/* convert to seconds if granularity is set */
+	/*
+	 * Processing received UTO even if the user doesn't accept it
+	 * yet. The user might wants to accept it later (perhaps after
+	 * authentication ) but the peer need not send it again.
+	 * The value is converter to seconds and not clamped (the user
+	 * needs to know the real value received).
+	 */
+	if (to.to_flags & TOF_UTO) {
 		tp->rcv_uto = (to.to_uto & UTO_MINS) ?
 		    (to.to_uto & ~(UTO_MINS)) * 60 : to.to_uto;
-		tp->rcv_uto = min(V_uto_max_timeout,
-		    max(V_uto_min_timeout, tp->rcv_uto));
 	}
 
 	/*

==== //depot/projects/soc2011/cnicutar_tcputo_8/src/sys/netinet/tcp_timer.c#7 (text+ko) ====

@@ -490,14 +490,23 @@
 
 	if (tp->t_rxtshift == 0)
 		/* UTO starting again since it's the first retransmit. */
-		tp->t_suto = 0;	
+		tp->t_suto = 0;
 
 	if (tp->snd_uto || ((tp->t_flags & TF_RCV_UTO) && tp->rcv_uto)) {
 		/*
 		 * Since we're using UTO for this connection we need to
 		 * compute how much time we've got left.
 		 */
-		uto_left = max(tp->snd_uto, tp->rcv_uto);
+		uto_left = 0;
+		if (tp->t_flags & TF_RCV_UTO)
+			/* Clamping the received value. */
+			uto_left = min(V_uto_max_timeout, 
+			    max(V_uto_min_timeout, tp->rcv_uto));
+
+		/* Taking the longer timeout. */
+		uto_left = max(tp->snd_uto, uto_left);
+
+		/* Subtract time that has passed since the first retransmit. */
 		if (tp->t_suto)
 			uto_left -= ticks_to_secs(ticks - tp->t_suto);
 
@@ -560,7 +569,9 @@
 			rexmt = TCPTV_REXMTMAX;
 	}
 	/* We might want to wait less than an entire backoff. */
-	rexmt = min(rexmt, uto_left * hz);
+	if (uto_left)
+		rexmt = min(rexmt, uto_left * hz);
+
 	TCPT_RANGESET(tp->t_rxtcur, rexmt,
 		      tp->t_rttmin, TCPTV_REXMTMAX);
 	/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201107140711.p6E7B77Y070434>