summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2017-04-25 13:15:32 -0400
committerDavid S. Miller <davem@davemloft.net>2017-04-26 14:44:36 -0400
commit69e996c58a35db9ca79b3f021a15bcd22202e1c0 (patch)
treeb01b75a8c41fe86ab2ce1fc88198c4f347268171
parent038a3e858de4e3ddf42c330a22b7efcddbc0a81a (diff)
tcp: add tp->tcp_mstamp field
We want to use precise timestamps in TCP stack, but we do not want to call possibly expensive kernel time services too often. tp->tcp_mstamp is guaranteed to be updated once per incoming packet. We will use it in the following patches, removing specific skb_mstamp_get() calls, and removing ack_time from struct tcp_sacktag_state. Signed-off-by: Eric Dumazet <edumazet@google.com> Acked-by: Soheil Hassas Yeganeh <soheil@google.com> Acked-by: Neal Cardwell <ncardwell@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/tcp.h1
-rw-r--r--net/ipv4/tcp_input.c3
2 files changed, 4 insertions, 0 deletions
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index cbe5b602a2d3..99a22f44c32e 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -240,6 +240,7 @@ struct tcp_sock {
240 u32 tlp_high_seq; /* snd_nxt at the time of TLP retransmit. */ 240 u32 tlp_high_seq; /* snd_nxt at the time of TLP retransmit. */
241 241
242/* RTT measurement */ 242/* RTT measurement */
243 struct skb_mstamp tcp_mstamp; /* most recent packet received/sent */
243 u32 srtt_us; /* smoothed round trip time << 3 in usecs */ 244 u32 srtt_us; /* smoothed round trip time << 3 in usecs */
244 u32 mdev_us; /* medium deviation */ 245 u32 mdev_us; /* medium deviation */
245 u32 mdev_max_us; /* maximal mdev for the last rtt period */ 246 u32 mdev_max_us; /* maximal mdev for the last rtt period */
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 5af2f04f8859..bd18c65df4a9 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -5362,6 +5362,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
5362{ 5362{
5363 struct tcp_sock *tp = tcp_sk(sk); 5363 struct tcp_sock *tp = tcp_sk(sk);
5364 5364
5365 skb_mstamp_get(&tp->tcp_mstamp);
5365 if (unlikely(!sk->sk_rx_dst)) 5366 if (unlikely(!sk->sk_rx_dst))
5366 inet_csk(sk)->icsk_af_ops->sk_rx_dst_set(sk, skb); 5367 inet_csk(sk)->icsk_af_ops->sk_rx_dst_set(sk, skb);
5367 /* 5368 /*
@@ -5922,6 +5923,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)
5922 5923
5923 case TCP_SYN_SENT: 5924 case TCP_SYN_SENT:
5924 tp->rx_opt.saw_tstamp = 0; 5925 tp->rx_opt.saw_tstamp = 0;
5926 skb_mstamp_get(&tp->tcp_mstamp);
5925 queued = tcp_rcv_synsent_state_process(sk, skb, th); 5927 queued = tcp_rcv_synsent_state_process(sk, skb, th);
5926 if (queued >= 0) 5928 if (queued >= 0)
5927 return queued; 5929 return queued;
@@ -5933,6 +5935,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)
5933 return 0; 5935 return 0;
5934 } 5936 }
5935 5937
5938 skb_mstamp_get(&tp->tcp_mstamp);
5936 tp->rx_opt.saw_tstamp = 0; 5939 tp->rx_opt.saw_tstamp = 0;
5937 req = tp->fastopen_rsk; 5940 req = tp->fastopen_rsk;
5938 if (req) { 5941 if (req) {