From nobody@FreeBSD.org  Tue Jun 21 08:21:53 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id BB4E916A41C
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 21 Jun 2005 08:21:53 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id A3AFB43D49
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 21 Jun 2005 08:21:53 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j5L8LrsQ014983
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 21 Jun 2005 08:21:53 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id j5L8Lrdx014982;
	Tue, 21 Jun 2005 08:21:53 GMT
	(envelope-from nobody)
Message-Id: <200506210821.j5L8Lrdx014982@www.freebsd.org>
Date: Tue, 21 Jun 2005 08:21:53 GMT
From: Pieter de Boer <pieter@os3.nl>
To: freebsd-gnats-submit@FreeBSD.org
Subject: FreeBSD advertises wrong window scale in some situations
X-Send-Pr-Version: www-2.3

>Number:         82470
>Category:       kern
>Synopsis:       FreeBSD advertises wrong window scale in some situations
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    silby
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 21 08:30:18 GMT 2005
>Closed-Date:    
>Last-Modified:  Wed Aug 03 09:14:22 GMT 2005
>Originator:     Pieter de Boer
>Release:        5.4-RELEASE
>Organization:
SNB@UvA
>Environment:
FreeBSD client.wind.surfnet.nl 5.4-RELEASE FreeBSD 5.4-RELEASE #0: Thu Jun 16 17:09:33 CEST 2005     root@:/usr/obj/usr/src/sys/SMP  i386

>Description:
      Setting a recv buffer of (65535*2)+1 lets FreeBSD advertise a window of 65535<<2 (window scale 2, 256KB) in stead of 65535<<1 (window scale 1, 128KB). So FreeBSD is advertising a window bigger than the actual available receive space. When setting the buffer to 65535*2 exactly, the window scale option is set correctly. 
>How-To-Repeat:
      sysctl net.inet.tcp.recvspace=131071

Then set up a connection from the FreeBSD system to something else. FreeBSD will advertise a windowsize of 256KB, although there's only 1 byte more than 128KB available.
>Fix:
      Haven't had time to look into it yet, sorry.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: arved 
Responsible-Changed-When: Wed Jun 29 12:18:53 GMT 2005 
Responsible-Changed-Why:  
over to Networking experts 

http://www.freebsd.org/cgi/query-pr.cgi?pr=82470 

From: Pieter de Boer <pieter@os3.nl>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: kern/82470: FreeBSD advertises wrong window scale in some situations
Date: Sun, 24 Jul 2005 15:39:15 +0200

 The following patch seems to fix the problem:
 
 
 diff -u netinet.orig/tcp_syncache.c netinet/tcp_syncache.c
 --- netinet.orig/tcp_syncache.c	Sun Jul 24 15:26:14 2005
 +++ netinet/tcp_syncache.c	Sun Jul 24 15:26:56 2005
 @@ -966,7 +966,7 @@
 
   			/* Compute proper scaling value from buffer space */
   			while (wscale < TCP_MAX_WINSHIFT &&
 -			    (TCP_MAXWIN << wscale) < so->so_rcv.sb_hiwat)
 +			    (TCP_MAXWIN << (wscale + 1)) <= so->so_rcv.sb_hiwat)
   				wscale++;
   			sc->sc_request_r_scale = wscale;
   			sc->sc_requested_s_scale = to->to_requested_s_scale;
 diff -u netinet.orig/tcp_usrreq.c netinet/tcp_usrreq.c
 --- netinet.orig/tcp_usrreq.c	Sun Jul 24 15:26:14 2005
 +++ netinet/tcp_usrreq.c	Sun Jul 24 15:26:47 2005
 @@ -888,7 +888,7 @@
 
   	/* Compute window scaling to request.  */
   	while (tp->request_r_scale < TCP_MAX_WINSHIFT &&
 -	    (TCP_MAXWIN << tp->request_r_scale) < so->so_rcv.sb_hiwat)
 +	    (TCP_MAXWIN << (tp->request_r_scale + 1)) <= so->so_rcv.sb_hiwat)
   		tp->request_r_scale++;
 
   	soisconnecting(so);
 @@ -950,7 +950,7 @@
 
   	/* Compute window scaling to request.  */
   	while (tp->request_r_scale < TCP_MAX_WINSHIFT &&
 -	    (TCP_MAXWIN << tp->request_r_scale) < so->so_rcv.sb_hiwat)
 +	    (TCP_MAXWIN << (tp->request_r_scale + 1)) <= so->so_rcv.sb_hiwat)
   		tp->request_r_scale++;
 
   	soisconnecting(so);
Responsible-Changed-From-To: freebsd-net->silby 
Responsible-Changed-By: rwatson 
Responsible-Changed-When: Wed Aug 3 09:13:49 GMT 2005 
Responsible-Changed-Why:  
Chown to silby, who has recently been spending some quality time with TCP. 


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