--- linux-2.6-2.6.15/net/ipv4/tcp_output.c.orig 2006-01-02 19:21:10.000000000 
-0800
+++ linux-2.6-2.6.15/net/ipv4/tcp_output.c      2006-03-09 10:41:46.000000000 
-0800
@@ -45,6 +45,11 @@
 /* People can turn this off for buggy TCP's found in printers etc. */
 int sysctl_tcp_retrans_collapse = 1;
 
+/* People can turn this on to  work with those rare, broken TCPs that 
+ * interpret the window field as a signed quantity.
+ */
+int sysctl_tcp_workaround_signed_windows = 0;
+
 /* This limits the percentage of the congestion window which we
  * will allow a single TSO frame to consume.  Building TSO frames
  * which are too large can cause TCP streams to be bursty.
@@ -171,12 +176,18 @@ void tcp_select_initial_window(int __spa
                space = (space / mss) * mss;
 
        /* NOTE: offering an initial window larger than 32767
-        * will break some buggy TCP stacks. We try to be nice.
-        * If we are not window scaling, then this truncates
-        * our initial window offering to 32k. There should also
-        * be a sysctl option to stop being nice.
+        * will break some buggy TCP stacks. If the admin tells us
+        * it is likely we could be speaking with such a buggy stack
+        * we will truncate our initial window offering to 32K-1
+        * unless the remote has sent us a window scaling option, 
+        * which we interpret as a sign the remote TCP is not
+        * misinterpreting the window field as a signed quantity.
         */
-       (*rcv_wnd) = min(space, MAX_TCP_WINDOW);
+       if (sysctl_tcp_workaround_signed_windows)
+               (*rcv_wnd) = min(space, MAX_TCP_WINDOW);
+       else
+               (*rcv_wnd) = space;
+
        (*rcv_wscale) = 0;
        if (wscale_ok) {
                /* Set window scaling on max possible window
@@ -235,7 +246,7 @@ static __inline__ u16 tcp_select_window(
        /* Make sure we do not exceed the maximum possible
         * scaled window.
         */
-       if (!tp->rx_opt.rcv_wscale)
+       if (!tp->rx_opt.rcv_wscale && sysctl_tcp_workaround_signed_windows)
                new_win = min(new_win, MAX_TCP_WINDOW);
        else
                new_win = min(new_win, (65535U << tp->rx_opt.rcv_wscale));
--- linux-2.6-2.6.15/include/net/tcp.h.orig     2006-02-28 13:40:33.000000000 
-0800
+++ linux-2.6-2.6.15/include/net/tcp.h  2006-03-09 10:34:40.000000000 -0800
@@ -219,6 +219,7 @@ extern int sysctl_tcp_nometrics_save;
 extern int sysctl_tcp_moderate_rcvbuf;
 extern int sysctl_tcp_tso_win_divisor;
 extern int sysctl_tcp_abc;
+extern int sysctl_tcp_workaround_signed_windows;
 
 extern atomic_t tcp_memory_allocated;
 extern atomic_t tcp_sockets_allocated;
--- linux-2.6-2.6.15/include/linux/sysctl.h.orig        2006-02-28 
13:40:46.000000000 -0800
+++ linux-2.6-2.6.15/include/linux/sysctl.h     2006-03-09 10:35:06.000000000 
-0800
@@ -390,6 +390,7 @@ enum
        NET_IPV4_ICMP_ERRORS_USE_INBOUND_IFADDR=109,
        NET_TCP_CONG_CONTROL=110,
        NET_TCP_ABC=111,
+       NET_IPV4_TCP_WORKAROUND_SIGNED_WINDOWS=112,
 };
 
 enum {
--- linux-2.6-2.6.15/net/ipv4/sysctl_net_ipv4.c.orig    2006-03-01 
17:45:46.000000000 -0800
+++ linux-2.6-2.6.15/net/ipv4/sysctl_net_ipv4.c 2006-03-09 10:35:43.000000000 
-0800
@@ -653,7 +653,14 @@ ctl_table ipv4_table[] = {
                .mode           = 0644,
                .proc_handler   = &proc_dointvec,
        },
-
+        {
+               .ctl_name       = NET_IPV4_TCP_WORKAROUND_SIGNED_WINDOWS,
+               .procname       = "tcp_workaround_signed_windows",
+               .data           = &sysctl_tcp_workaround_signed_windows,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = &proc_dointvec
+       },
        { .ctl_name = 0 }
 };
 
--- linux-2.6-2.6.15/Documentation/networking/ip-sysctl.txt.orig        
2006-01-02 19:21:10.000000000 -0800
+++ linux-2.6-2.6.15/Documentation/networking/ip-sysctl.txt     2006-03-09 
10:36:18.000000000 -0800
@@ -332,6 +332,13 @@ somaxconn - INTEGER
        Defaults to 128.  See also tcp_max_syn_backlog for additional tuning
        for TCP sockets.
 
+tcp_workaround_signed_windows - BOOLEAN
+       If set, assume no receipt of a window scaling option means the
+       remote TCP is broken and treats the window as a signed quantity. 
+       If unset, assume the remote TCP is not broken even if we do
+       not receive a window scaling option from them.
+       Default: 0
+
 IP Variables:
 
 ip_local_port_range - 2 INTEGERS
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to