xref: /titanic_52/usr/src/uts/common/inet/tcp_stack.h (revision 721fffe35d40e548a5a58dc53a2ec9c6762172d9)
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 	uint16_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 	/* Only modified during _init and _fini thus no locking is needed. */
65 	caddr_t		tcps_g_nd;
66 	struct tcpparam_s *tcps_params;	/* ndd parameters */
67 	struct tcpparam_s *tcps_wroff_xtra_param;
68 
69 	/* Hint not protected by any lock */
70 	uint_t		tcps_next_port_to_try;
71 
72 	/* TCP bind hash list - all tcp_t with state >= BOUND. */
73 	struct tf_s	*tcps_bind_fanout;
74 
75 	/* TCP queue hash list - all tcp_t in case they will be an acceptor. */
76 	struct tf_s	*tcps_acceptor_fanout;
77 
78 	/*
79 	 * MIB-2 stuff for SNMP
80 	 * Note: tcpInErrs {tcp 15} is accumulated in ip.c
81 	 */
82 	kstat_t		*tcps_mibkp;	/* kstat exporting tcp_mib data */
83 	kstat_t		*tcps_kstat;
84 
85 	uint32_t	tcps_iss_incr_extra;
86 				/* Incremented for each connection */
87 	kmutex_t	tcps_iss_key_lock;
88 	MD5_CTX		tcps_iss_key;
89 
90 	/* Packet dropper for TCP IPsec policy drops. */
91 	ipdropper_t	tcps_dropper;
92 
93 	/*
94 	 * These two variables control the rate for TCP to generate RSTs in
95 	 * response to segments not belonging to any connections.  We limit
96 	 * TCP to sent out tcp_rst_sent_rate (ndd param) number of RSTs in
97 	 * each 1 second interval.  This is to protect TCP against DoS attack.
98 	 */
99 	int64_t		tcps_last_rst_intrvl;
100 	uint32_t	tcps_rst_cnt;
101 
102 	ldi_ident_t	tcps_ldi_ident;
103 
104 	/* Used to synchronize access when reclaiming memory */
105 	mblk_t		*tcps_ixa_cleanup_mp;
106 	kmutex_t	tcps_ixa_cleanup_lock;
107 	kcondvar_t	tcps_ixa_cleanup_cv;
108 
109 	/* Variables for handling kmem reclaim call back. */
110 	kmutex_t	tcps_reclaim_lock;
111 	boolean_t	tcps_reclaim;
112 	timeout_id_t	tcps_reclaim_tid;
113 	uint32_t	tcps_reclaim_period;
114 
115 	/* Listener connection limit configuration. */
116 	kmutex_t	tcps_listener_conf_lock;
117 	list_t		tcps_listener_conf;
118 
119 	/*
120 	 * Per CPU stats
121 	 *
122 	 * tcps_sc: array of pointer to per CPU stats.  The i-th element in the
123 	 *    array represents the stats of the CPU with cpu_seqid.
124 	 * tcps_sc_cnt: number of CPU stats in the tcps_sc array.
125 	 */
126 	tcp_stats_cpu_t	**tcps_sc;
127 	int		tcps_sc_cnt;
128 };
129 
130 typedef struct tcp_stack tcp_stack_t;
131 
132 #endif /* _KERNEL */
133 #ifdef	__cplusplus
134 }
135 #endif
136 
137 #endif	/* _INET_TCP_STACK_H */
138