1 0 stevel /* 2 0 stevel * CDDL HEADER START 3 0 stevel * 4 0 stevel * The contents of this file are subject to the terms of the 5 1676 jpk * Common Development and Distribution License (the "License"). 6 1676 jpk * You may not use this file except in compliance with the License. 7 0 stevel * 8 0 stevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 0 stevel * or http://www.opensolaris.org/os/licensing. 10 0 stevel * See the License for the specific language governing permissions 11 0 stevel * and limitations under the License. 12 0 stevel * 13 0 stevel * When distributing Covered Code, include this CDDL HEADER in each 14 0 stevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 0 stevel * If applicable, add the following below this CDDL HEADER, with the 16 0 stevel * fields enclosed by brackets "[]" replaced with your own identifying 17 0 stevel * information: Portions Copyright [yyyy] [name of copyright owner] 18 0 stevel * 19 0 stevel * CDDL HEADER END 20 0 stevel */ 21 0 stevel /* 22 8951 Phil * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 0 stevel * Use is subject to license terms. 24 0 stevel */ 25 0 stevel /* Copyright (c) 1990 Mentat Inc. */ 26 0 stevel 27 0 stevel #ifndef _INET_TCP_H 28 0 stevel #define _INET_TCP_H 29 0 stevel 30 0 stevel #ifdef __cplusplus 31 0 stevel extern "C" { 32 0 stevel #endif 33 0 stevel 34 0 stevel #include <sys/inttypes.h> 35 0 stevel #include <netinet/ip6.h> 36 0 stevel #include <netinet/tcp.h> 37 0 stevel #include <sys/socket.h> 38 8348 Eric #include <sys/socket_proto.h> 39 3448 dh155122 #include <sys/md5.h> 40 3448 dh155122 #include <inet/common.h> 41 3448 dh155122 #include <inet/ip.h> 42 3448 dh155122 #include <inet/ip6.h> 43 3448 dh155122 #include <inet/mi.h> 44 3448 dh155122 #include <inet/mib2.h> 45 3448 dh155122 #include <inet/tcp_stack.h> 46 3448 dh155122 #include <inet/tcp_sack.h> 47 898 kais #include <inet/kssl/ksslapi.h> 48 0 stevel 49 0 stevel /* TCP states */ 50 0 stevel #define TCPS_CLOSED -6 51 0 stevel #define TCPS_IDLE -5 /* idle (opened, but not bound) */ 52 0 stevel #define TCPS_BOUND -4 /* bound, ready to connect or accept */ 53 0 stevel #define TCPS_LISTEN -3 /* listening for connection */ 54 0 stevel #define TCPS_SYN_SENT -2 /* active, have sent syn */ 55 0 stevel #define TCPS_SYN_RCVD -1 /* have received syn (and sent ours) */ 56 0 stevel /* states < TCPS_ESTABLISHED are those where connections not established */ 57 0 stevel #define TCPS_ESTABLISHED 0 /* established */ 58 0 stevel #define TCPS_CLOSE_WAIT 1 /* rcvd fin, waiting for close */ 59 0 stevel /* states > TCPS_CLOSE_WAIT are those where user has closed */ 60 0 stevel #define TCPS_FIN_WAIT_1 2 /* have closed and sent fin */ 61 0 stevel #define TCPS_CLOSING 3 /* closed, xchd FIN, await FIN ACK */ 62 0 stevel #define TCPS_LAST_ACK 4 /* had fin and close; await FIN ACK */ 63 0 stevel /* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */ 64 0 stevel #define TCPS_FIN_WAIT_2 5 /* have closed, fin is acked */ 65 0 stevel #define TCPS_TIME_WAIT 6 /* in 2*msl quiet wait after close */ 66 0 stevel 67 0 stevel /* 68 0 stevel * Internal flags used in conjunction with the packet header flags. 69 11042 Erik * Used in tcp_input_data to keep track of what needs to be done. 70 0 stevel */ 71 0 stevel #define TH_LIMIT_XMIT 0x0400 /* Limited xmit is needed */ 72 0 stevel #define TH_XMIT_NEEDED 0x0800 /* Window opened - send queued data */ 73 0 stevel #define TH_REXMIT_NEEDED 0x1000 /* Time expired for unacked data */ 74 0 stevel #define TH_ACK_NEEDED 0x2000 /* Send an ack now. */ 75 0 stevel #define TH_NEED_SACK_REXMIT 0x4000 /* Use SACK info to retransmission */ 76 0 stevel #define TH_ACK_TIMER_NEEDED 0x8000 /* Start the delayed ACK timer */ 77 0 stevel #define TH_ORDREL_NEEDED 0x10000 /* Generate an ordrel indication */ 78 0 stevel #define TH_MARKNEXT_NEEDED 0x20000 /* Data should have MSGMARKNEXT */ 79 0 stevel #define TH_SEND_URP_MARK 0x40000 /* Send up tcp_urp_mark_mp */ 80 0 stevel 81 0 stevel /* 82 0 stevel * TCP sequence numbers are 32 bit integers operated 83 0 stevel * on with modular arithmetic. These macros can be 84 0 stevel * used to compare such integers. 85 0 stevel */ 86 0 stevel #define SEQ_LT(a, b) ((int32_t)((a)-(b)) < 0) 87 0 stevel #define SEQ_LEQ(a, b) ((int32_t)((a)-(b)) <= 0) 88 0 stevel #define SEQ_GT(a, b) ((int32_t)((a)-(b)) > 0) 89 0 stevel #define SEQ_GEQ(a, b) ((int32_t)((a)-(b)) >= 0) 90 0 stevel 91 0 stevel /* TCP Protocol header */ 92 0 stevel typedef struct tcphdr_s { 93 0 stevel uint8_t th_lport[2]; /* Source port */ 94 0 stevel uint8_t th_fport[2]; /* Destination port */ 95 0 stevel uint8_t th_seq[4]; /* Sequence number */ 96 0 stevel uint8_t th_ack[4]; /* Acknowledgement number */ 97 0 stevel uint8_t th_offset_and_rsrvd[1]; /* Offset to the packet data */ 98 0 stevel uint8_t th_flags[1]; 99 0 stevel uint8_t th_win[2]; /* Allocation number */ 100 0 stevel uint8_t th_sum[2]; /* TCP checksum */ 101 0 stevel uint8_t th_urp[2]; /* Urgent pointer */ 102 0 stevel } tcph_t; 103 0 stevel 104 11042 Erik #define TCP_HDR_LENGTH(tcph) \ 105 11042 Erik ((((tcph_t *)tcph)->th_offset_and_rsrvd[0] >>2) &(0xF << 2)) 106 0 stevel #define TCP_MAX_COMBINED_HEADER_LENGTH (60 + 60) /* Maxed out ip + tcp */ 107 0 stevel #define TCP_MAX_IP_OPTIONS_LENGTH (60 - IP_SIMPLE_HDR_LENGTH) 108 0 stevel #define TCP_MAX_HDR_LENGTH 60 109 11042 Erik #define TCP_MAX_TCP_OPTIONS_LENGTH (60 - sizeof (tcpha_t)) 110 0 stevel #define TCP_MIN_HEADER_LENGTH 20 111 0 stevel #define TCP_MAXWIN 65535 112 0 stevel #define TCP_PORT_LEN sizeof (in_port_t) 113 0 stevel #define TCP_MAX_WINSHIFT 14 114 0 stevel #define TCP_MAX_LARGEWIN (TCP_MAXWIN << TCP_MAX_WINSHIFT) 115 3115 yl150051 #define TCP_MAX_LSO_LENGTH (IP_MAXPACKET - TCP_MAX_COMBINED_HEADER_LENGTH) 116 0 stevel 117 0 stevel #define TCPIP_HDR_LENGTH(mp, n) \ 118 0 stevel (n) = IPH_HDR_LENGTH((mp)->b_rptr), \ 119 11042 Erik (n) += TCP_HDR_LENGTH((tcpha_t *)&(mp)->b_rptr[(n)]) 120 0 stevel 121 0 stevel /* TCP Protocol header (used if the header is known to be 32-bit aligned) */ 122 0 stevel typedef struct tcphdra_s { 123 0 stevel in_port_t tha_lport; /* Source port */ 124 0 stevel in_port_t tha_fport; /* Destination port */ 125 0 stevel uint32_t tha_seq; /* Sequence number */ 126 0 stevel uint32_t tha_ack; /* Acknowledgement number */ 127 0 stevel uint8_t tha_offset_and_reserved; /* Offset to the packet data */ 128 0 stevel uint8_t tha_flags; 129 0 stevel uint16_t tha_win; /* Allocation number */ 130 0 stevel uint16_t tha_sum; /* TCP checksum */ 131 0 stevel uint16_t tha_urp; /* Urgent pointer */ 132 0 stevel } tcpha_t; 133 0 stevel 134 0 stevel struct conn_s; 135 0 stevel 136 0 stevel /* 137 0 stevel * Control structure for each open TCP stream, 138 0 stevel * defined only within the kernel or for a kmem user. 139 0 stevel * NOTE: tcp_reinit_values MUST have a line for each field in this structure! 140 0 stevel */ 141 0 stevel #if (defined(_KERNEL) || defined(_KMEMUSER)) 142 0 stevel 143 0 stevel typedef struct tcp_s { 144 0 stevel /* Pointer to previous bind hash next. */ 145 3448 dh155122 struct tcp_s *tcp_time_wait_next; 146 0 stevel /* Pointer to next T/W block */ 147 3448 dh155122 struct tcp_s *tcp_time_wait_prev; 148 0 stevel /* Pointer to previous T/W next */ 149 3448 dh155122 clock_t tcp_time_wait_expire; 150 3448 dh155122 151 3448 dh155122 struct conn_s *tcp_connp; 152 3448 dh155122 tcp_stack_t *tcp_tcps; /* Shortcut via conn_netstack */ 153 0 stevel 154 0 stevel int32_t tcp_state; 155 0 stevel int32_t tcp_rcv_ws; /* My window scale power */ 156 0 stevel int32_t tcp_snd_ws; /* Sender's window scale power */ 157 0 stevel uint32_t tcp_ts_recent; /* Timestamp of earliest unacked */ 158 0 stevel /* data segment */ 159 0 stevel clock_t tcp_rto; /* Round trip timeout */ 160 0 stevel clock_t tcp_last_rcv_lbolt; 161 0 stevel /* lbolt on last packet, used for PAWS */ 162 0 stevel 163 0 stevel uint32_t tcp_snxt; /* Senders next seq num */ 164 0 stevel uint32_t tcp_swnd; /* Senders window (relative to suna) */ 165 0 stevel uint32_t tcp_mss; /* Max segment size */ 166 0 stevel uint32_t tcp_iss; /* Initial send seq num */ 167 0 stevel uint32_t tcp_rnxt; /* Seq we expect to recv next */ 168 0 stevel uint32_t tcp_rwnd; 169 0 stevel 170 0 stevel /* Fields arranged in approximate access order along main paths */ 171 0 stevel mblk_t *tcp_xmit_head; /* Head of rexmit list */ 172 0 stevel mblk_t *tcp_xmit_last; /* last valid data seen by tcp_wput */ 173 0 stevel mblk_t *tcp_xmit_tail; /* Last rexmit data sent */ 174 0 stevel uint32_t tcp_unsent; /* # of bytes in hand that are unsent */ 175 0 stevel uint32_t tcp_xmit_tail_unsent; /* # of unsent bytes in xmit_tail */ 176 0 stevel 177 0 stevel uint32_t tcp_suna; /* Sender unacknowledged */ 178 0 stevel uint32_t tcp_rexmit_nxt; /* Next rexmit seq num */ 179 0 stevel uint32_t tcp_rexmit_max; /* Max retran seq num */ 180 0 stevel int32_t tcp_snd_burst; /* Send burst factor */ 181 0 stevel uint32_t tcp_cwnd; /* Congestion window */ 182 0 stevel int32_t tcp_cwnd_cnt; /* cwnd cnt in congestion avoidance */ 183 0 stevel 184 0 stevel uint32_t tcp_ibsegs; /* Inbound segments on this stream */ 185 0 stevel uint32_t tcp_obsegs; /* Outbound segments on this stream */ 186 0 stevel 187 0 stevel uint32_t tcp_naglim; /* Tunable nagle limit */ 188 0 stevel uint32_t tcp_valid_bits; 189 0 stevel #define TCP_ISS_VALID 0x1 /* Is the tcp_iss seq num active? */ 190 0 stevel #define TCP_FSS_VALID 0x2 /* Is the tcp_fss seq num active? */ 191 0 stevel #define TCP_URG_VALID 0x4 /* Is the tcp_urg seq num active? */ 192 0 stevel #define TCP_OFO_FIN_VALID 0x8 /* Has TCP received an out of order FIN? */ 193 0 stevel 194 0 stevel 195 0 stevel 196 0 stevel timeout_id_t tcp_timer_tid; /* Control block for timer service */ 197 0 stevel uchar_t tcp_timer_backoff; /* Backoff shift count. */ 198 0 stevel int64_t tcp_last_recv_time; /* Last time we receive a segment. */ 199 0 stevel uint32_t tcp_init_cwnd; /* Initial cwnd (start/restart) */ 200 0 stevel 201 0 stevel /* Following manipulated by TCP under squeue protection */ 202 0 stevel uint32_t 203 0 stevel tcp_urp_last_valid : 1, /* Is tcp_urp_last valid? */ 204 11042 Erik tcp_hard_binding : 1, /* TCP_DETACHED_NONEAGER */ 205 0 stevel tcp_fin_acked : 1, /* Has our FIN been acked? */ 206 11042 Erik tcp_fin_rcvd : 1, /* Have we seen a FIN? */ 207 0 stevel 208 0 stevel tcp_fin_sent : 1, /* Have we sent our FIN yet? */ 209 0 stevel tcp_ordrel_done : 1, /* Have we sent the ord_rel upstream? */ 210 3429 vi117747 tcp_detached : 1, /* If we're detached from a stream */ 211 8014 Kacheong tcp_zero_win_probe: 1, /* Zero win probing is in progress */ 212 0 stevel 213 0 stevel tcp_loopback: 1, /* src and dst are the same machine */ 214 3429 vi117747 tcp_localnet: 1, /* src and dst are on the same subnet */ 215 0 stevel tcp_syn_defense: 1, /* For defense against SYN attack */ 216 0 stevel #define tcp_dontdrop tcp_syn_defense 217 8014 Kacheong tcp_set_timer : 1, 218 7609 Eric 219 0 stevel tcp_active_open: 1, /* This is a active open */ 220 7609 Eric tcp_rexmit : 1, /* TCP is retransmitting */ 221 0 stevel tcp_snd_sack_ok : 1, /* Can use SACK for this connection */ 222 11042 Erik tcp_hwcksum : 1, /* The NIC is capable of hwcksum */ 223 8014 Kacheong 224 0 stevel tcp_ip_forward_progress : 1, 225 3429 vi117747 tcp_ecn_ok : 1, /* Can use ECN for this connection */ 226 7609 Eric tcp_ecn_echo_on : 1, /* Need to do ECN echo */ 227 0 stevel tcp_ecn_cwr_sent : 1, /* ECN_CWR has been sent */ 228 11042 Erik 229 3429 vi117747 tcp_cwr : 1, /* Cwnd has reduced recently */ 230 8014 Kacheong 231 11042 Erik tcp_pad_to_bit31 : 11; 232 11042 Erik 233 0 stevel /* Following manipulated by TCP under squeue protection */ 234 0 stevel uint32_t 235 0 stevel tcp_snd_ts_ok : 1, 236 0 stevel tcp_snd_ws_ok : 1, 237 11042 Erik tcp_reserved_port : 1, 238 11042 Erik tcp_in_free_list : 1, 239 0 stevel 240 0 stevel tcp_snd_zcopy_on : 1, /* xmit zero-copy enabled */ 241 0 stevel tcp_snd_zcopy_aware : 1, /* client is zero-copy aware */ 242 0 stevel tcp_xmit_zc_clean : 1, /* the xmit list is free of zc-mblk */ 243 0 stevel tcp_wait_for_eagers : 1, /* Wait for eagers to disappear */ 244 11042 Erik 245 0 stevel tcp_accept_error : 1, /* Error during TLI accept */ 246 0 stevel tcp_send_discon_ind : 1, /* TLI accept err, send discon ind */ 247 0 stevel tcp_cork : 1, /* tcp_cork option */ 248 3104 jprakash tcp_tconnind_started : 1, /* conn_ind message is being sent */ 249 11042 Erik 250 3115 yl150051 tcp_lso :1, /* Lower layer is capable of LSO */ 251 9864 Phil tcp_is_wnd_shrnk : 1, /* Window has shrunk */ 252 0 stevel 253 11042 Erik tcp_pad_to_bit_31 : 18; 254 11042 Erik 255 11042 Erik uint32_t tcp_initial_pmtu; /* Initial outgoing Path MTU. */ 256 0 stevel 257 0 stevel mblk_t *tcp_reass_head; /* Out of order reassembly list head */ 258 0 stevel mblk_t *tcp_reass_tail; /* Out of order reassembly list tail */ 259 0 stevel 260 0 stevel tcp_sack_info_t *tcp_sack_info; 261 0 stevel 262 0 stevel #define tcp_pipe tcp_sack_info->tcp_pipe 263 0 stevel #define tcp_fack tcp_sack_info->tcp_fack 264 0 stevel #define tcp_sack_snxt tcp_sack_info->tcp_sack_snxt 265 0 stevel #define tcp_max_sack_blk tcp_sack_info->tcp_max_sack_blk 266 0 stevel #define tcp_num_sack_blk tcp_sack_info->tcp_num_sack_blk 267 0 stevel #define tcp_sack_list tcp_sack_info->tcp_sack_list 268 0 stevel #define tcp_num_notsack_blk tcp_sack_info->tcp_num_notsack_blk 269 0 stevel #define tcp_cnt_notsack_list tcp_sack_info->tcp_cnt_notsack_list 270 0 stevel #define tcp_notsack_list tcp_sack_info->tcp_notsack_list 271 0 stevel 272 0 stevel mblk_t *tcp_rcv_list; /* Queued until push, urgent data, */ 273 0 stevel mblk_t *tcp_rcv_last_head; /* optdata, or the count exceeds */ 274 0 stevel mblk_t *tcp_rcv_last_tail; /* tcp_rcv_push_wait. */ 275 0 stevel uint32_t tcp_rcv_cnt; /* tcp_rcv_list is b_next chain. */ 276 0 stevel 277 0 stevel uint32_t tcp_cwnd_ssthresh; /* Congestion window */ 278 0 stevel uint32_t tcp_cwnd_max; 279 0 stevel uint32_t tcp_csuna; /* Clear (no rexmits in window) suna */ 280 0 stevel 281 0 stevel clock_t tcp_rtt_sa; /* Round trip smoothed average */ 282 0 stevel clock_t tcp_rtt_sd; /* Round trip smoothed deviation */ 283 0 stevel clock_t tcp_rtt_update; /* Round trip update(s) */ 284 0 stevel clock_t tcp_ms_we_have_waited; /* Total retrans time */ 285 0 stevel 286 0 stevel uint32_t tcp_swl1; /* These help us avoid using stale */ 287 0 stevel uint32_t tcp_swl2; /* packets to update state */ 288 0 stevel 289 0 stevel uint32_t tcp_rack; /* Seq # we have acked */ 290 0 stevel uint32_t tcp_rack_cnt; /* # of segs we have deferred ack */ 291 0 stevel uint32_t tcp_rack_cur_max; /* # of segs we may defer ack for now */ 292 0 stevel uint32_t tcp_rack_abs_max; /* # of segs we may defer ack ever */ 293 0 stevel timeout_id_t tcp_ack_tid; /* Delayed ACK timer ID */ 294 0 stevel timeout_id_t tcp_push_tid; /* Push timer ID */ 295 0 stevel 296 0 stevel uint32_t tcp_max_swnd; /* Maximum swnd we have seen */ 297 0 stevel 298 0 stevel struct tcp_s *tcp_listener; /* Our listener */ 299 0 stevel 300 0 stevel uint32_t tcp_irs; /* Initial recv seq num */ 301 0 stevel uint32_t tcp_fss; /* Final/fin send seq num */ 302 0 stevel uint32_t tcp_urg; /* Urgent data seq num */ 303 0 stevel 304 0 stevel clock_t tcp_first_timer_threshold; /* When to prod IP */ 305 0 stevel clock_t tcp_second_timer_threshold; /* When to give up completely */ 306 0 stevel clock_t tcp_first_ctimer_threshold; /* 1st threshold while connecting */ 307 0 stevel clock_t tcp_second_ctimer_threshold; /* 2nd ... while connecting */ 308 0 stevel 309 0 stevel uint32_t tcp_urp_last; /* Last urp for which signal sent */ 310 0 stevel mblk_t *tcp_urp_mp; /* T_EXDATA_IND for urgent byte */ 311 0 stevel mblk_t *tcp_urp_mark_mp; /* zero-length marked/unmarked msg */ 312 0 stevel 313 0 stevel int tcp_conn_req_cnt_q0; /* # of conn reqs in SYN_RCVD */ 314 0 stevel int tcp_conn_req_cnt_q; /* # of conn reqs in ESTABLISHED */ 315 0 stevel int tcp_conn_req_max; /* # of ESTABLISHED conn reqs allowed */ 316 0 stevel t_scalar_t tcp_conn_req_seqnum; /* Incrementing pending conn req ID */ 317 0 stevel #define tcp_ip_addr_cache tcp_reass_tail 318 0 stevel /* Cache ip addresses that */ 319 0 stevel /* complete the 3-way handshake */ 320 0 stevel kmutex_t tcp_eager_lock; 321 0 stevel struct tcp_s *tcp_eager_next_q; /* next eager in ESTABLISHED state */ 322 0 stevel struct tcp_s *tcp_eager_last_q; /* last eager in ESTABLISHED state */ 323 0 stevel struct tcp_s *tcp_eager_next_q0; /* next eager in SYN_RCVD state */ 324 0 stevel struct tcp_s *tcp_eager_prev_q0; /* prev eager in SYN_RCVD state */ 325 0 stevel /* all eagers form a circular list */ 326 7609 Eric boolean_t tcp_conn_def_q0; /* move from q0 to q deferred */ 327 7609 Eric 328 0 stevel union { 329 0 stevel mblk_t *tcp_eager_conn_ind; /* T_CONN_IND waiting for 3rd ack. */ 330 0 stevel mblk_t *tcp_opts_conn_req; /* T_CONN_REQ w/ options processed */ 331 0 stevel } tcp_conn; 332 0 stevel uint32_t tcp_syn_rcvd_timeout; /* How many SYN_RCVD timeout in q0 */ 333 0 stevel 334 0 stevel /* TCP Keepalive Timer members */ 335 0 stevel int32_t tcp_ka_last_intrvl; /* Last probe interval */ 336 0 stevel timeout_id_t tcp_ka_tid; /* Keepalive timer ID */ 337 0 stevel uint32_t tcp_ka_interval; /* Keepalive interval */ 338 0 stevel uint32_t tcp_ka_abort_thres; /* Keepalive abort threshold */ 339 0 stevel 340 0 stevel int32_t tcp_client_errno; /* How the client screwed up */ 341 0 stevel 342 11042 Erik /* 343 11042 Erik * The header template lives in conn_ht_iphc allocated by tcp_build_hdrs 344 11042 Erik * We maintain three pointers into conn_ht_iphc. 345 11042 Erik */ 346 11042 Erik ipha_t *tcp_ipha; /* IPv4 header in conn_ht_iphc */ 347 11042 Erik ip6_t *tcp_ip6h; /* IPv6 header in conn_ht_iphc */ 348 11042 Erik tcpha_t *tcp_tcpha; /* TCP header in conn_ht_iphc */ 349 0 stevel 350 0 stevel uint16_t tcp_last_sent_len; /* Record length for nagle */ 351 0 stevel uint16_t tcp_dupack_cnt; /* # of consequtive duplicate acks */ 352 0 stevel 353 0 stevel kmutex_t *tcp_acceptor_lockp; /* Ptr to tf_lock */ 354 0 stevel 355 8014 Kacheong mblk_t *tcp_ordrel_mp; /* T_ordrel_ind mblk */ 356 0 stevel t_uscalar_t tcp_acceptor_id; /* ACCEPTOR_id */ 357 0 stevel 358 0 stevel int tcp_ipsec_overhead; 359 0 stevel 360 0 stevel uint_t tcp_recvifindex; /* Last received IPV6_RCVPKTINFO */ 361 0 stevel uint_t tcp_recvhops; /* Last received IPV6_RECVHOPLIMIT */ 362 0 stevel uint_t tcp_recvtclass; /* Last received IPV6_RECVTCLASS */ 363 0 stevel ip6_hbh_t *tcp_hopopts; /* Last received IPV6_RECVHOPOPTS */ 364 0 stevel ip6_dest_t *tcp_dstopts; /* Last received IPV6_RECVDSTOPTS */ 365 11042 Erik ip6_dest_t *tcp_rthdrdstopts; /* Last recv IPV6_RECVRTHDRDSTOPTS */ 366 0 stevel ip6_rthdr_t *tcp_rthdr; /* Last received IPV6_RECVRTHDR */ 367 0 stevel uint_t tcp_hopoptslen; 368 0 stevel uint_t tcp_dstoptslen; 369 11042 Erik uint_t tcp_rthdrdstoptslen; 370 0 stevel uint_t tcp_rthdrlen; 371 0 stevel 372 0 stevel mblk_t *tcp_timercache; 373 0 stevel 374 0 stevel kmutex_t tcp_closelock; 375 0 stevel kcondvar_t tcp_closecv; 376 0 stevel uint8_t tcp_closed; 377 0 stevel uint8_t tcp_closeflags; 378 0 stevel uint8_t tcp_cleandeathtag; 379 0 stevel mblk_t tcp_closemp; 380 0 stevel timeout_id_t tcp_linger_tid; /* Linger timer ID */ 381 0 stevel 382 0 stevel struct tcp_s *tcp_acceptor_hash; /* Acceptor hash chain */ 383 0 stevel struct tcp_s **tcp_ptpahn; /* Pointer to previous accept hash next. */ 384 0 stevel struct tcp_s *tcp_bind_hash; /* Bind hash chain */ 385 8348 Eric struct tcp_s *tcp_bind_hash_port; /* tcp_t's bound to the same lport */ 386 0 stevel struct tcp_s **tcp_ptpbhn; 387 0 stevel 388 11042 Erik uint_t tcp_maxpsz_multiplier; 389 3115 yl150051 390 3115 yl150051 uint32_t tcp_lso_max; /* maximum LSO payload */ 391 0 stevel 392 0 stevel uint32_t tcp_ofo_fin_seq; /* Recv out of order FIN seq num */ 393 0 stevel uint32_t tcp_cwr_snd_max; 394 11042 Erik 395 0 stevel struct tcp_s *tcp_saved_listener; /* saved value of listener */ 396 0 stevel 397 741 masputra uint32_t tcp_in_ack_unsent; /* ACK for unsent data cnt. */ 398 741 masputra 399 741 masputra /* 400 9993 Anders * All fusion-related fields are protected by squeue. 401 741 masputra */ 402 0 stevel struct tcp_s *tcp_loopback_peer; /* peer tcp for loopback */ 403 0 stevel mblk_t *tcp_fused_sigurg_mp; /* M_PCSIG mblk for SIGURG */ 404 9993 Anders 405 741 masputra uint32_t 406 741 masputra tcp_fused : 1, /* loopback tcp in fusion mode */ 407 741 masputra tcp_unfusable : 1, /* fusion not allowed on endpoint */ 408 741 masputra tcp_fused_sigurg : 1, /* send SIGURG upon draining */ 409 0 stevel 410 9993 Anders tcp_fuse_to_bit_31 : 29; 411 9993 Anders 412 9993 Anders kmutex_t tcp_non_sq_lock; 413 0 stevel 414 0 stevel /* 415 0 stevel * This variable is accessed without any lock protection 416 0 stevel * and therefore must not be declared as a bit field along 417 0 stevel * with the rest which require such condition. 418 0 stevel */ 419 0 stevel boolean_t tcp_issocket; /* this is a socket tcp */ 420 741 masputra 421 3429 vi117747 /* protected by the tcp_non_sq_lock lock */ 422 741 masputra uint32_t tcp_squeue_bytes; 423 898 kais /* 424 898 kais * Kernel SSL session information 425 898 kais */ 426 898 kais boolean_t tcp_kssl_pending; /* waiting for 1st SSL rec. */ 427 898 kais boolean_t tcp_kssl_inhandshake; /* during SSL handshake */ 428 898 kais kssl_ent_t tcp_kssl_ent; /* SSL table entry */ 429 898 kais kssl_ctx_t tcp_kssl_ctx; /* SSL session */ 430 3104 jprakash 431 3104 jprakash /* 432 3104 jprakash * tcp_closemp_used is protected by listener's tcp_eager_lock 433 3104 jprakash * when used for eagers. When used for a tcp in TIME_WAIT state 434 3104 jprakash * or in tcp_close(), it is not protected by any lock as we 435 3104 jprakash * do not expect any other thread to use it concurrently. 436 4200 jprakash * We do allow re-use of tcp_closemp in tcp_time_wait_collector() 437 4200 jprakash * and tcp_close() but not concurrently. 438 3104 jprakash */ 439 4200 jprakash boolean_t tcp_closemp_used; 440 3104 jprakash 441 3104 jprakash /* 442 3104 jprakash * previous and next eagers in the list of droppable eagers. See 443 3104 jprakash * the comments before MAKE_DROPPABLE(). These pointers are 444 3104 jprakash * protected by listener's tcp_eager_lock. 445 3104 jprakash */ 446 3104 jprakash struct tcp_s *tcp_eager_prev_drop_q0; 447 3104 jprakash struct tcp_s *tcp_eager_next_drop_q0; 448 3429 vi117747 449 3429 vi117747 /* 450 3429 vi117747 * Have we flow controlled xmitter? 451 3429 vi117747 * This variable can be modified outside the squeue and hence must 452 3429 vi117747 * not be declared as a bit field along with the rest that are 453 3429 vi117747 * modified only within the squeue. 454 3429 vi117747 * protected by the tcp_non_sq_lock lock. 455 3429 vi117747 */ 456 3429 vi117747 boolean_t tcp_flow_stopped; 457 9864 Phil 458 9864 Phil /* 459 9864 Phil * Sender's next sequence number at the time the window was shrunk. 460 9864 Phil */ 461 9864 Phil uint32_t tcp_snxt_shrunk; 462 8348 Eric 463 8348 Eric /* 464 10832 Anders * Socket generation number which is bumped when a connection attempt 465 10832 Anders * is initiated. Its main purpose is to ensure that the socket does not 466 10832 Anders * miss the asynchronous connected/disconnected notification. 467 8348 Eric */ 468 8348 Eric sock_connid_t tcp_connid; 469 3429 vi117747 470 8014 Kacheong /* mblk_t used to enter TCP's squeue from the service routine. */ 471 8014 Kacheong mblk_t *tcp_rsrv_mp; 472 8014 Kacheong /* Mutex for accessing tcp_rsrv_mp */ 473 8014 Kacheong kmutex_t tcp_rsrv_mp_lock; 474 8014 Kacheong 475 3104 jprakash #ifdef DEBUG 476 3104 jprakash pc_t tcmp_stk[15]; 477 3104 jprakash #endif 478 0 stevel } tcp_t; 479 3104 jprakash 480 3104 jprakash #ifdef DEBUG 481 3104 jprakash #define TCP_DEBUG_GETPCSTACK(buffer, depth) ((void) getpcstack(buffer, \ 482 3104 jprakash depth)) 483 3104 jprakash #else 484 3104 jprakash #define TCP_DEBUG_GETPCSTACK(buffer, depth) 485 3104 jprakash #endif 486 0 stevel 487 0 stevel extern void tcp_free(tcp_t *tcp); 488 3448 dh155122 extern void tcp_ddi_g_init(void); 489 3448 dh155122 extern void tcp_ddi_g_destroy(void); 490 11042 Erik extern void tcp_xmit_listeners_reset(mblk_t *, ip_recv_attr_t *, 491 11042 Erik ip_stack_t *, conn_t *); 492 11042 Erik extern void tcp_input_listener(void *arg, mblk_t *mp, void *arg2, 493 11042 Erik ip_recv_attr_t *); 494 11042 Erik extern void tcp_input_listener_unbound(void *arg, mblk_t *mp, void *arg2, 495 11042 Erik ip_recv_attr_t *); 496 11042 Erik extern void tcp_input_data(void *arg, mblk_t *mp, void *arg2, 497 11042 Erik ip_recv_attr_t *); 498 9534 Anders extern void *tcp_get_conn(void *arg, tcp_stack_t *); 499 0 stevel extern void tcp_time_wait_collector(void *arg); 500 5240 nordmark extern mblk_t *tcp_snmp_get(queue_t *, mblk_t *); 501 741 masputra extern int tcp_snmp_set(queue_t *, int, int, uchar_t *, int len); 502 2958 dr146992 extern mblk_t *tcp_xmit_mp(tcp_t *tcp, mblk_t *mp, int32_t max_to_send, 503 2958 dr146992 int32_t *offset, mblk_t **end_mp, uint32_t seq, 504 2958 dr146992 boolean_t sendall, uint32_t *seg_len, boolean_t rexmit); 505 8951 Phil 506 0 stevel /* 507 0 stevel * The TCP Fanout structure. 508 0 stevel * The hash tables and their linkage (tcp_*_hash_next, tcp_ptp*hn) are 509 0 stevel * protected by the per-bucket tf_lock. Each tcp_t 510 0 stevel * inserted in the list points back at this lock using tcp_*_lockp. 511 0 stevel * 512 0 stevel * The listener and acceptor hash queues are lists of tcp_t. 513 0 stevel */ 514 0 stevel /* listener hash and acceptor hash queue head */ 515 0 stevel typedef struct tf_s { 516 0 stevel tcp_t *tf_tcp; 517 0 stevel kmutex_t tf_lock; 518 0 stevel } tf_t; 519 0 stevel #endif /* (defined(_KERNEL) || defined(_KMEMUSER)) */ 520 0 stevel 521 0 stevel /* Contract private interface between TCP and Clustering. */ 522 0 stevel 523 0 stevel #define CL_TCPI_V1 1 /* cl_tcpi_version number */ 524 0 stevel 525 0 stevel typedef struct cl_tcp_info_s { 526 0 stevel ushort_t cl_tcpi_version; /* cl_tcp_info_t's version no */ 527 0 stevel ushort_t cl_tcpi_ipversion; /* IP version */ 528 0 stevel int32_t cl_tcpi_state; /* TCP state */ 529 0 stevel in_port_t cl_tcpi_lport; /* Local port */ 530 0 stevel in_port_t cl_tcpi_fport; /* Remote port */ 531 0 stevel in6_addr_t cl_tcpi_laddr_v6; /* Local IP address */ 532 0 stevel in6_addr_t cl_tcpi_faddr_v6; /* Remote IP address */ 533 0 stevel #ifdef _KERNEL 534 0 stevel /* Note: V4_PART_OF_V6 is meant to be used only for _KERNEL defined stuff */ 535 0 stevel #define cl_tcpi_laddr V4_PART_OF_V6(cl_tcpi_laddr_v6) 536 0 stevel #define cl_tcpi_faddr V4_PART_OF_V6(cl_tcpi_faddr_v6) 537 0 stevel 538 0 stevel #endif /* _KERNEL */ 539 0 stevel } cl_tcp_info_t; 540 0 stevel 541 0 stevel /* 542 11042 Erik * Hook functions to enable cluster networking 543 11042 Erik * On non-clustered systems these vectors must always be NULL. 544 11042 Erik */ 545 11042 Erik extern void (*cl_inet_listen)(netstackid_t, uint8_t, sa_family_t, 546 11042 Erik uint8_t *, in_port_t, void *); 547 11042 Erik extern void (*cl_inet_unlisten)(netstackid_t, uint8_t, sa_family_t, 548 11042 Erik uint8_t *, in_port_t, void *); 549 11042 Erik 550 11042 Erik /* 551 0 stevel * Contracted Consolidation Private ioctl for aborting TCP connections. 552 0 stevel * In order to keep the offsets and size of the structure the same between 553 0 stevel * a 32-bit application and a 64-bit amd64 kernel, we use a #pragma 554 0 stevel * pack(4). 555 0 stevel */ 556 0 stevel #define TCP_IOC_ABORT_CONN (('T' << 8) + 91) 557 0 stevel 558 0 stevel #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 559 0 stevel #pragma pack(4) 560 0 stevel #endif 561 0 stevel 562 0 stevel typedef struct tcp_ioc_abort_conn_s { 563 0 stevel struct sockaddr_storage ac_local; /* local addr and port */ 564 0 stevel struct sockaddr_storage ac_remote; /* remote addr and port */ 565 0 stevel int32_t ac_start; /* start state */ 566 0 stevel int32_t ac_end; /* end state */ 567 0 stevel int32_t ac_zoneid; /* zoneid */ 568 0 stevel } tcp_ioc_abort_conn_t; 569 0 stevel 570 0 stevel #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 571 0 stevel #pragma pack() 572 0 stevel #endif 573 0 stevel 574 0 stevel #ifdef __cplusplus 575 0 stevel } 576 0 stevel #endif 577 0 stevel 578 0 stevel #endif /* _INET_TCP_H */ 579