From nobody@FreeBSD.ORG Mon May 31 14:16:41 1999
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id 8FDF314C16; Mon, 31 May 1999 14:16:41 -0700 (PDT)
Message-Id: <19990531211641.8FDF314C16@hub.freebsd.org>
Date: Mon, 31 May 1999 14:16:41 -0700 (PDT)
From: aron@cs.rice.edu
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@freebsd.org
Subject: TCP copies send and receive socket buffer sizes from routing information even when user applications set them
X-Send-Pr-Version: www-1.0

>Number:         11966
>Category:       kern
>Synopsis:       TCP copies send and receive socket buffer sizes from routing information even when user applications set them
>Confidential:   no
>Severity:       critical
>Priority:       low
>Responsible:    ru
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon May 31 14:20:01 PDT 1999
>Closed-Date:    Mon Jul 29 00:31:40 PDT 2002
>Last-Modified:  Mon Jul 29 00:31:40 PDT 2002
>Originator:     Mohit Aron
>Release:        FreeBSD-2.2.6-RELEASE
>Organization:
Rice University
>Environment:
FreeBSD pd01.cs.rice.edu 2.2.6-RELEASE FreeBSD 2.2.6-RELEASE #12: Sun Mar 14 23:50:03 CST 1999     aron@pd01.cs.rice.edu:/usr/users/aron/FreeBSD-2.2.6-src/sys/compile/PD0X  i386

>Description:
TCP (enabled with rfc1323 extensions) exchanges the window scale option
only during connection establishment in its SYN packet. Thus, it is 
imperative that applications should set the socket buffer sizes *before*
establishing the TCP connection. 

However, in function tcp_mss() (in netinet/tcp_input.c), the socket
buffer size is set from old information contained in the routing tables.
Thus even if the application had set the socketbuffer size, this 
part of the code completely ignores that and goes ahead and sets the
socket buffer size itself. As a result, TCP operates with the flow
control window size determined from past information rather than what
the user has set.

>How-To-Repeat:
Start a TCP transfer between two hosts (or just do a telnet) with the
default settings of socket buffer sizes. Then try starting a transfer
again transfer and try setting the TCP rcv socket buffer size on the 
TCP receiver to a large value. Check the size of the window scale option
exchanged - it'll still be small (perhaps 0). This is the result of
the user information being completely discarded away.
>Fix:
The socket code should keep track of the fact whether the socket 
buffer size was set explicitly by the user or whether it contains the
default setting. It should be copied over from the routing information
only if it contains the default setting.


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: iedowse 
State-Changed-When: Sun Jan 20 09:55:44 PST 2002 
State-Changed-Why:  

Does this problem still exist? 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=11966 

