[TCP]: Export accept queue len of a TCP listening socket via rx_queue

While debugging a TCP server hang issue, we noticed that currently there is
no way for a user to get the acceptq backlog value for a TCP listen socket.

All the standard networking utilities that display socket info like netstat,
ss and /proc/net/tcp have 2 fields called rx_queue and tx_queue. These
fields do not mean much for listening sockets. This patch uses one of these
unused fields(rx_queue) to export the accept queue len for listening sockets.

Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Sridhar Samudrala 2006-06-27 13:29:00 -07:00 коммит произвёл David S. Miller
Родитель c7bdb545d2
Коммит 47da8ee681
3 изменённых файлов: 8 добавлений и 3 удалений

Просмотреть файл

@ -26,7 +26,10 @@ static void tcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
const struct tcp_sock *tp = tcp_sk(sk); const struct tcp_sock *tp = tcp_sk(sk);
struct tcp_info *info = _info; struct tcp_info *info = _info;
r->idiag_rqueue = tp->rcv_nxt - tp->copied_seq; if (sk->sk_state == TCP_LISTEN)
r->idiag_rqueue = sk->sk_ack_backlog;
else
r->idiag_rqueue = tp->rcv_nxt - tp->copied_seq;
r->idiag_wqueue = tp->write_seq - tp->snd_una; r->idiag_wqueue = tp->write_seq - tp->snd_una;
if (info != NULL) if (info != NULL)
tcp_get_info(sk, info); tcp_get_info(sk, info);

Просмотреть файл

@ -1726,7 +1726,8 @@ static void get_tcp4_sock(struct sock *sp, char *tmpbuf, int i)
sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX " sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
"%08X %5d %8d %lu %d %p %u %u %u %u %d", "%08X %5d %8d %lu %d %p %u %u %u %u %d",
i, src, srcp, dest, destp, sp->sk_state, i, src, srcp, dest, destp, sp->sk_state,
tp->write_seq - tp->snd_una, tp->rcv_nxt - tp->copied_seq, tp->write_seq - tp->snd_una,
(sp->sk_state == TCP_LISTEN) ? sp->sk_ack_backlog : (tp->rcv_nxt - tp->copied_seq),
timer_active, timer_active,
jiffies_to_clock_t(timer_expires - jiffies), jiffies_to_clock_t(timer_expires - jiffies),
icsk->icsk_retransmits, icsk->icsk_retransmits,

Просмотреть файл

@ -1469,7 +1469,8 @@ 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[0], dest->s6_addr32[1],
dest->s6_addr32[2], dest->s6_addr32[3], destp, dest->s6_addr32[2], dest->s6_addr32[3], destp,
sp->sk_state, sp->sk_state,
tp->write_seq-tp->snd_una, tp->rcv_nxt-tp->copied_seq, tp->write_seq-tp->snd_una,
(sp->sk_state == TCP_LISTEN) ? sp->sk_ack_backlog : (tp->rcv_nxt - tp->copied_seq),
timer_active, timer_active,
jiffies_to_clock_t(timer_expires - jiffies), jiffies_to_clock_t(timer_expires - jiffies),
icsk->icsk_retransmits, icsk->icsk_retransmits,