Subject: Re: TCP/RFC 1323 bug
To: None <mallman@grc.nasa.gov>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: tech-net
Date: 08/07/1999 08:00:42
On Thu, 05 Aug 1999 14:10:03 -0400 
 Mark Allman <mallman@grc.nasa.gov> wrote:

 > to ensure that the timestamp is valid before using it to compute a
 > new RTO.  That seems to have cured my particular problem and seems
 > like it should be used in the general case, as well (at least thats
 > my reading of the RFC!).

How about the following patch, which addresses the problem of using a
bogus timestamp in PAWS as well (and also gets all the places where
ts_present is set to 1 :-)

        -- Jason R. Thorpe <thorpej@nas.nasa.gov>

Index: tcp_input.c
===================================================================
RCS file: /cvsroot/syssrc/sys/netinet/tcp_input.c,v
retrieving revision 1.89
diff -u -r1.89 tcp_input.c
--- tcp_input.c	1999/07/22 12:56:56	1.89
+++ tcp_input.c	1999/08/07 14:59:06
@@ -679,9 +679,10 @@
 			optp[TCPOLEN_TSTAMP_APPA] == TCPOPT_EOL)) &&
 		     *(u_int32_t *)optp == htonl(TCPOPT_TSTAMP_HDR) &&
 		     (th->th_flags & TH_SYN) == 0) {
-			opti.ts_present = 1;
 			opti.ts_val = ntohl(*(u_int32_t *)(optp + 4));
 			opti.ts_ecr = ntohl(*(u_int32_t *)(optp + 8));
+			if (opti.ts_ecr != 0)
+				opti.ts_present = 1;
 			optp = NULL;	/* we've parsed the options */
 		}
 	}
@@ -2120,11 +2121,12 @@
 		case TCPOPT_TIMESTAMP:
 			if (optlen != TCPOLEN_TIMESTAMP)
 				continue;
-			oi->ts_present = 1;
 			bcopy(cp + 2, &oi->ts_val, sizeof(oi->ts_val));
 			NTOHL(oi->ts_val);
 			bcopy(cp + 6, &oi->ts_ecr, sizeof(oi->ts_ecr));
 			NTOHL(oi->ts_ecr);
+			if (oi->ts_ecr != 0)
+				oi->ts_present = 1;
 
 			/* 
 			 * A timestamp received in a SYN makes