tcp: better SYNACK sent timestamp
authorYuchung Cheng <ycheng@google.com>
Mon, 29 Apr 2019 22:46:15 +0000 (15:46 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 1 May 2019 15:47:54 +0000 (11:47 -0400)
Detecting spurious SYNACK timeout using timestamp option requires
recording the exact SYNACK skb timestamp. Previously the SYNACK
sent timestamp was stamped slightly earlier before the skb
was transmitted. This patch uses the SYNACK skb transmission
timestamp directly.

Signed-off-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/tcp_input.c
net/ipv4/tcp_output.c

index 695f840acc14c8ce7b86156c75773fd6e03176bb..30c6a42b1f5b49a5aacd5d32f2ee650c18d9f503 100644 (file)
@@ -6319,7 +6319,7 @@ static void tcp_openreq_init(struct request_sock *req,
        req->cookie_ts = 0;
        tcp_rsk(req)->rcv_isn = TCP_SKB_CB(skb)->seq;
        tcp_rsk(req)->rcv_nxt = TCP_SKB_CB(skb)->seq + 1;
-       tcp_rsk(req)->snt_synack = tcp_clock_us();
+       tcp_rsk(req)->snt_synack = 0;
        tcp_rsk(req)->last_oow_ack_time = 0;
        req->mss = rx_opt->mss_clamp;
        req->ts_recent = rx_opt->saw_tstamp ? rx_opt->rcv_tsval : 0;
index 32061928b054275c546dae1141f45f0717018c78..0c4ed66dc1bf3441a9b7e5c9c37692333c92f17c 100644 (file)
@@ -3247,7 +3247,11 @@ struct sk_buff *tcp_make_synack(const struct sock *sk, struct dst_entry *dst,
                skb->skb_mstamp_ns = cookie_init_timestamp(req);
        else
 #endif
+       {
                skb->skb_mstamp_ns = tcp_clock_ns();
+               if (!tcp_rsk(req)->snt_synack) /* Timestamp first SYNACK */
+                       tcp_rsk(req)->snt_synack = tcp_skb_timestamp_us(skb);
+       }
 
 #ifdef CONFIG_TCP_MD5SIG
        rcu_read_lock();