net-timestamp: TCP timestamping
[cascardo/linux.git] / net / ipv4 / tcp_offload.c
index 55046ec..f597119 100644 (file)
 #include <net/tcp.h>
 #include <net/protocol.h>
 
+void tcp_gso_tstamp(struct sk_buff *skb, unsigned int ts_seq, unsigned int seq,
+                   unsigned int mss)
+{
+       while (skb) {
+               if (ts_seq < (__u64) seq + mss) {
+                       skb_shinfo(skb)->tx_flags = SKBTX_SW_TSTAMP;
+                       skb_shinfo(skb)->tskey = ts_seq;
+                       return;
+               }
+
+               skb = skb->next;
+               seq += mss;
+       }
+}
+
 struct sk_buff *tcp_gso_segment(struct sk_buff *skb,
                                netdev_features_t features)
 {
@@ -91,6 +106,9 @@ struct sk_buff *tcp_gso_segment(struct sk_buff *skb,
        th = tcp_hdr(skb);
        seq = ntohl(th->seq);
 
+       if (unlikely(skb_shinfo(gso_skb)->tx_flags & SKBTX_SW_TSTAMP))
+               tcp_gso_tstamp(segs, skb_shinfo(gso_skb)->tskey, seq, mss);
+
        newcheck = ~csum_fold((__force __wsum)((__force u32)th->check +
                                               (__force u32)delta));