diff mbox series

[2/2] tcp/ipv6: fix get_tcp6_sock() output error info

Message ID 20240509044323.247606-2-yf768672249@gmail.com (mailing list archive)
State Rejected
Delegated to: Netdev Maintainers
Headers show
Series [1/2] tcp: fix get_tcp4_sock() output error info | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
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: 928 this patch: 928
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 3 maintainers not CCed: pabeni@redhat.com dsahern@kernel.org kuba@kernel.org
netdev/build_clang success Errors and warnings before: 937 this patch: 937
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 No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 939 this patch: 939
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 35 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-05-11--21-00 (tests: 1018)

Commit Message

Yuan Fang May 9, 2024, 4:43 a.m. UTC
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(-)

Comments

Mohith Kumar Thummaluru May 9, 2024, 5:31 p.m. UTC | #1
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
diff mbox series

Patch

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),