Hi all,

While I read __tcp_select_window() code, I find that it maybe return a
smaller window.
Below is one scenario I thought, may be not right:
In function __tcp_select_window(), assume:
full_space is 6mss, free_space is 2mss, tp->rcv_wnd is 3MSS.
And assume disable window scaling, then
window = tp->rcv_wnd > free_space && window > free_space
then it will round down free_space and return it.

Is this expected behavior? The comment is also saying
"Get the largest window that is a nice multiple of mss."

Should we do something like below ? Or I miss something?
I don't know how to verify it now.

--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2680,9 +2680,9 @@ u32 __tcp_select_window(struct sock *sk)
                 * We also don't do any window rounding when the free space
                 * is too small.
-               if (window <= free_space - mss || window > free_space)
+               if (window <= free_space - mss)
                        window = rounddown(free_space, mss);
-               else if (mss == full_space &&
+               else if (window <= free_space && mss == full_space &&
                         free_space > window + (full_space >> 1))
                        window = free_space;


Reply via email to