xref: /titanic_52/usr/src/uts/common/inet/tcp.h (revision 633fc3a6eed35d918db16925b7048d7a2e28064a)
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.
25*633fc3a6SSebastien Roy  * Copyright (c) 2014 by Delphix. All rights reserved.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate /* Copyright (c) 1990 Mentat Inc. */
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifndef	_INET_TCP_H
307c478bd9Sstevel@tonic-gate #define	_INET_TCP_H
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
337c478bd9Sstevel@tonic-gate extern "C" {
347c478bd9Sstevel@tonic-gate #endif
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #include <sys/inttypes.h>
377c478bd9Sstevel@tonic-gate #include <netinet/ip6.h>
387c478bd9Sstevel@tonic-gate #include <netinet/tcp.h>
397c478bd9Sstevel@tonic-gate #include <sys/socket.h>
400f1702c5SYu Xiangning #include <sys/socket_proto.h>
41f4b3ec61Sdh155122 #include <sys/md5.h>
42f4b3ec61Sdh155122 #include <inet/common.h>
43f4b3ec61Sdh155122 #include <inet/ip.h>
44f4b3ec61Sdh155122 #include <inet/ip6.h>
45f4b3ec61Sdh155122 #include <inet/mi.h>
46f4b3ec61Sdh155122 #include <inet/mib2.h>
47f4b3ec61Sdh155122 #include <inet/tcp_stack.h>
48f4b3ec61Sdh155122 #include <inet/tcp_sack.h>
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate /* TCP states */
517c478bd9Sstevel@tonic-gate #define	TCPS_CLOSED		-6
527c478bd9Sstevel@tonic-gate #define	TCPS_IDLE		-5	/* idle (opened, but not bound) */
537c478bd9Sstevel@tonic-gate #define	TCPS_BOUND		-4	/* bound, ready to connect or accept */
547c478bd9Sstevel@tonic-gate #define	TCPS_LISTEN		-3	/* listening for connection */
557c478bd9Sstevel@tonic-gate #define	TCPS_SYN_SENT		-2	/* active, have sent syn */
567c478bd9Sstevel@tonic-gate #define	TCPS_SYN_RCVD		-1	/* have received syn (and sent ours) */
577c478bd9Sstevel@tonic-gate /* states < TCPS_ESTABLISHED are those where connections not established */
587c478bd9Sstevel@tonic-gate #define	TCPS_ESTABLISHED	0	/* established */
597c478bd9Sstevel@tonic-gate #define	TCPS_CLOSE_WAIT		1	/* rcvd fin, waiting for close */
607c478bd9Sstevel@tonic-gate /* states > TCPS_CLOSE_WAIT are those where user has closed */
617c478bd9Sstevel@tonic-gate #define	TCPS_FIN_WAIT_1		2	/* have closed and sent fin */
627c478bd9Sstevel@tonic-gate #define	TCPS_CLOSING		3	/* closed, xchd FIN, await FIN ACK */
637c478bd9Sstevel@tonic-gate #define	TCPS_LAST_ACK		4	/* had fin and close; await FIN ACK */
647c478bd9Sstevel@tonic-gate /* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */
657c478bd9Sstevel@tonic-gate #define	TCPS_FIN_WAIT_2		5	/* have closed, fin is acked */
667c478bd9Sstevel@tonic-gate #define	TCPS_TIME_WAIT		6	/* in 2*msl quiet wait after close */
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate /*
697c478bd9Sstevel@tonic-gate  * Internal flags used in conjunction with the packet header flags.
70bd670b35SErik Nordmark  * Used in tcp_input_data to keep track of what needs to be done.
717c478bd9Sstevel@tonic-gate  */
727c478bd9Sstevel@tonic-gate #define	TH_LIMIT_XMIT		0x0400	/* Limited xmit is needed */
737c478bd9Sstevel@tonic-gate #define	TH_XMIT_NEEDED		0x0800	/* Window opened - send queued data */
747c478bd9Sstevel@tonic-gate #define	TH_REXMIT_NEEDED	0x1000	/* Time expired for unacked data */
757c478bd9Sstevel@tonic-gate #define	TH_ACK_NEEDED		0x2000	/* Send an ack now. */
767c478bd9Sstevel@tonic-gate #define	TH_NEED_SACK_REXMIT	0x4000	/* Use SACK info to retransmission */
777c478bd9Sstevel@tonic-gate #define	TH_ACK_TIMER_NEEDED	0x8000	/* Start the delayed ACK timer */
787c478bd9Sstevel@tonic-gate #define	TH_ORDREL_NEEDED	0x10000	/* Generate an ordrel indication */
797c478bd9Sstevel@tonic-gate #define	TH_MARKNEXT_NEEDED	0x20000	/* Data should have MSGMARKNEXT */
807c478bd9Sstevel@tonic-gate #define	TH_SEND_URP_MARK	0x40000	/* Send up tcp_urp_mark_mp */
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate /*
837c478bd9Sstevel@tonic-gate  * TCP sequence numbers are 32 bit integers operated
847c478bd9Sstevel@tonic-gate  * on with modular arithmetic.  These macros can be
857c478bd9Sstevel@tonic-gate  * used to compare such integers.
867c478bd9Sstevel@tonic-gate  */
877c478bd9Sstevel@tonic-gate #define	SEQ_LT(a, b)	((int32_t)((a)-(b)) < 0)
887c478bd9Sstevel@tonic-gate #define	SEQ_LEQ(a, b)	((int32_t)((a)-(b)) <= 0)
897c478bd9Sstevel@tonic-gate #define	SEQ_GT(a, b)	((int32_t)((a)-(b)) > 0)
907c478bd9Sstevel@tonic-gate #define	SEQ_GEQ(a, b)	((int32_t)((a)-(b)) >= 0)
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate /* TCP Protocol header */
937c478bd9Sstevel@tonic-gate typedef	struct tcphdr_s {
947c478bd9Sstevel@tonic-gate 	uint8_t		th_lport[2];	/* Source port */
957c478bd9Sstevel@tonic-gate 	uint8_t		th_fport[2];	/* Destination port */
967c478bd9Sstevel@tonic-gate 	uint8_t		th_seq[4];	/* Sequence number */
977c478bd9Sstevel@tonic-gate 	uint8_t		th_ack[4];	/* Acknowledgement number */
987c478bd9Sstevel@tonic-gate 	uint8_t		th_offset_and_rsrvd[1]; /* Offset to the packet data */
997c478bd9Sstevel@tonic-gate 	uint8_t		th_flags[1];
1007c478bd9Sstevel@tonic-gate 	uint8_t		th_win[2];	/* Allocation number */
1017c478bd9Sstevel@tonic-gate 	uint8_t		th_sum[2];	/* TCP checksum */
1027c478bd9Sstevel@tonic-gate 	uint8_t		th_urp[2];	/* Urgent pointer */
1037c478bd9Sstevel@tonic-gate } tcph_t;
1047c478bd9Sstevel@tonic-gate 
105bd670b35SErik Nordmark #define	TCP_HDR_LENGTH(tcph) \
106bd670b35SErik Nordmark 	((((tcph_t *)tcph)->th_offset_and_rsrvd[0] >>2) &(0xF << 2))
1077c478bd9Sstevel@tonic-gate #define	TCP_MAX_COMBINED_HEADER_LENGTH	(60 + 60) /* Maxed out ip + tcp */
1087c478bd9Sstevel@tonic-gate #define	TCP_MAX_IP_OPTIONS_LENGTH	(60 - IP_SIMPLE_HDR_LENGTH)
1097c478bd9Sstevel@tonic-gate #define	TCP_MAX_HDR_LENGTH		60
110bd670b35SErik Nordmark #define	TCP_MAX_TCP_OPTIONS_LENGTH	(60 - sizeof (tcpha_t))
1117c478bd9Sstevel@tonic-gate #define	TCP_MIN_HEADER_LENGTH		20
1127c478bd9Sstevel@tonic-gate #define	TCP_MAXWIN			65535
1137c478bd9Sstevel@tonic-gate #define	TCP_PORT_LEN			sizeof (in_port_t)
1147c478bd9Sstevel@tonic-gate #define	TCP_MAX_WINSHIFT		14
1157c478bd9Sstevel@tonic-gate #define	TCP_MAX_LARGEWIN		(TCP_MAXWIN << TCP_MAX_WINSHIFT)
1168347601bSyl150051 #define	TCP_MAX_LSO_LENGTH	(IP_MAXPACKET - TCP_MAX_COMBINED_HEADER_LENGTH)
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate #define	TCPIP_HDR_LENGTH(mp, n)					\
1197c478bd9Sstevel@tonic-gate 	(n) = IPH_HDR_LENGTH((mp)->b_rptr),			\
120bd670b35SErik Nordmark 	(n) += TCP_HDR_LENGTH((tcpha_t *)&(mp)->b_rptr[(n)])
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate /* TCP Protocol header (used if the header is known to be 32-bit aligned) */
1237c478bd9Sstevel@tonic-gate typedef	struct tcphdra_s {
1247c478bd9Sstevel@tonic-gate 	in_port_t	tha_lport;	/* Source port */
1257c478bd9Sstevel@tonic-gate 	in_port_t	tha_fport;	/* Destination port */
1267c478bd9Sstevel@tonic-gate 	uint32_t	tha_seq;	/* Sequence number */
1277c478bd9Sstevel@tonic-gate 	uint32_t	tha_ack;	/* Acknowledgement number */
1287c478bd9Sstevel@tonic-gate 	uint8_t tha_offset_and_reserved; /* Offset to the packet data */
1297c478bd9Sstevel@tonic-gate 	uint8_t		tha_flags;
1307c478bd9Sstevel@tonic-gate 	uint16_t	tha_win;	/* Allocation number */
1317c478bd9Sstevel@tonic-gate 	uint16_t	tha_sum;	/* TCP checksum */
1327c478bd9Sstevel@tonic-gate 	uint16_t	tha_urp;	/* Urgent pointer */
1337c478bd9Sstevel@tonic-gate } tcpha_t;
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate struct conn_s;
13693fcb0b9SKacheong Poon struct tcp_listen_cnt_s;
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate /*
1397c478bd9Sstevel@tonic-gate  * Control structure for each open TCP stream,
1407c478bd9Sstevel@tonic-gate  * defined only within the kernel or for a kmem user.
1417c478bd9Sstevel@tonic-gate  * NOTE: tcp_reinit_values MUST have a line for each field in this structure!
1427c478bd9Sstevel@tonic-gate  */
1437c478bd9Sstevel@tonic-gate #if (defined(_KERNEL) || defined(_KMEMUSER))
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate typedef struct tcp_s {
1467c478bd9Sstevel@tonic-gate 	struct tcp_s	*tcp_time_wait_next;
1477c478bd9Sstevel@tonic-gate 				/* Pointer to next T/W block */
1487c478bd9Sstevel@tonic-gate 	struct tcp_s	*tcp_time_wait_prev;
1497c478bd9Sstevel@tonic-gate 				/* Pointer to previous T/W next */
15066cd0f60SKacheong Poon 	int64_t		tcp_time_wait_expire;
151f4b3ec61Sdh155122 
152721fffe3SKacheong Poon 	struct conn_s	*tcp_connp;	/* back pointer to conn_t */
153721fffe3SKacheong Poon 	tcp_stack_t	*tcp_tcps;	/* back pointer to tcp_stack_t */
1547c478bd9Sstevel@tonic-gate 
1557c478bd9Sstevel@tonic-gate 	int32_t	tcp_state;
1567c478bd9Sstevel@tonic-gate 	int32_t	tcp_rcv_ws;		/* My window scale power */
1577c478bd9Sstevel@tonic-gate 	int32_t	tcp_snd_ws;		/* Sender's window scale power */
1587c478bd9Sstevel@tonic-gate 	uint32_t tcp_ts_recent;		/* Timestamp of earliest unacked */
1597c478bd9Sstevel@tonic-gate 					/*  data segment */
1607c478bd9Sstevel@tonic-gate 	clock_t	tcp_rto;		/* Round trip timeout */
161fec71d83SGeorge Shepherd 	int64_t	tcp_last_rcv_lbolt;
1627c478bd9Sstevel@tonic-gate 				/* lbolt on last packet, used for PAWS */
163707e74bcSKacheong Poon 	uint32_t tcp_rto_initial;	/* Initial RTO */
164707e74bcSKacheong Poon 	uint32_t tcp_rto_min;		/* Minimum RTO */
165707e74bcSKacheong Poon 	uint32_t tcp_rto_max;		/* Maximum RTO */
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate 	uint32_t tcp_snxt;		/* Senders next seq num */
1687c478bd9Sstevel@tonic-gate 	uint32_t tcp_swnd;		/* Senders window (relative to suna) */
1697c478bd9Sstevel@tonic-gate 	uint32_t tcp_mss;		/* Max segment size */
1707c478bd9Sstevel@tonic-gate 	uint32_t tcp_iss;		/* Initial send seq num */
1717c478bd9Sstevel@tonic-gate 	uint32_t tcp_rnxt;		/* Seq we expect to recv next */
1727c478bd9Sstevel@tonic-gate 	uint32_t tcp_rwnd;
1737c478bd9Sstevel@tonic-gate 
1747c478bd9Sstevel@tonic-gate 	/* Fields arranged in approximate access order along main paths */
175721fffe3SKacheong Poon 	mblk_t	*tcp_xmit_head;		/* Head of xmit/rexmit list */
176721fffe3SKacheong Poon 	mblk_t	*tcp_xmit_last;		/* Last valid data seen by tcp_wput */
177721fffe3SKacheong Poon 	mblk_t	*tcp_xmit_tail;		/* Last data sent */
1787c478bd9Sstevel@tonic-gate 	uint32_t tcp_unsent;		/* # of bytes in hand that are unsent */
1797c478bd9Sstevel@tonic-gate 	uint32_t tcp_xmit_tail_unsent;	/* # of unsent bytes in xmit_tail */
1807c478bd9Sstevel@tonic-gate 
1817c478bd9Sstevel@tonic-gate 	uint32_t tcp_suna;		/* Sender unacknowledged */
1827c478bd9Sstevel@tonic-gate 	uint32_t tcp_rexmit_nxt;	/* Next rexmit seq num */
1837c478bd9Sstevel@tonic-gate 	uint32_t tcp_rexmit_max;	/* Max retran seq num */
1847c478bd9Sstevel@tonic-gate 	uint32_t tcp_cwnd;		/* Congestion window */
1857c478bd9Sstevel@tonic-gate 	int32_t tcp_cwnd_cnt;		/* cwnd cnt in congestion avoidance */
1867c478bd9Sstevel@tonic-gate 
1877c478bd9Sstevel@tonic-gate 	uint32_t tcp_ibsegs;		/* Inbound segments on this stream */
1887c478bd9Sstevel@tonic-gate 	uint32_t tcp_obsegs;		/* Outbound segments on this stream */
1897c478bd9Sstevel@tonic-gate 
1907c478bd9Sstevel@tonic-gate 	uint32_t tcp_naglim;		/* Tunable nagle limit */
1917c478bd9Sstevel@tonic-gate 	uint32_t	tcp_valid_bits;
1927c478bd9Sstevel@tonic-gate #define	TCP_ISS_VALID	0x1	/* Is the tcp_iss seq num active? */
1937c478bd9Sstevel@tonic-gate #define	TCP_FSS_VALID	0x2	/* Is the tcp_fss seq num active? */
1947c478bd9Sstevel@tonic-gate #define	TCP_URG_VALID	0x4	/* Is the tcp_urg seq num active? */
1957c478bd9Sstevel@tonic-gate #define	TCP_OFO_FIN_VALID 0x8	/* Has TCP received an out of order FIN? */
1967c478bd9Sstevel@tonic-gate 
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate 
1997c478bd9Sstevel@tonic-gate 	timeout_id_t	tcp_timer_tid;	/* Control block for timer service */
2007c478bd9Sstevel@tonic-gate 	uchar_t	tcp_timer_backoff;	/* Backoff shift count. */
2017c478bd9Sstevel@tonic-gate 	int64_t tcp_last_recv_time;	/* Last time we receive a segment. */
2027c478bd9Sstevel@tonic-gate 	uint32_t tcp_init_cwnd;		/* Initial cwnd (start/restart) */
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate 	/* Following manipulated by TCP under squeue protection */
2057c478bd9Sstevel@tonic-gate 	uint32_t
2067c478bd9Sstevel@tonic-gate 		tcp_urp_last_valid : 1,	/* Is tcp_urp_last valid? */
207bd670b35SErik Nordmark 		tcp_hard_binding : 1,	/* TCP_DETACHED_NONEAGER */
2087c478bd9Sstevel@tonic-gate 		tcp_fin_acked : 1,	/* Has our FIN been acked? */
2097c478bd9Sstevel@tonic-gate 		tcp_fin_rcvd : 1,	/* Have we seen a FIN? */
210bd670b35SErik Nordmark 
2117c478bd9Sstevel@tonic-gate 		tcp_fin_sent : 1,	/* Have we sent our FIN yet? */
2127c478bd9Sstevel@tonic-gate 		tcp_ordrel_done : 1,	/* Have we sent the ord_rel upstream? */
2137c478bd9Sstevel@tonic-gate 		tcp_detached : 1,	/* If we're detached from a stream */
2147c478bd9Sstevel@tonic-gate 		tcp_zero_win_probe: 1,	/* Zero win probing is in progress */
215f7f8e53dSKacheong Poon 
2167c478bd9Sstevel@tonic-gate 		tcp_loopback: 1,	/* src and dst are the same machine */
2177c478bd9Sstevel@tonic-gate 		tcp_localnet: 1,	/* src and dst are on the same subnet */
2187c478bd9Sstevel@tonic-gate 		tcp_syn_defense: 1,	/* For defense against SYN attack */
2197c478bd9Sstevel@tonic-gate #define	tcp_dontdrop	tcp_syn_defense
2207c478bd9Sstevel@tonic-gate 		tcp_set_timer : 1,
2218380b3ccSYu Xiangning 
222f7f8e53dSKacheong Poon 		tcp_active_open: 1,	/* This is a active open */
223f7f8e53dSKacheong Poon 		tcp_rexmit : 1,		/* TCP is retransmitting */
2247c478bd9Sstevel@tonic-gate 		tcp_snd_sack_ok : 1,	/* Can use SACK for this connection */
2257c478bd9Sstevel@tonic-gate 		tcp_hwcksum : 1,	/* The NIC is capable of hwcksum */
226f7f8e53dSKacheong Poon 
227bd670b35SErik Nordmark 		tcp_ip_forward_progress : 1,
2287c478bd9Sstevel@tonic-gate 		tcp_ecn_ok : 1,		/* Can use ECN for this connection */
2297c478bd9Sstevel@tonic-gate 		tcp_ecn_echo_on : 1,	/* Need to do ECN echo */
2307c478bd9Sstevel@tonic-gate 		tcp_ecn_cwr_sent : 1,	/* ECN_CWR has been sent */
231bd670b35SErik Nordmark 
232e0968231Svi117747 		tcp_cwr : 1,		/* Cwnd has reduced recently */
233f7f8e53dSKacheong Poon 
234bd670b35SErik Nordmark 		tcp_pad_to_bit31 : 11;
235bd670b35SErik Nordmark 
2367c478bd9Sstevel@tonic-gate 	/* Following manipulated by TCP under squeue protection */
2377c478bd9Sstevel@tonic-gate 	uint32_t
2387c478bd9Sstevel@tonic-gate 		tcp_snd_ts_ok  : 1,
2397c478bd9Sstevel@tonic-gate 		tcp_snd_ws_ok  : 1,
240bd670b35SErik Nordmark 		tcp_reserved_port : 1,
2417c478bd9Sstevel@tonic-gate 		tcp_in_free_list : 1,
2427c478bd9Sstevel@tonic-gate 
243bd670b35SErik Nordmark 		tcp_snd_zcopy_on : 1,	/* xmit zero-copy enabled */
2447c478bd9Sstevel@tonic-gate 		tcp_snd_zcopy_aware : 1, /* client is zero-copy aware */
2457c478bd9Sstevel@tonic-gate 		tcp_xmit_zc_clean : 1,	/* the xmit list is free of zc-mblk */
2467c478bd9Sstevel@tonic-gate 		tcp_wait_for_eagers : 1, /* Wait for eagers to disappear */
2477c478bd9Sstevel@tonic-gate 
248bd670b35SErik Nordmark 		tcp_accept_error : 1,	/* Error during TLI accept */
2497c478bd9Sstevel@tonic-gate 		tcp_send_discon_ind : 1, /* TLI accept err, send discon ind */
2507c478bd9Sstevel@tonic-gate 		tcp_cork : 1,		/* tcp_cork option */
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 */
255bd670b35SErik Nordmark 
256bd670b35SErik Nordmark 		tcp_pad_to_bit_31 : 18;
257bd670b35SErik Nordmark 
258bd670b35SErik Nordmark 	uint32_t	tcp_initial_pmtu; /* Initial outgoing Path MTU. */
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate 	mblk_t	*tcp_reass_head;	/* Out of order reassembly list head */
2617c478bd9Sstevel@tonic-gate 	mblk_t	*tcp_reass_tail;	/* Out of order reassembly list tail */
2627c478bd9Sstevel@tonic-gate 
26366cd0f60SKacheong Poon 	/* SACK related info */
26466cd0f60SKacheong Poon 	tcp_sack_info_t	tcp_sack_info;
2657c478bd9Sstevel@tonic-gate 
26666cd0f60SKacheong Poon #define	tcp_pipe		tcp_sack_info.tcp_pipe
26766cd0f60SKacheong Poon #define	tcp_fack		tcp_sack_info.tcp_fack
26866cd0f60SKacheong Poon #define	tcp_sack_snxt		tcp_sack_info.tcp_sack_snxt
26966cd0f60SKacheong Poon #define	tcp_max_sack_blk	tcp_sack_info.tcp_max_sack_blk
27066cd0f60SKacheong Poon #define	tcp_num_sack_blk	tcp_sack_info.tcp_num_sack_blk
27166cd0f60SKacheong Poon #define	tcp_sack_list		tcp_sack_info.tcp_sack_list
27266cd0f60SKacheong Poon #define	tcp_num_notsack_blk	tcp_sack_info.tcp_num_notsack_blk
27366cd0f60SKacheong Poon #define	tcp_cnt_notsack_list	tcp_sack_info.tcp_cnt_notsack_list
27466cd0f60SKacheong Poon #define	tcp_notsack_list	tcp_sack_info.tcp_notsack_list
2757c478bd9Sstevel@tonic-gate 
2767c478bd9Sstevel@tonic-gate 	mblk_t	*tcp_rcv_list;		/* Queued until push, urgent data, */
2777c478bd9Sstevel@tonic-gate 	mblk_t	*tcp_rcv_last_head;	/* optdata, or the count exceeds */
2787c478bd9Sstevel@tonic-gate 	mblk_t	*tcp_rcv_last_tail;	/* tcp_rcv_push_wait. */
2797c478bd9Sstevel@tonic-gate 	uint32_t tcp_rcv_cnt;		/* tcp_rcv_list is b_next chain. */
2807c478bd9Sstevel@tonic-gate 
2817c478bd9Sstevel@tonic-gate 	uint32_t tcp_cwnd_ssthresh;	/* Congestion window */
2827c478bd9Sstevel@tonic-gate 	uint32_t tcp_cwnd_max;
2837c478bd9Sstevel@tonic-gate 	uint32_t tcp_csuna;		/* Clear (no rexmits in window) suna */
2847c478bd9Sstevel@tonic-gate 
2857c478bd9Sstevel@tonic-gate 	clock_t	tcp_rtt_sa;		/* Round trip smoothed average */
2867c478bd9Sstevel@tonic-gate 	clock_t	tcp_rtt_sd;		/* Round trip smoothed deviation */
2877c478bd9Sstevel@tonic-gate 	clock_t	tcp_rtt_update;		/* Round trip update(s) */
2887c478bd9Sstevel@tonic-gate 	clock_t tcp_ms_we_have_waited;	/* Total retrans time */
2897c478bd9Sstevel@tonic-gate 
2907c478bd9Sstevel@tonic-gate 	uint32_t tcp_swl1;		/* These help us avoid using stale */
2917c478bd9Sstevel@tonic-gate 	uint32_t tcp_swl2;		/*  packets to update state */
2927c478bd9Sstevel@tonic-gate 
2937c478bd9Sstevel@tonic-gate 	uint32_t tcp_rack;		/* Seq # we have acked */
2947c478bd9Sstevel@tonic-gate 	uint32_t tcp_rack_cnt;		/* # of segs we have deferred ack */
2957c478bd9Sstevel@tonic-gate 	uint32_t tcp_rack_cur_max;	/* # of segs we may defer ack for now */
2967c478bd9Sstevel@tonic-gate 	uint32_t tcp_rack_abs_max;	/* # of segs we may defer ack ever */
2977c478bd9Sstevel@tonic-gate 	timeout_id_t	tcp_ack_tid;	/* Delayed ACK timer ID */
2987c478bd9Sstevel@tonic-gate 	timeout_id_t	tcp_push_tid;	/* Push timer ID */
2997c478bd9Sstevel@tonic-gate 
3007c478bd9Sstevel@tonic-gate 	uint32_t tcp_max_swnd;		/* Maximum swnd we have seen */
3017c478bd9Sstevel@tonic-gate 
3027c478bd9Sstevel@tonic-gate 	struct tcp_s *tcp_listener;	/* Our listener */
3037c478bd9Sstevel@tonic-gate 
3047c478bd9Sstevel@tonic-gate 	uint32_t tcp_irs;		/* Initial recv seq num */
3057c478bd9Sstevel@tonic-gate 	uint32_t tcp_fss;		/* Final/fin send seq num */
3067c478bd9Sstevel@tonic-gate 	uint32_t tcp_urg;		/* Urgent data seq num */
3077c478bd9Sstevel@tonic-gate 
3087c478bd9Sstevel@tonic-gate 	clock_t	tcp_first_timer_threshold;  /* When to prod IP */
3097c478bd9Sstevel@tonic-gate 	clock_t	tcp_second_timer_threshold; /* When to give up completely */
3107c478bd9Sstevel@tonic-gate 	clock_t	tcp_first_ctimer_threshold; /* 1st threshold while connecting */
3117c478bd9Sstevel@tonic-gate 	clock_t tcp_second_ctimer_threshold; /* 2nd ... while connecting */
3127c478bd9Sstevel@tonic-gate 
3137c478bd9Sstevel@tonic-gate 	uint32_t tcp_urp_last;		/* Last urp for which signal sent */
3147c478bd9Sstevel@tonic-gate 	mblk_t	*tcp_urp_mp;		/* T_EXDATA_IND for urgent byte */
3157c478bd9Sstevel@tonic-gate 	mblk_t	*tcp_urp_mark_mp;	/* zero-length marked/unmarked msg */
3167c478bd9Sstevel@tonic-gate 
3177c478bd9Sstevel@tonic-gate 	int tcp_conn_req_cnt_q0;	/* # of conn reqs in SYN_RCVD */
3187c478bd9Sstevel@tonic-gate 	int tcp_conn_req_cnt_q;	/* # of conn reqs in ESTABLISHED */
3197c478bd9Sstevel@tonic-gate 	int tcp_conn_req_max;	/* # of ESTABLISHED conn reqs allowed */
3207c478bd9Sstevel@tonic-gate 	t_scalar_t tcp_conn_req_seqnum;	/* Incrementing pending conn req ID */
3217c478bd9Sstevel@tonic-gate #define	tcp_ip_addr_cache	tcp_reass_tail
3227c478bd9Sstevel@tonic-gate 					/* Cache ip addresses that */
3237c478bd9Sstevel@tonic-gate 					/* complete the 3-way handshake */
3247c478bd9Sstevel@tonic-gate 	kmutex_t  tcp_eager_lock;
3257c478bd9Sstevel@tonic-gate 	struct tcp_s *tcp_eager_next_q; /* next eager in ESTABLISHED state */
3267c478bd9Sstevel@tonic-gate 	struct tcp_s *tcp_eager_last_q;	/* last eager in ESTABLISHED state */
3277c478bd9Sstevel@tonic-gate 	struct tcp_s *tcp_eager_next_q0; /* next eager in SYN_RCVD state */
3287c478bd9Sstevel@tonic-gate 	struct tcp_s *tcp_eager_prev_q0; /* prev eager in SYN_RCVD state */
3297c478bd9Sstevel@tonic-gate 					/* all eagers form a circular list */
3308380b3ccSYu Xiangning 	boolean_t tcp_conn_def_q0;	/* move from q0 to q deferred */
3318380b3ccSYu Xiangning 
3327c478bd9Sstevel@tonic-gate 	union {
3337c478bd9Sstevel@tonic-gate 	    mblk_t *tcp_eager_conn_ind; /* T_CONN_IND waiting for 3rd ack. */
3347c478bd9Sstevel@tonic-gate 	    mblk_t *tcp_opts_conn_req; /* T_CONN_REQ w/ options processed */
3357c478bd9Sstevel@tonic-gate 	} tcp_conn;
3367c478bd9Sstevel@tonic-gate 	uint32_t tcp_syn_rcvd_timeout;	/* How many SYN_RCVD timeout in q0 */
3377c478bd9Sstevel@tonic-gate 
3383d0a255cSGarrett D'Amore 	/*
3393d0a255cSGarrett D'Amore 	 * TCP Keepalive Timer members.
3403d0a255cSGarrett D'Amore 	 * All keepalive timer intervals are in milliseconds.
3413d0a255cSGarrett D'Amore 	 */
3427c478bd9Sstevel@tonic-gate 	int32_t	tcp_ka_last_intrvl;	/* Last probe interval */
3437c478bd9Sstevel@tonic-gate 	timeout_id_t tcp_ka_tid;	/* Keepalive timer ID */
3447c478bd9Sstevel@tonic-gate 	uint32_t tcp_ka_interval;	/* Keepalive interval */
3453d0a255cSGarrett D'Amore 
3463d0a255cSGarrett D'Amore 	/*
3473d0a255cSGarrett D'Amore 	 * TCP connection is terminated if we don't hear back from the peer
3483d0a255cSGarrett D'Amore 	 * for tcp_ka_abort_thres milliseconds after the first keepalive probe.
3493d0a255cSGarrett D'Amore 	 * tcp_ka_rinterval is the interval in milliseconds between successive
3503d0a255cSGarrett D'Amore 	 * keepalive probes. tcp_ka_cnt is the number of keepalive probes to
3513d0a255cSGarrett D'Amore 	 * be sent before terminating the connection, if we don't hear back from
3523d0a255cSGarrett D'Amore 	 * peer.
3533d0a255cSGarrett D'Amore 	 * tcp_ka_abort_thres = tcp_ka_rinterval * tcp_ka_cnt
3543d0a255cSGarrett D'Amore 	 */
3553d0a255cSGarrett D'Amore 	uint32_t tcp_ka_rinterval;	/* keepalive retransmit interval */
3567c478bd9Sstevel@tonic-gate 	uint32_t tcp_ka_abort_thres;	/* Keepalive abort threshold */
3573d0a255cSGarrett D'Amore 	uint32_t tcp_ka_cnt;		/* count of keepalive probes */
3587c478bd9Sstevel@tonic-gate 
3597c478bd9Sstevel@tonic-gate 	int32_t	tcp_client_errno;	/* How the client screwed up */
3607c478bd9Sstevel@tonic-gate 
361bd670b35SErik Nordmark 	/*
362bd670b35SErik Nordmark 	 * The header template lives in conn_ht_iphc allocated by tcp_build_hdrs
363bd670b35SErik Nordmark 	 * We maintain three pointers into conn_ht_iphc.
364bd670b35SErik Nordmark 	 */
365bd670b35SErik Nordmark 	ipha_t	*tcp_ipha;		/* IPv4 header in conn_ht_iphc */
366bd670b35SErik Nordmark 	ip6_t	*tcp_ip6h;		/* IPv6 header in conn_ht_iphc */
367bd670b35SErik Nordmark 	tcpha_t	*tcp_tcpha;		/* TCP header in conn_ht_iphc */
3687c478bd9Sstevel@tonic-gate 
3697c478bd9Sstevel@tonic-gate 	uint16_t tcp_last_sent_len;	/* Record length for nagle */
3709cd928feSAlan Maguire 	uint16_t tcp_last_recv_len;	/* Used by DTrace */
3717c478bd9Sstevel@tonic-gate 	uint16_t tcp_dupack_cnt;	/* # of consequtive duplicate acks */
3727c478bd9Sstevel@tonic-gate 
3737c478bd9Sstevel@tonic-gate 	kmutex_t	*tcp_acceptor_lockp;	/* Ptr to tf_lock */
3747c478bd9Sstevel@tonic-gate 
375f7f8e53dSKacheong Poon 	mblk_t		*tcp_ordrel_mp;		/* T_ordrel_ind mblk */
3767c478bd9Sstevel@tonic-gate 	t_uscalar_t	tcp_acceptor_id;	/* ACCEPTOR_id */
3777c478bd9Sstevel@tonic-gate 
3787c478bd9Sstevel@tonic-gate 	int		tcp_ipsec_overhead;
3797c478bd9Sstevel@tonic-gate 
3807c478bd9Sstevel@tonic-gate 	uint_t		tcp_recvifindex; /* Last received IPV6_RCVPKTINFO */
3817c478bd9Sstevel@tonic-gate 	uint_t		tcp_recvhops;	/* Last received IPV6_RECVHOPLIMIT */
3827c478bd9Sstevel@tonic-gate 	uint_t		tcp_recvtclass;	/* Last received IPV6_RECVTCLASS */
3837c478bd9Sstevel@tonic-gate 	ip6_hbh_t	*tcp_hopopts;	/* Last received IPV6_RECVHOPOPTS */
3847c478bd9Sstevel@tonic-gate 	ip6_dest_t	*tcp_dstopts;	/* Last received IPV6_RECVDSTOPTS */
385bd670b35SErik Nordmark 	ip6_dest_t	*tcp_rthdrdstopts; /* Last recv IPV6_RECVRTHDRDSTOPTS */
3867c478bd9Sstevel@tonic-gate 	ip6_rthdr_t	*tcp_rthdr;	/* Last received IPV6_RECVRTHDR */
3877c478bd9Sstevel@tonic-gate 	uint_t		tcp_hopoptslen;
3887c478bd9Sstevel@tonic-gate 	uint_t		tcp_dstoptslen;
389bd670b35SErik Nordmark 	uint_t		tcp_rthdrdstoptslen;
3907c478bd9Sstevel@tonic-gate 	uint_t		tcp_rthdrlen;
3917c478bd9Sstevel@tonic-gate 
3927c478bd9Sstevel@tonic-gate 	mblk_t		*tcp_timercache;
3937c478bd9Sstevel@tonic-gate 
3947c478bd9Sstevel@tonic-gate 	kmutex_t	tcp_closelock;
3957c478bd9Sstevel@tonic-gate 	kcondvar_t	tcp_closecv;
3967c478bd9Sstevel@tonic-gate 	uint8_t		tcp_closed;
3977c478bd9Sstevel@tonic-gate 	uint8_t		tcp_closeflags;
3987c478bd9Sstevel@tonic-gate 	mblk_t		tcp_closemp;
3997c478bd9Sstevel@tonic-gate 	timeout_id_t	tcp_linger_tid;	/* Linger timer ID */
4007c478bd9Sstevel@tonic-gate 
4017c478bd9Sstevel@tonic-gate 	struct tcp_s *tcp_acceptor_hash; /* Acceptor hash chain */
4027c478bd9Sstevel@tonic-gate 	struct tcp_s **tcp_ptpahn; /* Pointer to previous accept hash next. */
4037c478bd9Sstevel@tonic-gate 	struct tcp_s *tcp_bind_hash; /* Bind hash chain */
4040f1702c5SYu Xiangning 	struct tcp_s *tcp_bind_hash_port; /* tcp_t's bound to the same lport */
4057c478bd9Sstevel@tonic-gate 	struct tcp_s **tcp_ptpbhn;
4067c478bd9Sstevel@tonic-gate 
407bd670b35SErik Nordmark 	uint_t		tcp_maxpsz_multiplier;
4087c478bd9Sstevel@tonic-gate 
4098347601bSyl150051 	uint32_t	tcp_lso_max; /* maximum LSO payload */
4108347601bSyl150051 
4117c478bd9Sstevel@tonic-gate 	uint32_t	tcp_ofo_fin_seq; /* Recv out of order FIN seq num */
4127c478bd9Sstevel@tonic-gate 	uint32_t	tcp_cwr_snd_max;
413bd670b35SErik Nordmark 
4147c478bd9Sstevel@tonic-gate 	struct tcp_s *tcp_saved_listener;	/* saved value of listener */
4157c478bd9Sstevel@tonic-gate 
416ff550d0eSmasputra 	uint32_t	tcp_in_ack_unsent;	/* ACK for unsent data cnt. */
417ff550d0eSmasputra 
418ff550d0eSmasputra 	/*
4197b8f5432SAnders Persson 	 * All fusion-related fields are protected by squeue.
420ff550d0eSmasputra 	 */
4217c478bd9Sstevel@tonic-gate 	struct tcp_s *tcp_loopback_peer;	/* peer tcp for loopback */
4227c478bd9Sstevel@tonic-gate 	mblk_t	*tcp_fused_sigurg_mp;		/* M_PCSIG mblk for SIGURG */
4237b8f5432SAnders Persson 
424ff550d0eSmasputra 	uint32_t
425ff550d0eSmasputra 		tcp_fused : 1,		/* loopback tcp in fusion mode */
426ff550d0eSmasputra 		tcp_unfusable : 1,	/* fusion not allowed on endpoint */
427ff550d0eSmasputra 		tcp_fused_sigurg : 1,	/* send SIGURG upon draining */
4287c478bd9Sstevel@tonic-gate 
4297b8f5432SAnders Persson 		tcp_fuse_to_bit_31 : 29;
4307b8f5432SAnders Persson 
4317b8f5432SAnders Persson 	kmutex_t tcp_non_sq_lock;
4327c478bd9Sstevel@tonic-gate 
4337c478bd9Sstevel@tonic-gate 	/*
4347c478bd9Sstevel@tonic-gate 	 * This variable is accessed without any lock protection
4357c478bd9Sstevel@tonic-gate 	 * and therefore must not be declared as a bit field along
4367c478bd9Sstevel@tonic-gate 	 * with the rest which require such condition.
4377c478bd9Sstevel@tonic-gate 	 */
4387c478bd9Sstevel@tonic-gate 	boolean_t	tcp_issocket;	/* this is a socket tcp */
439ff550d0eSmasputra 
440e0968231Svi117747 	/* protected by the tcp_non_sq_lock lock */
441ff550d0eSmasputra 	uint32_t	tcp_squeue_bytes;
442866ba9ddSjprakash 
443866ba9ddSjprakash 	/*
444866ba9ddSjprakash 	 * tcp_closemp_used is protected by listener's tcp_eager_lock
445866ba9ddSjprakash 	 * when used for eagers. When used for a tcp in TIME_WAIT state
446866ba9ddSjprakash 	 * or in tcp_close(), it is not protected by any lock as we
447866ba9ddSjprakash 	 * do not expect any other thread to use it concurrently.
4480163a147Sjprakash 	 * We do allow re-use of tcp_closemp in tcp_time_wait_collector()
4490163a147Sjprakash 	 * and tcp_close() but not concurrently.
450866ba9ddSjprakash 	 */
4510163a147Sjprakash 	boolean_t tcp_closemp_used;
452866ba9ddSjprakash 
453866ba9ddSjprakash 	/*
454866ba9ddSjprakash 	 * previous and next eagers in the list of droppable eagers. See
455866ba9ddSjprakash 	 * the comments before MAKE_DROPPABLE(). These pointers are
456866ba9ddSjprakash 	 * protected by listener's tcp_eager_lock.
457866ba9ddSjprakash 	 */
458866ba9ddSjprakash 	struct tcp_s	*tcp_eager_prev_drop_q0;
459866ba9ddSjprakash 	struct tcp_s	*tcp_eager_next_drop_q0;
460e0968231Svi117747 
461e0968231Svi117747 	/*
462e0968231Svi117747 	 * Have we flow controlled xmitter?
463e0968231Svi117747 	 * This variable can be modified outside the squeue and hence must
464e0968231Svi117747 	 * not be declared as a bit field along with the rest that are
465e0968231Svi117747 	 * modified only within the squeue.
466e0968231Svi117747 	 * protected by the tcp_non_sq_lock lock.
467e0968231Svi117747 	 */
468e0968231Svi117747 	boolean_t	tcp_flow_stopped;
469e0968231Svi117747 
47017169044Sbrutus 	/*
471410734d4SPhilip Kirk 	 * Sender's next sequence number at the time the window was shrunk.
472410734d4SPhilip Kirk 	 */
473410734d4SPhilip Kirk 	uint32_t	tcp_snxt_shrunk;
474410734d4SPhilip Kirk 
475410734d4SPhilip Kirk 	/*
476dc7c1171SAnders Persson 	 * Socket generation number which is bumped when a connection attempt
477dc7c1171SAnders Persson 	 * is initiated. Its main purpose is to ensure that the socket does not
478dc7c1171SAnders Persson 	 * miss the asynchronous connected/disconnected notification.
4790f1702c5SYu Xiangning 	 */
4800f1702c5SYu Xiangning 	sock_connid_t	tcp_connid;
4810f1702c5SYu Xiangning 
482f7f8e53dSKacheong Poon 	/* mblk_t used to enter TCP's squeue from the service routine. */
483f7f8e53dSKacheong Poon 	mblk_t		*tcp_rsrv_mp;
484f7f8e53dSKacheong Poon 	/* Mutex for accessing tcp_rsrv_mp */
485f7f8e53dSKacheong Poon 	kmutex_t	tcp_rsrv_mp_lock;
486f7f8e53dSKacheong Poon 
48793fcb0b9SKacheong Poon 	/* For connection counting. */
48893fcb0b9SKacheong Poon 	struct tcp_listen_cnt_s	*tcp_listen_cnt;
48993fcb0b9SKacheong Poon 
49093fcb0b9SKacheong Poon 	/* Segment reassembly timer. */
49193fcb0b9SKacheong Poon 	timeout_id_t		tcp_reass_tid;
49293fcb0b9SKacheong Poon 
493707e74bcSKacheong Poon 	/* FIN-WAIT-2 flush timeout */
494707e74bcSKacheong Poon 	uint32_t		tcp_fin_wait_2_flush_interval;
495707e74bcSKacheong Poon 
496866ba9ddSjprakash #ifdef DEBUG
497866ba9ddSjprakash 	pc_t			tcmp_stk[15];
498866ba9ddSjprakash #endif
4997c478bd9Sstevel@tonic-gate } tcp_t;
5007c478bd9Sstevel@tonic-gate 
501866ba9ddSjprakash #ifdef DEBUG
502866ba9ddSjprakash #define	TCP_DEBUG_GETPCSTACK(buffer, depth)	((void) getpcstack(buffer, \
503866ba9ddSjprakash 						    depth))
504866ba9ddSjprakash #else
505866ba9ddSjprakash #define	TCP_DEBUG_GETPCSTACK(buffer, depth)
506866ba9ddSjprakash #endif
507866ba9ddSjprakash 
50893fcb0b9SKacheong Poon extern void	tcp_conn_reclaim(void *);
5097c478bd9Sstevel@tonic-gate extern void 	tcp_free(tcp_t *tcp);
510f4b3ec61Sdh155122 extern void	tcp_ddi_g_init(void);
511f4b3ec61Sdh155122 extern void	tcp_ddi_g_destroy(void);
512f3124163SAnders Persson extern void 	*tcp_get_conn(void *arg, tcp_stack_t *);
5136f773e29SBaban Kenkre extern mblk_t	*tcp_snmp_get(queue_t *, mblk_t *, boolean_t);
514ff550d0eSmasputra extern int	tcp_snmp_set(queue_t *, int, int, uchar_t *, int len);
5150854dd28SPhilip Kirk 
516aec2a073SJerry Jelinek /* Pad for the tf_t structure to avoid false cache line sharing. */
517aec2a073SJerry Jelinek #define	TF_CACHEL_PAD	64
518aec2a073SJerry Jelinek 
5197c478bd9Sstevel@tonic-gate /*
520721fffe3SKacheong Poon  * The TCP Fanout structure for bind and acceptor hashes.
521721fffe3SKacheong Poon  * The hash tables and their linkage (tcp_*_hash, tcp_ptp*hn) are
5227c478bd9Sstevel@tonic-gate  * protected by the per-bucket tf_lock.  Each tcp_t
5237c478bd9Sstevel@tonic-gate  * inserted in the list points back at this lock using tcp_*_lockp.
5247c478bd9Sstevel@tonic-gate  *
525721fffe3SKacheong Poon  * The bind and acceptor hash queues are lists of tcp_t.
5267c478bd9Sstevel@tonic-gate  */
5277c478bd9Sstevel@tonic-gate /* listener hash and acceptor hash queue head */
5287c478bd9Sstevel@tonic-gate typedef struct tf_s {
5297c478bd9Sstevel@tonic-gate 	tcp_t		*tf_tcp;
5307c478bd9Sstevel@tonic-gate 	kmutex_t	tf_lock;
531aec2a073SJerry Jelinek 	unsigned char	tf_pad[TF_CACHEL_PAD -
532aec2a073SJerry Jelinek 	    (sizeof (tcp_t *) + sizeof (kmutex_t))];
5337c478bd9Sstevel@tonic-gate } tf_t;
534721fffe3SKacheong Poon 
535721fffe3SKacheong Poon 
536721fffe3SKacheong Poon /* Also used in ipclassifier.c */
537721fffe3SKacheong Poon extern struct kmem_cache  *tcp_sack_info_cache;
538721fffe3SKacheong Poon 
5397c478bd9Sstevel@tonic-gate #endif	/* (defined(_KERNEL) || defined(_KMEMUSER)) */
5407c478bd9Sstevel@tonic-gate 
5417c478bd9Sstevel@tonic-gate /* Contract private interface between TCP and Clustering. */
5427c478bd9Sstevel@tonic-gate 
5437c478bd9Sstevel@tonic-gate #define	CL_TCPI_V1	1	/* cl_tcpi_version number */
5447c478bd9Sstevel@tonic-gate 
5457c478bd9Sstevel@tonic-gate typedef struct cl_tcp_info_s {
5467c478bd9Sstevel@tonic-gate 	ushort_t	cl_tcpi_version;	/* cl_tcp_info_t's version no */
5477c478bd9Sstevel@tonic-gate 	ushort_t	cl_tcpi_ipversion;	/* IP version */
5487c478bd9Sstevel@tonic-gate 	int32_t		cl_tcpi_state;		/* TCP state */
5497c478bd9Sstevel@tonic-gate 	in_port_t	cl_tcpi_lport;		/* Local port */
5507c478bd9Sstevel@tonic-gate 	in_port_t	cl_tcpi_fport;		/* Remote port */
5517c478bd9Sstevel@tonic-gate 	in6_addr_t	cl_tcpi_laddr_v6;	/* Local IP address */
5527c478bd9Sstevel@tonic-gate 	in6_addr_t	cl_tcpi_faddr_v6;	/* Remote IP address */
5537c478bd9Sstevel@tonic-gate #ifdef _KERNEL
5547c478bd9Sstevel@tonic-gate /* Note: V4_PART_OF_V6 is meant to be used only for _KERNEL defined stuff */
5557c478bd9Sstevel@tonic-gate #define	cl_tcpi_laddr	V4_PART_OF_V6(cl_tcpi_laddr_v6)
5567c478bd9Sstevel@tonic-gate #define	cl_tcpi_faddr	V4_PART_OF_V6(cl_tcpi_faddr_v6)
5577c478bd9Sstevel@tonic-gate 
5587c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
5597c478bd9Sstevel@tonic-gate } cl_tcp_info_t;
5607c478bd9Sstevel@tonic-gate 
5617c478bd9Sstevel@tonic-gate /*
562bd670b35SErik Nordmark  * Hook functions to enable cluster networking
563bd670b35SErik Nordmark  * On non-clustered systems these vectors must always be NULL.
564bd670b35SErik Nordmark  */
565bd670b35SErik Nordmark extern void	(*cl_inet_listen)(netstackid_t, uint8_t, sa_family_t,
566bd670b35SErik Nordmark 		    uint8_t *, in_port_t, void *);
567bd670b35SErik Nordmark extern void	(*cl_inet_unlisten)(netstackid_t, uint8_t, sa_family_t,
568bd670b35SErik Nordmark 		    uint8_t *, in_port_t, void *);
569bd670b35SErik Nordmark 
570bd670b35SErik Nordmark /*
5717c478bd9Sstevel@tonic-gate  * Contracted Consolidation Private ioctl for aborting TCP connections.
5727c478bd9Sstevel@tonic-gate  * In order to keep the offsets and size of the structure the same between
5737c478bd9Sstevel@tonic-gate  * a 32-bit application and a 64-bit amd64 kernel, we use a #pragma
5747c478bd9Sstevel@tonic-gate  * pack(4).
5757c478bd9Sstevel@tonic-gate  */
5767c478bd9Sstevel@tonic-gate #define	TCP_IOC_ABORT_CONN	(('T' << 8) + 91)
5777c478bd9Sstevel@tonic-gate 
5787c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
5797c478bd9Sstevel@tonic-gate #pragma pack(4)
5807c478bd9Sstevel@tonic-gate #endif
5817c478bd9Sstevel@tonic-gate 
5827c478bd9Sstevel@tonic-gate typedef struct tcp_ioc_abort_conn_s {
5837c478bd9Sstevel@tonic-gate 	struct sockaddr_storage ac_local;	/* local addr and port */
5847c478bd9Sstevel@tonic-gate 	struct sockaddr_storage ac_remote;	/* remote addr and port */
5857c478bd9Sstevel@tonic-gate 	int32_t ac_start;			/* start state */
5867c478bd9Sstevel@tonic-gate 	int32_t ac_end;				/* end state  */
5877c478bd9Sstevel@tonic-gate 	int32_t ac_zoneid;			/* zoneid */
5887c478bd9Sstevel@tonic-gate } tcp_ioc_abort_conn_t;
5897c478bd9Sstevel@tonic-gate 
5907c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
5917c478bd9Sstevel@tonic-gate #pragma pack()
5927c478bd9Sstevel@tonic-gate #endif
5937c478bd9Sstevel@tonic-gate 
5947c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
5957c478bd9Sstevel@tonic-gate }
5967c478bd9Sstevel@tonic-gate #endif
5977c478bd9Sstevel@tonic-gate 
5987c478bd9Sstevel@tonic-gate #endif	/* _INET_TCP_H */
599