diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2016-01-15 11:21:59 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2016-01-15 11:21:59 +0000 |
commit | b894a0eb230529198fafa120e7b042ab3ea573f8 (patch) | |
tree | 4cc2b42ea50f9ef5134f487b2ffcf5e538387c5f /sys/kern | |
parent | 24c4f587dd183708bc5cd6d94572fd17f974f0ef (diff) |
add a "show socket" command to ddb
should help inspecting socket issues in the future.
enthusiasm from mpi@ bluhm@ deraadt@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/subr_pool.c | 10 | ||||
-rw-r--r-- | sys/kern/uipc_socket.c | 88 |
2 files changed, 93 insertions, 5 deletions
diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c index 757381b77f7..043cc8b27b7 100644 --- a/sys/kern/subr_pool.c +++ b/sys/kern/subr_pool.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_pool.c,v 1.193 2015/09/11 09:26:13 kettenis Exp $ */ +/* $OpenBSD: subr_pool.c,v 1.194 2016/01/15 11:21:58 dlg Exp $ */ /* $NetBSD: subr_pool.c,v 1.61 2001/09/26 07:14:56 chs Exp $ */ /*- @@ -703,9 +703,11 @@ pool_put(struct pool *pp, void *v) if (freeph != NULL) pool_p_free(pp, freeph); - mtx_enter(&pp->pr_requests_mtx); - pool_runqueue(pp, PR_NOWAIT); - mtx_leave(&pp->pr_requests_mtx); + if (!TAILQ_EMPTY(&pp->pr_requests)) { + mtx_enter(&pp->pr_requests_mtx); + pool_runqueue(pp, PR_NOWAIT); + mtx_leave(&pp->pr_requests_mtx); + } } /* diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 024426831c1..7cbeb42085e 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket.c,v 1.146 2016/01/13 21:39:39 bluhm Exp $ */ +/* $OpenBSD: uipc_socket.c,v 1.147 2016/01/15 11:21:58 dlg Exp $ */ /* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */ /* @@ -50,6 +50,10 @@ #include <net/if.h> #include <sys/pool.h> +#ifdef DDB +#include <machine/db_machdep.h> +#endif + void sbsync(struct sockbuf *, struct mbuf *); int sosplice(struct socket *, int, off_t, struct timeval *); @@ -1893,3 +1897,85 @@ filt_solisten(struct knote *kn, long hint) kn->kn_data = so->so_qlen; return (so->so_qlen != 0); } + +#ifdef DDB +void +sobuf_print(struct sockbuf *, + int (*)(const char *, ...) __attribute__((__format__(__kprintf__,1,2)))); + +void +sobuf_print(struct sockbuf *sb, + int (*pr)(const char *, ...) __attribute__((__format__(__kprintf__,1,2)))) +{ + (*pr)("\tsb_cc: %lu\n", sb->sb_cc); + (*pr)("\tsb_datacc: %lu\n", sb->sb_datacc); + (*pr)("\tsb_hiwat: %lu\n", sb->sb_hiwat); + (*pr)("\tsb_wat: %lu\n", sb->sb_wat); + (*pr)("\tsb_mbcnt: %lu\n", sb->sb_mbcnt); + (*pr)("\tsb_mbmax: %lu\n", sb->sb_mbmax); + (*pr)("\tsb_lowat: %ld\n", sb->sb_lowat); + (*pr)("\tsb_mb: %p\n", sb->sb_mb); + (*pr)("\tsb_mbtail: %p\n", sb->sb_mbtail); + (*pr)("\tsb_lastrecord: %p\n", sb->sb_lastrecord); + (*pr)("\tsb_sel: ...\n"); + (*pr)("\tsb_flagsintr: %d\n", sb->sb_flagsintr); + (*pr)("\tsb_flags: %i\n", sb->sb_flags); + (*pr)("\tsb_timeo: %i\n", sb->sb_timeo); +} + +void +so_print(void *v, + int (*pr)(const char *, ...) __attribute__((__format__(__kprintf__,1,2)))) +{ + struct socket *so = v; + + (*pr)("socket %p\n", so); + (*pr)("so_type: %i\n", so->so_type); + (*pr)("so_options: 0x%04x\n", so->so_options); /* %b */ + (*pr)("so_linger: %i\n", so->so_linger); + (*pr)("so_state: %i\n", so->so_state); + (*pr)("so_pcb: %p\n", so->so_pcb); + (*pr)("so_proto: %p\n", so->so_proto); + + (*pr)("so_head: %p\n", so->so_head); + (*pr)("so_onq: %p\n", so->so_onq); + (*pr)("so_q0: @%p first: %p\n", &so->so_q0, TAILQ_FIRST(&so->so_q0)); + (*pr)("so_q: @%p first: %p\n", &so->so_q, TAILQ_FIRST(&so->so_q)); + (*pr)("so_q0len: %i\n", so->so_q0len); + (*pr)("so_qlen: %i\n", so->so_qlen); + (*pr)("so_qlimit: %i\n", so->so_qlimit); + (*pr)("so_timeo: %i\n", so->so_timeo); + (*pr)("so_pgid: %i\n", so->so_pgid); + (*pr)("so_siguid: %i\n", so->so_siguid); + (*pr)("so_sigeuid: %i\n", so->so_sigeuid); + (*pr)("so_obmark: %lu\n", so->so_oobmark); + + (*pr)("so_sp: %p\n", so->so_sp); + if (so->so_sp != NULL) { + (*pr)("\tssp_socket: %p\n", so->so_sp->ssp_socket); + (*pr)("\tssp_soback: %p\n", so->so_sp->ssp_soback); + (*pr)("\tssp_len: %lld\n", + (unsigned long long)so->so_sp->ssp_len); + (*pr)("\tssp_max: %lld\n", + (unsigned long long)so->so_sp->ssp_max); + (*pr)("\tssp_idletv: %lld %ldn", so->so_sp->ssp_idletv.tv_sec, + so->so_sp->ssp_idletv.tv_usec); + (*pr)("\tssp_idleto: %spending (@%i)\n", + timeout_pending(&so->so_sp->ssp_idleto) ? "" : "not ", + so->so_sp->ssp_idleto.to_time); + } + + (*pr)("so_rcv:\n"); + sobuf_print(&so->so_rcv, pr); + (*pr)("so_snd:\n"); + sobuf_print(&so->so_snd, pr); + + (*pr)("so_upcall: %p so_upcallarg: %p\n", + so->so_upcall, so->so_upcallarg); + + (*pr)("so_euid: %d so_ruid: %d\n", so->so_euid, so->so_ruid); + (*pr)("so_egid: %d so_rgid: %d\n", so->so_egid, so->so_rgid); + (*pr)("so_cpid: %d\n", so->so_cpid); +} +#endif + |