Print this page
3065 some functions in the tcp module can be static

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/inet/tcp/tcp_socket.c
          +++ new/usr/src/uts/common/inet/tcp/tcp_socket.c
↓ open down ↓ 46 lines elided ↑ open up ↑
  47   47  
  48   48  static void     tcp_activate(sock_lower_handle_t, sock_upper_handle_t,
  49   49                      sock_upcalls_t *, int, cred_t *);
  50   50  static int      tcp_accept(sock_lower_handle_t, sock_lower_handle_t,
  51   51                      sock_upper_handle_t, cred_t *);
  52   52  static int      tcp_bind(sock_lower_handle_t, struct sockaddr *,
  53   53                      socklen_t, cred_t *);
  54   54  static int      tcp_listen(sock_lower_handle_t, int, cred_t *);
  55   55  static int      tcp_connect(sock_lower_handle_t, const struct sockaddr *,
  56   56                      socklen_t, sock_connid_t *, cred_t *);
       57 +static int      tcp_getpeername(sock_lower_handle_t, struct sockaddr *,
       58 +                    socklen_t *, cred_t *);
       59 +static int      tcp_getsockname(sock_lower_handle_t, struct sockaddr *,
       60 +                    socklen_t *, cred_t *);
  57   61  static int      tcp_getsockopt(sock_lower_handle_t, int, int, void *,
  58   62                      socklen_t *, cred_t *);
  59   63  static int      tcp_setsockopt(sock_lower_handle_t, int, int, const void *,
  60   64                      socklen_t, cred_t *);
  61   65  static int      tcp_sendmsg(sock_lower_handle_t, mblk_t *, struct nmsghdr *,
  62      -                    cred_t *cr);
       66 +                    cred_t *);
  63   67  static int      tcp_shutdown(sock_lower_handle_t, int, cred_t *);
  64   68  static void     tcp_clr_flowctrl(sock_lower_handle_t);
  65   69  static int      tcp_ioctl(sock_lower_handle_t, int, intptr_t, int, int32_t *,
  66   70                      cred_t *);
  67   71  static int      tcp_close(sock_lower_handle_t, int, cred_t *);
  68   72  
  69   73  sock_downcalls_t sock_tcp_downcalls = {
  70   74          tcp_activate,
  71   75          tcp_accept,
  72   76          tcp_bind,
↓ open down ↓ 51 lines elided ↑ open up ↑
 124  128  
 125  129  /*ARGSUSED*/
 126  130  static int
 127  131  tcp_accept(sock_lower_handle_t lproto_handle,
 128  132      sock_lower_handle_t eproto_handle, sock_upper_handle_t sock_handle,
 129  133      cred_t *cr)
 130  134  {
 131  135          conn_t *lconnp, *econnp;
 132  136          tcp_t *listener, *eager;
 133  137  
      138 +        /* All Solaris components should pass a cred for this operation. */
      139 +        ASSERT(cr != NULL);
      140 +
 134  141          /*
 135  142           * KSSL can move a socket from one listener to another, in which
 136  143           * case `lproto_handle' points to the new listener. To ensure that
 137  144           * the original listener is used the information is obtained from
 138  145           * the eager.
 139  146           */
 140  147          econnp = (conn_t *)eproto_handle;
 141  148          eager = econnp->conn_tcp;
 142  149          ASSERT(IPCL_IS_NONSTR(econnp));
 143  150          ASSERT(eager->tcp_listener != NULL);
↓ open down ↓ 183 lines elided ↑ open up ↑
 327  334                  (*connp->conn_upcalls->su_set_proto_props)(
 328  335                      connp->conn_upper_handle, &sopp);
 329  336          }
 330  337  done:
 331  338          squeue_synch_exit(connp);
 332  339  
 333  340          return ((error == 0) ? EINPROGRESS : error);
 334  341  }
 335  342  
 336  343  /* ARGSUSED3 */
 337      -int
      344 +static int
 338  345  tcp_getpeername(sock_lower_handle_t proto_handle, struct sockaddr *addr,
 339  346      socklen_t *addrlenp, cred_t *cr)
 340  347  {
 341  348          conn_t  *connp = (conn_t *)proto_handle;
 342  349          tcp_t   *tcp = connp->conn_tcp;
 343  350  
 344  351          /* All Solaris components should pass a cred for this operation. */
 345  352          ASSERT(cr != NULL);
 346  353  
 347  354          ASSERT(tcp != NULL);
 348  355          if (tcp->tcp_state < TCPS_SYN_RCVD)
 349  356                  return (ENOTCONN);
 350  357  
 351  358          return (conn_getpeername(connp, addr, addrlenp));
 352  359  }
 353  360  
 354  361  /* ARGSUSED3 */
 355      -int
      362 +static int
 356  363  tcp_getsockname(sock_lower_handle_t proto_handle, struct sockaddr *addr,
 357  364      socklen_t *addrlenp, cred_t *cr)
 358  365  {
 359  366          conn_t  *connp = (conn_t *)proto_handle;
 360  367  
 361  368          /* All Solaris components should pass a cred for this operation. */
 362  369          ASSERT(cr != NULL);
 363  370  
 364  371          return (conn_getsockname(connp, addr, addrlenp));
 365  372  }
