diff options
author | Gao Feng <fgao@ikuai8.com> | 2017-03-29 18:49:19 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-03-30 18:41:32 -0400 |
commit | 1935299d9c946ac37eba3f820d2ce20885ec0739 (patch) | |
tree | ccdac1cedab8d57aa7cfbfbf6e16fbd65d1041db /net/ipv4/tcp_output.c | |
parent | bae76dd95b69350f6342d8a4ea1bdeec4c218053 (diff) |
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 <fgao@ikuai8.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_output.c')
-rw-r--r-- | net/ipv4/tcp_output.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 22548b5f05cb..13971942211b 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -2561,7 +2561,6 @@ u32 __tcp_select_window(struct sock *sk) | |||
2561 | /* Don't do rounding if we are using window scaling, since the | 2561 | /* Don't do rounding if we are using window scaling, since the |
2562 | * scaled window will not line up with the MSS boundary anyway. | 2562 | * scaled window will not line up with the MSS boundary anyway. |
2563 | */ | 2563 | */ |
2564 | window = tp->rcv_wnd; | ||
2565 | if (tp->rx_opt.rcv_wscale) { | 2564 | if (tp->rx_opt.rcv_wscale) { |
2566 | window = free_space; | 2565 | window = free_space; |
2567 | 2566 | ||
@@ -2569,10 +2568,9 @@ u32 __tcp_select_window(struct sock *sk) | |||
2569 | * Import case: prevent zero window announcement if | 2568 | * Import case: prevent zero window announcement if |
2570 | * 1<<rcv_wscale > mss. | 2569 | * 1<<rcv_wscale > mss. |
2571 | */ | 2570 | */ |
2572 | if (((window >> tp->rx_opt.rcv_wscale) << tp->rx_opt.rcv_wscale) != window) | 2571 | window = ALIGN(window, (1 << tp->rx_opt.rcv_wscale)); |
2573 | window = (((window >> tp->rx_opt.rcv_wscale) + 1) | ||
2574 | << tp->rx_opt.rcv_wscale); | ||
2575 | } else { | 2572 | } else { |
2573 | window = tp->rcv_wnd; | ||
2576 | /* Get the largest window that is a nice multiple of mss. | 2574 | /* Get the largest window that is a nice multiple of mss. |
2577 | * Window clamp already applied above. | 2575 | * Window clamp already applied above. |
2578 | * If our current window offering is within 1 mss of the | 2576 | * If our current window offering is within 1 mss of the |
@@ -2582,7 +2580,7 @@ u32 __tcp_select_window(struct sock *sk) | |||
2582 | * is too small. | 2580 | * is too small. |
2583 | */ | 2581 | */ |
2584 | if (window <= free_space - mss || window > free_space) | 2582 | if (window <= free_space - mss || window > free_space) |
2585 | window = (free_space / mss) * mss; | 2583 | window = rounddown(free_space, mss); |
2586 | else if (mss == full_space && | 2584 | else if (mss == full_space && |
2587 | free_space > window + (full_space >> 1)) | 2585 | free_space > window + (full_space >> 1)) |
2588 | window = free_space; | 2586 | window = free_space; |