netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [RFC] IPv4 TCP fails to send window scale option when window scale is zero
@ 2009-09-29 15:05 Gilad Ben-Yossef
  2009-09-29 17:19 ` Eric Dumazet
  0 siblings, 1 reply; 7+ messages in thread
From: Gilad Ben-Yossef @ 2009-09-29 15:05 UTC (permalink / raw)
  To: netdev; +Cc: Ori Finkalman

From: Ori Finkalman <ori@comsleep.com>


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 <gilad@codefidence.com>
Signed-off-by: Ori Finkelman <ori@comsleep.com>


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;



-- 
Gilad Ben-Yossef
Chief Coffee Drinker & CTO
Codefidence Ltd.

Web:   http://codefidence.com
Cell:  +972-52-8260388
Skype: gilad_codefidence
Tel:   +972-8-9316883 ext. 201
Fax:   +972-8-9316884
Email: gilad@codefidence.com

Check out our Open Source technology and training blog - http://tuxology.net

	"Now the world has gone to bed
	 Darkness won't engulf my head
	 I can see by infra-red
	 How I hate the night."


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-10-01  9:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-29 15:05 [PATCH] [RFC] IPv4 TCP fails to send window scale option when window scale is zero Gilad Ben-Yossef
2009-09-29 17:19 ` Eric Dumazet
2009-09-30  6:28   ` Gilad Ben-Yossef
2009-09-30  7:16     ` Eric Dumazet
2009-09-30 11:42       ` Ilpo Järvinen
2009-09-30 13:06         ` Eric Dumazet
2009-10-01  9:39           ` Gilad Ben-Yossef

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).