1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 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 2010 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _INET_TCP_STACK_H 28 #define _INET_TCP_STACK_H 29 30 #include <sys/netstack.h> 31 #include <inet/ip.h> 32 #include <inet/ipdrop.h> 33 #include <inet/tcp_stats.h> 34 #include <sys/sunddi.h> 35 #include <sys/sunldi.h> 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 #ifdef _KERNEL 42 43 /* 44 * TCP stack instances 45 */ 46 struct tcp_stack { 47 netstack_t *tcps_netstack; /* Common netstack */ 48 49 /* 50 * Extra privileged ports. In host byte order. 51 * Protected by tcp_epriv_port_lock. 52 */ 53 #define TCP_NUM_EPRIV_PORTS 64 54 int tcps_g_num_epriv_ports; 55 in_port_t tcps_g_epriv_ports[TCP_NUM_EPRIV_PORTS]; 56 kmutex_t tcps_epriv_port_lock; 57 58 /* 59 * The smallest anonymous port in the priviledged port range which TCP 60 * looks for free port. Use in the option TCP_ANONPRIVBIND. 61 */ 62 in_port_t tcps_min_anonpriv_port; 63 64 /* holds the tcp tunables */ 65 struct mod_prop_info_s *tcps_propinfo_tbl; 66 67 /* Hint not protected by any lock */ 68 uint_t tcps_next_port_to_try; 69 70 /* TCP bind hash list - all tcp_t with state >= BOUND. */ 71 struct tf_s *tcps_bind_fanout; 72 73 /* TCP queue hash list - all tcp_t in case they will be an acceptor. */ 74 struct tf_s *tcps_acceptor_fanout; 75 76 /* 77 * MIB-2 stuff for SNMP 78 * Note: tcpInErrs {tcp 15} is accumulated in ip.c 79 */ 80 kstat_t *tcps_mibkp; /* kstat exporting tcp_mib data */ 81 kstat_t *tcps_kstat; 82 83 uint32_t tcps_iss_incr_extra; 84 /* Incremented for each connection */ 85 kmutex_t tcps_iss_key_lock; 86 MD5_CTX tcps_iss_key; 87 88 /* Packet dropper for TCP IPsec policy drops. */ 89 ipdropper_t tcps_dropper; 90 91 /* 92 * These two variables control the rate for TCP to generate RSTs in 93 * response to segments not belonging to any connections. We limit 94 * TCP to sent out tcp_rst_sent_rate (ndd param) number of RSTs in 95 * each 1 second interval. This is to protect TCP against DoS attack. 96 */ 97 int64_t tcps_last_rst_intrvl; 98 uint32_t tcps_rst_cnt; 99 100 ldi_ident_t tcps_ldi_ident; 101 102 /* Used to synchronize access when reclaiming memory */ 103 mblk_t *tcps_ixa_cleanup_mp; 104 kmutex_t tcps_ixa_cleanup_lock; 105 kcondvar_t tcps_ixa_cleanup_cv; 106 107 /* Variables for handling kmem reclaim call back. */ 108 kmutex_t tcps_reclaim_lock; 109 boolean_t tcps_reclaim; 110 timeout_id_t tcps_reclaim_tid; 111 uint32_t tcps_reclaim_period; 112 113 /* Listener connection limit configuration. */ 114 kmutex_t tcps_listener_conf_lock; 115 list_t tcps_listener_conf; 116 117 /* 118 * Per CPU stats 119 * 120 * tcps_sc: array of pointer to per CPU stats. The i-th element in the 121 * array represents the stats of the CPU with cpu_seqid. 122 * tcps_sc_cnt: number of CPU stats in the tcps_sc array. 123 */ 124 tcp_stats_cpu_t **tcps_sc; 125 int tcps_sc_cnt; 126 }; 127 128 typedef struct tcp_stack tcp_stack_t; 129 130 #endif /* _KERNEL */ 131 #ifdef __cplusplus 132 } 133 #endif 134 135 #endif /* _INET_TCP_STACK_H */ 136