Print this page
%B
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/inet/sctp/sctp_impl.h
+++ new/usr/src/uts/common/inet/sctp/sctp_impl.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 /*
23 23 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
24 24 */
25 25
26 26 #ifndef _INET_SCTP_SCTP_IMPL_H
27 27 #define _INET_SCTP_SCTP_IMPL_H
28 28
29 29 #include <sys/inttypes.h>
30 30 #include <sys/taskq.h>
31 31 #include <sys/list.h>
32 32 #include <sys/strsun.h>
33 33 #include <sys/zone.h>
34 34 #include <sys/cpuvar.h>
35 35 #include <sys/clock_impl.h>
36 36
37 37 #include <netinet/ip6.h>
38 38 #include <inet/optcom.h>
39 39 #include <inet/tunables.h>
40 40 #include <netinet/sctp.h>
41 41 #include <inet/sctp_itf.h>
42 42 #include "sctp_stack.h"
43 43
44 44 #ifdef __cplusplus
45 45 extern "C" {
46 46 #endif
47 47
48 48 /* Streams device identifying info and version */
49 49 #define SCTP_DEV_IDINFO "SCTP Streams device 1.0"
50 50
51 51 #define SSN_GT(a, b) ((int16_t)((a)-(b)) > 0)
52 52 #define SSN_GE(a, b) ((int16_t)((a)-(b)) >= 0)
53 53
54 54 /* Default buffer size and flow control wake up threshold. */
55 55 #define SCTP_XMIT_LOWATER 8192
56 56 #define SCTP_XMIT_HIWATER 102400
57 57 #define SCTP_RECV_LOWATER 8192
58 58 #define SCTP_RECV_HIWATER 102400
59 59
60 60 /* SCTP Timer control structure */
61 61 typedef struct sctpt_s {
62 62 pfv_t sctpt_pfv; /* The routine we are to call */
63 63 struct sctp_s *sctpt_sctp; /* The parameter we are to pass in */
64 64 struct sctp_faddr_s *sctpt_faddr;
65 65 } sctpt_t;
66 66
67 67 /*
68 68 * Maximum number of duplicate TSNs we can report. This is currently
69 69 * static, and governs the size of the mblk used to hold the duplicate
70 70 * reports. The use of duplcate TSN reports is currently experimental,
71 71 * so for now a static limit should suffice.
72 72 */
73 73 #define SCTP_DUP_MBLK_SZ 64
74 74
75 75 #define SCTP_IS_ADDR_UNSPEC(isv4, addr) \
76 76 ((isv4) ? IN6_IS_ADDR_V4MAPPED_ANY(&(addr)) : \
77 77 IN6_IS_ADDR_UNSPECIFIED(&(addr)))
78 78
79 79 /*
80 80 * SCTP properties/tunables
81 81 */
82 82 #define sctps_max_init_retr sctps_propinfo_tbl[0].prop_cur_uval
83 83 #define sctps_max_init_retr_high sctps_propinfo_tbl[0].prop_max_uval
84 84 #define sctps_max_init_retr_low sctps_propinfo_tbl[0].prop_min_uval
85 85 #define sctps_pa_max_retr sctps_propinfo_tbl[1].prop_cur_uval
86 86 #define sctps_pa_max_retr_high sctps_propinfo_tbl[1].prop_max_uval
87 87 #define sctps_pa_max_retr_low sctps_propinfo_tbl[1].prop_min_uval
88 88 #define sctps_pp_max_retr sctps_propinfo_tbl[2].prop_cur_uval
89 89 #define sctps_pp_max_retr_high sctps_propinfo_tbl[2].prop_max_uval
90 90 #define sctps_pp_max_retr_low sctps_propinfo_tbl[2].prop_min_uval
91 91 #define sctps_cwnd_max_ sctps_propinfo_tbl[3].prop_cur_uval
92 92 #define sctps_smallest_nonpriv_port sctps_propinfo_tbl[4].prop_cur_uval
93 93 #define sctps_ipv4_ttl sctps_propinfo_tbl[5].prop_cur_uval
94 94 #define sctps_heartbeat_interval sctps_propinfo_tbl[6].prop_cur_uval
95 95 #define sctps_heartbeat_interval_high sctps_propinfo_tbl[6].prop_max_uval
96 96 #define sctps_heartbeat_interval_low sctps_propinfo_tbl[6].prop_min_uval
97 97 #define sctps_initial_mtu sctps_propinfo_tbl[7].prop_cur_uval
98 98 #define sctps_mtu_probe_interval sctps_propinfo_tbl[8].prop_cur_uval
99 99 #define sctps_new_secret_interval sctps_propinfo_tbl[9].prop_cur_uval
100 100 #define sctps_deferred_ack_interval sctps_propinfo_tbl[10].prop_cur_uval
101 101 #define sctps_snd_lowat_fraction sctps_propinfo_tbl[11].prop_cur_uval
102 102 #define sctps_ignore_path_mtu sctps_propinfo_tbl[12].prop_cur_bval
103 103 #define sctps_initial_ssthresh sctps_propinfo_tbl[13].prop_cur_uval
104 104 #define sctps_smallest_anon_port sctps_propinfo_tbl[14].prop_cur_uval
105 105 #define sctps_largest_anon_port sctps_propinfo_tbl[15].prop_cur_uval
106 106 #define sctps_xmit_hiwat sctps_propinfo_tbl[16].prop_cur_uval
107 107 #define sctps_xmit_lowat sctps_propinfo_tbl[17].prop_cur_uval
108 108 #define sctps_recv_hiwat sctps_propinfo_tbl[18].prop_cur_uval
109 109 #define sctps_max_buf sctps_propinfo_tbl[19].prop_cur_uval
110 110 #define sctps_rtt_updates sctps_propinfo_tbl[20].prop_cur_uval
111 111 #define sctps_ipv6_hoplimit sctps_propinfo_tbl[21].prop_cur_uval
112 112 #define sctps_rto_ming sctps_propinfo_tbl[22].prop_cur_uval
113 113 #define sctps_rto_ming_high sctps_propinfo_tbl[22].prop_max_uval
114 114 #define sctps_rto_ming_low sctps_propinfo_tbl[22].prop_min_uval
115 115 #define sctps_rto_maxg sctps_propinfo_tbl[23].prop_cur_uval
116 116 #define sctps_rto_maxg_high sctps_propinfo_tbl[23].prop_max_uval
117 117 #define sctps_rto_maxg_low sctps_propinfo_tbl[23].prop_min_uval
118 118 #define sctps_rto_initialg sctps_propinfo_tbl[24].prop_cur_uval
119 119 #define sctps_rto_initialg_high sctps_propinfo_tbl[24].prop_max_uval
120 120 #define sctps_rto_initialg_low sctps_propinfo_tbl[24].prop_min_uval
121 121 #define sctps_cookie_life sctps_propinfo_tbl[25].prop_cur_uval
122 122 #define sctps_cookie_life_high sctps_propinfo_tbl[25].prop_max_uval
123 123 #define sctps_cookie_life_low sctps_propinfo_tbl[25].prop_min_uval
124 124 #define sctps_max_in_streams sctps_propinfo_tbl[26].prop_cur_uval
125 125 #define sctps_max_in_streams_high sctps_propinfo_tbl[26].prop_max_uval
126 126 #define sctps_max_in_streams_low sctps_propinfo_tbl[26].prop_min_uval
127 127 #define sctps_initial_out_streams sctps_propinfo_tbl[27].prop_cur_uval
128 128 #define sctps_initial_out_streams_high sctps_propinfo_tbl[27].prop_max_uval
129 129 #define sctps_initial_out_streams_low sctps_propinfo_tbl[27].prop_min_uval
130 130 #define sctps_shutack_wait_bound sctps_propinfo_tbl[28].prop_cur_uval
131 131 #define sctps_maxburst sctps_propinfo_tbl[29].prop_cur_uval
132 132 #define sctps_addip_enabled sctps_propinfo_tbl[30].prop_cur_bval
133 133 #define sctps_recv_hiwat_minmss sctps_propinfo_tbl[31].prop_cur_uval
134 134 #define sctps_slow_start_initial sctps_propinfo_tbl[32].prop_cur_uval
135 135 #define sctps_slow_start_after_idle sctps_propinfo_tbl[33].prop_cur_uval
136 136 #define sctps_prsctp_enabled sctps_propinfo_tbl[34].prop_cur_bval
137 137 #define sctps_fast_rxt_thresh sctps_propinfo_tbl[35].prop_cur_uval
138 138 #define sctps_deferred_acks_max sctps_propinfo_tbl[36].prop_cur_uval
139 139 #define sctps_wroff_xtra sctps_propinfo_tbl[37].prop_cur_uval
140 140
141 141 /*
142 142 * Retransmission timer start and stop macro for a given faddr.
143 143 */
144 144 #define SCTP_FADDR_TIMER_RESTART(sctp, fp, intvl) \
145 145 { \
146 146 dprint(3, ("faddr_timer_restart: fp=%p %x:%x:%x:%x %d\n", \
147 147 (void *)(fp), SCTP_PRINTADDR((fp)->sf_faddr), (int)(intvl))); \
148 148 sctp_timer((sctp), (fp)->sf_timer_mp, (intvl)); \
149 149 (fp)->sf_timer_running = 1; \
150 150 }
151 151
152 152 #define SCTP_FADDR_TIMER_STOP(fp) \
153 153 ASSERT((fp)->sf_timer_mp != NULL); \
154 154 if ((fp)->sf_timer_running) { \
155 155 sctp_timer_stop((fp)->sf_timer_mp); \
156 156 (fp)->sf_timer_running = 0; \
157 157 }
158 158
159 159 /* For per endpoint association statistics */
160 160 #define SCTP_MAX_RTO(sctp, fp) { \
161 161 /* \
162 162 * Record the maximum observed RTO, \
163 163 * sctp_maxrto is zeroed elsewhere \
164 164 * at the end of each stats request. \
165 165 */ \
166 166 (sctp)->sctp_maxrto = \
167 167 MAX((sctp)->sctp_maxrto, (fp)->sf_rto); \
168 168 DTRACE_PROBE2(sctp__maxrto, sctp_t *, \
169 169 sctp, struct sctp_faddr_s, fp); \
170 170 }
171 171
172 172 #define SCTP_CALC_RXT(sctp, fp, max) \
173 173 { \
174 174 if (((fp)->sf_rto <<= 1) > (max)) \
175 175 (fp)->sf_rto = (max); \
176 176 SCTP_MAX_RTO(sctp, fp); \
177 177 }
178 178
179 179
180 180 #define SCTP_MAX_COMBINED_HEADER_LENGTH (60 + 12) /* Maxed out ip + sctp */
181 181 #define SCTP_MAX_IP_OPTIONS_LENGTH (60 - IP_SIMPLE_HDR_LENGTH)
182 182 #define SCTP_MAX_HDR_LENGTH 60
183 183
184 184 #define SCTP_SECRET_LEN 16
185 185
186 186 #define SCTP_REFHOLD(sctp) { \
187 187 mutex_enter(&(sctp)->sctp_reflock); \
188 188 (sctp)->sctp_refcnt++; \
189 189 DTRACE_PROBE1(sctp_refhold, sctp_t, sctp); \
190 190 ASSERT((sctp)->sctp_refcnt != 0); \
191 191 mutex_exit(&(sctp)->sctp_reflock); \
192 192 }
193 193
194 194 #define SCTP_REFRELE(sctp) { \
195 195 mutex_enter(&(sctp)->sctp_reflock); \
196 196 ASSERT((sctp)->sctp_refcnt != 0); \
197 197 if (--(sctp)->sctp_refcnt == 0) { \
198 198 DTRACE_PROBE1(sctp_refrele, sctp_t, sctp); \
199 199 mutex_exit(&(sctp)->sctp_reflock); \
200 200 CONN_DEC_REF((sctp)->sctp_connp); \
201 201 } else { \
202 202 DTRACE_PROBE1(sctp_refrele, sctp_t, sctp); \
203 203 mutex_exit(&(sctp)->sctp_reflock); \
204 204 } \
205 205 }
206 206
207 207 #define SCTP_PRINTADDR(a) (a).s6_addr32[0], (a).s6_addr32[1],\
208 208 (a).s6_addr32[2], (a).s6_addr32[3]
209 209
210 210 #define CONN2SCTP(conn) ((sctp_t *)(&((conn_t *)conn)[1]))
211 211
212 212 /*
213 213 * Outbound data, flags and macros for per-message, per-chunk info
214 214 */
215 215 typedef struct {
216 216 int64_t smh_ttl; /* Time to Live */
217 217 int64_t smh_tob; /* Time of Birth */
218 218 uint32_t smh_context;
219 219 uint16_t smh_sid;
220 220 uint16_t smh_ssn;
221 221 uint32_t smh_ppid;
222 222 uint16_t smh_flags;
223 223 uint32_t smh_msglen;
224 224 } sctp_msg_hdr_t;
225 225
226 226 #define SCTP_CHUNK_FLAG_SENT 0x01
227 227 #define SCTP_CHUNK_FLAG_REXMIT 0x02
228 228 #define SCTP_CHUNK_FLAG_ACKED 0x04
229 229 #define SCTP_MSG_FLAG_CHUNKED 0x08
230 230 #define SCTP_MSG_FLAG_ABANDONED 0x10
231 231 #define SCTP_CHUNK_FLAG_ABANDONED 0x20
232 232
233 233 #define SCTP_CHUNK_CLEAR_FLAGS(mp) ((mp)->b_flag = 0)
234 234 /*
235 235 * If we are transmitting the chunk for the first time we assign the TSN and
236 236 * SSN here. The reason we assign the SSN here (as opposed to doing it in
237 237 * sctp_chunkify()) is that the chunk may expire, if PRSCTP is enabled, before
238 238 * we get a chance to send it out. If we assign the SSN in sctp_chunkify()
239 239 * and this happens, then we need to send a Forward TSN to the peer, which
240 240 * will be expecting this SSN, assuming ordered. If we assign it here we
241 241 * can just take out the chunk from the transmit list without having to
242 242 * send a Forward TSN chunk. While assigning the SSN we use (meta)->b_cont
243 243 * to determine if it needs a new SSN (i.e. the next SSN for the stream),
244 244 * since (meta)->b_cont signifies the first chunk of a message (if the message
245 245 * is unordered, then the SSN is 0).
246 246 *
247 247 */
248 248 #define SCTP_CHUNK_SENT(sctp, mp, sdc, fp, chunkdata, meta) { \
249 249 if (!SCTP_CHUNK_ISSENT(mp)) { \
250 250 sctp_msg_hdr_t *mhdr = (sctp_msg_hdr_t *)(meta)->b_rptr; \
251 251 ASSERT(!SCTP_CHUNK_ABANDONED(mp)); \
252 252 (mp)->b_flag = SCTP_CHUNK_FLAG_SENT; \
253 253 (sdc)->sdh_tsn = htonl((sctp)->sctp_ltsn++); \
254 254 if ((mhdr)->smh_flags & MSG_UNORDERED) { \
255 255 (sdc)->sdh_ssn = 0; \
256 256 SCTP_DATA_SET_UBIT(sdc); \
257 257 BUMP_LOCAL((sctp)->sctp_oudchunks); \
258 258 } else { \
259 259 BUMP_LOCAL((sctp)->sctp_odchunks); \
260 260 if ((mp) == (meta)->b_cont) { \
261 261 mhdr->smh_ssn = htons( \
262 262 (sctp)->sctp_ostrcntrs[mhdr->smh_sid]++); \
263 263 } \
264 264 (sdc)->sdh_ssn = mhdr->smh_ssn; \
265 265 } \
266 266 DTRACE_PROBE3(sctp__chunk__sent1, sctp_t *, sctp, \
267 267 mblk_t *, mp, mblk_t *, meta); \
268 268 (sctp)->sctp_unacked += (chunkdata); \
269 269 (sctp)->sctp_unsent -= (chunkdata); \
270 270 (sctp)->sctp_frwnd -= (chunkdata); \
271 271 } else { \
272 272 if (SCTP_CHUNK_ISACKED(mp)) { \
273 273 (sctp)->sctp_unacked += (chunkdata); \
274 274 } else { \
275 275 ASSERT(SCTP_CHUNK_DEST(mp)->sf_suna >= ((chunkdata) + \
276 276 sizeof (*sdc))); \
277 277 SCTP_CHUNK_DEST(mp)->sf_suna -= ((chunkdata) + \
278 278 sizeof (*sdc)); \
279 279 } \
280 280 DTRACE_PROBE3(sctp__chunk__sent2, sctp_t *, sctp, \
281 281 mblk_t *, mp, mblk_t *, meta); \
282 282 (mp)->b_flag &= ~(SCTP_CHUNK_FLAG_REXMIT | \
283 283 SCTP_CHUNK_FLAG_ACKED); \
284 284 SCTP_CHUNK_SET_SACKCNT(mp, 0); \
285 285 BUMP_LOCAL(sctp->sctp_rxtchunks); \
286 286 BUMP_LOCAL((sctp)->sctp_T3expire); \
287 287 BUMP_LOCAL((fp)->sf_T3expire); \
288 288 } \
289 289 SCTP_SET_CHUNK_DEST(mp, fp); \
290 290 (fp)->sf_suna += ((chunkdata) + sizeof (*sdc)); \
291 291 }
292 292
293 293 #define SCTP_CHUNK_ISSENT(mp) ((mp)->b_flag & SCTP_CHUNK_FLAG_SENT)
294 294 #define SCTP_CHUNK_CANSEND(mp) \
295 295 (!(SCTP_CHUNK_ABANDONED(mp)) && \
296 296 (((mp)->b_flag & (SCTP_CHUNK_FLAG_REXMIT|SCTP_CHUNK_FLAG_SENT)) != \
297 297 SCTP_CHUNK_FLAG_SENT))
298 298
299 299 #define SCTP_CHUNK_DEST(mp) ((sctp_faddr_t *)(mp)->b_queue)
300 300 #define SCTP_SET_CHUNK_DEST(mp, fp) ((mp)->b_queue = (queue_t *)fp)
301 301
302 302 #define SCTP_CHUNK_REXMIT(sctp, mp) { \
303 303 DTRACE_PROBE2(sctp__chunk__rexmit, sctp_t *, sctp, mblk_t *, \
304 304 mp); \
305 305 (mp)->b_flag |= SCTP_CHUNK_FLAG_REXMIT; \
306 306 }
307 307 #define SCTP_CHUNK_CLEAR_REXMIT(mp) ((mp)->b_flag &= ~SCTP_CHUNK_FLAG_REXMIT)
308 308 #define SCTP_CHUNK_WANT_REXMIT(mp) ((mp)->b_flag & SCTP_CHUNK_FLAG_REXMIT)
309 309
310 310 #define SCTP_CHUNK_ACKED(mp) \
311 311 ((mp)->b_flag = (SCTP_CHUNK_FLAG_SENT|SCTP_CHUNK_FLAG_ACKED))
312 312 #define SCTP_CHUNK_ISACKED(mp) ((mp)->b_flag & SCTP_CHUNK_FLAG_ACKED)
313 313 #define SCTP_CHUNK_CLEAR_ACKED(sctp, mp) { \
314 314 DTRACE_PROBE2(sctp__chunk__clracked, sctp_t *, sctp, mblk_t *, \
315 315 mp); \
316 316 (mp)->b_flag &= ~SCTP_CHUNK_FLAG_ACKED; \
317 317 }
318 318
319 319 #define SCTP_CHUNK_SACKCNT(mp) ((intptr_t)((mp)->b_prev))
320 320 #define SCTP_CHUNK_SET_SACKCNT(mp, val) ((mp)->b_prev = \
321 321 (mblk_t *)(uintptr_t)(val))
322 322
323 323 #define SCTP_MSG_SET_CHUNKED(mp) ((mp)->b_flag |= SCTP_MSG_FLAG_CHUNKED)
324 324 #define SCTP_MSG_CLEAR_CHUNKED(mp)((mp)->b_flag &= ~SCTP_MSG_FLAG_CHUNKED)
325 325 #define SCTP_IS_MSG_CHUNKED(mp) ((mp)->b_flag & SCTP_MSG_FLAG_CHUNKED)
326 326
327 327 /* For PR-SCTP */
328 328 #define SCTP_ABANDON_CHUNK(mp) ((mp)->b_flag |= SCTP_CHUNK_FLAG_ABANDONED)
329 329 #define SCTP_CHUNK_ABANDONED(mp) \
330 330 ((mp)->b_flag & SCTP_CHUNK_FLAG_ABANDONED)
331 331
332 332 #define SCTP_MSG_SET_ABANDONED(mp) \
333 333 ((mp)->b_flag |= SCTP_MSG_FLAG_ABANDONED)
334 334 #define SCTP_MSG_CLEAR_ABANDONED(mp)((mp)->b_flag &= ~SCTP_MSG_FLAG_ABANDONED)
335 335 #define SCTP_IS_MSG_ABANDONED(mp) ((mp)->b_flag & SCTP_MSG_FLAG_ABANDONED)
336 336
337 337 /*
338 338 * Check if a message has expired. A message is expired if
339 339 * 1. It has a non-zero time to live value and has not been sent before
340 340 * that time expires.
341 341 * 2. It is sent using PRSCTP and it has not been SACK'ed before
342 342 * its lifetime expires.
343 343 */
344 344 #define SCTP_MSG_TO_BE_ABANDONED(meta, mhdr, sctp) \
345 345 (((!SCTP_CHUNK_ISSENT((meta)->b_cont) && (mhdr)->smh_ttl > 0) || \
346 346 ((sctp)->sctp_prsctp_aware && ((mhdr)->smh_flags & MSG_PR_SCTP))) && \
347 347 ((ddi_get_lbolt64() - (mhdr)->smh_tob) > (mhdr)->smh_ttl))
348 348
349 349 /* SCTP association hash function. */
350 350 #define SCTP_CONN_HASH(sctps, ports) \
351 351 ((((ports) ^ ((ports) >> 16)) * 31) & \
352 352 ((sctps)->sctps_conn_hash_size - 1))
353 353
354 354 /*
355 355 * Linked list struct to store SCTP listener association limit configuration
356 356 * per IP stack. The list is stored at sctps_listener_conf in sctp_stack_t.
357 357 *
358 358 * sl_port: the listener port of this limit configuration
359 359 * sl_ratio: the maximum amount of memory consumed by all concurrent SCTP
360 360 * connections created by a listener does not exceed 1/tl_ratio
361 361 * of the total system memory. Note that this is only an
362 362 * approximation.
363 363 * sl_link: linked list struct
364 364 */
365 365 typedef struct sctp_listener_s {
366 366 in_port_t sl_port;
367 367 uint32_t sl_ratio;
368 368 list_node_t sl_link;
369 369 } sctp_listener_t;
370 370
371 371 /*
372 372 * If there is a limit set on the number of association allowed per each
373 373 * listener, the following struct is used to store that counter. It keeps
374 374 * the number of SCTP association created by a listener. Note that this needs
375 375 * to be separated from the listener since the listener can go away before
376 376 * all the associations are gone.
377 377 *
378 378 * When the struct is allocated, slc_cnt is set to 1. When a new association
379 379 * is created by the listener, slc_cnt is incremented by 1. When an
380 380 * association created by the listener goes away, slc_count is decremented by
381 381 * 1. When the listener itself goes away, slc_cnt is decremented by one.
382 382 * The last association (or the listener) which decrements slc_cnt to zero
383 383 * frees the struct.
384 384 *
385 385 * slc_max is the maximum number of concurrent associations created from a
386 386 * listener. It is calculated when the sctp_listen_cnt_t is allocated.
387 387 *
388 388 * slc_report_time stores the time when cmn_err() is called to report that the
389 389 * max has been exceeeded. Report is done at most once every
390 390 * SCTP_SLC_REPORT_INTERVAL mins for a listener.
391 391 *
392 392 * slc_drop stores the number of connection attempt dropped because the
393 393 * limit has reached.
394 394 */
395 395 typedef struct sctp_listen_cnt_s {
396 396 uint32_t slc_max;
397 397 uint32_t slc_cnt;
398 398 int64_t slc_report_time;
399 399 uint32_t slc_drop;
400 400 } sctp_listen_cnt_t;
401 401
402 402 #define SCTP_SLC_REPORT_INTERVAL (30 * MINUTES)
403 403
404 404 #define SCTP_DECR_LISTEN_CNT(sctp) \
405 405 { \
406 406 ASSERT((sctp)->sctp_listen_cnt->slc_cnt > 0); \
407 407 if (atomic_add_32_nv(&(sctp)->sctp_listen_cnt->slc_cnt, -1) == 0) \
408 408 kmem_free((sctp)->sctp_listen_cnt, sizeof (sctp_listen_cnt_t));\
409 409 (sctp)->sctp_listen_cnt = NULL; \
410 410 }
411 411
412 412 /* Increment and decrement the number of associations in sctp_stack_t. */
413 413 #define SCTPS_ASSOC_INC(sctps) \
414 414 atomic_inc_64( \
415 415 (uint64_t *)&(sctps)->sctps_sc[CPU->cpu_seqid]->sctp_sc_assoc_cnt)
416 416
417 417 #define SCTPS_ASSOC_DEC(sctps) \
418 418 atomic_dec_64( \
419 419 (uint64_t *)&(sctps)->sctps_sc[CPU->cpu_seqid]->sctp_sc_assoc_cnt)
420 420
421 421 #define SCTP_ASSOC_EST(sctps, sctp) \
422 422 { \
423 423 (sctp)->sctp_state = SCTPS_ESTABLISHED; \
424 424 (sctp)->sctp_assoc_start_time = (uint32_t)LBOLT_FASTPATH64; \
425 425 SCTPS_ASSOC_INC(sctps); \
426 426 }
427 427
428 428 /*
429 429 * Bind hash array size and hash function. The size must be a power
430 430 * of 2 and lport must be in host byte order.
431 431 */
432 432 #define SCTP_BIND_FANOUT_SIZE 2048
433 433 #define SCTP_BIND_HASH(lport) (((lport) * 31) & (SCTP_BIND_FANOUT_SIZE - 1))
434 434
435 435 /* options that SCTP negotiates during association establishment */
436 436 #define SCTP_PRSCTP_OPTION 0x01
437 437
↓ open down ↓ |
437 lines elided |
↑ open up ↑ |
438 438 /*
439 439 * Listener hash array size and hash function. The size must be a power
440 440 * of 2 and lport must be in host byte order.
441 441 */
442 442 #define SCTP_LISTEN_FANOUT_SIZE 512
443 443 #define SCTP_LISTEN_HASH(lport) (((lport) * 31) & (SCTP_LISTEN_FANOUT_SIZE - 1))
444 444
445 445 typedef struct sctp_tf_s {
446 446 struct sctp_s *tf_sctp;
447 447 kmutex_t tf_lock;
448 +#define SF_CACHEL_PAD 64
449 + uchar_t tf_pad[SF_CACHEL_PAD - (sizeof (struct sctp_s *) +
450 + sizeof (kmutex_t))];
448 451 } sctp_tf_t;
449 452
450 453 /* Round up the value to the nearest mss. */
451 454 #define MSS_ROUNDUP(value, mss) ((((value) - 1) / (mss) + 1) * (mss))
452 455
453 456 extern sin_t sctp_sin_null; /* Zero address for quick clears */
454 457 extern sin6_t sctp_sin6_null; /* Zero address for quick clears */
455 458
456 459 #define SCTP_IS_DETACHED(sctp) ((sctp)->sctp_detached)
457 460
458 461 /* Data structure used to track received TSNs */
459 462 typedef struct sctp_set_s {
460 463 struct sctp_set_s *next;
461 464 struct sctp_set_s *prev;
462 465 uint32_t begin;
463 466 uint32_t end;
464 467 } sctp_set_t;
465 468
466 469 /* Data structure used to track TSNs for PR-SCTP */
467 470 typedef struct sctp_ftsn_set_s {
468 471 struct sctp_ftsn_set_s *next;
469 472 ftsn_entry_t ftsn_entries;
470 473 } sctp_ftsn_set_t;
471 474
472 475 /* Data structure used to track incoming SCTP streams */
473 476 typedef struct sctp_instr_s {
474 477 mblk_t *istr_msgs;
475 478 int istr_nmsgs;
476 479 uint16_t nextseq;
477 480 struct sctp_s *sctp;
478 481 mblk_t *istr_reass;
479 482 } sctp_instr_t;
480 483
481 484 /* Reassembly data structure (per-stream) */
482 485 typedef struct sctp_reass_s {
483 486 uint16_t sr_ssn;
484 487 uint16_t sr_needed;
485 488 uint16_t sr_got;
486 489 uint16_t sr_msglen; /* len of consecutive fragments */
487 490 /* from the begining (B-bit) */
488 491 mblk_t *sr_tail;
489 492 boolean_t sr_hasBchunk; /* If the fragment list begins with */
490 493 /* a B-bit set chunk */
491 494 uint32_t sr_nexttsn; /* TSN of the next fragment we */
492 495 /* are expecting */
493 496 boolean_t sr_partial_delivered;
494 497 } sctp_reass_t;
495 498
496 499 /* debugging */
497 500 #undef dprint
498 501 #ifdef DEBUG
499 502 extern int sctpdebug;
500 503 #define dprint(level, args) { if (sctpdebug > (level)) printf args; }
501 504 #else
502 505 #define dprint(level, args) {}
503 506 #endif
504 507
505 508
506 509 /* Peer address tracking */
507 510
508 511 /*
509 512 * States for peer addresses
510 513 *
511 514 * SCTP_FADDRS_UNCONFIRMED: we have not communicated with this peer address
512 515 * before, mark it as unconfirmed so that we will not send data to it.
513 516 * All addresses initially are in unconfirmed state and required
514 517 * validation. SCTP sends a heartbeat to each of them and when it gets
515 518 * back a heartbeat ACK, the address will be marked as alive. This
516 519 * validation fixes a security issue with multihoming. If an attacker
517 520 * establishes an association with us and tells us that it has addresses
518 521 * belonging to another host A, this will prevent A from communicating
519 522 * with us. This is fixed by peer address validation. In the above case,
520 523 * A will respond with an abort.
521 524 *
522 525 * SCTP_FADDRS_ALIVE: this peer address is alive and we can communicate with
523 526 * it with no problem.
524 527 *
525 528 * SCTP_FADDRS_DOWN: we have exceeded the retransmission limit to this
526 529 * peer address. Once an address is marked down, we will only send
527 530 * a heartbeat to it every hb_interval in case it becomes alive now.
528 531 *
529 532 * SCTP_FADDRS_UNREACH: there is no suitable source address to send to
530 533 * this peer address. For example, the peer address is v6 but we only
531 534 * have v4 addresses. It is marked unreachable until there is an
532 535 * address configuration change. At that time, mark these addresses
533 536 * as unconfirmed and try again to see if those unreachable addresses
534 537 * are OK as we may have more source addresses.
535 538 */
536 539 typedef enum {
537 540 SCTP_FADDRS_UNREACH,
538 541 SCTP_FADDRS_DOWN,
539 542 SCTP_FADDRS_ALIVE,
540 543 SCTP_FADDRS_UNCONFIRMED
541 544 } faddr_state_t;
542 545
543 546 typedef struct sctp_faddr_s {
544 547 struct sctp_faddr_s *sf_next;
545 548 faddr_state_t sf_state;
546 549
547 550 in6_addr_t sf_faddr;
548 551 in6_addr_t sf_saddr;
549 552
550 553 int64_t sf_hb_expiry; /* time to retransmit heartbeat */
551 554 uint32_t sf_hb_interval; /* the heartbeat interval */
552 555
553 556 int sf_rto; /* RTO in tick */
554 557 int sf_srtt; /* Smoothed RTT in tick */
555 558 int sf_rttvar; /* RTT variance in tick */
556 559 uint32_t sf_rtt_updates;
557 560 int sf_strikes;
558 561 int sf_max_retr;
559 562 uint32_t sf_pmss;
560 563 uint32_t sf_cwnd;
561 564 uint32_t sf_ssthresh;
562 565 uint32_t sf_suna; /* sent - unack'ed */
563 566 uint32_t sf_pba; /* partial bytes acked */
564 567 uint32_t sf_acked;
565 568 int64_t sf_lastactive;
566 569 mblk_t *sf_timer_mp; /* retransmission timer control */
567 570 uint32_t
568 571 sf_hb_pending : 1,
569 572 sf_timer_running : 1,
570 573 sf_df : 1,
571 574 sf_pmtu_discovered : 1,
572 575
573 576 sf_rc_timer_running : 1,
574 577 sf_isv4 : 1,
575 578 sf_hb_enabled : 1;
576 579
577 580 mblk_t *sf_rc_timer_mp; /* reliable control chunk timer */
578 581 ip_xmit_attr_t *sf_ixa; /* Transmit attributes */
579 582 uint32_t sf_T3expire; /* # of times T3 timer expired */
580 583
581 584 uint64_t sf_hb_secret; /* per addr "secret" in heartbeat */
582 585 uint32_t sf_rxt_unacked; /* # unack'ed retransmitted bytes */
583 586 } sctp_faddr_t;
584 587
585 588 /* Flags to indicate supported address type in the PARM_SUP_ADDRS. */
586 589 #define PARM_SUPP_V6 0x1
587 590 #define PARM_SUPP_V4 0x2
588 591
589 592 /*
590 593 * Set heartbeat interval plus jitter. The jitter is supposed to be random,
591 594 * up to +/- 50% of the RTO. We use gethrtime() here for performance reason
592 595 * as the jitter does not really need to be "very" random.
593 596 */
594 597 #define SET_HB_INTVL(fp) \
595 598 ((fp)->sf_hb_interval + (fp)->sf_rto + ((fp)->sf_rto >> 1) - \
596 599 (uint_t)gethrtime() % (fp)->sf_rto)
597 600
598 601 #define SCTP_IPIF_HASH 16
599 602
600 603 typedef struct sctp_ipif_hash_s {
601 604 list_t sctp_ipif_list;
602 605 int ipif_count;
603 606 krwlock_t ipif_hash_lock;
604 607 } sctp_ipif_hash_t;
605 608
606 609
607 610 /*
608 611 * Initialize cwnd according to RFC 3390. def_max_init_cwnd is
609 612 * either sctp_slow_start_initial or sctp_slow_start_after idle
610 613 * depending on the caller.
611 614 */
612 615 #define SET_CWND(fp, mss, def_max_init_cwnd) \
613 616 { \
614 617 (fp)->sf_cwnd = MIN(def_max_init_cwnd * (mss), \
615 618 MIN(4 * (mss), MAX(2 * (mss), 4380 / (mss) * (mss)))); \
616 619 }
617 620
618 621
619 622 struct sctp_s;
620 623
621 624 /*
622 625 * Control structure for each open SCTP stream,
623 626 * defined only within the kernel or for a kmem user.
624 627 * NOTE: sctp_reinit_values MUST have a line for each field in this structure!
625 628 */
626 629 #if (defined(_KERNEL) || defined(_KMEMUSER))
627 630
628 631 typedef struct sctp_s {
629 632
630 633 /*
631 634 * The following is shared with (and duplicated) in IP, so if you
632 635 * make changes, make sure you also change things in ip_sctp.c.
633 636 */
634 637 struct sctp_s *sctp_conn_hash_next;
635 638 struct sctp_s *sctp_conn_hash_prev;
636 639
637 640 struct sctp_s *sctp_listen_hash_next;
638 641 struct sctp_s *sctp_listen_hash_prev;
639 642
640 643 sctp_tf_t *sctp_listen_tfp; /* Ptr to tf */
641 644 sctp_tf_t *sctp_conn_tfp; /* Ptr to tf */
642 645
643 646 /* Global list of sctp */
644 647 list_node_t sctp_list;
645 648
646 649 sctp_faddr_t *sctp_faddrs;
647 650 int sctp_nfaddrs;
648 651 sctp_ipif_hash_t sctp_saddrs[SCTP_IPIF_HASH];
649 652 int sctp_nsaddrs;
650 653
651 654 kmutex_t sctp_lock;
652 655 kcondvar_t sctp_cv;
653 656 boolean_t sctp_running;
654 657
655 658 #define sctp_ulpd sctp_connp->conn_upper_handle
656 659 #define sctp_upcalls sctp_connp->conn_upcalls
657 660
658 661 #define sctp_ulp_newconn sctp_upcalls->su_newconn
659 662 #define sctp_ulp_connected sctp_upcalls->su_connected
660 663 #define sctp_ulp_disconnected sctp_upcalls->su_disconnected
661 664 #define sctp_ulp_opctl sctp_upcalls->su_opctl
662 665 #define sctp_ulp_recv sctp_upcalls->su_recv
663 666 #define sctp_ulp_txq_full sctp_upcalls->su_txq_full
664 667 #define sctp_ulp_prop sctp_upcalls->su_set_proto_props
665 668
666 669 int32_t sctp_state;
667 670
668 671 conn_t *sctp_connp; /* conn_t stuff */
669 672 sctp_stack_t *sctp_sctps;
670 673
671 674 /* Peer address tracking */
672 675 sctp_faddr_t *sctp_lastfaddr; /* last faddr in list */
673 676 sctp_faddr_t *sctp_primary; /* primary faddr */
674 677 sctp_faddr_t *sctp_current; /* current faddr */
675 678 sctp_faddr_t *sctp_lastdata; /* last data seen from this */
676 679
677 680 /* Outbound data tracking */
678 681 mblk_t *sctp_xmit_head;
679 682 mblk_t *sctp_xmit_tail;
680 683 mblk_t *sctp_xmit_unsent;
681 684 mblk_t *sctp_xmit_unsent_tail;
682 685 mblk_t *sctp_xmit_unacked;
683 686
684 687 int32_t sctp_unacked; /* # of unacked bytes */
685 688 int32_t sctp_unsent; /* # of unsent bytes in hand */
686 689
687 690 uint32_t sctp_ltsn; /* Local instance TSN */
688 691 uint32_t sctp_lastack_rxd; /* Last rx'd cumtsn */
689 692 uint32_t sctp_recovery_tsn; /* Exit from fast recovery */
690 693 uint32_t sctp_adv_pap; /* Adv. Peer Ack Point */
691 694
692 695 uint16_t sctp_num_ostr;
693 696 uint16_t *sctp_ostrcntrs;
694 697
695 698 mblk_t *sctp_pad_mp; /* pad unaligned data chunks */
696 699
697 700 /* sendmsg() default parameters */
698 701 uint16_t sctp_def_stream; /* default stream id */
699 702 uint16_t sctp_def_flags; /* default xmit flags */
700 703 uint32_t sctp_def_ppid; /* default payload id */
701 704 uint32_t sctp_def_context; /* default context */
702 705 uint32_t sctp_def_timetolive; /* default msg TTL */
703 706
704 707 /* Inbound data tracking */
705 708 sctp_set_t *sctp_sack_info; /* Sack tracking */
706 709 mblk_t *sctp_ack_mp; /* Delayed ACK timer block */
707 710 sctp_instr_t *sctp_instr; /* Instream trackers */
708 711 mblk_t *sctp_uo_frags; /* Un-ordered msg. fragments */
709 712 uint32_t sctp_ftsn; /* Peer's TSN */
710 713 uint32_t sctp_lastacked; /* last cumtsn SACKd */
711 714 uint16_t sctp_num_istr; /* No. of instreams */
712 715 int32_t sctp_istr_nmsgs; /* No. of chunks in instreams */
713 716 int32_t sctp_sack_gaps; /* No. of received gaps */
714 717 int32_t sctp_sack_toggle; /* SACK every other pkt */
715 718
716 719 /* RTT calculation */
717 720 uint32_t sctp_rtt_tsn;
718 721 int64_t sctp_out_time;
719 722
720 723 /* Stats can be reset by snmp users kstat, netstat and snmp agents */
721 724 uint64_t sctp_opkts; /* sent pkts */
722 725 uint64_t sctp_obchunks; /* sent control chunks */
723 726 uint64_t sctp_odchunks; /* sent ordered data chunks */
724 727 uint64_t sctp_oudchunks; /* sent unord data chunks */
725 728 uint64_t sctp_rxtchunks; /* retransmitted chunks */
726 729 uint64_t sctp_ipkts; /* recv pkts */
727 730 uint64_t sctp_ibchunks; /* recv control chunks */
728 731 uint64_t sctp_idchunks; /* recv ordered data chunks */
729 732 uint64_t sctp_iudchunks; /* recv unord data chunks */
730 733 uint64_t sctp_fragdmsgs;
731 734 uint64_t sctp_reassmsgs;
732 735 uint32_t sctp_T1expire; /* # of times T1timer expired */
733 736 uint32_t sctp_T2expire; /* # of times T2timer expired */
734 737 uint32_t sctp_T3expire; /* # of times T3timer expired */
735 738 uint32_t sctp_assoc_start_time; /* time when assoc was est. */
736 739
737 740 uint32_t sctp_frwnd; /* Peer RWND */
738 741 uint32_t sctp_cwnd_max;
739 742
740 743 /* Inbound flow control */
741 744 int32_t sctp_rwnd; /* Current receive window */
742 745 int32_t sctp_arwnd; /* Last advertised window */
743 746 int32_t sctp_rxqueued; /* No. of bytes in RX q's */
744 747 int32_t sctp_ulp_rxqueued; /* Data in ULP */
745 748
746 749 /* Pre-initialized composite headers */
747 750 uchar_t *sctp_iphc; /* v4 sctp/ip hdr template buffer */
748 751 uchar_t *sctp_iphc6; /* v6 sctp/ip hdr template buffer */
749 752
750 753 int32_t sctp_iphc_len; /* actual allocated v4 buffer size */
751 754 int32_t sctp_iphc6_len; /* actual allocated v6 buffer size */
752 755
753 756 int32_t sctp_hdr_len; /* len of combined SCTP/IP v4 hdr */
754 757 int32_t sctp_hdr6_len; /* len of combined SCTP/IP v6 hdr */
755 758
756 759 ipha_t *sctp_ipha; /* IPv4 header in the buffer */
757 760 ip6_t *sctp_ip6h; /* IPv6 header in the buffer */
758 761
759 762 int32_t sctp_ip_hdr_len; /* Byte len of our current v4 hdr */
760 763 int32_t sctp_ip_hdr6_len; /* Byte len of our current v6 hdr */
761 764
762 765 sctp_hdr_t *sctp_sctph; /* sctp header in combined v4 hdr */
763 766 sctp_hdr_t *sctp_sctph6; /* sctp header in combined v6 hdr */
764 767
765 768 uint32_t sctp_lvtag; /* local SCTP instance verf tag */
766 769 uint32_t sctp_fvtag; /* Peer's SCTP verf tag */
767 770
768 771 /* Path MTU Discovery */
769 772 int64_t sctp_last_mtu_probe;
770 773 clock_t sctp_mtu_probe_intvl;
771 774 uint32_t sctp_mss; /* Max send size (not TCP MSS!) */
772 775
773 776 /* structs sctp_bits, sctp_events are for clearing all bits at once */
774 777 struct {
775 778 uint32_t
776 779
777 780 sctp_understands_asconf : 1, /* Peer handles ASCONF chunks */
778 781 sctp_cchunk_pend : 1, /* Control chunk in flight. */
779 782 sctp_lingering : 1, /* Lingering in close */
780 783 sctp_loopback: 1, /* src and dst are the same machine */
781 784
782 785 sctp_force_sack : 1,
783 786 sctp_ack_timer_running: 1, /* Delayed ACK timer running */
784 787 sctp_hwcksum : 1, /* The NIC is capable of hwcksum */
785 788 sctp_understands_addip : 1,
786 789
787 790 sctp_bound_to_all : 1,
788 791 sctp_cansleep : 1, /* itf routines can sleep */
789 792 sctp_detached : 1, /* If we're detached from a stream */
790 793 sctp_send_adaptation : 1, /* send adaptation layer ind */
791 794
792 795 sctp_recv_adaptation : 1, /* recv adaptation layer ind */
793 796 sctp_ndelay : 1, /* turn off Nagle */
794 797 sctp_condemned : 1, /* this sctp is about to disappear */
795 798 sctp_chk_fast_rexmit : 1, /* check for fast rexmit message */
796 799
797 800 sctp_prsctp_aware : 1, /* is peer PR-SCTP aware? */
798 801 sctp_linklocal : 1, /* is linklocal assoc. */
799 802 sctp_rexmitting : 1, /* SCTP is retransmitting */
800 803 sctp_zero_win_probe : 1, /* doing zero win probe */
801 804
802 805 sctp_txq_full : 1, /* the tx queue is full */
803 806 sctp_ulp_discon_done : 1, /* ulp_disconnecting done */
804 807 sctp_flowctrld : 1, /* upper layer flow controlled */
805 808 sctp_dummy : 5;
806 809 } sctp_bits;
807 810 struct {
808 811 uint32_t
809 812
810 813 sctp_recvsndrcvinfo : 1,
811 814 sctp_recvassocevnt : 1,
812 815 sctp_recvpathevnt : 1,
813 816 sctp_recvsendfailevnt : 1,
814 817
815 818 sctp_recvpeererr : 1,
816 819 sctp_recvshutdownevnt : 1,
817 820 sctp_recvpdevnt : 1,
818 821 sctp_recvalevnt : 1;
819 822 } sctp_events;
820 823 #define sctp_priv_stream sctp_bits.sctp_priv_stream
821 824 #define sctp_understands_asconf sctp_bits.sctp_understands_asconf
822 825 #define sctp_cchunk_pend sctp_bits.sctp_cchunk_pend
823 826 #define sctp_lingering sctp_bits.sctp_lingering
824 827 #define sctp_loopback sctp_bits.sctp_loopback
825 828 #define sctp_force_sack sctp_bits.sctp_force_sack
826 829 #define sctp_ack_timer_running sctp_bits.sctp_ack_timer_running
827 830 #define sctp_hwcksum sctp_bits.sctp_hwcksum
828 831 #define sctp_understands_addip sctp_bits.sctp_understands_addip
829 832 #define sctp_bound_to_all sctp_bits.sctp_bound_to_all
830 833 #define sctp_cansleep sctp_bits.sctp_cansleep
831 834 #define sctp_detached sctp_bits.sctp_detached
832 835 #define sctp_send_adaptation sctp_bits.sctp_send_adaptation
833 836 #define sctp_recv_adaptation sctp_bits.sctp_recv_adaptation
834 837 #define sctp_ndelay sctp_bits.sctp_ndelay
835 838 #define sctp_condemned sctp_bits.sctp_condemned
836 839 #define sctp_chk_fast_rexmit sctp_bits.sctp_chk_fast_rexmit
837 840 #define sctp_prsctp_aware sctp_bits.sctp_prsctp_aware
838 841 #define sctp_linklocal sctp_bits.sctp_linklocal
839 842 #define sctp_rexmitting sctp_bits.sctp_rexmitting
840 843 #define sctp_zero_win_probe sctp_bits.sctp_zero_win_probe
841 844 #define sctp_txq_full sctp_bits.sctp_txq_full
842 845 #define sctp_ulp_discon_done sctp_bits.sctp_ulp_discon_done
843 846 #define sctp_flowctrld sctp_bits.sctp_flowctrld
844 847
845 848 #define sctp_recvsndrcvinfo sctp_events.sctp_recvsndrcvinfo
846 849 #define sctp_recvassocevnt sctp_events.sctp_recvassocevnt
847 850 #define sctp_recvpathevnt sctp_events.sctp_recvpathevnt
848 851 #define sctp_recvsendfailevnt sctp_events.sctp_recvsendfailevnt
849 852 #define sctp_recvpeererr sctp_events.sctp_recvpeererr
850 853 #define sctp_recvshutdownevnt sctp_events.sctp_recvshutdownevnt
851 854 #define sctp_recvpdevnt sctp_events.sctp_recvpdevnt
852 855 #define sctp_recvalevnt sctp_events.sctp_recvalevnt
853 856
854 857 /* Retransmit info */
855 858 mblk_t *sctp_cookie_mp; /* cookie chunk, if rxt needed */
856 859 int32_t sctp_strikes; /* Total number of assoc strikes */
857 860 int32_t sctp_max_init_rxt;
858 861 int32_t sctp_pa_max_rxt; /* Max per-assoc retransmit cnt */
859 862 int32_t sctp_pp_max_rxt; /* Max per-path retransmit cnt */
860 863 uint32_t sctp_rto_max;
861 864 uint32_t sctp_rto_max_init;
862 865 uint32_t sctp_rto_min;
863 866 uint32_t sctp_rto_initial;
864 867
865 868 int64_t sctp_last_secret_update;
866 869 uint8_t sctp_secret[SCTP_SECRET_LEN]; /* for cookie auth */
867 870 uint8_t sctp_old_secret[SCTP_SECRET_LEN];
868 871 uint32_t sctp_cookie_lifetime; /* cookie lifetime in tick */
869 872
870 873 /* Bind hash tables */
871 874 kmutex_t *sctp_bind_lockp; /* Ptr to tf_lock */
872 875 struct sctp_s *sctp_bind_hash;
873 876 struct sctp_s **sctp_ptpbhn;
874 877
875 878 /* Shutdown / cleanup */
876 879 sctp_faddr_t *sctp_shutdown_faddr; /* rotate faddr during shutd */
877 880 int32_t sctp_client_errno; /* How the client screwed up */
878 881 kmutex_t sctp_reflock; /* Protects sctp_refcnt & timer mp */
879 882 ushort_t sctp_refcnt; /* No. of pending upstream msg */
880 883 mblk_t *sctp_timer_mp; /* List of fired timers. */
881 884
882 885 mblk_t *sctp_heartbeat_mp; /* Timer block for heartbeats */
883 886 uint32_t sctp_hb_interval; /* Default hb_interval */
884 887
885 888 int32_t sctp_autoclose; /* Auto disconnect in ticks */
886 889 int64_t sctp_active; /* Last time data/sack on this conn */
887 890 uint32_t sctp_tx_adaptation_code; /* TX adaptation code */
888 891 uint32_t sctp_rx_adaptation_code; /* RX adaptation code */
889 892
890 893 /* Reliable control chunks */
891 894 mblk_t *sctp_cxmit_list; /* Xmit list for control chunks */
892 895 uint32_t sctp_lcsn; /* Our serial number */
893 896 uint32_t sctp_fcsn; /* Peer serial number */
894 897
895 898 /* Per association receive queue */
896 899 kmutex_t sctp_recvq_lock;
897 900 mblk_t *sctp_recvq;
898 901 mblk_t *sctp_recvq_tail;
899 902 taskq_t *sctp_recvq_tq;
900 903
901 904 /* IPv6 ancillary data */
902 905 uint_t sctp_recvifindex; /* last rcvd IPV6_RCVPKTINFO */
903 906 uint_t sctp_recvhops; /* " IPV6_RECVHOPLIMIT */
904 907 uint_t sctp_recvtclass; /* " IPV6_RECVTCLASS */
905 908 ip6_hbh_t *sctp_hopopts; /* " IPV6_RECVHOPOPTS */
906 909 ip6_dest_t *sctp_dstopts; /* " IPV6_RECVDSTOPTS */
907 910 ip6_dest_t *sctp_rthdrdstopts; /* " IPV6_RECVRTHDRDSTOPTS */
908 911 ip6_rthdr_t *sctp_rthdr; /* " IPV6_RECVRTHDR */
909 912 uint_t sctp_hopoptslen;
910 913 uint_t sctp_dstoptslen;
911 914 uint_t sctp_rthdrdstoptslen;
912 915 uint_t sctp_rthdrlen;
913 916
914 917 /* Stats */
915 918 uint64_t sctp_msgcount;
916 919 uint64_t sctp_prsctpdrop;
917 920
918 921 uint_t sctp_v4label_len; /* length of cached v4 label */
919 922 uint_t sctp_v6label_len; /* length of cached v6 label */
920 923 uint32_t sctp_rxt_nxttsn; /* Next TSN to be rexmitted */
921 924 uint32_t sctp_rxt_maxtsn; /* Max TSN sent at time out */
922 925
923 926 int sctp_pd_point; /* Partial delivery point */
924 927 mblk_t *sctp_err_chunks; /* Error chunks */
925 928 uint32_t sctp_err_len; /* Total error chunks length */
926 929
927 930 /* additional source data for per endpoint association statistics */
928 931 uint64_t sctp_outseqtsns; /* TSN rx > expected TSN */
929 932 uint64_t sctp_osacks; /* total sacks sent */
930 933 uint64_t sctp_isacks; /* total sacks received */
931 934 uint64_t sctp_idupchunks; /* rx dups, ord or unord */
932 935 uint64_t sctp_gapcnt; /* total gap acks rx */
933 936 /*
934 937 * Add the current data from the counters which are reset by snmp
935 938 * to these cumulative counters to use in per endpoint statistics.
936 939 */
937 940 uint64_t sctp_cum_obchunks; /* sent control chunks */
938 941 uint64_t sctp_cum_odchunks; /* sent ordered data chunks */
939 942 uint64_t sctp_cum_oudchunks; /* sent unord data chunks */
940 943 uint64_t sctp_cum_rxtchunks; /* retransmitted chunks */
941 944 uint64_t sctp_cum_ibchunks; /* recv control chunks */
942 945 uint64_t sctp_cum_idchunks; /* recv ordered data chunks */
943 946 uint64_t sctp_cum_iudchunks; /* recv unord data chunks */
944 947
945 948 /*
946 949 * When non-zero, this is the maximum observed RTO since assoc stats
947 950 * were last requested. When zero, no RTO update has occurred since
948 951 * the previous user request for stats on this endpoint.
949 952 */
950 953 int sctp_maxrto;
951 954 /*
952 955 * The stored value of sctp_maxrto passed to user during the previous
953 956 * user request for stats on this endpoint.
954 957 */
955 958 int sctp_prev_maxrto;
956 959
957 960 /* For association counting. */
958 961 sctp_listen_cnt_t *sctp_listen_cnt;
959 962 } sctp_t;
960 963
961 964 #define SCTP_TXQ_LEN(sctp) ((sctp)->sctp_unsent + (sctp)->sctp_unacked)
962 965 #define SCTP_TXQ_UPDATE(sctp) \
963 966 if ((sctp)->sctp_txq_full && SCTP_TXQ_LEN(sctp) <= \
964 967 (sctp)->sctp_connp->conn_sndlowat) { \
965 968 (sctp)->sctp_txq_full = 0; \
966 969 (sctp)->sctp_ulp_txq_full((sctp)->sctp_ulpd, \
967 970 B_FALSE); \
968 971 }
969 972
970 973 #endif /* (defined(_KERNEL) || defined(_KMEMUSER)) */
971 974
972 975 extern void sctp_ack_timer(sctp_t *);
973 976 extern size_t sctp_adaptation_code_param(sctp_t *, uchar_t *);
974 977 extern void sctp_adaptation_event(sctp_t *);
975 978 extern void sctp_add_err(sctp_t *, uint16_t, void *, size_t,
976 979 sctp_faddr_t *);
977 980 extern int sctp_add_faddr(sctp_t *, in6_addr_t *, int, boolean_t);
978 981 extern boolean_t sctp_add_ftsn_set(sctp_ftsn_set_t **, sctp_faddr_t *, mblk_t *,
979 982 uint_t *, uint32_t *);
980 983 extern void sctp_add_recvq(sctp_t *, mblk_t *, boolean_t,
981 984 ip_recv_attr_t *);
982 985 extern void sctp_add_unrec_parm(sctp_parm_hdr_t *, mblk_t **, boolean_t);
983 986 extern size_t sctp_addr_params(sctp_t *, int, uchar_t *, boolean_t);
984 987 extern mblk_t *sctp_add_proto_hdr(sctp_t *, sctp_faddr_t *, mblk_t *, int,
985 988 int *);
986 989 extern void sctp_addr_req(sctp_t *, mblk_t *);
987 990 extern sctp_t *sctp_addrlist2sctp(mblk_t *, sctp_hdr_t *, sctp_chunk_hdr_t *,
988 991 zoneid_t, sctp_stack_t *);
989 992 extern void sctp_check_adv_ack_pt(sctp_t *, mblk_t *, mblk_t *);
990 993 extern void sctp_assoc_event(sctp_t *, uint16_t, uint16_t,
991 994 sctp_chunk_hdr_t *);
992 995
993 996 extern void sctp_bind_hash_insert(sctp_tf_t *, sctp_t *, int);
994 997 extern void sctp_bind_hash_remove(sctp_t *);
995 998 extern int sctp_bindi(sctp_t *, in_port_t, boolean_t, int, in_port_t *);
996 999 extern int sctp_bind_add(sctp_t *, const void *, uint32_t, boolean_t,
997 1000 in_port_t);
998 1001 extern int sctp_bind_del(sctp_t *, const void *, uint32_t, boolean_t);
999 1002 extern int sctp_build_hdrs(sctp_t *, int);
1000 1003
1001 1004 extern int sctp_check_abandoned_msg(sctp_t *, mblk_t *);
1002 1005 extern void sctp_clean_death(sctp_t *, int);
1003 1006 extern void sctp_close_eager(sctp_t *);
1004 1007 extern int sctp_compare_faddrsets(sctp_faddr_t *, sctp_faddr_t *);
1005 1008 extern void sctp_congest_reset(sctp_t *);
1006 1009 extern void sctp_conn_hash_insert(sctp_tf_t *, sctp_t *, int);
1007 1010 extern void sctp_conn_hash_remove(sctp_t *);
1008 1011 extern void sctp_conn_init(conn_t *);
1009 1012 extern sctp_t *sctp_conn_match(in6_addr_t **, uint32_t, in6_addr_t *,
1010 1013 uint32_t, zoneid_t, iaflags_t, sctp_stack_t *);
1011 1014 extern void sctp_conn_reclaim(void *);
1012 1015 extern sctp_t *sctp_conn_request(sctp_t *, mblk_t *, uint_t, uint_t,
1013 1016 sctp_init_chunk_t *, ip_recv_attr_t *);
1014 1017 extern uint32_t sctp_cumack(sctp_t *, uint32_t, mblk_t **);
1015 1018 extern sctp_t *sctp_create_eager(sctp_t *);
1016 1019
1017 1020 extern void sctp_dispatch_rput(queue_t *, sctp_t *, sctp_hdr_t *, mblk_t *,
1018 1021 uint_t, uint_t, in6_addr_t);
1019 1022 extern char *sctp_display(sctp_t *, char *);
1020 1023 extern void sctp_display_all(sctp_stack_t *);
1021 1024
1022 1025 extern void sctp_error_event(sctp_t *, sctp_chunk_hdr_t *, boolean_t);
1023 1026
1024 1027 extern void sctp_faddr_alive(sctp_t *, sctp_faddr_t *);
1025 1028 extern int sctp_faddr_dead(sctp_t *, sctp_faddr_t *, int);
1026 1029 extern void sctp_faddr_fini(void);
1027 1030 extern void sctp_faddr_init(void);
1028 1031 extern void sctp_fast_rexmit(sctp_t *);
1029 1032 extern void sctp_fill_sack(sctp_t *, unsigned char *, int);
1030 1033 extern uint32_t sctp_find_listener_conf(sctp_stack_t *, in_port_t);
1031 1034 extern void sctp_free_faddr_timers(sctp_t *);
1032 1035 extern void sctp_free_ftsn_set(sctp_ftsn_set_t *);
1033 1036 extern void sctp_free_msg(mblk_t *);
1034 1037 extern void sctp_free_reass(sctp_instr_t *);
1035 1038 extern void sctp_free_set(sctp_set_t *);
1036 1039 extern void sctp_ftsn_sets_fini(void);
1037 1040 extern void sctp_ftsn_sets_init(void);
1038 1041
1039 1042 extern int sctp_get_addrlist(sctp_t *, const void *, uint32_t *,
1040 1043 uchar_t **, int *, size_t *);
1041 1044 extern int sctp_get_addrparams(sctp_t *, sctp_t *, mblk_t *,
1042 1045 sctp_chunk_hdr_t *, uint_t *);
1043 1046 extern void sctp_get_dest(sctp_t *, sctp_faddr_t *);
1044 1047 extern void sctp_get_faddr_list(sctp_t *, uchar_t *, size_t);
1045 1048 extern mblk_t *sctp_get_first_sent(sctp_t *);
1046 1049 extern mblk_t *sctp_get_msg_to_send(sctp_t *, mblk_t **, mblk_t *, int *,
1047 1050 int32_t, uint32_t, sctp_faddr_t *);
1048 1051 extern void sctp_get_saddr_list(sctp_t *, uchar_t *, size_t);
1049 1052
1050 1053 extern int sctp_handle_error(sctp_t *, sctp_hdr_t *, sctp_chunk_hdr_t *,
1051 1054 mblk_t *, ip_recv_attr_t *);
1052 1055 extern void sctp_hash_destroy(sctp_stack_t *);
1053 1056 extern void sctp_hash_init(sctp_stack_t *);
1054 1057 extern void sctp_heartbeat_timer(sctp_t *);
1055 1058
1056 1059 extern void sctp_icmp_error(sctp_t *, mblk_t *);
1057 1060 extern void sctp_inc_taskq(sctp_stack_t *);
1058 1061 extern void sctp_info_req(sctp_t *, mblk_t *);
1059 1062 extern mblk_t *sctp_init_mp(sctp_t *, sctp_faddr_t *);
1060 1063 extern boolean_t sctp_initialize_params(sctp_t *, sctp_init_chunk_t *,
1061 1064 sctp_init_chunk_t *);
1062 1065 extern uint32_t sctp_init2vtag(sctp_chunk_hdr_t *);
1063 1066 extern void sctp_intf_event(sctp_t *, in6_addr_t, int, int);
1064 1067 extern void sctp_input_data(sctp_t *, mblk_t *, ip_recv_attr_t *);
1065 1068 extern void sctp_instream_cleanup(sctp_t *, boolean_t);
1066 1069 extern boolean_t sctp_is_a_faddr_clean(sctp_t *);
1067 1070
1068 1071 extern void *sctp_kstat_init(netstackid_t);
1069 1072 extern void sctp_kstat_fini(netstackid_t, kstat_t *);
1070 1073 extern void *sctp_kstat2_init(netstackid_t);
1071 1074 extern void sctp_kstat2_fini(netstackid_t, kstat_t *);
1072 1075
1073 1076 extern ssize_t sctp_link_abort(mblk_t *, uint16_t, char *, size_t, int,
1074 1077 boolean_t);
1075 1078 extern void sctp_listen_hash_insert(sctp_tf_t *, sctp_t *);
1076 1079 extern void sctp_listen_hash_remove(sctp_t *);
1077 1080 extern void sctp_listener_conf_cleanup(sctp_stack_t *);
1078 1081 extern sctp_t *sctp_lookup(sctp_t *, in6_addr_t *, sctp_tf_t *, uint32_t *,
1079 1082 int);
1080 1083 extern sctp_faddr_t *sctp_lookup_faddr(sctp_t *, in6_addr_t *);
1081 1084
1082 1085 extern mblk_t *sctp_make_err(sctp_t *, uint16_t, void *, size_t);
1083 1086 extern mblk_t *sctp_make_ftsn_chunk(sctp_t *, sctp_faddr_t *,
1084 1087 sctp_ftsn_set_t *, uint_t, uint32_t);
1085 1088 extern void sctp_make_ftsns(sctp_t *, mblk_t *, mblk_t *, mblk_t **,
1086 1089 sctp_faddr_t *, uint32_t *);
1087 1090 extern mblk_t *sctp_make_mp(sctp_t *, sctp_faddr_t *, int);
1088 1091 extern mblk_t *sctp_make_sack(sctp_t *, sctp_faddr_t *, mblk_t *);
1089 1092 extern void sctp_maxpsz_set(sctp_t *);
1090 1093 extern void sctp_move_faddr_timers(queue_t *, sctp_t *);
1091 1094
1092 1095 extern sctp_parm_hdr_t *sctp_next_parm(sctp_parm_hdr_t *, ssize_t *);
1093 1096
1094 1097 extern void sctp_ootb_shutdown_ack(mblk_t *, uint_t, ip_recv_attr_t *,
1095 1098 ip_stack_t *);
1096 1099 extern size_t sctp_options_param(const sctp_t *, void *, int);
1097 1100 extern size_t sctp_options_param_len(const sctp_t *, int);
1098 1101 extern void sctp_output(sctp_t *, uint_t);
1099 1102
1100 1103 extern void sctp_partial_delivery_event(sctp_t *);
1101 1104 extern int sctp_process_cookie(sctp_t *, sctp_chunk_hdr_t *, mblk_t *,
1102 1105 sctp_init_chunk_t **, sctp_hdr_t *, int *, in6_addr_t *,
1103 1106 ip_recv_attr_t *);
1104 1107 extern void sctp_process_err(sctp_t *);
1105 1108 extern void sctp_process_heartbeat(sctp_t *, sctp_chunk_hdr_t *);
1106 1109 extern void sctp_process_timer(sctp_t *);
1107 1110
1108 1111 extern void sctp_redo_faddr_srcs(sctp_t *);
1109 1112 extern void sctp_regift_xmitlist(sctp_t *);
1110 1113 extern void sctp_return_heartbeat(sctp_t *, sctp_chunk_hdr_t *, mblk_t *);
1111 1114 extern void sctp_rexmit(sctp_t *, sctp_faddr_t *);
1112 1115 extern mblk_t *sctp_rexmit_packet(sctp_t *, mblk_t **, mblk_t **,
1113 1116 sctp_faddr_t *, uint_t *);
1114 1117 extern void sctp_rexmit_timer(sctp_t *, sctp_faddr_t *);
1115 1118 extern sctp_faddr_t *sctp_rotate_faddr(sctp_t *, sctp_faddr_t *);
1116 1119
1117 1120 extern boolean_t sctp_sack(sctp_t *, mblk_t *);
1118 1121 extern int sctp_secure_restart_check(mblk_t *, sctp_chunk_hdr_t *,
1119 1122 uint32_t, int, sctp_stack_t *, ip_recv_attr_t *);
1120 1123 extern void sctp_send_abort(sctp_t *, uint32_t, uint16_t, char *, size_t,
1121 1124 mblk_t *, int, boolean_t, ip_recv_attr_t *);
1122 1125 extern void sctp_ootb_send_abort(uint32_t, uint16_t, char *, size_t,
1123 1126 const mblk_t *, int, boolean_t, ip_recv_attr_t *,
1124 1127 ip_stack_t *);
1125 1128 extern void sctp_send_cookie_ack(sctp_t *);
1126 1129 extern void sctp_send_cookie_echo(sctp_t *, sctp_chunk_hdr_t *, mblk_t *,
1127 1130 ip_recv_attr_t *);
1128 1131 extern void sctp_send_initack(sctp_t *, sctp_hdr_t *, sctp_chunk_hdr_t *,
1129 1132 mblk_t *, ip_recv_attr_t *);
1130 1133 extern void sctp_send_shutdown(sctp_t *, int);
1131 1134 extern void sctp_send_heartbeat(sctp_t *, sctp_faddr_t *);
1132 1135 extern void sctp_sendfail_event(sctp_t *, mblk_t *, int, boolean_t);
1133 1136 extern void sctp_set_faddr_current(sctp_t *, sctp_faddr_t *);
1134 1137 extern int sctp_set_hdraddrs(sctp_t *);
1135 1138 extern void sctp_set_saddr(sctp_t *, sctp_faddr_t *);
1136 1139 extern void sctp_sets_init(void);
1137 1140 extern void sctp_sets_fini(void);
1138 1141 extern void sctp_shutdown_event(sctp_t *);
1139 1142 extern void sctp_stop_faddr_timers(sctp_t *);
1140 1143 extern int sctp_shutdown_received(sctp_t *, sctp_chunk_hdr_t *, boolean_t,
1141 1144 boolean_t, sctp_faddr_t *);
1142 1145 extern void sctp_shutdown_complete(sctp_t *);
1143 1146 extern void sctp_set_if_mtu(sctp_t *);
1144 1147 extern void sctp_set_iplen(sctp_t *, mblk_t *, ip_xmit_attr_t *);
1145 1148 extern void sctp_set_ulp_prop(sctp_t *);
1146 1149 extern void sctp_ss_rexmit(sctp_t *);
1147 1150 extern void sctp_stack_cpu_add(sctp_stack_t *, processorid_t);
1148 1151 extern size_t sctp_supaddr_param_len(sctp_t *);
1149 1152 extern size_t sctp_supaddr_param(sctp_t *, uchar_t *);
1150 1153
1151 1154 extern void sctp_timer(sctp_t *, mblk_t *, clock_t);
1152 1155 extern mblk_t *sctp_timer_alloc(sctp_t *, pfv_t, int);
1153 1156 extern void sctp_timer_call(sctp_t *sctp, mblk_t *);
1154 1157 extern void sctp_timer_free(mblk_t *);
1155 1158 extern void sctp_timer_stop(mblk_t *);
1156 1159 extern void sctp_unlink_faddr(sctp_t *, sctp_faddr_t *);
1157 1160
1158 1161 extern void sctp_update_dce(sctp_t *sctp);
1159 1162 extern in_port_t sctp_update_next_port(in_port_t, zone_t *zone, sctp_stack_t *);
1160 1163 extern void sctp_update_rtt(sctp_t *, sctp_faddr_t *, clock_t);
1161 1164 extern void sctp_user_abort(sctp_t *, mblk_t *);
1162 1165
1163 1166 extern void sctp_validate_peer(sctp_t *);
1164 1167
1165 1168 extern int sctp_xmit_list_clean(sctp_t *, ssize_t);
1166 1169
1167 1170 extern void sctp_zap_addrs(sctp_t *);
1168 1171 extern void sctp_zap_faddrs(sctp_t *, int);
1169 1172 extern sctp_chunk_hdr_t *sctp_first_chunk(uchar_t *, ssize_t);
1170 1173 extern void sctp_send_shutdown_ack(sctp_t *, sctp_faddr_t *, boolean_t);
1171 1174
1172 1175 /* Contract private interface between SCTP and Clustering - PSARC/2005/602 */
1173 1176
1174 1177 extern void (*cl_sctp_listen)(sa_family_t, uchar_t *, uint_t, in_port_t);
1175 1178 extern void (*cl_sctp_unlisten)(sa_family_t, uchar_t *, uint_t, in_port_t);
1176 1179 extern void (*cl_sctp_connect)(sa_family_t, uchar_t *, uint_t, in_port_t,
1177 1180 uchar_t *, uint_t, in_port_t, boolean_t, cl_sctp_handle_t);
1178 1181 extern void (*cl_sctp_disconnect)(sa_family_t, cl_sctp_handle_t);
1179 1182 extern void (*cl_sctp_assoc_change)(sa_family_t, uchar_t *, size_t, uint_t,
1180 1183 uchar_t *, size_t, uint_t, int, cl_sctp_handle_t);
1181 1184 extern void (*cl_sctp_check_addrs)(sa_family_t, in_port_t, uchar_t **,
1182 1185 size_t, uint_t *, boolean_t);
1183 1186
1184 1187 #define RUN_SCTP(sctp) \
1185 1188 { \
1186 1189 mutex_enter(&(sctp)->sctp_lock); \
1187 1190 while ((sctp)->sctp_running) \
1188 1191 cv_wait(&(sctp)->sctp_cv, &(sctp)->sctp_lock); \
1189 1192 (sctp)->sctp_running = B_TRUE; \
1190 1193 mutex_exit(&(sctp)->sctp_lock); \
1191 1194 }
1192 1195
1193 1196 /* Wake up recvq taskq */
1194 1197 #define WAKE_SCTP(sctp) \
1195 1198 { \
1196 1199 mutex_enter(&(sctp)->sctp_lock); \
1197 1200 if ((sctp)->sctp_timer_mp != NULL) \
1198 1201 sctp_process_timer(sctp); \
1199 1202 (sctp)->sctp_running = B_FALSE; \
1200 1203 cv_broadcast(&(sctp)->sctp_cv); \
1201 1204 mutex_exit(&(sctp)->sctp_lock); \
1202 1205 }
1203 1206
1204 1207 #ifdef __cplusplus
1205 1208 }
1206 1209 #endif
1207 1210
1208 1211 #endif /* _INET_SCTP_SCTP_IMPL_H */
↓ open down ↓ |
751 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX