xref: /illumos-gate/usr/src/uts/common/inet/tcp.h (revision 1edba515a3484e0f74b638b203d462b3112ac84d)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
545916cd2Sjpk  * Common Development and Distribution License (the "License").
645916cd2Sjpk  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
2266cd0f60SKacheong Poon  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
23aec2a073SJerry Jelinek  * Copyright (c) 2011, Joyent, Inc. All rights reserved.
243d0a255cSGarrett D'Amore  * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
2545a4b79dSSebastien Roy  * Copyright (c) 2014, 2017 by Delphix. All rights reserved.
26221e47fbSAndy Fiddaman  * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
27*1edba515SAndy Fiddaman  * Copyright 2024 Oxide Computer Company
287c478bd9Sstevel@tonic-gate  */
297c478bd9Sstevel@tonic-gate /* Copyright (c) 1990 Mentat Inc. */
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifndef	_INET_TCP_H
327c478bd9Sstevel@tonic-gate #define	_INET_TCP_H
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
357c478bd9Sstevel@tonic-gate extern "C" {
367c478bd9Sstevel@tonic-gate #endif
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #include <sys/inttypes.h>
397c478bd9Sstevel@tonic-gate #include <netinet/ip6.h>
407c478bd9Sstevel@tonic-gate #include <netinet/tcp.h>
417c478bd9Sstevel@tonic-gate #include <sys/socket.h>
420f1702c5SYu Xiangning #include <sys/socket_proto.h>
43f4b3ec61Sdh155122 #include <sys/md5.h>
44f4b3ec61Sdh155122 #include <inet/common.h>
45f4b3ec61Sdh155122 #include <inet/ip.h>
46f4b3ec61Sdh155122 #include <inet/ip6.h>
47f4b3ec61Sdh155122 #include <inet/mi.h>
48f4b3ec61Sdh155122 #include <inet/mib2.h>
49f4b3ec61Sdh155122 #include <inet/tcp_stack.h>
50f4b3ec61Sdh155122 #include <inet/tcp_sack.h>
5145a4b79dSSebastien Roy #include <inet/cc.h>
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate /* TCP states */
547c478bd9Sstevel@tonic-gate #define	TCPS_CLOSED		-6
557c478bd9Sstevel@tonic-gate #define	TCPS_IDLE		-5	/* idle (opened, but not bound) */
567c478bd9Sstevel@tonic-gate #define	TCPS_BOUND		-4	/* bound, ready to connect or accept */
577c478bd9Sstevel@tonic-gate #define	TCPS_LISTEN		-3	/* listening for connection */
587c478bd9Sstevel@tonic-gate #define	TCPS_SYN_SENT		-2	/* active, have sent syn */
597c478bd9Sstevel@tonic-gate #define	TCPS_SYN_RCVD		-1	/* have received syn (and sent ours) */
607c478bd9Sstevel@tonic-gate /* states < TCPS_ESTABLISHED are those where connections not established */
617c478bd9Sstevel@tonic-gate #define	TCPS_ESTABLISHED	0	/* established */
627c478bd9Sstevel@tonic-gate #define	TCPS_CLOSE_WAIT		1	/* rcvd fin, waiting for close */
637c478bd9Sstevel@tonic-gate /* states > TCPS_CLOSE_WAIT are those where user has closed */
647c478bd9Sstevel@tonic-gate #define	TCPS_FIN_WAIT_1		2	/* have closed and sent fin */
657c478bd9Sstevel@tonic-gate #define	TCPS_CLOSING		3	/* closed, xchd FIN, await FIN ACK */
667c478bd9Sstevel@tonic-gate #define	TCPS_LAST_ACK		4	/* had fin and close; await FIN ACK */
677c478bd9Sstevel@tonic-gate /* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */
687c478bd9Sstevel@tonic-gate #define	TCPS_FIN_WAIT_2		5	/* have closed, fin is acked */
697c478bd9Sstevel@tonic-gate #define	TCPS_TIME_WAIT		6	/* in 2*msl quiet wait after close */
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate /*
727c478bd9Sstevel@tonic-gate  * Internal flags used in conjunction with the packet header flags.
73bd670b35SErik Nordmark  * Used in tcp_input_data to keep track of what needs to be done.
747c478bd9Sstevel@tonic-gate  */
757c478bd9Sstevel@tonic-gate #define	TH_LIMIT_XMIT		0x0400	/* Limited xmit is needed */
767c478bd9Sstevel@tonic-gate #define	TH_XMIT_NEEDED		0x0800	/* Window opened - send queued data */
777c478bd9Sstevel@tonic-gate #define	TH_REXMIT_NEEDED	0x1000	/* Time expired for unacked data */
787c478bd9Sstevel@tonic-gate #define	TH_ACK_NEEDED		0x2000	/* Send an ack now. */
797c478bd9Sstevel@tonic-gate #define	TH_NEED_SACK_REXMIT	0x4000	/* Use SACK info to retransmission */
807c478bd9Sstevel@tonic-gate #define	TH_ACK_TIMER_NEEDED	0x8000	/* Start the delayed ACK timer */
817c478bd9Sstevel@tonic-gate #define	TH_ORDREL_NEEDED	0x10000	/* Generate an ordrel indication */
827c478bd9Sstevel@tonic-gate #define	TH_MARKNEXT_NEEDED	0x20000	/* Data should have MSGMARKNEXT */
837c478bd9Sstevel@tonic-gate #define	TH_SEND_URP_MARK	0x40000	/* Send up tcp_urp_mark_mp */
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate /*
867c478bd9Sstevel@tonic-gate  * TCP sequence numbers are 32 bit integers operated
877c478bd9Sstevel@tonic-gate  * on with modular arithmetic.  These macros can be
887c478bd9Sstevel@tonic-gate  * used to compare such integers.
897c478bd9Sstevel@tonic-gate  */
907c478bd9Sstevel@tonic-gate #define	SEQ_LT(a, b)	((int32_t)((a)-(b)) < 0)
917c478bd9Sstevel@tonic-gate #define	SEQ_LEQ(a, b)	((int32_t)((a)-(b)) <= 0)
927c478bd9Sstevel@tonic-gate #define	SEQ_GT(a, b)	((int32_t)((a)-(b)) > 0)
937c478bd9Sstevel@tonic-gate #define	SEQ_GEQ(a, b)	((int32_t)((a)-(b)) >= 0)
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate /* TCP Protocol header */
967c478bd9Sstevel@tonic-gate typedef	struct tcphdr_s {
977c478bd9Sstevel@tonic-gate 	uint8_t		th_lport[2];	/* Source port */
987c478bd9Sstevel@tonic-gate 	uint8_t		th_fport[2];	/* Destination port */
997c478bd9Sstevel@tonic-gate 	uint8_t		th_seq[4];	/* Sequence number */
1007c478bd9Sstevel@tonic-gate 	uint8_t		th_ack[4];	/* Acknowledgement number */
1017c478bd9Sstevel@tonic-gate 	uint8_t		th_offset_and_rsrvd[1]; /* Offset to the packet data */
1027c478bd9Sstevel@tonic-gate 	uint8_t		th_flags[1];
1037c478bd9Sstevel@tonic-gate 	uint8_t		th_win[2];	/* Allocation number */
1047c478bd9Sstevel@tonic-gate 	uint8_t		th_sum[2];	/* TCP checksum */
1057c478bd9Sstevel@tonic-gate 	uint8_t		th_urp[2];	/* Urgent pointer */
1067c478bd9Sstevel@tonic-gate } tcph_t;
1077c478bd9Sstevel@tonic-gate 
108bd670b35SErik Nordmark #define	TCP_HDR_LENGTH(tcph) \
109bd670b35SErik Nordmark 	((((tcph_t *)tcph)->th_offset_and_rsrvd[0] >>2) &(0xF << 2))
1107c478bd9Sstevel@tonic-gate #define	TCP_MAX_COMBINED_HEADER_LENGTH	(60 + 60) /* Maxed out ip + tcp */
1117c478bd9Sstevel@tonic-gate #define	TCP_MAX_IP_OPTIONS_LENGTH	(60 - IP_SIMPLE_HDR_LENGTH)
1127c478bd9Sstevel@tonic-gate #define	TCP_MAX_HDR_LENGTH		60
113bd670b35SErik Nordmark #define	TCP_MAX_TCP_OPTIONS_LENGTH	(60 - sizeof (tcpha_t))
1147c478bd9Sstevel@tonic-gate #define	TCP_MIN_HEADER_LENGTH		20
1157c478bd9Sstevel@tonic-gate #define	TCP_MAXWIN			65535
1167c478bd9Sstevel@tonic-gate #define	TCP_PORT_LEN			sizeof (in_port_t)
1177c478bd9Sstevel@tonic-gate #define	TCP_MAX_WINSHIFT		14
1187c478bd9Sstevel@tonic-gate #define	TCP_MAX_LARGEWIN		(TCP_MAXWIN << TCP_MAX_WINSHIFT)
1198347601bSyl150051 #define	TCP_MAX_LSO_LENGTH	(IP_MAXPACKET - TCP_MAX_COMBINED_HEADER_LENGTH)
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate #define	TCPIP_HDR_LENGTH(mp, n)					\
1227c478bd9Sstevel@tonic-gate 	(n) = IPH_HDR_LENGTH((mp)->b_rptr),			\
123bd670b35SErik Nordmark 	(n) += TCP_HDR_LENGTH((tcpha_t *)&(mp)->b_rptr[(n)])
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate /* TCP Protocol header (used if the header is known to be 32-bit aligned) */
1267c478bd9Sstevel@tonic-gate typedef	struct tcphdra_s {
1277c478bd9Sstevel@tonic-gate 	in_port_t	tha_lport;	/* Source port */
1287c478bd9Sstevel@tonic-gate 	in_port_t	tha_fport;	/* Destination port */
1297c478bd9Sstevel@tonic-gate 	uint32_t	tha_seq;	/* Sequence number */
1307c478bd9Sstevel@tonic-gate 	uint32_t	tha_ack;	/* Acknowledgement number */
1317c478bd9Sstevel@tonic-gate 	uint8_t tha_offset_and_reserved; /* Offset to the packet data */
1327c478bd9Sstevel@tonic-gate 	uint8_t		tha_flags;
1337c478bd9Sstevel@tonic-gate 	uint16_t	tha_win;	/* Allocation number */
1347c478bd9Sstevel@tonic-gate 	uint16_t	tha_sum;	/* TCP checksum */
1357c478bd9Sstevel@tonic-gate 	uint16_t	tha_urp;	/* Urgent pointer */
1367c478bd9Sstevel@tonic-gate } tcpha_t;
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate struct conn_s;
13993fcb0b9SKacheong Poon struct tcp_listen_cnt_s;
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate /*
1427c478bd9Sstevel@tonic-gate  * Control structure for each open TCP stream,
1437c478bd9Sstevel@tonic-gate  * defined only within the kernel or for a kmem user.
1447c478bd9Sstevel@tonic-gate  * NOTE: tcp_reinit_values MUST have a line for each field in this structure!
1457c478bd9Sstevel@tonic-gate  */
1467c478bd9Sstevel@tonic-gate #if (defined(_KERNEL) || defined(_KMEMUSER))
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate typedef struct tcp_s {
1497c478bd9Sstevel@tonic-gate 	struct tcp_s	*tcp_time_wait_next;
1507c478bd9Sstevel@tonic-gate 				/* Pointer to next T/W block */
1517c478bd9Sstevel@tonic-gate 	struct tcp_s	*tcp_time_wait_prev;
1527c478bd9Sstevel@tonic-gate 				/* Pointer to previous T/W next */
15366cd0f60SKacheong Poon 	int64_t		tcp_time_wait_expire;
154f4b3ec61Sdh155122 
155721fffe3SKacheong Poon 	struct conn_s	*tcp_connp;	/* back pointer to conn_t */
156721fffe3SKacheong Poon 	tcp_stack_t	*tcp_tcps;	/* back pointer to tcp_stack_t */
1577c478bd9Sstevel@tonic-gate 
15845a4b79dSSebastien Roy 	struct cc_algo	*tcp_cc_algo;	/* congestion control algorithm */
15945a4b79dSSebastien Roy 	struct cc_var	tcp_ccv;	/* congestion control specific vars */
16045a4b79dSSebastien Roy 
1617c478bd9Sstevel@tonic-gate 	int32_t	tcp_state;
1627c478bd9Sstevel@tonic-gate 	int32_t	tcp_rcv_ws;		/* My window scale power */
1637c478bd9Sstevel@tonic-gate 	int32_t	tcp_snd_ws;		/* Sender's window scale power */
1647c478bd9Sstevel@tonic-gate 	uint32_t tcp_ts_recent;		/* Timestamp of earliest unacked */
1657c478bd9Sstevel@tonic-gate 					/*  data segment */
1667c478bd9Sstevel@tonic-gate 	clock_t	tcp_rto;		/* Round trip timeout */
167fec71d83SGeorge Shepherd 	int64_t	tcp_last_rcv_lbolt;
1687c478bd9Sstevel@tonic-gate 				/* lbolt on last packet, used for PAWS */
169707e74bcSKacheong Poon 	uint32_t tcp_rto_initial;	/* Initial RTO */
170707e74bcSKacheong Poon 	uint32_t tcp_rto_min;		/* Minimum RTO */
171707e74bcSKacheong Poon 	uint32_t tcp_rto_max;		/* Maximum RTO */
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate 	uint32_t tcp_snxt;		/* Senders next seq num */
1747c478bd9Sstevel@tonic-gate 	uint32_t tcp_swnd;		/* Senders window (relative to suna) */
1757c478bd9Sstevel@tonic-gate 	uint32_t tcp_mss;		/* Max segment size */
1767c478bd9Sstevel@tonic-gate 	uint32_t tcp_iss;		/* Initial send seq num */
1777c478bd9Sstevel@tonic-gate 	uint32_t tcp_rnxt;		/* Seq we expect to recv next */
1787c478bd9Sstevel@tonic-gate 	uint32_t tcp_rwnd;
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate 	/* Fields arranged in approximate access order along main paths */
181721fffe3SKacheong Poon 	mblk_t	*tcp_xmit_head;		/* Head of xmit/rexmit list */
182721fffe3SKacheong Poon 	mblk_t	*tcp_xmit_last;		/* Last valid data seen by tcp_wput */
183721fffe3SKacheong Poon 	mblk_t	*tcp_xmit_tail;		/* Last data sent */
1847c478bd9Sstevel@tonic-gate 	uint32_t tcp_unsent;		/* # of bytes in hand that are unsent */
1857c478bd9Sstevel@tonic-gate 	uint32_t tcp_xmit_tail_unsent;	/* # of unsent bytes in xmit_tail */
1867c478bd9Sstevel@tonic-gate 	uint32_t tcp_suna;		/* Sender unacknowledged */
1877c478bd9Sstevel@tonic-gate 	uint32_t tcp_rexmit_nxt;	/* Next rexmit seq num */
1887c478bd9Sstevel@tonic-gate 	uint32_t tcp_rexmit_max;	/* Max retran seq num */
1897c478bd9Sstevel@tonic-gate 	uint32_t tcp_cwnd;		/* Congestion window */
1907c478bd9Sstevel@tonic-gate 	int32_t tcp_cwnd_cnt;		/* cwnd cnt in congestion avoidance */
1917c478bd9Sstevel@tonic-gate 	uint32_t tcp_naglim;		/* Tunable nagle limit */
1927c478bd9Sstevel@tonic-gate 	uint32_t	tcp_valid_bits;
1937c478bd9Sstevel@tonic-gate #define	TCP_ISS_VALID	0x1	/* Is the tcp_iss seq num active? */
1947c478bd9Sstevel@tonic-gate #define	TCP_FSS_VALID	0x2	/* Is the tcp_fss seq num active? */
1957c478bd9Sstevel@tonic-gate #define	TCP_URG_VALID	0x4	/* Is the tcp_urg seq num active? */
1967c478bd9Sstevel@tonic-gate #define	TCP_OFO_FIN_VALID 0x8	/* Has TCP received an out of order FIN? */
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate 	timeout_id_t	tcp_timer_tid;	/* Control block for timer service */
1997c478bd9Sstevel@tonic-gate 	uchar_t	tcp_timer_backoff;	/* Backoff shift count. */
2007c478bd9Sstevel@tonic-gate 	int64_t tcp_last_recv_time;	/* Last time we receive a segment. */
2017c478bd9Sstevel@tonic-gate 	uint32_t tcp_init_cwnd;		/* Initial cwnd (start/restart) */
2027c478bd9Sstevel@tonic-gate 
2037c478bd9Sstevel@tonic-gate 	/* Following manipulated by TCP under squeue protection */
2047c478bd9Sstevel@tonic-gate 	uint32_t
2057c478bd9Sstevel@tonic-gate 		tcp_urp_last_valid : 1,	/* Is tcp_urp_last valid? */
206bd670b35SErik Nordmark 		tcp_hard_binding : 1,	/* TCP_DETACHED_NONEAGER */
2077c478bd9Sstevel@tonic-gate 		tcp_fin_acked : 1,	/* Has our FIN been acked? */
2087c478bd9Sstevel@tonic-gate 		tcp_fin_rcvd : 1,	/* Have we seen a FIN? */
209bd670b35SErik Nordmark 
2107c478bd9Sstevel@tonic-gate 		tcp_fin_sent : 1,	/* Have we sent our FIN yet? */
2117c478bd9Sstevel@tonic-gate 		tcp_ordrel_done : 1,	/* Have we sent the ord_rel upstream? */
2127c478bd9Sstevel@tonic-gate 		tcp_detached : 1,	/* If we're detached from a stream */
2137c478bd9Sstevel@tonic-gate 		tcp_zero_win_probe: 1,	/* Zero win probing is in progress */
214f7f8e53dSKacheong Poon 
2157c478bd9Sstevel@tonic-gate 		tcp_loopback: 1,	/* src and dst are the same machine */
2167c478bd9Sstevel@tonic-gate 		tcp_localnet: 1,	/* src and dst are on the same subnet */
2177c478bd9Sstevel@tonic-gate 		tcp_syn_defense: 1,	/* For defense against SYN attack */
2187c478bd9Sstevel@tonic-gate #define	tcp_dontdrop	tcp_syn_defense
2197c478bd9Sstevel@tonic-gate 		tcp_set_timer : 1,
2208380b3ccSYu Xiangning 
221f7f8e53dSKacheong Poon 		tcp_active_open: 1,	/* This is a active open */
222f7f8e53dSKacheong Poon 		tcp_rexmit : 1,		/* TCP is retransmitting */
2237c478bd9Sstevel@tonic-gate 		tcp_snd_sack_ok : 1,	/* Can use SACK for this connection */
2247c478bd9Sstevel@tonic-gate 		tcp_hwcksum : 1,	/* The NIC is capable of hwcksum */
225f7f8e53dSKacheong Poon 
226bd670b35SErik Nordmark 		tcp_ip_forward_progress : 1,
2277c478bd9Sstevel@tonic-gate 		tcp_ecn_ok : 1,		/* Can use ECN for this connection */
2287c478bd9Sstevel@tonic-gate 		tcp_ecn_echo_on : 1,	/* Need to do ECN echo */
2297c478bd9Sstevel@tonic-gate 		tcp_ecn_cwr_sent : 1,	/* ECN_CWR has been sent */
230bd670b35SErik Nordmark 
231e0968231Svi117747 		tcp_cwr : 1,		/* Cwnd has reduced recently */
232f7f8e53dSKacheong Poon 
233bd670b35SErik Nordmark 		tcp_pad_to_bit31 : 11;
234bd670b35SErik Nordmark 
2357c478bd9Sstevel@tonic-gate 	/* Following manipulated by TCP under squeue protection */
2367c478bd9Sstevel@tonic-gate 	uint32_t
2377c478bd9Sstevel@tonic-gate 		tcp_snd_ts_ok  : 1,
2387c478bd9Sstevel@tonic-gate 		tcp_snd_ws_ok  : 1,
239bd670b35SErik Nordmark 		tcp_reserved_port : 1,
2407c478bd9Sstevel@tonic-gate 		tcp_in_free_list : 1,
2417c478bd9Sstevel@tonic-gate 
242bd670b35SErik Nordmark 		tcp_snd_zcopy_on : 1,	/* xmit zero-copy enabled */
2437c478bd9Sstevel@tonic-gate 		tcp_snd_zcopy_aware : 1, /* client is zero-copy aware */
2447c478bd9Sstevel@tonic-gate 		tcp_xmit_zc_clean : 1,	/* the xmit list is free of zc-mblk */
2457c478bd9Sstevel@tonic-gate 		tcp_wait_for_eagers : 1, /* Wait for eagers to disappear */
2467c478bd9Sstevel@tonic-gate 
247bd670b35SErik Nordmark 		tcp_accept_error : 1,	/* Error during TLI accept */
2487c478bd9Sstevel@tonic-gate 		tcp_send_discon_ind : 1, /* TLI accept err, send discon ind */
2497c478bd9Sstevel@tonic-gate 		tcp_cork : 1,		/* tcp_cork option */
250861fa149SNils Nieuwejaar 		tcp_quickack : 1,	/* Send acks immediately */
251866ba9ddSjprakash 		tcp_tconnind_started : 1, /* conn_ind message is being sent */
2527c478bd9Sstevel@tonic-gate 
253bd670b35SErik Nordmark 		tcp_lso :1,		/* Lower layer is capable of LSO */
254bd670b35SErik Nordmark 		tcp_is_wnd_shrnk : 1,	/* Window has shrunk */
255*1edba515SAndy Fiddaman 		tcp_md5sig : 1,		/* Add MD5 signature option */
256bd670b35SErik Nordmark 
257*1edba515SAndy Fiddaman 		tcp_pad_to_bit_31 : 16;
258bd670b35SErik Nordmark 
259bd670b35SErik Nordmark 	uint32_t	tcp_initial_pmtu; /* Initial outgoing Path MTU. */
2607c478bd9Sstevel@tonic-gate 
2617c478bd9Sstevel@tonic-gate 	mblk_t	*tcp_reass_head;	/* Out of order reassembly list head */
2627c478bd9Sstevel@tonic-gate 	mblk_t	*tcp_reass_tail;	/* Out of order reassembly list tail */
2637c478bd9Sstevel@tonic-gate 
26466cd0f60SKacheong Poon 	/* SACK related info */
26566cd0f60SKacheong Poon 	tcp_sack_info_t	tcp_sack_info;
2667c478bd9Sstevel@tonic-gate 
26766cd0f60SKacheong Poon #define	tcp_pipe		tcp_sack_info.tcp_pipe
26866cd0f60SKacheong Poon #define	tcp_fack		tcp_sack_info.tcp_fack
26966cd0f60SKacheong Poon #define	tcp_sack_snxt		tcp_sack_info.tcp_sack_snxt
27066cd0f60SKacheong Poon #define	tcp_max_sack_blk	tcp_sack_info.tcp_max_sack_blk
27166cd0f60SKacheong Poon #define	tcp_num_sack_blk	tcp_sack_info.tcp_num_sack_blk
27266cd0f60SKacheong Poon #define	tcp_sack_list		tcp_sack_info.tcp_sack_list
27366cd0f60SKacheong Poon #define	tcp_num_notsack_blk	tcp_sack_info.tcp_num_notsack_blk
27466cd0f60SKacheong Poon #define	tcp_cnt_notsack_list	tcp_sack_info.tcp_cnt_notsack_list
27566cd0f60SKacheong Poon #define	tcp_notsack_list	tcp_sack_info.tcp_notsack_list
2767c478bd9Sstevel@tonic-gate 
2777c478bd9Sstevel@tonic-gate 	mblk_t	*tcp_rcv_list;		/* Queued until push, urgent data, */
2787c478bd9Sstevel@tonic-gate 	mblk_t	*tcp_rcv_last_head;	/* optdata, or the count exceeds */
2797c478bd9Sstevel@tonic-gate 	mblk_t	*tcp_rcv_last_tail;	/* tcp_rcv_push_wait. */
2807c478bd9Sstevel@tonic-gate 	uint32_t tcp_rcv_cnt;		/* tcp_rcv_list is b_next chain. */
2817c478bd9Sstevel@tonic-gate 
2827c478bd9Sstevel@tonic-gate 	uint32_t tcp_cwnd_ssthresh;	/* Congestion window */
2837c478bd9Sstevel@tonic-gate 	uint32_t tcp_cwnd_max;
2847c478bd9Sstevel@tonic-gate 	uint32_t tcp_csuna;		/* Clear (no rexmits in window) suna */
2857c478bd9Sstevel@tonic-gate 
286a2f04351SSebastien Roy 	hrtime_t tcp_rtt_sum;		/* Round trip sum */
287a2f04351SSebastien Roy 	uint32_t tcp_rtt_cnt;		/* Round trip count (non_dup ACKs) */
288c12492cfSSebastien Roy 	hrtime_t tcp_rtt_sa;		/* Round trip smoothed average */
289c12492cfSSebastien Roy 	hrtime_t tcp_rtt_sd;		/* Round trip smoothed deviation */
290c12492cfSSebastien Roy 	uint32_t tcp_rtt_update;	/* Round trip update(s) */
2917c478bd9Sstevel@tonic-gate 	clock_t tcp_ms_we_have_waited;	/* Total retrans time */
2927c478bd9Sstevel@tonic-gate 
2937c478bd9Sstevel@tonic-gate 	uint32_t tcp_swl1;		/* These help us avoid using stale */
2947c478bd9Sstevel@tonic-gate 	uint32_t tcp_swl2;		/*  packets to update state */
2957c478bd9Sstevel@tonic-gate 
2967c478bd9Sstevel@tonic-gate 	uint32_t tcp_rack;		/* Seq # we have acked */
2977c478bd9Sstevel@tonic-gate 	uint32_t tcp_rack_cnt;		/* # of segs we have deferred ack */
2987c478bd9Sstevel@tonic-gate 	uint32_t tcp_rack_cur_max;	/* # of segs we may defer ack for now */
2997c478bd9Sstevel@tonic-gate 	uint32_t tcp_rack_abs_max;	/* # of segs we may defer ack ever */
3007c478bd9Sstevel@tonic-gate 	timeout_id_t	tcp_ack_tid;	/* Delayed ACK timer ID */
3017c478bd9Sstevel@tonic-gate 	timeout_id_t	tcp_push_tid;	/* Push timer ID */
3027c478bd9Sstevel@tonic-gate 
3037c478bd9Sstevel@tonic-gate 	uint32_t tcp_max_swnd;		/* Maximum swnd we have seen */
3047c478bd9Sstevel@tonic-gate 
3057c478bd9Sstevel@tonic-gate 	struct tcp_s *tcp_listener;	/* Our listener */
3067c478bd9Sstevel@tonic-gate 
3077c478bd9Sstevel@tonic-gate 	uint32_t tcp_irs;		/* Initial recv seq num */
3087c478bd9Sstevel@tonic-gate 	uint32_t tcp_fss;		/* Final/fin send seq num */
3097c478bd9Sstevel@tonic-gate 	uint32_t tcp_urg;		/* Urgent data seq num */
3107c478bd9Sstevel@tonic-gate 
3117c478bd9Sstevel@tonic-gate 	clock_t	tcp_first_timer_threshold;  /* When to prod IP */
3127c478bd9Sstevel@tonic-gate 	clock_t	tcp_second_timer_threshold; /* When to give up completely */
3137c478bd9Sstevel@tonic-gate 	clock_t	tcp_first_ctimer_threshold; /* 1st threshold while connecting */
3147c478bd9Sstevel@tonic-gate 	clock_t tcp_second_ctimer_threshold; /* 2nd ... while connecting */
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate 	uint32_t tcp_urp_last;		/* Last urp for which signal sent */
3177c478bd9Sstevel@tonic-gate 	mblk_t	*tcp_urp_mp;		/* T_EXDATA_IND for urgent byte */
3187c478bd9Sstevel@tonic-gate 	mblk_t	*tcp_urp_mark_mp;	/* zero-length marked/unmarked msg */
3197c478bd9Sstevel@tonic-gate 
3207c478bd9Sstevel@tonic-gate 	int tcp_conn_req_cnt_q0;	/* # of conn reqs in SYN_RCVD */
3217c478bd9Sstevel@tonic-gate 	int tcp_conn_req_cnt_q;	/* # of conn reqs in ESTABLISHED */
3227c478bd9Sstevel@tonic-gate 	int tcp_conn_req_max;	/* # of ESTABLISHED conn reqs allowed */
3237c478bd9Sstevel@tonic-gate 	t_scalar_t tcp_conn_req_seqnum;	/* Incrementing pending conn req ID */
3247c478bd9Sstevel@tonic-gate #define	tcp_ip_addr_cache	tcp_reass_tail
3257c478bd9Sstevel@tonic-gate 					/* Cache ip addresses that */
3267c478bd9Sstevel@tonic-gate 					/* complete the 3-way handshake */
3277c478bd9Sstevel@tonic-gate 	kmutex_t  tcp_eager_lock;
3287c478bd9Sstevel@tonic-gate 	struct tcp_s *tcp_eager_next_q; /* next eager in ESTABLISHED state */
3297c478bd9Sstevel@tonic-gate 	struct tcp_s *tcp_eager_last_q;	/* last eager in ESTABLISHED state */
3307c478bd9Sstevel@tonic-gate 	struct tcp_s *tcp_eager_next_q0; /* next eager in SYN_RCVD state */
3317c478bd9Sstevel@tonic-gate 	struct tcp_s *tcp_eager_prev_q0; /* prev eager in SYN_RCVD state */
3327c478bd9Sstevel@tonic-gate 					/* all eagers form a circular list */
3338380b3ccSYu Xiangning 	boolean_t tcp_conn_def_q0;	/* move from q0 to q deferred */
3348380b3ccSYu Xiangning 
3357c478bd9Sstevel@tonic-gate 	union {
3367c478bd9Sstevel@tonic-gate 	    mblk_t *tcp_eager_conn_ind; /* T_CONN_IND waiting for 3rd ack. */
3377c478bd9Sstevel@tonic-gate 	    mblk_t *tcp_opts_conn_req; /* T_CONN_REQ w/ options processed */
3387c478bd9Sstevel@tonic-gate 	} tcp_conn;
3397c478bd9Sstevel@tonic-gate 	uint32_t tcp_syn_rcvd_timeout;	/* How many SYN_RCVD timeout in q0 */
3407c478bd9Sstevel@tonic-gate 
3413d0a255cSGarrett D'Amore 	/*
3423d0a255cSGarrett D'Amore 	 * TCP Keepalive Timer members.
3433d0a255cSGarrett D'Amore 	 * All keepalive timer intervals are in milliseconds.
3443d0a255cSGarrett D'Amore 	 */
3457c478bd9Sstevel@tonic-gate 	int32_t	tcp_ka_last_intrvl;	/* Last probe interval */
3467c478bd9Sstevel@tonic-gate 	timeout_id_t tcp_ka_tid;	/* Keepalive timer ID */
3477c478bd9Sstevel@tonic-gate 	uint32_t tcp_ka_interval;	/* Keepalive interval */
3483d0a255cSGarrett D'Amore 
3493d0a255cSGarrett D'Amore 	/*
3503d0a255cSGarrett D'Amore 	 * TCP connection is terminated if we don't hear back from the peer
3513d0a255cSGarrett D'Amore 	 * for tcp_ka_abort_thres milliseconds after the first keepalive probe.
3523d0a255cSGarrett D'Amore 	 * tcp_ka_rinterval is the interval in milliseconds between successive
3533d0a255cSGarrett D'Amore 	 * keepalive probes. tcp_ka_cnt is the number of keepalive probes to
3543d0a255cSGarrett D'Amore 	 * be sent before terminating the connection, if we don't hear back from
3553d0a255cSGarrett D'Amore 	 * peer.
3563d0a255cSGarrett D'Amore 	 * tcp_ka_abort_thres = tcp_ka_rinterval * tcp_ka_cnt
3573d0a255cSGarrett D'Amore 	 */
3583d0a255cSGarrett D'Amore 	uint32_t tcp_ka_rinterval;	/* keepalive retransmit interval */
3597c478bd9Sstevel@tonic-gate 	uint32_t tcp_ka_abort_thres;	/* Keepalive abort threshold */
3603d0a255cSGarrett D'Amore 	uint32_t tcp_ka_cnt;		/* count of keepalive probes */
3617c478bd9Sstevel@tonic-gate 
3627c478bd9Sstevel@tonic-gate 	int32_t	tcp_client_errno;	/* How the client screwed up */
3637c478bd9Sstevel@tonic-gate 
364bd670b35SErik Nordmark 	/*
365bd670b35SErik Nordmark 	 * The header template lives in conn_ht_iphc allocated by tcp_build_hdrs
366bd670b35SErik Nordmark 	 * We maintain three pointers into conn_ht_iphc.
367bd670b35SErik Nordmark 	 */
368bd670b35SErik Nordmark 	ipha_t	*tcp_ipha;		/* IPv4 header in conn_ht_iphc */
369bd670b35SErik Nordmark 	ip6_t	*tcp_ip6h;		/* IPv6 header in conn_ht_iphc */
370bd670b35SErik Nordmark 	tcpha_t	*tcp_tcpha;		/* TCP header in conn_ht_iphc */
3717c478bd9Sstevel@tonic-gate 
3727c478bd9Sstevel@tonic-gate 	uint16_t tcp_last_sent_len;	/* Record length for nagle */
3739cd928feSAlan Maguire 	uint16_t tcp_last_recv_len;	/* Used by DTrace */
3747c478bd9Sstevel@tonic-gate 	uint16_t tcp_dupack_cnt;	/* # of consequtive duplicate acks */
3757c478bd9Sstevel@tonic-gate 
3767c478bd9Sstevel@tonic-gate 	kmutex_t	*tcp_acceptor_lockp;	/* Ptr to tf_lock */
3777c478bd9Sstevel@tonic-gate 
378f7f8e53dSKacheong Poon 	mblk_t		*tcp_ordrel_mp;		/* T_ordrel_ind mblk */
3797c478bd9Sstevel@tonic-gate 	t_uscalar_t	tcp_acceptor_id;	/* ACCEPTOR_id */
3807c478bd9Sstevel@tonic-gate 
3817c478bd9Sstevel@tonic-gate 	int		tcp_ipsec_overhead;
3827c478bd9Sstevel@tonic-gate 
383221e47fbSAndy Fiddaman 	uint_t		tcp_recvtos;	/* Last received IP_RECVTOS */
3847c478bd9Sstevel@tonic-gate 	uint_t		tcp_recvifindex; /* Last received IPV6_RCVPKTINFO */
3857c478bd9Sstevel@tonic-gate 	uint_t		tcp_recvhops;	/* Last received IPV6_RECVHOPLIMIT */
3867c478bd9Sstevel@tonic-gate 	uint_t		tcp_recvtclass;	/* Last received IPV6_RECVTCLASS */
3877c478bd9Sstevel@tonic-gate 	ip6_hbh_t	*tcp_hopopts;	/* Last received IPV6_RECVHOPOPTS */
3887c478bd9Sstevel@tonic-gate 	ip6_dest_t	*tcp_dstopts;	/* Last received IPV6_RECVDSTOPTS */
389bd670b35SErik Nordmark 	ip6_dest_t	*tcp_rthdrdstopts; /* Last recv IPV6_RECVRTHDRDSTOPTS */
3907c478bd9Sstevel@tonic-gate 	ip6_rthdr_t	*tcp_rthdr;	/* Last received IPV6_RECVRTHDR */
3917c478bd9Sstevel@tonic-gate 	uint_t		tcp_hopoptslen;
3927c478bd9Sstevel@tonic-gate 	uint_t		tcp_dstoptslen;
393bd670b35SErik Nordmark 	uint_t		tcp_rthdrdstoptslen;
3947c478bd9Sstevel@tonic-gate 	uint_t		tcp_rthdrlen;
3957c478bd9Sstevel@tonic-gate 
3967c478bd9Sstevel@tonic-gate 	mblk_t		*tcp_timercache;
3977c478bd9Sstevel@tonic-gate 
3987c478bd9Sstevel@tonic-gate 	kmutex_t	tcp_closelock;
3997c478bd9Sstevel@tonic-gate 	kcondvar_t	tcp_closecv;
4007c478bd9Sstevel@tonic-gate 	uint8_t		tcp_closed;
4017c478bd9Sstevel@tonic-gate 	uint8_t		tcp_closeflags;
4027c478bd9Sstevel@tonic-gate 	mblk_t		tcp_closemp;
4037c478bd9Sstevel@tonic-gate 	timeout_id_t	tcp_linger_tid;	/* Linger timer ID */
4047c478bd9Sstevel@tonic-gate 
4057c478bd9Sstevel@tonic-gate 	struct tcp_s *tcp_acceptor_hash; /* Acceptor hash chain */
4067c478bd9Sstevel@tonic-gate 	struct tcp_s **tcp_ptpahn; /* Pointer to previous accept hash next. */
4077c478bd9Sstevel@tonic-gate 	struct tcp_s *tcp_bind_hash; /* Bind hash chain */
4080f1702c5SYu Xiangning 	struct tcp_s *tcp_bind_hash_port; /* tcp_t's bound to the same lport */
4097c478bd9Sstevel@tonic-gate 	struct tcp_s **tcp_ptpbhn;
4107c478bd9Sstevel@tonic-gate 
411bd670b35SErik Nordmark 	uint_t		tcp_maxpsz_multiplier;
4127c478bd9Sstevel@tonic-gate 
4138347601bSyl150051 	uint32_t	tcp_lso_max; /* maximum LSO payload */
4148347601bSyl150051 
4157c478bd9Sstevel@tonic-gate 	uint32_t	tcp_ofo_fin_seq; /* Recv out of order FIN seq num */
4167c478bd9Sstevel@tonic-gate 	uint32_t	tcp_cwr_snd_max;
417bd670b35SErik Nordmark 
4187c478bd9Sstevel@tonic-gate 	struct tcp_s *tcp_saved_listener;	/* saved value of listener */
4197c478bd9Sstevel@tonic-gate 
420ff550d0eSmasputra 	uint32_t	tcp_in_ack_unsent;	/* ACK for unsent data cnt. */
421ff550d0eSmasputra 
422ff550d0eSmasputra 	/*
4237b8f5432SAnders Persson 	 * All fusion-related fields are protected by squeue.
424ff550d0eSmasputra 	 */
4257c478bd9Sstevel@tonic-gate 	struct tcp_s *tcp_loopback_peer;	/* peer tcp for loopback */
4267c478bd9Sstevel@tonic-gate 	mblk_t	*tcp_fused_sigurg_mp;		/* M_PCSIG mblk for SIGURG */
4277b8f5432SAnders Persson 
428ff550d0eSmasputra 	uint32_t
429ff550d0eSmasputra 		tcp_fused : 1,		/* loopback tcp in fusion mode */
430ff550d0eSmasputra 		tcp_unfusable : 1,	/* fusion not allowed on endpoint */
431ff550d0eSmasputra 		tcp_fused_sigurg : 1,	/* send SIGURG upon draining */
4327c478bd9Sstevel@tonic-gate 
4337b8f5432SAnders Persson 		tcp_fuse_to_bit_31 : 29;
4347b8f5432SAnders Persson 
4357b8f5432SAnders Persson 	kmutex_t tcp_non_sq_lock;
4367c478bd9Sstevel@tonic-gate 
4377c478bd9Sstevel@tonic-gate 	/*
4387c478bd9Sstevel@tonic-gate 	 * This variable is accessed without any lock protection
4397c478bd9Sstevel@tonic-gate 	 * and therefore must not be declared as a bit field along
4407c478bd9Sstevel@tonic-gate 	 * with the rest which require such condition.
4417c478bd9Sstevel@tonic-gate 	 */
4427c478bd9Sstevel@tonic-gate 	boolean_t	tcp_issocket;	/* this is a socket tcp */
443ff550d0eSmasputra 
444e0968231Svi117747 	/* protected by the tcp_non_sq_lock lock */
445ff550d0eSmasputra 	uint32_t	tcp_squeue_bytes;
446866ba9ddSjprakash 
447866ba9ddSjprakash 	/*
448866ba9ddSjprakash 	 * tcp_closemp_used is protected by listener's tcp_eager_lock
449866ba9ddSjprakash 	 * when used for eagers. When used for a tcp in TIME_WAIT state
450866ba9ddSjprakash 	 * or in tcp_close(), it is not protected by any lock as we
451866ba9ddSjprakash 	 * do not expect any other thread to use it concurrently.
4520163a147Sjprakash 	 * We do allow re-use of tcp_closemp in tcp_time_wait_collector()
4530163a147Sjprakash 	 * and tcp_close() but not concurrently.
454866ba9ddSjprakash 	 */
4550163a147Sjprakash 	boolean_t tcp_closemp_used;
456866ba9ddSjprakash 
457866ba9ddSjprakash 	/*
458866ba9ddSjprakash 	 * previous and next eagers in the list of droppable eagers. See
459866ba9ddSjprakash 	 * the comments before MAKE_DROPPABLE(). These pointers are
460866ba9ddSjprakash 	 * protected by listener's tcp_eager_lock.
461866ba9ddSjprakash 	 */
462866ba9ddSjprakash 	struct tcp_s	*tcp_eager_prev_drop_q0;
463866ba9ddSjprakash 	struct tcp_s	*tcp_eager_next_drop_q0;
464e0968231Svi117747 
465e0968231Svi117747 	/*
466e0968231Svi117747 	 * Have we flow controlled xmitter?
467e0968231Svi117747 	 * This variable can be modified outside the squeue and hence must
468e0968231Svi117747 	 * not be declared as a bit field along with the rest that are
469e0968231Svi117747 	 * modified only within the squeue.
470e0968231Svi117747 	 * protected by the tcp_non_sq_lock lock.
471e0968231Svi117747 	 */
472e0968231Svi117747 	boolean_t	tcp_flow_stopped;
473e0968231Svi117747 
47417169044Sbrutus 	/*
475410734d4SPhilip Kirk 	 * Sender's next sequence number at the time the window was shrunk.
476410734d4SPhilip Kirk 	 */
477410734d4SPhilip Kirk 	uint32_t	tcp_snxt_shrunk;
478410734d4SPhilip Kirk 
479410734d4SPhilip Kirk 	/*
480dc7c1171SAnders Persson 	 * Socket generation number which is bumped when a connection attempt
481dc7c1171SAnders Persson 	 * is initiated. Its main purpose is to ensure that the socket does not
482dc7c1171SAnders Persson 	 * miss the asynchronous connected/disconnected notification.
4830f1702c5SYu Xiangning 	 */
4840f1702c5SYu Xiangning 	sock_connid_t	tcp_connid;
4850f1702c5SYu Xiangning 
486f7f8e53dSKacheong Poon 	/* mblk_t used to enter TCP's squeue from the service routine. */
487f7f8e53dSKacheong Poon 	mblk_t		*tcp_rsrv_mp;
488f7f8e53dSKacheong Poon 	/* Mutex for accessing tcp_rsrv_mp */
489f7f8e53dSKacheong Poon 	kmutex_t	tcp_rsrv_mp_lock;
490f7f8e53dSKacheong Poon 
49193fcb0b9SKacheong Poon 	/* For connection counting. */
49293fcb0b9SKacheong Poon 	struct tcp_listen_cnt_s	*tcp_listen_cnt;
49393fcb0b9SKacheong Poon 
49493fcb0b9SKacheong Poon 	/* Segment reassembly timer. */
49593fcb0b9SKacheong Poon 	timeout_id_t		tcp_reass_tid;
49693fcb0b9SKacheong Poon 
497707e74bcSKacheong Poon 	/* FIN-WAIT-2 flush timeout */
498707e74bcSKacheong Poon 	uint32_t		tcp_fin_wait_2_flush_interval;
499707e74bcSKacheong Poon 
500a2f04351SSebastien Roy 	tcp_conn_stats_t	tcp_cs;
501a2f04351SSebastien Roy 
502*1edba515SAndy Fiddaman 	/*
503*1edba515SAndy Fiddaman 	 * The cached inbound and outbound security associations (SAs) for the
504*1edba515SAndy Fiddaman 	 * TCP signature (TCP_MD5SIG).
505*1edba515SAndy Fiddaman 	 */
506*1edba515SAndy Fiddaman 	void		*tcp_sig_sa_in;
507*1edba515SAndy Fiddaman 	void		*tcp_sig_sa_out;
508*1edba515SAndy Fiddaman 
509866ba9ddSjprakash #ifdef DEBUG
510866ba9ddSjprakash 	pc_t			tcmp_stk[15];
511866ba9ddSjprakash #endif
5127c478bd9Sstevel@tonic-gate } tcp_t;
5137c478bd9Sstevel@tonic-gate 
514866ba9ddSjprakash #ifdef DEBUG
515866ba9ddSjprakash #define	TCP_DEBUG_GETPCSTACK(buffer, depth)	((void) getpcstack(buffer, \
516866ba9ddSjprakash 						    depth))
517866ba9ddSjprakash #else
518866ba9ddSjprakash #define	TCP_DEBUG_GETPCSTACK(buffer, depth)
519866ba9ddSjprakash #endif
520866ba9ddSjprakash 
52193fcb0b9SKacheong Poon extern void	tcp_conn_reclaim(void *);
5227c478bd9Sstevel@tonic-gate extern void	tcp_free(tcp_t *tcp);
523f4b3ec61Sdh155122 extern void	tcp_ddi_g_init(void);
524f4b3ec61Sdh155122 extern void	tcp_ddi_g_destroy(void);
52545a4b79dSSebastien Roy extern conn_t	*tcp_get_conn(void *arg, tcp_stack_t *);
5266f773e29SBaban Kenkre extern mblk_t	*tcp_snmp_get(queue_t *, mblk_t *, boolean_t);
527ff550d0eSmasputra extern int	tcp_snmp_set(queue_t *, int, int, uchar_t *, int len);
5280854dd28SPhilip Kirk 
529aec2a073SJerry Jelinek /* Pad for the tf_t structure to avoid false cache line sharing. */
530aec2a073SJerry Jelinek #define	TF_CACHEL_PAD	64
531aec2a073SJerry Jelinek 
5327c478bd9Sstevel@tonic-gate /*
533721fffe3SKacheong Poon  * The TCP Fanout structure for bind and acceptor hashes.
534721fffe3SKacheong Poon  * The hash tables and their linkage (tcp_*_hash, tcp_ptp*hn) are
5357c478bd9Sstevel@tonic-gate  * protected by the per-bucket tf_lock.  Each tcp_t
5367c478bd9Sstevel@tonic-gate  * inserted in the list points back at this lock using tcp_*_lockp.
5377c478bd9Sstevel@tonic-gate  *
538721fffe3SKacheong Poon  * The bind and acceptor hash queues are lists of tcp_t.
5397c478bd9Sstevel@tonic-gate  */
5407c478bd9Sstevel@tonic-gate /* listener hash and acceptor hash queue head */
5417c478bd9Sstevel@tonic-gate typedef struct tf_s {
5427c478bd9Sstevel@tonic-gate 	tcp_t		*tf_tcp;
5437c478bd9Sstevel@tonic-gate 	kmutex_t	tf_lock;
544aec2a073SJerry Jelinek 	unsigned char	tf_pad[TF_CACHEL_PAD -
545aec2a073SJerry Jelinek 	    (sizeof (tcp_t *) + sizeof (kmutex_t))];
5467c478bd9Sstevel@tonic-gate } tf_t;
547721fffe3SKacheong Poon 
548721fffe3SKacheong Poon 
549721fffe3SKacheong Poon /* Also used in ipclassifier.c */
550721fffe3SKacheong Poon extern struct kmem_cache  *tcp_sack_info_cache;
551721fffe3SKacheong Poon 
5527c478bd9Sstevel@tonic-gate #endif	/* (defined(_KERNEL) || defined(_KMEMUSER)) */
5537c478bd9Sstevel@tonic-gate 
5547c478bd9Sstevel@tonic-gate /* Contract private interface between TCP and Clustering. */
5557c478bd9Sstevel@tonic-gate 
5567c478bd9Sstevel@tonic-gate #define	CL_TCPI_V1	1	/* cl_tcpi_version number */
5577c478bd9Sstevel@tonic-gate 
5587c478bd9Sstevel@tonic-gate typedef struct cl_tcp_info_s {
5597c478bd9Sstevel@tonic-gate 	ushort_t	cl_tcpi_version;	/* cl_tcp_info_t's version no */
5607c478bd9Sstevel@tonic-gate 	ushort_t	cl_tcpi_ipversion;	/* IP version */
5617c478bd9Sstevel@tonic-gate 	int32_t		cl_tcpi_state;		/* TCP state */
5627c478bd9Sstevel@tonic-gate 	in_port_t	cl_tcpi_lport;		/* Local port */
5637c478bd9Sstevel@tonic-gate 	in_port_t	cl_tcpi_fport;		/* Remote port */
5647c478bd9Sstevel@tonic-gate 	in6_addr_t	cl_tcpi_laddr_v6;	/* Local IP address */
5657c478bd9Sstevel@tonic-gate 	in6_addr_t	cl_tcpi_faddr_v6;	/* Remote IP address */
5667c478bd9Sstevel@tonic-gate #ifdef _KERNEL
5677c478bd9Sstevel@tonic-gate /* Note: V4_PART_OF_V6 is meant to be used only for _KERNEL defined stuff */
5687c478bd9Sstevel@tonic-gate #define	cl_tcpi_laddr	V4_PART_OF_V6(cl_tcpi_laddr_v6)
5697c478bd9Sstevel@tonic-gate #define	cl_tcpi_faddr	V4_PART_OF_V6(cl_tcpi_faddr_v6)
5707c478bd9Sstevel@tonic-gate 
5717c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
5727c478bd9Sstevel@tonic-gate } cl_tcp_info_t;
5737c478bd9Sstevel@tonic-gate 
5747c478bd9Sstevel@tonic-gate /*
575bd670b35SErik Nordmark  * Hook functions to enable cluster networking
576bd670b35SErik Nordmark  * On non-clustered systems these vectors must always be NULL.
577bd670b35SErik Nordmark  */
578bd670b35SErik Nordmark extern void	(*cl_inet_listen)(netstackid_t, uint8_t, sa_family_t,
579bd670b35SErik Nordmark 		    uint8_t *, in_port_t, void *);
580bd670b35SErik Nordmark extern void	(*cl_inet_unlisten)(netstackid_t, uint8_t, sa_family_t,
581bd670b35SErik Nordmark 		    uint8_t *, in_port_t, void *);
582bd670b35SErik Nordmark 
583bd670b35SErik Nordmark /*
5847c478bd9Sstevel@tonic-gate  * Contracted Consolidation Private ioctl for aborting TCP connections.
5857c478bd9Sstevel@tonic-gate  * In order to keep the offsets and size of the structure the same between
5867c478bd9Sstevel@tonic-gate  * a 32-bit application and a 64-bit amd64 kernel, we use a #pragma
5877c478bd9Sstevel@tonic-gate  * pack(4).
5887c478bd9Sstevel@tonic-gate  */
5897c478bd9Sstevel@tonic-gate #define	TCP_IOC_ABORT_CONN	(('T' << 8) + 91)
5907c478bd9Sstevel@tonic-gate 
5917c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
5927c478bd9Sstevel@tonic-gate #pragma pack(4)
5937c478bd9Sstevel@tonic-gate #endif
5947c478bd9Sstevel@tonic-gate 
5957c478bd9Sstevel@tonic-gate typedef struct tcp_ioc_abort_conn_s {
5967c478bd9Sstevel@tonic-gate 	struct sockaddr_storage ac_local;	/* local addr and port */
5977c478bd9Sstevel@tonic-gate 	struct sockaddr_storage ac_remote;	/* remote addr and port */
5987c478bd9Sstevel@tonic-gate 	int32_t ac_start;			/* start state */
5997c478bd9Sstevel@tonic-gate 	int32_t ac_end;				/* end state  */
6007c478bd9Sstevel@tonic-gate 	int32_t ac_zoneid;			/* zoneid */
6017c478bd9Sstevel@tonic-gate } tcp_ioc_abort_conn_t;
6027c478bd9Sstevel@tonic-gate 
6037c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
6047c478bd9Sstevel@tonic-gate #pragma pack()
6057c478bd9Sstevel@tonic-gate #endif
6067c478bd9Sstevel@tonic-gate 
6077c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
6087c478bd9Sstevel@tonic-gate }
6097c478bd9Sstevel@tonic-gate #endif
6107c478bd9Sstevel@tonic-gate 
6117c478bd9Sstevel@tonic-gate #endif	/* _INET_TCP_H */
612