* [PATCH 1/2] tcp: fix get_tcp4_sock() output error info
@ 2024-05-09 4:43 Yuan Fang
2024-05-09 4:43 ` [PATCH 2/2] tcp/ipv6: fix get_tcp6_sock() " Yuan Fang
2024-05-09 17:29 ` [External] : [PATCH 1/2] tcp: fix get_tcp4_sock() " Mohith Kumar Thummaluru
0 siblings, 2 replies; 6+ messages in thread
From: Yuan Fang @ 2024-05-09 4:43 UTC (permalink / raw
To: edumazet; +Cc: davem, netdev, linux-kernel, Yuan Fang
When in the TCP_LISTEN state, using netstat,the Send-Q is always 0.
Modify tx_queue to the value of sk->sk_max_ack_backlog.
Signed-off-by: Yuan Fang <yf768672249@gmail.com>
---
net/ipv4/tcp_ipv4.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index a22ee5838751..70416ba902b9 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2867,7 +2867,7 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i)
__be32 src = inet->inet_rcv_saddr;
__u16 destp = ntohs(inet->inet_dport);
__u16 srcp = ntohs(inet->inet_sport);
- int rx_queue;
+ int rx_queue, tx_queue;
int state;
if (icsk->icsk_pending == ICSK_TIME_RETRANS ||
@@ -2887,19 +2887,22 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i)
}
state = inet_sk_state_load(sk);
- if (state == TCP_LISTEN)
+ if (state == TCP_LISTEN) {
rx_queue = READ_ONCE(sk->sk_ack_backlog);
- else
+ tx_queue = READ_ONCE(sk->sk_max_ack_backlog);
+ } else {
/* Because we don't lock the socket,
* we might find a transient negative value.
*/
rx_queue = max_t(int, READ_ONCE(tp->rcv_nxt) -
READ_ONCE(tp->copied_seq), 0);
+ tx_queue = READ_ONCE(tp->write_seq) - tp->snd_una;
+ }
seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
"%08X %5u %8d %lu %d %pK %lu %lu %u %u %d",
i, src, srcp, dest, destp, state,
- READ_ONCE(tp->write_seq) - tp->snd_una,
+ tx_queue,
rx_queue,
timer_active,
jiffies_delta_to_clock_t(timer_expires - jiffies),
--
2.45.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] tcp/ipv6: fix get_tcp6_sock() output error info
2024-05-09 4:43 [PATCH 1/2] tcp: fix get_tcp4_sock() output error info Yuan Fang
@ 2024-05-09 4:43 ` Yuan Fang
2024-05-09 17:31 ` [External] : " Mohith Kumar Thummaluru
2024-05-09 17:29 ` [External] : [PATCH 1/2] tcp: fix get_tcp4_sock() " Mohith Kumar Thummaluru
1 sibling, 1 reply; 6+ messages in thread
From: Yuan Fang @ 2024-05-09 4:43 UTC (permalink / raw
To: edumazet; +Cc: davem, netdev, linux-kernel, Yuan Fang
Using the netstat command, the Send-Q is always 0 in TCP_LISTEN.
Modify tx_queue to the value of sk->sk_max_ack_backlog.
Signed-off-by: Yuan Fang <yf768672249@gmail.com>
---
net/ipv6/tcp_ipv6.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 3f4cba49e9ee..07ea1be13151 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -2177,7 +2177,7 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
const struct tcp_sock *tp = tcp_sk(sp);
const struct inet_connection_sock *icsk = inet_csk(sp);
const struct fastopen_queue *fastopenq = &icsk->icsk_accept_queue.fastopenq;
- int rx_queue;
+ int rx_queue, tx_queue;
int state;
dest = &sp->sk_v6_daddr;
@@ -2202,14 +2202,17 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
}
state = inet_sk_state_load(sp);
- if (state == TCP_LISTEN)
+ if (state == TCP_LISTEN) {
rx_queue = READ_ONCE(sp->sk_ack_backlog);
- else
+ tx_queue = READ_ONCE(sp->sk_max_ack_backlog);
+ } else {
/* Because we don't lock the socket,
* we might find a transient negative value.
*/
rx_queue = max_t(int, READ_ONCE(tp->rcv_nxt) -
READ_ONCE(tp->copied_seq), 0);
+ tx_queue = READ_ONCE(tp->write_seq) - tp->snd_una;
+ }
seq_printf(seq,
"%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
@@ -2220,7 +2223,7 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
dest->s6_addr32[0], dest->s6_addr32[1],
dest->s6_addr32[2], dest->s6_addr32[3], destp,
state,
- READ_ONCE(tp->write_seq) - tp->snd_una,
+ tx_queue,
rx_queue,
timer_active,
jiffies_delta_to_clock_t(timer_expires - jiffies),
--
2.45.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [External] : [PATCH 1/2] tcp: fix get_tcp4_sock() output error info
2024-05-09 4:43 [PATCH 1/2] tcp: fix get_tcp4_sock() output error info Yuan Fang
2024-05-09 4:43 ` [PATCH 2/2] tcp/ipv6: fix get_tcp6_sock() " Yuan Fang
@ 2024-05-09 17:29 ` Mohith Kumar Thummaluru
2024-05-09 18:09 ` David Wei
1 sibling, 1 reply; 6+ messages in thread
From: Mohith Kumar Thummaluru @ 2024-05-09 17:29 UTC (permalink / raw
To: Yuan Fang, edumazet@google.com
Cc: davem@davemloft.net, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Good catch! Thanks for this fix.
LGTM.
Reviewed-by : Mohith Kumar Thummaluru <mohith.k.kumar.thummaluru@oracle.com>
Tested-by: Mohith Kumar Thummaluru <mohith.k.kumar.thummaluru@oracle.com>
Regards,
Mohith
-----Original Message-----
From: Yuan Fang <yf768672249@gmail.com>
Sent: 09 May 2024 10:13
To: edumazet@google.com
Cc: davem@davemloft.net; netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Yuan Fang <yf768672249@gmail.com>
Subject: [External] : [PATCH 1/2] tcp: fix get_tcp4_sock() output error info
When in the TCP_LISTEN state, using netstat,the Send-Q is always 0.
Modify tx_queue to the value of sk->sk_max_ack_backlog.
Signed-off-by: Yuan Fang <yf768672249@gmail.com>
---
net/ipv4/tcp_ipv4.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index a22ee5838751..70416ba902b9 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2867,7 +2867,7 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i)
__be32 src = inet->inet_rcv_saddr;
__u16 destp = ntohs(inet->inet_dport);
__u16 srcp = ntohs(inet->inet_sport);
- int rx_queue;
+ int rx_queue, tx_queue;
int state;
if (icsk->icsk_pending == ICSK_TIME_RETRANS || @@ -2887,19 +2887,22 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i)
}
state = inet_sk_state_load(sk);
- if (state == TCP_LISTEN)
+ if (state == TCP_LISTEN) {
rx_queue = READ_ONCE(sk->sk_ack_backlog);
- else
+ tx_queue = READ_ONCE(sk->sk_max_ack_backlog);
+ } else {
/* Because we don't lock the socket,
* we might find a transient negative value.
*/
rx_queue = max_t(int, READ_ONCE(tp->rcv_nxt) -
READ_ONCE(tp->copied_seq), 0);
+ tx_queue = READ_ONCE(tp->write_seq) - tp->snd_una;
+ }
seq_printf(f, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
"%08X %5u %8d %lu %d %pK %lu %lu %u %u %d",
i, src, srcp, dest, destp, state,
- READ_ONCE(tp->write_seq) - tp->snd_una,
+ tx_queue,
rx_queue,
timer_active,
jiffies_delta_to_clock_t(timer_expires - jiffies),
--
2.45.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [External] : [PATCH 2/2] tcp/ipv6: fix get_tcp6_sock() output error info
2024-05-09 4:43 ` [PATCH 2/2] tcp/ipv6: fix get_tcp6_sock() " Yuan Fang
@ 2024-05-09 17:31 ` Mohith Kumar Thummaluru
0 siblings, 0 replies; 6+ messages in thread
From: Mohith Kumar Thummaluru @ 2024-05-09 17:31 UTC (permalink / raw
To: Yuan Fang, edumazet@google.com
Cc: davem@davemloft.net, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
LGTM.
Reviewed-by : Mohith Kumar Thummaluru <mohith.k.kumar.thummaluru@oracle.com>
-----Original Message-----
From: Yuan Fang <yf768672249@gmail.com>
Sent: 09 May 2024 10:13
To: edumazet@google.com
Cc: davem@davemloft.net; netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Yuan Fang <yf768672249@gmail.com>
Subject: [External] : [PATCH 2/2] tcp/ipv6: fix get_tcp6_sock() output error info
Using the netstat command, the Send-Q is always 0 in TCP_LISTEN.
Modify tx_queue to the value of sk->sk_max_ack_backlog.
Signed-off-by: Yuan Fang <yf768672249@gmail.com>
---
net/ipv6/tcp_ipv6.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 3f4cba49e9ee..07ea1be13151 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -2177,7 +2177,7 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
const struct tcp_sock *tp = tcp_sk(sp);
const struct inet_connection_sock *icsk = inet_csk(sp);
const struct fastopen_queue *fastopenq = &icsk->icsk_accept_queue.fastopenq;
- int rx_queue;
+ int rx_queue, tx_queue;
int state;
dest = &sp->sk_v6_daddr;
@@ -2202,14 +2202,17 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
}
state = inet_sk_state_load(sp);
- if (state == TCP_LISTEN)
+ if (state == TCP_LISTEN) {
rx_queue = READ_ONCE(sp->sk_ack_backlog);
- else
+ tx_queue = READ_ONCE(sp->sk_max_ack_backlog);
+ } else {
/* Because we don't lock the socket,
* we might find a transient negative value.
*/
rx_queue = max_t(int, READ_ONCE(tp->rcv_nxt) -
READ_ONCE(tp->copied_seq), 0);
+ tx_queue = READ_ONCE(tp->write_seq) - tp->snd_una;
+ }
seq_printf(seq,
"%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
@@ -2220,7 +2223,7 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
dest->s6_addr32[0], dest->s6_addr32[1],
dest->s6_addr32[2], dest->s6_addr32[3], destp,
state,
- READ_ONCE(tp->write_seq) - tp->snd_una,
+ tx_queue,
rx_queue,
timer_active,
jiffies_delta_to_clock_t(timer_expires - jiffies),
--
2.45.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [External] : [PATCH 1/2] tcp: fix get_tcp4_sock() output error info
2024-05-09 17:29 ` [External] : [PATCH 1/2] tcp: fix get_tcp4_sock() " Mohith Kumar Thummaluru
@ 2024-05-09 18:09 ` David Wei
2024-05-09 19:46 ` Eric Dumazet
0 siblings, 1 reply; 6+ messages in thread
From: David Wei @ 2024-05-09 18:09 UTC (permalink / raw
To: Mohith Kumar Thummaluru, Yuan Fang, edumazet@google.com
Cc: davem@davemloft.net, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
On 2024-05-09 10:29, Mohith Kumar Thummaluru wrote:
> Good catch! Thanks for this fix.
If this is a fix, can you please add a Fixes tag? And in general some
surrounding context in a cover letter? Thanks.
>
> LGTM.
>
> Reviewed-by : Mohith Kumar Thummaluru <mohith.k.kumar.thummaluru@oracle.com>
> Tested-by: Mohith Kumar Thummaluru <mohith.k.kumar.thummaluru@oracle.com>
>
> Regards,
> Mohith
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [External] : [PATCH 1/2] tcp: fix get_tcp4_sock() output error info
2024-05-09 18:09 ` David Wei
@ 2024-05-09 19:46 ` Eric Dumazet
0 siblings, 0 replies; 6+ messages in thread
From: Eric Dumazet @ 2024-05-09 19:46 UTC (permalink / raw
To: David Wei
Cc: Mohith Kumar Thummaluru, Yuan Fang, davem@davemloft.net,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
On Thu, May 9, 2024 at 8:09 PM David Wei <dw@davidwei.uk> wrote:
>
> On 2024-05-09 10:29, Mohith Kumar Thummaluru wrote:
> > Good catch! Thanks for this fix.
>
> If this is a fix, can you please add a Fixes tag? And in general some
> surrounding context in a cover letter? Thanks.
I do not think it is a fix, and I am not sure we want this patch anyway.
/proc interface is legacy, we do not change it.
Please use TCP_INFO or inet_diag, because
commit 5ee3afba88f5 "[TCP]: Return useful listenq info in tcp_info and
INET_DIAG_INFO."
took care of this in 2007.
Already in 2007 we were considering /proc/net/tcp as a legacy.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-05-09 19:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-09 4:43 [PATCH 1/2] tcp: fix get_tcp4_sock() output error info Yuan Fang
2024-05-09 4:43 ` [PATCH 2/2] tcp/ipv6: fix get_tcp6_sock() " Yuan Fang
2024-05-09 17:31 ` [External] : " Mohith Kumar Thummaluru
2024-05-09 17:29 ` [External] : [PATCH 1/2] tcp: fix get_tcp4_sock() " Mohith Kumar Thummaluru
2024-05-09 18:09 ` David Wei
2024-05-09 19:46 ` Eric Dumazet
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 read-only IMAP folder(s) and NNTP newsgroup(s).