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