Print this page
XXXX adding PID information to netstat output
*** 35,44 ****
--- 35,45 ----
#include <sys/cmn_err.h>
#include <sys/stropts.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
+ #include <sys/fcntl.h>
#define _SUN_TPI_VERSION 2
#include <sys/tihdr.h>
#include <sys/sockio.h>
#include <sys/kmem_impl.h>
*** 355,364 ****
--- 356,366 ----
nso->so_proto_handle, (sock_upper_handle_t)nso, cr)) != 0) {
(void) socket_close(nso, 0, cr);
socket_destroy(nso);
} else {
*nsop = nso;
+ sonode_insert_pid(nso, curproc);
}
}
SO_UNBLOCK_FALLBACK(so);
return (error);
*** 1538,1547 ****
--- 1540,1588 ----
struct sonode *so = (struct sonode *)sock_handle;
VN_RELE(SOTOV(so));
}
+ conn_pid_node_list_hdr_t *
+ so_get_sock_pid_list(sock_upper_handle_t sock_handle)
+ {
+ int sz, n = 0;
+ pid_node_t *pn;
+ conn_pid_node_t *cpn;
+ conn_pid_node_list_hdr_t *cph;
+ struct sonode *so = (struct sonode *)sock_handle;
+
+ mutex_enter(&so->so_pid_list_lock);
+
+ n = list_size(&so->so_pid_list);
+ sz = sizeof (conn_pid_node_list_hdr_t);
+ sz += (n > 1)?((n - 1) * sizeof (conn_pid_node_t)):0;
+ cph = kmem_zalloc(sz, KM_SLEEP);
+
+ cph->cph_magic = CONN_PID_NODE_LIST_HDR_MAGIC;
+ cph->cph_contents = CONN_PID_NODE_LIST_HDR_SOC;
+ cph->cph_pn_cnt = n;
+ cph->cph_tot_size = sz;
+ cph->cph_flags = 0;
+ cph->cph_optional1 = 0;
+ cph->cph_optional2 = 0;
+
+ if (cph->cph_pn_cnt > 0) {
+ cpn = cph->cph_cpns;
+ pn = list_head(&so->so_pid_list);
+ while (pn != NULL) {
+ PIDNODE2CONNPIDNODE(pn, cpn);
+ pn = list_next(&so->so_pid_list, pn);
+ cpn++;
+ }
+ }
+
+ mutex_exit(&so->so_pid_list_lock);
+
+ return (cph);
+ }
+
void
so_zcopy_notify(sock_upper_handle_t sock_handle)
{
struct sonode *so = (struct sonode *)sock_handle;
*** 1938,1944 ****
so_set_prop,
so_txq_full,
so_signal_oob,
so_zcopy_notify,
so_set_error,
! so_closed
};
--- 1979,1986 ----
so_set_prop,
so_txq_full,
so_signal_oob,
so_zcopy_notify,
so_set_error,
! so_closed,
! so_get_sock_pid_list
};