From 8675ebe3a08f394ddc99e4a55fbec9875854a3d5 Mon Sep 17 00:00:00 2001 From: Xuan Zhuo Date: Thu, 21 May 2020 19:10:07 +0800 Subject: [PATCH 1722/2944] alinux: tcp_rt module: fix repeat stats for mrtt to #27804112 Only count mrtt at the end of the connection. In the case of ports peer, if mrtt is counted in each output, it will cause repeated statistics. Signed-off-by: Xuan Zhuo Acked-by: Dust Li Reviewed-by: Ya Zhao Reviewed-by: Cambda Zhu --- net/ipv4/tcp_rt/output.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/ipv4/tcp_rt/output.c b/net/ipv4/tcp_rt/output.c index d1b57b6..558719b 100644 --- a/net/ipv4/tcp_rt/output.c +++ b/net/ipv4/tcp_rt/output.c @@ -248,7 +248,13 @@ void tcp_rt_log_printk(const struct sock *sk, char flag, bool fin, bool stats) size += bufappend(buf, size, mrtt); buf[size++] = '\n'; - if (mrtt > 0) { + if (mrtt <= 0) + break; + + if (rt->type == TCPRT_TYPE_PEER_PORT) { + stats_peer_inc(rt, con_num); + stats_peer_add(rt, rtt, mrtt); + } else { r = tcp_rt_get_local_stats_sk(sk); if (!r) break; @@ -273,9 +279,7 @@ void tcp_rt_log_printk(const struct sock *sk, char flag, bool fin, bool stats) if (stats) { stats_peer_inc(rt, number); - stats_peer_inc(rt, con_num); stats_peer_add(rt, bytes, t_seq); - stats_peer_add(rt, rtt, mrtt); stats_peer_add(rt, packets, t_seq / tp->mss_cache + 1); stats_peer_add(rt, drop, t_retrans); } -- 1.8.3.1