This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit efb99142dcbf2b7086fc917052b4ec68fd876475 Author: Yongrong Wang <[email protected]> AuthorDate: Tue Mar 10 17:20:58 2026 +0800 vsock: add vsock_conn_dump for connection diagnostics Add vsock_conn_dump() to print the state of a connection for diagnostics. Signed-off-by: Yongrong Wang <[email protected]> --- net/vsock/vsock.h | 2 ++ net/vsock/vsock_sockif.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/net/vsock/vsock.h b/net/vsock/vsock.h index 082cb81bb9a..902495241bd 100644 --- a/net/vsock/vsock.h +++ b/net/vsock/vsock.h @@ -115,6 +115,8 @@ void vsock_recv_pkt(FAR struct vsock_transport_s *t, int vsock_queue_work(FAR struct work_s *work, worker_t worker, FAR void *arg, clock_t delay); +void vsock_conn_dump(FAR struct vsock_transport_s *t); + /* Register vsock transport layer to the vsock interface layer, should be * called by the vsock transport layer only. */ diff --git a/net/vsock/vsock_sockif.c b/net/vsock/vsock_sockif.c index 08ac12ab956..64ba36c8fbd 100644 --- a/net/vsock/vsock_sockif.c +++ b/net/vsock/vsock_sockif.c @@ -2451,6 +2451,49 @@ int vsock_queue_work(FAR struct work_s *work, worker_t worker, FAR void *arg, return work_queue_wq(g_vsock_wqueue, work, worker, arg, delay); } +/**************************************************************************** + * Name: vsock_conn_dump + * + * Description: + * Dump vsock connections owned by the specified transport. + * + ****************************************************************************/ + +void vsock_conn_dump(FAR struct vsock_transport_s *t) +{ + FAR struct vsock_conn_s *conn; + irqstate_t flags; + int i = 0; + + flags = spin_lock_irqsave(&g_vsock_conn_lock); + list_for_every_entry(&g_vsock_conn, conn, struct vsock_conn_s, node) + { + if (conn->transport != t) + { + continue; + } + + syslog(LOG_EMERG, " conn[%d]: %s, local=%u:%u" + ", remote=%u:%u, flags=0x%x" + ", rx=%zu/%zu, tx_credit=%zu\n", + i++, + _SS_ISLISTENING(conn->sconn.s_flags) ? "server" : "client", + conn->local_addr.svm_cid, conn->local_addr.svm_port, + conn->remote_addr.svm_cid, conn->remote_addr.svm_port, + conn->sconn.s_flags, + circbuf_used(&conn->rx_buf), + circbuf_size(&conn->rx_buf), + vsock_get_tx_credit(conn)); + } + + if (i == 0) + { + syslog(LOG_EMERG, " (no connections)\n"); + } + + spin_unlock_irqrestore(&g_vsock_conn_lock, flags); +} + /**************************************************************************** * Name: vsock_transport_register *
