xref: /titanic_50/usr/src/uts/common/inet/tcp.h (revision 49d3bc91e27cd871b950d56c01398fa2f2e12ab4)
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  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
23  * Copyright (c) 2011, Joyent, Inc. All rights reserved.
24  */
25 /* Copyright (c) 1990 Mentat Inc. */
26 
27 #ifndef	_INET_TCP_H
28 #define	_INET_TCP_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 #include <sys/inttypes.h>
35 #include <netinet/ip6.h>
36 #include <netinet/tcp.h>
37 #include <sys/socket.h>
38 #include <sys/socket_proto.h>
39 #include <sys/md5.h>
40 #include <inet/common.h>
41 #include <inet/ip.h>
42 #include <inet/ip6.h>
43 #include <inet/mi.h>
44 #include <inet/mib2.h>
45 #include <inet/tcp_stack.h>
46 #include <inet/tcp_sack.h>
47 
48 /* TCP states */
49 #define	TCPS_CLOSED		-6
50 #define	TCPS_IDLE		-5	/* idle (opened, but not bound) */
51 #define	TCPS_BOUND		-4	/* bound, ready to connect or accept */
52 #define	TCPS_LISTEN		-3	/* listening for connection */
53 #define	TCPS_SYN_SENT		-2	/* active, have sent syn */
54 #define	TCPS_SYN_RCVD		-1	/* have received syn (and sent ours) */
55 /* states < TCPS_ESTABLISHED are those where connections not established */
56 #define	TCPS_ESTABLISHED	0	/* established */
57 #define	TCPS_CLOSE_WAIT		1	/* rcvd fin, waiting for close */
58 /* states > TCPS_CLOSE_WAIT are those where user has closed */
59 #define	TCPS_FIN_WAIT_1		2	/* have closed and sent fin */
60 #define	TCPS_CLOSING		3	/* closed, xchd FIN, await FIN ACK */
61 #define	TCPS_LAST_ACK		4	/* had fin and close; await FIN ACK */
62 /* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */
63 #define	TCPS_FIN_WAIT_2		5	/* have closed, fin is acked */
64 #define	TCPS_TIME_WAIT		6	/* in 2*msl quiet wait after close */
65 
66 /*
67  * Internal flags used in conjunction with the packet header flags.
68  * Used in tcp_input_data to keep track of what needs to be done.
69  */
70 #define	TH_LIMIT_XMIT		0x0400	/* Limited xmit is needed */
71 #define	TH_XMIT_NEEDED		0x0800	/* Window opened - send queued data */
72 #define	TH_REXMIT_NEEDED	0x1000	/* Time expired for unacked data */
73 #define	TH_ACK_NEEDED		0x2000	/* Send an ack now. */
74 #define	TH_NEED_SACK_REXMIT	0x4000	/* Use SACK info to retransmission */
75 #define	TH_ACK_TIMER_NEEDED	0x8000	/* Start the delayed ACK timer */
76 #define	TH_ORDREL_NEEDED	0x10000	/* Generate an ordrel indication */
77 #define	TH_MARKNEXT_NEEDED	0x20000	/* Data should have MSGMARKNEXT */
78 #define	TH_SEND_URP_MARK	0x40000	/* Send up tcp_urp_mark_mp */
79 
80 /*
81  * TCP sequence numbers are 32 bit integers operated
82  * on with modular arithmetic.  These macros can be
83  * used to compare such integers.
84  */
85 #define	SEQ_LT(a, b)	((int32_t)((a)-(b)) < 0)
86 #define	SEQ_LEQ(a, b)	((int32_t)((a)-(b)) <= 0)
87 #define	SEQ_GT(a, b)	((int32_t)((a)-(b)) > 0)
88 #define	SEQ_GEQ(a, b)	((int32_t)((a)-(b)) >= 0)
89 
90 /* TCP Protocol header */
91 typedef	struct tcphdr_s {
92 	uint8_t		th_lport[2];	/* Source port */
93 	uint8_t		th_fport[2];	/* Destination port */
94 	uint8_t		th_seq[4];	/* Sequence number */
95 	uint8_t		th_ack[4];	/* Acknowledgement number */
96 	uint8_t		th_offset_and_rsrvd[1]; /* Offset to the packet data */
97 	uint8_t		th_flags[1];
98 	uint8_t		th_win[2];	/* Allocation number */
99 	uint8_t		th_sum[2];	/* TCP checksum */
100 	uint8_t		th_urp[2];	/* Urgent pointer */
101 } tcph_t;
102 
103 #define	TCP_HDR_LENGTH(tcph) \
104 	((((tcph_t *)tcph)->th_offset_and_rsrvd[0] >>2) &(0xF << 2))
105 #define	TCP_MAX_COMBINED_HEADER_LENGTH	(60 + 60) /* Maxed out ip + tcp */
106 #define	TCP_MAX_IP_OPTIONS_LENGTH	(60 - IP_SIMPLE_HDR_LENGTH)
107 #define	TCP_MAX_HDR_LENGTH		60
108 #define	TCP_MAX_TCP_OPTIONS_LENGTH	(60 - sizeof (tcpha_t))
109 #define	TCP_MIN_HEADER_LENGTH		20
110 #define	TCP_MAXWIN			65535
111 #define	TCP_PORT_LEN			sizeof (in_port_t)
112 #define	TCP_MAX_WINSHIFT		14
113 #define	TCP_MAX_LARGEWIN		(TCP_MAXWIN << TCP_MAX_WINSHIFT)
114 #define	TCP_MAX_LSO_LENGTH	(IP_MAXPACKET - TCP_MAX_COMBINED_HEADER_LENGTH)
115 
116 #define	TCPIP_HDR_LENGTH(mp, n)					\
117 	(n) = IPH_HDR_LENGTH((mp)->b_rptr),			\
118 	(n) += TCP_HDR_LENGTH((tcpha_t *)&(mp)->b_rptr[(n)])
119 
120 /* TCP Protocol header (used if the header is known to be 32-bit aligned) */
121 typedef	struct tcphdra_s {
122 	in_port_t	tha_lport;	/* Source port */
123 	in_port_t	tha_fport;	/* Destination port */
124 	uint32_t	tha_seq;	/* Sequence number */
125 	uint32_t	tha_ack;	/* Acknowledgement number */
126 	uint8_t tha_offset_and_reserved; /* Offset to the packet data */
127 	uint8_t		tha_flags;
128 	uint16_t	tha_win;	/* Allocation number */
129 	uint16_t	tha_sum;	/* TCP checksum */
130 	uint16_t	tha_urp;	/* Urgent pointer */
131 } tcpha_t;
132 
133 struct conn_s;
134 struct tcp_listen_cnt_s;
135 
136 /*
137  * Control structure for each open TCP stream,
138  * defined only within the kernel or for a kmem user.
139  * NOTE: tcp_reinit_values MUST have a line for each field in this structure!
140  */
141 #if (defined(_KERNEL) || defined(_KMEMUSER))
142 
143 typedef struct tcp_s {
144 	struct tcp_s	*tcp_time_wait_next;
145 				/* Pointer to next T/W block */
146 	struct tcp_s	*tcp_time_wait_prev;
147 				/* Pointer to previous T/W next */
148 	int64_t		tcp_time_wait_expire;
149 
150 	struct conn_s	*tcp_connp;	/* back pointer to conn_t */
151 	tcp_stack_t	*tcp_tcps;	/* back pointer to tcp_stack_t */
152 
153 	int32_t	tcp_state;
154 	int32_t	tcp_rcv_ws;		/* My window scale power */
155 	int32_t	tcp_snd_ws;		/* Sender's window scale power */
156 	uint32_t tcp_ts_recent;		/* Timestamp of earliest unacked */
157 					/*  data segment */
158 	clock_t	tcp_rto;		/* Round trip timeout */
159 	int64_t	tcp_last_rcv_lbolt;
160 				/* lbolt on last packet, used for PAWS */
161 	uint32_t tcp_rto_initial;	/* Initial RTO */
162 	uint32_t tcp_rto_min;		/* Minimum RTO */
163 	uint32_t tcp_rto_max;		/* Maximum RTO */
164 
165 	uint32_t tcp_snxt;		/* Senders next seq num */
166 	uint32_t tcp_swnd;		/* Senders window (relative to suna) */
167 	uint32_t tcp_mss;		/* Max segment size */
168 	uint32_t tcp_iss;		/* Initial send seq num */
169 	uint32_t tcp_rnxt;		/* Seq we expect to recv next */
170 	uint32_t tcp_rwnd;
171 
172 	/* Fields arranged in approximate access order along main paths */
173 	mblk_t	*tcp_xmit_head;		/* Head of xmit/rexmit list */
174 	mblk_t	*tcp_xmit_last;		/* Last valid data seen by tcp_wput */
175 	mblk_t	*tcp_xmit_tail;		/* Last data sent */
176 	uint32_t tcp_unsent;		/* # of bytes in hand that are unsent */
177 	uint32_t tcp_xmit_tail_unsent;	/* # of unsent bytes in xmit_tail */
178 
179 	uint32_t tcp_suna;		/* Sender unacknowledged */
180 	uint32_t tcp_rexmit_nxt;	/* Next rexmit seq num */
181 	uint32_t tcp_rexmit_max;	/* Max retran seq num */
182 	int32_t	tcp_snd_burst;		/* Send burst factor */
183 	uint32_t tcp_cwnd;		/* Congestion window */
184 	int32_t tcp_cwnd_cnt;		/* cwnd cnt in congestion avoidance */
185 
186 	uint32_t tcp_ibsegs;		/* Inbound segments on this stream */
187 	uint32_t tcp_obsegs;		/* Outbound segments on this stream */
188 
189 	uint32_t tcp_naglim;		/* Tunable nagle limit */
190 	uint32_t	tcp_valid_bits;
191 #define	TCP_ISS_VALID	0x1	/* Is the tcp_iss seq num active? */
192 #define	TCP_FSS_VALID	0x2	/* Is the tcp_fss seq num active? */
193 #define	TCP_URG_VALID	0x4	/* Is the tcp_urg seq num active? */
194 #define	TCP_OFO_FIN_VALID 0x8	/* Has TCP received an out of order FIN? */
195 
196 
197 
198 	timeout_id_t	tcp_timer_tid;	/* Control block for timer service */
199 	uchar_t	tcp_timer_backoff;	/* Backoff shift count. */
200 	int64_t tcp_last_recv_time;	/* Last time we receive a segment. */
201 	uint32_t tcp_init_cwnd;		/* Initial cwnd (start/restart) */
202 
203 	/* Following manipulated by TCP under squeue protection */
204 	uint32_t
205 		tcp_urp_last_valid : 1,	/* Is tcp_urp_last valid? */
206 		tcp_hard_binding : 1,	/* TCP_DETACHED_NONEAGER */
207 		tcp_fin_acked : 1,	/* Has our FIN been acked? */
208 		tcp_fin_rcvd : 1,	/* Have we seen a FIN? */
209 
210 		tcp_fin_sent : 1,	/* Have we sent our FIN yet? */
211 		tcp_ordrel_done : 1,	/* Have we sent the ord_rel upstream? */
212 		tcp_detached : 1,	/* If we're detached from a stream */
213 		tcp_zero_win_probe: 1,	/* Zero win probing is in progress */
214 
215 		tcp_loopback: 1,	/* src and dst are the same machine */
216 		tcp_localnet: 1,	/* src and dst are on the same subnet */
217 		tcp_syn_defense: 1,	/* For defense against SYN attack */
218 #define	tcp_dontdrop	tcp_syn_defense
219 		tcp_set_timer : 1,
220 
221 		tcp_active_open: 1,	/* This is a active open */
222 		tcp_rexmit : 1,		/* TCP is retransmitting */
223 		tcp_snd_sack_ok : 1,	/* Can use SACK for this connection */
224 		tcp_hwcksum : 1,	/* The NIC is capable of hwcksum */
225 
226 		tcp_ip_forward_progress : 1,
227 		tcp_ecn_ok : 1,		/* Can use ECN for this connection */
228 		tcp_ecn_echo_on : 1,	/* Need to do ECN echo */
229 		tcp_ecn_cwr_sent : 1,	/* ECN_CWR has been sent */
230 
231 		tcp_cwr : 1,		/* Cwnd has reduced recently */
232 
233 		tcp_pad_to_bit31 : 11;
234 
235 	/* Following manipulated by TCP under squeue protection */
236 	uint32_t
237 		tcp_snd_ts_ok  : 1,
238 		tcp_snd_ws_ok  : 1,
239 		tcp_reserved_port : 1,
240 		tcp_in_free_list : 1,
241 
242 		tcp_snd_zcopy_on : 1,	/* xmit zero-copy enabled */
243 		tcp_snd_zcopy_aware : 1, /* client is zero-copy aware */
244 		tcp_xmit_zc_clean : 1,	/* the xmit list is free of zc-mblk */
245 		tcp_wait_for_eagers : 1, /* Wait for eagers to disappear */
246 
247 		tcp_accept_error : 1,	/* Error during TLI accept */
248 		tcp_send_discon_ind : 1, /* TLI accept err, send discon ind */
249 		tcp_cork : 1,		/* tcp_cork option */
250 		tcp_tconnind_started : 1, /* conn_ind message is being sent */
251 
252 		tcp_lso :1,		/* Lower layer is capable of LSO */
253 		tcp_is_wnd_shrnk : 1,	/* Window has shrunk */
254 
255 		tcp_pad_to_bit_31 : 18;
256 
257 	uint32_t	tcp_initial_pmtu; /* Initial outgoing Path MTU. */
258 
259 	mblk_t	*tcp_reass_head;	/* Out of order reassembly list head */
260 	mblk_t	*tcp_reass_tail;	/* Out of order reassembly list tail */
261 
262 	/* SACK related info */
263 	tcp_sack_info_t	tcp_sack_info;
264 
265 #define	tcp_pipe		tcp_sack_info.tcp_pipe
266 #define	tcp_fack		tcp_sack_info.tcp_fack
267 #define	tcp_sack_snxt		tcp_sack_info.tcp_sack_snxt
268 #define	tcp_max_sack_blk	tcp_sack_info.tcp_max_sack_blk
269 #define	tcp_num_sack_blk	tcp_sack_info.tcp_num_sack_blk
270 #define	tcp_sack_list		tcp_sack_info.tcp_sack_list
271 #define	tcp_num_notsack_blk	tcp_sack_info.tcp_num_notsack_blk
272 #define	tcp_cnt_notsack_list	tcp_sack_info.tcp_cnt_notsack_list
273 #define	tcp_notsack_list	tcp_sack_info.tcp_notsack_list
274 
275 	mblk_t	*tcp_rcv_list;		/* Queued until push, urgent data, */
276 	mblk_t	*tcp_rcv_last_head;	/* optdata, or the count exceeds */
277 	mblk_t	*tcp_rcv_last_tail;	/* tcp_rcv_push_wait. */
278 	uint32_t tcp_rcv_cnt;		/* tcp_rcv_list is b_next chain. */
279 
280 	uint32_t tcp_cwnd_ssthresh;	/* Congestion window */
281 	uint32_t tcp_cwnd_max;
282 	uint32_t tcp_csuna;		/* Clear (no rexmits in window) suna */
283 
284 	clock_t	tcp_rtt_sa;		/* Round trip smoothed average */
285 	clock_t	tcp_rtt_sd;		/* Round trip smoothed deviation */
286 	clock_t	tcp_rtt_update;		/* Round trip update(s) */
287 	clock_t tcp_ms_we_have_waited;	/* Total retrans time */
288 
289 	uint32_t tcp_swl1;		/* These help us avoid using stale */
290 	uint32_t tcp_swl2;		/*  packets to update state */
291 
292 	uint32_t tcp_rack;		/* Seq # we have acked */
293 	uint32_t tcp_rack_cnt;		/* # of segs we have deferred ack */
294 	uint32_t tcp_rack_cur_max;	/* # of segs we may defer ack for now */
295 	uint32_t tcp_rack_abs_max;	/* # of segs we may defer ack ever */
296 	timeout_id_t	tcp_ack_tid;	/* Delayed ACK timer ID */
297 	timeout_id_t	tcp_push_tid;	/* Push timer ID */
298 
299 	uint32_t tcp_max_swnd;		/* Maximum swnd we have seen */
300 
301 	struct tcp_s *tcp_listener;	/* Our listener */
302 
303 	uint32_t tcp_irs;		/* Initial recv seq num */
304 	uint32_t tcp_fss;		/* Final/fin send seq num */
305 	uint32_t tcp_urg;		/* Urgent data seq num */
306 
307 	clock_t	tcp_first_timer_threshold;  /* When to prod IP */
308 	clock_t	tcp_second_timer_threshold; /* When to give up completely */
309 	clock_t	tcp_first_ctimer_threshold; /* 1st threshold while connecting */
310 	clock_t tcp_second_ctimer_threshold; /* 2nd ... while connecting */
311 
312 	uint32_t tcp_urp_last;		/* Last urp for which signal sent */
313 	mblk_t	*tcp_urp_mp;		/* T_EXDATA_IND for urgent byte */
314 	mblk_t	*tcp_urp_mark_mp;	/* zero-length marked/unmarked msg */
315 
316 	int tcp_conn_req_cnt_q0;	/* # of conn reqs in SYN_RCVD */
317 	int tcp_conn_req_cnt_q;	/* # of conn reqs in ESTABLISHED */
318 	int tcp_conn_req_max;	/* # of ESTABLISHED conn reqs allowed */
319 	t_scalar_t tcp_conn_req_seqnum;	/* Incrementing pending conn req ID */
320 #define	tcp_ip_addr_cache	tcp_reass_tail
321 					/* Cache ip addresses that */
322 					/* complete the 3-way handshake */
323 	kmutex_t  tcp_eager_lock;
324 	struct tcp_s *tcp_eager_next_q; /* next eager in ESTABLISHED state */
325 	struct tcp_s *tcp_eager_last_q;	/* last eager in ESTABLISHED state */
326 	struct tcp_s *tcp_eager_next_q0; /* next eager in SYN_RCVD state */
327 	struct tcp_s *tcp_eager_prev_q0; /* prev eager in SYN_RCVD state */
328 					/* all eagers form a circular list */
329 	boolean_t tcp_conn_def_q0;	/* move from q0 to q deferred */
330 
331 	union {
332 	    mblk_t *tcp_eager_conn_ind; /* T_CONN_IND waiting for 3rd ack. */
333 	    mblk_t *tcp_opts_conn_req; /* T_CONN_REQ w/ options processed */
334 	} tcp_conn;
335 	uint32_t tcp_syn_rcvd_timeout;	/* How many SYN_RCVD timeout in q0 */
336 
337 	/* TCP Keepalive Timer members */
338 	int32_t	tcp_ka_last_intrvl;	/* Last probe interval */
339 	timeout_id_t tcp_ka_tid;	/* Keepalive timer ID */
340 	uint32_t tcp_ka_interval;	/* Keepalive interval */
341 	uint32_t tcp_ka_abort_thres;	/* Keepalive abort threshold */
342 
343 	int32_t	tcp_client_errno;	/* How the client screwed up */
344 
345 	/*
346 	 * The header template lives in conn_ht_iphc allocated by tcp_build_hdrs
347 	 * We maintain three pointers into conn_ht_iphc.
348 	 */
349 	ipha_t	*tcp_ipha;		/* IPv4 header in conn_ht_iphc */
350 	ip6_t	*tcp_ip6h;		/* IPv6 header in conn_ht_iphc */
351 	tcpha_t	*tcp_tcpha;		/* TCP header in conn_ht_iphc */
352 
353 	uint16_t tcp_last_sent_len;	/* Record length for nagle */
354 	uint16_t tcp_last_recv_len;	/* Used by DTrace */
355 	uint16_t tcp_dupack_cnt;	/* # of consequtive duplicate acks */
356 
357 	kmutex_t	*tcp_acceptor_lockp;	/* Ptr to tf_lock */
358 
359 	mblk_t		*tcp_ordrel_mp;		/* T_ordrel_ind mblk */
360 	t_uscalar_t	tcp_acceptor_id;	/* ACCEPTOR_id */
361 
362 	int		tcp_ipsec_overhead;
363 
364 	uint_t		tcp_recvifindex; /* Last received IPV6_RCVPKTINFO */
365 	uint_t		tcp_recvhops;	/* Last received IPV6_RECVHOPLIMIT */
366 	uint_t		tcp_recvtclass;	/* Last received IPV6_RECVTCLASS */
367 	ip6_hbh_t	*tcp_hopopts;	/* Last received IPV6_RECVHOPOPTS */
368 	ip6_dest_t	*tcp_dstopts;	/* Last received IPV6_RECVDSTOPTS */
369 	ip6_dest_t	*tcp_rthdrdstopts; /* Last recv IPV6_RECVRTHDRDSTOPTS */
370 	ip6_rthdr_t	*tcp_rthdr;	/* Last received IPV6_RECVRTHDR */
371 	uint_t		tcp_hopoptslen;
372 	uint_t		tcp_dstoptslen;
373 	uint_t		tcp_rthdrdstoptslen;
374 	uint_t		tcp_rthdrlen;
375 
376 	mblk_t		*tcp_timercache;
377 
378 	kmutex_t	tcp_closelock;
379 	kcondvar_t	tcp_closecv;
380 	uint8_t		tcp_closed;
381 	uint8_t		tcp_closeflags;
382 	mblk_t		tcp_closemp;
383 	timeout_id_t	tcp_linger_tid;	/* Linger timer ID */
384 
385 	struct tcp_s *tcp_acceptor_hash; /* Acceptor hash chain */
386 	struct tcp_s **tcp_ptpahn; /* Pointer to previous accept hash next. */
387 	struct tcp_s *tcp_bind_hash; /* Bind hash chain */
388 	struct tcp_s *tcp_bind_hash_port; /* tcp_t's bound to the same lport */
389 	struct tcp_s **tcp_ptpbhn;
390 
391 	uint_t		tcp_maxpsz_multiplier;
392 
393 	uint32_t	tcp_lso_max; /* maximum LSO payload */
394 
395 	uint32_t	tcp_ofo_fin_seq; /* Recv out of order FIN seq num */
396 	uint32_t	tcp_cwr_snd_max;
397 
398 	struct tcp_s *tcp_saved_listener;	/* saved value of listener */
399 
400 	uint32_t	tcp_in_ack_unsent;	/* ACK for unsent data cnt. */
401 
402 	/*
403 	 * All fusion-related fields are protected by squeue.
404 	 */
405 	struct tcp_s *tcp_loopback_peer;	/* peer tcp for loopback */
406 	mblk_t	*tcp_fused_sigurg_mp;		/* M_PCSIG mblk for SIGURG */
407 
408 	uint32_t
409 		tcp_fused : 1,		/* loopback tcp in fusion mode */
410 		tcp_unfusable : 1,	/* fusion not allowed on endpoint */
411 		tcp_fused_sigurg : 1,	/* send SIGURG upon draining */
412 
413 		tcp_fuse_to_bit_31 : 29;
414 
415 	kmutex_t tcp_non_sq_lock;
416 
417 	/*
418 	 * This variable is accessed without any lock protection
419 	 * and therefore must not be declared as a bit field along
420 	 * with the rest which require such condition.
421 	 */
422 	boolean_t	tcp_issocket;	/* this is a socket tcp */
423 
424 	/* protected by the tcp_non_sq_lock lock */
425 	uint32_t	tcp_squeue_bytes;
426 
427 	/*
428 	 * tcp_closemp_used is protected by listener's tcp_eager_lock
429 	 * when used for eagers. When used for a tcp in TIME_WAIT state
430 	 * or in tcp_close(), it is not protected by any lock as we
431 	 * do not expect any other thread to use it concurrently.
432 	 * We do allow re-use of tcp_closemp in tcp_time_wait_collector()
433 	 * and tcp_close() but not concurrently.
434 	 */
435 	boolean_t tcp_closemp_used;
436 
437 	/*
438 	 * previous and next eagers in the list of droppable eagers. See
439 	 * the comments before MAKE_DROPPABLE(). These pointers are
440 	 * protected by listener's tcp_eager_lock.
441 	 */
442 	struct tcp_s	*tcp_eager_prev_drop_q0;
443 	struct tcp_s	*tcp_eager_next_drop_q0;
444 
445 	/*
446 	 * Have we flow controlled xmitter?
447 	 * This variable can be modified outside the squeue and hence must
448 	 * not be declared as a bit field along with the rest that are
449 	 * modified only within the squeue.
450 	 * protected by the tcp_non_sq_lock lock.
451 	 */
452 	boolean_t	tcp_flow_stopped;
453 
454 	/*
455 	 * Sender's next sequence number at the time the window was shrunk.
456 	 */
457 	uint32_t	tcp_snxt_shrunk;
458 
459 	/*
460 	 * Socket generation number which is bumped when a connection attempt
461 	 * is initiated. Its main purpose is to ensure that the socket does not
462 	 * miss the asynchronous connected/disconnected notification.
463 	 */
464 	sock_connid_t	tcp_connid;
465 
466 	/* mblk_t used to enter TCP's squeue from the service routine. */
467 	mblk_t		*tcp_rsrv_mp;
468 	/* Mutex for accessing tcp_rsrv_mp */
469 	kmutex_t	tcp_rsrv_mp_lock;
470 
471 	/* For connection counting. */
472 	struct tcp_listen_cnt_s	*tcp_listen_cnt;
473 
474 	/* Segment reassembly timer. */
475 	timeout_id_t		tcp_reass_tid;
476 
477 	/* FIN-WAIT-2 flush timeout */
478 	uint32_t		tcp_fin_wait_2_flush_interval;
479 
480 #ifdef DEBUG
481 	pc_t			tcmp_stk[15];
482 #endif
483 } tcp_t;
484 
485 #ifdef DEBUG
486 #define	TCP_DEBUG_GETPCSTACK(buffer, depth)	((void) getpcstack(buffer, \
487 						    depth))
488 #else
489 #define	TCP_DEBUG_GETPCSTACK(buffer, depth)
490 #endif
491 
492 extern void	tcp_conn_reclaim(void *);
493 extern void 	tcp_free(tcp_t *tcp);
494 extern void	tcp_ddi_g_init(void);
495 extern void	tcp_ddi_g_destroy(void);
496 extern void 	*tcp_get_conn(void *arg, tcp_stack_t *);
497 extern mblk_t	*tcp_snmp_get(queue_t *, mblk_t *, boolean_t);
498 extern int	tcp_snmp_set(queue_t *, int, int, uchar_t *, int len);
499 
500 /* Pad for the tf_t structure to avoid false cache line sharing. */
501 #define	TF_CACHEL_PAD	64
502 
503 /*
504  * The TCP Fanout structure for bind and acceptor hashes.
505  * The hash tables and their linkage (tcp_*_hash, tcp_ptp*hn) are
506  * protected by the per-bucket tf_lock.  Each tcp_t
507  * inserted in the list points back at this lock using tcp_*_lockp.
508  *
509  * The bind and acceptor hash queues are lists of tcp_t.
510  */
511 /* listener hash and acceptor hash queue head */
512 typedef struct tf_s {
513 	tcp_t		*tf_tcp;
514 	kmutex_t	tf_lock;
515 	unsigned char	tf_pad[TF_CACHEL_PAD -
516 	    (sizeof (tcp_t *) + sizeof (kmutex_t))];
517 } tf_t;
518 
519 
520 /* Also used in ipclassifier.c */
521 extern struct kmem_cache  *tcp_sack_info_cache;
522 
523 #endif	/* (defined(_KERNEL) || defined(_KMEMUSER)) */
524 
525 /* Contract private interface between TCP and Clustering. */
526 
527 #define	CL_TCPI_V1	1	/* cl_tcpi_version number */
528 
529 typedef struct cl_tcp_info_s {
530 	ushort_t	cl_tcpi_version;	/* cl_tcp_info_t's version no */
531 	ushort_t	cl_tcpi_ipversion;	/* IP version */
532 	int32_t		cl_tcpi_state;		/* TCP state */
533 	in_port_t	cl_tcpi_lport;		/* Local port */
534 	in_port_t	cl_tcpi_fport;		/* Remote port */
535 	in6_addr_t	cl_tcpi_laddr_v6;	/* Local IP address */
536 	in6_addr_t	cl_tcpi_faddr_v6;	/* Remote IP address */
537 #ifdef _KERNEL
538 /* Note: V4_PART_OF_V6 is meant to be used only for _KERNEL defined stuff */
539 #define	cl_tcpi_laddr	V4_PART_OF_V6(cl_tcpi_laddr_v6)
540 #define	cl_tcpi_faddr	V4_PART_OF_V6(cl_tcpi_faddr_v6)
541 
542 #endif	/* _KERNEL */
543 } cl_tcp_info_t;
544 
545 /*
546  * Hook functions to enable cluster networking
547  * On non-clustered systems these vectors must always be NULL.
548  */
549 extern void	(*cl_inet_listen)(netstackid_t, uint8_t, sa_family_t,
550 		    uint8_t *, in_port_t, void *);
551 extern void	(*cl_inet_unlisten)(netstackid_t, uint8_t, sa_family_t,
552 		    uint8_t *, in_port_t, void *);
553 
554 /*
555  * Contracted Consolidation Private ioctl for aborting TCP connections.
556  * In order to keep the offsets and size of the structure the same between
557  * a 32-bit application and a 64-bit amd64 kernel, we use a #pragma
558  * pack(4).
559  */
560 #define	TCP_IOC_ABORT_CONN	(('T' << 8) + 91)
561 
562 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
563 #pragma pack(4)
564 #endif
565 
566 typedef struct tcp_ioc_abort_conn_s {
567 	struct sockaddr_storage ac_local;	/* local addr and port */
568 	struct sockaddr_storage ac_remote;	/* remote addr and port */
569 	int32_t ac_start;			/* start state */
570 	int32_t ac_end;				/* end state  */
571 	int32_t ac_zoneid;			/* zoneid */
572 } tcp_ioc_abort_conn_t;
573 
574 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
575 #pragma pack()
576 #endif
577 
578 #ifdef	__cplusplus
579 }
580 #endif
581 
582 #endif	/* _INET_TCP_H */
583