aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_input.c
diff options
context:
space:
mode:
authorYuchung Cheng <ycheng@google.com>2013-07-22 19:20:45 -0400
committerDavid S. Miller <davem@davemloft.net>2013-07-22 20:53:42 -0400
commit375fe02c91792917aa26d68a87ab110d1937f44e (patch)
tree2a6c1205f6b136f7ac55f191912b386a0f3b2491 /net/ipv4/tcp_input.c
parentc3f51d5f387b552b9d9fd7f41e19b84929712f82 (diff)
tcp: consolidate SYNACK RTT sampling
The first patch consolidates SYNACK and other RTT measurement to use a central function tcp_ack_update_rtt(). A (small) bonus is now SYNACK RTT measurement happens after PAWS check, potentially reducing the impact of RTO seeding on bad TCP timestamps values. Signed-off-by: Yuchung Cheng <ycheng@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, 12 insertions, 2 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 28af45abe062..b531710596ec 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -2853,6 +2853,17 @@ static inline void tcp_ack_update_rtt(struct sock *sk, const int flag,
2853 tcp_ack_no_tstamp(sk, seq_rtt, flag); 2853 tcp_ack_no_tstamp(sk, seq_rtt, flag);
2854} 2854}
2855 2855
2856/* Compute time elapsed between (last) SYNACK and the ACK completing 3WHS. */
2857static void tcp_synack_rtt_meas(struct sock *sk, struct request_sock *req)
2858{
2859 struct tcp_sock *tp = tcp_sk(sk);
2860 s32 seq_rtt = -1;
2861
2862 if (tp->lsndtime && !tp->total_retrans)
2863 seq_rtt = tcp_time_stamp - tp->lsndtime;
2864 tcp_ack_update_rtt(sk, FLAG_SYN_ACKED, seq_rtt);
2865}
2866
2856static void tcp_cong_avoid(struct sock *sk, u32 ack, u32 in_flight) 2867static void tcp_cong_avoid(struct sock *sk, u32 ack, u32 in_flight)
2857{ 2868{
2858 const struct inet_connection_sock *icsk = inet_csk(sk); 2869 const struct inet_connection_sock *icsk = inet_csk(sk);
@@ -5624,9 +5635,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
5624 * so release it. 5635 * so release it.
5625 */ 5636 */
5626 if (req) { 5637 if (req) {
5627 tcp_synack_rtt_meas(sk, req);
5628 tp->total_retrans = req->num_retrans; 5638 tp->total_retrans = req->num_retrans;
5629
5630 reqsk_fastopen_remove(sk, req, false); 5639 reqsk_fastopen_remove(sk, req, false);
5631 } else { 5640 } else {
5632 /* Make sure socket is routed, for correct metrics. */ 5641 /* Make sure socket is routed, for correct metrics. */
@@ -5651,6 +5660,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
5651 tp->snd_una = TCP_SKB_CB(skb)->ack_seq; 5660 tp->snd_una = TCP_SKB_CB(skb)->ack_seq;
5652 tp->snd_wnd = ntohs(th->window) << tp->rx_opt.snd_wscale; 5661 tp->snd_wnd = ntohs(th->window) << tp->rx_opt.snd_wscale;
5653 tcp_init_wl(tp, TCP_SKB_CB(skb)->seq); 5662 tcp_init_wl(tp, TCP_SKB_CB(skb)->seq);
5663 tcp_synack_rtt_meas(sk, req);
5654 5664
5655 if (tp->rx_opt.tstamp_ok) 5665 if (tp->rx_opt.tstamp_ok)
5656 tp->advmss -= TCPOLEN_TSTAMP_ALIGNED; 5666 tp->advmss -= TCPOLEN_TSTAMP_ALIGNED;