]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/ipv4/tcp_output.c
tcp: update also tcp_output with regard to RFC 5681
[net-next-2.6.git] / net / ipv4 / tcp_output.c
index de3bd84585881f99f8a23eb28fa9f380516d087c..ea09d2fd50c794a3f04a7178cb7f54cb58c42e2a 100644 (file)
@@ -224,16 +224,10 @@ void tcp_select_initial_window(int __space, __u32 mss,
                }
        }
 
-       /* Set initial window to value enough for senders,
-        * following RFC2414. Senders, not following this RFC,
-        * will be satisfied with 2.
-        */
+       /* Set initial window to value enough for senders, following RFC5681. */
        if (mss > (1 << *rcv_wscale)) {
-               int init_cwnd = 4;
-               if (mss > 1460 * 3)
-                       init_cwnd = 2;
-               else if (mss > 1460)
-                       init_cwnd = 3;
+               int init_cwnd = rfc3390_bytes_to_packets(mss);
+
                /* when initializing use the value from init_rcv_wnd
                 * rather than the default from above
                 */
@@ -2429,6 +2423,12 @@ struct sk_buff *tcp_make_synack(struct sock *sk, struct dst_entry *dst,
                __u8 rcv_wscale;
                /* Set this up on the first call only */
                req->window_clamp = tp->window_clamp ? : dst_metric(dst, RTAX_WINDOW);
+
+               /* limit the window selection if the user enforce a smaller rx buffer */
+               if (sk->sk_userlocks & SOCK_RCVBUF_LOCK &&
+                   (req->window_clamp > tcp_full_space(sk) || req->window_clamp == 0))
+                       req->window_clamp = tcp_full_space(sk);
+
                /* tcp_full_space because it is guaranteed to be the first packet */
                tcp_select_initial_window(tcp_full_space(sk),
                        mss - (ireq->tstamp_ok ? TCPOLEN_TSTAMP_ALIGNED : 0),
@@ -2555,6 +2555,11 @@ static void tcp_connect_init(struct sock *sk)
 
        tcp_initialize_rcv_mss(sk);
 
+       /* limit the window selection if the user enforce a smaller rx buffer */
+       if (sk->sk_userlocks & SOCK_RCVBUF_LOCK &&
+           (tp->window_clamp > tcp_full_space(sk) || tp->window_clamp == 0))
+               tp->window_clamp = tcp_full_space(sk);
+
        tcp_select_initial_window(tcp_full_space(sk),
                                  tp->advmss - (tp->rx_opt.ts_recent_stamp ? tp->tcp_header_len - sizeof(struct tcphdr) : 0),
                                  &tp->rcv_wnd,