Subject: pr/22551: kernel diagnostic assertion to_ticks>=0 failed
To: None <current-users@NetBSD.org>
From: Geoff Adams <gadams@avernus.com>
List: current-users
Date: 04/06/2005 01:14:58
--Apple-Mail-17--834171575
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	delsp=yes;
	format=flowed

Is there any hope of getting this fix pulled up to the 2.0 branch? I  
have applied the relevant part of the fix in sys/netinet/tcp_input.c  
1.213 to the 2.0 branch, and this fixes the problem for me. (Before  
applying the fix, my mail server would panic every day or so. This  
server talks, naturally, to hosts around the world. Mostly spammers,  
of course. And some of those hosts triggered the bug. Since applying  
the fix nearly two months ago, I have had no panics.)

I've attached my patch against the 2.0 branch. I certainly imagine  
this must affect more folks than just me. Otherwise, I'd be happy to  
just keep going with my locally modified sources.

- Geoff


--Apple-Mail-17--834171575
Content-Type: multipart/appledouble;
	boundary=Apple-Mail-18--834171574
Content-Disposition: attachment


--Apple-Mail-18--834171574
Content-Transfer-Encoding: base64
Content-Type: application/applefile;
	name="pr-22551-fix-for-2.0-branch.patch"
Content-Disposition: attachment;
	filename=pr-22551-fix-for-2.0-branch.patch

AAUWBwACAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAJAAAAPgAAAAoAAAADAAAASAAAACEAAAACAAAA
aQAAAX5URVhUUipjaAAAcHItMjI1NTEtZml4LWZvci0yLjAtYnJhbmNoLnBhdGNoAAABAAAAAUwA
AABMAAAAMgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgACU1vbmFjbwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAQABACEACgDdgIoAIQAKAN2Aii+eOdLAAAEegAABHoAAAAAAQAAAAEAAAABTAAAAEwAAAAyAE/g
jALdAAAAHAAyAABNUFNSAAAACgPt//8AAAAAAHvRfA==

--Apple-Mail-18--834171574
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
	x-mac-type=54455854;
	x-unix-mode=0644;
	x-mac-creator=522A6368;
	name="pr-22551-fix-for-2.0-branch.patch"
Content-Disposition: attachment;
	filename=pr-22551-fix-for-2.0-branch.patch

Index: sys/netinet/tcp_input.c
===================================================================
RCS file: /cvsroot/src/sys/netinet/tcp_input.c,v
retrieving revision 1.190.2.6
diff -u -r1.190.2.6 tcp_input.c
--- sys/netinet/tcp_input.c     19 Sep 2004 15:38:01 -0000      1.190.2.6
+++ sys/netinet/tcp_input.c     6 Apr 2005 02:18:15 -0000
@@ -1445,6 +1445,21 @@
        if (optp)
                tcp_dooptions(tp, optp, optlen, th, &opti);
 
+       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_GEQ(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

--Apple-Mail-18--834171574--

--Apple-Mail-17--834171575--