tcp: don't use timestamp from repaired skb-s to calculate RTT (v2)
[pandora-kernel.git] / net / ipv4 / tcp_output.c
index 179b51e..ff3f0f7 100644 (file)
@@ -916,6 +916,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
        skb_orphan(skb);
        skb->sk = sk;
        skb->destructor = tcp_wfree;
+       skb_set_hash_from_sk(skb, sk);
        atomic_add(skb->truesize, &sk->sk_wmem_alloc);
 
        /* Build TCP header and checksum it. */
@@ -978,7 +979,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
        if (likely(err <= 0))
                return err;
 
-       tcp_enter_cwr(sk, 1);
+       tcp_enter_cwr(sk);
 
        return net_xmit_eval(err);
 }
@@ -1068,6 +1069,21 @@ static void tcp_adjust_pcount(struct sock *sk, const struct sk_buff *skb, int de
        tcp_verify_left_out(tp);
 }
 
+static void tcp_fragment_tstamp(struct sk_buff *skb, struct sk_buff *skb2)
+{
+       struct skb_shared_info *shinfo = skb_shinfo(skb);
+
+       if (unlikely(shinfo->tx_flags & SKBTX_ANY_TSTAMP) &&
+           !before(shinfo->tskey, TCP_SKB_CB(skb2)->seq)) {
+               struct skb_shared_info *shinfo2 = skb_shinfo(skb2);
+               u8 tsflags = shinfo->tx_flags & SKBTX_ANY_TSTAMP;
+
+               shinfo->tx_flags &= ~tsflags;
+               shinfo2->tx_flags |= tsflags;
+               swap(shinfo->tskey, shinfo2->tskey);
+       }
+}
+
 /* Function to create two new TCP segments.  Shrinks the given segment
  * to the specified size and appends a new segment with the rest of the
  * packet to the list.  This won't be called frequently, I hope.
@@ -1135,6 +1151,7 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len,
         */
        TCP_SKB_CB(buff)->when = TCP_SKB_CB(skb)->when;
        buff->tstamp = skb->tstamp;
+       tcp_fragment_tstamp(skb, buff);
 
        old_factor = tcp_skb_pcount(skb);
 
@@ -1651,6 +1668,7 @@ static int tso_fragment(struct sock *sk, struct sk_buff *skb, unsigned int len,
 
        buff->ip_summed = skb->ip_summed = CHECKSUM_PARTIAL;
        skb_split(skb, buff, len);
+       tcp_fragment_tstamp(skb, buff);
 
        /* Fix up tso_factor for both original and new SKB.  */
        tcp_set_skb_tso_segs(sk, skb, mss_now);
@@ -1916,8 +1934,11 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
                tso_segs = tcp_init_tso_segs(sk, skb, mss_now);
                BUG_ON(!tso_segs);
 
-               if (unlikely(tp->repair) && tp->repair_queue == TCP_SEND_QUEUE)
+               if (unlikely(tp->repair) && tp->repair_queue == TCP_SEND_QUEUE) {
+                       /* "when" is used as a start point for the retransmit timer */
+                       TCP_SKB_CB(skb)->when = tcp_time_stamp;
                        goto repair; /* Skip network transmission */
+               }
 
                cwnd_quota = tcp_cwnd_test(tp, skb);
                if (!cwnd_quota) {
@@ -3301,3 +3322,18 @@ void tcp_send_probe0(struct sock *sk)
                                          TCP_RTO_MAX);
        }
 }
+
+int tcp_rtx_synack(struct sock *sk, struct request_sock *req)
+{
+       const struct tcp_request_sock_ops *af_ops = tcp_rsk(req)->af_specific;
+       struct flowi fl;
+       int res;
+
+       res = af_ops->send_synack(sk, NULL, &fl, req, 0, NULL);
+       if (!res) {
+               TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_RETRANSSEGS);
+               NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPSYNRETRANS);
+       }
+       return res;
+}
+EXPORT_SYMBOL(tcp_rtx_synack);