ddb: add show all tcpcbs

Add a command to show all TCP control blocks. Also provide an option
to limit the output to TCP control blocks, which are locked.
The plan is to run show all tcpcbs/l when syzkaller triggers a panic.
If a TCP control block is affected, it is most likely locked and
therefore the command shows the information of the affected TCP
control block.

Reviewed by:		markj, thj
Tested by:		thj
MFC after:		1 week
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D50516
This commit is contained in:
Michael Tuexen 2025-05-28 12:25:26 +02:00
parent 8d4f495df4
commit f1430567f2
2 changed files with 32 additions and 1 deletions

View file

@ -24,7 +24,7 @@
.\" any improvements or extensions that they make and grant Carnegie Mellon
.\" the rights to redistribute these changes.
.\"
.Dd May 24, 2025
.Dd May 28, 2025
.Dt DDB 4
.Os
.Sh NAME
@ -604,6 +604,14 @@ The
modifier will print command line arguments for each process.
.\"
.Pp
.It Ic show Cm all tcpcbs Ns Op Li / Ns Cm l
Show the same output as "show tcpcb" does, but for all
TCP control blocks within the system.
Using the
.Cm l
modifier will limit the output to TCP control blocks, which are locked.
.\"
.Pp
.It Ic show Cm all trace
.It Ic alltrace
Show a stack trace for every thread in the system.

View file

@ -3222,4 +3222,27 @@ DB_SHOW_COMMAND(tcpcb, db_show_tcpcb)
db_print_tcpcb(tp, "tcpcb", 0);
}
DB_SHOW_ALL_COMMAND(tcpcbs, db_show_all_tcpcbs)
{
VNET_ITERATOR_DECL(vnet_iter);
struct inpcb *inp;
bool only_locked;
only_locked = strchr(modif, 'l') != NULL;
VNET_FOREACH(vnet_iter) {
CURVNET_SET(vnet_iter);
CK_LIST_FOREACH(inp, &V_tcbinfo.ipi_listhead, inp_list) {
if (only_locked &&
inp->inp_lock.rw_lock == RW_UNLOCKED)
continue;
db_print_tcpcb(intotcpcb(inp), "tcpcb", 0);
if (db_pager_quit)
break;
}
CURVNET_RESTORE();
if (db_pager_quit)
break;
}
}
#endif