diff options
author | Gao Feng <fgao@ikuai8.com> | 2017-04-04 09:09:48 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-04-05 10:50:32 -0400 |
commit | 589c49cbf9674808fd4ac9b7c17155abc0686f86 (patch) | |
tree | 7065ecc4a28f72a6fd73570a0b793d92fee62e88 /net/ipv4/tcp_output.c | |
parent | 5e351410667ab0bf0dd1845730cba8b2211781e7 (diff) |
net: tcp: Define the TCP_MAX_WSCALE instead of literal number 14
Define one new macro TCP_MAX_WSCALE instead of literal number '14',
and use U16_MAX instead of 65535 as the max value of TCP window.
There is another minor change, use rounddown(space, mss) instead of
(space / mss) * mss;
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 | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 13971942211b..0e807a83c1bc 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -212,12 +212,12 @@ void tcp_select_initial_window(int __space, __u32 mss, | |||
212 | 212 | ||
213 | /* If no clamp set the clamp to the max possible scaled window */ | 213 | /* If no clamp set the clamp to the max possible scaled window */ |
214 | if (*window_clamp == 0) | 214 | if (*window_clamp == 0) |
215 | (*window_clamp) = (65535 << 14); | 215 | (*window_clamp) = (U16_MAX << TCP_MAX_WSCALE); |
216 | space = min(*window_clamp, space); | 216 | space = min(*window_clamp, space); |
217 | 217 | ||
218 | /* Quantize space offering to a multiple of mss if possible. */ | 218 | /* Quantize space offering to a multiple of mss if possible. */ |
219 | if (space > mss) | 219 | if (space > mss) |
220 | space = (space / mss) * mss; | 220 | space = rounddown(space, mss); |
221 | 221 | ||
222 | /* NOTE: offering an initial window larger than 32767 | 222 | /* NOTE: offering an initial window larger than 32767 |
223 | * will break some buggy TCP stacks. If the admin tells us | 223 | * will break some buggy TCP stacks. If the admin tells us |
@@ -234,13 +234,11 @@ void tcp_select_initial_window(int __space, __u32 mss, | |||
234 | 234 | ||
235 | (*rcv_wscale) = 0; | 235 | (*rcv_wscale) = 0; |
236 | if (wscale_ok) { | 236 | if (wscale_ok) { |
237 | /* Set window scaling on max possible window | 237 | /* Set window scaling on max possible window */ |
238 | * See RFC1323 for an explanation of the limit to 14 | ||
239 | */ | ||
240 | space = max_t(u32, space, sysctl_tcp_rmem[2]); | 238 | space = max_t(u32, space, sysctl_tcp_rmem[2]); |
241 | space = max_t(u32, space, sysctl_rmem_max); | 239 | space = max_t(u32, space, sysctl_rmem_max); |
242 | space = min_t(u32, space, *window_clamp); | 240 | space = min_t(u32, space, *window_clamp); |
243 | while (space > 65535 && (*rcv_wscale) < 14) { | 241 | while (space > U16_MAX && (*rcv_wscale) < TCP_MAX_WSCALE) { |
244 | space >>= 1; | 242 | space >>= 1; |
245 | (*rcv_wscale)++; | 243 | (*rcv_wscale)++; |
246 | } | 244 | } |
@@ -253,7 +251,7 @@ void tcp_select_initial_window(int __space, __u32 mss, | |||
253 | } | 251 | } |
254 | 252 | ||
255 | /* Set the clamp no higher than max representable value */ | 253 | /* Set the clamp no higher than max representable value */ |
256 | (*window_clamp) = min(65535U << (*rcv_wscale), *window_clamp); | 254 | (*window_clamp) = min_t(__u32, U16_MAX << (*rcv_wscale), *window_clamp); |
257 | } | 255 | } |
258 | EXPORT_SYMBOL(tcp_select_initial_window); | 256 | EXPORT_SYMBOL(tcp_select_initial_window); |
259 | 257 | ||