Print this page
XXXX adding PID information to netstat output

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/sockfs/sockcommon_sops.c
          +++ new/usr/src/uts/common/fs/sockfs/sockcommon_sops.c
↓ open down ↓ 29 lines elided ↑ open up ↑
  30   30  #include <sys/types.h>
  31   31  #include <sys/param.h>
  32   32  #include <sys/systm.h>
  33   33  #include <sys/sysmacros.h>
  34   34  #include <sys/debug.h>
  35   35  #include <sys/cmn_err.h>
  36   36  
  37   37  #include <sys/stropts.h>
  38   38  #include <sys/socket.h>
  39   39  #include <sys/socketvar.h>
       40 +#include <sys/fcntl.h>
  40   41  
  41   42  #define _SUN_TPI_VERSION        2
  42   43  #include <sys/tihdr.h>
  43   44  #include <sys/sockio.h>
  44   45  #include <sys/kmem_impl.h>
  45   46  
  46   47  #include <sys/strsubr.h>
  47   48  #include <sys/strsun.h>
  48   49  #include <sys/ddi.h>
  49   50  #include <netinet/in.h>
↓ open down ↓ 300 lines elided ↑ open up ↑
 350  351  
 351  352                  /* finish the accept */
 352  353                  if ((so->so_filter_active > 0 &&
 353  354                      (error = sof_filter_accept(nso, cr)) > 0) ||
 354  355                      (error = (*so->so_downcalls->sd_accept)(so->so_proto_handle,
 355  356                      nso->so_proto_handle, (sock_upper_handle_t)nso, cr)) != 0) {
 356  357                          (void) socket_close(nso, 0, cr);
 357  358                          socket_destroy(nso);
 358  359                  } else {
 359  360                          *nsop = nso;
      361 +                        sonode_insert_pid(nso, curproc);
 360  362                  }
 361  363          }
 362  364  
 363  365          SO_UNBLOCK_FALLBACK(so);
 364  366          return (error);
 365  367  }
 366  368  
 367  369  int
 368  370  so_sendmsg(struct sonode *so, struct nmsghdr *msg, struct uio *uiop,
 369  371      struct cred *cr)
↓ open down ↓ 1163 lines elided ↑ open up ↑
1533 1535   * will drop the protocol's reference on the socket.
1534 1536   */
1535 1537  void
1536 1538  so_closed(sock_upper_handle_t sock_handle)
1537 1539  {
1538 1540          struct sonode *so = (struct sonode *)sock_handle;
1539 1541  
1540 1542          VN_RELE(SOTOV(so));
1541 1543  }
1542 1544  
     1545 +conn_pid_node_list_hdr_t *
     1546 +so_get_sock_pid_list(sock_upper_handle_t sock_handle)
     1547 +{
     1548 +        int sz, n = 0;
     1549 +        pid_node_t                      *pn;
     1550 +        conn_pid_node_t                 *cpn;
     1551 +        conn_pid_node_list_hdr_t        *cph;
     1552 +        struct sonode                   *so = (struct sonode *)sock_handle;
     1553 +
     1554 +        mutex_enter(&so->so_pid_list_lock);
     1555 +
     1556 +        n = list_size(&so->so_pid_list);
     1557 +        sz = sizeof (conn_pid_node_list_hdr_t);
     1558 +        sz += (n > 1)?((n - 1) * sizeof (conn_pid_node_t)):0;
     1559 +        cph = kmem_zalloc(sz, KM_SLEEP);
     1560 +
     1561 +        cph->cph_magic = CONN_PID_NODE_LIST_HDR_MAGIC;
     1562 +        cph->cph_contents = CONN_PID_NODE_LIST_HDR_SOC;
     1563 +        cph->cph_pn_cnt = n;
     1564 +        cph->cph_tot_size = sz;
     1565 +        cph->cph_flags = 0;
     1566 +        cph->cph_optional1 = 0;
     1567 +        cph->cph_optional2 = 0;
     1568 +
     1569 +        if (cph->cph_pn_cnt > 0) {
     1570 +                cpn = cph->cph_cpns;
     1571 +                pn = list_head(&so->so_pid_list);
     1572 +                while (pn != NULL) {
     1573 +                        PIDNODE2CONNPIDNODE(pn, cpn);
     1574 +                        pn = list_next(&so->so_pid_list, pn);
     1575 +                        cpn++;
     1576 +                }
     1577 +        }
     1578 +
     1579 +        mutex_exit(&so->so_pid_list_lock);
     1580 +
     1581 +        return (cph);
     1582 +}
     1583 +
1543 1584  void
1544 1585  so_zcopy_notify(sock_upper_handle_t sock_handle)
1545 1586  {
1546 1587          struct sonode *so = (struct sonode *)sock_handle;
1547 1588  
1548 1589          mutex_enter(&so->so_lock);
1549 1590          so->so_copyflag |= STZCNOTIFY;
1550 1591          cv_broadcast(&so->so_copy_cv);
1551 1592          mutex_exit(&so->so_lock);
1552 1593  }
↓ open down ↓ 380 lines elided ↑ open up ↑
1933 1974          so_newconn,
1934 1975          so_connected,
1935 1976          so_disconnected,
1936 1977          so_opctl,
1937 1978          so_queue_msg,
1938 1979          so_set_prop,
1939 1980          so_txq_full,
1940 1981          so_signal_oob,
1941 1982          so_zcopy_notify,
1942 1983          so_set_error,
1943      -        so_closed
     1984 +        so_closed,
     1985 +        so_get_sock_pid_list
1944 1986  };
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX