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