Subject: tcp_output fix for acking with a full send buffer
To: None <tech-net@netbsd.org>
From: Darrin B.Jewell <dbj@netbsd.org>
List: tech-net
Date: 09/14/2006 10:34:42
--=-=-=


A while ago, I encountered a bug where I could get tcp to slow down
because it couldn't get acks on the wire.  I tracked this down to
mycroft's original fix to avoid sending more than half a buffer full.

The fix is to never send more than (hiwat - lowat + 1)/2 instead of
mycroft's fix of just hiwat/2.  I've had a patch in my tree for some
time, but haven't had the time to write up a simplified test case
demonstrating the problem.

Does the following patch look correct?

Thanks,
Darrin


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=tcpoutput.diff
Content-Description: never send more than (hiwat - lowat + 1) /2

Index: tcp_output.c
===================================================================
RCS file: /cvsroot/src/sys/netinet/tcp_output.c,v
retrieving revision 1.139
diff -u -r1.139 tcp_output.c
--- tcp_output.c	10 Aug 2005 13:07:21 -0000	1.139
+++ tcp_output.c	30 Jan 2006 21:45:24 -0000
@@ -397,7 +397,8 @@
 	 * transmit.
 	 */
 	if (so)
-		*txsegsizep = min(so->so_snd.sb_hiwat >> 1, *txsegsizep);
+		*txsegsizep = min((so->so_snd.sb_hiwat - 
+			so->so_snd.sb_lowat + 1) >> 1, *txsegsizep);
 	*rxsegsizep = min(tp->t_ourmss - optlen, size);
 
 	if (*txsegsizep != tp->t_segsz) {

--=-=-=--