Print this page
5255 uts shouldn't open-code ISP2


   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 

  26 #include <sys/socket.h>
  27 #include <sys/ddi.h>
  28 #include <sys/sunddi.h>
  29 #include <sys/tsol/tndb.h>
  30 #include <sys/tsol/tnet.h>
  31 
  32 #include <netinet/in.h>
  33 #include <netinet/ip6.h>
  34 
  35 #include <inet/common.h>
  36 #include <inet/ip.h>
  37 #include <inet/ip6.h>
  38 #include <inet/ipclassifier.h>
  39 #include <inet/ipsec_impl.h>
  40 #include <inet/ipp_common.h>
  41 #include <inet/sctp_ip.h>
  42 
  43 #include "sctp_impl.h"
  44 #include "sctp_addr.h"
  45 


  49 uint_t          sctp_conn_hash_size = SCTP_CONN_HASH_SIZE; /* /etc/system */
  50 
  51 /*
  52  * Cluster networking hook for traversing current assoc list.
  53  * This routine is used to extract the current list of live associations
  54  * which must continue to to be dispatched to this node.
  55  */
  56 int cl_sctp_walk_list(int (*cl_callback)(cl_sctp_info_t *, void *), void *,
  57     boolean_t);
  58 static int cl_sctp_walk_list_stack(int (*cl_callback)(cl_sctp_info_t *,
  59     void *), void *arg, boolean_t cansleep, sctp_stack_t *sctps);
  60 
  61 void
  62 sctp_hash_init(sctp_stack_t *sctps)
  63 {
  64         int i;
  65 
  66         /* Start with /etc/system value */
  67         sctps->sctps_conn_hash_size = sctp_conn_hash_size;
  68 
  69         if (sctps->sctps_conn_hash_size & (sctps->sctps_conn_hash_size - 1)) {
  70                 /* Not a power of two. Round up to nearest power of two */
  71                 for (i = 0; i < 31; i++) {
  72                         if (sctps->sctps_conn_hash_size < (1 << i))
  73                                 break;
  74                 }
  75                 sctps->sctps_conn_hash_size = 1 << i;
  76         }
  77         if (sctps->sctps_conn_hash_size < SCTP_CONN_HASH_SIZE) {
  78                 sctps->sctps_conn_hash_size = SCTP_CONN_HASH_SIZE;
  79                 cmn_err(CE_CONT, "using sctp_conn_hash_size = %u\n",
  80                     sctps->sctps_conn_hash_size);
  81         }
  82         sctps->sctps_conn_fanout =
  83             (sctp_tf_t *)kmem_zalloc(sctps->sctps_conn_hash_size *
  84             sizeof (sctp_tf_t), KM_SLEEP);
  85         for (i = 0; i < sctps->sctps_conn_hash_size; i++) {
  86                 mutex_init(&sctps->sctps_conn_fanout[i].tf_lock, NULL,
  87                     MUTEX_DEFAULT, NULL);
  88         }
  89         sctps->sctps_listen_fanout = kmem_zalloc(SCTP_LISTEN_FANOUT_SIZE *




   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 
  26 #include <sys/sysmacros.h>
  27 #include <sys/socket.h>
  28 #include <sys/ddi.h>
  29 #include <sys/sunddi.h>
  30 #include <sys/tsol/tndb.h>
  31 #include <sys/tsol/tnet.h>
  32 
  33 #include <netinet/in.h>
  34 #include <netinet/ip6.h>
  35 
  36 #include <inet/common.h>
  37 #include <inet/ip.h>
  38 #include <inet/ip6.h>
  39 #include <inet/ipclassifier.h>
  40 #include <inet/ipsec_impl.h>
  41 #include <inet/ipp_common.h>
  42 #include <inet/sctp_ip.h>
  43 
  44 #include "sctp_impl.h"
  45 #include "sctp_addr.h"
  46 


  50 uint_t          sctp_conn_hash_size = SCTP_CONN_HASH_SIZE; /* /etc/system */
  51 
  52 /*
  53  * Cluster networking hook for traversing current assoc list.
  54  * This routine is used to extract the current list of live associations
  55  * which must continue to to be dispatched to this node.
  56  */
  57 int cl_sctp_walk_list(int (*cl_callback)(cl_sctp_info_t *, void *), void *,
  58     boolean_t);
  59 static int cl_sctp_walk_list_stack(int (*cl_callback)(cl_sctp_info_t *,
  60     void *), void *arg, boolean_t cansleep, sctp_stack_t *sctps);
  61 
  62 void
  63 sctp_hash_init(sctp_stack_t *sctps)
  64 {
  65         int i;
  66 
  67         /* Start with /etc/system value */
  68         sctps->sctps_conn_hash_size = sctp_conn_hash_size;
  69 
  70         if (!ISP2(sctps->sctps_conn_hash_size)) {
  71                 /* Not a power of two. Round up to nearest power of two */
  72                 for (i = 0; i < 31; i++) {
  73                         if (sctps->sctps_conn_hash_size < (1 << i))
  74                                 break;
  75                 }
  76                 sctps->sctps_conn_hash_size = 1 << i;
  77         }
  78         if (sctps->sctps_conn_hash_size < SCTP_CONN_HASH_SIZE) {
  79                 sctps->sctps_conn_hash_size = SCTP_CONN_HASH_SIZE;
  80                 cmn_err(CE_CONT, "using sctp_conn_hash_size = %u\n",
  81                     sctps->sctps_conn_hash_size);
  82         }
  83         sctps->sctps_conn_fanout =
  84             (sctp_tf_t *)kmem_zalloc(sctps->sctps_conn_hash_size *
  85             sizeof (sctp_tf_t), KM_SLEEP);
  86         for (i = 0; i < sctps->sctps_conn_hash_size; i++) {
  87                 mutex_init(&sctps->sctps_conn_fanout[i].tf_lock, NULL,
  88                     MUTEX_DEFAULT, NULL);
  89         }
  90         sctps->sctps_listen_fanout = kmem_zalloc(SCTP_LISTEN_FANOUT_SIZE *