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 5*45916cd2Sjpk * Common Development and Distribution License (the "License"). 6*45916cd2Sjpk * 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 /* 22*45916cd2Sjpk * Copyright 2006 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 <inet/tcp_sack.h> 407c478bd9Sstevel@tonic-gate #include <sys/socket.h> 417c478bd9Sstevel@tonic-gate #include <sys/multidata.h> 42c28749e9Skais #include <inet/kssl/ksslapi.h> 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate /* 457c478bd9Sstevel@tonic-gate * Private (and possibly temporary) ioctl used by configuration code 467c478bd9Sstevel@tonic-gate * to lock in the "default" stream for detached closes. 477c478bd9Sstevel@tonic-gate */ 487c478bd9Sstevel@tonic-gate #define TCP_IOC_DEFAULT_Q (('T' << 8) + 51) 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate /* TCP states */ 517c478bd9Sstevel@tonic-gate #define TCPS_CLOSED -6 527c478bd9Sstevel@tonic-gate #define TCPS_IDLE -5 /* idle (opened, but not bound) */ 537c478bd9Sstevel@tonic-gate #define TCPS_BOUND -4 /* bound, ready to connect or accept */ 547c478bd9Sstevel@tonic-gate #define TCPS_LISTEN -3 /* listening for connection */ 557c478bd9Sstevel@tonic-gate #define TCPS_SYN_SENT -2 /* active, have sent syn */ 567c478bd9Sstevel@tonic-gate #define TCPS_SYN_RCVD -1 /* have received syn (and sent ours) */ 577c478bd9Sstevel@tonic-gate /* states < TCPS_ESTABLISHED are those where connections not established */ 587c478bd9Sstevel@tonic-gate #define TCPS_ESTABLISHED 0 /* established */ 597c478bd9Sstevel@tonic-gate #define TCPS_CLOSE_WAIT 1 /* rcvd fin, waiting for close */ 607c478bd9Sstevel@tonic-gate /* states > TCPS_CLOSE_WAIT are those where user has closed */ 617c478bd9Sstevel@tonic-gate #define TCPS_FIN_WAIT_1 2 /* have closed and sent fin */ 627c478bd9Sstevel@tonic-gate #define TCPS_CLOSING 3 /* closed, xchd FIN, await FIN ACK */ 637c478bd9Sstevel@tonic-gate #define TCPS_LAST_ACK 4 /* had fin and close; await FIN ACK */ 647c478bd9Sstevel@tonic-gate /* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */ 657c478bd9Sstevel@tonic-gate #define TCPS_FIN_WAIT_2 5 /* have closed, fin is acked */ 667c478bd9Sstevel@tonic-gate #define TCPS_TIME_WAIT 6 /* in 2*msl quiet wait after close */ 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* 697c478bd9Sstevel@tonic-gate * Internal flags used in conjunction with the packet header flags. 707c478bd9Sstevel@tonic-gate * Used in tcp_rput_data to keep track of what needs to be done. 717c478bd9Sstevel@tonic-gate */ 727c478bd9Sstevel@tonic-gate #define TH_LIMIT_XMIT 0x0400 /* Limited xmit is needed */ 737c478bd9Sstevel@tonic-gate #define TH_XMIT_NEEDED 0x0800 /* Window opened - send queued data */ 747c478bd9Sstevel@tonic-gate #define TH_REXMIT_NEEDED 0x1000 /* Time expired for unacked data */ 757c478bd9Sstevel@tonic-gate #define TH_ACK_NEEDED 0x2000 /* Send an ack now. */ 767c478bd9Sstevel@tonic-gate #define TH_NEED_SACK_REXMIT 0x4000 /* Use SACK info to retransmission */ 777c478bd9Sstevel@tonic-gate #define TH_ACK_TIMER_NEEDED 0x8000 /* Start the delayed ACK timer */ 787c478bd9Sstevel@tonic-gate #define TH_ORDREL_NEEDED 0x10000 /* Generate an ordrel indication */ 797c478bd9Sstevel@tonic-gate #define TH_MARKNEXT_NEEDED 0x20000 /* Data should have MSGMARKNEXT */ 807c478bd9Sstevel@tonic-gate #define TH_SEND_URP_MARK 0x40000 /* Send up tcp_urp_mark_mp */ 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate /* 837c478bd9Sstevel@tonic-gate * TCP sequence numbers are 32 bit integers operated 847c478bd9Sstevel@tonic-gate * on with modular arithmetic. These macros can be 857c478bd9Sstevel@tonic-gate * used to compare such integers. 867c478bd9Sstevel@tonic-gate */ 877c478bd9Sstevel@tonic-gate #define SEQ_LT(a, b) ((int32_t)((a)-(b)) < 0) 887c478bd9Sstevel@tonic-gate #define SEQ_LEQ(a, b) ((int32_t)((a)-(b)) <= 0) 897c478bd9Sstevel@tonic-gate #define SEQ_GT(a, b) ((int32_t)((a)-(b)) > 0) 907c478bd9Sstevel@tonic-gate #define SEQ_GEQ(a, b) ((int32_t)((a)-(b)) >= 0) 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate /* TCP Protocol header */ 937c478bd9Sstevel@tonic-gate typedef struct tcphdr_s { 947c478bd9Sstevel@tonic-gate uint8_t th_lport[2]; /* Source port */ 957c478bd9Sstevel@tonic-gate uint8_t th_fport[2]; /* Destination port */ 967c478bd9Sstevel@tonic-gate uint8_t th_seq[4]; /* Sequence number */ 977c478bd9Sstevel@tonic-gate uint8_t th_ack[4]; /* Acknowledgement number */ 987c478bd9Sstevel@tonic-gate uint8_t th_offset_and_rsrvd[1]; /* Offset to the packet data */ 997c478bd9Sstevel@tonic-gate uint8_t th_flags[1]; 1007c478bd9Sstevel@tonic-gate uint8_t th_win[2]; /* Allocation number */ 1017c478bd9Sstevel@tonic-gate uint8_t th_sum[2]; /* TCP checksum */ 1027c478bd9Sstevel@tonic-gate uint8_t th_urp[2]; /* Urgent pointer */ 1037c478bd9Sstevel@tonic-gate } tcph_t; 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate #define TCP_HDR_LENGTH(tcph) (((tcph)->th_offset_and_rsrvd[0] >>2) &(0xF << 2)) 1067c478bd9Sstevel@tonic-gate #define TCP_MAX_COMBINED_HEADER_LENGTH (60 + 60) /* Maxed out ip + tcp */ 1077c478bd9Sstevel@tonic-gate #define TCP_MAX_IP_OPTIONS_LENGTH (60 - IP_SIMPLE_HDR_LENGTH) 1087c478bd9Sstevel@tonic-gate #define TCP_MAX_HDR_LENGTH 60 1097c478bd9Sstevel@tonic-gate #define TCP_MAX_TCP_OPTIONS_LENGTH (60 - sizeof (tcph_t)) 1107c478bd9Sstevel@tonic-gate #define TCP_MIN_HEADER_LENGTH 20 1117c478bd9Sstevel@tonic-gate #define TCP_MAXWIN 65535 1127c478bd9Sstevel@tonic-gate #define TCP_PORT_LEN sizeof (in_port_t) 1137c478bd9Sstevel@tonic-gate #define TCP_MAX_WINSHIFT 14 1147c478bd9Sstevel@tonic-gate #define TCP_MAX_LARGEWIN (TCP_MAXWIN << TCP_MAX_WINSHIFT) 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate #define TCPIP_HDR_LENGTH(mp, n) \ 1177c478bd9Sstevel@tonic-gate (n) = IPH_HDR_LENGTH((mp)->b_rptr), \ 1187c478bd9Sstevel@tonic-gate (n) += TCP_HDR_LENGTH((tcph_t *)&(mp)->b_rptr[(n)]) 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate /* TCP Protocol header (used if the header is known to be 32-bit aligned) */ 1217c478bd9Sstevel@tonic-gate typedef struct tcphdra_s { 1227c478bd9Sstevel@tonic-gate in_port_t tha_lport; /* Source port */ 1237c478bd9Sstevel@tonic-gate in_port_t tha_fport; /* Destination port */ 1247c478bd9Sstevel@tonic-gate uint32_t tha_seq; /* Sequence number */ 1257c478bd9Sstevel@tonic-gate uint32_t tha_ack; /* Acknowledgement number */ 1267c478bd9Sstevel@tonic-gate uint8_t tha_offset_and_reserved; /* Offset to the packet data */ 1277c478bd9Sstevel@tonic-gate uint8_t tha_flags; 1287c478bd9Sstevel@tonic-gate uint16_t tha_win; /* Allocation number */ 1297c478bd9Sstevel@tonic-gate uint16_t tha_sum; /* TCP checksum */ 1307c478bd9Sstevel@tonic-gate uint16_t tha_urp; /* Urgent pointer */ 1317c478bd9Sstevel@tonic-gate } tcpha_t; 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate struct conn_s; 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate /* 1367c478bd9Sstevel@tonic-gate * Control structure for each open TCP stream, 1377c478bd9Sstevel@tonic-gate * defined only within the kernel or for a kmem user. 1387c478bd9Sstevel@tonic-gate * NOTE: tcp_reinit_values MUST have a line for each field in this structure! 1397c478bd9Sstevel@tonic-gate */ 1407c478bd9Sstevel@tonic-gate #if (defined(_KERNEL) || defined(_KMEMUSER)) 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate typedef struct tcp_s { 1437c478bd9Sstevel@tonic-gate /* Pointer to previous bind hash next. */ 1447c478bd9Sstevel@tonic-gate struct tcp_s *tcp_time_wait_next; 1457c478bd9Sstevel@tonic-gate /* Pointer to next T/W block */ 1467c478bd9Sstevel@tonic-gate struct tcp_s *tcp_time_wait_prev; 1477c478bd9Sstevel@tonic-gate /* Pointer to previous T/W next */ 1487c478bd9Sstevel@tonic-gate clock_t tcp_time_wait_expire; 1497c478bd9Sstevel@tonic-gate struct conn_s *tcp_connp; 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate int32_t tcp_state; 1527c478bd9Sstevel@tonic-gate int32_t tcp_rcv_ws; /* My window scale power */ 1537c478bd9Sstevel@tonic-gate int32_t tcp_snd_ws; /* Sender's window scale power */ 1547c478bd9Sstevel@tonic-gate uint32_t tcp_ts_recent; /* Timestamp of earliest unacked */ 1557c478bd9Sstevel@tonic-gate /* data segment */ 1567c478bd9Sstevel@tonic-gate clock_t tcp_rto; /* Round trip timeout */ 1577c478bd9Sstevel@tonic-gate clock_t tcp_last_rcv_lbolt; 1587c478bd9Sstevel@tonic-gate /* lbolt on last packet, used for PAWS */ 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate uint32_t tcp_snxt; /* Senders next seq num */ 1617c478bd9Sstevel@tonic-gate uint32_t tcp_swnd; /* Senders window (relative to suna) */ 1627c478bd9Sstevel@tonic-gate uint32_t tcp_mss; /* Max segment size */ 1637c478bd9Sstevel@tonic-gate uint32_t tcp_iss; /* Initial send seq num */ 1647c478bd9Sstevel@tonic-gate uint32_t tcp_rnxt; /* Seq we expect to recv next */ 1657c478bd9Sstevel@tonic-gate uint32_t tcp_rwnd; 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate queue_t *tcp_rq; /* Our upstream neighbor (client) */ 1687c478bd9Sstevel@tonic-gate queue_t *tcp_wq; /* Our downstream neighbor */ 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate /* Fields arranged in approximate access order along main paths */ 1717c478bd9Sstevel@tonic-gate mblk_t *tcp_xmit_head; /* Head of rexmit list */ 1727c478bd9Sstevel@tonic-gate mblk_t *tcp_xmit_last; /* last valid data seen by tcp_wput */ 1737c478bd9Sstevel@tonic-gate mblk_t *tcp_xmit_tail; /* Last rexmit data sent */ 1747c478bd9Sstevel@tonic-gate uint32_t tcp_unsent; /* # of bytes in hand that are unsent */ 1757c478bd9Sstevel@tonic-gate uint32_t tcp_xmit_tail_unsent; /* # of unsent bytes in xmit_tail */ 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate uint32_t tcp_suna; /* Sender unacknowledged */ 1787c478bd9Sstevel@tonic-gate uint32_t tcp_rexmit_nxt; /* Next rexmit seq num */ 1797c478bd9Sstevel@tonic-gate uint32_t tcp_rexmit_max; /* Max retran seq num */ 1807c478bd9Sstevel@tonic-gate int32_t tcp_snd_burst; /* Send burst factor */ 1817c478bd9Sstevel@tonic-gate uint32_t tcp_cwnd; /* Congestion window */ 1827c478bd9Sstevel@tonic-gate int32_t tcp_cwnd_cnt; /* cwnd cnt in congestion avoidance */ 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate uint32_t tcp_ibsegs; /* Inbound segments on this stream */ 1857c478bd9Sstevel@tonic-gate uint32_t tcp_obsegs; /* Outbound segments on this stream */ 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate uint32_t tcp_naglim; /* Tunable nagle limit */ 1887c478bd9Sstevel@tonic-gate uint32_t tcp_valid_bits; 1897c478bd9Sstevel@tonic-gate #define TCP_ISS_VALID 0x1 /* Is the tcp_iss seq num active? */ 1907c478bd9Sstevel@tonic-gate #define TCP_FSS_VALID 0x2 /* Is the tcp_fss seq num active? */ 1917c478bd9Sstevel@tonic-gate #define TCP_URG_VALID 0x4 /* Is the tcp_urg seq num active? */ 1927c478bd9Sstevel@tonic-gate #define TCP_OFO_FIN_VALID 0x8 /* Has TCP received an out of order FIN? */ 1937c478bd9Sstevel@tonic-gate 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate int32_t tcp_xmit_hiwater; /* Send buffer high water mark. */ 1967c478bd9Sstevel@tonic-gate 1977c478bd9Sstevel@tonic-gate timeout_id_t tcp_timer_tid; /* Control block for timer service */ 1987c478bd9Sstevel@tonic-gate uchar_t tcp_timer_backoff; /* Backoff shift count. */ 1997c478bd9Sstevel@tonic-gate int64_t tcp_last_recv_time; /* Last time we receive a segment. */ 2007c478bd9Sstevel@tonic-gate uint32_t tcp_init_cwnd; /* Initial cwnd (start/restart) */ 2017c478bd9Sstevel@tonic-gate 2027c478bd9Sstevel@tonic-gate /* 2037c478bd9Sstevel@tonic-gate * Following socket options are set by sockfs outside the squeue 2047c478bd9Sstevel@tonic-gate * and we want to separate these bit fields from the other bit fields 2057c478bd9Sstevel@tonic-gate * set by TCP to avoid grabbing locks. sockfs ensures that only one 2067c478bd9Sstevel@tonic-gate * thread in sockfs can set a socket option at a time on a conn_t. 2077c478bd9Sstevel@tonic-gate * However TCP may read these options concurrently. The linger option 2087c478bd9Sstevel@tonic-gate * needs atomicity since tcp_lingertime also needs to be in sync. 2097c478bd9Sstevel@tonic-gate * However TCP uses it only during close, and by then no socket option 2107c478bd9Sstevel@tonic-gate * can come down. So we don't need any locks, instead just separating 2117c478bd9Sstevel@tonic-gate * the sockfs settable bit fields from the other bit fields is 2127c478bd9Sstevel@tonic-gate * sufficient. 2137c478bd9Sstevel@tonic-gate */ 2147c478bd9Sstevel@tonic-gate uint32_t 2157c478bd9Sstevel@tonic-gate tcp_debug : 1, /* SO_DEBUG "socket" option. */ 2167c478bd9Sstevel@tonic-gate tcp_dontroute : 1, /* SO_DONTROUTE "socket" option. */ 2177c478bd9Sstevel@tonic-gate tcp_broadcast : 1, /* SO_BROADCAST "socket" option. */ 2187c478bd9Sstevel@tonic-gate tcp_useloopback : 1, /* SO_USELOOPBACK "socket" option. */ 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate tcp_oobinline : 1, /* SO_OOBINLINE "socket" option. */ 2217c478bd9Sstevel@tonic-gate tcp_dgram_errind : 1, /* SO_DGRAM_ERRIND option */ 2227c478bd9Sstevel@tonic-gate tcp_linger : 1, /* SO_LINGER turned on */ 2237c478bd9Sstevel@tonic-gate tcp_reuseaddr : 1, /* SO_REUSEADDR "socket" option. */ 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate tcp_junk_to_bit_31 : 24; 2267c478bd9Sstevel@tonic-gate 2277c478bd9Sstevel@tonic-gate /* Following manipulated by TCP under squeue protection */ 2287c478bd9Sstevel@tonic-gate uint32_t 2297c478bd9Sstevel@tonic-gate tcp_urp_last_valid : 1, /* Is tcp_urp_last valid? */ 2307c478bd9Sstevel@tonic-gate tcp_hard_binding : 1, /* If we've started a full bind */ 2317c478bd9Sstevel@tonic-gate tcp_hard_bound : 1, /* If we've done a full bind with IP */ 2327c478bd9Sstevel@tonic-gate tcp_fin_acked : 1, /* Has our FIN been acked? */ 2337c478bd9Sstevel@tonic-gate 2347c478bd9Sstevel@tonic-gate tcp_fin_rcvd : 1, /* Have we seen a FIN? */ 2357c478bd9Sstevel@tonic-gate tcp_fin_sent : 1, /* Have we sent our FIN yet? */ 2367c478bd9Sstevel@tonic-gate tcp_ordrel_done : 1, /* Have we sent the ord_rel upstream? */ 2377c478bd9Sstevel@tonic-gate tcp_flow_stopped : 1, /* Have we flow controlled xmitter? */ 2387c478bd9Sstevel@tonic-gate 2397c478bd9Sstevel@tonic-gate tcp_detached : 1, /* If we're detached from a stream */ 2407c478bd9Sstevel@tonic-gate tcp_bind_pending : 1, /* Client is waiting for bind ack */ 2417c478bd9Sstevel@tonic-gate tcp_unbind_pending : 1, /* Client sent T_UNBIND_REQ */ 2427c478bd9Sstevel@tonic-gate tcp_deferred_clean_death : 1, 2437c478bd9Sstevel@tonic-gate /* defer tcp endpoint cleanup etc. */ 2447c478bd9Sstevel@tonic-gate 2457c478bd9Sstevel@tonic-gate tcp_conn_def_q0: 1, /* move from q0 to q deferred */ 2467c478bd9Sstevel@tonic-gate tcp_ka_enabled: 1, /* Connection KeepAlive Timer needed */ 2477c478bd9Sstevel@tonic-gate tcp_zero_win_probe: 1, /* Zero win probing is in progress */ 2487c478bd9Sstevel@tonic-gate tcp_loopback: 1, /* src and dst are the same machine */ 2497c478bd9Sstevel@tonic-gate 2507c478bd9Sstevel@tonic-gate tcp_localnet: 1, /* src and dst are on the same subnet */ 2517c478bd9Sstevel@tonic-gate tcp_syn_defense: 1, /* For defense against SYN attack */ 2527c478bd9Sstevel@tonic-gate #define tcp_dontdrop tcp_syn_defense 2537c478bd9Sstevel@tonic-gate tcp_set_timer : 1, 2547c478bd9Sstevel@tonic-gate tcp_active_open: 1, /* This is a active open */ 2557c478bd9Sstevel@tonic-gate 2567c478bd9Sstevel@tonic-gate tcp_timeout : 1, /* qbufcall failed, qtimeout pending */ 2577c478bd9Sstevel@tonic-gate tcp_rexmit : 1, /* TCP is retransmitting */ 2587c478bd9Sstevel@tonic-gate tcp_snd_sack_ok : 1, /* Can use SACK for this connection */ 2597c478bd9Sstevel@tonic-gate tcp_empty_flag : 1, /* Empty flag for future use */ 2607c478bd9Sstevel@tonic-gate 2617c478bd9Sstevel@tonic-gate tcp_recvdstaddr : 1, /* return T_EXTCONN_IND with dst addr */ 2627c478bd9Sstevel@tonic-gate tcp_hwcksum : 1, /* The NIC is capable of hwcksum */ 2637c478bd9Sstevel@tonic-gate tcp_ip_forward_progress : 1, 2647c478bd9Sstevel@tonic-gate tcp_anon_priv_bind : 1, 2657c478bd9Sstevel@tonic-gate 2667c478bd9Sstevel@tonic-gate tcp_ecn_ok : 1, /* Can use ECN for this connection */ 2677c478bd9Sstevel@tonic-gate tcp_ecn_echo_on : 1, /* Need to do ECN echo */ 2687c478bd9Sstevel@tonic-gate tcp_ecn_cwr_sent : 1, /* ECN_CWR has been sent */ 2697c478bd9Sstevel@tonic-gate tcp_cwr : 1; /* Cwnd has reduced recently */ 2707c478bd9Sstevel@tonic-gate 2717c478bd9Sstevel@tonic-gate /* Following manipulated by TCP under squeue protection */ 2727c478bd9Sstevel@tonic-gate uint32_t 2737c478bd9Sstevel@tonic-gate tcp_mdt : 1, /* Lower layer is capable of MDT */ 2747c478bd9Sstevel@tonic-gate tcp_snd_ts_ok : 1, 2757c478bd9Sstevel@tonic-gate tcp_snd_ws_ok : 1, 2767c478bd9Sstevel@tonic-gate tcp_exclbind : 1, /* ``exclusive'' binding */ 2777c478bd9Sstevel@tonic-gate 2787c478bd9Sstevel@tonic-gate tcp_reserved_port : 1, 2797c478bd9Sstevel@tonic-gate tcp_hdr_grown : 1, 2807c478bd9Sstevel@tonic-gate tcp_in_free_list : 1, 2817c478bd9Sstevel@tonic-gate tcp_snd_zcopy_on : 1, /* xmit zero-copy enabled */ 2827c478bd9Sstevel@tonic-gate 2837c478bd9Sstevel@tonic-gate tcp_snd_zcopy_aware : 1, /* client is zero-copy aware */ 2847c478bd9Sstevel@tonic-gate tcp_xmit_zc_clean : 1, /* the xmit list is free of zc-mblk */ 2857c478bd9Sstevel@tonic-gate tcp_wait_for_eagers : 1, /* Wait for eagers to disappear */ 2867c478bd9Sstevel@tonic-gate tcp_accept_error : 1, /* Error during TLI accept */ 2877c478bd9Sstevel@tonic-gate 2887c478bd9Sstevel@tonic-gate tcp_send_discon_ind : 1, /* TLI accept err, send discon ind */ 2897c478bd9Sstevel@tonic-gate tcp_cork : 1, /* tcp_cork option */ 290ff550d0eSmasputra tcp_pad_to_bit_31 : 18; 2917c478bd9Sstevel@tonic-gate 2927c478bd9Sstevel@tonic-gate uint32_t tcp_if_mtu; /* Outgoing interface MTU. */ 2937c478bd9Sstevel@tonic-gate 2947c478bd9Sstevel@tonic-gate mblk_t *tcp_reass_head; /* Out of order reassembly list head */ 2957c478bd9Sstevel@tonic-gate mblk_t *tcp_reass_tail; /* Out of order reassembly list tail */ 2967c478bd9Sstevel@tonic-gate 2977c478bd9Sstevel@tonic-gate tcp_sack_info_t *tcp_sack_info; 2987c478bd9Sstevel@tonic-gate 2997c478bd9Sstevel@tonic-gate #define tcp_pipe tcp_sack_info->tcp_pipe 3007c478bd9Sstevel@tonic-gate #define tcp_fack tcp_sack_info->tcp_fack 3017c478bd9Sstevel@tonic-gate #define tcp_sack_snxt tcp_sack_info->tcp_sack_snxt 3027c478bd9Sstevel@tonic-gate #define tcp_max_sack_blk tcp_sack_info->tcp_max_sack_blk 3037c478bd9Sstevel@tonic-gate #define tcp_num_sack_blk tcp_sack_info->tcp_num_sack_blk 3047c478bd9Sstevel@tonic-gate #define tcp_sack_list tcp_sack_info->tcp_sack_list 3057c478bd9Sstevel@tonic-gate #define tcp_num_notsack_blk tcp_sack_info->tcp_num_notsack_blk 3067c478bd9Sstevel@tonic-gate #define tcp_cnt_notsack_list tcp_sack_info->tcp_cnt_notsack_list 3077c478bd9Sstevel@tonic-gate #define tcp_notsack_list tcp_sack_info->tcp_notsack_list 3087c478bd9Sstevel@tonic-gate 3097c478bd9Sstevel@tonic-gate mblk_t *tcp_rcv_list; /* Queued until push, urgent data, */ 3107c478bd9Sstevel@tonic-gate mblk_t *tcp_rcv_last_head; /* optdata, or the count exceeds */ 3117c478bd9Sstevel@tonic-gate mblk_t *tcp_rcv_last_tail; /* tcp_rcv_push_wait. */ 3127c478bd9Sstevel@tonic-gate uint32_t tcp_rcv_cnt; /* tcp_rcv_list is b_next chain. */ 3137c478bd9Sstevel@tonic-gate 3147c478bd9Sstevel@tonic-gate uint32_t tcp_cwnd_ssthresh; /* Congestion window */ 3157c478bd9Sstevel@tonic-gate uint32_t tcp_cwnd_max; 3167c478bd9Sstevel@tonic-gate uint32_t tcp_csuna; /* Clear (no rexmits in window) suna */ 3177c478bd9Sstevel@tonic-gate 3187c478bd9Sstevel@tonic-gate clock_t tcp_rtt_sa; /* Round trip smoothed average */ 3197c478bd9Sstevel@tonic-gate clock_t tcp_rtt_sd; /* Round trip smoothed deviation */ 3207c478bd9Sstevel@tonic-gate clock_t tcp_rtt_update; /* Round trip update(s) */ 3217c478bd9Sstevel@tonic-gate clock_t tcp_ms_we_have_waited; /* Total retrans time */ 3227c478bd9Sstevel@tonic-gate 3237c478bd9Sstevel@tonic-gate uint32_t tcp_swl1; /* These help us avoid using stale */ 3247c478bd9Sstevel@tonic-gate uint32_t tcp_swl2; /* packets to update state */ 3257c478bd9Sstevel@tonic-gate 3267c478bd9Sstevel@tonic-gate uint32_t tcp_rack; /* Seq # we have acked */ 3277c478bd9Sstevel@tonic-gate uint32_t tcp_rack_cnt; /* # of segs we have deferred ack */ 3287c478bd9Sstevel@tonic-gate uint32_t tcp_rack_cur_max; /* # of segs we may defer ack for now */ 3297c478bd9Sstevel@tonic-gate uint32_t tcp_rack_abs_max; /* # of segs we may defer ack ever */ 3307c478bd9Sstevel@tonic-gate timeout_id_t tcp_ack_tid; /* Delayed ACK timer ID */ 3317c478bd9Sstevel@tonic-gate timeout_id_t tcp_push_tid; /* Push timer ID */ 3327c478bd9Sstevel@tonic-gate 3337c478bd9Sstevel@tonic-gate uint32_t tcp_max_swnd; /* Maximum swnd we have seen */ 3347c478bd9Sstevel@tonic-gate 3357c478bd9Sstevel@tonic-gate struct tcp_s *tcp_listener; /* Our listener */ 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate int32_t tcp_xmit_lowater; /* Send buffer low water mark. */ 3387c478bd9Sstevel@tonic-gate 3397c478bd9Sstevel@tonic-gate uint32_t tcp_irs; /* Initial recv seq num */ 3407c478bd9Sstevel@tonic-gate uint32_t tcp_fss; /* Final/fin send seq num */ 3417c478bd9Sstevel@tonic-gate uint32_t tcp_urg; /* Urgent data seq num */ 3427c478bd9Sstevel@tonic-gate 3437c478bd9Sstevel@tonic-gate clock_t tcp_first_timer_threshold; /* When to prod IP */ 3447c478bd9Sstevel@tonic-gate clock_t tcp_second_timer_threshold; /* When to give up completely */ 3457c478bd9Sstevel@tonic-gate clock_t tcp_first_ctimer_threshold; /* 1st threshold while connecting */ 3467c478bd9Sstevel@tonic-gate clock_t tcp_second_ctimer_threshold; /* 2nd ... while connecting */ 3477c478bd9Sstevel@tonic-gate 3487c478bd9Sstevel@tonic-gate int tcp_lingertime; /* Close linger time (in seconds) */ 3497c478bd9Sstevel@tonic-gate 3507c478bd9Sstevel@tonic-gate uint32_t tcp_urp_last; /* Last urp for which signal sent */ 3517c478bd9Sstevel@tonic-gate mblk_t *tcp_urp_mp; /* T_EXDATA_IND for urgent byte */ 3527c478bd9Sstevel@tonic-gate mblk_t *tcp_urp_mark_mp; /* zero-length marked/unmarked msg */ 3537c478bd9Sstevel@tonic-gate 3547c478bd9Sstevel@tonic-gate int tcp_conn_req_cnt_q0; /* # of conn reqs in SYN_RCVD */ 3557c478bd9Sstevel@tonic-gate int tcp_conn_req_cnt_q; /* # of conn reqs in ESTABLISHED */ 3567c478bd9Sstevel@tonic-gate int tcp_conn_req_max; /* # of ESTABLISHED conn reqs allowed */ 3577c478bd9Sstevel@tonic-gate t_scalar_t tcp_conn_req_seqnum; /* Incrementing pending conn req ID */ 3587c478bd9Sstevel@tonic-gate #define tcp_ip_addr_cache tcp_reass_tail 3597c478bd9Sstevel@tonic-gate /* Cache ip addresses that */ 3607c478bd9Sstevel@tonic-gate /* complete the 3-way handshake */ 3617c478bd9Sstevel@tonic-gate kmutex_t tcp_eager_lock; 3627c478bd9Sstevel@tonic-gate struct tcp_s *tcp_eager_next_q; /* next eager in ESTABLISHED state */ 3637c478bd9Sstevel@tonic-gate struct tcp_s *tcp_eager_last_q; /* last eager in ESTABLISHED state */ 3647c478bd9Sstevel@tonic-gate struct tcp_s *tcp_eager_next_q0; /* next eager in SYN_RCVD state */ 3657c478bd9Sstevel@tonic-gate struct tcp_s *tcp_eager_prev_q0; /* prev eager in SYN_RCVD state */ 3667c478bd9Sstevel@tonic-gate /* all eagers form a circular list */ 3677c478bd9Sstevel@tonic-gate union { 3687c478bd9Sstevel@tonic-gate mblk_t *tcp_eager_conn_ind; /* T_CONN_IND waiting for 3rd ack. */ 3697c478bd9Sstevel@tonic-gate mblk_t *tcp_opts_conn_req; /* T_CONN_REQ w/ options processed */ 3707c478bd9Sstevel@tonic-gate } tcp_conn; 3717c478bd9Sstevel@tonic-gate uint32_t tcp_syn_rcvd_timeout; /* How many SYN_RCVD timeout in q0 */ 3727c478bd9Sstevel@tonic-gate 3737c478bd9Sstevel@tonic-gate /* TCP Keepalive Timer members */ 3747c478bd9Sstevel@tonic-gate int32_t tcp_ka_last_intrvl; /* Last probe interval */ 3757c478bd9Sstevel@tonic-gate timeout_id_t tcp_ka_tid; /* Keepalive timer ID */ 3767c478bd9Sstevel@tonic-gate uint32_t tcp_ka_interval; /* Keepalive interval */ 3777c478bd9Sstevel@tonic-gate uint32_t tcp_ka_abort_thres; /* Keepalive abort threshold */ 3787c478bd9Sstevel@tonic-gate 3797c478bd9Sstevel@tonic-gate int32_t tcp_client_errno; /* How the client screwed up */ 3807c478bd9Sstevel@tonic-gate 3817c478bd9Sstevel@tonic-gate char *tcp_iphc; /* Buffer holding tcp/ip hdr template */ 3827c478bd9Sstevel@tonic-gate int tcp_iphc_len; /* actual allocated buffer size */ 3837c478bd9Sstevel@tonic-gate int32_t tcp_hdr_len; /* Byte len of combined TCP/IP hdr */ 3847c478bd9Sstevel@tonic-gate ipha_t *tcp_ipha; /* IPv4 header in the buffer */ 3857c478bd9Sstevel@tonic-gate ip6_t *tcp_ip6h; /* IPv6 header in the buffer */ 3867c478bd9Sstevel@tonic-gate int tcp_ip_hdr_len; /* Byte len of our current IPvx hdr */ 3877c478bd9Sstevel@tonic-gate tcph_t *tcp_tcph; /* tcp header within combined hdr */ 3887c478bd9Sstevel@tonic-gate int32_t tcp_tcp_hdr_len; /* tcp header len within combined */ 3897c478bd9Sstevel@tonic-gate 3907c478bd9Sstevel@tonic-gate uint32_t tcp_sum; /* checksum to compensate for source */ 3917c478bd9Sstevel@tonic-gate /* routed packets. Host byte order */ 3927c478bd9Sstevel@tonic-gate uint16_t tcp_last_sent_len; /* Record length for nagle */ 3937c478bd9Sstevel@tonic-gate uint16_t tcp_dupack_cnt; /* # of consequtive duplicate acks */ 3947c478bd9Sstevel@tonic-gate 3957c478bd9Sstevel@tonic-gate kmutex_t *tcp_acceptor_lockp; /* Ptr to tf_lock */ 3967c478bd9Sstevel@tonic-gate 3977c478bd9Sstevel@tonic-gate timeout_id_t tcp_ordrelid; /* qbufcall/qtimeout id */ 3987c478bd9Sstevel@tonic-gate t_uscalar_t tcp_acceptor_id; /* ACCEPTOR_id */ 3997c478bd9Sstevel@tonic-gate 4007c478bd9Sstevel@tonic-gate int tcp_ipsec_overhead; 4017c478bd9Sstevel@tonic-gate /* 4027c478bd9Sstevel@tonic-gate * Address family that app wishes returned addrsses to be in. 4037c478bd9Sstevel@tonic-gate * Currently taken from address family used in T_BIND_REQ, but 4047c478bd9Sstevel@tonic-gate * should really come from family used in original socket() call. 4057c478bd9Sstevel@tonic-gate * Value can be AF_INET or AF_INET6. 4067c478bd9Sstevel@tonic-gate */ 4077c478bd9Sstevel@tonic-gate uint_t tcp_family; 4087c478bd9Sstevel@tonic-gate /* 4097c478bd9Sstevel@tonic-gate * used for a quick test to determine if any ancillary bits are 4107c478bd9Sstevel@tonic-gate * set 4117c478bd9Sstevel@tonic-gate */ 4127c478bd9Sstevel@tonic-gate uint_t tcp_ipv6_recvancillary; /* Flags */ 4137c478bd9Sstevel@tonic-gate #define TCP_IPV6_RECVPKTINFO 0x01 /* IPV6_RECVPKTINFO option */ 4147c478bd9Sstevel@tonic-gate #define TCP_IPV6_RECVHOPLIMIT 0x02 /* IPV6_RECVHOPLIMIT option */ 4157c478bd9Sstevel@tonic-gate #define TCP_IPV6_RECVHOPOPTS 0x04 /* IPV6_RECVHOPOPTS option */ 4167c478bd9Sstevel@tonic-gate #define TCP_IPV6_RECVDSTOPTS 0x08 /* IPV6_RECVDSTOPTS option */ 4177c478bd9Sstevel@tonic-gate #define TCP_IPV6_RECVRTHDR 0x10 /* IPV6_RECVRTHDR option */ 4187c478bd9Sstevel@tonic-gate #define TCP_IPV6_RECVRTDSTOPTS 0x20 /* IPV6_RECVRTHDRDSTOPTS option */ 4197c478bd9Sstevel@tonic-gate #define TCP_IPV6_RECVTCLASS 0x40 /* IPV6_RECVTCLASS option */ 4207c478bd9Sstevel@tonic-gate #define TCP_OLD_IPV6_RECVDSTOPTS 0x80 /* old IPV6_RECVDSTOPTS option */ 4217c478bd9Sstevel@tonic-gate 4227c478bd9Sstevel@tonic-gate uint_t tcp_recvifindex; /* Last received IPV6_RCVPKTINFO */ 4237c478bd9Sstevel@tonic-gate uint_t tcp_recvhops; /* Last received IPV6_RECVHOPLIMIT */ 4247c478bd9Sstevel@tonic-gate uint_t tcp_recvtclass; /* Last received IPV6_RECVTCLASS */ 4257c478bd9Sstevel@tonic-gate ip6_hbh_t *tcp_hopopts; /* Last received IPV6_RECVHOPOPTS */ 4267c478bd9Sstevel@tonic-gate ip6_dest_t *tcp_dstopts; /* Last received IPV6_RECVDSTOPTS */ 4277c478bd9Sstevel@tonic-gate ip6_dest_t *tcp_rtdstopts; /* Last recvd IPV6_RECVRTHDRDSTOPTS */ 4287c478bd9Sstevel@tonic-gate ip6_rthdr_t *tcp_rthdr; /* Last received IPV6_RECVRTHDR */ 4297c478bd9Sstevel@tonic-gate uint_t tcp_hopoptslen; 4307c478bd9Sstevel@tonic-gate uint_t tcp_dstoptslen; 4317c478bd9Sstevel@tonic-gate uint_t tcp_rtdstoptslen; 4327c478bd9Sstevel@tonic-gate uint_t tcp_rthdrlen; 4337c478bd9Sstevel@tonic-gate 4347c478bd9Sstevel@tonic-gate mblk_t *tcp_timercache; 4357c478bd9Sstevel@tonic-gate cred_t *tcp_cred; /* Credentials when this was opened */ 4367c478bd9Sstevel@tonic-gate pid_t tcp_cpid; /* Process id when this was opened */ 4377c478bd9Sstevel@tonic-gate 4387c478bd9Sstevel@tonic-gate 4397c478bd9Sstevel@tonic-gate union { 4407c478bd9Sstevel@tonic-gate struct { 4417c478bd9Sstevel@tonic-gate uchar_t v4_ttl; 4427c478bd9Sstevel@tonic-gate /* Dup of tcp_ipha.iph_type_of_service */ 4437c478bd9Sstevel@tonic-gate uchar_t v4_tos; /* Dup of tcp_ipha.iph_ttl */ 4447c478bd9Sstevel@tonic-gate } v4_hdr_info; 4457c478bd9Sstevel@tonic-gate struct { 4467c478bd9Sstevel@tonic-gate uint_t v6_vcf; /* Dup of tcp_ip6h.ip6h_vcf */ 4477c478bd9Sstevel@tonic-gate uchar_t v6_hops; /* Dup of tcp_ip6h.ip6h_hops */ 4487c478bd9Sstevel@tonic-gate } v6_hdr_info; 4497c478bd9Sstevel@tonic-gate } tcp_hdr_info; 4507c478bd9Sstevel@tonic-gate #define tcp_ttl tcp_hdr_info.v4_hdr_info.v4_ttl 4517c478bd9Sstevel@tonic-gate #define tcp_tos tcp_hdr_info.v4_hdr_info.v4_tos 4527c478bd9Sstevel@tonic-gate #define tcp_ip6_vcf tcp_hdr_info.v6_hdr_info.v6_vcf 4537c478bd9Sstevel@tonic-gate #define tcp_ip6_hops tcp_hdr_info.v6_hdr_info.v6_hops 4547c478bd9Sstevel@tonic-gate 4557c478bd9Sstevel@tonic-gate ushort_t tcp_ipversion; 4567c478bd9Sstevel@tonic-gate uint_t tcp_bound_if; /* IPV6_BOUND_IF */ 4577c478bd9Sstevel@tonic-gate 4587c478bd9Sstevel@tonic-gate #define tcp_lport tcp_connp->conn_lport 4597c478bd9Sstevel@tonic-gate #define tcp_fport tcp_connp->conn_fport 4607c478bd9Sstevel@tonic-gate #define tcp_ports tcp_connp->conn_ports 4617c478bd9Sstevel@tonic-gate 4627c478bd9Sstevel@tonic-gate #define tcp_remote tcp_connp->conn_rem 4637c478bd9Sstevel@tonic-gate #define tcp_ip_src tcp_connp->conn_src 4647c478bd9Sstevel@tonic-gate 4657c478bd9Sstevel@tonic-gate #define tcp_remote_v6 tcp_connp->conn_remv6 4667c478bd9Sstevel@tonic-gate #define tcp_ip_src_v6 tcp_connp->conn_srcv6 4677c478bd9Sstevel@tonic-gate #define tcp_bound_source_v6 tcp_connp->conn_bound_source_v6 4687c478bd9Sstevel@tonic-gate #define tcp_bound_source tcp_connp->conn_bound_source 4697c478bd9Sstevel@tonic-gate 4707c478bd9Sstevel@tonic-gate kmutex_t tcp_closelock; 4717c478bd9Sstevel@tonic-gate kcondvar_t tcp_closecv; 4727c478bd9Sstevel@tonic-gate uint8_t tcp_closed; 4737c478bd9Sstevel@tonic-gate uint8_t tcp_closeflags; 4747c478bd9Sstevel@tonic-gate uint8_t tcp_cleandeathtag; 4757c478bd9Sstevel@tonic-gate mblk_t tcp_closemp; 4767c478bd9Sstevel@tonic-gate timeout_id_t tcp_linger_tid; /* Linger timer ID */ 4777c478bd9Sstevel@tonic-gate void *tcp_tracebuf; 4787c478bd9Sstevel@tonic-gate 4797c478bd9Sstevel@tonic-gate struct tcp_s *tcp_acceptor_hash; /* Acceptor hash chain */ 4807c478bd9Sstevel@tonic-gate struct tcp_s **tcp_ptpahn; /* Pointer to previous accept hash next. */ 4817c478bd9Sstevel@tonic-gate struct tcp_s *tcp_bind_hash; /* Bind hash chain */ 4827c478bd9Sstevel@tonic-gate struct tcp_s **tcp_ptpbhn; 4837c478bd9Sstevel@tonic-gate 4847c478bd9Sstevel@tonic-gate boolean_t tcp_ire_ill_check_done; 4857c478bd9Sstevel@tonic-gate uint_t tcp_maxpsz; 4867c478bd9Sstevel@tonic-gate 4877c478bd9Sstevel@tonic-gate /* 4887c478bd9Sstevel@tonic-gate * used for Multidata Transmit 4897c478bd9Sstevel@tonic-gate */ 4907c478bd9Sstevel@tonic-gate uint_t tcp_mdt_hdr_head; /* leading header fragment extra space */ 4917c478bd9Sstevel@tonic-gate uint_t tcp_mdt_hdr_tail; /* trailing header fragment extra space */ 4927c478bd9Sstevel@tonic-gate int tcp_mdt_max_pld; /* maximum payload buffers per Multidata */ 4937c478bd9Sstevel@tonic-gate 4947c478bd9Sstevel@tonic-gate uint32_t tcp_ofo_fin_seq; /* Recv out of order FIN seq num */ 4957c478bd9Sstevel@tonic-gate uint32_t tcp_cwr_snd_max; 4967c478bd9Sstevel@tonic-gate uint_t tcp_drop_opt_ack_cnt; /* # tcp generated optmgmt */ 4977c478bd9Sstevel@tonic-gate ip6_pkt_t tcp_sticky_ipp; /* Sticky options */ 4987c478bd9Sstevel@tonic-gate #define tcp_ipp_fields tcp_sticky_ipp.ipp_fields /* valid fields */ 4997c478bd9Sstevel@tonic-gate #define tcp_ipp_ifindex tcp_sticky_ipp.ipp_ifindex /* pktinfo ifindex */ 5007c478bd9Sstevel@tonic-gate #define tcp_ipp_addr tcp_sticky_ipp.ipp_addr /* pktinfo src/dst addr */ 5017c478bd9Sstevel@tonic-gate #define tcp_ipp_hoplimit tcp_sticky_ipp.ipp_hoplimit 5027c478bd9Sstevel@tonic-gate #define tcp_ipp_hopoptslen tcp_sticky_ipp.ipp_hopoptslen 5037c478bd9Sstevel@tonic-gate #define tcp_ipp_rtdstoptslen tcp_sticky_ipp.ipp_rtdstoptslen 5047c478bd9Sstevel@tonic-gate #define tcp_ipp_rthdrlen tcp_sticky_ipp.ipp_rthdrlen 5057c478bd9Sstevel@tonic-gate #define tcp_ipp_dstoptslen tcp_sticky_ipp.ipp_dstoptslen 5067c478bd9Sstevel@tonic-gate #define tcp_ipp_hopopts tcp_sticky_ipp.ipp_hopopts 5077c478bd9Sstevel@tonic-gate #define tcp_ipp_rtdstopts tcp_sticky_ipp.ipp_rtdstopts 5087c478bd9Sstevel@tonic-gate #define tcp_ipp_rthdr tcp_sticky_ipp.ipp_rthdr 5097c478bd9Sstevel@tonic-gate #define tcp_ipp_dstopts tcp_sticky_ipp.ipp_dstopts 5107c478bd9Sstevel@tonic-gate #define tcp_ipp_nexthop tcp_sticky_ipp.ipp_nexthop 5117c478bd9Sstevel@tonic-gate #define tcp_ipp_use_min_mtu tcp_sticky_ipp.ipp_use_min_mtu 5127c478bd9Sstevel@tonic-gate struct tcp_s *tcp_saved_listener; /* saved value of listener */ 5137c478bd9Sstevel@tonic-gate 514ff550d0eSmasputra uint32_t tcp_in_ack_unsent; /* ACK for unsent data cnt. */ 515ff550d0eSmasputra 516ff550d0eSmasputra /* 517ff550d0eSmasputra * The following fusion-related fields are protected by squeue. 518ff550d0eSmasputra */ 5197c478bd9Sstevel@tonic-gate struct tcp_s *tcp_loopback_peer; /* peer tcp for loopback */ 5207c478bd9Sstevel@tonic-gate mblk_t *tcp_fused_sigurg_mp; /* M_PCSIG mblk for SIGURG */ 521ff550d0eSmasputra size_t tcp_fuse_rcv_hiwater; /* fusion receive queue size */ 522ff550d0eSmasputra uint_t tcp_fuse_rcv_unread_hiwater; /* max # of outstanding pkts */ 523ff550d0eSmasputra /* 524ff550d0eSmasputra * The following fusion-related fields and bit fields are to be 525ff550d0eSmasputra * manipulated with squeue protection or with tcp_fuse_lock held. 526ff550d0eSmasputra */ 527ff550d0eSmasputra kmutex_t tcp_fuse_lock; 528ff550d0eSmasputra uint_t tcp_fuse_rcv_unread_cnt; /* # of outstanding pkts */ 529ff550d0eSmasputra uint32_t 530ff550d0eSmasputra tcp_fused : 1, /* loopback tcp in fusion mode */ 531ff550d0eSmasputra tcp_unfusable : 1, /* fusion not allowed on endpoint */ 532ff550d0eSmasputra tcp_fused_sigurg : 1, /* send SIGURG upon draining */ 533ff550d0eSmasputra tcp_direct_sockfs : 1, /* direct calls to sockfs */ 5347c478bd9Sstevel@tonic-gate 535ff550d0eSmasputra tcp_fuse_syncstr_stopped : 1, /* synchronous streams stopped */ 536ff550d0eSmasputra tcp_fuse_to_bit_31 : 27; 5377c478bd9Sstevel@tonic-gate 5387c478bd9Sstevel@tonic-gate /* 5397c478bd9Sstevel@tonic-gate * This variable is accessed without any lock protection 5407c478bd9Sstevel@tonic-gate * and therefore must not be declared as a bit field along 5417c478bd9Sstevel@tonic-gate * with the rest which require such condition. 5427c478bd9Sstevel@tonic-gate */ 5437c478bd9Sstevel@tonic-gate boolean_t tcp_issocket; /* this is a socket tcp */ 544ff550d0eSmasputra 545ff550d0eSmasputra uint32_t tcp_squeue_bytes; 546c28749e9Skais /* 547c28749e9Skais * Kernel SSL session information 548c28749e9Skais */ 549c28749e9Skais boolean_t tcp_kssl_pending; /* waiting for 1st SSL rec. */ 550c28749e9Skais boolean_t tcp_kssl_inhandshake; /* during SSL handshake */ 551c28749e9Skais kssl_ent_t tcp_kssl_ent; /* SSL table entry */ 552c28749e9Skais kssl_ctx_t tcp_kssl_ctx; /* SSL session */ 553*45916cd2Sjpk uint_t tcp_label_len; /* length of cached label */ 5547c478bd9Sstevel@tonic-gate } tcp_t; 5557c478bd9Sstevel@tonic-gate 5567c478bd9Sstevel@tonic-gate extern void tcp_free(tcp_t *tcp); 5577c478bd9Sstevel@tonic-gate extern void tcp_ddi_init(void); 5587c478bd9Sstevel@tonic-gate extern void tcp_ddi_destroy(void); 5597c478bd9Sstevel@tonic-gate extern void tcp_xmit_listeners_reset(mblk_t *mp, uint_t ip_hdr_len); 5607c478bd9Sstevel@tonic-gate extern void tcp_conn_request(void *arg, mblk_t *mp, void *arg2); 5617c478bd9Sstevel@tonic-gate extern void tcp_conn_request_unbound(void *arg, mblk_t *mp, void *arg2); 5627c478bd9Sstevel@tonic-gate extern void tcp_input(void *arg, mblk_t *mp, void *arg2); 5637c478bd9Sstevel@tonic-gate extern void tcp_rput_data(void *arg, mblk_t *mp, void *arg2); 5647c478bd9Sstevel@tonic-gate extern void *tcp_get_conn(void *arg); 5657c478bd9Sstevel@tonic-gate extern void tcp_time_wait_collector(void *arg); 566ff550d0eSmasputra extern int tcp_snmp_get(queue_t *, mblk_t *); 567ff550d0eSmasputra extern int tcp_snmp_set(queue_t *, int, int, uchar_t *, int len); 5687c478bd9Sstevel@tonic-gate /* 5697c478bd9Sstevel@tonic-gate * The TCP Fanout structure. 5707c478bd9Sstevel@tonic-gate * The hash tables and their linkage (tcp_*_hash_next, tcp_ptp*hn) are 5717c478bd9Sstevel@tonic-gate * protected by the per-bucket tf_lock. Each tcp_t 5727c478bd9Sstevel@tonic-gate * inserted in the list points back at this lock using tcp_*_lockp. 5737c478bd9Sstevel@tonic-gate * 5747c478bd9Sstevel@tonic-gate * The listener and acceptor hash queues are lists of tcp_t. 5757c478bd9Sstevel@tonic-gate */ 5767c478bd9Sstevel@tonic-gate 5777c478bd9Sstevel@tonic-gate /* listener hash and acceptor hash queue head */ 5787c478bd9Sstevel@tonic-gate typedef struct tf_s { 5797c478bd9Sstevel@tonic-gate tcp_t *tf_tcp; 5807c478bd9Sstevel@tonic-gate kmutex_t tf_lock; 5817c478bd9Sstevel@tonic-gate } tf_t; 5827c478bd9Sstevel@tonic-gate 5837c478bd9Sstevel@tonic-gate extern mib2_tcp_t tcp_mib; 5847c478bd9Sstevel@tonic-gate 5857c478bd9Sstevel@tonic-gate #endif /* (defined(_KERNEL) || defined(_KMEMUSER)) */ 5867c478bd9Sstevel@tonic-gate 5877c478bd9Sstevel@tonic-gate /* Contract private interface between TCP and Clustering. */ 5887c478bd9Sstevel@tonic-gate 5897c478bd9Sstevel@tonic-gate #define CL_TCPI_V1 1 /* cl_tcpi_version number */ 5907c478bd9Sstevel@tonic-gate 5917c478bd9Sstevel@tonic-gate typedef struct cl_tcp_info_s { 5927c478bd9Sstevel@tonic-gate ushort_t cl_tcpi_version; /* cl_tcp_info_t's version no */ 5937c478bd9Sstevel@tonic-gate ushort_t cl_tcpi_ipversion; /* IP version */ 5947c478bd9Sstevel@tonic-gate int32_t cl_tcpi_state; /* TCP state */ 5957c478bd9Sstevel@tonic-gate in_port_t cl_tcpi_lport; /* Local port */ 5967c478bd9Sstevel@tonic-gate in_port_t cl_tcpi_fport; /* Remote port */ 5977c478bd9Sstevel@tonic-gate in6_addr_t cl_tcpi_laddr_v6; /* Local IP address */ 5987c478bd9Sstevel@tonic-gate in6_addr_t cl_tcpi_faddr_v6; /* Remote IP address */ 5997c478bd9Sstevel@tonic-gate #ifdef _KERNEL 6007c478bd9Sstevel@tonic-gate /* Note: V4_PART_OF_V6 is meant to be used only for _KERNEL defined stuff */ 6017c478bd9Sstevel@tonic-gate #define cl_tcpi_laddr V4_PART_OF_V6(cl_tcpi_laddr_v6) 6027c478bd9Sstevel@tonic-gate #define cl_tcpi_faddr V4_PART_OF_V6(cl_tcpi_faddr_v6) 6037c478bd9Sstevel@tonic-gate 6047c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 6057c478bd9Sstevel@tonic-gate } cl_tcp_info_t; 6067c478bd9Sstevel@tonic-gate 6077c478bd9Sstevel@tonic-gate /* 6087c478bd9Sstevel@tonic-gate * Hook functions to enable cluster networking 6097c478bd9Sstevel@tonic-gate * On non-clustered systems these vectors must always be NULL. 6107c478bd9Sstevel@tonic-gate */ 6117c478bd9Sstevel@tonic-gate 6127c478bd9Sstevel@tonic-gate extern void (*cl_inet_listen)(uint8_t, sa_family_t, uint8_t *, in_port_t); 6137c478bd9Sstevel@tonic-gate extern void (*cl_inet_unlisten)(uint8_t, sa_family_t, uint8_t *, 6147c478bd9Sstevel@tonic-gate in_port_t); 6157c478bd9Sstevel@tonic-gate 6167c478bd9Sstevel@tonic-gate /* 6177c478bd9Sstevel@tonic-gate * Contracted Consolidation Private ioctl for aborting TCP connections. 6187c478bd9Sstevel@tonic-gate * In order to keep the offsets and size of the structure the same between 6197c478bd9Sstevel@tonic-gate * a 32-bit application and a 64-bit amd64 kernel, we use a #pragma 6207c478bd9Sstevel@tonic-gate * pack(4). 6217c478bd9Sstevel@tonic-gate */ 6227c478bd9Sstevel@tonic-gate #define TCP_IOC_ABORT_CONN (('T' << 8) + 91) 6237c478bd9Sstevel@tonic-gate 6247c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 6257c478bd9Sstevel@tonic-gate #pragma pack(4) 6267c478bd9Sstevel@tonic-gate #endif 6277c478bd9Sstevel@tonic-gate 6287c478bd9Sstevel@tonic-gate typedef struct tcp_ioc_abort_conn_s { 6297c478bd9Sstevel@tonic-gate struct sockaddr_storage ac_local; /* local addr and port */ 6307c478bd9Sstevel@tonic-gate struct sockaddr_storage ac_remote; /* remote addr and port */ 6317c478bd9Sstevel@tonic-gate int32_t ac_start; /* start state */ 6327c478bd9Sstevel@tonic-gate int32_t ac_end; /* end state */ 6337c478bd9Sstevel@tonic-gate int32_t ac_zoneid; /* zoneid */ 6347c478bd9Sstevel@tonic-gate } tcp_ioc_abort_conn_t; 6357c478bd9Sstevel@tonic-gate 6367c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 6377c478bd9Sstevel@tonic-gate #pragma pack() 6387c478bd9Sstevel@tonic-gate #endif 6397c478bd9Sstevel@tonic-gate 6407c478bd9Sstevel@tonic-gate #if (defined(_KERNEL) || defined(_KMEMUSER)) 6417c478bd9Sstevel@tonic-gate extern void tcp_rput_other(tcp_t *tcp, mblk_t *mp); 6427c478bd9Sstevel@tonic-gate #endif 6437c478bd9Sstevel@tonic-gate 6447c478bd9Sstevel@tonic-gate #ifdef __cplusplus 6457c478bd9Sstevel@tonic-gate } 6467c478bd9Sstevel@tonic-gate #endif 6477c478bd9Sstevel@tonic-gate 6487c478bd9Sstevel@tonic-gate #endif /* _INET_TCP_H */ 649