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 ↓ 23 lines elided ↑ open up ↑
  24   24   * Copyright (c) 2015 Joyent, Inc.  All rights reserved.
  25   25   */
  26   26  
  27   27  #include <sys/types.h>
  28   28  #include <sys/t_lock.h>
  29   29  #include <sys/param.h>
  30   30  #include <sys/systm.h>
  31   31  #include <sys/buf.h>
  32   32  #include <sys/vfs.h>
  33   33  #include <sys/vnode.h>
       34 +#include <sys/fcntl.h>
  34   35  #include <sys/debug.h>
  35   36  #include <sys/errno.h>
  36   37  #include <sys/stropts.h>
  37   38  #include <sys/cmn_err.h>
  38   39  #include <sys/sysmacros.h>
  39   40  #include <sys/filio.h>
  40   41  #include <sys/policy.h>
  41   42  
  42   43  #include <sys/project.h>
  43   44  #include <sys/tihdr.h>
↓ open down ↓ 56 lines elided ↑ open up ↑
 100  101  static void sctp_assoc_connected(sock_upper_handle_t, sock_connid_t,
 101  102      struct cred *, pid_t);
 102  103  static int sctp_assoc_disconnected(sock_upper_handle_t, sock_connid_t, int);
 103  104  static void sctp_assoc_disconnecting(sock_upper_handle_t, sock_opctl_action_t,
 104  105      uintptr_t arg);
 105  106  static ssize_t sctp_assoc_recv(sock_upper_handle_t, mblk_t *, size_t, int,
 106  107      int *, boolean_t *);
 107  108  static void sctp_assoc_xmitted(sock_upper_handle_t, boolean_t);
 108  109  static void sctp_assoc_properties(sock_upper_handle_t,
 109  110      struct sock_proto_props *);
      111 +static mblk_t *sctp_get_sock_pid_mblk(sock_upper_handle_t);
 110  112  
 111  113  sonodeops_t sosctp_sonodeops = {
 112  114          sosctp_init,                    /* sop_init     */
 113  115          sosctp_accept,                  /* sop_accept   */
 114  116          sosctp_bind,                    /* sop_bind     */
 115  117          sosctp_listen,                  /* sop_listen   */
 116  118          sosctp_connect,                 /* sop_connect  */
 117  119          sosctp_recvmsg,                 /* sop_recvmsg  */
 118  120          sosctp_sendmsg,                 /* sop_sendmsg  */
 119  121          so_sendmblk_notsupp,            /* sop_sendmblk */
↓ open down ↓ 42 lines elided ↑ open up ↑
 162  164  sock_upcalls_t sosctp_assoc_upcalls = {
 163  165          sctp_assoc_newconn,
 164  166          sctp_assoc_connected,
 165  167          sctp_assoc_disconnected,
 166  168          sctp_assoc_disconnecting,
 167  169          sctp_assoc_recv,
 168  170          sctp_assoc_properties,
 169  171          sctp_assoc_xmitted,
 170  172          NULL,                   /* su_recv_space */
 171  173          NULL,                   /* su_signal_oob */
      174 +        NULL,                   /* su_set_error */
      175 +        NULL,                   /* su_closed */
      176 +        sctp_get_sock_pid_mblk
 172  177  };
 173  178  
 174  179  /* ARGSUSED */
 175  180  static int
 176  181  sosctp_init(struct sonode *so, struct sonode *pso, struct cred *cr, int flags)
 177  182  {
 178  183          struct sctp_sonode *ss;
 179  184          struct sctp_sonode *pss;
 180  185          sctp_sockbuf_limits_t sbl;
 181  186          int err;
↓ open down ↓ 1584 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