lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] Wrong value of the initial window (SYN packets) with big TC


From: Dmitry Adamushko
Subject: [lwip-devel] Wrong value of the initial window (SYN packets) with big TCP_WND and window scaling.
Date: Thu, 9 Jul 2015 15:24:52 +0200

Hi,

When TCP_WND is set to (for example) 1MiB, the initially advertised window in SYN packets ends up being 0. Would the fix below be sufficient?

Note: It should be 32KiB if we want to be cautious about (rare cases?) TCP stacks interpreting 'window-size' as a signed value. However, I see that setting TCP_WND to values bigger than 32KiB is supported even without window scaling (according to existing checks for TCP_WND in src/core/init.c), hence I used 64KiB.

--- a/src/core/tcp_out.c
+++ b/src/core/tcp_out.c
@@ -1141,7 +1141,7 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
   if (seg->flags & TF_SEG_OPTS_WND_SCALE) {
     /* The Window field in a SYN segment itself (the only type where we send
        the window scale option) is never scaled. */
-    seg->tcphdr->wnd = htons(pcb->rcv_ann_wnd);
+    seg->tcphdr->wnd = htons(LWIP_MIN(pcb->rcv_ann_wnd, 65535U));
   } else
 #endif /* LWIP_WND_SCALE */
   {


-- Dmitry

Attachment: lwip-set_initial_window.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]