diff mbox series

[net-next,2/2] tcp: fix showing wrong rtomin in snmp file when setting sysctl_tcp_rto_min_us

Message ID 20240606150307.78648-3-kerneljasonxing@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series tcp: show the right value of TCP_MIB_RTOMIN | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 903 this patch: 903
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers fail 3 blamed authors not CCed: ycheng@google.com yyd@google.com tonylu@linux.alibaba.com; 3 maintainers not CCed: ycheng@google.com yyd@google.com tonylu@linux.alibaba.com
netdev/build_clang success Errors and warnings before: 905 this patch: 905
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 907 this patch: 907
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 28 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-06-07--00-00 (tests: 1040)

Commit Message

Jason Xing June 6, 2024, 3:03 p.m. UTC
From: Jason Xing <kernelxing@tencent.com>

A few days ago, sysctl_tcp_rto_min_us has been introduced to allow user to
tune the rto min value per netns. But the RtoMin field in /proc/net/snmp
should have been adjusted accordingly. Or else, it will show 200 which is
TCP_RTO_MIN.

This patch can show the correct value even when user sets though using both
'ip route' and 'sysctl -w'. The priority from high to low like what
tcp_rto_min() shows to us is:
1) ip route option rto_min
2) icsk->icsk_rto_min

Fixes: f086edef71be ("tcp: add sysctl_tcp_rto_min_us")
Signed-off-by: Jason Xing <kernelxing@tencent.com>
---
 net/ipv4/proc.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

Comments

Eric Dumazet June 6, 2024, 3:17 p.m. UTC | #1
On Thu, Jun 6, 2024 at 5:03 PM Jason Xing <kerneljasonxing@gmail.com> wrote:
>
> From: Jason Xing <kernelxing@tencent.com>
>
> A few days ago, sysctl_tcp_rto_min_us has been introduced to allow user to
> tune the rto min value per netns. But the RtoMin field in /proc/net/snmp
> should have been adjusted accordingly. Or else, it will show 200 which is
> TCP_RTO_MIN.
>
> This patch can show the correct value even when user sets though using both
> 'ip route' and 'sysctl -w'. The priority from high to low like what
> tcp_rto_min() shows to us is:
> 1) ip route option rto_min
> 2) icsk->icsk_rto_min
>
> Fixes: f086edef71be ("tcp: add sysctl_tcp_rto_min_us")

Same remark as for the prior patch.

We can not 'fix' the issue of an old MIB that can not express the
variety of situations.
diff mbox series

Patch

diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
index ce387081a3c9..4aeef3118442 100644
--- a/net/ipv4/proc.c
+++ b/net/ipv4/proc.c
@@ -409,6 +409,19 @@  static int snmp_seq_show_ipstats(struct seq_file *seq, void *v)
 	return 0;
 }
 
+static void snmp_seq_show_tcp_rtomin(struct seq_file *seq, struct net *net,
+				     unsigned long val)
+{
+	int sysctl_rtomin = READ_ONCE(net->ipv4.sysctl_tcp_rto_min_us);
+
+	if (tcp_rtax_rtomin)
+		seq_printf(seq, " %u", tcp_rtax_rtomin);
+	else if (sysctl_rtomin != jiffies_to_usecs(TCP_RTO_MIN))
+		seq_printf(seq, " %lu", usecs_to_jiffies(sysctl_rtomin));
+	else
+		seq_printf(seq, " %lu", val);
+}
+
 static int snmp_seq_show_tcp_udp(struct seq_file *seq, void *v)
 {
 	unsigned long buff[TCPUDP_MIB_MAX];
@@ -429,8 +442,7 @@  static int snmp_seq_show_tcp_udp(struct seq_file *seq, void *v)
 		if (snmp4_tcp_list[i].entry == TCP_MIB_MAXCONN)
 			seq_printf(seq, " %ld", buff[i]);
 		else if (snmp4_tcp_list[i].entry == TCP_MIB_RTOMIN)
-			seq_printf(seq, " %lu",
-				   tcp_rtax_rtomin ? tcp_rtax_rtomin : buff[i]);
+			snmp_seq_show_tcp_rtomin(seq, net, buff[i]);
 		else
 			seq_printf(seq, " %lu", buff[i]);
 	}