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