]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/ipv4/tcp_output.c
xps: Improvements in TX queue selection
[net-next-2.6.git] / net / ipv4 / tcp_output.c
index de3bd84585881f99f8a23eb28fa9f380516d087c..5f29b2e20e23b524a218a6d2e5956f428509b69e 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
                 */
@@ -828,8 +822,11 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
                                                           &md5);
        tcp_header_size = tcp_options_size + sizeof(struct tcphdr);
 
-       if (tcp_packets_in_flight(tp) == 0)
+       if (tcp_packets_in_flight(tp) == 0) {
                tcp_ca_event(sk, CA_EVENT_TX_START);
+               skb->ooo_okay = 1;
+       } else
+               skb->ooo_okay = 0;
 
        skb_push(skb, tcp_header_size);
        skb_reset_transport_header(skb);
@@ -1376,9 +1373,9 @@ static inline int tcp_nagle_check(const struct tcp_sock *tp,
                                  const struct sk_buff *skb,
                                  unsigned mss_now, int nonagle)
 {
-       return (skb->len < mss_now &&
+       return skb->len < mss_now &&
                ((nonagle & TCP_NAGLE_CORK) ||
-                (!nonagle && tp->packets_out && tcp_minshall_check(tp))));
+                (!nonagle && tp->packets_out && tcp_minshall_check(tp)));
 }
 
 /* Return non-zero if the Nagle test allows this packet to be
@@ -1449,10 +1446,10 @@ int tcp_may_send_now(struct sock *sk)
        struct tcp_sock *tp = tcp_sk(sk);
        struct sk_buff *skb = tcp_send_head(sk);
 
-       return (skb &&
+       return skb &&
                tcp_snd_test(sk, skb, tcp_current_mss(sk),
                             (tcp_skb_is_last(sk, skb) ?
-                             tp->nonagle : TCP_NAGLE_PUSH)));
+                             tp->nonagle : TCP_NAGLE_PUSH));
 }
 
 /* Trim TSO SKB to LEN bytes, put the remaining data into a new packet
@@ -2429,6 +2426,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 +2558,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,
@@ -2587,6 +2595,7 @@ int tcp_connect(struct sock *sk)
 {
        struct tcp_sock *tp = tcp_sk(sk);
        struct sk_buff *buff;
+       int err;
 
        tcp_connect_init(sk);
 
@@ -2609,7 +2618,9 @@ int tcp_connect(struct sock *sk)
        sk->sk_wmem_queued += buff->truesize;
        sk_mem_charge(sk, buff->truesize);
        tp->packets_out += tcp_skb_pcount(buff);
-       tcp_transmit_skb(sk, buff, 1, sk->sk_allocation);
+       err = tcp_transmit_skb(sk, buff, 1, sk->sk_allocation);
+       if (err == -ECONNREFUSED)
+               return err;
 
        /* We change tp->snd_nxt after the tcp_transmit_skb() call
         * in order to make this packet get counted in tcpOutSegs.