1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1990 Mentat Inc. */ 27*7c478bd9Sstevel@tonic-gate 28*7c478bd9Sstevel@tonic-gate #ifndef _INET_TCP_H 29*7c478bd9Sstevel@tonic-gate #define _INET_TCP_H 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 32*7c478bd9Sstevel@tonic-gate 33*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 34*7c478bd9Sstevel@tonic-gate extern "C" { 35*7c478bd9Sstevel@tonic-gate #endif 36*7c478bd9Sstevel@tonic-gate 37*7c478bd9Sstevel@tonic-gate #include <sys/inttypes.h> 38*7c478bd9Sstevel@tonic-gate #include <netinet/ip6.h> 39*7c478bd9Sstevel@tonic-gate #include <netinet/tcp.h> 40*7c478bd9Sstevel@tonic-gate #include <inet/tcp_sack.h> 41*7c478bd9Sstevel@tonic-gate #include <sys/socket.h> 42*7c478bd9Sstevel@tonic-gate #include <sys/multidata.h> 43*7c478bd9Sstevel@tonic-gate 44*7c478bd9Sstevel@tonic-gate /* 45*7c478bd9Sstevel@tonic-gate * Private (and possibly temporary) ioctl used by configuration code 46*7c478bd9Sstevel@tonic-gate * to lock in the "default" stream for detached closes. 47*7c478bd9Sstevel@tonic-gate */ 48*7c478bd9Sstevel@tonic-gate #define TCP_IOC_DEFAULT_Q (('T' << 8) + 51) 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate /* TCP states */ 51*7c478bd9Sstevel@tonic-gate #define TCPS_CLOSED -6 52*7c478bd9Sstevel@tonic-gate #define TCPS_IDLE -5 /* idle (opened, but not bound) */ 53*7c478bd9Sstevel@tonic-gate #define TCPS_BOUND -4 /* bound, ready to connect or accept */ 54*7c478bd9Sstevel@tonic-gate #define TCPS_LISTEN -3 /* listening for connection */ 55*7c478bd9Sstevel@tonic-gate #define TCPS_SYN_SENT -2 /* active, have sent syn */ 56*7c478bd9Sstevel@tonic-gate #define TCPS_SYN_RCVD -1 /* have received syn (and sent ours) */ 57*7c478bd9Sstevel@tonic-gate /* states < TCPS_ESTABLISHED are those where connections not established */ 58*7c478bd9Sstevel@tonic-gate #define TCPS_ESTABLISHED 0 /* established */ 59*7c478bd9Sstevel@tonic-gate #define TCPS_CLOSE_WAIT 1 /* rcvd fin, waiting for close */ 60*7c478bd9Sstevel@tonic-gate /* states > TCPS_CLOSE_WAIT are those where user has closed */ 61*7c478bd9Sstevel@tonic-gate #define TCPS_FIN_WAIT_1 2 /* have closed and sent fin */ 62*7c478bd9Sstevel@tonic-gate #define TCPS_CLOSING 3 /* closed, xchd FIN, await FIN ACK */ 63*7c478bd9Sstevel@tonic-gate #define TCPS_LAST_ACK 4 /* had fin and close; await FIN ACK */ 64*7c478bd9Sstevel@tonic-gate /* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */ 65*7c478bd9Sstevel@tonic-gate #define TCPS_FIN_WAIT_2 5 /* have closed, fin is acked */ 66*7c478bd9Sstevel@tonic-gate #define TCPS_TIME_WAIT 6 /* in 2*msl quiet wait after close */ 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate /* 69*7c478bd9Sstevel@tonic-gate * Internal flags used in conjunction with the packet header flags. 70*7c478bd9Sstevel@tonic-gate * Used in tcp_rput_data to keep track of what needs to be done. 71*7c478bd9Sstevel@tonic-gate */ 72*7c478bd9Sstevel@tonic-gate #define TH_LIMIT_XMIT 0x0400 /* Limited xmit is needed */ 73*7c478bd9Sstevel@tonic-gate #define TH_XMIT_NEEDED 0x0800 /* Window opened - send queued data */ 74*7c478bd9Sstevel@tonic-gate #define TH_REXMIT_NEEDED 0x1000 /* Time expired for unacked data */ 75*7c478bd9Sstevel@tonic-gate #define TH_ACK_NEEDED 0x2000 /* Send an ack now. */ 76*7c478bd9Sstevel@tonic-gate #define TH_NEED_SACK_REXMIT 0x4000 /* Use SACK info to retransmission */ 77*7c478bd9Sstevel@tonic-gate #define TH_ACK_TIMER_NEEDED 0x8000 /* Start the delayed ACK timer */ 78*7c478bd9Sstevel@tonic-gate #define TH_ORDREL_NEEDED 0x10000 /* Generate an ordrel indication */ 79*7c478bd9Sstevel@tonic-gate #define TH_MARKNEXT_NEEDED 0x20000 /* Data should have MSGMARKNEXT */ 80*7c478bd9Sstevel@tonic-gate #define TH_SEND_URP_MARK 0x40000 /* Send up tcp_urp_mark_mp */ 81*7c478bd9Sstevel@tonic-gate 82*7c478bd9Sstevel@tonic-gate /* 83*7c478bd9Sstevel@tonic-gate * TCP sequence numbers are 32 bit integers operated 84*7c478bd9Sstevel@tonic-gate * on with modular arithmetic. These macros can be 85*7c478bd9Sstevel@tonic-gate * used to compare such integers. 86*7c478bd9Sstevel@tonic-gate */ 87*7c478bd9Sstevel@tonic-gate #define SEQ_LT(a, b) ((int32_t)((a)-(b)) < 0) 88*7c478bd9Sstevel@tonic-gate #define SEQ_LEQ(a, b) ((int32_t)((a)-(b)) <= 0) 89*7c478bd9Sstevel@tonic-gate #define SEQ_GT(a, b) ((int32_t)((a)-(b)) > 0) 90*7c478bd9Sstevel@tonic-gate #define SEQ_GEQ(a, b) ((int32_t)((a)-(b)) >= 0) 91*7c478bd9Sstevel@tonic-gate 92*7c478bd9Sstevel@tonic-gate /* TCP Protocol header */ 93*7c478bd9Sstevel@tonic-gate typedef struct tcphdr_s { 94*7c478bd9Sstevel@tonic-gate uint8_t th_lport[2]; /* Source port */ 95*7c478bd9Sstevel@tonic-gate uint8_t th_fport[2]; /* Destination port */ 96*7c478bd9Sstevel@tonic-gate uint8_t th_seq[4]; /* Sequence number */ 97*7c478bd9Sstevel@tonic-gate uint8_t th_ack[4]; /* Acknowledgement number */ 98*7c478bd9Sstevel@tonic-gate uint8_t th_offset_and_rsrvd[1]; /* Offset to the packet data */ 99*7c478bd9Sstevel@tonic-gate uint8_t th_flags[1]; 100*7c478bd9Sstevel@tonic-gate uint8_t th_win[2]; /* Allocation number */ 101*7c478bd9Sstevel@tonic-gate uint8_t th_sum[2]; /* TCP checksum */ 102*7c478bd9Sstevel@tonic-gate uint8_t th_urp[2]; /* Urgent pointer */ 103*7c478bd9Sstevel@tonic-gate } tcph_t; 104*7c478bd9Sstevel@tonic-gate 105*7c478bd9Sstevel@tonic-gate #define TCP_HDR_LENGTH(tcph) (((tcph)->th_offset_and_rsrvd[0] >>2) &(0xF << 2)) 106*7c478bd9Sstevel@tonic-gate #define TCP_MAX_COMBINED_HEADER_LENGTH (60 + 60) /* Maxed out ip + tcp */ 107*7c478bd9Sstevel@tonic-gate #define TCP_MAX_IP_OPTIONS_LENGTH (60 - IP_SIMPLE_HDR_LENGTH) 108*7c478bd9Sstevel@tonic-gate #define TCP_MAX_HDR_LENGTH 60 109*7c478bd9Sstevel@tonic-gate #define TCP_MAX_TCP_OPTIONS_LENGTH (60 - sizeof (tcph_t)) 110*7c478bd9Sstevel@tonic-gate #define TCP_MIN_HEADER_LENGTH 20 111*7c478bd9Sstevel@tonic-gate #define TCP_MAXWIN 65535 112*7c478bd9Sstevel@tonic-gate #define TCP_PORT_LEN sizeof (in_port_t) 113*7c478bd9Sstevel@tonic-gate #define TCP_MAX_WINSHIFT 14 114*7c478bd9Sstevel@tonic-gate #define TCP_MAX_LARGEWIN (TCP_MAXWIN << TCP_MAX_WINSHIFT) 115*7c478bd9Sstevel@tonic-gate 116*7c478bd9Sstevel@tonic-gate #define TCPIP_HDR_LENGTH(mp, n) \ 117*7c478bd9Sstevel@tonic-gate (n) = IPH_HDR_LENGTH((mp)->b_rptr), \ 118*7c478bd9Sstevel@tonic-gate (n) += TCP_HDR_LENGTH((tcph_t *)&(mp)->b_rptr[(n)]) 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate /* TCP Protocol header (used if the header is known to be 32-bit aligned) */ 121*7c478bd9Sstevel@tonic-gate typedef struct tcphdra_s { 122*7c478bd9Sstevel@tonic-gate in_port_t tha_lport; /* Source port */ 123*7c478bd9Sstevel@tonic-gate in_port_t tha_fport; /* Destination port */ 124*7c478bd9Sstevel@tonic-gate uint32_t tha_seq; /* Sequence number */ 125*7c478bd9Sstevel@tonic-gate uint32_t tha_ack; /* Acknowledgement number */ 126*7c478bd9Sstevel@tonic-gate uint8_t tha_offset_and_reserved; /* Offset to the packet data */ 127*7c478bd9Sstevel@tonic-gate uint8_t tha_flags; 128*7c478bd9Sstevel@tonic-gate uint16_t tha_win; /* Allocation number */ 129*7c478bd9Sstevel@tonic-gate uint16_t tha_sum; /* TCP checksum */ 130*7c478bd9Sstevel@tonic-gate uint16_t tha_urp; /* Urgent pointer */ 131*7c478bd9Sstevel@tonic-gate } tcpha_t; 132*7c478bd9Sstevel@tonic-gate 133*7c478bd9Sstevel@tonic-gate struct conn_s; 134*7c478bd9Sstevel@tonic-gate 135*7c478bd9Sstevel@tonic-gate /* 136*7c478bd9Sstevel@tonic-gate * Control structure for each open TCP stream, 137*7c478bd9Sstevel@tonic-gate * defined only within the kernel or for a kmem user. 138*7c478bd9Sstevel@tonic-gate * NOTE: tcp_reinit_values MUST have a line for each field in this structure! 139*7c478bd9Sstevel@tonic-gate */ 140*7c478bd9Sstevel@tonic-gate #if (defined(_KERNEL) || defined(_KMEMUSER)) 141*7c478bd9Sstevel@tonic-gate 142*7c478bd9Sstevel@tonic-gate typedef struct tcp_s { 143*7c478bd9Sstevel@tonic-gate /* Pointer to previous bind hash next. */ 144*7c478bd9Sstevel@tonic-gate struct tcp_s *tcp_time_wait_next; 145*7c478bd9Sstevel@tonic-gate /* Pointer to next T/W block */ 146*7c478bd9Sstevel@tonic-gate struct tcp_s *tcp_time_wait_prev; 147*7c478bd9Sstevel@tonic-gate /* Pointer to previous T/W next */ 148*7c478bd9Sstevel@tonic-gate clock_t tcp_time_wait_expire; 149*7c478bd9Sstevel@tonic-gate struct conn_s *tcp_connp; 150*7c478bd9Sstevel@tonic-gate 151*7c478bd9Sstevel@tonic-gate int32_t tcp_state; 152*7c478bd9Sstevel@tonic-gate int32_t tcp_rcv_ws; /* My window scale power */ 153*7c478bd9Sstevel@tonic-gate int32_t tcp_snd_ws; /* Sender's window scale power */ 154*7c478bd9Sstevel@tonic-gate uint32_t tcp_ts_recent; /* Timestamp of earliest unacked */ 155*7c478bd9Sstevel@tonic-gate /* data segment */ 156*7c478bd9Sstevel@tonic-gate clock_t tcp_rto; /* Round trip timeout */ 157*7c478bd9Sstevel@tonic-gate clock_t tcp_last_rcv_lbolt; 158*7c478bd9Sstevel@tonic-gate /* lbolt on last packet, used for PAWS */ 159*7c478bd9Sstevel@tonic-gate 160*7c478bd9Sstevel@tonic-gate uint32_t tcp_snxt; /* Senders next seq num */ 161*7c478bd9Sstevel@tonic-gate uint32_t tcp_swnd; /* Senders window (relative to suna) */ 162*7c478bd9Sstevel@tonic-gate uint32_t tcp_mss; /* Max segment size */ 163*7c478bd9Sstevel@tonic-gate uint32_t tcp_iss; /* Initial send seq num */ 164*7c478bd9Sstevel@tonic-gate uint32_t tcp_rnxt; /* Seq we expect to recv next */ 165*7c478bd9Sstevel@tonic-gate uint32_t tcp_rwnd; 166*7c478bd9Sstevel@tonic-gate 167*7c478bd9Sstevel@tonic-gate queue_t *tcp_rq; /* Our upstream neighbor (client) */ 168*7c478bd9Sstevel@tonic-gate queue_t *tcp_wq; /* Our downstream neighbor */ 169*7c478bd9Sstevel@tonic-gate 170*7c478bd9Sstevel@tonic-gate /* Fields arranged in approximate access order along main paths */ 171*7c478bd9Sstevel@tonic-gate mblk_t *tcp_xmit_head; /* Head of rexmit list */ 172*7c478bd9Sstevel@tonic-gate mblk_t *tcp_xmit_last; /* last valid data seen by tcp_wput */ 173*7c478bd9Sstevel@tonic-gate mblk_t *tcp_xmit_tail; /* Last rexmit data sent */ 174*7c478bd9Sstevel@tonic-gate uint32_t tcp_unsent; /* # of bytes in hand that are unsent */ 175*7c478bd9Sstevel@tonic-gate uint32_t tcp_xmit_tail_unsent; /* # of unsent bytes in xmit_tail */ 176*7c478bd9Sstevel@tonic-gate 177*7c478bd9Sstevel@tonic-gate uint32_t tcp_suna; /* Sender unacknowledged */ 178*7c478bd9Sstevel@tonic-gate uint32_t tcp_rexmit_nxt; /* Next rexmit seq num */ 179*7c478bd9Sstevel@tonic-gate uint32_t tcp_rexmit_max; /* Max retran seq num */ 180*7c478bd9Sstevel@tonic-gate int32_t tcp_snd_burst; /* Send burst factor */ 181*7c478bd9Sstevel@tonic-gate uint32_t tcp_cwnd; /* Congestion window */ 182*7c478bd9Sstevel@tonic-gate int32_t tcp_cwnd_cnt; /* cwnd cnt in congestion avoidance */ 183*7c478bd9Sstevel@tonic-gate 184*7c478bd9Sstevel@tonic-gate uint32_t tcp_ibsegs; /* Inbound segments on this stream */ 185*7c478bd9Sstevel@tonic-gate uint32_t tcp_obsegs; /* Outbound segments on this stream */ 186*7c478bd9Sstevel@tonic-gate 187*7c478bd9Sstevel@tonic-gate uint32_t tcp_naglim; /* Tunable nagle limit */ 188*7c478bd9Sstevel@tonic-gate uint32_t tcp_valid_bits; 189*7c478bd9Sstevel@tonic-gate #define TCP_ISS_VALID 0x1 /* Is the tcp_iss seq num active? */ 190*7c478bd9Sstevel@tonic-gate #define TCP_FSS_VALID 0x2 /* Is the tcp_fss seq num active? */ 191*7c478bd9Sstevel@tonic-gate #define TCP_URG_VALID 0x4 /* Is the tcp_urg seq num active? */ 192*7c478bd9Sstevel@tonic-gate #define TCP_OFO_FIN_VALID 0x8 /* Has TCP received an out of order FIN? */ 193*7c478bd9Sstevel@tonic-gate 194*7c478bd9Sstevel@tonic-gate 195*7c478bd9Sstevel@tonic-gate int32_t tcp_xmit_hiwater; /* Send buffer high water mark. */ 196*7c478bd9Sstevel@tonic-gate 197*7c478bd9Sstevel@tonic-gate timeout_id_t tcp_timer_tid; /* Control block for timer service */ 198*7c478bd9Sstevel@tonic-gate uchar_t tcp_timer_backoff; /* Backoff shift count. */ 199*7c478bd9Sstevel@tonic-gate int64_t tcp_last_recv_time; /* Last time we receive a segment. */ 200*7c478bd9Sstevel@tonic-gate uint32_t tcp_init_cwnd; /* Initial cwnd (start/restart) */ 201*7c478bd9Sstevel@tonic-gate 202*7c478bd9Sstevel@tonic-gate /* 203*7c478bd9Sstevel@tonic-gate * Following socket options are set by sockfs outside the squeue 204*7c478bd9Sstevel@tonic-gate * and we want to separate these bit fields from the other bit fields 205*7c478bd9Sstevel@tonic-gate * set by TCP to avoid grabbing locks. sockfs ensures that only one 206*7c478bd9Sstevel@tonic-gate * thread in sockfs can set a socket option at a time on a conn_t. 207*7c478bd9Sstevel@tonic-gate * However TCP may read these options concurrently. The linger option 208*7c478bd9Sstevel@tonic-gate * needs atomicity since tcp_lingertime also needs to be in sync. 209*7c478bd9Sstevel@tonic-gate * However TCP uses it only during close, and by then no socket option 210*7c478bd9Sstevel@tonic-gate * can come down. So we don't need any locks, instead just separating 211*7c478bd9Sstevel@tonic-gate * the sockfs settable bit fields from the other bit fields is 212*7c478bd9Sstevel@tonic-gate * sufficient. 213*7c478bd9Sstevel@tonic-gate */ 214*7c478bd9Sstevel@tonic-gate uint32_t 215*7c478bd9Sstevel@tonic-gate tcp_debug : 1, /* SO_DEBUG "socket" option. */ 216*7c478bd9Sstevel@tonic-gate tcp_dontroute : 1, /* SO_DONTROUTE "socket" option. */ 217*7c478bd9Sstevel@tonic-gate tcp_broadcast : 1, /* SO_BROADCAST "socket" option. */ 218*7c478bd9Sstevel@tonic-gate tcp_useloopback : 1, /* SO_USELOOPBACK "socket" option. */ 219*7c478bd9Sstevel@tonic-gate 220*7c478bd9Sstevel@tonic-gate tcp_oobinline : 1, /* SO_OOBINLINE "socket" option. */ 221*7c478bd9Sstevel@tonic-gate tcp_dgram_errind : 1, /* SO_DGRAM_ERRIND option */ 222*7c478bd9Sstevel@tonic-gate tcp_linger : 1, /* SO_LINGER turned on */ 223*7c478bd9Sstevel@tonic-gate tcp_reuseaddr : 1, /* SO_REUSEADDR "socket" option. */ 224*7c478bd9Sstevel@tonic-gate 225*7c478bd9Sstevel@tonic-gate tcp_junk_to_bit_31 : 24; 226*7c478bd9Sstevel@tonic-gate 227*7c478bd9Sstevel@tonic-gate /* Following manipulated by TCP under squeue protection */ 228*7c478bd9Sstevel@tonic-gate uint32_t 229*7c478bd9Sstevel@tonic-gate tcp_urp_last_valid : 1, /* Is tcp_urp_last valid? */ 230*7c478bd9Sstevel@tonic-gate tcp_hard_binding : 1, /* If we've started a full bind */ 231*7c478bd9Sstevel@tonic-gate tcp_hard_bound : 1, /* If we've done a full bind with IP */ 232*7c478bd9Sstevel@tonic-gate tcp_fin_acked : 1, /* Has our FIN been acked? */ 233*7c478bd9Sstevel@tonic-gate 234*7c478bd9Sstevel@tonic-gate tcp_fin_rcvd : 1, /* Have we seen a FIN? */ 235*7c478bd9Sstevel@tonic-gate tcp_fin_sent : 1, /* Have we sent our FIN yet? */ 236*7c478bd9Sstevel@tonic-gate tcp_ordrel_done : 1, /* Have we sent the ord_rel upstream? */ 237*7c478bd9Sstevel@tonic-gate tcp_flow_stopped : 1, /* Have we flow controlled xmitter? */ 238*7c478bd9Sstevel@tonic-gate 239*7c478bd9Sstevel@tonic-gate tcp_detached : 1, /* If we're detached from a stream */ 240*7c478bd9Sstevel@tonic-gate tcp_bind_pending : 1, /* Client is waiting for bind ack */ 241*7c478bd9Sstevel@tonic-gate tcp_unbind_pending : 1, /* Client sent T_UNBIND_REQ */ 242*7c478bd9Sstevel@tonic-gate tcp_deferred_clean_death : 1, 243*7c478bd9Sstevel@tonic-gate /* defer tcp endpoint cleanup etc. */ 244*7c478bd9Sstevel@tonic-gate 245*7c478bd9Sstevel@tonic-gate tcp_conn_def_q0: 1, /* move from q0 to q deferred */ 246*7c478bd9Sstevel@tonic-gate tcp_ka_enabled: 1, /* Connection KeepAlive Timer needed */ 247*7c478bd9Sstevel@tonic-gate tcp_zero_win_probe: 1, /* Zero win probing is in progress */ 248*7c478bd9Sstevel@tonic-gate tcp_loopback: 1, /* src and dst are the same machine */ 249*7c478bd9Sstevel@tonic-gate 250*7c478bd9Sstevel@tonic-gate tcp_localnet: 1, /* src and dst are on the same subnet */ 251*7c478bd9Sstevel@tonic-gate tcp_syn_defense: 1, /* For defense against SYN attack */ 252*7c478bd9Sstevel@tonic-gate #define tcp_dontdrop tcp_syn_defense 253*7c478bd9Sstevel@tonic-gate tcp_set_timer : 1, 254*7c478bd9Sstevel@tonic-gate tcp_active_open: 1, /* This is a active open */ 255*7c478bd9Sstevel@tonic-gate 256*7c478bd9Sstevel@tonic-gate tcp_timeout : 1, /* qbufcall failed, qtimeout pending */ 257*7c478bd9Sstevel@tonic-gate tcp_rexmit : 1, /* TCP is retransmitting */ 258*7c478bd9Sstevel@tonic-gate tcp_snd_sack_ok : 1, /* Can use SACK for this connection */ 259*7c478bd9Sstevel@tonic-gate tcp_empty_flag : 1, /* Empty flag for future use */ 260*7c478bd9Sstevel@tonic-gate 261*7c478bd9Sstevel@tonic-gate tcp_recvdstaddr : 1, /* return T_EXTCONN_IND with dst addr */ 262*7c478bd9Sstevel@tonic-gate tcp_hwcksum : 1, /* The NIC is capable of hwcksum */ 263*7c478bd9Sstevel@tonic-gate tcp_ip_forward_progress : 1, 264*7c478bd9Sstevel@tonic-gate tcp_anon_priv_bind : 1, 265*7c478bd9Sstevel@tonic-gate 266*7c478bd9Sstevel@tonic-gate tcp_ecn_ok : 1, /* Can use ECN for this connection */ 267*7c478bd9Sstevel@tonic-gate tcp_ecn_echo_on : 1, /* Need to do ECN echo */ 268*7c478bd9Sstevel@tonic-gate tcp_ecn_cwr_sent : 1, /* ECN_CWR has been sent */ 269*7c478bd9Sstevel@tonic-gate tcp_cwr : 1; /* Cwnd has reduced recently */ 270*7c478bd9Sstevel@tonic-gate 271*7c478bd9Sstevel@tonic-gate /* Following manipulated by TCP under squeue protection */ 272*7c478bd9Sstevel@tonic-gate uint32_t 273*7c478bd9Sstevel@tonic-gate tcp_mdt : 1, /* Lower layer is capable of MDT */ 274*7c478bd9Sstevel@tonic-gate tcp_snd_ts_ok : 1, 275*7c478bd9Sstevel@tonic-gate tcp_snd_ws_ok : 1, 276*7c478bd9Sstevel@tonic-gate tcp_exclbind : 1, /* ``exclusive'' binding */ 277*7c478bd9Sstevel@tonic-gate 278*7c478bd9Sstevel@tonic-gate tcp_reserved_port : 1, 279*7c478bd9Sstevel@tonic-gate tcp_hdr_grown : 1, 280*7c478bd9Sstevel@tonic-gate tcp_in_free_list : 1, 281*7c478bd9Sstevel@tonic-gate tcp_snd_zcopy_on : 1, /* xmit zero-copy enabled */ 282*7c478bd9Sstevel@tonic-gate 283*7c478bd9Sstevel@tonic-gate tcp_snd_zcopy_aware : 1, /* client is zero-copy aware */ 284*7c478bd9Sstevel@tonic-gate tcp_xmit_zc_clean : 1, /* the xmit list is free of zc-mblk */ 285*7c478bd9Sstevel@tonic-gate tcp_wait_for_eagers : 1, /* Wait for eagers to disappear */ 286*7c478bd9Sstevel@tonic-gate tcp_accept_error : 1, /* Error during TLI accept */ 287*7c478bd9Sstevel@tonic-gate 288*7c478bd9Sstevel@tonic-gate tcp_send_discon_ind : 1, /* TLI accept err, send discon ind */ 289*7c478bd9Sstevel@tonic-gate tcp_fused : 1, /* loopback tcp in fusion mode */ 290*7c478bd9Sstevel@tonic-gate tcp_unfusable : 1, /* fusion not allowed on endpoint */ 291*7c478bd9Sstevel@tonic-gate tcp_fused_sigurg : 1, /* send SIGURG upon draining */ 292*7c478bd9Sstevel@tonic-gate tcp_cork : 1, /* tcp_cork option */ 293*7c478bd9Sstevel@tonic-gate tcp_pad_to_bit_31 : 15; 294*7c478bd9Sstevel@tonic-gate 295*7c478bd9Sstevel@tonic-gate uint32_t tcp_if_mtu; /* Outgoing interface MTU. */ 296*7c478bd9Sstevel@tonic-gate 297*7c478bd9Sstevel@tonic-gate mblk_t *tcp_reass_head; /* Out of order reassembly list head */ 298*7c478bd9Sstevel@tonic-gate mblk_t *tcp_reass_tail; /* Out of order reassembly list tail */ 299*7c478bd9Sstevel@tonic-gate 300*7c478bd9Sstevel@tonic-gate tcp_sack_info_t *tcp_sack_info; 301*7c478bd9Sstevel@tonic-gate 302*7c478bd9Sstevel@tonic-gate #define tcp_pipe tcp_sack_info->tcp_pipe 303*7c478bd9Sstevel@tonic-gate #define tcp_fack tcp_sack_info->tcp_fack 304*7c478bd9Sstevel@tonic-gate #define tcp_sack_snxt tcp_sack_info->tcp_sack_snxt 305*7c478bd9Sstevel@tonic-gate #define tcp_max_sack_blk tcp_sack_info->tcp_max_sack_blk 306*7c478bd9Sstevel@tonic-gate #define tcp_num_sack_blk tcp_sack_info->tcp_num_sack_blk 307*7c478bd9Sstevel@tonic-gate #define tcp_sack_list tcp_sack_info->tcp_sack_list 308*7c478bd9Sstevel@tonic-gate #define tcp_num_notsack_blk tcp_sack_info->tcp_num_notsack_blk 309*7c478bd9Sstevel@tonic-gate #define tcp_cnt_notsack_list tcp_sack_info->tcp_cnt_notsack_list 310*7c478bd9Sstevel@tonic-gate #define tcp_notsack_list tcp_sack_info->tcp_notsack_list 311*7c478bd9Sstevel@tonic-gate 312*7c478bd9Sstevel@tonic-gate mblk_t *tcp_rcv_list; /* Queued until push, urgent data, */ 313*7c478bd9Sstevel@tonic-gate mblk_t *tcp_rcv_last_head; /* optdata, or the count exceeds */ 314*7c478bd9Sstevel@tonic-gate mblk_t *tcp_rcv_last_tail; /* tcp_rcv_push_wait. */ 315*7c478bd9Sstevel@tonic-gate uint32_t tcp_rcv_cnt; /* tcp_rcv_list is b_next chain. */ 316*7c478bd9Sstevel@tonic-gate 317*7c478bd9Sstevel@tonic-gate uint32_t tcp_cwnd_ssthresh; /* Congestion window */ 318*7c478bd9Sstevel@tonic-gate uint32_t tcp_cwnd_max; 319*7c478bd9Sstevel@tonic-gate uint32_t tcp_csuna; /* Clear (no rexmits in window) suna */ 320*7c478bd9Sstevel@tonic-gate 321*7c478bd9Sstevel@tonic-gate clock_t tcp_rtt_sa; /* Round trip smoothed average */ 322*7c478bd9Sstevel@tonic-gate clock_t tcp_rtt_sd; /* Round trip smoothed deviation */ 323*7c478bd9Sstevel@tonic-gate clock_t tcp_rtt_update; /* Round trip update(s) */ 324*7c478bd9Sstevel@tonic-gate clock_t tcp_ms_we_have_waited; /* Total retrans time */ 325*7c478bd9Sstevel@tonic-gate 326*7c478bd9Sstevel@tonic-gate uint32_t tcp_swl1; /* These help us avoid using stale */ 327*7c478bd9Sstevel@tonic-gate uint32_t tcp_swl2; /* packets to update state */ 328*7c478bd9Sstevel@tonic-gate 329*7c478bd9Sstevel@tonic-gate uint32_t tcp_rack; /* Seq # we have acked */ 330*7c478bd9Sstevel@tonic-gate uint32_t tcp_rack_cnt; /* # of segs we have deferred ack */ 331*7c478bd9Sstevel@tonic-gate uint32_t tcp_rack_cur_max; /* # of segs we may defer ack for now */ 332*7c478bd9Sstevel@tonic-gate uint32_t tcp_rack_abs_max; /* # of segs we may defer ack ever */ 333*7c478bd9Sstevel@tonic-gate timeout_id_t tcp_ack_tid; /* Delayed ACK timer ID */ 334*7c478bd9Sstevel@tonic-gate timeout_id_t tcp_push_tid; /* Push timer ID */ 335*7c478bd9Sstevel@tonic-gate 336*7c478bd9Sstevel@tonic-gate uint32_t tcp_max_swnd; /* Maximum swnd we have seen */ 337*7c478bd9Sstevel@tonic-gate 338*7c478bd9Sstevel@tonic-gate struct tcp_s *tcp_listener; /* Our listener */ 339*7c478bd9Sstevel@tonic-gate 340*7c478bd9Sstevel@tonic-gate int32_t tcp_xmit_lowater; /* Send buffer low water mark. */ 341*7c478bd9Sstevel@tonic-gate 342*7c478bd9Sstevel@tonic-gate uint32_t tcp_irs; /* Initial recv seq num */ 343*7c478bd9Sstevel@tonic-gate uint32_t tcp_fss; /* Final/fin send seq num */ 344*7c478bd9Sstevel@tonic-gate uint32_t tcp_urg; /* Urgent data seq num */ 345*7c478bd9Sstevel@tonic-gate 346*7c478bd9Sstevel@tonic-gate clock_t tcp_first_timer_threshold; /* When to prod IP */ 347*7c478bd9Sstevel@tonic-gate clock_t tcp_second_timer_threshold; /* When to give up completely */ 348*7c478bd9Sstevel@tonic-gate clock_t tcp_first_ctimer_threshold; /* 1st threshold while connecting */ 349*7c478bd9Sstevel@tonic-gate clock_t tcp_second_ctimer_threshold; /* 2nd ... while connecting */ 350*7c478bd9Sstevel@tonic-gate 351*7c478bd9Sstevel@tonic-gate int tcp_lingertime; /* Close linger time (in seconds) */ 352*7c478bd9Sstevel@tonic-gate 353*7c478bd9Sstevel@tonic-gate uint32_t tcp_urp_last; /* Last urp for which signal sent */ 354*7c478bd9Sstevel@tonic-gate mblk_t *tcp_urp_mp; /* T_EXDATA_IND for urgent byte */ 355*7c478bd9Sstevel@tonic-gate mblk_t *tcp_urp_mark_mp; /* zero-length marked/unmarked msg */ 356*7c478bd9Sstevel@tonic-gate 357*7c478bd9Sstevel@tonic-gate int tcp_conn_req_cnt_q0; /* # of conn reqs in SYN_RCVD */ 358*7c478bd9Sstevel@tonic-gate int tcp_conn_req_cnt_q; /* # of conn reqs in ESTABLISHED */ 359*7c478bd9Sstevel@tonic-gate int tcp_conn_req_max; /* # of ESTABLISHED conn reqs allowed */ 360*7c478bd9Sstevel@tonic-gate t_scalar_t tcp_conn_req_seqnum; /* Incrementing pending conn req ID */ 361*7c478bd9Sstevel@tonic-gate #define tcp_ip_addr_cache tcp_reass_tail 362*7c478bd9Sstevel@tonic-gate /* Cache ip addresses that */ 363*7c478bd9Sstevel@tonic-gate /* complete the 3-way handshake */ 364*7c478bd9Sstevel@tonic-gate kmutex_t tcp_eager_lock; 365*7c478bd9Sstevel@tonic-gate struct tcp_s *tcp_eager_next_q; /* next eager in ESTABLISHED state */ 366*7c478bd9Sstevel@tonic-gate struct tcp_s *tcp_eager_last_q; /* last eager in ESTABLISHED state */ 367*7c478bd9Sstevel@tonic-gate struct tcp_s *tcp_eager_next_q0; /* next eager in SYN_RCVD state */ 368*7c478bd9Sstevel@tonic-gate struct tcp_s *tcp_eager_prev_q0; /* prev eager in SYN_RCVD state */ 369*7c478bd9Sstevel@tonic-gate /* all eagers form a circular list */ 370*7c478bd9Sstevel@tonic-gate union { 371*7c478bd9Sstevel@tonic-gate mblk_t *tcp_eager_conn_ind; /* T_CONN_IND waiting for 3rd ack. */ 372*7c478bd9Sstevel@tonic-gate mblk_t *tcp_opts_conn_req; /* T_CONN_REQ w/ options processed */ 373*7c478bd9Sstevel@tonic-gate } tcp_conn; 374*7c478bd9Sstevel@tonic-gate uint32_t tcp_syn_rcvd_timeout; /* How many SYN_RCVD timeout in q0 */ 375*7c478bd9Sstevel@tonic-gate 376*7c478bd9Sstevel@tonic-gate /* TCP Keepalive Timer members */ 377*7c478bd9Sstevel@tonic-gate int32_t tcp_ka_last_intrvl; /* Last probe interval */ 378*7c478bd9Sstevel@tonic-gate timeout_id_t tcp_ka_tid; /* Keepalive timer ID */ 379*7c478bd9Sstevel@tonic-gate uint32_t tcp_ka_interval; /* Keepalive interval */ 380*7c478bd9Sstevel@tonic-gate uint32_t tcp_ka_abort_thres; /* Keepalive abort threshold */ 381*7c478bd9Sstevel@tonic-gate 382*7c478bd9Sstevel@tonic-gate int32_t tcp_client_errno; /* How the client screwed up */ 383*7c478bd9Sstevel@tonic-gate 384*7c478bd9Sstevel@tonic-gate char *tcp_iphc; /* Buffer holding tcp/ip hdr template */ 385*7c478bd9Sstevel@tonic-gate int tcp_iphc_len; /* actual allocated buffer size */ 386*7c478bd9Sstevel@tonic-gate int32_t tcp_hdr_len; /* Byte len of combined TCP/IP hdr */ 387*7c478bd9Sstevel@tonic-gate ipha_t *tcp_ipha; /* IPv4 header in the buffer */ 388*7c478bd9Sstevel@tonic-gate ip6_t *tcp_ip6h; /* IPv6 header in the buffer */ 389*7c478bd9Sstevel@tonic-gate int tcp_ip_hdr_len; /* Byte len of our current IPvx hdr */ 390*7c478bd9Sstevel@tonic-gate tcph_t *tcp_tcph; /* tcp header within combined hdr */ 391*7c478bd9Sstevel@tonic-gate int32_t tcp_tcp_hdr_len; /* tcp header len within combined */ 392*7c478bd9Sstevel@tonic-gate 393*7c478bd9Sstevel@tonic-gate uint32_t tcp_sum; /* checksum to compensate for source */ 394*7c478bd9Sstevel@tonic-gate /* routed packets. Host byte order */ 395*7c478bd9Sstevel@tonic-gate uint16_t tcp_last_sent_len; /* Record length for nagle */ 396*7c478bd9Sstevel@tonic-gate uint16_t tcp_dupack_cnt; /* # of consequtive duplicate acks */ 397*7c478bd9Sstevel@tonic-gate 398*7c478bd9Sstevel@tonic-gate kmutex_t *tcp_acceptor_lockp; /* Ptr to tf_lock */ 399*7c478bd9Sstevel@tonic-gate 400*7c478bd9Sstevel@tonic-gate timeout_id_t tcp_ordrelid; /* qbufcall/qtimeout id */ 401*7c478bd9Sstevel@tonic-gate t_uscalar_t tcp_acceptor_id; /* ACCEPTOR_id */ 402*7c478bd9Sstevel@tonic-gate 403*7c478bd9Sstevel@tonic-gate int tcp_ipsec_overhead; 404*7c478bd9Sstevel@tonic-gate /* 405*7c478bd9Sstevel@tonic-gate * Address family that app wishes returned addrsses to be in. 406*7c478bd9Sstevel@tonic-gate * Currently taken from address family used in T_BIND_REQ, but 407*7c478bd9Sstevel@tonic-gate * should really come from family used in original socket() call. 408*7c478bd9Sstevel@tonic-gate * Value can be AF_INET or AF_INET6. 409*7c478bd9Sstevel@tonic-gate */ 410*7c478bd9Sstevel@tonic-gate uint_t tcp_family; 411*7c478bd9Sstevel@tonic-gate /* 412*7c478bd9Sstevel@tonic-gate * used for a quick test to determine if any ancillary bits are 413*7c478bd9Sstevel@tonic-gate * set 414*7c478bd9Sstevel@tonic-gate */ 415*7c478bd9Sstevel@tonic-gate uint_t tcp_ipv6_recvancillary; /* Flags */ 416*7c478bd9Sstevel@tonic-gate #define TCP_IPV6_RECVPKTINFO 0x01 /* IPV6_RECVPKTINFO option */ 417*7c478bd9Sstevel@tonic-gate #define TCP_IPV6_RECVHOPLIMIT 0x02 /* IPV6_RECVHOPLIMIT option */ 418*7c478bd9Sstevel@tonic-gate #define TCP_IPV6_RECVHOPOPTS 0x04 /* IPV6_RECVHOPOPTS option */ 419*7c478bd9Sstevel@tonic-gate #define TCP_IPV6_RECVDSTOPTS 0x08 /* IPV6_RECVDSTOPTS option */ 420*7c478bd9Sstevel@tonic-gate #define TCP_IPV6_RECVRTHDR 0x10 /* IPV6_RECVRTHDR option */ 421*7c478bd9Sstevel@tonic-gate #define TCP_IPV6_RECVRTDSTOPTS 0x20 /* IPV6_RECVRTHDRDSTOPTS option */ 422*7c478bd9Sstevel@tonic-gate #define TCP_IPV6_RECVTCLASS 0x40 /* IPV6_RECVTCLASS option */ 423*7c478bd9Sstevel@tonic-gate #define TCP_OLD_IPV6_RECVDSTOPTS 0x80 /* old IPV6_RECVDSTOPTS option */ 424*7c478bd9Sstevel@tonic-gate 425*7c478bd9Sstevel@tonic-gate uint_t tcp_recvifindex; /* Last received IPV6_RCVPKTINFO */ 426*7c478bd9Sstevel@tonic-gate uint_t tcp_recvhops; /* Last received IPV6_RECVHOPLIMIT */ 427*7c478bd9Sstevel@tonic-gate uint_t tcp_recvtclass; /* Last received IPV6_RECVTCLASS */ 428*7c478bd9Sstevel@tonic-gate ip6_hbh_t *tcp_hopopts; /* Last received IPV6_RECVHOPOPTS */ 429*7c478bd9Sstevel@tonic-gate ip6_dest_t *tcp_dstopts; /* Last received IPV6_RECVDSTOPTS */ 430*7c478bd9Sstevel@tonic-gate ip6_dest_t *tcp_rtdstopts; /* Last recvd IPV6_RECVRTHDRDSTOPTS */ 431*7c478bd9Sstevel@tonic-gate ip6_rthdr_t *tcp_rthdr; /* Last received IPV6_RECVRTHDR */ 432*7c478bd9Sstevel@tonic-gate uint_t tcp_hopoptslen; 433*7c478bd9Sstevel@tonic-gate uint_t tcp_dstoptslen; 434*7c478bd9Sstevel@tonic-gate uint_t tcp_rtdstoptslen; 435*7c478bd9Sstevel@tonic-gate uint_t tcp_rthdrlen; 436*7c478bd9Sstevel@tonic-gate 437*7c478bd9Sstevel@tonic-gate mblk_t *tcp_timercache; 438*7c478bd9Sstevel@tonic-gate cred_t *tcp_cred; /* Credentials when this was opened */ 439*7c478bd9Sstevel@tonic-gate pid_t tcp_cpid; /* Process id when this was opened */ 440*7c478bd9Sstevel@tonic-gate 441*7c478bd9Sstevel@tonic-gate 442*7c478bd9Sstevel@tonic-gate union { 443*7c478bd9Sstevel@tonic-gate struct { 444*7c478bd9Sstevel@tonic-gate uchar_t v4_ttl; 445*7c478bd9Sstevel@tonic-gate /* Dup of tcp_ipha.iph_type_of_service */ 446*7c478bd9Sstevel@tonic-gate uchar_t v4_tos; /* Dup of tcp_ipha.iph_ttl */ 447*7c478bd9Sstevel@tonic-gate } v4_hdr_info; 448*7c478bd9Sstevel@tonic-gate struct { 449*7c478bd9Sstevel@tonic-gate uint_t v6_vcf; /* Dup of tcp_ip6h.ip6h_vcf */ 450*7c478bd9Sstevel@tonic-gate uchar_t v6_hops; /* Dup of tcp_ip6h.ip6h_hops */ 451*7c478bd9Sstevel@tonic-gate } v6_hdr_info; 452*7c478bd9Sstevel@tonic-gate } tcp_hdr_info; 453*7c478bd9Sstevel@tonic-gate #define tcp_ttl tcp_hdr_info.v4_hdr_info.v4_ttl 454*7c478bd9Sstevel@tonic-gate #define tcp_tos tcp_hdr_info.v4_hdr_info.v4_tos 455*7c478bd9Sstevel@tonic-gate #define tcp_ip6_vcf tcp_hdr_info.v6_hdr_info.v6_vcf 456*7c478bd9Sstevel@tonic-gate #define tcp_ip6_hops tcp_hdr_info.v6_hdr_info.v6_hops 457*7c478bd9Sstevel@tonic-gate 458*7c478bd9Sstevel@tonic-gate ushort_t tcp_ipversion; 459*7c478bd9Sstevel@tonic-gate uint_t tcp_bound_if; /* IPV6_BOUND_IF */ 460*7c478bd9Sstevel@tonic-gate 461*7c478bd9Sstevel@tonic-gate #define tcp_lport tcp_connp->conn_lport 462*7c478bd9Sstevel@tonic-gate #define tcp_fport tcp_connp->conn_fport 463*7c478bd9Sstevel@tonic-gate #define tcp_ports tcp_connp->conn_ports 464*7c478bd9Sstevel@tonic-gate 465*7c478bd9Sstevel@tonic-gate #define tcp_remote tcp_connp->conn_rem 466*7c478bd9Sstevel@tonic-gate #define tcp_ip_src tcp_connp->conn_src 467*7c478bd9Sstevel@tonic-gate 468*7c478bd9Sstevel@tonic-gate #define tcp_remote_v6 tcp_connp->conn_remv6 469*7c478bd9Sstevel@tonic-gate #define tcp_ip_src_v6 tcp_connp->conn_srcv6 470*7c478bd9Sstevel@tonic-gate #define tcp_bound_source_v6 tcp_connp->conn_bound_source_v6 471*7c478bd9Sstevel@tonic-gate #define tcp_bound_source tcp_connp->conn_bound_source 472*7c478bd9Sstevel@tonic-gate 473*7c478bd9Sstevel@tonic-gate kmutex_t tcp_closelock; 474*7c478bd9Sstevel@tonic-gate kcondvar_t tcp_closecv; 475*7c478bd9Sstevel@tonic-gate uint8_t tcp_closed; 476*7c478bd9Sstevel@tonic-gate uint8_t tcp_closeflags; 477*7c478bd9Sstevel@tonic-gate uint8_t tcp_cleandeathtag; 478*7c478bd9Sstevel@tonic-gate mblk_t tcp_closemp; 479*7c478bd9Sstevel@tonic-gate timeout_id_t tcp_linger_tid; /* Linger timer ID */ 480*7c478bd9Sstevel@tonic-gate void *tcp_tracebuf; 481*7c478bd9Sstevel@tonic-gate 482*7c478bd9Sstevel@tonic-gate struct tcp_s *tcp_acceptor_hash; /* Acceptor hash chain */ 483*7c478bd9Sstevel@tonic-gate struct tcp_s **tcp_ptpahn; /* Pointer to previous accept hash next. */ 484*7c478bd9Sstevel@tonic-gate struct tcp_s *tcp_bind_hash; /* Bind hash chain */ 485*7c478bd9Sstevel@tonic-gate struct tcp_s **tcp_ptpbhn; 486*7c478bd9Sstevel@tonic-gate 487*7c478bd9Sstevel@tonic-gate boolean_t tcp_ire_ill_check_done; 488*7c478bd9Sstevel@tonic-gate uint_t tcp_maxpsz; 489*7c478bd9Sstevel@tonic-gate 490*7c478bd9Sstevel@tonic-gate /* 491*7c478bd9Sstevel@tonic-gate * used for Multidata Transmit 492*7c478bd9Sstevel@tonic-gate */ 493*7c478bd9Sstevel@tonic-gate uint_t tcp_mdt_hdr_head; /* leading header fragment extra space */ 494*7c478bd9Sstevel@tonic-gate uint_t tcp_mdt_hdr_tail; /* trailing header fragment extra space */ 495*7c478bd9Sstevel@tonic-gate int tcp_mdt_max_pld; /* maximum payload buffers per Multidata */ 496*7c478bd9Sstevel@tonic-gate 497*7c478bd9Sstevel@tonic-gate uint32_t tcp_ofo_fin_seq; /* Recv out of order FIN seq num */ 498*7c478bd9Sstevel@tonic-gate uint32_t tcp_cwr_snd_max; 499*7c478bd9Sstevel@tonic-gate uint_t tcp_drop_opt_ack_cnt; /* # tcp generated optmgmt */ 500*7c478bd9Sstevel@tonic-gate ip6_pkt_t tcp_sticky_ipp; /* Sticky options */ 501*7c478bd9Sstevel@tonic-gate #define tcp_ipp_fields tcp_sticky_ipp.ipp_fields /* valid fields */ 502*7c478bd9Sstevel@tonic-gate #define tcp_ipp_ifindex tcp_sticky_ipp.ipp_ifindex /* pktinfo ifindex */ 503*7c478bd9Sstevel@tonic-gate #define tcp_ipp_addr tcp_sticky_ipp.ipp_addr /* pktinfo src/dst addr */ 504*7c478bd9Sstevel@tonic-gate #define tcp_ipp_hoplimit tcp_sticky_ipp.ipp_hoplimit 505*7c478bd9Sstevel@tonic-gate #define tcp_ipp_hopoptslen tcp_sticky_ipp.ipp_hopoptslen 506*7c478bd9Sstevel@tonic-gate #define tcp_ipp_rtdstoptslen tcp_sticky_ipp.ipp_rtdstoptslen 507*7c478bd9Sstevel@tonic-gate #define tcp_ipp_rthdrlen tcp_sticky_ipp.ipp_rthdrlen 508*7c478bd9Sstevel@tonic-gate #define tcp_ipp_dstoptslen tcp_sticky_ipp.ipp_dstoptslen 509*7c478bd9Sstevel@tonic-gate #define tcp_ipp_hopopts tcp_sticky_ipp.ipp_hopopts 510*7c478bd9Sstevel@tonic-gate #define tcp_ipp_rtdstopts tcp_sticky_ipp.ipp_rtdstopts 511*7c478bd9Sstevel@tonic-gate #define tcp_ipp_rthdr tcp_sticky_ipp.ipp_rthdr 512*7c478bd9Sstevel@tonic-gate #define tcp_ipp_dstopts tcp_sticky_ipp.ipp_dstopts 513*7c478bd9Sstevel@tonic-gate #define tcp_ipp_nexthop tcp_sticky_ipp.ipp_nexthop 514*7c478bd9Sstevel@tonic-gate #define tcp_ipp_use_min_mtu tcp_sticky_ipp.ipp_use_min_mtu 515*7c478bd9Sstevel@tonic-gate struct tcp_s *tcp_saved_listener; /* saved value of listener */ 516*7c478bd9Sstevel@tonic-gate 517*7c478bd9Sstevel@tonic-gate struct tcp_s *tcp_loopback_peer; /* peer tcp for loopback */ 518*7c478bd9Sstevel@tonic-gate mblk_t *tcp_fused_sigurg_mp; /* M_PCSIG mblk for SIGURG */ 519*7c478bd9Sstevel@tonic-gate 520*7c478bd9Sstevel@tonic-gate uint32_t tcp_in_ack_unsent; /* ACK for unsent data cnt. */ 521*7c478bd9Sstevel@tonic-gate 522*7c478bd9Sstevel@tonic-gate /* 523*7c478bd9Sstevel@tonic-gate * This variable is accessed without any lock protection 524*7c478bd9Sstevel@tonic-gate * and therefore must not be declared as a bit field along 525*7c478bd9Sstevel@tonic-gate * with the rest which require such condition. 526*7c478bd9Sstevel@tonic-gate */ 527*7c478bd9Sstevel@tonic-gate boolean_t tcp_issocket; /* this is a socket tcp */ 528*7c478bd9Sstevel@tonic-gate } tcp_t; 529*7c478bd9Sstevel@tonic-gate 530*7c478bd9Sstevel@tonic-gate extern void tcp_free(tcp_t *tcp); 531*7c478bd9Sstevel@tonic-gate extern void tcp_ddi_init(void); 532*7c478bd9Sstevel@tonic-gate extern void tcp_ddi_destroy(void); 533*7c478bd9Sstevel@tonic-gate extern void tcp_xmit_listeners_reset(mblk_t *mp, uint_t ip_hdr_len); 534*7c478bd9Sstevel@tonic-gate extern void tcp_conn_request(void *arg, mblk_t *mp, void *arg2); 535*7c478bd9Sstevel@tonic-gate extern void tcp_conn_request_unbound(void *arg, mblk_t *mp, void *arg2); 536*7c478bd9Sstevel@tonic-gate extern void tcp_input(void *arg, mblk_t *mp, void *arg2); 537*7c478bd9Sstevel@tonic-gate extern void tcp_rput_data(void *arg, mblk_t *mp, void *arg2); 538*7c478bd9Sstevel@tonic-gate extern void *tcp_get_conn(void *arg); 539*7c478bd9Sstevel@tonic-gate extern void tcp_time_wait_collector(void *arg); 540*7c478bd9Sstevel@tonic-gate 541*7c478bd9Sstevel@tonic-gate /* 542*7c478bd9Sstevel@tonic-gate * The TCP Fanout structure. 543*7c478bd9Sstevel@tonic-gate * The hash tables and their linkage (tcp_*_hash_next, tcp_ptp*hn) are 544*7c478bd9Sstevel@tonic-gate * protected by the per-bucket tf_lock. Each tcp_t 545*7c478bd9Sstevel@tonic-gate * inserted in the list points back at this lock using tcp_*_lockp. 546*7c478bd9Sstevel@tonic-gate * 547*7c478bd9Sstevel@tonic-gate * The listener and acceptor hash queues are lists of tcp_t. 548*7c478bd9Sstevel@tonic-gate */ 549*7c478bd9Sstevel@tonic-gate 550*7c478bd9Sstevel@tonic-gate /* listener hash and acceptor hash queue head */ 551*7c478bd9Sstevel@tonic-gate typedef struct tf_s { 552*7c478bd9Sstevel@tonic-gate tcp_t *tf_tcp; 553*7c478bd9Sstevel@tonic-gate kmutex_t tf_lock; 554*7c478bd9Sstevel@tonic-gate } tf_t; 555*7c478bd9Sstevel@tonic-gate 556*7c478bd9Sstevel@tonic-gate extern mib2_tcp_t tcp_mib; 557*7c478bd9Sstevel@tonic-gate 558*7c478bd9Sstevel@tonic-gate #endif /* (defined(_KERNEL) || defined(_KMEMUSER)) */ 559*7c478bd9Sstevel@tonic-gate 560*7c478bd9Sstevel@tonic-gate /* Contract private interface between TCP and Clustering. */ 561*7c478bd9Sstevel@tonic-gate 562*7c478bd9Sstevel@tonic-gate #define CL_TCPI_V1 1 /* cl_tcpi_version number */ 563*7c478bd9Sstevel@tonic-gate 564*7c478bd9Sstevel@tonic-gate typedef struct cl_tcp_info_s { 565*7c478bd9Sstevel@tonic-gate ushort_t cl_tcpi_version; /* cl_tcp_info_t's version no */ 566*7c478bd9Sstevel@tonic-gate ushort_t cl_tcpi_ipversion; /* IP version */ 567*7c478bd9Sstevel@tonic-gate int32_t cl_tcpi_state; /* TCP state */ 568*7c478bd9Sstevel@tonic-gate in_port_t cl_tcpi_lport; /* Local port */ 569*7c478bd9Sstevel@tonic-gate in_port_t cl_tcpi_fport; /* Remote port */ 570*7c478bd9Sstevel@tonic-gate in6_addr_t cl_tcpi_laddr_v6; /* Local IP address */ 571*7c478bd9Sstevel@tonic-gate in6_addr_t cl_tcpi_faddr_v6; /* Remote IP address */ 572*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 573*7c478bd9Sstevel@tonic-gate /* Note: V4_PART_OF_V6 is meant to be used only for _KERNEL defined stuff */ 574*7c478bd9Sstevel@tonic-gate #define cl_tcpi_laddr V4_PART_OF_V6(cl_tcpi_laddr_v6) 575*7c478bd9Sstevel@tonic-gate #define cl_tcpi_faddr V4_PART_OF_V6(cl_tcpi_faddr_v6) 576*7c478bd9Sstevel@tonic-gate 577*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 578*7c478bd9Sstevel@tonic-gate } cl_tcp_info_t; 579*7c478bd9Sstevel@tonic-gate 580*7c478bd9Sstevel@tonic-gate /* 581*7c478bd9Sstevel@tonic-gate * Hook functions to enable cluster networking 582*7c478bd9Sstevel@tonic-gate * On non-clustered systems these vectors must always be NULL. 583*7c478bd9Sstevel@tonic-gate */ 584*7c478bd9Sstevel@tonic-gate 585*7c478bd9Sstevel@tonic-gate extern void (*cl_inet_listen)(uint8_t, sa_family_t, uint8_t *, in_port_t); 586*7c478bd9Sstevel@tonic-gate extern void (*cl_inet_unlisten)(uint8_t, sa_family_t, uint8_t *, 587*7c478bd9Sstevel@tonic-gate in_port_t); 588*7c478bd9Sstevel@tonic-gate 589*7c478bd9Sstevel@tonic-gate /* 590*7c478bd9Sstevel@tonic-gate * Contracted Consolidation Private ioctl for aborting TCP connections. 591*7c478bd9Sstevel@tonic-gate * In order to keep the offsets and size of the structure the same between 592*7c478bd9Sstevel@tonic-gate * a 32-bit application and a 64-bit amd64 kernel, we use a #pragma 593*7c478bd9Sstevel@tonic-gate * pack(4). 594*7c478bd9Sstevel@tonic-gate */ 595*7c478bd9Sstevel@tonic-gate #define TCP_IOC_ABORT_CONN (('T' << 8) + 91) 596*7c478bd9Sstevel@tonic-gate 597*7c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 598*7c478bd9Sstevel@tonic-gate #pragma pack(4) 599*7c478bd9Sstevel@tonic-gate #endif 600*7c478bd9Sstevel@tonic-gate 601*7c478bd9Sstevel@tonic-gate typedef struct tcp_ioc_abort_conn_s { 602*7c478bd9Sstevel@tonic-gate struct sockaddr_storage ac_local; /* local addr and port */ 603*7c478bd9Sstevel@tonic-gate struct sockaddr_storage ac_remote; /* remote addr and port */ 604*7c478bd9Sstevel@tonic-gate int32_t ac_start; /* start state */ 605*7c478bd9Sstevel@tonic-gate int32_t ac_end; /* end state */ 606*7c478bd9Sstevel@tonic-gate int32_t ac_zoneid; /* zoneid */ 607*7c478bd9Sstevel@tonic-gate } tcp_ioc_abort_conn_t; 608*7c478bd9Sstevel@tonic-gate 609*7c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 610*7c478bd9Sstevel@tonic-gate #pragma pack() 611*7c478bd9Sstevel@tonic-gate #endif 612*7c478bd9Sstevel@tonic-gate 613*7c478bd9Sstevel@tonic-gate /* Named Dispatch Parameter Management Structure */ 614*7c478bd9Sstevel@tonic-gate typedef struct tcpparam_s { 615*7c478bd9Sstevel@tonic-gate uint32_t tcp_param_min; 616*7c478bd9Sstevel@tonic-gate uint32_t tcp_param_max; 617*7c478bd9Sstevel@tonic-gate uint32_t tcp_param_val; 618*7c478bd9Sstevel@tonic-gate char *tcp_param_name; 619*7c478bd9Sstevel@tonic-gate } tcpparam_t; 620*7c478bd9Sstevel@tonic-gate 621*7c478bd9Sstevel@tonic-gate extern tcpparam_t tcp_param_arr[]; 622*7c478bd9Sstevel@tonic-gate 623*7c478bd9Sstevel@tonic-gate extern boolean_t do_tcp_fusion; 624*7c478bd9Sstevel@tonic-gate 625*7c478bd9Sstevel@tonic-gate #if (defined(_KERNEL) || defined(_KMEMUSER)) 626*7c478bd9Sstevel@tonic-gate extern void tcp_rput_other(tcp_t *tcp, mblk_t *mp); 627*7c478bd9Sstevel@tonic-gate #endif 628*7c478bd9Sstevel@tonic-gate 629*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 630*7c478bd9Sstevel@tonic-gate } 631*7c478bd9Sstevel@tonic-gate #endif 632*7c478bd9Sstevel@tonic-gate 633*7c478bd9Sstevel@tonic-gate #endif /* _INET_TCP_H */ 634