tcp: avoid rcv wnd less than mss 59/26959/5
authorFlorin Coras <fcoras@cisco.com>
Fri, 8 May 2020 16:23:38 +0000 (16:23 +0000)
committerDave Barach <openvpp@barachs.net>
Tue, 12 May 2020 14:06:42 +0000 (14:06 +0000)
Type: fix

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I84ec1c91a3a7b2195aad58923fa6f17f551444cb

src/vnet/tcp/tcp_output.c

index a21c012..6bcca31 100644 (file)
@@ -143,13 +143,11 @@ tcp_update_rcv_wnd (tcp_connection_t * tc)
       wnd = available_space;
     }
 
-  /* Make sure we have a multiple of rcv_wscale */
+  /* Make sure we have a multiple of 1 << rcv_wscale. We round up to
+   * avoid advertising a window less than mss which could happen if
+   * 1 << rcv_wscale < mss */
   if (wnd && tc->rcv_wscale)
-    {
-      wnd &= ~((1 << tc->rcv_wscale) - 1);
-      if (wnd == 0)
-       wnd = 1 << tc->rcv_wscale;
-    }
+    wnd = round_pow2 (wnd, 1 << tc->rcv_wscale);
 
   tc->rcv_wnd = clib_min (wnd, TCP_WND_MAX << tc->rcv_wscale);
 }