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

@@ -52,16 +52,20 @@
 static int      tcp_bind(sock_lower_handle_t, struct sockaddr *,
                     socklen_t, cred_t *);
 static int      tcp_listen(sock_lower_handle_t, int, cred_t *);
 static int      tcp_connect(sock_lower_handle_t, const struct sockaddr *,
                     socklen_t, sock_connid_t *, cred_t *);
+static int      tcp_getpeername(sock_lower_handle_t, struct sockaddr *,
+                    socklen_t *, cred_t *);
+static int      tcp_getsockname(sock_lower_handle_t, struct sockaddr *,
+                    socklen_t *, cred_t *);
 static int      tcp_getsockopt(sock_lower_handle_t, int, int, void *,
                     socklen_t *, cred_t *);
 static int      tcp_setsockopt(sock_lower_handle_t, int, int, const void *,
                     socklen_t, cred_t *);
 static int      tcp_sendmsg(sock_lower_handle_t, mblk_t *, struct nmsghdr *,
-                    cred_t *cr);
+                    cred_t *);
 static int      tcp_shutdown(sock_lower_handle_t, int, cred_t *);
 static void     tcp_clr_flowctrl(sock_lower_handle_t);
 static int      tcp_ioctl(sock_lower_handle_t, int, intptr_t, int, int32_t *,
                     cred_t *);
 static int      tcp_close(sock_lower_handle_t, int, cred_t *);

@@ -129,10 +133,13 @@
     cred_t *cr)
 {
         conn_t *lconnp, *econnp;
         tcp_t *listener, *eager;
 
+        /* All Solaris components should pass a cred for this operation. */
+        ASSERT(cr != NULL);
+
         /*
          * KSSL can move a socket from one listener to another, in which
          * case `lproto_handle' points to the new listener. To ensure that
          * the original listener is used the information is obtained from
          * the eager.

@@ -332,11 +339,11 @@
 
         return ((error == 0) ? EINPROGRESS : error);
 }
 
 /* ARGSUSED3 */
-int
+static int
 tcp_getpeername(sock_lower_handle_t proto_handle, struct sockaddr *addr,
     socklen_t *addrlenp, cred_t *cr)
 {
         conn_t  *connp = (conn_t *)proto_handle;
         tcp_t   *tcp = connp->conn_tcp;

@@ -350,11 +357,11 @@
 
         return (conn_getpeername(connp, addr, addrlenp));
 }
 
 /* ARGSUSED3 */
-int
+static int
 tcp_getsockname(sock_lower_handle_t proto_handle, struct sockaddr *addr,
     socklen_t *addrlenp, cred_t *cr)
 {
         conn_t  *connp = (conn_t *)proto_handle;
 

@@ -375,10 +382,13 @@
         void            *optvalp_buf;
         int             len;
 
         ASSERT(connp->conn_upper_handle != NULL);
 
+        /* All Solaris components should pass a cred for this operation. */
+        ASSERT(cr != NULL);
+
         error = proto_opt_check(level, option_name, *optlen, &max_optbuf_len,
             tcp_opt_obj.odb_opt_des_arr,
             tcp_opt_obj.odb_opt_arr_cnt,
             B_FALSE, B_TRUE, cr);
         if (error != 0) {

@@ -422,10 +432,14 @@
 {
         conn_t          *connp = (conn_t *)proto_handle;
         int             error;
 
         ASSERT(connp->conn_upper_handle != NULL);
+
+        /* All Solaris components should pass a cred for this operation. */
+        ASSERT(cr != NULL);
+
         /*
          * Entering the squeue synchronously can result in a context switch,
          * which can cause a rather sever performance degradation. So we try to
          * handle whatever options we can without entering the squeue.
          */

@@ -750,10 +764,11 @@
 tcp_create(int family, int type, int proto, sock_downcalls_t **sock_downcalls,
     uint_t *smodep, int *errorp, int flags, cred_t *credp)
 {
         conn_t          *connp;
         boolean_t       isv6 = family == AF_INET6;
+
         if (type != SOCK_STREAM || (family != AF_INET && family != AF_INET6) ||
             (proto != 0 && proto != IPPROTO_TCP)) {
                 *errorp = EPROTONOSUPPORT;
                 return (NULL);
         }

@@ -763,11 +778,11 @@
                 return (NULL);
         }
 
         /*
          * Put the ref for TCP. Ref for IP was already put
-         * by ipcl_conn_create. Also Make the conn_t globally
+         * by ipcl_conn_create. Also make the conn_t globally
          * visible to walkers
          */
         mutex_enter(&connp->conn_lock);
         CONN_INC_REF_LOCKED(connp);
         ASSERT(connp->conn_ref == 2);