↓ open down ↓ 4 lines elided ↑ open up ↑
 370  377      void *optvalp, socklen_t *optlen, cred_t *cr)
 371  378  {
 372  379          conn_t          *connp = (conn_t *)proto_handle;
 373  380          int             error;
 374  381          t_uscalar_t     max_optbuf_len;
 375  382          void            *optvalp_buf;
 376  383          int             len;
 377  384  
 378  385          ASSERT(connp->conn_upper_handle != NULL);
 379  386  
      387 +        /* All Solaris components should pass a cred for this operation. */
      388 +        ASSERT(cr != NULL);
      389 +
 380  390          error = proto_opt_check(level, option_name, *optlen, &max_optbuf_len,
 381  391              tcp_opt_obj.odb_opt_des_arr,
 382  392              tcp_opt_obj.odb_opt_arr_cnt,
 383  393              B_FALSE, B_TRUE, cr);
 384  394          if (error != 0) {
 385  395                  if (error < 0) {
 386  396                          error = proto_tlitosyserr(-error);
 387  397                  }
 388  398                  return (error);
 389  399          }
↓ open down ↓ 27 lines elided ↑ open up ↑
 417  427  }
 418  428  
 419  429  static int
 420  430  tcp_setsockopt(sock_lower_handle_t proto_handle, int level, int option_name,
 421  431      const void *optvalp, socklen_t optlen, cred_t *cr)
 422  432  {
 423  433          conn_t          *connp = (conn_t *)proto_handle;
 424  434          int             error;
 425  435  
 426  436          ASSERT(connp->conn_upper_handle != NULL);
      437 +
      438 +        /* All Solaris components should pass a cred for this operation. */
      439 +        ASSERT(cr != NULL);
      440 +
 427  441          /*
 428  442           * Entering the squeue synchronously can result in a context switch,
 429  443           * which can cause a rather sever performance degradation. So we try to
 430  444           * handle whatever options we can without entering the squeue.
 431  445           */
 432  446          if (level == IPPROTO_TCP) {
 433  447                  switch (option_name) {
 434  448                  case TCP_NODELAY:
 435  449                          if (optlen != sizeof (int32_t))
 436  450                                  return (EINVAL);
↓ open down ↓ 308 lines elided ↑ open up ↑
 745  759          return (EINPROGRESS);
 746  760  }
 747  761  
 748  762  /* ARGSUSED */
 749  763  sock_lower_handle_t
 750  764  tcp_create(int family, int type, int proto, sock_downcalls_t **sock_downcalls,
 751  765      uint_t *smodep, int *errorp, int flags, cred_t *credp)
 752  766  {
 753  767          conn_t          *connp;
 754  768          boolean_t       isv6 = family == AF_INET6;
      769 +
 755  770          if (type != SOCK_STREAM || (family != AF_INET && family != AF_INET6) ||
 756  771              (proto != 0 && proto != IPPROTO_TCP)) {
 757  772                  *errorp = EPROTONOSUPPORT;
 758  773                  return (NULL);
 759  774          }
 760  775  
 761  776          connp = tcp_create_common(credp, isv6, B_TRUE, errorp);
 762  777          if (connp == NULL) {
 763  778                  return (NULL);
 764  779          }
 765  780  
 766  781          /*
 767  782           * Put the ref for TCP. Ref for IP was already put
 768      -         * by ipcl_conn_create. Also Make the conn_t globally
      783 +         * by ipcl_conn_create. Also make the conn_t globally
 769  784           * visible to walkers
 770  785           */
 771  786          mutex_enter(&connp->conn_lock);
 772  787          CONN_INC_REF_LOCKED(connp);
 773  788          ASSERT(connp->conn_ref == 2);
 774  789          connp->conn_state_flags &= ~CONN_INCIPIENT;
 775  790  
 776  791          connp->conn_flags |= IPCL_NONSTR;
 777  792          mutex_exit(&connp->conn_lock);
 778  793  
↓ open down ↓ 394 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX