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