Print this page
XXXX adding PID information to netstat output

*** 75,84 **** --- 75,85 ---- #include <sys/autoconf.h> #include <sys/policy.h> #include <sys/dld.h> #include <sys/zone.h> #include <c2/audit.h> + #include <sys/fcntl.h> /* * This define helps improve the readability of streams code while * still maintaining a very old streams performance enhancement. The * performance enhancement basically involved having all callers
*** 140,149 **** --- 141,151 ---- static void putback(struct stdata *, queue_t *, mblk_t *, int); static void strcleanall(struct vnode *); static int strwsrv(queue_t *); static int strdocmd(struct stdata *, struct strcmd *, cred_t *); + static boolean_t is_xti_str(const struct stdata *); /* * qinit and module_info structures for stream head read and write queues */ struct module_info strm_info = { 0, "strrhead", 0, INFPSZ, STRHIGH, STRLOW };
*** 394,403 **** --- 396,413 ---- stp->sd_maxblk = INFPSZ; qp->q_ptr = _WR(qp)->q_ptr = stp; STREAM(qp) = STREAM(_WR(qp)) = stp; vp->v_stream = stp; mutex_exit(&vp->v_lock); + + /* + * If this is not a system process, then add it to + * the list associated with the stream head. + */ + if (!(curproc->p_flag & SSYS) && is_xti_str(stp)) + sh_insert_pid(stp, curproc->p_pidp->pid_id); + if (vp->v_type == VFIFO) { stp->sd_flag |= OLDNDELAY; /* * This means, both for pipes and fifos * strwrite will send SIGPIPE if the other
*** 5680,5689 **** --- 5690,5715 ---- } case FIONBIO: case FIOASYNC: return (0); /* handled by the upper layer */ + case F_ASSOCI_PID: + { + if (crp != kcred) + return (EPERM); + if (is_xti_str(stp)) + sh_insert_pid(stp, (pid_t)arg); + return (0); + } + case F_DASSOC_PID: + { + if (crp != kcred) + return (EPERM); + if (is_xti_str(stp)) + sh_remove_pid(stp, (pid_t)arg); + return (0); + } } } /* * Custom free routine used for M_PASSFP messages.
*** 8612,8616 **** --- 8638,8672 ---- if (bp->b_wptr > bp->b_rptr) return (B_TRUE); } return (B_FALSE); } + + /* + * Check whether a stream is an XTI stream or not. + */ + static boolean_t + is_xti_str(const struct stdata *stp) + { + struct devnames *dnp; + vnode_t *vn; + major_t major; + if ((vn = stp->sd_vnode) != NULL && vn->v_type == VCHR && + vn->v_rdev != 0) { + major = getmajor(vn->v_rdev); + dnp = (major != DDI_MAJOR_T_NONE && major >= 0 && + major < devcnt) ? &devnamesp[major] : NULL; + if (dnp != NULL && dnp->dn_name != NULL && + (strcmp(dnp->dn_name, "ip") == 0 || + strcmp(dnp->dn_name, "tcp") == 0 || + strcmp(dnp->dn_name, "udp") == 0 || + strcmp(dnp->dn_name, "icmp") == 0 || + strcmp(dnp->dn_name, "tl") == 0 || + strcmp(dnp->dn_name, "ip6") == 0 || + strcmp(dnp->dn_name, "tcp6") == 0 || + strcmp(dnp->dn_name, "udp6") == 0 || + strcmp(dnp->dn_name, "icmp6") == 0)) { + return (B_TRUE); + } + } + return (B_FALSE); + }