Subject: Re: Odd crashes in tcp_output (2.0ish)
To: Greg Troxel <gdt@ir.bbn.com>
From: Charles M. Hannum <abuse@spamalicious.com>
List: tech-net
Date: 01/26/2005 18:14:20
--Boundary-00=_8399BxP9IwWvtOH
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
On Wednesday 26 January 2005 18:08, Charles M. Hannum wrote:
> I think this should fix the problem, though I haven't actually tested it...
Whoops, ignore that. I have a sign problem there. Try this patch instead...
--Boundary-00=_8399BxP9IwWvtOH
Content-Type: text/x-diff;
charset="iso-8859-1";
name="tstamp.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="tstamp.diff"
Index: tcp_input.c
===================================================================
RCS file: /cvsroot/src/sys/netinet/tcp_input.c,v
retrieving revision 1.212
diff -u -r1.212 tcp_input.c
--- tcp_input.c 21 Dec 2004 05:51:31 -0000 1.212
+++ tcp_input.c 26 Jan 2005 18:12:24 -0000
@@ -1495,6 +1495,21 @@
if (tcp_dooptions(tp, optp, optlen, th, m, toff, &opti) < 0)
goto drop;
+ if (opti.ts_present && opti.ts_ecr) {
+ u_int32_t now;
+
+ /*
+ * Calculate the RTT from the returned time stamp and the
+ * connection's time base. If the time stamp is later than
+ * the current time, fall back to non-1323 RTT calculation.
+ */
+ now = TCP_TIMESTAMP(tp);
+ if (SEQ_GT(now, opti.ts_ecr))
+ opti.ts_ecr = now - opti.ts_ecr + 1;
+ else
+ opti.ts_ecr = 0;
+ }
+
/*
* Header prediction: check for the two common cases
* of a uni-directional data xfer. If the packet has
@@ -1537,8 +1552,7 @@
*/
++tcpstat.tcps_predack;
if (opti.ts_present && opti.ts_ecr)
- tcp_xmit_timer(tp,
- TCP_TIMESTAMP(tp) - opti.ts_ecr + 1);
+ tcp_xmit_timer(tp, opti.ts_ecr);
else if (tp->t_rtttime &&
SEQ_GT(th->th_ack, tp->t_rtseq))
tcp_xmit_timer(tp,
@@ -2167,7 +2181,7 @@
* Recompute the initial retransmit timer.
*/
if (opti.ts_present && opti.ts_ecr)
- tcp_xmit_timer(tp, TCP_TIMESTAMP(tp) - opti.ts_ecr + 1);
+ tcp_xmit_timer(tp, opti.ts_ecr);
else if (tp->t_rtttime && SEQ_GT(th->th_ack, tp->t_rtseq))
tcp_xmit_timer(tp, tcp_now - tp->t_rtttime);
--Boundary-00=_8399BxP9IwWvtOH--