* [PATCH net] tcp: tcp_get_info() should read tcp_time_stamp later
@ 2017-03-16 22:43 Eric Dumazet
2017-03-17 4:37 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2017-03-16 22:43 UTC (permalink / raw)
To: David Miller; +Cc: netdev
From: Eric Dumazet <edumazet@google.com>
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>
---
net/ipv4/tcp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index cf4555581282c608f920254078264e36e18584c6..1e319a525d51b0b603a5ccc5143381c752b9f2c7 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)
{
const struct tcp_sock *tp = tcp_sk(sk); /* iff sk_type == SOCK_STREAM */
const struct inet_connection_sock *icsk = inet_csk(sk);
- u32 now = tcp_time_stamp, intv;
+ u32 now, intv;
u64 rate64;
bool slow;
u32 rate;
@@ -2839,6 +2839,7 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
info->tcpi_retrans = tp->retrans_out;
info->tcpi_fackets = tp->fackets_out;
+ now = tcp_time_stamp;
info->tcpi_last_data_sent = jiffies_to_msecs(now - tp->lsndtime);
info->tcpi_last_data_recv = jiffies_to_msecs(now - icsk->icsk_ack.lrcvtime);
info->tcpi_last_ack_recv = jiffies_to_msecs(now - tp->rcv_tstamp);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] tcp: tcp_get_info() should read tcp_time_stamp later
2017-03-16 22:43 [PATCH net] tcp: tcp_get_info() should read tcp_time_stamp later Eric Dumazet
@ 2017-03-17 4:37 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-03-17 4:37 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 16 Mar 2017 15:43:19 -0700
> From: Eric Dumazet <edumazet@google.com>
>
> 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>
Applied, thanks Eric.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-17 4:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-16 22:43 [PATCH net] tcp: tcp_get_info() should read tcp_time_stamp later Eric Dumazet
2017-03-17 4:37 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).