netdev
[Top] [All Lists]

[PATCH] window announcement with scaling

To: "David S. Miller" <davem@xxxxxxxxxx>
Subject: [PATCH] window announcement with scaling
From: John Heffner <jheffner@xxxxxxx>
Date: Wed, 7 Jul 2004 17:45:13 -0400 (EDT)
Cc: <netdev@xxxxxxxxxxx>, <linux-net@xxxxxxxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
See comments in patch below.

  -John

===== net/ipv4/tcp_output.c 1.40 vs edited =====
--- 1.40/net/ipv4/tcp_output.c  Tue Jun 22 02:52:20 2004
+++ edited/net/ipv4/tcp_output.c        Wed Jul  7 17:39:42 2004
@@ -682,17 +682,30 @@
        if (free_space > tp->rcv_ssthresh)
                free_space = tp->rcv_ssthresh;

-       /* Get the largest window that is a nice multiple of mss.
-        * Window clamp already applied above.
-        * If our current window offering is within 1 mss of the
-        * free space we just keep it. This prevents the divide
-        * and multiply from happening most of the time.
-        * We also don't do any window rounding when the free space
-        * is too small.
+       /* Don't do rounding if we are using window scaling, since the
+        * scaled window will not line up with the MSS boundary anyway.
         */
        window = tp->rcv_wnd;
-       if (window <= free_space - mss || window > free_space)
-               window = (free_space/mss)*mss;
+       if (tp->rcv_wscale) {
+               window = free_space;
+
+               /* Advertise enough space so that it won't get scaled away.
+                * Import case: prevent zero window announcement if
+                * 1<<rcv_wscale > mss. */
+               if (((window >> tp->rcv_wscale) << tp->rcv_wscale) != window)
+                       window = ((window >> tp->rcv_wscale) + 1) << 
tp->rcv_wscale;
+       } else {
+               /* Get the largest window that is a nice multiple of mss.
+                * Window clamp already applied above.
+                * If our current window offering is within 1 mss of the
+                * free space we just keep it. This prevents the divide
+                * and multiply from happening most of the time.
+                * We also don't do any window rounding when the free space
+                * is too small.
+                */
+               if (window <= free_space - mss || window > free_space)
+                       window = (free_space/mss)*mss;
+       }

        return window;
 }



<Prev in Thread] Current Thread [Next in Thread>