Skip to content

Commit 5ee3afb

Browse files
Rick JonesDavid S. Miller
authored andcommitted
[TCP]: Return useful listenq info in tcp_info and INET_DIAG_INFO.
Return some useful information such as the maximum listen backlog and the current listen backlog in the tcp_info structure and INET_DIAG_INFO. Signed-off-by: Rick Jones <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 768f359 commit 5ee3afb

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

net/ipv4/tcp.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,8 +2031,13 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
20312031
info->tcpi_snd_mss = tp->mss_cache;
20322032
info->tcpi_rcv_mss = icsk->icsk_ack.rcv_mss;
20332033

2034-
info->tcpi_unacked = tp->packets_out;
2035-
info->tcpi_sacked = tp->sacked_out;
2034+
if (sk->sk_state == TCP_LISTEN) {
2035+
info->tcpi_unacked = sk->sk_ack_backlog;
2036+
info->tcpi_sacked = sk->sk_max_ack_backlog;
2037+
} else {
2038+
info->tcpi_unacked = tp->packets_out;
2039+
info->tcpi_sacked = tp->sacked_out;
2040+
}
20362041
info->tcpi_lost = tp->lost_out;
20372042
info->tcpi_retrans = tp->retrans_out;
20382043
info->tcpi_fackets = tp->fackets_out;

net/ipv4/tcp_diag.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ static void tcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
2525
const struct tcp_sock *tp = tcp_sk(sk);
2626
struct tcp_info *info = _info;
2727

28-
if (sk->sk_state == TCP_LISTEN)
28+
if (sk->sk_state == TCP_LISTEN) {
2929
r->idiag_rqueue = sk->sk_ack_backlog;
30-
else
30+
r->idiag_wqueue = sk->sk_max_ack_backlog;
31+
} else {
3132
r->idiag_rqueue = tp->rcv_nxt - tp->copied_seq;
32-
r->idiag_wqueue = tp->write_seq - tp->snd_una;
33+
r->idiag_wqueue = tp->write_seq - tp->snd_una;
34+
}
3335
if (info != NULL)
3436
tcp_get_info(sk, info);
3537
}

0 commit comments

Comments
 (0)