Print this page
3903 DTrace SCTP Provider


 145                 int ret;
 146 
 147                 bzero(&ss, sizeof (ss));
 148                 ss.ss_family = connp->conn_family;
 149 
 150                 WAKE_SCTP(sctp);
 151                 if ((ret = sctp_bind(sctp, (struct sockaddr *)&ss,
 152                     sizeof (ss))) != 0)
 153                         return (ret);
 154                 RUN_SCTP(sctp)
 155         }
 156 
 157         /* Cache things in the ixa without any refhold */
 158         ASSERT(!(connp->conn_ixa->ixa_free_flags & IXA_FREE_CRED));
 159         connp->conn_ixa->ixa_cred = connp->conn_cred;
 160         connp->conn_ixa->ixa_cpid = connp->conn_cpid;
 161         if (is_system_labeled())
 162                 connp->conn_ixa->ixa_tsl = crgetlabel(connp->conn_cred);
 163 
 164         sctp->sctp_state = SCTPS_LISTEN;



 165         (void) random_get_pseudo_bytes(sctp->sctp_secret, SCTP_SECRET_LEN);
 166         sctp->sctp_last_secret_update = ddi_get_lbolt64();
 167         bzero(sctp->sctp_old_secret, SCTP_SECRET_LEN);
 168 
 169         /*
 170          * If there is an association limit, allocate and initialize
 171          * the counter struct.  Note that since listen can be called
 172          * multiple times, the struct may have been allready allocated.
 173          */
 174         if (!list_is_empty(&sctps->sctps_listener_conf) &&
 175             sctp->sctp_listen_cnt == NULL) {
 176                 sctp_listen_cnt_t *slc;
 177                 uint32_t ratio;
 178 
 179                 ratio = sctp_find_listener_conf(sctps,
 180                     ntohs(connp->conn_lport));
 181                 if (ratio != 0) {
 182                         uint32_t mem_ratio, tot_buf;
 183 
 184                         slc = kmem_alloc(sizeof (sctp_listen_cnt_t), KM_SLEEP);


 691                                          * to the shared stack.
 692                                          */
 693 
 694                                         if (mlptype == mlptShared &&
 695                                             addrtype == mlptShared &&
 696                                             connp->conn_zoneid !=
 697                                             tsol_mlp_findzone(IPPROTO_SCTP,
 698                                             lport)) {
 699                                                 mutex_exit(&tbf->tf_lock);
 700                                                 return (EACCES);
 701                                         }
 702                                         connp->conn_mlp_type = mlptype;
 703                                 }
 704                         }
 705                         /*
 706                          * This port is ours. Insert in fanout and mark as
 707                          * bound to prevent others from getting the port
 708                          * number.
 709                          */
 710                         sctp->sctp_state = SCTPS_BOUND;




 711                         connp->conn_lport = lport;
 712 
 713                         ASSERT(&sctps->sctps_bind_fanout[
 714                             SCTP_BIND_HASH(port)] == tbf);
 715                         sctp_bind_hash_insert(tbf, sctp, 1);
 716 
 717                         mutex_exit(&tbf->tf_lock);
 718 
 719                         /*
 720                          * We don't want sctp_next_port_to_try to "inherit"
 721                          * a port number supplied by the user in a bind.
 722                          *
 723                          * This is the only place where sctp_next_port_to_try
 724                          * is updated. After the update, it may or may not
 725                          * be in the valid range.
 726                          */
 727                         if (user_specified == 0)
 728                                 sctps->sctps_next_port_to_try = port + 1;
 729 
 730                         *allocated_port = port;




 145                 int ret;
 146 
 147                 bzero(&ss, sizeof (ss));
 148                 ss.ss_family = connp->conn_family;
 149 
 150                 WAKE_SCTP(sctp);
 151                 if ((ret = sctp_bind(sctp, (struct sockaddr *)&ss,
 152                     sizeof (ss))) != 0)
 153                         return (ret);
 154                 RUN_SCTP(sctp)
 155         }
 156 
 157         /* Cache things in the ixa without any refhold */
 158         ASSERT(!(connp->conn_ixa->ixa_free_flags & IXA_FREE_CRED));
 159         connp->conn_ixa->ixa_cred = connp->conn_cred;
 160         connp->conn_ixa->ixa_cpid = connp->conn_cpid;
 161         if (is_system_labeled())
 162                 connp->conn_ixa->ixa_tsl = crgetlabel(connp->conn_cred);
 163 
 164         sctp->sctp_state = SCTPS_LISTEN;
 165         DTRACE_SCTP6(state__change, void, NULL, ip_xmit_attr_t *,
 166             connp->conn_ixa, void, NULL, sctp_t *, sctp, void, NULL,
 167             int32_t, SCTPS_BOUND);
 168         (void) random_get_pseudo_bytes(sctp->sctp_secret, SCTP_SECRET_LEN);
 169         sctp->sctp_last_secret_update = ddi_get_lbolt64();
 170         bzero(sctp->sctp_old_secret, SCTP_SECRET_LEN);
 171 
 172         /*
 173          * If there is an association limit, allocate and initialize
 174          * the counter struct.  Note that since listen can be called
 175          * multiple times, the struct may have been allready allocated.
 176          */
 177         if (!list_is_empty(&sctps->sctps_listener_conf) &&
 178             sctp->sctp_listen_cnt == NULL) {
 179                 sctp_listen_cnt_t *slc;
 180                 uint32_t ratio;
 181 
 182                 ratio = sctp_find_listener_conf(sctps,
 183                     ntohs(connp->conn_lport));
 184                 if (ratio != 0) {
 185                         uint32_t mem_ratio, tot_buf;
 186 
 187                         slc = kmem_alloc(sizeof (sctp_listen_cnt_t), KM_SLEEP);


 694                                          * to the shared stack.
 695                                          */
 696 
 697                                         if (mlptype == mlptShared &&
 698                                             addrtype == mlptShared &&
 699                                             connp->conn_zoneid !=
 700                                             tsol_mlp_findzone(IPPROTO_SCTP,
 701                                             lport)) {
 702                                                 mutex_exit(&tbf->tf_lock);
 703                                                 return (EACCES);
 704                                         }
 705                                         connp->conn_mlp_type = mlptype;
 706                                 }
 707                         }
 708                         /*
 709                          * This port is ours. Insert in fanout and mark as
 710                          * bound to prevent others from getting the port
 711                          * number.
 712                          */
 713                         sctp->sctp_state = SCTPS_BOUND;
 714                         DTRACE_SCTP6(state__change, void, NULL,
 715                             ip_xmit_attr_t *, connp->conn_ixa, void, NULL,
 716                             scpt_t *, sctp, void, NULL,
 717                             int32_t, SCTPS_IDLE);
 718                         connp->conn_lport = lport;
 719 
 720                         ASSERT(&sctps->sctps_bind_fanout[
 721                             SCTP_BIND_HASH(port)] == tbf);
 722                         sctp_bind_hash_insert(tbf, sctp, 1);
 723 
 724                         mutex_exit(&tbf->tf_lock);
 725 
 726                         /*
 727                          * We don't want sctp_next_port_to_try to "inherit"
 728                          * a port number supplied by the user in a bind.
 729                          *
 730                          * This is the only place where sctp_next_port_to_try
 731                          * is updated. After the update, it may or may not
 732                          * be in the valid range.
 733                          */
 734                         if (user_specified == 0)
 735                                 sctps->sctps_next_port_to_try = port + 1;
 736 
 737                         *allocated_port = port;