From patchwork Tue Sep 29 15:05:52 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 34439 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id B917EB7C25 for ; Wed, 30 Sep 2009 01:31:51 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752525AbZI2Pbk (ORCPT ); Tue, 29 Sep 2009 11:31:40 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752145AbZI2Pbk (ORCPT ); Tue, 29 Sep 2009 11:31:40 -0400 Received: from xenbox.codefidence.com ([92.48.73.16]:46420 "EHLO xenbox.codefidence.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751901AbZI2Pbj (ORCPT ); Tue, 29 Sep 2009 11:31:39 -0400 X-Greylist: delayed 1549 seconds by postgrey-1.27 at vger.kernel.org; Tue, 29 Sep 2009 11:31:39 EDT Received: by xenbox.codefidence.com (Postfix, from userid 56) id 0E9862458C; Tue, 29 Sep 2009 11:05:54 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on codefidence.com X-Spam-Level: X-Spam-Status: No, score=-102.5 required=5.0 tests=AWL, BAYES_00, NO_RECEIVED, NO_RELAYS,USER_IN_WHITELIST autolearn=ham version=3.2.4 Message-ID: <4AC22250.7060301@codefidence.com> Date: Tue, 29 Sep 2009 17:05:52 +0200 From: Gilad Ben-Yossef User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: netdev@vger.kernel.org CC: Ori Finkalman Subject: [PATCH] [RFC] IPv4 TCP fails to send window scale option when window scale is zero Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ori Finkalman Acknowledge TCP window scale support by inserting the proper option in SYN/ACK header even if our window scale is zero. This fixes the following observed behavior: 1. Client sends a SYN with TCP window scaling option and non zero window scale value to a Linux box. 2. Linux box notes large receive window from client. 3. Linux decides on a zero value of window scale for its part. 4. Due to compare against requested window scale size option, Linux does not to send windows scale TCP option header on SYN/ACK at all. Result: Client box thinks TCP window scaling is not supported, since SYN/ACK had no TCP window scale option, while Linux thinks that TCP window scaling is supported (and scale might be non zero), since SYN had TCP window scale option and we have a mismatched idea between the client and server regarding window sizes. Please comment and/or apply. --- Bug reported and patch written by Ori Finkalman from Comsleep Ltd. I'm just helping mainline it. The behavior was observed with a Windows box as the client and latest Debian kernel but for the best of my understanding this can happen with latest kernel versions and other client OS (probably also Linux) as well. Signed-off-by: Gilad Ben-Yossef Signed-off-by: Ori Finkelman Index: net/ipv4/tcp_output.c =================================================================== --- net/ipv4/tcp_output.c (revision 46) +++ net/ipv4/tcp_output.c (revision 210) @@ -353,6 +353,7 @@ static void tcp_init_nondata_skb(struct #define OPTION_SACK_ADVERTISE (1 << 0) #define OPTION_TS (1 << 1) #define OPTION_MD5 (1 << 2) +#define OPTION_WSCALE (1 << 3) struct tcp_out_options { u8 options; /* bit field of OPTION_* */ @@ -417,7 +418,7 @@ static void tcp_options_write(__be32 *pt TCPOLEN_SACK_PERM); } - if (unlikely(opts->ws)) { + if (unlikely(OPTION_WSCALE & opts->options)) { *ptr++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_WINDOW << 16) | (TCPOLEN_WINDOW << 8) | @@ -530,8 +531,8 @@ static unsigned tcp_synack_options(struc if (likely(ireq->wscale_ok)) { opts->ws = ireq->rcv_wscale; - if(likely(opts->ws)) - size += TCPOLEN_WSCALE_ALIGNED; + opts->options |= OPTION_WSCALE; + size += TCPOLEN_WSCALE_ALIGNED; } if (likely(doing_ts)) { opts->options |= OPTION_TS;