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 * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
24 * Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
25 */
26 /* Copyright (c) 1990 Mentat Inc. */
27
28 #include <sys/types.h>
29 #include <sys/stream.h>
30 #include <sys/stropts.h>
31 #include <sys/strlog.h>
32 #include <sys/strsun.h>
33 #define _SUN_TPI_VERSION 2
34 #include <sys/tihdr.h>
35 #include <sys/timod.h>
36 #include <sys/ddi.h>
37 #include <sys/sunddi.h>
38 #include <sys/strsubr.h>
39 #include <sys/suntpi.h>
40 #include <sys/xti_inet.h>
41 #include <sys/kmem.h>
42 #include <sys/cred_impl.h>
43 #include <sys/policy.h>
44 #include <sys/priv.h>
45 #include <sys/ucred.h>
46 #include <sys/zone.h>
47
4367 major_t major;
4368 size_t arrsz;
4369
4370 us = (udp_stack_t *)kmem_zalloc(sizeof (*us), KM_SLEEP);
4371 us->us_netstack = ns;
4372
4373 mutex_init(&us->us_epriv_port_lock, NULL, MUTEX_DEFAULT, NULL);
4374 us->us_num_epriv_ports = UDP_NUM_EPRIV_PORTS;
4375 us->us_epriv_ports[0] = ULP_DEF_EPRIV_PORT1;
4376 us->us_epriv_ports[1] = ULP_DEF_EPRIV_PORT2;
4377
4378 /*
4379 * The smallest anonymous port in the priviledged port range which UDP
4380 * looks for free port. Use in the option UDP_ANONPRIVBIND.
4381 */
4382 us->us_min_anonpriv_port = 512;
4383
4384 us->us_bind_fanout_size = udp_bind_fanout_size;
4385
4386 /* Roundup variable that might have been modified in /etc/system */
4387 if (us->us_bind_fanout_size & (us->us_bind_fanout_size - 1)) {
4388 /* Not a power of two. Round up to nearest power of two */
4389 for (i = 0; i < 31; i++) {
4390 if (us->us_bind_fanout_size < (1 << i))
4391 break;
4392 }
4393 us->us_bind_fanout_size = 1 << i;
4394 }
4395 us->us_bind_fanout = kmem_zalloc(us->us_bind_fanout_size *
4396 sizeof (udp_fanout_t), KM_SLEEP);
4397 for (i = 0; i < us->us_bind_fanout_size; i++) {
4398 mutex_init(&us->us_bind_fanout[i].uf_lock, NULL, MUTEX_DEFAULT,
4399 NULL);
4400 }
4401
4402 arrsz = udp_propinfo_count * sizeof (mod_prop_info_t);
4403 us->us_propinfo_tbl = (mod_prop_info_t *)kmem_alloc(arrsz,
4404 KM_SLEEP);
4405 bcopy(udp_propinfo_tbl, us->us_propinfo_tbl, arrsz);
4406
4407 /* Allocate the per netstack stats */
|
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 * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
24 * Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
25 */
26 /* Copyright (c) 1990 Mentat Inc. */
27
28 #include <sys/sysmacros.h>
29 #include <sys/types.h>
30 #include <sys/stream.h>
31 #include <sys/stropts.h>
32 #include <sys/strlog.h>
33 #include <sys/strsun.h>
34 #define _SUN_TPI_VERSION 2
35 #include <sys/tihdr.h>
36 #include <sys/timod.h>
37 #include <sys/ddi.h>
38 #include <sys/sunddi.h>
39 #include <sys/strsubr.h>
40 #include <sys/suntpi.h>
41 #include <sys/xti_inet.h>
42 #include <sys/kmem.h>
43 #include <sys/cred_impl.h>
44 #include <sys/policy.h>
45 #include <sys/priv.h>
46 #include <sys/ucred.h>
47 #include <sys/zone.h>
48
4368 major_t major;
4369 size_t arrsz;
4370
4371 us = (udp_stack_t *)kmem_zalloc(sizeof (*us), KM_SLEEP);
4372 us->us_netstack = ns;
4373
4374 mutex_init(&us->us_epriv_port_lock, NULL, MUTEX_DEFAULT, NULL);
4375 us->us_num_epriv_ports = UDP_NUM_EPRIV_PORTS;
4376 us->us_epriv_ports[0] = ULP_DEF_EPRIV_PORT1;
4377 us->us_epriv_ports[1] = ULP_DEF_EPRIV_PORT2;
4378
4379 /*
4380 * The smallest anonymous port in the priviledged port range which UDP
4381 * looks for free port. Use in the option UDP_ANONPRIVBIND.
4382 */
4383 us->us_min_anonpriv_port = 512;
4384
4385 us->us_bind_fanout_size = udp_bind_fanout_size;
4386
4387 /* Roundup variable that might have been modified in /etc/system */
4388 if (!ISP2(us->us_bind_fanout_size)) {
4389 /* Not a power of two. Round up to nearest power of two */
4390 for (i = 0; i < 31; i++) {
4391 if (us->us_bind_fanout_size < (1 << i))
4392 break;
4393 }
4394 us->us_bind_fanout_size = 1 << i;
4395 }
4396 us->us_bind_fanout = kmem_zalloc(us->us_bind_fanout_size *
4397 sizeof (udp_fanout_t), KM_SLEEP);
4398 for (i = 0; i < us->us_bind_fanout_size; i++) {
4399 mutex_init(&us->us_bind_fanout[i].uf_lock, NULL, MUTEX_DEFAULT,
4400 NULL);
4401 }
4402
4403 arrsz = udp_propinfo_count * sizeof (mod_prop_info_t);
4404 us->us_propinfo_tbl = (mod_prop_info_t *)kmem_alloc(arrsz,
4405 KM_SLEEP);
4406 bcopy(udp_propinfo_tbl, us->us_propinfo_tbl, arrsz);
4407
4408 /* Allocate the per netstack stats */
|