From: Ruslan Ermilov <ru@FreeBSD.org>
To: Ian Dowse <iedowse@FreeBSD.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: kern/11966: TCP copies send and receive socket buffer sizes from routing information even when user applications set them
Date: Thu, 24 Jan 2002 14:59:38 +0200

 On Sun, Jan 20, 2002 at 09:56:02AM -0800, iedowse@FreeBSD.ORG wrote:
 > Synopsis: TCP copies send and receive socket buffer sizes from routing information even when user applications set them
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: iedowse
 > State-Changed-When: Sun Jan 20 09:55:44 PST 2002
 > State-Changed-Why: 
 > 
 > Does this problem still exist?
 > 
 Yes, and I think this patch (sitting in my RELENG_4 tree for over
 a year now, and I now almost forgot what it's about) should fix it:
 
 Index: tcp_input.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/netinet/tcp_input.c,v
 retrieving revision 1.107.2.20
 diff -u -p -r1.107.2.20 tcp_input.c
 --- tcp_input.c	2001/12/14 20:21:12	1.107.2.20
 +++ tcp_input.c	2002/01/24 12:55:22
 @@ -2615,7 +2615,8 @@ tcp_mss(tp, offer)
  		bufsize = roundup(bufsize, mss);
  		if (bufsize > sb_max)
  			bufsize = sb_max;
 -		(void)sbreserve(&so->so_snd, bufsize, so, NULL);
 +		if (bufsize > so->so_snd.sb_hiwat)
 +			(void)sbreserve(&so->so_snd, bufsize, so, NULL);
  	}
  	tp->t_maxseg = mss;
  
 @@ -2627,7 +2628,8 @@ tcp_mss(tp, offer)
  		bufsize = roundup(bufsize, mss);
  		if (bufsize > sb_max)
  			bufsize = sb_max;
 -		(void)sbreserve(&so->so_rcv, bufsize, so, NULL);
 +		if (bufsize > so->so_rcv.sb_hiwat)
 +			(void)sbreserve(&so->so_rcv, bufsize, so, NULL);
  	}
  
  	/*
 
 
 Cheers,
 -- 
 Ruslan Ermilov		Oracle Developer/DBA,
 ru@sunbay.com		Sunbay Software AG,
 ru@FreeBSD.org		FreeBSD committer,
 +380.652.512.251	Simferopol, Ukraine
 
 http://www.FreeBSD.org	The Power To Serve
 http://www.oracle.com	Enabling The Information Age

From: Sheldon Hearn <sheldonh@starjuice.net>
To: Ruslan Ermilov <ru@FreeBSD.org>
Cc: bug-followup@freebsd.org
Subject: Re: kern/11966: TCP copies send and receive socket buffer sizes from routing information even when user applications set them 
Date: Thu, 31 Jan 2002 17:14:10 +0200

 On Thu, 24 Jan 2002 05:00:02 PST, Ruslan Ermilov wrote:
 
 >  Yes, and I think this patch (sitting in my RELENG_4 tree for over
 >  a year now, and I now almost forgot what it's about) should fix it:
 
 You want to commit your patch to tcp_input.c yourself, or shall I assign
 this PR to jlemon?
 
 Ciao,
 Sheldon.
State-Changed-From-To: feedback->open 
State-Changed-By: sheldonh 
State-Changed-When: Thu Jan 31 07:27:40 PST 2002 
State-Changed-Why:  
Ruslan will commit his patch when he has time. 


Responsible-Changed-From-To: freebsd-bugs->ru 
Responsible-Changed-By: sheldonh 
Responsible-Changed-When: Thu Jan 31 07:27:40 PST 2002 
Responsible-Changed-Why:  
Ruslan will commit his patch when he has time. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=11966 

From: Hiten Pandya <hitmaster2k@yahoo.com>
To: bug-followup@FreeBSD.org
Cc: aron@cs.rice.edu
Subject: Re: kern/11966 (TCP copies snd and rcv buffer sizes from routing applications)
Date: Tue, 16 Apr 2002 04:46:58 -0700 (PDT)

 Hi,
 
 ru@, have you committed this patch, or does it simply need updating?  Just 
 a reminder. :)
 
   -- Hiten Pandya
   -- <hiten@uk.FreeBSD.org>
 
 __________________________________________________
 Do You Yahoo!?
 Yahoo! Tax Center - online filing with TurboTax
 http://taxes.yahoo.com/

From: Joseph Holland King <gte743n@cad.gatech.edu>
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: kern/11966 (TCP copies snd and rcv buffer sizes from routing applications)
Date: Wed, 19 Jun 2002 16:36:25 -0400

 a patch is there and has been open for a while
 can this pr be closed?
 
 -- 
 Holland King        
 gte743n@cad.gatech.edu
State-Changed-From-To: open->patched 
State-Changed-By: ru 
State-Changed-When: Mon Jul 22 15:37:53 PDT 2002 
State-Changed-Why:  
Fixed in 5.0-CURRENT, sys/netinet/tcp_input.c,v 1.166. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=11966 
State-Changed-From-To: patched->closed 
State-Changed-By: ru 
State-Changed-When: Mon Jul 29 00:30:42 PDT 2002 
State-Changed-Why:  
Fixed in 4.6-STABLE, sys/netinet/tcp_input.c,v 1.107.2.25. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=11966 
>Unformatted:
