]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv4/tcp_output.c
[TCP]: Move code from tcp_ecn.h to tcp*.c and tcp.h & remove it
[linux-2.6-omap-h63xx.git] / net / ipv4 / tcp_output.c
index 0faacf9c419d5a888c8578d15e3f3c948edfb0b9..3abe22e4b57622ca6a6ecbca64dc54a2d34efed9 100644 (file)
@@ -40,7 +40,6 @@
 
 #include <linux/compiler.h>
 #include <linux/module.h>
-#include <linux/smp_lock.h>
 
 /* People can turn this off for buggy TCP's found in printers etc. */
 int sysctl_tcp_retrans_collapse __read_mostly = 1;
@@ -270,6 +269,56 @@ static u16 tcp_select_window(struct sock *sk)
        return new_win;
 }
 
+static inline void TCP_ECN_send_synack(struct tcp_sock *tp,
+                                      struct sk_buff *skb)
+{
+       TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_CWR;
+       if (!(tp->ecn_flags&TCP_ECN_OK))
+               TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_ECE;
+}
+
+static inline void TCP_ECN_send_syn(struct sock *sk, struct sk_buff *skb)
+{
+       struct tcp_sock *tp = tcp_sk(sk);
+
+       tp->ecn_flags = 0;
+       if (sysctl_tcp_ecn) {
+               TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_ECE|TCPCB_FLAG_CWR;
+               tp->ecn_flags = TCP_ECN_OK;
+       }
+}
+
+static __inline__ void
+TCP_ECN_make_synack(struct request_sock *req, struct tcphdr *th)
+{
+       if (inet_rsk(req)->ecn_ok)
+               th->ece = 1;
+}
+
+static inline void TCP_ECN_send(struct sock *sk, struct sk_buff *skb,
+                               int tcp_header_len)
+{
+       struct tcp_sock *tp = tcp_sk(sk);
+
+       if (tp->ecn_flags & TCP_ECN_OK) {
+               /* Not-retransmitted data segment: set ECT and inject CWR. */
+               if (skb->len != tcp_header_len &&
+                   !before(TCP_SKB_CB(skb)->seq, tp->snd_nxt)) {
+                       INET_ECN_xmit(sk);
+                       if (tp->ecn_flags&TCP_ECN_QUEUE_CWR) {
+                               tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR;
+                               tcp_hdr(skb)->cwr = 1;
+                               skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN;
+                       }
+               } else {
+                       /* ACK or retransmitted segment: clear ECT|CE */
+                       INET_ECN_dontxmit(sk);
+               }
+               if (tp->ecn_flags & TCP_ECN_DEMAND_CWR)
+                       tcp_hdr(skb)->ece = 1;
+       }
+}
+
 static void tcp_build_and_update_options(__be32 *ptr, struct tcp_sock *tp,
                                         __u32 tstamp, __u8 **md5_hash)
 {
@@ -700,6 +749,14 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss
                        tp->fackets_out -= diff;
                        if ((int)tp->fackets_out < 0)
                                tp->fackets_out = 0;
+                       /* SACK fastpath might overwrite it unless dealt with */
+                       if (tp->fastpath_skb_hint != NULL &&
+                           after(TCP_SKB_CB(tp->fastpath_skb_hint)->seq,
+                                 TCP_SKB_CB(skb)->seq)) {
+                               tp->fastpath_cnt_hint -= diff;
+                               if ((int)tp->fastpath_cnt_hint < 0)
+                                       tp->fastpath_cnt_hint = 0;
+                       }
                }
        }
 
@@ -1608,7 +1665,7 @@ u32 __tcp_select_window(struct sock *sk)
                if (window <= free_space - mss || window > free_space)
                        window = (free_space/mss)*mss;
                else if (mss == full_space &&
-                        free_space > window + full_space/2)
+                        free_space > window + full_space/2)
                        window = free_space;
        }
 
@@ -1938,33 +1995,28 @@ void tcp_xmit_retransmit_queue(struct sock *sk)
         * and retransmission... Both ways have their merits...
         *
         * For now we do not retransmit anything, while we have some new
-        * segments to send.
+        * segments to send. In the other cases, follow rule 3 for
+        * NextSeg() specified in RFC3517.
         */
 
        if (tcp_may_send_now(sk))
                return;
 
-       if (tp->forward_skb_hint) {
+       /* If nothing is SACKed, highest_sack in the loop won't be valid */
+       if (!tp->sacked_out)
+               return;
+
+       if (tp->forward_skb_hint)
                skb = tp->forward_skb_hint;
-               packet_cnt = tp->forward_cnt_hint;
-       } else{
+       else
                skb = tcp_write_queue_head(sk);
-               packet_cnt = 0;
-       }
 
        tcp_for_write_queue_from(skb, sk) {
                if (skb == tcp_send_head(sk))
                        break;
-               tp->forward_cnt_hint = packet_cnt;
                tp->forward_skb_hint = skb;
 
-               /* Similar to the retransmit loop above we
-                * can pretend that the retransmitted SKB
-                * we send out here will be composed of one
-                * real MSS sized packet because tcp_retransmit_skb()
-                * will fragment it if necessary.
-                */
-               if (++packet_cnt > tp->fackets_out)
+               if (after(TCP_SKB_CB(skb)->seq, tp->highest_sack))
                        break;
 
                if (tcp_packets_in_flight(tp) >= tp->snd_cwnd)