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 /* 220854dd28SPhilip Kirk * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate /* Copyright (c) 1990 Mentat Inc. */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _INET_TCP_H 287c478bd9Sstevel@tonic-gate #define _INET_TCP_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #ifdef __cplusplus 317c478bd9Sstevel@tonic-gate extern "C" { 327c478bd9Sstevel@tonic-gate #endif 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #include <sys/inttypes.h> 357c478bd9Sstevel@tonic-gate #include <netinet/ip6.h> 367c478bd9Sstevel@tonic-gate #include <netinet/tcp.h> 377c478bd9Sstevel@tonic-gate #include <sys/socket.h> 380f1702c5SYu Xiangning #include <sys/socket_proto.h> 397c478bd9Sstevel@tonic-gate #include <sys/multidata.h> 40f4b3ec61Sdh155122 #include <sys/md5.h> 41f4b3ec61Sdh155122 #include <inet/common.h> 42f4b3ec61Sdh155122 #include <inet/ip.h> 43f4b3ec61Sdh155122 #include <inet/ip6.h> 44f4b3ec61Sdh155122 #include <inet/mi.h> 45f4b3ec61Sdh155122 #include <inet/mib2.h> 46f4b3ec61Sdh155122 #include <inet/tcp_stack.h> 47f4b3ec61Sdh155122 #include <inet/tcp_sack.h> 48c28749e9Skais #include <inet/kssl/ksslapi.h> 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate /* 517c478bd9Sstevel@tonic-gate * Private (and possibly temporary) ioctl used by configuration code 527c478bd9Sstevel@tonic-gate * to lock in the "default" stream for detached closes. 537c478bd9Sstevel@tonic-gate */ 547c478bd9Sstevel@tonic-gate #define TCP_IOC_DEFAULT_Q (('T' << 8) + 51) 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate /* TCP states */ 577c478bd9Sstevel@tonic-gate #define TCPS_CLOSED -6 587c478bd9Sstevel@tonic-gate #define TCPS_IDLE -5 /* idle (opened, but not bound) */ 597c478bd9Sstevel@tonic-gate #define TCPS_BOUND -4 /* bound, ready to connect or accept */ 607c478bd9Sstevel@tonic-gate #define TCPS_LISTEN -3 /* listening for connection */ 617c478bd9Sstevel@tonic-gate #define TCPS_SYN_SENT -2 /* active, have sent syn */ 627c478bd9Sstevel@tonic-gate #define TCPS_SYN_RCVD -1 /* have received syn (and sent ours) */ 637c478bd9Sstevel@tonic-gate /* states < TCPS_ESTABLISHED are those where connections not established */ 647c478bd9Sstevel@tonic-gate #define TCPS_ESTABLISHED 0 /* established */ 657c478bd9Sstevel@tonic-gate #define TCPS_CLOSE_WAIT 1 /* rcvd fin, waiting for close */ 667c478bd9Sstevel@tonic-gate /* states > TCPS_CLOSE_WAIT are those where user has closed */ 677c478bd9Sstevel@tonic-gate #define TCPS_FIN_WAIT_1 2 /* have closed and sent fin */ 687c478bd9Sstevel@tonic-gate #define TCPS_CLOSING 3 /* closed, xchd FIN, await FIN ACK */ 697c478bd9Sstevel@tonic-gate #define TCPS_LAST_ACK 4 /* had fin and close; await FIN ACK */ 707c478bd9Sstevel@tonic-gate /* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */ 717c478bd9Sstevel@tonic-gate #define TCPS_FIN_WAIT_2 5 /* have closed, fin is acked */ 727c478bd9Sstevel@tonic-gate #define TCPS_TIME_WAIT 6 /* in 2*msl quiet wait after close */ 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate /* 757c478bd9Sstevel@tonic-gate * Internal flags used in conjunction with the packet header flags. 767c478bd9Sstevel@tonic-gate * Used in tcp_rput_data to keep track of what needs to be done. 777c478bd9Sstevel@tonic-gate */ 787c478bd9Sstevel@tonic-gate #define TH_LIMIT_XMIT 0x0400 /* Limited xmit is needed */ 797c478bd9Sstevel@tonic-gate #define TH_XMIT_NEEDED 0x0800 /* Window opened - send queued data */ 807c478bd9Sstevel@tonic-gate #define TH_REXMIT_NEEDED 0x1000 /* Time expired for unacked data */ 817c478bd9Sstevel@tonic-gate #define TH_ACK_NEEDED 0x2000 /* Send an ack now. */ 827c478bd9Sstevel@tonic-gate #define TH_NEED_SACK_REXMIT 0x4000 /* Use SACK info to retransmission */ 837c478bd9Sstevel@tonic-gate #define TH_ACK_TIMER_NEEDED 0x8000 /* Start the delayed ACK timer */ 847c478bd9Sstevel@tonic-gate #define TH_ORDREL_NEEDED 0x10000 /* Generate an ordrel indication */ 857c478bd9Sstevel@tonic-gate #define TH_MARKNEXT_NEEDED 0x20000 /* Data should have MSGMARKNEXT */ 867c478bd9Sstevel@tonic-gate #define TH_SEND_URP_MARK 0x40000 /* Send up tcp_urp_mark_mp */ 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate /* 897c478bd9Sstevel@tonic-gate * TCP sequence numbers are 32 bit integers operated 907c478bd9Sstevel@tonic-gate * on with modular arithmetic. These macros can be 917c478bd9Sstevel@tonic-gate * used to compare such integers. 927c478bd9Sstevel@tonic-gate */ 937c478bd9Sstevel@tonic-gate #define SEQ_LT(a, b) ((int32_t)((a)-(b)) < 0) 947c478bd9Sstevel@tonic-gate #define SEQ_LEQ(a, b) ((int32_t)((a)-(b)) <= 0) 957c478bd9Sstevel@tonic-gate #define SEQ_GT(a, b) ((int32_t)((a)-(b)) > 0) 967c478bd9Sstevel@tonic-gate #define SEQ_GEQ(a, b) ((int32_t)((a)-(b)) >= 0) 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate /* TCP Protocol header */ 997c478bd9Sstevel@tonic-gate typedef struct tcphdr_s { 1007c478bd9Sstevel@tonic-gate uint8_t th_lport[2]; /* Source port */ 1017c478bd9Sstevel@tonic-gate uint8_t th_fport[2]; /* Destination port */ 1027c478bd9Sstevel@tonic-gate uint8_t th_seq[4]; /* Sequence number */ 1037c478bd9Sstevel@tonic-gate uint8_t th_ack[4]; /* Acknowledgement number */ 1047c478bd9Sstevel@tonic-gate uint8_t th_offset_and_rsrvd[1]; /* Offset to the packet data */ 1057c478bd9Sstevel@tonic-gate uint8_t th_flags[1]; 1067c478bd9Sstevel@tonic-gate uint8_t th_win[2]; /* Allocation number */ 1077c478bd9Sstevel@tonic-gate uint8_t th_sum[2]; /* TCP checksum */ 1087c478bd9Sstevel@tonic-gate uint8_t th_urp[2]; /* Urgent pointer */ 1097c478bd9Sstevel@tonic-gate } tcph_t; 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate #define TCP_HDR_LENGTH(tcph) (((tcph)->th_offset_and_rsrvd[0] >>2) &(0xF << 2)) 1127c478bd9Sstevel@tonic-gate #define TCP_MAX_COMBINED_HEADER_LENGTH (60 + 60) /* Maxed out ip + tcp */ 1137c478bd9Sstevel@tonic-gate #define TCP_MAX_IP_OPTIONS_LENGTH (60 - IP_SIMPLE_HDR_LENGTH) 1147c478bd9Sstevel@tonic-gate #define TCP_MAX_HDR_LENGTH 60 1157c478bd9Sstevel@tonic-gate #define TCP_MAX_TCP_OPTIONS_LENGTH (60 - sizeof (tcph_t)) 1167c478bd9Sstevel@tonic-gate #define TCP_MIN_HEADER_LENGTH 20 1177c478bd9Sstevel@tonic-gate #define TCP_MAXWIN 65535 1187c478bd9Sstevel@tonic-gate #define TCP_PORT_LEN sizeof (in_port_t) 1197c478bd9Sstevel@tonic-gate #define TCP_MAX_WINSHIFT 14 1207c478bd9Sstevel@tonic-gate #define TCP_MAX_LARGEWIN (TCP_MAXWIN << TCP_MAX_WINSHIFT) 1218347601bSyl150051 #define TCP_MAX_LSO_LENGTH (IP_MAXPACKET - TCP_MAX_COMBINED_HEADER_LENGTH) 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate #define TCPIP_HDR_LENGTH(mp, n) \ 1247c478bd9Sstevel@tonic-gate (n) = IPH_HDR_LENGTH((mp)->b_rptr), \ 1257c478bd9Sstevel@tonic-gate (n) += TCP_HDR_LENGTH((tcph_t *)&(mp)->b_rptr[(n)]) 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate /* TCP Protocol header (used if the header is known to be 32-bit aligned) */ 1287c478bd9Sstevel@tonic-gate typedef struct tcphdra_s { 1297c478bd9Sstevel@tonic-gate in_port_t tha_lport; /* Source port */ 1307c478bd9Sstevel@tonic-gate in_port_t tha_fport; /* Destination port */ 1317c478bd9Sstevel@tonic-gate uint32_t tha_seq; /* Sequence number */ 1327c478bd9Sstevel@tonic-gate uint32_t tha_ack; /* Acknowledgement number */ 1337c478bd9Sstevel@tonic-gate uint8_t tha_offset_and_reserved; /* Offset to the packet data */ 1347c478bd9Sstevel@tonic-gate uint8_t tha_flags; 1357c478bd9Sstevel@tonic-gate uint16_t tha_win; /* Allocation number */ 1367c478bd9Sstevel@tonic-gate uint16_t tha_sum; /* TCP checksum */ 1377c478bd9Sstevel@tonic-gate uint16_t tha_urp; /* Urgent pointer */ 1387c478bd9Sstevel@tonic-gate } tcpha_t; 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate struct conn_s; 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate /* 1437c478bd9Sstevel@tonic-gate * Control structure for each open TCP stream, 1447c478bd9Sstevel@tonic-gate * defined only within the kernel or for a kmem user. 1457c478bd9Sstevel@tonic-gate * NOTE: tcp_reinit_values MUST have a line for each field in this structure! 1467c478bd9Sstevel@tonic-gate */ 1477c478bd9Sstevel@tonic-gate #if (defined(_KERNEL) || defined(_KMEMUSER)) 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate typedef struct tcp_s { 1507c478bd9Sstevel@tonic-gate /* Pointer to previous bind hash next. */ 1517c478bd9Sstevel@tonic-gate struct tcp_s *tcp_time_wait_next; 1527c478bd9Sstevel@tonic-gate /* Pointer to next T/W block */ 1537c478bd9Sstevel@tonic-gate struct tcp_s *tcp_time_wait_prev; 1547c478bd9Sstevel@tonic-gate /* Pointer to previous T/W next */ 1557c478bd9Sstevel@tonic-gate clock_t tcp_time_wait_expire; 156f4b3ec61Sdh155122 1577c478bd9Sstevel@tonic-gate struct conn_s *tcp_connp; 158f4b3ec61Sdh155122 tcp_stack_t *tcp_tcps; /* Shortcut via conn_netstack */ 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate int32_t tcp_state; 1617c478bd9Sstevel@tonic-gate int32_t tcp_rcv_ws; /* My window scale power */ 1627c478bd9Sstevel@tonic-gate int32_t tcp_snd_ws; /* Sender's window scale power */ 1637c478bd9Sstevel@tonic-gate uint32_t tcp_ts_recent; /* Timestamp of earliest unacked */ 1647c478bd9Sstevel@tonic-gate /* data segment */ 1657c478bd9Sstevel@tonic-gate clock_t tcp_rto; /* Round trip timeout */ 1667c478bd9Sstevel@tonic-gate clock_t tcp_last_rcv_lbolt; 1677c478bd9Sstevel@tonic-gate /* lbolt on last packet, used for PAWS */ 1687c478bd9Sstevel@tonic-gate 1697c478bd9Sstevel@tonic-gate uint32_t tcp_snxt; /* Senders next seq num */ 1707c478bd9Sstevel@tonic-gate uint32_t tcp_swnd; /* Senders window (relative to suna) */ 1717c478bd9Sstevel@tonic-gate uint32_t tcp_mss; /* Max segment size */ 1727c478bd9Sstevel@tonic-gate uint32_t tcp_iss; /* Initial send seq num */ 1737c478bd9Sstevel@tonic-gate uint32_t tcp_rnxt; /* Seq we expect to recv next */ 1747c478bd9Sstevel@tonic-gate uint32_t tcp_rwnd; 1757c478bd9Sstevel@tonic-gate 1767c478bd9Sstevel@tonic-gate queue_t *tcp_rq; /* Our upstream neighbor (client) */ 1777c478bd9Sstevel@tonic-gate queue_t *tcp_wq; /* Our downstream neighbor */ 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate /* Fields arranged in approximate access order along main paths */ 1807c478bd9Sstevel@tonic-gate mblk_t *tcp_xmit_head; /* Head of rexmit list */ 1817c478bd9Sstevel@tonic-gate mblk_t *tcp_xmit_last; /* last valid data seen by tcp_wput */ 1827c478bd9Sstevel@tonic-gate mblk_t *tcp_xmit_tail; /* Last rexmit data sent */ 1837c478bd9Sstevel@tonic-gate uint32_t tcp_unsent; /* # of bytes in hand that are unsent */ 1847c478bd9Sstevel@tonic-gate uint32_t tcp_xmit_tail_unsent; /* # of unsent bytes in xmit_tail */ 1857c478bd9Sstevel@tonic-gate 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 int32_t tcp_snd_burst; /* Send burst factor */ 1907c478bd9Sstevel@tonic-gate uint32_t tcp_cwnd; /* Congestion window */ 1917c478bd9Sstevel@tonic-gate int32_t tcp_cwnd_cnt; /* cwnd cnt in congestion avoidance */ 1927c478bd9Sstevel@tonic-gate 1937c478bd9Sstevel@tonic-gate uint32_t tcp_ibsegs; /* Inbound segments on this stream */ 1947c478bd9Sstevel@tonic-gate uint32_t tcp_obsegs; /* Outbound segments on this stream */ 1957c478bd9Sstevel@tonic-gate 1967c478bd9Sstevel@tonic-gate uint32_t tcp_naglim; /* Tunable nagle limit */ 1977c478bd9Sstevel@tonic-gate uint32_t tcp_valid_bits; 1987c478bd9Sstevel@tonic-gate #define TCP_ISS_VALID 0x1 /* Is the tcp_iss seq num active? */ 1997c478bd9Sstevel@tonic-gate #define TCP_FSS_VALID 0x2 /* Is the tcp_fss seq num active? */ 2007c478bd9Sstevel@tonic-gate #define TCP_URG_VALID 0x4 /* Is the tcp_urg seq num active? */ 2017c478bd9Sstevel@tonic-gate #define TCP_OFO_FIN_VALID 0x8 /* Has TCP received an out of order FIN? */ 2027c478bd9Sstevel@tonic-gate 2037c478bd9Sstevel@tonic-gate 2047c478bd9Sstevel@tonic-gate 2057c478bd9Sstevel@tonic-gate timeout_id_t tcp_timer_tid; /* Control block for timer service */ 2067c478bd9Sstevel@tonic-gate uchar_t tcp_timer_backoff; /* Backoff shift count. */ 2077c478bd9Sstevel@tonic-gate int64_t tcp_last_recv_time; /* Last time we receive a segment. */ 2087c478bd9Sstevel@tonic-gate uint32_t tcp_init_cwnd; /* Initial cwnd (start/restart) */ 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate /* 2117c478bd9Sstevel@tonic-gate * Following socket options are set by sockfs outside the squeue 2127c478bd9Sstevel@tonic-gate * and we want to separate these bit fields from the other bit fields 2137c478bd9Sstevel@tonic-gate * set by TCP to avoid grabbing locks. sockfs ensures that only one 2147c478bd9Sstevel@tonic-gate * thread in sockfs can set a socket option at a time on a conn_t. 2157c478bd9Sstevel@tonic-gate * However TCP may read these options concurrently. The linger option 2167c478bd9Sstevel@tonic-gate * needs atomicity since tcp_lingertime also needs to be in sync. 2177c478bd9Sstevel@tonic-gate * However TCP uses it only during close, and by then no socket option 2187c478bd9Sstevel@tonic-gate * can come down. So we don't need any locks, instead just separating 2197c478bd9Sstevel@tonic-gate * the sockfs settable bit fields from the other bit fields is 2207c478bd9Sstevel@tonic-gate * sufficient. 2217c478bd9Sstevel@tonic-gate */ 2227c478bd9Sstevel@tonic-gate uint32_t 2237c478bd9Sstevel@tonic-gate tcp_debug : 1, /* SO_DEBUG "socket" option. */ 2247c478bd9Sstevel@tonic-gate tcp_dontroute : 1, /* SO_DONTROUTE "socket" option. */ 2257c478bd9Sstevel@tonic-gate tcp_broadcast : 1, /* SO_BROADCAST "socket" option. */ 2267c478bd9Sstevel@tonic-gate tcp_useloopback : 1, /* SO_USELOOPBACK "socket" option. */ 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate tcp_oobinline : 1, /* SO_OOBINLINE "socket" option. */ 2297c478bd9Sstevel@tonic-gate tcp_dgram_errind : 1, /* SO_DGRAM_ERRIND option */ 2307c478bd9Sstevel@tonic-gate tcp_linger : 1, /* SO_LINGER turned on */ 2317c478bd9Sstevel@tonic-gate tcp_reuseaddr : 1, /* SO_REUSEADDR "socket" option. */ 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate tcp_junk_to_bit_31 : 24; 2347c478bd9Sstevel@tonic-gate 2357c478bd9Sstevel@tonic-gate /* Following manipulated by TCP under squeue protection */ 2367c478bd9Sstevel@tonic-gate uint32_t 2377c478bd9Sstevel@tonic-gate tcp_urp_last_valid : 1, /* Is tcp_urp_last valid? */ 2387c478bd9Sstevel@tonic-gate tcp_hard_binding : 1, /* If we've started a full bind */ 2397c478bd9Sstevel@tonic-gate tcp_hard_bound : 1, /* If we've done a full bind with IP */ 2407c478bd9Sstevel@tonic-gate tcp_fin_acked : 1, /* Has our FIN been acked? */ 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gate tcp_fin_rcvd : 1, /* Have we seen a FIN? */ 2437c478bd9Sstevel@tonic-gate tcp_fin_sent : 1, /* Have we sent our FIN yet? */ 2447c478bd9Sstevel@tonic-gate tcp_ordrel_done : 1, /* Have we sent the ord_rel upstream? */ 2457c478bd9Sstevel@tonic-gate tcp_detached : 1, /* If we're detached from a stream */ 246e0968231Svi117747 2477c478bd9Sstevel@tonic-gate tcp_bind_pending : 1, /* Client is waiting for bind ack */ 2487c478bd9Sstevel@tonic-gate tcp_unbind_pending : 1, /* Client sent T_UNBIND_REQ */ 2497c478bd9Sstevel@tonic-gate tcp_ka_enabled: 1, /* Connection KeepAlive Timer needed */ 2507c478bd9Sstevel@tonic-gate tcp_zero_win_probe: 1, /* Zero win probing is in progress */ 251f7f8e53dSKacheong Poon 2527c478bd9Sstevel@tonic-gate tcp_loopback: 1, /* src and dst are the same machine */ 2537c478bd9Sstevel@tonic-gate tcp_localnet: 1, /* src and dst are on the same subnet */ 2547c478bd9Sstevel@tonic-gate tcp_syn_defense: 1, /* For defense against SYN attack */ 2557c478bd9Sstevel@tonic-gate #define tcp_dontdrop tcp_syn_defense 2567c478bd9Sstevel@tonic-gate tcp_set_timer : 1, 2578380b3ccSYu Xiangning 258f7f8e53dSKacheong Poon tcp_active_open: 1, /* This is a active open */ 259f7f8e53dSKacheong Poon tcp_rexmit : 1, /* TCP is retransmitting */ 2607c478bd9Sstevel@tonic-gate tcp_snd_sack_ok : 1, /* Can use SACK for this connection */ 2617c478bd9Sstevel@tonic-gate tcp_empty_flag : 1, /* Empty flag for future use */ 262f7f8e53dSKacheong Poon 2637c478bd9Sstevel@tonic-gate tcp_recvdstaddr : 1, /* return T_EXTCONN_IND with dst addr */ 2647c478bd9Sstevel@tonic-gate tcp_hwcksum : 1, /* The NIC is capable of hwcksum */ 2657c478bd9Sstevel@tonic-gate tcp_ip_forward_progress : 1, 2667c478bd9Sstevel@tonic-gate tcp_anon_priv_bind : 1, 267f7f8e53dSKacheong Poon 2687c478bd9Sstevel@tonic-gate tcp_ecn_ok : 1, /* Can use ECN for this connection */ 2697c478bd9Sstevel@tonic-gate tcp_ecn_echo_on : 1, /* Need to do ECN echo */ 2707c478bd9Sstevel@tonic-gate tcp_ecn_cwr_sent : 1, /* ECN_CWR has been sent */ 271e0968231Svi117747 tcp_cwr : 1, /* Cwnd has reduced recently */ 272f7f8e53dSKacheong Poon 273f7f8e53dSKacheong Poon tcp_pad_to_bit31 : 4; 2747c478bd9Sstevel@tonic-gate /* Following manipulated by TCP under squeue protection */ 2757c478bd9Sstevel@tonic-gate uint32_t 2767c478bd9Sstevel@tonic-gate tcp_mdt : 1, /* Lower layer is capable of MDT */ 2777c478bd9Sstevel@tonic-gate tcp_snd_ts_ok : 1, 2787c478bd9Sstevel@tonic-gate tcp_snd_ws_ok : 1, 2797c478bd9Sstevel@tonic-gate tcp_exclbind : 1, /* ``exclusive'' binding */ 2807c478bd9Sstevel@tonic-gate 2817c478bd9Sstevel@tonic-gate tcp_hdr_grown : 1, 2827c478bd9Sstevel@tonic-gate tcp_in_free_list : 1, 2837c478bd9Sstevel@tonic-gate tcp_snd_zcopy_on : 1, /* xmit zero-copy enabled */ 2847c478bd9Sstevel@tonic-gate 2857c478bd9Sstevel@tonic-gate tcp_snd_zcopy_aware : 1, /* client is zero-copy aware */ 2867c478bd9Sstevel@tonic-gate tcp_xmit_zc_clean : 1, /* the xmit list is free of zc-mblk */ 2877c478bd9Sstevel@tonic-gate tcp_wait_for_eagers : 1, /* Wait for eagers to disappear */ 2887c478bd9Sstevel@tonic-gate tcp_accept_error : 1, /* Error during TLI accept */ 2897c478bd9Sstevel@tonic-gate 2907c478bd9Sstevel@tonic-gate tcp_send_discon_ind : 1, /* TLI accept err, send discon ind */ 2917c478bd9Sstevel@tonic-gate tcp_cork : 1, /* tcp_cork option */ 292866ba9ddSjprakash tcp_tconnind_started : 1, /* conn_ind message is being sent */ 2938347601bSyl150051 tcp_lso :1, /* Lower layer is capable of LSO */ 294b127ac41SPhilip Kirk tcp_refuse :1, /* Connection needs refusing */ 295b127ac41SPhilip Kirk tcp_pad_to_bit_31 : 16; 2967c478bd9Sstevel@tonic-gate 2977c478bd9Sstevel@tonic-gate uint32_t tcp_if_mtu; /* Outgoing interface MTU. */ 2987c478bd9Sstevel@tonic-gate 2997c478bd9Sstevel@tonic-gate mblk_t *tcp_reass_head; /* Out of order reassembly list head */ 3007c478bd9Sstevel@tonic-gate mblk_t *tcp_reass_tail; /* Out of order reassembly list tail */ 3017c478bd9Sstevel@tonic-gate 3027c478bd9Sstevel@tonic-gate tcp_sack_info_t *tcp_sack_info; 3037c478bd9Sstevel@tonic-gate 3047c478bd9Sstevel@tonic-gate #define tcp_pipe tcp_sack_info->tcp_pipe 3057c478bd9Sstevel@tonic-gate #define tcp_fack tcp_sack_info->tcp_fack 3067c478bd9Sstevel@tonic-gate #define tcp_sack_snxt tcp_sack_info->tcp_sack_snxt 3077c478bd9Sstevel@tonic-gate #define tcp_max_sack_blk tcp_sack_info->tcp_max_sack_blk 3087c478bd9Sstevel@tonic-gate #define tcp_num_sack_blk tcp_sack_info->tcp_num_sack_blk 3097c478bd9Sstevel@tonic-gate #define tcp_sack_list tcp_sack_info->tcp_sack_list 3107c478bd9Sstevel@tonic-gate #define tcp_num_notsack_blk tcp_sack_info->tcp_num_notsack_blk 3117c478bd9Sstevel@tonic-gate #define tcp_cnt_notsack_list tcp_sack_info->tcp_cnt_notsack_list 3127c478bd9Sstevel@tonic-gate #define tcp_notsack_list tcp_sack_info->tcp_notsack_list 3137c478bd9Sstevel@tonic-gate 3147c478bd9Sstevel@tonic-gate mblk_t *tcp_rcv_list; /* Queued until push, urgent data, */ 3157c478bd9Sstevel@tonic-gate mblk_t *tcp_rcv_last_head; /* optdata, or the count exceeds */ 3167c478bd9Sstevel@tonic-gate mblk_t *tcp_rcv_last_tail; /* tcp_rcv_push_wait. */ 3177c478bd9Sstevel@tonic-gate uint32_t tcp_rcv_cnt; /* tcp_rcv_list is b_next chain. */ 3187c478bd9Sstevel@tonic-gate 3197c478bd9Sstevel@tonic-gate uint32_t tcp_cwnd_ssthresh; /* Congestion window */ 3207c478bd9Sstevel@tonic-gate uint32_t tcp_cwnd_max; 3217c478bd9Sstevel@tonic-gate uint32_t tcp_csuna; /* Clear (no rexmits in window) suna */ 3227c478bd9Sstevel@tonic-gate 3237c478bd9Sstevel@tonic-gate clock_t tcp_rtt_sa; /* Round trip smoothed average */ 3247c478bd9Sstevel@tonic-gate clock_t tcp_rtt_sd; /* Round trip smoothed deviation */ 3257c478bd9Sstevel@tonic-gate clock_t tcp_rtt_update; /* Round trip update(s) */ 3267c478bd9Sstevel@tonic-gate clock_t tcp_ms_we_have_waited; /* Total retrans time */ 3277c478bd9Sstevel@tonic-gate 3287c478bd9Sstevel@tonic-gate uint32_t tcp_swl1; /* These help us avoid using stale */ 3297c478bd9Sstevel@tonic-gate uint32_t tcp_swl2; /* packets to update state */ 3307c478bd9Sstevel@tonic-gate 3317c478bd9Sstevel@tonic-gate uint32_t tcp_rack; /* Seq # we have acked */ 3327c478bd9Sstevel@tonic-gate uint32_t tcp_rack_cnt; /* # of segs we have deferred ack */ 3337c478bd9Sstevel@tonic-gate uint32_t tcp_rack_cur_max; /* # of segs we may defer ack for now */ 3347c478bd9Sstevel@tonic-gate uint32_t tcp_rack_abs_max; /* # of segs we may defer ack ever */ 3357c478bd9Sstevel@tonic-gate timeout_id_t tcp_ack_tid; /* Delayed ACK timer ID */ 3367c478bd9Sstevel@tonic-gate timeout_id_t tcp_push_tid; /* Push timer ID */ 3377c478bd9Sstevel@tonic-gate 3387c478bd9Sstevel@tonic-gate uint32_t tcp_max_swnd; /* Maximum swnd we have seen */ 3397c478bd9Sstevel@tonic-gate 3407c478bd9Sstevel@tonic-gate struct tcp_s *tcp_listener; /* Our listener */ 3417c478bd9Sstevel@tonic-gate 3420f1702c5SYu Xiangning size_t tcp_xmit_hiwater; /* Send buffer high water mark. */ 3430f1702c5SYu Xiangning size_t tcp_xmit_lowater; /* Send buffer low water mark. */ 3440f1702c5SYu Xiangning size_t tcp_recv_hiwater; /* Recv high water mark */ 3450f1702c5SYu Xiangning size_t tcp_recv_lowater; /* Recv low water mark */ 3467c478bd9Sstevel@tonic-gate 3477c478bd9Sstevel@tonic-gate uint32_t tcp_irs; /* Initial recv seq num */ 3487c478bd9Sstevel@tonic-gate uint32_t tcp_fss; /* Final/fin send seq num */ 3497c478bd9Sstevel@tonic-gate uint32_t tcp_urg; /* Urgent data seq num */ 3507c478bd9Sstevel@tonic-gate 3517c478bd9Sstevel@tonic-gate clock_t tcp_first_timer_threshold; /* When to prod IP */ 3527c478bd9Sstevel@tonic-gate clock_t tcp_second_timer_threshold; /* When to give up completely */ 3537c478bd9Sstevel@tonic-gate clock_t tcp_first_ctimer_threshold; /* 1st threshold while connecting */ 3547c478bd9Sstevel@tonic-gate clock_t tcp_second_ctimer_threshold; /* 2nd ... while connecting */ 3557c478bd9Sstevel@tonic-gate 3567c478bd9Sstevel@tonic-gate int tcp_lingertime; /* Close linger time (in seconds) */ 3577c478bd9Sstevel@tonic-gate 3587c478bd9Sstevel@tonic-gate uint32_t tcp_urp_last; /* Last urp for which signal sent */ 3597c478bd9Sstevel@tonic-gate mblk_t *tcp_urp_mp; /* T_EXDATA_IND for urgent byte */ 3607c478bd9Sstevel@tonic-gate mblk_t *tcp_urp_mark_mp; /* zero-length marked/unmarked msg */ 3617c478bd9Sstevel@tonic-gate 3627c478bd9Sstevel@tonic-gate int tcp_conn_req_cnt_q0; /* # of conn reqs in SYN_RCVD */ 3637c478bd9Sstevel@tonic-gate int tcp_conn_req_cnt_q; /* # of conn reqs in ESTABLISHED */ 3647c478bd9Sstevel@tonic-gate int tcp_conn_req_max; /* # of ESTABLISHED conn reqs allowed */ 3657c478bd9Sstevel@tonic-gate t_scalar_t tcp_conn_req_seqnum; /* Incrementing pending conn req ID */ 3667c478bd9Sstevel@tonic-gate #define tcp_ip_addr_cache tcp_reass_tail 3677c478bd9Sstevel@tonic-gate /* Cache ip addresses that */ 3687c478bd9Sstevel@tonic-gate /* complete the 3-way handshake */ 3697c478bd9Sstevel@tonic-gate kmutex_t tcp_eager_lock; 3707c478bd9Sstevel@tonic-gate struct tcp_s *tcp_eager_next_q; /* next eager in ESTABLISHED state */ 3717c478bd9Sstevel@tonic-gate struct tcp_s *tcp_eager_last_q; /* last eager in ESTABLISHED state */ 3727c478bd9Sstevel@tonic-gate struct tcp_s *tcp_eager_next_q0; /* next eager in SYN_RCVD state */ 3737c478bd9Sstevel@tonic-gate struct tcp_s *tcp_eager_prev_q0; /* prev eager in SYN_RCVD state */ 3747c478bd9Sstevel@tonic-gate /* all eagers form a circular list */ 3758380b3ccSYu Xiangning boolean_t tcp_conn_def_q0; /* move from q0 to q deferred */ 3768380b3ccSYu Xiangning 3777c478bd9Sstevel@tonic-gate union { 3787c478bd9Sstevel@tonic-gate mblk_t *tcp_eager_conn_ind; /* T_CONN_IND waiting for 3rd ack. */ 3797c478bd9Sstevel@tonic-gate mblk_t *tcp_opts_conn_req; /* T_CONN_REQ w/ options processed */ 3807c478bd9Sstevel@tonic-gate } tcp_conn; 3817c478bd9Sstevel@tonic-gate uint32_t tcp_syn_rcvd_timeout; /* How many SYN_RCVD timeout in q0 */ 3827c478bd9Sstevel@tonic-gate 3837c478bd9Sstevel@tonic-gate /* TCP Keepalive Timer members */ 3847c478bd9Sstevel@tonic-gate int32_t tcp_ka_last_intrvl; /* Last probe interval */ 3857c478bd9Sstevel@tonic-gate timeout_id_t tcp_ka_tid; /* Keepalive timer ID */ 3867c478bd9Sstevel@tonic-gate uint32_t tcp_ka_interval; /* Keepalive interval */ 3877c478bd9Sstevel@tonic-gate uint32_t tcp_ka_abort_thres; /* Keepalive abort threshold */ 3887c478bd9Sstevel@tonic-gate 3897c478bd9Sstevel@tonic-gate int32_t tcp_client_errno; /* How the client screwed up */ 3907c478bd9Sstevel@tonic-gate 3917c478bd9Sstevel@tonic-gate char *tcp_iphc; /* Buffer holding tcp/ip hdr template */ 3927c478bd9Sstevel@tonic-gate int tcp_iphc_len; /* actual allocated buffer size */ 3937c478bd9Sstevel@tonic-gate int32_t tcp_hdr_len; /* Byte len of combined TCP/IP hdr */ 3947c478bd9Sstevel@tonic-gate ipha_t *tcp_ipha; /* IPv4 header in the buffer */ 3957c478bd9Sstevel@tonic-gate ip6_t *tcp_ip6h; /* IPv6 header in the buffer */ 3967c478bd9Sstevel@tonic-gate int tcp_ip_hdr_len; /* Byte len of our current IPvx hdr */ 3977c478bd9Sstevel@tonic-gate tcph_t *tcp_tcph; /* tcp header within combined hdr */ 3987c478bd9Sstevel@tonic-gate int32_t tcp_tcp_hdr_len; /* tcp header len within combined */ 399b127ac41SPhilip Kirk /* Saved peer headers in the case of re-fusion */ 400b127ac41SPhilip Kirk ipha_t tcp_saved_ipha; 401b127ac41SPhilip Kirk ip6_t tcp_saved_ip6h; 402b127ac41SPhilip Kirk tcph_t tcp_saved_tcph; 4037c478bd9Sstevel@tonic-gate 4047c478bd9Sstevel@tonic-gate uint32_t tcp_sum; /* checksum to compensate for source */ 4057c478bd9Sstevel@tonic-gate /* routed packets. Host byte order */ 4067c478bd9Sstevel@tonic-gate uint16_t tcp_last_sent_len; /* Record length for nagle */ 4077c478bd9Sstevel@tonic-gate uint16_t tcp_dupack_cnt; /* # of consequtive duplicate acks */ 4087c478bd9Sstevel@tonic-gate 4097c478bd9Sstevel@tonic-gate kmutex_t *tcp_acceptor_lockp; /* Ptr to tf_lock */ 4107c478bd9Sstevel@tonic-gate 411f7f8e53dSKacheong Poon mblk_t *tcp_ordrel_mp; /* T_ordrel_ind mblk */ 4127c478bd9Sstevel@tonic-gate t_uscalar_t tcp_acceptor_id; /* ACCEPTOR_id */ 4137c478bd9Sstevel@tonic-gate 4147c478bd9Sstevel@tonic-gate int tcp_ipsec_overhead; 4157c478bd9Sstevel@tonic-gate /* 4167c478bd9Sstevel@tonic-gate * Address family that app wishes returned addrsses to be in. 4177c478bd9Sstevel@tonic-gate * Currently taken from address family used in T_BIND_REQ, but 4187c478bd9Sstevel@tonic-gate * should really come from family used in original socket() call. 4197c478bd9Sstevel@tonic-gate * Value can be AF_INET or AF_INET6. 4207c478bd9Sstevel@tonic-gate */ 4217c478bd9Sstevel@tonic-gate uint_t tcp_family; 4227c478bd9Sstevel@tonic-gate /* 4237c478bd9Sstevel@tonic-gate * used for a quick test to determine if any ancillary bits are 4247c478bd9Sstevel@tonic-gate * set 4257c478bd9Sstevel@tonic-gate */ 4267c478bd9Sstevel@tonic-gate uint_t tcp_ipv6_recvancillary; /* Flags */ 4277c478bd9Sstevel@tonic-gate #define TCP_IPV6_RECVPKTINFO 0x01 /* IPV6_RECVPKTINFO option */ 4287c478bd9Sstevel@tonic-gate #define TCP_IPV6_RECVHOPLIMIT 0x02 /* IPV6_RECVHOPLIMIT option */ 4297c478bd9Sstevel@tonic-gate #define TCP_IPV6_RECVHOPOPTS 0x04 /* IPV6_RECVHOPOPTS option */ 4307c478bd9Sstevel@tonic-gate #define TCP_IPV6_RECVDSTOPTS 0x08 /* IPV6_RECVDSTOPTS option */ 4317c478bd9Sstevel@tonic-gate #define TCP_IPV6_RECVRTHDR 0x10 /* IPV6_RECVRTHDR option */ 4327c478bd9Sstevel@tonic-gate #define TCP_IPV6_RECVRTDSTOPTS 0x20 /* IPV6_RECVRTHDRDSTOPTS option */ 4337c478bd9Sstevel@tonic-gate #define TCP_IPV6_RECVTCLASS 0x40 /* IPV6_RECVTCLASS option */ 4347c478bd9Sstevel@tonic-gate #define TCP_OLD_IPV6_RECVDSTOPTS 0x80 /* old IPV6_RECVDSTOPTS option */ 4357c478bd9Sstevel@tonic-gate 4367c478bd9Sstevel@tonic-gate uint_t tcp_recvifindex; /* Last received IPV6_RCVPKTINFO */ 4377c478bd9Sstevel@tonic-gate uint_t tcp_recvhops; /* Last received IPV6_RECVHOPLIMIT */ 4387c478bd9Sstevel@tonic-gate uint_t tcp_recvtclass; /* Last received IPV6_RECVTCLASS */ 4397c478bd9Sstevel@tonic-gate ip6_hbh_t *tcp_hopopts; /* Last received IPV6_RECVHOPOPTS */ 4407c478bd9Sstevel@tonic-gate ip6_dest_t *tcp_dstopts; /* Last received IPV6_RECVDSTOPTS */ 4417c478bd9Sstevel@tonic-gate ip6_dest_t *tcp_rtdstopts; /* Last recvd IPV6_RECVRTHDRDSTOPTS */ 4427c478bd9Sstevel@tonic-gate ip6_rthdr_t *tcp_rthdr; /* Last received IPV6_RECVRTHDR */ 4437c478bd9Sstevel@tonic-gate uint_t tcp_hopoptslen; 4447c478bd9Sstevel@tonic-gate uint_t tcp_dstoptslen; 4457c478bd9Sstevel@tonic-gate uint_t tcp_rtdstoptslen; 4467c478bd9Sstevel@tonic-gate uint_t tcp_rthdrlen; 4477c478bd9Sstevel@tonic-gate 4487c478bd9Sstevel@tonic-gate mblk_t *tcp_timercache; 4497c478bd9Sstevel@tonic-gate cred_t *tcp_cred; /* Credentials when this was opened */ 4507c478bd9Sstevel@tonic-gate pid_t tcp_cpid; /* Process id when this was opened */ 4513173664eSapersson uint64_t tcp_open_time; /* time when this was opened */ 4527c478bd9Sstevel@tonic-gate 4537c478bd9Sstevel@tonic-gate 4547c478bd9Sstevel@tonic-gate union { 4557c478bd9Sstevel@tonic-gate struct { 4567c478bd9Sstevel@tonic-gate uchar_t v4_ttl; 4577c478bd9Sstevel@tonic-gate /* Dup of tcp_ipha.iph_type_of_service */ 4587c478bd9Sstevel@tonic-gate uchar_t v4_tos; /* Dup of tcp_ipha.iph_ttl */ 4597c478bd9Sstevel@tonic-gate } v4_hdr_info; 4607c478bd9Sstevel@tonic-gate struct { 4617c478bd9Sstevel@tonic-gate uint_t v6_vcf; /* Dup of tcp_ip6h.ip6h_vcf */ 4627c478bd9Sstevel@tonic-gate uchar_t v6_hops; /* Dup of tcp_ip6h.ip6h_hops */ 4637c478bd9Sstevel@tonic-gate } v6_hdr_info; 4647c478bd9Sstevel@tonic-gate } tcp_hdr_info; 4657c478bd9Sstevel@tonic-gate #define tcp_ttl tcp_hdr_info.v4_hdr_info.v4_ttl 4667c478bd9Sstevel@tonic-gate #define tcp_tos tcp_hdr_info.v4_hdr_info.v4_tos 4677c478bd9Sstevel@tonic-gate #define tcp_ip6_vcf tcp_hdr_info.v6_hdr_info.v6_vcf 4687c478bd9Sstevel@tonic-gate #define tcp_ip6_hops tcp_hdr_info.v6_hdr_info.v6_hops 4697c478bd9Sstevel@tonic-gate 4707c478bd9Sstevel@tonic-gate ushort_t tcp_ipversion; 4717c478bd9Sstevel@tonic-gate uint_t tcp_bound_if; /* IPV6_BOUND_IF */ 4727c478bd9Sstevel@tonic-gate 4737c478bd9Sstevel@tonic-gate #define tcp_lport tcp_connp->conn_lport 4747c478bd9Sstevel@tonic-gate #define tcp_fport tcp_connp->conn_fport 4757c478bd9Sstevel@tonic-gate #define tcp_ports tcp_connp->conn_ports 4767c478bd9Sstevel@tonic-gate 4777c478bd9Sstevel@tonic-gate #define tcp_remote tcp_connp->conn_rem 4787c478bd9Sstevel@tonic-gate #define tcp_ip_src tcp_connp->conn_src 4797c478bd9Sstevel@tonic-gate 4807c478bd9Sstevel@tonic-gate #define tcp_remote_v6 tcp_connp->conn_remv6 4817c478bd9Sstevel@tonic-gate #define tcp_ip_src_v6 tcp_connp->conn_srcv6 4827c478bd9Sstevel@tonic-gate #define tcp_bound_source_v6 tcp_connp->conn_bound_source_v6 4837c478bd9Sstevel@tonic-gate #define tcp_bound_source tcp_connp->conn_bound_source 4847c478bd9Sstevel@tonic-gate 4857c478bd9Sstevel@tonic-gate kmutex_t tcp_closelock; 4867c478bd9Sstevel@tonic-gate kcondvar_t tcp_closecv; 4877c478bd9Sstevel@tonic-gate uint8_t tcp_closed; 4887c478bd9Sstevel@tonic-gate uint8_t tcp_closeflags; 4897c478bd9Sstevel@tonic-gate uint8_t tcp_cleandeathtag; 4907c478bd9Sstevel@tonic-gate mblk_t tcp_closemp; 4917c478bd9Sstevel@tonic-gate timeout_id_t tcp_linger_tid; /* Linger timer ID */ 4927c478bd9Sstevel@tonic-gate 4937c478bd9Sstevel@tonic-gate struct tcp_s *tcp_acceptor_hash; /* Acceptor hash chain */ 4947c478bd9Sstevel@tonic-gate struct tcp_s **tcp_ptpahn; /* Pointer to previous accept hash next. */ 4957c478bd9Sstevel@tonic-gate struct tcp_s *tcp_bind_hash; /* Bind hash chain */ 4960f1702c5SYu Xiangning struct tcp_s *tcp_bind_hash_port; /* tcp_t's bound to the same lport */ 4977c478bd9Sstevel@tonic-gate struct tcp_s **tcp_ptpbhn; 4987c478bd9Sstevel@tonic-gate 4997c478bd9Sstevel@tonic-gate boolean_t tcp_ire_ill_check_done; 5007c478bd9Sstevel@tonic-gate uint_t tcp_maxpsz; 5017c478bd9Sstevel@tonic-gate 5027c478bd9Sstevel@tonic-gate /* 5037c478bd9Sstevel@tonic-gate * used for Multidata Transmit 5047c478bd9Sstevel@tonic-gate */ 5057c478bd9Sstevel@tonic-gate uint_t tcp_mdt_hdr_head; /* leading header fragment extra space */ 5067c478bd9Sstevel@tonic-gate uint_t tcp_mdt_hdr_tail; /* trailing header fragment extra space */ 5077c478bd9Sstevel@tonic-gate int tcp_mdt_max_pld; /* maximum payload buffers per Multidata */ 5087c478bd9Sstevel@tonic-gate 5098347601bSyl150051 uint32_t tcp_lso_max; /* maximum LSO payload */ 5108347601bSyl150051 5117c478bd9Sstevel@tonic-gate uint32_t tcp_ofo_fin_seq; /* Recv out of order FIN seq num */ 5127c478bd9Sstevel@tonic-gate uint32_t tcp_cwr_snd_max; 5137c478bd9Sstevel@tonic-gate uint_t tcp_drop_opt_ack_cnt; /* # tcp generated optmgmt */ 5147c478bd9Sstevel@tonic-gate ip6_pkt_t tcp_sticky_ipp; /* Sticky options */ 5157c478bd9Sstevel@tonic-gate #define tcp_ipp_fields tcp_sticky_ipp.ipp_fields /* valid fields */ 5167c478bd9Sstevel@tonic-gate #define tcp_ipp_ifindex tcp_sticky_ipp.ipp_ifindex /* pktinfo ifindex */ 5177c478bd9Sstevel@tonic-gate #define tcp_ipp_addr tcp_sticky_ipp.ipp_addr /* pktinfo src/dst addr */ 5187c478bd9Sstevel@tonic-gate #define tcp_ipp_hoplimit tcp_sticky_ipp.ipp_hoplimit 5197c478bd9Sstevel@tonic-gate #define tcp_ipp_hopoptslen tcp_sticky_ipp.ipp_hopoptslen 5207c478bd9Sstevel@tonic-gate #define tcp_ipp_rtdstoptslen tcp_sticky_ipp.ipp_rtdstoptslen 5217c478bd9Sstevel@tonic-gate #define tcp_ipp_rthdrlen tcp_sticky_ipp.ipp_rthdrlen 5227c478bd9Sstevel@tonic-gate #define tcp_ipp_dstoptslen tcp_sticky_ipp.ipp_dstoptslen 5237c478bd9Sstevel@tonic-gate #define tcp_ipp_hopopts tcp_sticky_ipp.ipp_hopopts 5247c478bd9Sstevel@tonic-gate #define tcp_ipp_rtdstopts tcp_sticky_ipp.ipp_rtdstopts 5257c478bd9Sstevel@tonic-gate #define tcp_ipp_rthdr tcp_sticky_ipp.ipp_rthdr 5267c478bd9Sstevel@tonic-gate #define tcp_ipp_dstopts tcp_sticky_ipp.ipp_dstopts 5277c478bd9Sstevel@tonic-gate #define tcp_ipp_nexthop tcp_sticky_ipp.ipp_nexthop 5287c478bd9Sstevel@tonic-gate #define tcp_ipp_use_min_mtu tcp_sticky_ipp.ipp_use_min_mtu 5297c478bd9Sstevel@tonic-gate struct tcp_s *tcp_saved_listener; /* saved value of listener */ 5307c478bd9Sstevel@tonic-gate 531ff550d0eSmasputra uint32_t tcp_in_ack_unsent; /* ACK for unsent data cnt. */ 532ff550d0eSmasputra 533ff550d0eSmasputra /* 534ff550d0eSmasputra * The following fusion-related fields are protected by squeue. 535ff550d0eSmasputra */ 5367c478bd9Sstevel@tonic-gate struct tcp_s *tcp_loopback_peer; /* peer tcp for loopback */ 5377c478bd9Sstevel@tonic-gate mblk_t *tcp_fused_sigurg_mp; /* M_PCSIG mblk for SIGURG */ 538ff550d0eSmasputra size_t tcp_fuse_rcv_hiwater; /* fusion receive queue size */ 539ff550d0eSmasputra uint_t tcp_fuse_rcv_unread_hiwater; /* max # of outstanding pkts */ 540ff550d0eSmasputra /* 541ff550d0eSmasputra * The following fusion-related fields and bit fields are to be 542e0968231Svi117747 * manipulated with squeue protection or with tcp_non_sq_lock held. 543e0968231Svi117747 * tcp_non_sq_lock is used to protect fields that may be modified 544e0968231Svi117747 * accessed outside the squeue. 545ff550d0eSmasputra */ 546e0968231Svi117747 kmutex_t tcp_non_sq_lock; 547a2036d4dSmeem kcondvar_t tcp_fuse_plugcv; 548ff550d0eSmasputra uint_t tcp_fuse_rcv_unread_cnt; /* # of outstanding pkts */ 549ff550d0eSmasputra uint32_t 550ff550d0eSmasputra tcp_fused : 1, /* loopback tcp in fusion mode */ 551ff550d0eSmasputra tcp_unfusable : 1, /* fusion not allowed on endpoint */ 552ff550d0eSmasputra tcp_fused_sigurg : 1, /* send SIGURG upon draining */ 553ff550d0eSmasputra tcp_direct_sockfs : 1, /* direct calls to sockfs */ 5547c478bd9Sstevel@tonic-gate 555ff550d0eSmasputra tcp_fuse_syncstr_stopped : 1, /* synchronous streams stopped */ 556a2036d4dSmeem tcp_fuse_syncstr_plugged : 1, /* synchronous streams plugged */ 557a2036d4dSmeem tcp_fuse_to_bit_31 : 26; 5587c478bd9Sstevel@tonic-gate 5597c478bd9Sstevel@tonic-gate /* 5607c478bd9Sstevel@tonic-gate * This variable is accessed without any lock protection 5617c478bd9Sstevel@tonic-gate * and therefore must not be declared as a bit field along 5627c478bd9Sstevel@tonic-gate * with the rest which require such condition. 5637c478bd9Sstevel@tonic-gate */ 5647c478bd9Sstevel@tonic-gate boolean_t tcp_issocket; /* this is a socket tcp */ 565ff550d0eSmasputra 566e0968231Svi117747 /* protected by the tcp_non_sq_lock lock */ 567ff550d0eSmasputra uint32_t tcp_squeue_bytes; 568c28749e9Skais /* 569c28749e9Skais * Kernel SSL session information 570c28749e9Skais */ 571c28749e9Skais boolean_t tcp_kssl_pending; /* waiting for 1st SSL rec. */ 572c28749e9Skais boolean_t tcp_kssl_inhandshake; /* during SSL handshake */ 573c28749e9Skais kssl_ent_t tcp_kssl_ent; /* SSL table entry */ 574c28749e9Skais kssl_ctx_t tcp_kssl_ctx; /* SSL session */ 57545916cd2Sjpk uint_t tcp_label_len; /* length of cached label */ 576866ba9ddSjprakash 577866ba9ddSjprakash /* 578866ba9ddSjprakash * tcp_closemp_used is protected by listener's tcp_eager_lock 579866ba9ddSjprakash * when used for eagers. When used for a tcp in TIME_WAIT state 580866ba9ddSjprakash * or in tcp_close(), it is not protected by any lock as we 581866ba9ddSjprakash * do not expect any other thread to use it concurrently. 5820163a147Sjprakash * We do allow re-use of tcp_closemp in tcp_time_wait_collector() 5830163a147Sjprakash * and tcp_close() but not concurrently. 584866ba9ddSjprakash */ 5850163a147Sjprakash boolean_t tcp_closemp_used; 586866ba9ddSjprakash 587866ba9ddSjprakash /* 588866ba9ddSjprakash * previous and next eagers in the list of droppable eagers. See 589866ba9ddSjprakash * the comments before MAKE_DROPPABLE(). These pointers are 590866ba9ddSjprakash * protected by listener's tcp_eager_lock. 591866ba9ddSjprakash */ 592866ba9ddSjprakash struct tcp_s *tcp_eager_prev_drop_q0; 593866ba9ddSjprakash struct tcp_s *tcp_eager_next_drop_q0; 594e0968231Svi117747 595e0968231Svi117747 /* 596e0968231Svi117747 * Have we flow controlled xmitter? 597e0968231Svi117747 * This variable can be modified outside the squeue and hence must 598e0968231Svi117747 * not be declared as a bit field along with the rest that are 599e0968231Svi117747 * modified only within the squeue. 600e0968231Svi117747 * protected by the tcp_non_sq_lock lock. 601e0968231Svi117747 */ 602e0968231Svi117747 boolean_t tcp_flow_stopped; 603e0968231Svi117747 60417169044Sbrutus /* 6050f1702c5SYu Xiangning * The socket generation number is bumped when an outgoing connection 6060f1702c5SYu Xiangning * attempts is made, and it sent up to the socket when the 6070f1702c5SYu Xiangning * connection was successfully established, or an error occured. The 6080f1702c5SYu Xiangning * generation is used to ensure that the socket does not miss the 6090f1702c5SYu Xiangning * asynchronous notification. 6100f1702c5SYu Xiangning */ 6110f1702c5SYu Xiangning sock_connid_t tcp_connid; 6120f1702c5SYu Xiangning 613f7f8e53dSKacheong Poon /* mblk_t used to enter TCP's squeue from the service routine. */ 614f7f8e53dSKacheong Poon mblk_t *tcp_rsrv_mp; 615f7f8e53dSKacheong Poon /* Mutex for accessing tcp_rsrv_mp */ 616f7f8e53dSKacheong Poon kmutex_t tcp_rsrv_mp_lock; 617f7f8e53dSKacheong Poon 618866ba9ddSjprakash #ifdef DEBUG 619866ba9ddSjprakash pc_t tcmp_stk[15]; 620866ba9ddSjprakash #endif 6217c478bd9Sstevel@tonic-gate } tcp_t; 6227c478bd9Sstevel@tonic-gate 623866ba9ddSjprakash #ifdef DEBUG 624866ba9ddSjprakash #define TCP_DEBUG_GETPCSTACK(buffer, depth) ((void) getpcstack(buffer, \ 625866ba9ddSjprakash depth)) 626866ba9ddSjprakash #else 627866ba9ddSjprakash #define TCP_DEBUG_GETPCSTACK(buffer, depth) 628866ba9ddSjprakash #endif 629866ba9ddSjprakash 630f4b3ec61Sdh155122 /* 631f4b3ec61Sdh155122 * Track a reference count on the tcps in order to know when 632f4b3ec61Sdh155122 * the tcps_g_q can be removed. As long as there is any 633f4b3ec61Sdh155122 * tcp_t, other that the tcps_g_q itself, in the tcp_stack_t we 634f4b3ec61Sdh155122 * need to keep tcps_g_q around so that a closing connection can 635f4b3ec61Sdh155122 * switch to using tcps_g_q as part of it closing. 636f4b3ec61Sdh155122 */ 637f4b3ec61Sdh155122 #define TCPS_REFHOLD(tcps) { \ 638f4b3ec61Sdh155122 atomic_add_32(&(tcps)->tcps_refcnt, 1); \ 639f4b3ec61Sdh155122 ASSERT((tcps)->tcps_refcnt != 0); \ 640f4b3ec61Sdh155122 DTRACE_PROBE1(tcps__refhold, tcp_stack_t, tcps); \ 641f4b3ec61Sdh155122 } 642f4b3ec61Sdh155122 643f4b3ec61Sdh155122 /* 644f4b3ec61Sdh155122 * Decrement the reference count on the tcp_stack_t. 645f4b3ec61Sdh155122 * In architectures e.g sun4u, where atomic_add_32_nv is just 646f4b3ec61Sdh155122 * a cas, we need to maintain the right memory barrier semantics 647f4b3ec61Sdh155122 * as that of mutex_exit i.e all the loads and stores should complete 648f4b3ec61Sdh155122 * before the cas is executed. membar_exit() does that here. 649f4b3ec61Sdh155122 */ 650f4b3ec61Sdh155122 #define TCPS_REFRELE(tcps) { \ 651f4b3ec61Sdh155122 ASSERT((tcps)->tcps_refcnt != 0); \ 652f4b3ec61Sdh155122 membar_exit(); \ 653f4b3ec61Sdh155122 DTRACE_PROBE1(tcps__refrele, tcp_stack_t, tcps); \ 654f4b3ec61Sdh155122 if (atomic_add_32_nv(&(tcps)->tcps_refcnt, -1) == 0 && \ 655f4b3ec61Sdh155122 (tcps)->tcps_g_q != NULL) { \ 656f4b3ec61Sdh155122 /* Only tcps_g_q left */ \ 657f4b3ec61Sdh155122 tcp_g_q_inactive(tcps); \ 658f4b3ec61Sdh155122 } \ 659f4b3ec61Sdh155122 } 660f4b3ec61Sdh155122 6617c478bd9Sstevel@tonic-gate extern void tcp_free(tcp_t *tcp); 662f4b3ec61Sdh155122 extern void tcp_ddi_g_init(void); 663f4b3ec61Sdh155122 extern void tcp_ddi_g_destroy(void); 664f4b3ec61Sdh155122 extern void tcp_g_q_inactive(tcp_stack_t *); 6655597b60aSnordmark extern void tcp_xmit_listeners_reset(mblk_t *mp, uint_t ip_hdr_len, 6665c267e8aSrs200217 zoneid_t zoneid, tcp_stack_t *, conn_t *connp); 6677c478bd9Sstevel@tonic-gate extern void tcp_conn_request(void *arg, mblk_t *mp, void *arg2); 6687c478bd9Sstevel@tonic-gate extern void tcp_conn_request_unbound(void *arg, mblk_t *mp, void *arg2); 6697c478bd9Sstevel@tonic-gate extern void tcp_input(void *arg, mblk_t *mp, void *arg2); 6707c478bd9Sstevel@tonic-gate extern void tcp_rput_data(void *arg, mblk_t *mp, void *arg2); 671*f3124163SAnders Persson extern void *tcp_get_conn(void *arg, tcp_stack_t *); 6727c478bd9Sstevel@tonic-gate extern void tcp_time_wait_collector(void *arg); 673fc80c0dfSnordmark extern mblk_t *tcp_snmp_get(queue_t *, mblk_t *); 674ff550d0eSmasputra extern int tcp_snmp_set(queue_t *, int, int, uchar_t *, int len); 675381a2a9aSdr146992 extern mblk_t *tcp_xmit_mp(tcp_t *tcp, mblk_t *mp, int32_t max_to_send, 676381a2a9aSdr146992 int32_t *offset, mblk_t **end_mp, uint32_t seq, 677381a2a9aSdr146992 boolean_t sendall, uint32_t *seg_len, boolean_t rexmit); 6780854dd28SPhilip Kirk extern void tcp_xmit_reset(void *arg, mblk_t *mp, void *arg2); 6790854dd28SPhilip Kirk 6807c478bd9Sstevel@tonic-gate /* 6817c478bd9Sstevel@tonic-gate * The TCP Fanout structure. 6827c478bd9Sstevel@tonic-gate * The hash tables and their linkage (tcp_*_hash_next, tcp_ptp*hn) are 6837c478bd9Sstevel@tonic-gate * protected by the per-bucket tf_lock. Each tcp_t 6847c478bd9Sstevel@tonic-gate * inserted in the list points back at this lock using tcp_*_lockp. 6857c478bd9Sstevel@tonic-gate * 6867c478bd9Sstevel@tonic-gate * The listener and acceptor hash queues are lists of tcp_t. 6877c478bd9Sstevel@tonic-gate */ 6887c478bd9Sstevel@tonic-gate /* listener hash and acceptor hash queue head */ 6897c478bd9Sstevel@tonic-gate typedef struct tf_s { 6907c478bd9Sstevel@tonic-gate tcp_t *tf_tcp; 6917c478bd9Sstevel@tonic-gate kmutex_t tf_lock; 6927c478bd9Sstevel@tonic-gate } tf_t; 6937c478bd9Sstevel@tonic-gate #endif /* (defined(_KERNEL) || defined(_KMEMUSER)) */ 6947c478bd9Sstevel@tonic-gate 6957c478bd9Sstevel@tonic-gate /* Contract private interface between TCP and Clustering. */ 6967c478bd9Sstevel@tonic-gate 6977c478bd9Sstevel@tonic-gate #define CL_TCPI_V1 1 /* cl_tcpi_version number */ 6987c478bd9Sstevel@tonic-gate 6997c478bd9Sstevel@tonic-gate typedef struct cl_tcp_info_s { 7007c478bd9Sstevel@tonic-gate ushort_t cl_tcpi_version; /* cl_tcp_info_t's version no */ 7017c478bd9Sstevel@tonic-gate ushort_t cl_tcpi_ipversion; /* IP version */ 7027c478bd9Sstevel@tonic-gate int32_t cl_tcpi_state; /* TCP state */ 7037c478bd9Sstevel@tonic-gate in_port_t cl_tcpi_lport; /* Local port */ 7047c478bd9Sstevel@tonic-gate in_port_t cl_tcpi_fport; /* Remote port */ 7057c478bd9Sstevel@tonic-gate in6_addr_t cl_tcpi_laddr_v6; /* Local IP address */ 7067c478bd9Sstevel@tonic-gate in6_addr_t cl_tcpi_faddr_v6; /* Remote IP address */ 7077c478bd9Sstevel@tonic-gate #ifdef _KERNEL 7087c478bd9Sstevel@tonic-gate /* Note: V4_PART_OF_V6 is meant to be used only for _KERNEL defined stuff */ 7097c478bd9Sstevel@tonic-gate #define cl_tcpi_laddr V4_PART_OF_V6(cl_tcpi_laddr_v6) 7107c478bd9Sstevel@tonic-gate #define cl_tcpi_faddr V4_PART_OF_V6(cl_tcpi_faddr_v6) 7117c478bd9Sstevel@tonic-gate 7127c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 7137c478bd9Sstevel@tonic-gate } cl_tcp_info_t; 7147c478bd9Sstevel@tonic-gate 7157c478bd9Sstevel@tonic-gate /* 7167c478bd9Sstevel@tonic-gate * Contracted Consolidation Private ioctl for aborting TCP connections. 7177c478bd9Sstevel@tonic-gate * In order to keep the offsets and size of the structure the same between 7187c478bd9Sstevel@tonic-gate * a 32-bit application and a 64-bit amd64 kernel, we use a #pragma 7197c478bd9Sstevel@tonic-gate * pack(4). 7207c478bd9Sstevel@tonic-gate */ 7217c478bd9Sstevel@tonic-gate #define TCP_IOC_ABORT_CONN (('T' << 8) + 91) 7227c478bd9Sstevel@tonic-gate 7237c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 7247c478bd9Sstevel@tonic-gate #pragma pack(4) 7257c478bd9Sstevel@tonic-gate #endif 7267c478bd9Sstevel@tonic-gate 7277c478bd9Sstevel@tonic-gate typedef struct tcp_ioc_abort_conn_s { 7287c478bd9Sstevel@tonic-gate struct sockaddr_storage ac_local; /* local addr and port */ 7297c478bd9Sstevel@tonic-gate struct sockaddr_storage ac_remote; /* remote addr and port */ 7307c478bd9Sstevel@tonic-gate int32_t ac_start; /* start state */ 7317c478bd9Sstevel@tonic-gate int32_t ac_end; /* end state */ 7327c478bd9Sstevel@tonic-gate int32_t ac_zoneid; /* zoneid */ 7337c478bd9Sstevel@tonic-gate } tcp_ioc_abort_conn_t; 7347c478bd9Sstevel@tonic-gate 7357c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 7367c478bd9Sstevel@tonic-gate #pragma pack() 7377c478bd9Sstevel@tonic-gate #endif 7387c478bd9Sstevel@tonic-gate 7397c478bd9Sstevel@tonic-gate #if (defined(_KERNEL) || defined(_KMEMUSER)) 7407c478bd9Sstevel@tonic-gate extern void tcp_rput_other(tcp_t *tcp, mblk_t *mp); 7417c478bd9Sstevel@tonic-gate #endif 7427c478bd9Sstevel@tonic-gate 7430854dd28SPhilip Kirk #if (defined(_KERNEL)) 7440854dd28SPhilip Kirk #define TCP_XRE_EVENT_IP_FANOUT_TCP 1 7450854dd28SPhilip Kirk 7460854dd28SPhilip Kirk /* 7470854dd28SPhilip Kirk * This is a private structure used to pass data to an squeue function during 7480854dd28SPhilip Kirk * tcp's listener reset sending path. 7490854dd28SPhilip Kirk */ 7500854dd28SPhilip Kirk typedef struct tcp_xmit_reset_event { 7510854dd28SPhilip Kirk int tcp_xre_event; 7520854dd28SPhilip Kirk int tcp_xre_iphdrlen; 7530854dd28SPhilip Kirk zoneid_t tcp_xre_zoneid; 7540854dd28SPhilip Kirk tcp_stack_t *tcp_xre_tcps; 7550854dd28SPhilip Kirk } tcp_xmit_reset_event_t; 7560854dd28SPhilip Kirk #endif 7570854dd28SPhilip Kirk 7587c478bd9Sstevel@tonic-gate #ifdef __cplusplus 7597c478bd9Sstevel@tonic-gate } 7607c478bd9Sstevel@tonic-gate #endif 7617c478bd9Sstevel@tonic-gate 7627c478bd9Sstevel@tonic-gate #endif /* _INET_TCP_H */ 763