xref: /titanic_44/usr/src/uts/common/inet/tcp_stack.h (revision 7c6d7024e51780d3aacf9063d2133c1e957d7eea)
1f4b3ec61Sdh155122 /*
2f4b3ec61Sdh155122  * CDDL HEADER START
3f4b3ec61Sdh155122  *
4f4b3ec61Sdh155122  * The contents of this file are subject to the terms of the
5f4b3ec61Sdh155122  * Common Development and Distribution License (the "License").
6f4b3ec61Sdh155122  * You may not use this file except in compliance with the License.
7f4b3ec61Sdh155122  *
8f4b3ec61Sdh155122  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9f4b3ec61Sdh155122  * or http://www.opensolaris.org/os/licensing.
10f4b3ec61Sdh155122  * See the License for the specific language governing permissions
11f4b3ec61Sdh155122  * and limitations under the License.
12f4b3ec61Sdh155122  *
13f4b3ec61Sdh155122  * When distributing Covered Code, include this CDDL HEADER in each
14f4b3ec61Sdh155122  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15f4b3ec61Sdh155122  * If applicable, add the following below this CDDL HEADER, with the
16f4b3ec61Sdh155122  * fields enclosed by brackets "[]" replaced with your own identifying
17f4b3ec61Sdh155122  * information: Portions Copyright [yyyy] [name of copyright owner]
18f4b3ec61Sdh155122  *
19f4b3ec61Sdh155122  * CDDL HEADER END
20f4b3ec61Sdh155122  */
21f4b3ec61Sdh155122 
22f4b3ec61Sdh155122 /*
235dd46ab5SKacheong Poon  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24f4b3ec61Sdh155122  */
25f4b3ec61Sdh155122 
26f4b3ec61Sdh155122 #ifndef	_INET_TCP_STACK_H
27f4b3ec61Sdh155122 #define	_INET_TCP_STACK_H
28f4b3ec61Sdh155122 
29f4b3ec61Sdh155122 #include <sys/netstack.h>
30f4b3ec61Sdh155122 #include <inet/ip.h>
31f4b3ec61Sdh155122 #include <inet/ipdrop.h>
32721fffe3SKacheong Poon #include <inet/tcp_stats.h>
330f1702c5SYu Xiangning #include <sys/sunddi.h>
340f1702c5SYu Xiangning #include <sys/sunldi.h>
35f4b3ec61Sdh155122 
36f4b3ec61Sdh155122 #ifdef	__cplusplus
37f4b3ec61Sdh155122 extern "C" {
38f4b3ec61Sdh155122 #endif
39f4b3ec61Sdh155122 
40f4b3ec61Sdh155122 #ifdef _KERNEL
41f4b3ec61Sdh155122 
42f4b3ec61Sdh155122 /*
43f4b3ec61Sdh155122  * TCP stack instances
44f4b3ec61Sdh155122  */
45f4b3ec61Sdh155122 struct tcp_stack {
46f4b3ec61Sdh155122 	netstack_t	*tcps_netstack;	/* Common netstack */
47f4b3ec61Sdh155122 
48f4b3ec61Sdh155122 	/*
49f4b3ec61Sdh155122 	 * Extra privileged ports. In host byte order.
50f4b3ec61Sdh155122 	 * Protected by tcp_epriv_port_lock.
51f4b3ec61Sdh155122 	 */
52f4b3ec61Sdh155122 #define	TCP_NUM_EPRIV_PORTS	64
53f4b3ec61Sdh155122 	int		tcps_g_num_epriv_ports;
546e91bba0SGirish Moodalbail 	in_port_t	tcps_g_epriv_ports[TCP_NUM_EPRIV_PORTS];
55f4b3ec61Sdh155122 	kmutex_t	tcps_epriv_port_lock;
56f4b3ec61Sdh155122 
57f4b3ec61Sdh155122 	/*
58f4b3ec61Sdh155122 	 * The smallest anonymous port in the priviledged port range which TCP
59f4b3ec61Sdh155122 	 * looks for free port.  Use in the option TCP_ANONPRIVBIND.
60f4b3ec61Sdh155122 	 */
61f4b3ec61Sdh155122 	in_port_t	tcps_min_anonpriv_port;
62f4b3ec61Sdh155122 
636e91bba0SGirish Moodalbail 	/* holds the tcp tunables */
646e91bba0SGirish Moodalbail 	struct mod_prop_info_s *tcps_propinfo_tbl;
65f4b3ec61Sdh155122 
66f4b3ec61Sdh155122 	/* Hint not protected by any lock */
67f4b3ec61Sdh155122 	uint_t		tcps_next_port_to_try;
68f4b3ec61Sdh155122 
69f4b3ec61Sdh155122 	/* TCP bind hash list - all tcp_t with state >= BOUND. */
70f4b3ec61Sdh155122 	struct tf_s	*tcps_bind_fanout;
71f4b3ec61Sdh155122 
72f4b3ec61Sdh155122 	/* TCP queue hash list - all tcp_t in case they will be an acceptor. */
73f4b3ec61Sdh155122 	struct tf_s	*tcps_acceptor_fanout;
74f4b3ec61Sdh155122 
75f4b3ec61Sdh155122 	/*
76f4b3ec61Sdh155122 	 * MIB-2 stuff for SNMP
77f4b3ec61Sdh155122 	 * Note: tcpInErrs {tcp 15} is accumulated in ip.c
78f4b3ec61Sdh155122 	 */
795dd46ab5SKacheong Poon 	kstat_t		*tcps_mibkp;	/* kstat exporting mib2_tcp_t data */
805dd46ab5SKacheong Poon 	kstat_t		*tcps_kstat;	/* kstat exporting tcp_stat_t data */
81f4b3ec61Sdh155122 
82f4b3ec61Sdh155122 	uint32_t	tcps_iss_incr_extra;
83f4b3ec61Sdh155122 				/* Incremented for each connection */
84f4b3ec61Sdh155122 	kmutex_t	tcps_iss_key_lock;
85f4b3ec61Sdh155122 	MD5_CTX		tcps_iss_key;
86f4b3ec61Sdh155122 
87f4b3ec61Sdh155122 	/* Packet dropper for TCP IPsec policy drops. */
88f4b3ec61Sdh155122 	ipdropper_t	tcps_dropper;
89f4b3ec61Sdh155122 
90f4b3ec61Sdh155122 	/*
91f4b3ec61Sdh155122 	 * These two variables control the rate for TCP to generate RSTs in
92f4b3ec61Sdh155122 	 * response to segments not belonging to any connections.  We limit
93f4b3ec61Sdh155122 	 * TCP to sent out tcp_rst_sent_rate (ndd param) number of RSTs in
94f4b3ec61Sdh155122 	 * each 1 second interval.  This is to protect TCP against DoS attack.
95f4b3ec61Sdh155122 	 */
9693fcb0b9SKacheong Poon 	int64_t		tcps_last_rst_intrvl;
97f4b3ec61Sdh155122 	uint32_t	tcps_rst_cnt;
9893fcb0b9SKacheong Poon 
990f1702c5SYu Xiangning 	ldi_ident_t	tcps_ldi_ident;
100bd670b35SErik Nordmark 
101bd670b35SErik Nordmark 	/* Used to synchronize access when reclaiming memory */
102bd670b35SErik Nordmark 	mblk_t		*tcps_ixa_cleanup_mp;
103bd670b35SErik Nordmark 	kmutex_t	tcps_ixa_cleanup_lock;
104*7c6d7024SJerry Jelinek 	kcondvar_t	tcps_ixa_cleanup_ready_cv;
105*7c6d7024SJerry Jelinek 	kcondvar_t	tcps_ixa_cleanup_done_cv;
10693fcb0b9SKacheong Poon 
10793fcb0b9SKacheong Poon 	/* Variables for handling kmem reclaim call back. */
10893fcb0b9SKacheong Poon 	kmutex_t	tcps_reclaim_lock;
10993fcb0b9SKacheong Poon 	boolean_t	tcps_reclaim;
11093fcb0b9SKacheong Poon 	timeout_id_t	tcps_reclaim_tid;
11193fcb0b9SKacheong Poon 	uint32_t	tcps_reclaim_period;
11293fcb0b9SKacheong Poon 
11393fcb0b9SKacheong Poon 	/* Listener connection limit configuration. */
11493fcb0b9SKacheong Poon 	kmutex_t	tcps_listener_conf_lock;
11593fcb0b9SKacheong Poon 	list_t		tcps_listener_conf;
116721fffe3SKacheong Poon 
117721fffe3SKacheong Poon 	/*
118721fffe3SKacheong Poon 	 * Per CPU stats
119721fffe3SKacheong Poon 	 *
120721fffe3SKacheong Poon 	 * tcps_sc: array of pointer to per CPU stats.  The i-th element in the
121721fffe3SKacheong Poon 	 *    array represents the stats of the CPU with cpu_seqid.
122721fffe3SKacheong Poon 	 * tcps_sc_cnt: number of CPU stats in the tcps_sc array.
123721fffe3SKacheong Poon 	 */
124721fffe3SKacheong Poon 	tcp_stats_cpu_t	**tcps_sc;
125721fffe3SKacheong Poon 	int		tcps_sc_cnt;
126f4b3ec61Sdh155122 };
127721fffe3SKacheong Poon 
128f4b3ec61Sdh155122 typedef struct tcp_stack tcp_stack_t;
129f4b3ec61Sdh155122 
130f4b3ec61Sdh155122 #endif /* _KERNEL */
131f4b3ec61Sdh155122 #ifdef	__cplusplus
132f4b3ec61Sdh155122 }
133f4b3ec61Sdh155122 #endif
134f4b3ec61Sdh155122 
135f4b3ec61Sdh155122 #endif	/* _INET_TCP_STACK_H */
136