Print this page
XXXX adding PID information to netstat output

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/inet/sockmods/socksctp.c
          +++ new/usr/src/uts/common/inet/sockmods/socksctp.c
↓ open down ↓ 22 lines elided ↑ open up ↑
  23   23   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   */
  25   25  
  26   26  #include <sys/types.h>
  27   27  #include <sys/t_lock.h>
  28   28  #include <sys/param.h>
  29   29  #include <sys/systm.h>
  30   30  #include <sys/buf.h>
  31   31  #include <sys/vfs.h>
  32   32  #include <sys/vnode.h>
       33 +#include <sys/fcntl.h>
  33   34  #include <sys/debug.h>
  34   35  #include <sys/errno.h>
  35   36  #include <sys/stropts.h>
  36   37  #include <sys/cmn_err.h>
  37   38  #include <sys/sysmacros.h>
  38   39  #include <sys/filio.h>
  39   40  #include <sys/policy.h>
  40   41  
  41   42  #include <sys/project.h>
  42   43  #include <sys/tihdr.h>
↓ open down ↓ 56 lines elided ↑ open up ↑
  99  100  static void sctp_assoc_connected(sock_upper_handle_t, sock_connid_t,
 100  101      struct cred *, pid_t);
 101  102  static int sctp_assoc_disconnected(sock_upper_handle_t, sock_connid_t, int);
 102  103  static void sctp_assoc_disconnecting(sock_upper_handle_t, sock_opctl_action_t,
 103  104      uintptr_t arg);
 104  105  static ssize_t sctp_assoc_recv(sock_upper_handle_t, mblk_t *, size_t, int,
 105  106      int *, boolean_t *);
 106  107  static void sctp_assoc_xmitted(sock_upper_handle_t, boolean_t);
 107  108  static void sctp_assoc_properties(sock_upper_handle_t,
 108  109      struct sock_proto_props *);
      110 +static mblk_t *sctp_get_sock_pid_mblk(sock_upper_handle_t);
 109  111  
 110  112  sonodeops_t sosctp_sonodeops = {
 111  113          sosctp_init,                    /* sop_init     */
 112  114          sosctp_accept,                  /* sop_accept   */
 113  115          sosctp_bind,                    /* sop_bind     */
 114  116          sosctp_listen,                  /* sop_listen   */
 115  117          sosctp_connect,                 /* sop_connect  */
 116  118          sosctp_recvmsg,                 /* sop_recvmsg  */
 117  119          sosctp_sendmsg,                 /* sop_sendmsg  */
 118  120          so_sendmblk_notsupp,            /* sop_sendmblk */
↓ open down ↓ 42 lines elided ↑ open up ↑
 161  163  sock_upcalls_t sosctp_assoc_upcalls = {
 162  164          sctp_assoc_newconn,
 163  165          sctp_assoc_connected,
 164  166          sctp_assoc_disconnected,
 165  167          sctp_assoc_disconnecting,
 166  168          sctp_assoc_recv,
 167  169          sctp_assoc_properties,
 168  170          sctp_assoc_xmitted,
 169  171          NULL,                   /* su_recv_space */
 170  172          NULL,                   /* su_signal_oob */
      173 +        NULL,                   /* su_set_error */
      174 +        NULL,                   /* su_closed */
      175 +        sctp_get_sock_pid_mblk
 171  176  };
 172  177  
 173  178  /* ARGSUSED */
 174  179  static int
 175  180  sosctp_init(struct sonode *so, struct sonode *pso, struct cred *cr, int flags)
 176  181  {
 177  182          struct sctp_sonode *ss;
 178  183          struct sctp_sonode *pss;
 179  184          sctp_sockbuf_limits_t sbl;
 180  185          int err;
↓ open down ↓ 1585 lines elided ↑ open up ↑
1766 1771                          goto peelerr;
1767 1772                  }
1768 1773  
1769 1774                  /*
1770 1775                   * fill in the entries that falloc reserved
1771 1776                   */
1772 1777                  nfp->f_vnode = nvp;
1773 1778                  mutex_exit(&nfp->f_tlock);
1774 1779                  setf(nfd, nfp);
1775 1780  
     1781 +                /* Add pid to the list associated with that socket. */
     1782 +                if (nfp->f_vnode != NULL) {
     1783 +                        (void) VOP_IOCTL(nfp->f_vnode, F_ASSOCI_PID,
     1784 +                            (intptr_t)curproc->p_pidp->pid_id, FKIOCTL, kcred,
     1785 +                            NULL, NULL);
     1786 +                }
     1787 +
1776 1788                  mutex_enter(&so->so_lock);
1777 1789  
1778 1790                  sosctp_assoc_move(ss, SOTOSSO(nso), ssa);
1779 1791  
1780 1792                  mutex_exit(&nso->so_lock);
1781 1793  
1782 1794                  ssa->ssa_conn = NULL;
1783 1795                  sosctp_assoc_free(ss, ssa);
1784 1796  
1785 1797                  so_unlock_single(so, SOLOCKED);
↓ open down ↓ 436 lines elided ↑ open up ↑
2222 2234                          if (so->so_rcvlowat > lowat) {
2223 2235                                  /* Sanity check... */
2224 2236                                  if (lowat == 0)
2225 2237                                          so->so_rcvlowat = soppp->sopp_rxhiwat;
2226 2238                                  else
2227 2239                                          so->so_rcvlowat = lowat;
2228 2240                          }
2229 2241                  }
2230 2242          }
2231 2243          mutex_exit(&so->so_lock);
     2244 +}
     2245 +
     2246 +static mblk_t *
     2247 +sctp_get_sock_pid_mblk(sock_upper_handle_t handle)
     2248 +{
     2249 +        struct sctp_soassoc *ssa = (struct sctp_soassoc *)handle;
     2250 +        struct sonode *so;
     2251 +
     2252 +        if (ssa->ssa_type == SOSCTP_ASSOC)
     2253 +                so = &ssa->ssa_sonode->ss_so;
     2254 +        else
     2255 +                so = &((struct sctp_sonode *)handle)->ss_so;
     2256 +
     2257 +        return (so_get_sock_pid_mblk((sock_upper_handle_t)so));
2232 2258  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX