The branch main has been updated by tuexen:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=f1430567f26bc84db3818914fa91c74507d1602a

commit f1430567f26bc84db3818914fa91c74507d1602a
Author:     Michael Tuexen <tue...@freebsd.org>
AuthorDate: 2025-05-28 10:25:26 +0000
Commit:     Michael Tuexen <tue...@freebsd.org>
CommitDate: 2025-05-28 10:25:26 +0000

    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
---
 share/man/man4/ddb.4     | 10 +++++++++-
 sys/netinet/tcp_usrreq.c | 23 +++++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/share/man/man4/ddb.4 b/share/man/man4/ddb.4
index 4f6304e88114..9a9af553b29d 100644
--- a/share/man/man4/ddb.4
+++ b/share/man/man4/ddb.4
@@ -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.
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 5be4c399893a..a7a1d98fd193 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -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

Reply via email to