diff --git a/share/man/man4/ddb.4 b/share/man/man4/ddb.4 --- 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 @@ 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 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -3222,4 +3222,27 @@ 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