aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_output.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/tcp_output.c')
-rw-r--r--net/ipv4/tcp_output.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index de3bd8458588..7abecf73add9 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -237,11 +237,10 @@ void tcp_select_initial_window(int __space, __u32 mss,
237 /* when initializing use the value from init_rcv_wnd 237 /* when initializing use the value from init_rcv_wnd
238 * rather than the default from above 238 * rather than the default from above
239 */ 239 */
240 if (init_rcv_wnd && 240 if (init_rcv_wnd)
241 (*rcv_wnd > init_rcv_wnd * mss)) 241 *rcv_wnd = min(*rcv_wnd, init_rcv_wnd * mss);
242 *rcv_wnd = init_rcv_wnd * mss; 242 else
243 else if (*rcv_wnd > init_cwnd * mss) 243 *rcv_wnd = min(*rcv_wnd, init_cwnd * mss);
244 *rcv_wnd = init_cwnd * mss;
245 } 244 }
246 245
247 /* Set the clamp no higher than max representable value */ 246 /* Set the clamp no higher than max representable value */
@@ -392,27 +391,30 @@ struct tcp_out_options {
392 */ 391 */
393static u8 tcp_cookie_size_check(u8 desired) 392static u8 tcp_cookie_size_check(u8 desired)
394{ 393{
395 if (desired > 0) { 394 int cookie_size;
395
396 if (desired > 0)
396 /* previously specified */ 397 /* previously specified */
397 return desired; 398 return desired;
398 } 399
399 if (sysctl_tcp_cookie_size <= 0) { 400 cookie_size = ACCESS_ONCE(sysctl_tcp_cookie_size);
401 if (cookie_size <= 0)
400 /* no default specified */ 402 /* no default specified */
401 return 0; 403 return 0;
402 } 404
403 if (sysctl_tcp_cookie_size <= TCP_COOKIE_MIN) { 405 if (cookie_size <= TCP_COOKIE_MIN)
404 /* value too small, specify minimum */ 406 /* value too small, specify minimum */
405 return TCP_COOKIE_MIN; 407 return TCP_COOKIE_MIN;
406 } 408
407 if (sysctl_tcp_cookie_size >= TCP_COOKIE_MAX) { 409 if (cookie_size >= TCP_COOKIE_MAX)
408 /* value too large, specify maximum */ 410 /* value too large, specify maximum */
409 return TCP_COOKIE_MAX; 411 return TCP_COOKIE_MAX;
410 } 412
411 if (0x1 & sysctl_tcp_cookie_size) { 413 if (cookie_size & 1)
412 /* 8-bit multiple, illegal, fix it */ 414 /* 8-bit multiple, illegal, fix it */
413 return (u8)(sysctl_tcp_cookie_size + 0x1); 415 cookie_size++;
414 } 416
415 return (u8)sysctl_tcp_cookie_size; 417 return (u8)cookie_size;
416} 418}
417 419
418/* Write previously computed TCP options to the packet. 420/* Write previously computed TCP options to the packet.
@@ -1519,6 +1521,7 @@ static int tcp_tso_should_defer(struct sock *sk, struct sk_buff *skb)
1519 struct tcp_sock *tp = tcp_sk(sk); 1521 struct tcp_sock *tp = tcp_sk(sk);
1520 const struct inet_connection_sock *icsk = inet_csk(sk); 1522 const struct inet_connection_sock *icsk = inet_csk(sk);
1521 u32 send_win, cong_win, limit, in_flight; 1523 u32 send_win, cong_win, limit, in_flight;
1524 int win_divisor;
1522 1525
1523 if (TCP_SKB_CB(skb)->flags & TCPHDR_FIN) 1526 if (TCP_SKB_CB(skb)->flags & TCPHDR_FIN)
1524 goto send_now; 1527 goto send_now;
@@ -1550,13 +1553,14 @@ static int tcp_tso_should_defer(struct sock *sk, struct sk_buff *skb)
1550 if ((skb != tcp_write_queue_tail(sk)) && (limit >= skb->len)) 1553 if ((skb != tcp_write_queue_tail(sk)) && (limit >= skb->len))
1551 goto send_now; 1554 goto send_now;
1552 1555
1553 if (sysctl_tcp_tso_win_divisor) { 1556 win_divisor = ACCESS_ONCE(sysctl_tcp_tso_win_divisor);
1557 if (win_divisor) {
1554 u32 chunk = min(tp->snd_wnd, tp->snd_cwnd * tp->mss_cache); 1558 u32 chunk = min(tp->snd_wnd, tp->snd_cwnd * tp->mss_cache);
1555 1559
1556 /* If at least some fraction of a window is available, 1560 /* If at least some fraction of a window is available,
1557 * just use it. 1561 * just use it.
1558 */ 1562 */
1559 chunk /= sysctl_tcp_tso_win_divisor; 1563 chunk /= win_divisor;
1560 if (limit >= chunk) 1564 if (limit >= chunk)
1561 goto send_now; 1565 goto send_now;
1562 } else { 1566 } else {