From owner-freebsd-net@FreeBSD.ORG Tue Nov 3 21:30:08 2009 Return-Path: Delivered-To: net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 76A01106566B; Tue, 3 Nov 2009 21:30:08 +0000 (UTC) (envelope-from bzeeb-lists@lists.zabbadoz.net) Received: from mail.cksoft.de (mail.cksoft.de [195.88.108.3]) by mx1.freebsd.org (Postfix) with ESMTP id 3187C8FC17; Tue, 3 Nov 2009 21:30:08 +0000 (UTC) Received: from localhost (amavis.fra.cksoft.de [192.168.74.71]) by mail.cksoft.de (Postfix) with ESMTP id D0BD541C6DB; Tue, 3 Nov 2009 22:30:06 +0100 (CET) X-Virus-Scanned: amavisd-new at cksoft.de Received: from mail.cksoft.de ([195.88.108.3]) by localhost (amavis.fra.cksoft.de [192.168.74.71]) (amavisd-new, port 10024) with ESMTP id P-j+tf1kMd1M; Tue, 3 Nov 2009 22:30:06 +0100 (CET) Received: by mail.cksoft.de (Postfix, from userid 66) id 3358441C6FC; Tue, 3 Nov 2009 22:30:06 +0100 (CET) Received: from maildrop.int.zabbadoz.net (maildrop.int.zabbadoz.net [10.111.66.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.int.zabbadoz.net (Postfix) with ESMTP id 4D3E74448E6; Tue, 3 Nov 2009 21:26:48 +0000 (UTC) Date: Tue, 3 Nov 2009 21:26:48 +0000 (UTC) From: "Bjoern A. Zeeb" X-X-Sender: bz@maildrop.int.zabbadoz.net To: John Baldwin In-Reply-To: <200911031529.26514.jhb@FreeBSD.org> Message-ID: <20091103212129.F37440@maildrop.int.zabbadoz.net> References: <200911031529.26514.jhb@FreeBSD.org> X-OpenPGP-Key: 0x14003F198FEFA3E77207EE8D2B58B8F83CCF1842 MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: net@FreeBSD.org Subject: Re: Small bug with TCP zero windows X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Nov 2009 21:30:08 -0000 On Tue, 3 Nov 2009, John Baldwin wrote: > Several years ago Dillon added a feature to TCP that casued soreceive() to > send an ACK right away if data was drained from a TCP socket that had > previously advertised a zero-sized window. The current code requires the > receive window to be exactly zero for this to kick in. If window scaling is > enabled and the window is smaller than the scale, then the effective window > that is advertised is zero. However, in that case the zero-sized window > handling is not enabled because the window is not exactly zero. The patch > below changes the code to check the raw window value against zero. Arguably > it could check 'th_win' directly instead if folks would prefer that. hmm, looking a few lines up, there is a htons() there as well; obviously doesn't matter for 0. th_win is set to something different for SYNs. I guess what you are doing is ok, and even though it is not needed, I feel that it would be easier to read it with an extra pair of (). > Index: tcp_output.c > =================================================================== > --- tcp_output.c (revision 198794) > +++ tcp_output.c (working copy) > @@ -992,7 +992,7 @@ > * to read more data than can be buffered prior to transmitting on > * the connection. > */ > - if (recwin == 0) > + if (recwin >> tp->rcv_scale == 0) > tp->t_flags |= TF_RXWIN0SENT; > else > tp->t_flags &= ~TF_RXWIN0SENT; > > -- Bjoern A. Zeeb It will not break if you know what you are doing.