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 |
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 --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]); }