aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_input.c
diff options
context:
space:
mode:
authorWei Wang <weiwan@google.com>2018-06-20 00:42:50 -0400
committerDavid S. Miller <davem@davemloft.net>2018-06-22 00:45:01 -0400
commit3f6c65d6255a872846c44182c82c78d3dc6239f5 (patch)
tree7dabd565296b1e797140820da5205e4c0f60aae2 /net/ipv4/tcp_input.c
parent66caeeb99d0db139c894b1b650546c982701aa27 (diff)
tcp: ignore rcv_rtt sample with old ts ecr value
When receiving multiple packets with the same ts ecr value, only try to compute rcv_rtt sample with the earliest received packet. This is because the rcv_rtt calculated by later received packets could possibly include long idle time or other types of delay. For example: (1) server sends last packet of reply with TS val V1 (2) client ACKs last packet of reply with TS ecr V1 (3) long idle time passes (4) client sends next request data packet with TS ecr V1 (again!) At this time, the rcv_rtt computed on server with TS ecr V1 will be inflated with the idle time and should get ignored. Signed-off-by: Wei Wang <weiwan@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>
Diffstat (limited to 'net/ipv4/tcp_input.c')
-rw-r--r--net/ipv4/tcp_input.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 355d3dffd021..76ca88f63b70 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -582,9 +582,12 @@ static inline void tcp_rcv_rtt_measure_ts(struct sock *sk,
582{ 582{
583 struct tcp_sock *tp = tcp_sk(sk); 583 struct tcp_sock *tp = tcp_sk(sk);
584 584
585 if (tp->rx_opt.rcv_tsecr && 585 if (tp->rx_opt.rcv_tsecr == tp->rcv_rtt_last_tsecr)
586 (TCP_SKB_CB(skb)->end_seq - 586 return;
587 TCP_SKB_CB(skb)->seq >= inet_csk(sk)->icsk_ack.rcv_mss)) { 587 tp->rcv_rtt_last_tsecr = tp->rx_opt.rcv_tsecr;
588
589 if (TCP_SKB_CB(skb)->end_seq -
590 TCP_SKB_CB(skb)->seq >= inet_csk(sk)->icsk_ack.rcv_mss) {
588 u32 delta = tcp_time_stamp(tp) - tp->rx_opt.rcv_tsecr; 591 u32 delta = tcp_time_stamp(tp) - tp->rx_opt.rcv_tsecr;
589 u32 delta_us; 592 u32 delta_us;
590 593
@@ -5475,6 +5478,11 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb)
5475 tcp_ack(sk, skb, 0); 5478 tcp_ack(sk, skb, 0);
5476 __kfree_skb(skb); 5479 __kfree_skb(skb);
5477 tcp_data_snd_check(sk); 5480 tcp_data_snd_check(sk);
5481 /* When receiving pure ack in fast path, update
5482 * last ts ecr directly instead of calling
5483 * tcp_rcv_rtt_measure_ts()
5484 */
5485 tp->rcv_rtt_last_tsecr = tp->rx_opt.rcv_tsecr;
5478 return; 5486 return;
5479 } else { /* Header too small */ 5487 } else { /* Header too small */
5480 TCP_INC_STATS(sock_net(sk), TCP_MIB_INERRS); 5488 TCP_INC_STATS(sock_net(sk), TCP_MIB_INERRS);