diff options
Diffstat (limited to 'net/ipv4/tcp_output.c')
-rw-r--r-- | net/ipv4/tcp_output.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index de3bd8458588..05b1ecf36763 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -224,16 +224,10 @@ void tcp_select_initial_window(int __space, __u32 mss, | |||
224 | } | 224 | } |
225 | } | 225 | } |
226 | 226 | ||
227 | /* Set initial window to value enough for senders, | 227 | /* Set initial window to value enough for senders, following RFC5681. */ |
228 | * following RFC2414. Senders, not following this RFC, | ||
229 | * will be satisfied with 2. | ||
230 | */ | ||
231 | if (mss > (1 << *rcv_wscale)) { | 228 | if (mss > (1 << *rcv_wscale)) { |
232 | int init_cwnd = 4; | 229 | int init_cwnd = rfc3390_bytes_to_packets(mss); |
233 | if (mss > 1460 * 3) | 230 | |
234 | init_cwnd = 2; | ||
235 | else if (mss > 1460) | ||
236 | init_cwnd = 3; | ||
237 | /* when initializing use the value from init_rcv_wnd | 231 | /* when initializing use the value from init_rcv_wnd |
238 | * rather than the default from above | 232 | * rather than the default from above |
239 | */ | 233 | */ |
@@ -1376,9 +1370,9 @@ static inline int tcp_nagle_check(const struct tcp_sock *tp, | |||
1376 | const struct sk_buff *skb, | 1370 | const struct sk_buff *skb, |
1377 | unsigned mss_now, int nonagle) | 1371 | unsigned mss_now, int nonagle) |
1378 | { | 1372 | { |
1379 | return (skb->len < mss_now && | 1373 | return skb->len < mss_now && |
1380 | ((nonagle & TCP_NAGLE_CORK) || | 1374 | ((nonagle & TCP_NAGLE_CORK) || |
1381 | (!nonagle && tp->packets_out && tcp_minshall_check(tp)))); | 1375 | (!nonagle && tp->packets_out && tcp_minshall_check(tp))); |
1382 | } | 1376 | } |
1383 | 1377 | ||
1384 | /* Return non-zero if the Nagle test allows this packet to be | 1378 | /* Return non-zero if the Nagle test allows this packet to be |
@@ -1449,10 +1443,10 @@ int tcp_may_send_now(struct sock *sk) | |||
1449 | struct tcp_sock *tp = tcp_sk(sk); | 1443 | struct tcp_sock *tp = tcp_sk(sk); |
1450 | struct sk_buff *skb = tcp_send_head(sk); | 1444 | struct sk_buff *skb = tcp_send_head(sk); |
1451 | 1445 | ||
1452 | return (skb && | 1446 | return skb && |
1453 | tcp_snd_test(sk, skb, tcp_current_mss(sk), | 1447 | tcp_snd_test(sk, skb, tcp_current_mss(sk), |
1454 | (tcp_skb_is_last(sk, skb) ? | 1448 | (tcp_skb_is_last(sk, skb) ? |
1455 | tp->nonagle : TCP_NAGLE_PUSH))); | 1449 | tp->nonagle : TCP_NAGLE_PUSH)); |
1456 | } | 1450 | } |
1457 | 1451 | ||
1458 | /* Trim TSO SKB to LEN bytes, put the remaining data into a new packet | 1452 | /* Trim TSO SKB to LEN bytes, put the remaining data into a new packet |
@@ -2429,6 +2423,12 @@ struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst, | |||
2429 | __u8 rcv_wscale; | 2423 | __u8 rcv_wscale; |
2430 | /* Set this up on the first call only */ | 2424 | /* Set this up on the first call only */ |
2431 | req->window_clamp = tp->window_clamp ? : dst_metric(dst, RTAX_WINDOW); | 2425 | req->window_clamp = tp->window_clamp ? : dst_metric(dst, RTAX_WINDOW); |
2426 | |||
2427 | /* limit the window selection if the user enforce a smaller rx buffer */ | ||
2428 | if (sk->sk_userlocks & SOCK_RCVBUF_LOCK && | ||
2429 | (req->window_clamp > tcp_full_space(sk) || req->window_clamp == 0)) | ||
2430 | req->window_clamp = tcp_full_space(sk); | ||
2431 | |||
2432 | /* tcp_full_space because it is guaranteed to be the first packet */ | 2432 | /* tcp_full_space because it is guaranteed to be the first packet */ |
2433 | tcp_select_initial_window(tcp_full_space(sk), | 2433 | tcp_select_initial_window(tcp_full_space(sk), |
2434 | mss - (ireq->tstamp_ok ? TCPOLEN_TSTAMP_ALIGNED : 0), | 2434 | mss - (ireq->tstamp_ok ? TCPOLEN_TSTAMP_ALIGNED : 0), |
@@ -2555,6 +2555,11 @@ static void tcp_connect_init(struct sock *sk) | |||
2555 | 2555 | ||
2556 | tcp_initialize_rcv_mss(sk); | 2556 | tcp_initialize_rcv_mss(sk); |
2557 | 2557 | ||
2558 | /* limit the window selection if the user enforce a smaller rx buffer */ | ||
2559 | if (sk->sk_userlocks & SOCK_RCVBUF_LOCK && | ||
2560 | (tp->window_clamp > tcp_full_space(sk) || tp->window_clamp == 0)) | ||
2561 | tp->window_clamp = tcp_full_space(sk); | ||
2562 | |||
2558 | tcp_select_initial_window(tcp_full_space(sk), | 2563 | tcp_select_initial_window(tcp_full_space(sk), |
2559 | tp->advmss - (tp->rx_opt.ts_recent_stamp ? tp->tcp_header_len - sizeof(struct tcphdr) : 0), | 2564 | tp->advmss - (tp->rx_opt.ts_recent_stamp ? tp->tcp_header_len - sizeof(struct tcphdr) : 0), |
2560 | &tp->rcv_wnd, | 2565 | &tp->rcv_wnd, |