Skip to content

Commit 1935299

Browse files
gfreewinddavem330
authored andcommitted
net: tcp: Refine the __tcp_select_window
1. Move the "window = tp->rcv_wnd;" into the condition block without tp->rx_opt.rcv_wscale. Because it is unnecessary when enable wscale; 2. Use the macro ALIGN instead of two statements. The two statements are used to make window align to 1<<wscale. Use the ALIGN is more clearer. 3. Use the rounddown to make codes clearer. Signed-off-by: Gao Feng <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent bae76dd commit 1935299

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

net/ipv4/tcp_output.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2561,18 +2561,16 @@ u32 __tcp_select_window(struct sock *sk)
25612561
/* Don't do rounding if we are using window scaling, since the
25622562
* scaled window will not line up with the MSS boundary anyway.
25632563
*/
2564-
window = tp->rcv_wnd;
25652564
if (tp->rx_opt.rcv_wscale) {
25662565
window = free_space;
25672566

25682567
/* Advertise enough space so that it won't get scaled away.
25692568
* Import case: prevent zero window announcement if
25702569
* 1<<rcv_wscale > mss.
25712570
*/
2572-
if (((window >> tp->rx_opt.rcv_wscale) << tp->rx_opt.rcv_wscale) != window)
2573-
window = (((window >> tp->rx_opt.rcv_wscale) + 1)
2574-
<< tp->rx_opt.rcv_wscale);
2571+
window = ALIGN(window, (1 << tp->rx_opt.rcv_wscale));
25752572
} else {
2573+
window = tp->rcv_wnd;
25762574
/* Get the largest window that is a nice multiple of mss.
25772575
* Window clamp already applied above.
25782576
* If our current window offering is within 1 mss of the
@@ -2582,7 +2580,7 @@ u32 __tcp_select_window(struct sock *sk)
25822580
* is too small.
25832581
*/
25842582
if (window <= free_space - mss || window > free_space)
2585-
window = (free_space / mss) * mss;
2583+
window = rounddown(free_space, mss);
25862584
else if (mss == full_space &&
25872585
free_space > window + (full_space >> 1))
25882586
window = free_space;

0 commit comments

Comments
 (0)