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