aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2017-03-16 18:43:19 -0400
committerDavid S. Miller <davem@davemloft.net>2017-03-17 00:37:13 -0400
commitdb7f00b8dba6d687b6ab1f2e9309acfd214fcb4b (patch)
tree63eedb1bec5da3449c41e53e56fea4eee4f02c5e
parente14b4db7a567ff507453ecd9c64da51bbc2b6d23 (diff)
tcp: tcp_get_info() should read tcp_time_stamp later
Commit b369e7fd41f7 ("tcp: make TCP_INFO more consistent") moved lock_sock_fast() earlier in tcp_get_info() This has the minor effect that jiffies value being sampled at the beginning of tcp_get_info() is more likely to be off by one, and we report big tcpi_last_data_sent values (like 0xFFFFFFFF). Since we lock the socket, fetching tcp_time_stamp right before doing the jiffies_to_msecs() calls is enough to remove these wrong values. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv4/tcp.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index cf4555581282..1e319a525d51 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2770,7 +2770,7 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
2770{ 2770{
2771 const struct tcp_sock *tp = tcp_sk(sk); /* iff sk_type == SOCK_STREAM */ 2771 const struct tcp_sock *tp = tcp_sk(sk); /* iff sk_type == SOCK_STREAM */
2772 const struct inet_connection_sock *icsk = inet_csk(sk); 2772 const struct inet_connection_sock *icsk = inet_csk(sk);
2773 u32 now = tcp_time_stamp, intv; 2773 u32 now, intv;
2774 u64 rate64; 2774 u64 rate64;
2775 bool slow; 2775 bool slow;
2776 u32 rate; 2776 u32 rate;
@@ -2839,6 +2839,7 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
2839 info->tcpi_retrans = tp->retrans_out; 2839 info->tcpi_retrans = tp->retrans_out;
2840 info->tcpi_fackets = tp->fackets_out; 2840 info->tcpi_fackets = tp->fackets_out;
2841 2841
2842 now = tcp_time_stamp;
2842 info->tcpi_last_data_sent = jiffies_to_msecs(now - tp->lsndtime); 2843 info->tcpi_last_data_sent = jiffies_to_msecs(now - tp->lsndtime);
2843 info->tcpi_last_data_recv = jiffies_to_msecs(now - icsk->icsk_ack.lrcvtime); 2844 info->tcpi_last_data_recv = jiffies_to_msecs(now - icsk->icsk_ack.lrcvtime);
2844 info->tcpi_last_ack_recv = jiffies_to_msecs(now - tp->rcv_tstamp); 2845 info->tcpi_last_ack_recv = jiffies_to_msecs(now - tp->rcv_tstamp);