1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2007, by Cisco Systems, Inc. All rights reserved.
5 * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
6 * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * a) Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 *
14 * b) Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the distribution.
17 *
18 * c) Neither the name of Cisco Systems, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 * THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #ifdef __FreeBSD__
36 #include <sys/cdefs.h>
37 __FBSDID("$FreeBSD: head/sys/netinet/sctp_sysctl.c 356357 2020-01-04 20:33:12Z tuexen $");
38 #endif
39
40 #include <netinet/sctp_os.h>
41 #include <netinet/sctp.h>
42 #include <netinet/sctp_constants.h>
43 #include <netinet/sctp_sysctl.h>
44 #include <netinet/sctp_pcb.h>
45 #include <netinet/sctputil.h>
46 #include <netinet/sctp_output.h>
47 #ifdef __FreeBSD__
48 #include <sys/smp.h>
49 #include <sys/sysctl.h>
50 #endif
51 #if defined(__APPLE__)
52 #include <netinet/sctp_bsd_addr.h>
53 #endif
54
55 #ifdef __FreeBSD__
56 FEATURE(sctp, "Stream Control Transmission Protocol");
57 #endif
58
59 /*
60 * sysctl tunable variables
61 */
62
63 void
sctp_init_sysctls()64 sctp_init_sysctls()
65 {
66 SCTP_BASE_SYSCTL(sctp_sendspace) = SCTPCTL_MAXDGRAM_DEFAULT;
67 SCTP_BASE_SYSCTL(sctp_recvspace) = SCTPCTL_RECVSPACE_DEFAULT;
68 SCTP_BASE_SYSCTL(sctp_auto_asconf) = SCTPCTL_AUTOASCONF_DEFAULT;
69 SCTP_BASE_SYSCTL(sctp_multiple_asconfs) = SCTPCTL_MULTIPLEASCONFS_DEFAULT;
70 SCTP_BASE_SYSCTL(sctp_ecn_enable) = SCTPCTL_ECN_ENABLE_DEFAULT;
71 SCTP_BASE_SYSCTL(sctp_pr_enable) = SCTPCTL_PR_ENABLE_DEFAULT;
72 SCTP_BASE_SYSCTL(sctp_auth_enable) = SCTPCTL_AUTH_ENABLE_DEFAULT;
73 SCTP_BASE_SYSCTL(sctp_asconf_enable) = SCTPCTL_ASCONF_ENABLE_DEFAULT;
74 SCTP_BASE_SYSCTL(sctp_reconfig_enable) = SCTPCTL_RECONFIG_ENABLE_DEFAULT;
75 SCTP_BASE_SYSCTL(sctp_nrsack_enable) = SCTPCTL_NRSACK_ENABLE_DEFAULT;
76 SCTP_BASE_SYSCTL(sctp_pktdrop_enable) = SCTPCTL_PKTDROP_ENABLE_DEFAULT;
77 #if !(defined(__FreeBSD__) && __FreeBSD_version >= 800000)
78 SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback) = SCTPCTL_LOOPBACK_NOCSUM_DEFAULT;
79 #endif
80 SCTP_BASE_SYSCTL(sctp_peer_chunk_oh) = SCTPCTL_PEER_CHKOH_DEFAULT;
81 SCTP_BASE_SYSCTL(sctp_max_burst_default) = SCTPCTL_MAXBURST_DEFAULT;
82 SCTP_BASE_SYSCTL(sctp_fr_max_burst_default) = SCTPCTL_FRMAXBURST_DEFAULT;
83 SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue) = SCTPCTL_MAXCHUNKS_DEFAULT;
84 #if defined(__Userspace__)
85 if (SCTP_BASE_SYSCTL(sctp_hashtblsize) == 0) {
86 SCTP_BASE_SYSCTL(sctp_hashtblsize) = SCTPCTL_TCBHASHSIZE_DEFAULT;
87 }
88 #else
89 SCTP_BASE_SYSCTL(sctp_hashtblsize) = SCTPCTL_TCBHASHSIZE_DEFAULT;
90 #endif
91 #if defined(__Userspace__)
92 if (SCTP_BASE_SYSCTL(sctp_pcbtblsize) == 0) {
93 SCTP_BASE_SYSCTL(sctp_pcbtblsize) = SCTPCTL_PCBHASHSIZE_DEFAULT;
94 }
95 #else
96 SCTP_BASE_SYSCTL(sctp_pcbtblsize) = SCTPCTL_PCBHASHSIZE_DEFAULT;
97 #endif
98 SCTP_BASE_SYSCTL(sctp_min_split_point) = SCTPCTL_MIN_SPLIT_POINT_DEFAULT;
99 #if defined(__Userspace__)
100 if (SCTP_BASE_SYSCTL(sctp_chunkscale) == 0) {
101 SCTP_BASE_SYSCTL(sctp_chunkscale) = SCTPCTL_CHUNKSCALE_DEFAULT;
102 }
103 #else
104 SCTP_BASE_SYSCTL(sctp_chunkscale) = SCTPCTL_CHUNKSCALE_DEFAULT;
105 #endif
106 SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default) = SCTPCTL_DELAYED_SACK_TIME_DEFAULT;
107 SCTP_BASE_SYSCTL(sctp_sack_freq_default) = SCTPCTL_SACK_FREQ_DEFAULT;
108 SCTP_BASE_SYSCTL(sctp_system_free_resc_limit) = SCTPCTL_SYS_RESOURCE_DEFAULT;
109 SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit) = SCTPCTL_ASOC_RESOURCE_DEFAULT;
110 SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default) = SCTPCTL_HEARTBEAT_INTERVAL_DEFAULT;
111 SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default) = SCTPCTL_PMTU_RAISE_TIME_DEFAULT;
112 SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default) = SCTPCTL_SHUTDOWN_GUARD_TIME_DEFAULT;
113 SCTP_BASE_SYSCTL(sctp_secret_lifetime_default) = SCTPCTL_SECRET_LIFETIME_DEFAULT;
114 SCTP_BASE_SYSCTL(sctp_rto_max_default) = SCTPCTL_RTO_MAX_DEFAULT;
115 SCTP_BASE_SYSCTL(sctp_rto_min_default) = SCTPCTL_RTO_MIN_DEFAULT;
116 SCTP_BASE_SYSCTL(sctp_rto_initial_default) = SCTPCTL_RTO_INITIAL_DEFAULT;
117 SCTP_BASE_SYSCTL(sctp_init_rto_max_default) = SCTPCTL_INIT_RTO_MAX_DEFAULT;
118 SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default) = SCTPCTL_VALID_COOKIE_LIFE_DEFAULT;
119 SCTP_BASE_SYSCTL(sctp_init_rtx_max_default) = SCTPCTL_INIT_RTX_MAX_DEFAULT;
120 SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default) = SCTPCTL_ASSOC_RTX_MAX_DEFAULT;
121 SCTP_BASE_SYSCTL(sctp_path_rtx_max_default) = SCTPCTL_PATH_RTX_MAX_DEFAULT;
122 SCTP_BASE_SYSCTL(sctp_path_pf_threshold) = SCTPCTL_PATH_PF_THRESHOLD_DEFAULT;
123 SCTP_BASE_SYSCTL(sctp_add_more_threshold) = SCTPCTL_ADD_MORE_ON_OUTPUT_DEFAULT;
124 SCTP_BASE_SYSCTL(sctp_nr_incoming_streams_default) = SCTPCTL_INCOMING_STREAMS_DEFAULT;
125 SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default) = SCTPCTL_OUTGOING_STREAMS_DEFAULT;
126 SCTP_BASE_SYSCTL(sctp_cmt_on_off) = SCTPCTL_CMT_ON_OFF_DEFAULT;
127 SCTP_BASE_SYSCTL(sctp_cmt_use_dac) = SCTPCTL_CMT_USE_DAC_DEFAULT;
128 SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst) = SCTPCTL_CWND_MAXBURST_DEFAULT;
129 SCTP_BASE_SYSCTL(sctp_nat_friendly) = SCTPCTL_NAT_FRIENDLY_DEFAULT;
130 SCTP_BASE_SYSCTL(sctp_L2_abc_variable) = SCTPCTL_ABC_L_VAR_DEFAULT;
131 SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count) = SCTPCTL_MAX_CHAINED_MBUFS_DEFAULT;
132 SCTP_BASE_SYSCTL(sctp_do_drain) = SCTPCTL_DO_SCTP_DRAIN_DEFAULT;
133 SCTP_BASE_SYSCTL(sctp_hb_maxburst) = SCTPCTL_HB_MAX_BURST_DEFAULT;
134 SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit) = SCTPCTL_ABORT_AT_LIMIT_DEFAULT;
135 SCTP_BASE_SYSCTL(sctp_min_residual) = SCTPCTL_MIN_RESIDUAL_DEFAULT;
136 SCTP_BASE_SYSCTL(sctp_max_retran_chunk) = SCTPCTL_MAX_RETRAN_CHUNK_DEFAULT;
137 SCTP_BASE_SYSCTL(sctp_logging_level) = SCTPCTL_LOGGING_LEVEL_DEFAULT;
138 SCTP_BASE_SYSCTL(sctp_default_cc_module) = SCTPCTL_DEFAULT_CC_MODULE_DEFAULT;
139 SCTP_BASE_SYSCTL(sctp_default_ss_module) = SCTPCTL_DEFAULT_SS_MODULE_DEFAULT;
140 SCTP_BASE_SYSCTL(sctp_default_frag_interleave) = SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DEFAULT;
141 SCTP_BASE_SYSCTL(sctp_mobility_base) = SCTPCTL_MOBILITY_BASE_DEFAULT;
142 SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff) = SCTPCTL_MOBILITY_FASTHANDOFF_DEFAULT;
143 SCTP_BASE_SYSCTL(sctp_vtag_time_wait) = SCTPCTL_TIME_WAIT_DEFAULT;
144 SCTP_BASE_SYSCTL(sctp_buffer_splitting) = SCTPCTL_BUFFER_SPLITTING_DEFAULT;
145 SCTP_BASE_SYSCTL(sctp_initial_cwnd) = SCTPCTL_INITIAL_CWND_DEFAULT;
146 SCTP_BASE_SYSCTL(sctp_rttvar_bw) = SCTPCTL_RTTVAR_BW_DEFAULT;
147 SCTP_BASE_SYSCTL(sctp_rttvar_rtt) = SCTPCTL_RTTVAR_RTT_DEFAULT;
148 SCTP_BASE_SYSCTL(sctp_rttvar_eqret) = SCTPCTL_RTTVAR_EQRET_DEFAULT;
149 SCTP_BASE_SYSCTL(sctp_steady_step) = SCTPCTL_RTTVAR_STEADYS_DEFAULT;
150 SCTP_BASE_SYSCTL(sctp_use_dccc_ecn) = SCTPCTL_RTTVAR_DCCCECN_DEFAULT;
151 SCTP_BASE_SYSCTL(sctp_blackhole) = SCTPCTL_BLACKHOLE_DEFAULT;
152 SCTP_BASE_SYSCTL(sctp_sendall_limit) = SCTPCTL_SENDALL_LIMIT_DEFAULT;
153 SCTP_BASE_SYSCTL(sctp_diag_info_code) = SCTPCTL_DIAG_INFO_CODE_DEFAULT;
154 #if defined(SCTP_LOCAL_TRACE_BUF)
155 #if defined(__Windows__)
156 /* On Windows, the resource for global variables is limited. */
157 MALLOC(SCTP_BASE_SYSCTL(sctp_log), struct sctp_log *, sizeof(struct sctp_log), M_SYSCTL, M_ZERO);
158 #else
159 memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log));
160 #endif
161 #endif
162 SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = SCTPCTL_UDP_TUNNELING_PORT_DEFAULT;
163 SCTP_BASE_SYSCTL(sctp_enable_sack_immediately) = SCTPCTL_SACK_IMMEDIATELY_ENABLE_DEFAULT;
164 SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly) = SCTPCTL_NAT_FRIENDLY_INITS_DEFAULT;
165 #if defined(SCTP_DEBUG)
166 SCTP_BASE_SYSCTL(sctp_debug_on) = SCTPCTL_DEBUG_DEFAULT;
167 #endif
168 #if defined(__APPLE__)
169 SCTP_BASE_SYSCTL(sctp_ignore_vmware_interfaces) = SCTPCTL_IGNORE_VMWARE_INTERFACES_DEFAULT;
170 SCTP_BASE_SYSCTL(sctp_main_timer) = SCTPCTL_MAIN_TIMER_DEFAULT;
171 SCTP_BASE_SYSCTL(sctp_addr_watchdog_limit) = SCTPCTL_ADDR_WATCHDOG_LIMIT_DEFAULT;
172 SCTP_BASE_SYSCTL(sctp_vtag_watchdog_limit) = SCTPCTL_VTAG_WATCHDOG_LIMIT_DEFAULT;
173 #endif
174 #if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
175 SCTP_BASE_SYSCTL(sctp_output_unlocked) = SCTPCTL_OUTPUT_UNLOCKED_DEFAULT;
176 #endif
177 }
178
179 #if defined(__Windows__)
180 void
sctp_finish_sysctls()181 sctp_finish_sysctls()
182 {
183 #if defined(SCTP_LOCAL_TRACE_BUF)
184 if (SCTP_BASE_SYSCTL(sctp_log) != NULL) {
185 FREE(SCTP_BASE_SYSCTL(sctp_log), M_SYSCTL);
186 SCTP_BASE_SYSCTL(sctp_log) = NULL;
187 }
188 #endif
189 }
190 #endif
191
192 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__Windows__)
193 /* It returns an upper limit. No filtering is done here */
194 static unsigned int
sctp_sysctl_number_of_addresses(struct sctp_inpcb * inp)195 sctp_sysctl_number_of_addresses(struct sctp_inpcb *inp)
196 {
197 unsigned int cnt;
198 struct sctp_vrf *vrf;
199 struct sctp_ifn *sctp_ifn;
200 struct sctp_ifa *sctp_ifa;
201 struct sctp_laddr *laddr;
202
203 cnt = 0;
204 /* neither Mac OS X nor FreeBSD support mulitple routing functions */
205 if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) {
206 return (0);
207 }
208 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
209 LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
210 LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
211 switch (sctp_ifa->address.sa.sa_family) {
212 #ifdef INET
213 case AF_INET:
214 #endif
215 #ifdef INET6
216 case AF_INET6:
217 #endif
218 cnt++;
219 break;
220 default:
221 break;
222 }
223 }
224 }
225 } else {
226 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
227 switch (laddr->ifa->address.sa.sa_family) {
228 #ifdef INET
229 case AF_INET:
230 #endif
231 #ifdef INET6
232 case AF_INET6:
233 #endif
234 cnt++;
235 break;
236 default:
237 break;
238 }
239 }
240 }
241 return (cnt);
242 }
243
244 static int
sctp_sysctl_copy_out_local_addresses(struct sctp_inpcb * inp,struct sctp_tcb * stcb,struct sysctl_req * req)245 sctp_sysctl_copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sysctl_req *req)
246 {
247 struct sctp_ifn *sctp_ifn;
248 struct sctp_ifa *sctp_ifa;
249 int loopback_scope, ipv4_local_scope, local_scope, site_scope;
250 int ipv4_addr_legal, ipv6_addr_legal;
251 #if defined(__Userspace__)
252 int conn_addr_legal;
253 #endif
254 struct sctp_vrf *vrf;
255 struct xsctp_laddr xladdr;
256 struct sctp_laddr *laddr;
257 int error;
258
259 /* Turn on all the appropriate scope */
260 if (stcb) {
261 /* use association specific values */
262 loopback_scope = stcb->asoc.scope.loopback_scope;
263 ipv4_local_scope = stcb->asoc.scope.ipv4_local_scope;
264 local_scope = stcb->asoc.scope.local_scope;
265 site_scope = stcb->asoc.scope.site_scope;
266 ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal;
267 ipv6_addr_legal = stcb->asoc.scope.ipv6_addr_legal;
268 #if defined(__Userspace__)
269 conn_addr_legal = stcb->asoc.scope.conn_addr_legal;
270 #endif
271 } else {
272 /* Use generic values for endpoints. */
273 loopback_scope = 1;
274 ipv4_local_scope = 1;
275 local_scope = 1;
276 site_scope = 1;
277 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) {
278 ipv6_addr_legal = 1;
279 if (SCTP_IPV6_V6ONLY(inp)) {
280 ipv4_addr_legal = 0;
281 } else {
282 ipv4_addr_legal = 1;
283 }
284 #if defined(__Userspace__)
285 conn_addr_legal = 0;
286 #endif
287 } else {
288 ipv6_addr_legal = 0;
289 #if defined(__Userspace__)
290 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_CONN) {
291 conn_addr_legal = 1;
292 ipv4_addr_legal = 0;
293 } else {
294 conn_addr_legal = 0;
295 ipv4_addr_legal = 1;
296 }
297 #else
298 ipv4_addr_legal = 1;
299 #endif
300 }
301 }
302
303 /* neither Mac OS X nor FreeBSD support mulitple routing functions */
304 if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) {
305 SCTP_INP_RUNLOCK(inp);
306 SCTP_INP_INFO_RUNLOCK();
307 return (-1);
308 }
309 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
310 LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
311 if ((loopback_scope == 0) && SCTP_IFN_IS_IFT_LOOP(sctp_ifn))
312 /* Skip loopback if loopback_scope not set */
313 continue;
314 LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
315 if (stcb) {
316 /*
317 * ignore if blacklisted at
318 * association level
319 */
320 if (sctp_is_addr_restricted(stcb, sctp_ifa))
321 continue;
322 }
323 switch (sctp_ifa->address.sa.sa_family) {
324 #ifdef INET
325 case AF_INET:
326 if (ipv4_addr_legal) {
327 struct sockaddr_in *sin;
328
329 sin = &sctp_ifa->address.sin;
330 if (sin->sin_addr.s_addr == 0)
331 continue;
332 #if defined(__FreeBSD__)
333 if (prison_check_ip4(inp->ip_inp.inp.inp_cred,
334 &sin->sin_addr) != 0) {
335 continue;
336 }
337 #endif
338 if ((ipv4_local_scope == 0) && (IN4_ISPRIVATE_ADDRESS(&sin->sin_addr)))
339 continue;
340 } else {
341 continue;
342 }
343 break;
344 #endif
345 #ifdef INET6
346 case AF_INET6:
347 if (ipv6_addr_legal) {
348 struct sockaddr_in6 *sin6;
349
350 sin6 = &sctp_ifa->address.sin6;
351 if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr))
352 continue;
353 #if defined(__FreeBSD__)
354 if (prison_check_ip6(inp->ip_inp.inp.inp_cred,
355 &sin6->sin6_addr) != 0) {
356 continue;
357 }
358 #endif
359 if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
360 if (local_scope == 0)
361 continue;
362 }
363 if ((site_scope == 0) && (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)))
364 continue;
365 } else {
366 continue;
367 }
368 break;
369 #endif
370 #if defined(__Userspace__)
371 case AF_CONN:
372 if (!conn_addr_legal) {
373 continue;
374 }
375 break;
376 #endif
377 default:
378 continue;
379 }
380 memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
381 memcpy((void *)&xladdr.address, (const void *)&sctp_ifa->address, sizeof(union sctp_sockstore));
382 SCTP_INP_RUNLOCK(inp);
383 SCTP_INP_INFO_RUNLOCK();
384 error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
385 if (error) {
386 return (error);
387 } else {
388 SCTP_INP_INFO_RLOCK();
389 SCTP_INP_RLOCK(inp);
390 }
391 }
392 }
393 } else {
394 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
395 /* ignore if blacklisted at association level */
396 if (stcb && sctp_is_addr_restricted(stcb, laddr->ifa))
397 continue;
398 memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
399 memcpy((void *)&xladdr.address, (const void *)&laddr->ifa->address, sizeof(union sctp_sockstore));
400 xladdr.start_time.tv_sec = (uint32_t)laddr->start_time.tv_sec;
401 xladdr.start_time.tv_usec = (uint32_t)laddr->start_time.tv_usec;
402 SCTP_INP_RUNLOCK(inp);
403 SCTP_INP_INFO_RUNLOCK();
404 error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
405 if (error) {
406 return (error);
407 } else {
408 SCTP_INP_INFO_RLOCK();
409 SCTP_INP_RLOCK(inp);
410 }
411 }
412 }
413 memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
414 xladdr.last = 1;
415 SCTP_INP_RUNLOCK(inp);
416 SCTP_INP_INFO_RUNLOCK();
417 error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
418
419 if (error) {
420 return (error);
421 } else {
422 SCTP_INP_INFO_RLOCK();
423 SCTP_INP_RLOCK(inp);
424 return (0);
425 }
426 }
427
428 /*
429 * sysctl functions
430 */
431 #if defined(__APPLE__)
432 static int
433 sctp_sysctl_handle_assoclist SYSCTL_HANDLER_ARGS
434 {
435 #pragma unused(oidp, arg1, arg2)
436 #else
437 static int
438 sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS)
439 {
440 #endif
441 unsigned int number_of_endpoints;
442 unsigned int number_of_local_addresses;
443 unsigned int number_of_associations;
444 unsigned int number_of_remote_addresses;
445 unsigned int n;
446 int error;
447 struct sctp_inpcb *inp;
448 struct sctp_tcb *stcb;
449 struct sctp_nets *net;
450 struct xsctp_inpcb xinpcb;
451 struct xsctp_tcb xstcb;
452 struct xsctp_raddr xraddr;
453 struct socket *so;
454
455 number_of_endpoints = 0;
456 number_of_local_addresses = 0;
457 number_of_associations = 0;
458 number_of_remote_addresses = 0;
459
460 SCTP_INP_INFO_RLOCK();
461 #if defined(__APPLE__)
462 if (req->oldptr == USER_ADDR_NULL) {
463 #else
464 if (req->oldptr == NULL) {
465 #endif
466 LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
467 SCTP_INP_RLOCK(inp);
468 number_of_endpoints++;
469 number_of_local_addresses += sctp_sysctl_number_of_addresses(inp);
470 LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
471 number_of_associations++;
472 number_of_local_addresses += sctp_sysctl_number_of_addresses(inp);
473 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
474 number_of_remote_addresses++;
475 }
476 }
477 SCTP_INP_RUNLOCK(inp);
478 }
479 SCTP_INP_INFO_RUNLOCK();
480 n = (number_of_endpoints + 1) * sizeof(struct xsctp_inpcb) +
481 (number_of_local_addresses + number_of_endpoints + number_of_associations) * sizeof(struct xsctp_laddr) +
482 (number_of_associations + number_of_endpoints) * sizeof(struct xsctp_tcb) +
483 (number_of_remote_addresses + number_of_associations) * sizeof(struct xsctp_raddr);
484
485 /* request some more memory than needed */
486 #if !defined(__Windows__)
487 req->oldidx = (n + n / 8);
488 #else
489 req->dataidx = (n + n / 8);
490 #endif
491 return (0);
492 }
493 #if defined(__APPLE__)
494 if (req->newptr != USER_ADDR_NULL) {
495 #else
496 if (req->newptr != NULL) {
497 #endif
498 SCTP_INP_INFO_RUNLOCK();
499 SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_SYSCTL, EPERM);
500 return (EPERM);
501 }
502 memset(&xinpcb, 0, sizeof(xinpcb));
503 memset(&xstcb, 0, sizeof(xstcb));
504 memset(&xraddr, 0, sizeof(xraddr));
505 LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
506 SCTP_INP_RLOCK(inp);
507 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
508 /* if its allgone it is being freed - skip it */
509 goto skip;
510 }
511 xinpcb.last = 0;
512 xinpcb.local_port = ntohs(inp->sctp_lport);
513 xinpcb.flags = inp->sctp_flags;
514 #if defined(__FreeBSD__) && __FreeBSD_version < 1000048
515 xinpcb.features = (uint32_t)inp->sctp_features;
516 #else
517 xinpcb.features = inp->sctp_features;
518 #endif
519 xinpcb.total_sends = inp->total_sends;
520 xinpcb.total_recvs = inp->total_recvs;
521 xinpcb.total_nospaces = inp->total_nospaces;
522 xinpcb.fragmentation_point = inp->sctp_frag_point;
523 #if defined(__FreeBSD__)
524 xinpcb.socket = (uintptr_t)inp->sctp_socket;
525 #else
526 xinpcb.socket = inp->sctp_socket;
527 #endif
528 so = inp->sctp_socket;
529 if ((so == NULL) ||
530 (!SCTP_IS_LISTENING(inp)) ||
531 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) {
532 xinpcb.qlen = 0;
533 xinpcb.maxqlen = 0;
534 } else {
535 #if defined(__FreeBSD__) && __FreeBSD_version >= 1200034
536 xinpcb.qlen = so->sol_qlen;
537 #else
538 xinpcb.qlen = so->so_qlen;
539 #endif
540 #if defined(__FreeBSD__) && __FreeBSD_version > 1100096
541 #if __FreeBSD_version >= 1200034
542 xinpcb.qlen_old = so->sol_qlen > USHRT_MAX ?
543 USHRT_MAX : (uint16_t) so->sol_qlen;
544 #else
545 xinpcb.qlen_old = so->so_qlen > USHRT_MAX ?
546 USHRT_MAX : (uint16_t) so->so_qlen;
547 #endif
548 #endif
549 #if defined(__FreeBSD__) && __FreeBSD_version >= 1200034
550 xinpcb.maxqlen = so->sol_qlimit;
551 #else
552 xinpcb.maxqlen = so->so_qlimit;
553 #endif
554 #if defined(__FreeBSD__) && __FreeBSD_version > 1100096
555 #if __FreeBSD_version >= 1200034
556 xinpcb.maxqlen_old = so->sol_qlimit > USHRT_MAX ?
557 USHRT_MAX : (uint16_t) so->sol_qlimit;
558 #else
559 xinpcb.maxqlen_old = so->so_qlimit > USHRT_MAX ?
560 USHRT_MAX : (uint16_t) so->so_qlimit;
561 #endif
562 #endif
563 }
564 SCTP_INP_INCR_REF(inp);
565 SCTP_INP_RUNLOCK(inp);
566 SCTP_INP_INFO_RUNLOCK();
567 error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb));
568 if (error) {
569 SCTP_INP_DECR_REF(inp);
570 return (error);
571 }
572 SCTP_INP_INFO_RLOCK();
573 SCTP_INP_RLOCK(inp);
574 error = sctp_sysctl_copy_out_local_addresses(inp, NULL, req);
575 if (error) {
576 SCTP_INP_DECR_REF(inp);
577 return (error);
578 }
579 LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
580 SCTP_TCB_LOCK(stcb);
581 atomic_add_int(&stcb->asoc.refcnt, 1);
582 SCTP_TCB_UNLOCK(stcb);
583 xstcb.last = 0;
584 xstcb.local_port = ntohs(inp->sctp_lport);
585 xstcb.remote_port = ntohs(stcb->rport);
586 if (stcb->asoc.primary_destination != NULL)
587 xstcb.primary_addr = stcb->asoc.primary_destination->ro._l_addr;
588 xstcb.heartbeat_interval = stcb->asoc.heart_beat_delay;
589 xstcb.state = (uint32_t)sctp_map_assoc_state(stcb->asoc.state);
590 #if defined(__FreeBSD__)
591 #if __FreeBSD_version >= 800000
592 /* 7.0 does not support these */
593 xstcb.assoc_id = sctp_get_associd(stcb);
594 xstcb.peers_rwnd = stcb->asoc.peers_rwnd;
595 #endif
596 #else
597 xstcb.assoc_id = sctp_get_associd(stcb);
598 xstcb.peers_rwnd = stcb->asoc.peers_rwnd;
599 #endif
600 xstcb.in_streams = stcb->asoc.streamincnt;
601 xstcb.out_streams = stcb->asoc.streamoutcnt;
602 xstcb.max_nr_retrans = stcb->asoc.overall_error_count;
603 xstcb.primary_process = 0; /* not really supported yet */
604 xstcb.T1_expireries = stcb->asoc.timoinit + stcb->asoc.timocookie;
605 xstcb.T2_expireries = stcb->asoc.timoshutdown + stcb->asoc.timoshutdownack;
606 xstcb.retransmitted_tsns = stcb->asoc.marked_retrans;
607 xstcb.start_time.tv_sec = (uint32_t)stcb->asoc.start_time.tv_sec;
608 xstcb.start_time.tv_usec = (uint32_t)stcb->asoc.start_time.tv_usec;
609 xstcb.discontinuity_time.tv_sec = (uint32_t)stcb->asoc.discontinuity_time.tv_sec;
610 xstcb.discontinuity_time.tv_usec = (uint32_t)stcb->asoc.discontinuity_time.tv_usec;
611 xstcb.total_sends = stcb->total_sends;
612 xstcb.total_recvs = stcb->total_recvs;
613 xstcb.local_tag = stcb->asoc.my_vtag;
614 xstcb.remote_tag = stcb->asoc.peer_vtag;
615 xstcb.initial_tsn = stcb->asoc.init_seq_number;
616 xstcb.highest_tsn = stcb->asoc.sending_seq - 1;
617 xstcb.cumulative_tsn = stcb->asoc.last_acked_seq;
618 xstcb.cumulative_tsn_ack = stcb->asoc.cumulative_tsn;
619 xstcb.mtu = stcb->asoc.smallest_mtu;
620 xstcb.refcnt = stcb->asoc.refcnt;
621 SCTP_INP_RUNLOCK(inp);
622 SCTP_INP_INFO_RUNLOCK();
623 error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb));
624 if (error) {
625 SCTP_INP_DECR_REF(inp);
626 atomic_subtract_int(&stcb->asoc.refcnt, 1);
627 return (error);
628 }
629 SCTP_INP_INFO_RLOCK();
630 SCTP_INP_RLOCK(inp);
631 error = sctp_sysctl_copy_out_local_addresses(inp, stcb, req);
632 if (error) {
633 SCTP_INP_DECR_REF(inp);
634 atomic_subtract_int(&stcb->asoc.refcnt, 1);
635 return (error);
636 }
637 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
638 xraddr.last = 0;
639 xraddr.address = net->ro._l_addr;
640 xraddr.active = ((net->dest_state & SCTP_ADDR_REACHABLE) == SCTP_ADDR_REACHABLE);
641 xraddr.confirmed = ((net->dest_state & SCTP_ADDR_UNCONFIRMED) == 0);
642 xraddr.heartbeat_enabled = ((net->dest_state & SCTP_ADDR_NOHB) == 0);
643 xraddr.potentially_failed = ((net->dest_state & SCTP_ADDR_PF) == SCTP_ADDR_PF);
644 xraddr.rto = net->RTO;
645 xraddr.max_path_rtx = net->failure_threshold;
646 xraddr.rtx = net->marked_retrans;
647 xraddr.error_counter = net->error_count;
648 xraddr.cwnd = net->cwnd;
649 xraddr.flight_size = net->flight_size;
650 xraddr.mtu = net->mtu;
651 #if defined(__FreeBSD__)
652 #if __FreeBSD_version >= 800000
653 xraddr.rtt = net->rtt / 1000;
654 xraddr.heartbeat_interval = net->heart_beat_delay;
655 xraddr.ssthresh = net->ssthresh;
656 xraddr.encaps_port = net->port;
657 if (net->dest_state & SCTP_ADDR_UNCONFIRMED) {
658 xraddr.state = SCTP_UNCONFIRMED;
659 } else if (net->dest_state & SCTP_ADDR_REACHABLE) {
660 xraddr.state = SCTP_ACTIVE;
661 } else {
662 xraddr.state = SCTP_INACTIVE;
663 }
664 #endif
665 #else
666 xraddr.rtt = net->rtt / 1000;
667 xraddr.heartbeat_interval = net->heart_beat_delay;
668 xraddr.ssthresh = net->ssthresh;
669 xraddr.encaps_port = net->port;
670 if (net->dest_state & SCTP_ADDR_UNCONFIRMED) {
671 xraddr.state = SCTP_UNCONFIRMED;
672 } else if (net->dest_state & SCTP_ADDR_REACHABLE) {
673 xraddr.state = SCTP_ACTIVE;
674 } else {
675 xraddr.state = SCTP_INACTIVE;
676 }
677 #endif
678 xraddr.start_time.tv_sec = (uint32_t)net->start_time.tv_sec;
679 xraddr.start_time.tv_usec = (uint32_t)net->start_time.tv_usec;
680 SCTP_INP_RUNLOCK(inp);
681 SCTP_INP_INFO_RUNLOCK();
682 error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr));
683 if (error) {
684 SCTP_INP_DECR_REF(inp);
685 atomic_subtract_int(&stcb->asoc.refcnt, 1);
686 return (error);
687 }
688 SCTP_INP_INFO_RLOCK();
689 SCTP_INP_RLOCK(inp);
690 }
691 atomic_subtract_int(&stcb->asoc.refcnt, 1);
692 memset((void *)&xraddr, 0, sizeof(struct xsctp_raddr));
693 xraddr.last = 1;
694 SCTP_INP_RUNLOCK(inp);
695 SCTP_INP_INFO_RUNLOCK();
696 error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr));
697 if (error) {
698 SCTP_INP_DECR_REF(inp);
699 return (error);
700 }
701 SCTP_INP_INFO_RLOCK();
702 SCTP_INP_RLOCK(inp);
703 }
704 SCTP_INP_DECR_REF(inp);
705 SCTP_INP_RUNLOCK(inp);
706 SCTP_INP_INFO_RUNLOCK();
707 memset((void *)&xstcb, 0, sizeof(struct xsctp_tcb));
708 xstcb.last = 1;
709 error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb));
710 if (error) {
711 return (error);
712 }
713 skip:
714 SCTP_INP_INFO_RLOCK();
715 }
716 SCTP_INP_INFO_RUNLOCK();
717
718 memset((void *)&xinpcb, 0, sizeof(struct xsctp_inpcb));
719 xinpcb.last = 1;
720 error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb));
721 return (error);
722 }
723
724 #if defined(__APPLE__)
725 static int
726 sctp_sysctl_handle_udp_tunneling SYSCTL_HANDLER_ARGS
727 {
728 #pragma unused(arg1, arg2)
729 #else
730 static int
731 sctp_sysctl_handle_udp_tunneling(SYSCTL_HANDLER_ARGS)
732 {
733 #endif
734 int error;
735 uint32_t old, new;
736
737 SCTP_INP_INFO_RLOCK();
738 old = SCTP_BASE_SYSCTL(sctp_udp_tunneling_port);
739 SCTP_INP_INFO_RUNLOCK();
740 new = old;
741 #if defined(__FreeBSD__) && __FreeBSD_version >= 800056 && __FreeBSD_version < 1000100
742 #ifdef VIMAGE
743 error = vnet_sysctl_handle_int(oidp, &new, 0, req);
744 #else
745 error = sysctl_handle_int(oidp, &new, 0, req);
746 #endif
747 #else
748 error = sysctl_handle_int(oidp, &new, 0, req);
749 #endif
750 if ((error == 0) &&
751 #if defined (__APPLE__)
752 (req->newptr != USER_ADDR_NULL)) {
753 #else
754 (req->newptr != NULL)) {
755 #endif
756 #if defined(__Windows__)
757 SCTP_INP_INFO_WLOCK();
758 sctp_over_udp_restart();
759 SCTP_INP_INFO_WUNLOCK();
760 #else
761 #if (SCTPCTL_UDP_TUNNELING_PORT_MIN == 0)
762 if (new > SCTPCTL_UDP_TUNNELING_PORT_MAX) {
763 #else
764 if ((new < SCTPCTL_UDP_TUNNELING_PORT_MIN) ||
765 (new > SCTPCTL_UDP_TUNNELING_PORT_MAX)) {
766 #endif
767 error = EINVAL;
768 } else {
769 SCTP_INP_INFO_WLOCK();
770 SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = new;
771 if (old != 0) {
772 sctp_over_udp_stop();
773 }
774 if (new != 0) {
775 error = sctp_over_udp_start();
776 }
777 SCTP_INP_INFO_WUNLOCK();
778 }
779 #endif
780 }
781 return (error);
782 }
783
784 #if defined(__APPLE__)
785 int sctp_is_vmware_interface(struct ifnet *);
786
787 static int
788 sctp_sysctl_handle_vmware_interfaces SYSCTL_HANDLER_ARGS
789 {
790 #pragma unused(arg1, arg2)
791 int error;
792 uint32_t old, new;
793
794 old = SCTP_BASE_SYSCTL(sctp_ignore_vmware_interfaces);
795 new = old;
796 error = sysctl_handle_int(oidp, &new, 0, req);
797 if ((error == 0) && (req->newptr != USER_ADDR_NULL)) {
798 if ((new < SCTPCTL_IGNORE_VMWARE_INTERFACES_MIN) ||
799 (new > SCTPCTL_IGNORE_VMWARE_INTERFACES_MAX)) {
800 error = EINVAL;
801 } else {
802 if ((old == 1) && (new == 0)) {
803 sctp_add_or_del_interfaces(sctp_is_vmware_interface, 1);
804 }
805 if ((old == 0) && (new == 1)) {
806 sctp_add_or_del_interfaces(sctp_is_vmware_interface, 0);
807 }
808 if (old != new) {
809 SCTP_BASE_SYSCTL(sctp_ignore_vmware_interfaces) = new;
810 }
811 }
812 }
813 return (error);
814 }
815 #endif
816
817 #if defined(__APPLE__)
818 static int
819 sctp_sysctl_handle_auth SYSCTL_HANDLER_ARGS
820 {
821 #pragma unused(arg1, arg2)
822 #else
823 static int
824 sctp_sysctl_handle_auth(SYSCTL_HANDLER_ARGS)
825 {
826 #endif
827 int error;
828 uint32_t new;
829
830 new = SCTP_BASE_SYSCTL(sctp_auth_enable);
831 #if defined(__FreeBSD__) && __FreeBSD_version >= 800056 && __FreeBSD_version < 1000100
832 #ifdef VIMAGE
833 error = vnet_sysctl_handle_int(oidp, &new, 0, req);
834 #else
835 error = sysctl_handle_int(oidp, &new, 0, req);
836 #endif
837 #else
838 error = sysctl_handle_int(oidp, &new, 0, req);
839 #endif
840 if ((error == 0) &&
841 #if defined (__APPLE__)
842 (req->newptr != USER_ADDR_NULL)) {
843 #else
844 (req->newptr != NULL)) {
845 #endif
846 #if (SCTPCTL_AUTH_ENABLE_MIN == 0)
847 if ((new > SCTPCTL_AUTH_ENABLE_MAX) ||
848 ((new == 0) && (SCTP_BASE_SYSCTL(sctp_asconf_enable) == 1))) {
849 #else
850 if ((new < SCTPCTL_AUTH_ENABLE_MIN) ||
851 (new > SCTPCTL_AUTH_ENABLE_MAX) ||
852 ((new == 0) && (SCTP_BASE_SYSCTL(sctp_asconf_enable) == 1))) {
853 #endif
854 error = EINVAL;
855 } else {
856 SCTP_BASE_SYSCTL(sctp_auth_enable) = new;
857 }
858 }
859 return (error);
860 }
861
862 #if defined(__APPLE__)
863 static int
864 sctp_sysctl_handle_asconf SYSCTL_HANDLER_ARGS
865 {
866 #pragma unused(arg1, arg2)
867 #else
868 static int
869 sctp_sysctl_handle_asconf(SYSCTL_HANDLER_ARGS)
870 {
871 #endif
872 int error;
873 uint32_t new;
874
875 new = SCTP_BASE_SYSCTL(sctp_asconf_enable);
876 #if defined(__FreeBSD__) && __FreeBSD_version >= 800056 && __FreeBSD_version < 1000100
877 #ifdef VIMAGE
878 error = vnet_sysctl_handle_int(oidp, &new, 0, req);
879 #else
880 error = sysctl_handle_int(oidp, &new, 0, req);
881 #endif
882 #else
883 error = sysctl_handle_int(oidp, &new, 0, req);
884 #endif
885 if ((error == 0) &&
886 #if defined (__APPLE__)
887 (req->newptr != USER_ADDR_NULL)) {
888 #else
889 (req->newptr != NULL)) {
890 #endif
891 #if (SCTPCTL_ASCONF_ENABLE_MIN == 0)
892 if ((new > SCTPCTL_ASCONF_ENABLE_MAX) ||
893 ((new == 1) && (SCTP_BASE_SYSCTL(sctp_auth_enable) == 0))) {
894 #else
895 if ((new < SCTPCTL_ASCONF_ENABLE_MIN) ||
896 (new > SCTPCTL_ASCONF_ENABLE_MAX) ||
897 ((new == 1) && (SCTP_BASE_SYSCTL(sctp_auth_enable) == 0))) {
898 #endif
899 error = EINVAL;
900 } else {
901 SCTP_BASE_SYSCTL(sctp_asconf_enable) = new;
902 }
903 }
904 return (error);
905 }
906
907 #if defined(__APPLE__)
908 static int
909 sctp_sysctl_handle_stats SYSCTL_HANDLER_ARGS
910 {
911 #pragma unused(oidp, arg1, arg2)
912 #else
913 static int
914 sctp_sysctl_handle_stats(SYSCTL_HANDLER_ARGS)
915 {
916 #endif
917 int error;
918 #if defined(__FreeBSD__)
919 #if defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
920 struct sctpstat *sarry;
921 struct sctpstat sb;
922 int cpu;
923 #endif
924 struct sctpstat sb_temp;
925 #endif
926
927 #if defined (__APPLE__)
928 if ((req->newptr != USER_ADDR_NULL) &&
929 #else
930 if ((req->newptr != NULL) &&
931 #endif
932 (req->newlen != sizeof(struct sctpstat))) {
933 return (EINVAL);
934 }
935 #if defined(__FreeBSD__)
936 memset(&sb_temp, 0, sizeof(struct sctpstat));
937
938 if (req->newptr != NULL) {
939 error = SYSCTL_IN(req, &sb_temp, sizeof(struct sctpstat));
940 if (error != 0) {
941 return (error);
942 }
943 }
944 #if defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
945 memset(&sb, 0, sizeof(sb));
946 for (cpu = 0; cpu < mp_maxid; cpu++) {
947 sarry = &SCTP_BASE_STATS[cpu];
948 if (sarry->sctps_discontinuitytime.tv_sec > sb.sctps_discontinuitytime.tv_sec) {
949 sb.sctps_discontinuitytime.tv_sec = sarry->sctps_discontinuitytime.tv_sec;
950 sb.sctps_discontinuitytime.tv_usec = sarry->sctps_discontinuitytime.tv_usec;
951 }
952 sb.sctps_currestab += sarry->sctps_currestab;
953 sb.sctps_activeestab += sarry->sctps_activeestab;
954 sb.sctps_restartestab += sarry->sctps_restartestab;
955 sb.sctps_collisionestab += sarry->sctps_collisionestab;
956 sb.sctps_passiveestab += sarry->sctps_passiveestab;
957 sb.sctps_aborted += sarry->sctps_aborted;
958 sb.sctps_shutdown += sarry->sctps_shutdown;
959 sb.sctps_outoftheblue += sarry->sctps_outoftheblue;
960 sb.sctps_checksumerrors += sarry->sctps_checksumerrors;
961 sb.sctps_outcontrolchunks += sarry->sctps_outcontrolchunks;
962 sb.sctps_outorderchunks += sarry->sctps_outorderchunks;
963 sb.sctps_outunorderchunks += sarry->sctps_outunorderchunks;
964 sb.sctps_incontrolchunks += sarry->sctps_incontrolchunks;
965 sb.sctps_inorderchunks += sarry->sctps_inorderchunks;
966 sb.sctps_inunorderchunks += sarry->sctps_inunorderchunks;
967 sb.sctps_fragusrmsgs += sarry->sctps_fragusrmsgs;
968 sb.sctps_reasmusrmsgs += sarry->sctps_reasmusrmsgs;
969 sb.sctps_outpackets += sarry->sctps_outpackets;
970 sb.sctps_inpackets += sarry->sctps_inpackets;
971 sb.sctps_recvpackets += sarry->sctps_recvpackets;
972 sb.sctps_recvdatagrams += sarry->sctps_recvdatagrams;
973 sb.sctps_recvpktwithdata += sarry->sctps_recvpktwithdata;
974 sb.sctps_recvsacks += sarry->sctps_recvsacks;
975 sb.sctps_recvdata += sarry->sctps_recvdata;
976 sb.sctps_recvdupdata += sarry->sctps_recvdupdata;
977 sb.sctps_recvheartbeat += sarry->sctps_recvheartbeat;
978 sb.sctps_recvheartbeatack += sarry->sctps_recvheartbeatack;
979 sb.sctps_recvecne += sarry->sctps_recvecne;
980 sb.sctps_recvauth += sarry->sctps_recvauth;
981 sb.sctps_recvauthmissing += sarry->sctps_recvauthmissing;
982 sb.sctps_recvivalhmacid += sarry->sctps_recvivalhmacid;
983 sb.sctps_recvivalkeyid += sarry->sctps_recvivalkeyid;
984 sb.sctps_recvauthfailed += sarry->sctps_recvauthfailed;
985 sb.sctps_recvexpress += sarry->sctps_recvexpress;
986 sb.sctps_recvexpressm += sarry->sctps_recvexpressm;
987 sb.sctps_recvswcrc += sarry->sctps_recvswcrc;
988 sb.sctps_recvhwcrc += sarry->sctps_recvhwcrc;
989 sb.sctps_sendpackets += sarry->sctps_sendpackets;
990 sb.sctps_sendsacks += sarry->sctps_sendsacks;
991 sb.sctps_senddata += sarry->sctps_senddata;
992 sb.sctps_sendretransdata += sarry->sctps_sendretransdata;
993 sb.sctps_sendfastretrans += sarry->sctps_sendfastretrans;
994 sb.sctps_sendmultfastretrans += sarry->sctps_sendmultfastretrans;
995 sb.sctps_sendheartbeat += sarry->sctps_sendheartbeat;
996 sb.sctps_sendecne += sarry->sctps_sendecne;
997 sb.sctps_sendauth += sarry->sctps_sendauth;
998 sb.sctps_senderrors += sarry->sctps_senderrors;
999 sb.sctps_sendswcrc += sarry->sctps_sendswcrc;
1000 sb.sctps_sendhwcrc += sarry->sctps_sendhwcrc;
1001 sb.sctps_pdrpfmbox += sarry->sctps_pdrpfmbox;
1002 sb.sctps_pdrpfehos += sarry->sctps_pdrpfehos;
1003 sb.sctps_pdrpmbda += sarry->sctps_pdrpmbda;
1004 sb.sctps_pdrpmbct += sarry->sctps_pdrpmbct;
1005 sb.sctps_pdrpbwrpt += sarry->sctps_pdrpbwrpt;
1006 sb.sctps_pdrpcrupt += sarry->sctps_pdrpcrupt;
1007 sb.sctps_pdrpnedat += sarry->sctps_pdrpnedat;
1008 sb.sctps_pdrppdbrk += sarry->sctps_pdrppdbrk;
1009 sb.sctps_pdrptsnnf += sarry->sctps_pdrptsnnf;
1010 sb.sctps_pdrpdnfnd += sarry->sctps_pdrpdnfnd;
1011 sb.sctps_pdrpdiwnp += sarry->sctps_pdrpdiwnp;
1012 sb.sctps_pdrpdizrw += sarry->sctps_pdrpdizrw;
1013 sb.sctps_pdrpbadd += sarry->sctps_pdrpbadd;
1014 sb.sctps_pdrpmark += sarry->sctps_pdrpmark;
1015 sb.sctps_timoiterator += sarry->sctps_timoiterator;
1016 sb.sctps_timodata += sarry->sctps_timodata;
1017 sb.sctps_timowindowprobe += sarry->sctps_timowindowprobe;
1018 sb.sctps_timoinit += sarry->sctps_timoinit;
1019 sb.sctps_timosack += sarry->sctps_timosack;
1020 sb.sctps_timoshutdown += sarry->sctps_timoshutdown;
1021 sb.sctps_timoheartbeat += sarry->sctps_timoheartbeat;
1022 sb.sctps_timocookie += sarry->sctps_timocookie;
1023 sb.sctps_timosecret += sarry->sctps_timosecret;
1024 sb.sctps_timopathmtu += sarry->sctps_timopathmtu;
1025 sb.sctps_timoshutdownack += sarry->sctps_timoshutdownack;
1026 sb.sctps_timoshutdownguard += sarry->sctps_timoshutdownguard;
1027 sb.sctps_timostrmrst += sarry->sctps_timostrmrst;
1028 sb.sctps_timoearlyfr += sarry->sctps_timoearlyfr;
1029 sb.sctps_timoasconf += sarry->sctps_timoasconf;
1030 sb.sctps_timodelprim += sarry->sctps_timodelprim;
1031 sb.sctps_timoautoclose += sarry->sctps_timoautoclose;
1032 sb.sctps_timoassockill += sarry->sctps_timoassockill;
1033 sb.sctps_timoinpkill += sarry->sctps_timoinpkill;
1034 sb.sctps_hdrops += sarry->sctps_hdrops;
1035 sb.sctps_badsum += sarry->sctps_badsum;
1036 sb.sctps_noport += sarry->sctps_noport;
1037 sb.sctps_badvtag += sarry->sctps_badvtag;
1038 sb.sctps_badsid += sarry->sctps_badsid;
1039 sb.sctps_nomem += sarry->sctps_nomem;
1040 sb.sctps_fastretransinrtt += sarry->sctps_fastretransinrtt;
1041 sb.sctps_markedretrans += sarry->sctps_markedretrans;
1042 sb.sctps_naglesent += sarry->sctps_naglesent;
1043 sb.sctps_naglequeued += sarry->sctps_naglequeued;
1044 sb.sctps_maxburstqueued += sarry->sctps_maxburstqueued;
1045 sb.sctps_ifnomemqueued += sarry->sctps_ifnomemqueued;
1046 sb.sctps_windowprobed += sarry->sctps_windowprobed;
1047 sb.sctps_lowlevelerr += sarry->sctps_lowlevelerr;
1048 sb.sctps_lowlevelerrusr += sarry->sctps_lowlevelerrusr;
1049 sb.sctps_datadropchklmt += sarry->sctps_datadropchklmt;
1050 sb.sctps_datadroprwnd += sarry->sctps_datadroprwnd;
1051 sb.sctps_ecnereducedcwnd += sarry->sctps_ecnereducedcwnd;
1052 sb.sctps_vtagexpress += sarry->sctps_vtagexpress;
1053 sb.sctps_vtagbogus += sarry->sctps_vtagbogus;
1054 sb.sctps_primary_randry += sarry->sctps_primary_randry;
1055 sb.sctps_cmt_randry += sarry->sctps_cmt_randry;
1056 sb.sctps_slowpath_sack += sarry->sctps_slowpath_sack;
1057 sb.sctps_wu_sacks_sent += sarry->sctps_wu_sacks_sent;
1058 sb.sctps_sends_with_flags += sarry->sctps_sends_with_flags;
1059 sb.sctps_sends_with_unord += sarry->sctps_sends_with_unord;
1060 sb.sctps_sends_with_eof += sarry->sctps_sends_with_eof;
1061 sb.sctps_sends_with_abort += sarry->sctps_sends_with_abort;
1062 sb.sctps_protocol_drain_calls += sarry->sctps_protocol_drain_calls;
1063 sb.sctps_protocol_drains_done += sarry->sctps_protocol_drains_done;
1064 sb.sctps_read_peeks += sarry->sctps_read_peeks;
1065 sb.sctps_cached_chk += sarry->sctps_cached_chk;
1066 sb.sctps_cached_strmoq += sarry->sctps_cached_strmoq;
1067 sb.sctps_left_abandon += sarry->sctps_left_abandon;
1068 sb.sctps_send_burst_avoid += sarry->sctps_send_burst_avoid;
1069 sb.sctps_send_cwnd_avoid += sarry->sctps_send_cwnd_avoid;
1070 sb.sctps_fwdtsn_map_over += sarry->sctps_fwdtsn_map_over;
1071 if (req->newptr != NULL) {
1072 memcpy(sarry, &sb_temp, sizeof(struct sctpstat));
1073 }
1074 }
1075 error = SYSCTL_OUT(req, &sb, sizeof(struct sctpstat));
1076 #else
1077 error = SYSCTL_OUT(req, &SCTP_BASE_STATS, sizeof(struct sctpstat));
1078 if (error != 0) {
1079 return (error);
1080 }
1081 if (req->newptr != NULL) {
1082 memcpy(&SCTP_BASE_STATS, &sb_temp, sizeof(struct sctpstat));
1083 }
1084 #endif
1085 #else
1086 error = SYSCTL_OUT(req, &SCTP_BASE_STATS, sizeof(struct sctpstat));
1087 #endif
1088 return (error);
1089 }
1090
1091 #if defined(SCTP_LOCAL_TRACE_BUF)
1092 #if defined(__APPLE__)
1093 static int
1094 sctp_sysctl_handle_trace_log SYSCTL_HANDLER_ARGS
1095 {
1096 #pragma unused(arg1, arg2, oidp)
1097 #else
1098 static int
1099 sctp_sysctl_handle_trace_log(SYSCTL_HANDLER_ARGS)
1100 {
1101 #endif
1102 int error;
1103
1104 #if defined(__Windows__)
1105 error = SYSCTL_OUT(req, SCTP_BASE_SYSCTL(sctp_log), sizeof(struct sctp_log));
1106 #else
1107 error = SYSCTL_OUT(req, &SCTP_BASE_SYSCTL(sctp_log), sizeof(struct sctp_log));
1108 #endif
1109 return (error);
1110 }
1111
1112 #if defined(__APPLE__)
1113 static int
1114 sctp_sysctl_handle_trace_log_clear SYSCTL_HANDLER_ARGS
1115 {
1116 #pragma unused(arg1, arg2, req, oidp)
1117 #else
1118 static int
1119 sctp_sysctl_handle_trace_log_clear(SYSCTL_HANDLER_ARGS)
1120 {
1121 #endif
1122 int error = 0;
1123 #if defined(__Windows__)
1124 int value = 0;
1125
1126 if (req->new_data == NULL) {
1127 return (error);
1128 }
1129 error = SYSCTL_IN(req, &value, sizeof(int));
1130 if (error == 0 && value != 0 && SCTP_BASE_SYSCTL(sctp_log) != NULL) {
1131 memset(SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log));
1132 }
1133 #else
1134
1135 memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log));
1136 #endif
1137 return (error);
1138 }
1139 #endif
1140
1141 #if defined(__APPLE__) || defined(__FreeBSD__)
1142 #if defined(__FreeBSD__)
1143 #if __FreeBSD_version >= 800056 && __FreeBSD_version < 1000100
1144 #ifdef VIMAGE
1145 #define SCTP_UINT_SYSCTL(name, var_name, prefix) \
1146 static int \
1147 sctp_sysctl_handle_##mib_name(SYSCTL_HANDLER_ARGS) \
1148 { \
1149 int error; \
1150 uint32_t new; \
1151 \
1152 new = SCTP_BASE_SYSCTL(var_name); \
1153 error = vnet_sysctl_handle_int(oidp, &new, 0, req); \
1154 if ((error == 0) && (req->newptr != NULL)) { \
1155 if ((new < prefix##_MIN) || \
1156 (new > prefix##_MAX)) { \
1157 error = EINVAL; \
1158 } else { \
1159 SCTP_BASE_SYSCTL(var_name) = new; \
1160 } \
1161 } \
1162 return (error); \
1163 } \
1164 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mib_name, \
1165 CTLTYPE_UINT|CTLFLAG_RW, NULL, 0, \
1166 sctp_sysctl_handle_##mib_name, "UI", prefix##_DESC);
1167 #else
1168 #define SCTP_UINT_SYSCTL(mib_name, var_name, prefix) \
1169 static int \
1170 sctp_sysctl_handle_##mib_name(SYSCTL_HANDLER_ARGS) \
1171 { \
1172 int error; \
1173 uint32_t new; \
1174 \
1175 new = SCTP_BASE_SYSCTL(var_name); \
1176 error = sysctl_handle_int(oidp, &new, 0, req); \
1177 if ((error == 0) && (req->newptr != NULL)) { \
1178 if ((new < prefix##_MIN) || \
1179 (new > prefix##_MAX)) { \
1180 error = EINVAL; \
1181 } else { \
1182 SCTP_BASE_SYSCTL(var_name) = new; \
1183 } \
1184 } \
1185 return (error); \
1186 } \
1187 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mib_name, \
1188 CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW, NULL, 0, \
1189 sctp_sysctl_handle_##mib_name, "UI", prefix##_DESC);
1190 #endif
1191 #else
1192 #define SCTP_UINT_SYSCTL(mib_name, var_name, prefix) \
1193 static int \
1194 sctp_sysctl_handle_##mib_name(SYSCTL_HANDLER_ARGS) \
1195 { \
1196 int error; \
1197 uint32_t new; \
1198 \
1199 new = SCTP_BASE_SYSCTL(var_name); \
1200 error = sysctl_handle_int(oidp, &new, 0, req); \
1201 if ((error == 0) && (req->newptr != NULL)) { \
1202 if ((new < prefix##_MIN) || \
1203 (new > prefix##_MAX)) { \
1204 error = EINVAL; \
1205 } else { \
1206 SCTP_BASE_SYSCTL(var_name) = new; \
1207 } \
1208 } \
1209 return (error); \
1210 } \
1211 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mib_name, \
1212 CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW, NULL, 0, \
1213 sctp_sysctl_handle_##mib_name, "UI", prefix##_DESC);
1214 #endif
1215 #else
1216 #define SCTP_UINT_SYSCTL(mib_name, var_name, prefix) \
1217 static int \
1218 sctp_sysctl_handle_##mib_name(struct sysctl_oid *oidp, \
1219 void *arg1 __attribute__((unused)), \
1220 int arg2 __attribute__((unused)), \
1221 struct sysctl_req *req) \
1222 { \
1223 int error; \
1224 uint32_t new; \
1225 \
1226 new = SCTP_BASE_SYSCTL(var_name); \
1227 error = sysctl_handle_int(oidp, &new, 0, req); \
1228 if ((error == 0) && (req->newptr != USER_ADDR_NULL)) { \
1229 if ((new < prefix##_MIN) || \
1230 (new > prefix##_MAX)) { \
1231 error = EINVAL; \
1232 } else { \
1233 SCTP_BASE_SYSCTL(var_name) = new; \
1234 } \
1235 } \
1236 return (error); \
1237 } \
1238 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mib_name, \
1239 CTLTYPE_INT | CTLFLAG_RW, NULL, 0, \
1240 sctp_sysctl_handle_##mib_name, "I", prefix##_DESC);
1241 #define CTLTYPE_UINT CTLTYPE_INT
1242 #define CTLFLAG_VNET 0
1243 #endif
1244
1245 /*
1246 * sysctl definitions
1247 */
1248
1249 SCTP_UINT_SYSCTL(sendspace, sctp_sendspace, SCTPCTL_MAXDGRAM)
1250 SCTP_UINT_SYSCTL(recvspace, sctp_recvspace, SCTPCTL_RECVSPACE)
1251 SCTP_UINT_SYSCTL(auto_asconf, sctp_auto_asconf, SCTPCTL_AUTOASCONF)
1252 SCTP_UINT_SYSCTL(ecn_enable, sctp_ecn_enable, SCTPCTL_ECN_ENABLE)
1253 SCTP_UINT_SYSCTL(pr_enable, sctp_pr_enable, SCTPCTL_PR_ENABLE)
1254 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, auth_enable, CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW,
1255 NULL, 0, sctp_sysctl_handle_auth, "IU", SCTPCTL_AUTH_ENABLE_DESC);
1256 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, asconf_enable, CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW,
1257 NULL, 0, sctp_sysctl_handle_asconf, "IU", SCTPCTL_ASCONF_ENABLE_DESC);
1258 SCTP_UINT_SYSCTL(reconfig_enable, sctp_reconfig_enable, SCTPCTL_RECONFIG_ENABLE)
1259 SCTP_UINT_SYSCTL(nrsack_enable, sctp_nrsack_enable, SCTPCTL_NRSACK_ENABLE)
1260 SCTP_UINT_SYSCTL(pktdrop_enable, sctp_pktdrop_enable, SCTPCTL_PKTDROP_ENABLE)
1261 #if defined(__APPLE__)
1262 SCTP_UINT_SYSCTL(loopback_nocsum, sctp_no_csum_on_loopback, SCTPCTL_LOOPBACK_NOCSUM)
1263 #endif
1264 SCTP_UINT_SYSCTL(peer_chkoh, sctp_peer_chunk_oh, SCTPCTL_PEER_CHKOH)
1265 SCTP_UINT_SYSCTL(maxburst, sctp_max_burst_default, SCTPCTL_MAXBURST)
1266 SCTP_UINT_SYSCTL(fr_maxburst, sctp_fr_max_burst_default, SCTPCTL_FRMAXBURST)
1267 SCTP_UINT_SYSCTL(maxchunks, sctp_max_chunks_on_queue, SCTPCTL_MAXCHUNKS)
1268 SCTP_UINT_SYSCTL(tcbhashsize, sctp_hashtblsize, SCTPCTL_TCBHASHSIZE)
1269 SCTP_UINT_SYSCTL(pcbhashsize, sctp_pcbtblsize, SCTPCTL_PCBHASHSIZE)
1270 SCTP_UINT_SYSCTL(min_split_point, sctp_min_split_point, SCTPCTL_MIN_SPLIT_POINT)
1271 SCTP_UINT_SYSCTL(chunkscale, sctp_chunkscale, SCTPCTL_CHUNKSCALE)
1272 SCTP_UINT_SYSCTL(delayed_sack_time, sctp_delayed_sack_time_default, SCTPCTL_DELAYED_SACK_TIME)
1273 SCTP_UINT_SYSCTL(sack_freq, sctp_sack_freq_default, SCTPCTL_SACK_FREQ)
1274 SCTP_UINT_SYSCTL(sys_resource, sctp_system_free_resc_limit, SCTPCTL_SYS_RESOURCE)
1275 SCTP_UINT_SYSCTL(asoc_resource, sctp_asoc_free_resc_limit, SCTPCTL_ASOC_RESOURCE)
1276 SCTP_UINT_SYSCTL(heartbeat_interval, sctp_heartbeat_interval_default, SCTPCTL_HEARTBEAT_INTERVAL)
1277 SCTP_UINT_SYSCTL(pmtu_raise_time, sctp_pmtu_raise_time_default, SCTPCTL_PMTU_RAISE_TIME)
1278 SCTP_UINT_SYSCTL(shutdown_guard_time, sctp_shutdown_guard_time_default, SCTPCTL_SHUTDOWN_GUARD_TIME)
1279 SCTP_UINT_SYSCTL(secret_lifetime, sctp_secret_lifetime_default, SCTPCTL_SECRET_LIFETIME)
1280 SCTP_UINT_SYSCTL(rto_max, sctp_rto_max_default, SCTPCTL_RTO_MAX)
1281 SCTP_UINT_SYSCTL(rto_min, sctp_rto_min_default, SCTPCTL_RTO_MIN)
1282 SCTP_UINT_SYSCTL(rto_initial, sctp_rto_initial_default, SCTPCTL_RTO_INITIAL)
1283 SCTP_UINT_SYSCTL(init_rto_max, sctp_init_rto_max_default, SCTPCTL_INIT_RTO_MAX)
1284 SCTP_UINT_SYSCTL(valid_cookie_life, sctp_valid_cookie_life_default, SCTPCTL_VALID_COOKIE_LIFE)
1285 SCTP_UINT_SYSCTL(init_rtx_max, sctp_init_rtx_max_default, SCTPCTL_INIT_RTX_MAX)
1286 SCTP_UINT_SYSCTL(assoc_rtx_max, sctp_assoc_rtx_max_default, SCTPCTL_ASSOC_RTX_MAX)
1287 SCTP_UINT_SYSCTL(path_rtx_max, sctp_path_rtx_max_default, SCTPCTL_PATH_RTX_MAX)
1288 SCTP_UINT_SYSCTL(path_pf_threshold, sctp_path_pf_threshold, SCTPCTL_PATH_PF_THRESHOLD)
1289 SCTP_UINT_SYSCTL(add_more_on_output, sctp_add_more_threshold, SCTPCTL_ADD_MORE_ON_OUTPUT)
1290 SCTP_UINT_SYSCTL(incoming_streams, sctp_nr_incoming_streams_default, SCTPCTL_INCOMING_STREAMS)
1291 SCTP_UINT_SYSCTL(outgoing_streams, sctp_nr_outgoing_streams_default, SCTPCTL_OUTGOING_STREAMS)
1292 SCTP_UINT_SYSCTL(cmt_on_off, sctp_cmt_on_off, SCTPCTL_CMT_ON_OFF)
1293 SCTP_UINT_SYSCTL(cmt_use_dac, sctp_cmt_use_dac, SCTPCTL_CMT_USE_DAC)
1294 SCTP_UINT_SYSCTL(cwnd_maxburst, sctp_use_cwnd_based_maxburst, SCTPCTL_CWND_MAXBURST)
1295 SCTP_UINT_SYSCTL(nat_friendly, sctp_nat_friendly, SCTPCTL_NAT_FRIENDLY)
1296 SCTP_UINT_SYSCTL(abc_l_var, sctp_L2_abc_variable, SCTPCTL_ABC_L_VAR)
1297 SCTP_UINT_SYSCTL(max_chained_mbufs, sctp_mbuf_threshold_count, SCTPCTL_MAX_CHAINED_MBUFS)
1298 SCTP_UINT_SYSCTL(do_sctp_drain, sctp_do_drain, SCTPCTL_DO_SCTP_DRAIN)
1299 SCTP_UINT_SYSCTL(hb_max_burst, sctp_hb_maxburst, SCTPCTL_HB_MAX_BURST)
1300 SCTP_UINT_SYSCTL(abort_at_limit, sctp_abort_if_one_2_one_hits_limit, SCTPCTL_ABORT_AT_LIMIT)
1301 SCTP_UINT_SYSCTL(min_residual, sctp_min_residual, SCTPCTL_MIN_RESIDUAL)
1302 SCTP_UINT_SYSCTL(max_retran_chunk, sctp_max_retran_chunk, SCTPCTL_MAX_RETRAN_CHUNK)
1303 SCTP_UINT_SYSCTL(log_level, sctp_logging_level, SCTPCTL_LOGGING_LEVEL)
1304 SCTP_UINT_SYSCTL(default_cc_module, sctp_default_cc_module, SCTPCTL_DEFAULT_CC_MODULE)
1305 SCTP_UINT_SYSCTL(default_ss_module, sctp_default_ss_module, SCTPCTL_DEFAULT_SS_MODULE)
1306 SCTP_UINT_SYSCTL(default_frag_interleave, sctp_default_frag_interleave, SCTPCTL_DEFAULT_FRAG_INTERLEAVE)
1307 SCTP_UINT_SYSCTL(mobility_base, sctp_mobility_base, SCTPCTL_MOBILITY_BASE)
1308 SCTP_UINT_SYSCTL(mobility_fasthandoff, sctp_mobility_fasthandoff, SCTPCTL_MOBILITY_FASTHANDOFF)
1309 #if defined(SCTP_LOCAL_TRACE_BUF)
1310 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, log, CTLFLAG_VNET|CTLTYPE_STRUCT|CTLFLAG_RD,
1311 NULL, 0, sctp_sysctl_handle_trace_log, "S,sctplog", "SCTP logging (struct sctp_log)");
1312 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, clear_trace, CTLFLAG_VNET|CTLTYPE_UINT | CTLFLAG_RW,
1313 NULL, 0, sctp_sysctl_handle_trace_log_clear, "IU", "Clear SCTP Logging buffer");
1314 #endif
1315 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, udp_tunneling_port, CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW,
1316 NULL, 0, sctp_sysctl_handle_udp_tunneling, "IU", SCTPCTL_UDP_TUNNELING_PORT_DESC);
1317 SCTP_UINT_SYSCTL(enable_sack_immediately, sctp_enable_sack_immediately, SCTPCTL_SACK_IMMEDIATELY_ENABLE)
1318 SCTP_UINT_SYSCTL(nat_friendly_init, sctp_inits_include_nat_friendly, SCTPCTL_NAT_FRIENDLY_INITS)
1319 SCTP_UINT_SYSCTL(vtag_time_wait, sctp_vtag_time_wait, SCTPCTL_TIME_WAIT)
1320 SCTP_UINT_SYSCTL(buffer_splitting, sctp_buffer_splitting, SCTPCTL_BUFFER_SPLITTING)
1321 SCTP_UINT_SYSCTL(initial_cwnd, sctp_initial_cwnd, SCTPCTL_INITIAL_CWND)
1322 SCTP_UINT_SYSCTL(rttvar_bw, sctp_rttvar_bw, SCTPCTL_RTTVAR_BW)
1323 SCTP_UINT_SYSCTL(rttvar_rtt, sctp_rttvar_rtt, SCTPCTL_RTTVAR_RTT)
1324 SCTP_UINT_SYSCTL(rttvar_eqret, sctp_rttvar_eqret, SCTPCTL_RTTVAR_EQRET)
1325 SCTP_UINT_SYSCTL(rttvar_steady_step, sctp_steady_step, SCTPCTL_RTTVAR_STEADYS)
1326 SCTP_UINT_SYSCTL(use_dcccecn, sctp_use_dccc_ecn, SCTPCTL_RTTVAR_DCCCECN)
1327 SCTP_UINT_SYSCTL(blackhole, sctp_blackhole, SCTPCTL_BLACKHOLE)
1328 SCTP_UINT_SYSCTL(sendall_limit, sctp_sendall_limit, SCTPCTL_SENDALL_LIMIT)
1329 SCTP_UINT_SYSCTL(diag_info_code, sctp_diag_info_code, SCTPCTL_DIAG_INFO_CODE)
1330 #ifdef SCTP_DEBUG
1331 SCTP_UINT_SYSCTL(debug, sctp_debug_on, SCTPCTL_DEBUG)
1332 #endif
1333 #if defined(__APPLE__)
1334 SCTP_UINT_SYSCTL(main_timer, sctp_main_timer, SCTPCTL_MAIN_TIMER)
1335 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, ignore_vmware_interfaces, CTLTYPE_UINT|CTLFLAG_RW,
1336 NULL, 0, sctp_sysctl_handle_vmware_interfaces, "IU", SCTPCTL_IGNORE_VMWARE_INTERFACES_DESC);
1337 SCTP_UINT_SYSCTL(addr_watchdog_limit, sctp_addr_watchdog_limit, SCTPCTL_ADDR_WATCHDOG_LIMIT)
1338 SCTP_UINT_SYSCTL(vtag_watchdog_limit, sctp_vtag_watchdog_limit, SCTPCTL_VTAG_WATCHDOG_LIMIT)
1339 #endif
1340 #if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
1341 SCTP_UINT_SYSCTL(output_unlocked, sctp_output_unlocked, SCTPCTL_OUTPUT_UNLOCKED)
1342 #endif
1343 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, stats, CTLFLAG_VNET|CTLTYPE_STRUCT|CTLFLAG_RW,
1344 NULL, 0, sctp_sysctl_handle_stats, "S,sctpstat", "SCTP statistics (struct sctp_stat)");
1345 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, assoclist, CTLFLAG_VNET|CTLTYPE_OPAQUE|CTLFLAG_RD,
1346 NULL, 0, sctp_sysctl_handle_assoclist, "S,xassoc", "List of active SCTP associations");
1347
1348 #elif defined(__Windows__)
1349
1350 #define RANGECHK(var, min, max) \
1351 if ((var) < (min)) { (var) = (min); } \
1352 else if ((var) > (max)) { (var) = (max); }
1353
1354 static int
sctp_sysctl_handle_int(SYSCTL_HANDLER_ARGS)1355 sctp_sysctl_handle_int(SYSCTL_HANDLER_ARGS)
1356 {
1357 int error;
1358
1359 error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
1360 if (error == 0) {
1361 RANGECHK(SCTP_BASE_SYSCTL(sctp_sendspace), SCTPCTL_MAXDGRAM_MIN, SCTPCTL_MAXDGRAM_MAX);
1362 RANGECHK(SCTP_BASE_SYSCTL(sctp_recvspace), SCTPCTL_RECVSPACE_MIN, SCTPCTL_RECVSPACE_MAX);
1363 RANGECHK(SCTP_BASE_SYSCTL(sctp_auto_asconf), SCTPCTL_AUTOASCONF_MIN, SCTPCTL_AUTOASCONF_MAX);
1364 RANGECHK(SCTP_BASE_SYSCTL(sctp_auto_asconf), SCTPCTL_AUTOASCONF_MIN, SCTPCTL_AUTOASCONF_MAX);
1365 RANGECHK(SCTP_BASE_SYSCTL(sctp_ecn_enable), SCTPCTL_ECN_ENABLE_MIN, SCTPCTL_ECN_ENABLE_MAX);
1366 RANGECHK(SCTP_BASE_SYSCTL(sctp_pr_enable), SCTPCTL_PR_ENABLE_MIN, SCTPCTL_PR_ENABLE_MAX);
1367 RANGECHK(SCTP_BASE_SYSCTL(sctp_reconfig_enable), SCTPCTL_RECONFIG_ENABLE_MIN, SCTPCTL_RECONFIG_ENABLE_MAX);
1368 RANGECHK(SCTP_BASE_SYSCTL(sctp_nrsack_enable), SCTPCTL_NRSACK_ENABLE_MIN, SCTPCTL_NRSACK_ENABLE_MAX);
1369 RANGECHK(SCTP_BASE_SYSCTL(sctp_pktdrop_enable), SCTPCTL_PKTDROP_ENABLE_MIN, SCTPCTL_PKTDROP_ENABLE_MAX);
1370 RANGECHK(SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback), SCTPCTL_LOOPBACK_NOCSUM_MIN, SCTPCTL_LOOPBACK_NOCSUM_MAX);
1371 RANGECHK(SCTP_BASE_SYSCTL(sctp_peer_chunk_oh), SCTPCTL_PEER_CHKOH_MIN, SCTPCTL_PEER_CHKOH_MAX);
1372 RANGECHK(SCTP_BASE_SYSCTL(sctp_max_burst_default), SCTPCTL_MAXBURST_MIN, SCTPCTL_MAXBURST_MAX);
1373 RANGECHK(SCTP_BASE_SYSCTL(sctp_fr_max_burst_default), SCTPCTL_FRMAXBURST_MIN, SCTPCTL_FRMAXBURST_MAX);
1374 RANGECHK(SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue), SCTPCTL_MAXCHUNKS_MIN, SCTPCTL_MAXCHUNKS_MAX);
1375 RANGECHK(SCTP_BASE_SYSCTL(sctp_hashtblsize), SCTPCTL_TCBHASHSIZE_MIN, SCTPCTL_TCBHASHSIZE_MAX);
1376 RANGECHK(SCTP_BASE_SYSCTL(sctp_pcbtblsize), SCTPCTL_PCBHASHSIZE_MIN, SCTPCTL_PCBHASHSIZE_MAX);
1377 RANGECHK(SCTP_BASE_SYSCTL(sctp_min_split_point), SCTPCTL_MIN_SPLIT_POINT_MIN, SCTPCTL_MIN_SPLIT_POINT_MAX);
1378 RANGECHK(SCTP_BASE_SYSCTL(sctp_chunkscale), SCTPCTL_CHUNKSCALE_MIN, SCTPCTL_CHUNKSCALE_MAX);
1379 RANGECHK(SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default), SCTPCTL_DELAYED_SACK_TIME_MIN, SCTPCTL_DELAYED_SACK_TIME_MAX);
1380 RANGECHK(SCTP_BASE_SYSCTL(sctp_sack_freq_default), SCTPCTL_SACK_FREQ_MIN, SCTPCTL_SACK_FREQ_MAX);
1381 RANGECHK(SCTP_BASE_SYSCTL(sctp_system_free_resc_limit), SCTPCTL_SYS_RESOURCE_MIN, SCTPCTL_SYS_RESOURCE_MAX);
1382 RANGECHK(SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit), SCTPCTL_ASOC_RESOURCE_MIN, SCTPCTL_ASOC_RESOURCE_MAX);
1383 RANGECHK(SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default), SCTPCTL_HEARTBEAT_INTERVAL_MIN, SCTPCTL_HEARTBEAT_INTERVAL_MAX);
1384 RANGECHK(SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default), SCTPCTL_PMTU_RAISE_TIME_MIN, SCTPCTL_PMTU_RAISE_TIME_MAX);
1385 RANGECHK(SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default), SCTPCTL_SHUTDOWN_GUARD_TIME_MIN, SCTPCTL_SHUTDOWN_GUARD_TIME_MAX);
1386 RANGECHK(SCTP_BASE_SYSCTL(sctp_secret_lifetime_default), SCTPCTL_SECRET_LIFETIME_MIN, SCTPCTL_SECRET_LIFETIME_MAX);
1387 RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_max_default), SCTPCTL_RTO_MAX_MIN, SCTPCTL_RTO_MAX_MAX);
1388 RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_min_default), SCTPCTL_RTO_MIN_MIN, SCTPCTL_RTO_MIN_MAX);
1389 RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_initial_default), SCTPCTL_RTO_INITIAL_MIN, SCTPCTL_RTO_INITIAL_MAX);
1390 RANGECHK(SCTP_BASE_SYSCTL(sctp_init_rto_max_default), SCTPCTL_INIT_RTO_MAX_MIN, SCTPCTL_INIT_RTO_MAX_MAX);
1391 RANGECHK(SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default), SCTPCTL_VALID_COOKIE_LIFE_MIN, SCTPCTL_VALID_COOKIE_LIFE_MAX);
1392 RANGECHK(SCTP_BASE_SYSCTL(sctp_init_rtx_max_default), SCTPCTL_INIT_RTX_MAX_MIN, SCTPCTL_INIT_RTX_MAX_MAX);
1393 RANGECHK(SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default), SCTPCTL_ASSOC_RTX_MAX_MIN, SCTPCTL_ASSOC_RTX_MAX_MAX);
1394 RANGECHK(SCTP_BASE_SYSCTL(sctp_path_rtx_max_default), SCTPCTL_PATH_RTX_MAX_MIN, SCTPCTL_PATH_RTX_MAX_MAX);
1395 RANGECHK(SCTP_BASE_SYSCTL(sctp_path_pf_threshold), SCTPCTL_PATH_PF_THRESHOLD_MIN, SCTPCTL_PATH_PF_THRESHOLD_MAX);
1396 RANGECHK(SCTP_BASE_SYSCTL(sctp_add_more_threshold), SCTPCTL_ADD_MORE_ON_OUTPUT_MIN, SCTPCTL_ADD_MORE_ON_OUTPUT_MAX);
1397 RANGECHK(SCTP_BASE_SYSCTL(sctp_nr_incoming_streams_default), SCTPCTL_INCOMING_STREAMS_MIN, SCTPCTL_INCOMING_STREAMS_MAX);
1398 RANGECHK(SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default), SCTPCTL_OUTGOING_STREAMS_MIN, SCTPCTL_OUTGOING_STREAMS_MAX);
1399 RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_on_off), SCTPCTL_CMT_ON_OFF_MIN, SCTPCTL_CMT_ON_OFF_MAX);
1400 RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_use_dac), SCTPCTL_CMT_USE_DAC_MIN, SCTPCTL_CMT_USE_DAC_MAX);
1401 RANGECHK(SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst), SCTPCTL_CWND_MAXBURST_MIN, SCTPCTL_CWND_MAXBURST_MAX);
1402 RANGECHK(SCTP_BASE_SYSCTL(sctp_nat_friendly), SCTPCTL_NAT_FRIENDLY_MIN, SCTPCTL_NAT_FRIENDLY_MAX);
1403 RANGECHK(SCTP_BASE_SYSCTL(sctp_L2_abc_variable), SCTPCTL_ABC_L_VAR_MIN, SCTPCTL_ABC_L_VAR_MAX);
1404 RANGECHK(SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count), SCTPCTL_MAX_CHAINED_MBUFS_MIN, SCTPCTL_MAX_CHAINED_MBUFS_MAX);
1405 RANGECHK(SCTP_BASE_SYSCTL(sctp_do_drain), SCTPCTL_DO_SCTP_DRAIN_MIN, SCTPCTL_DO_SCTP_DRAIN_MAX);
1406 RANGECHK(SCTP_BASE_SYSCTL(sctp_hb_maxburst), SCTPCTL_HB_MAX_BURST_MIN, SCTPCTL_HB_MAX_BURST_MAX);
1407 RANGECHK(SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit), SCTPCTL_ABORT_AT_LIMIT_MIN, SCTPCTL_ABORT_AT_LIMIT_MAX);
1408 RANGECHK(SCTP_BASE_SYSCTL(sctp_min_residual), SCTPCTL_MIN_RESIDUAL_MIN, SCTPCTL_MIN_RESIDUAL_MAX);
1409 RANGECHK(SCTP_BASE_SYSCTL(sctp_max_retran_chunk), SCTPCTL_MAX_RETRAN_CHUNK_MIN, SCTPCTL_MAX_RETRAN_CHUNK_MAX);
1410 RANGECHK(SCTP_BASE_SYSCTL(sctp_logging_level), SCTPCTL_LOGGING_LEVEL_MIN, SCTPCTL_LOGGING_LEVEL_MAX);
1411 RANGECHK(SCTP_BASE_SYSCTL(sctp_default_cc_module), SCTPCTL_DEFAULT_CC_MODULE_MIN, SCTPCTL_DEFAULT_CC_MODULE_MAX);
1412 RANGECHK(SCTP_BASE_SYSCTL(sctp_default_ss_module), SCTPCTL_DEFAULT_SS_MODULE_MIN, SCTPCTL_DEFAULT_SS_MODULE_MAX);
1413 RANGECHK(SCTP_BASE_SYSCTL(sctp_default_frag_interleave), SCTPCTL_DEFAULT_FRAG_INTERLEAVE_MIN, SCTPCTL_DEFAULT_FRAG_INTERLEAVE_MAX);
1414 RANGECHK(SCTP_BASE_SYSCTL(sctp_vtag_time_wait), SCTPCTL_TIME_WAIT_MIN, SCTPCTL_TIME_WAIT_MAX);
1415 RANGECHK(SCTP_BASE_SYSCTL(sctp_buffer_splitting), SCTPCTL_BUFFER_SPLITTING_MIN, SCTPCTL_BUFFER_SPLITTING_MAX);
1416 RANGECHK(SCTP_BASE_SYSCTL(sctp_initial_cwnd), SCTPCTL_INITIAL_CWND_MIN, SCTPCTL_INITIAL_CWND_MAX);
1417 RANGECHK(SCTP_BASE_SYSCTL(sctp_rttvar_bw), SCTPCTL_RTTVAR_BW_MIN, SCTPCTL_RTTVAR_BW_MAX);
1418 RANGECHK(SCTP_BASE_SYSCTL(sctp_rttvar_rtt), SCTPCTL_RTTVAR_RTT_MIN, SCTPCTL_RTTVAR_RTT_MAX);
1419 RANGECHK(SCTP_BASE_SYSCTL(sctp_rttvar_eqret), SCTPCTL_RTTVAR_EQRET_MIN, SCTPCTL_RTTVAR_EQRET_MAX);
1420 RANGECHK(SCTP_BASE_SYSCTL(sctp_steady_step), SCTPCTL_RTTVAR_STEADYS_MIN, SCTPCTL_RTTVAR_STEADYS_MAX);
1421 RANGECHK(SCTP_BASE_SYSCTL(sctp_use_dccc_ecn), SCTPCTL_RTTVAR_DCCCECN_MIN, SCTPCTL_RTTVAR_DCCCECN_MAX);
1422 RANGECHK(SCTP_BASE_SYSCTL(sctp_mobility_base), SCTPCTL_MOBILITY_BASE_MIN, SCTPCTL_MOBILITY_BASE_MAX);
1423 RANGECHK(SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff), SCTPCTL_MOBILITY_FASTHANDOFF_MIN, SCTPCTL_MOBILITY_FASTHANDOFF_MAX);
1424 RANGECHK(SCTP_BASE_SYSCTL(sctp_enable_sack_immediately), SCTPCTL_SACK_IMMEDIATELY_ENABLE_MIN, SCTPCTL_SACK_IMMEDIATELY_ENABLE_MAX);
1425 RANGECHK(SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly), SCTPCTL_NAT_FRIENDLY_INITS_MIN, SCTPCTL_NAT_FRIENDLY_INITS_MAX);
1426 RANGECHK(SCTP_BASE_SYSCTL(sctp_blackhole), SCTPCTL_BLACKHOLE_MIN, SCTPCTL_BLACKHOLE_MAX);
1427 RANGECHK(SCTP_BASE_SYSCTL(sctp_sendall_limit), SCTPCTL_SENDALL_LIMIT_MIN, SCTPCTL_SENDALL_LIMIT_MAX);
1428 RANGECHK(SCTP_BASE_SYSCTL(sctp_diag_info_code), SCTPCTL_DIAG_INFO_CODE_MIN, SCTPCTL_DIAG_INFO_CODE_MAX);
1429 #ifdef SCTP_DEBUG
1430 RANGECHK(SCTP_BASE_SYSCTL(sctp_debug_on), SCTPCTL_DEBUG_MIN, SCTPCTL_DEBUG_MAX);
1431 #endif
1432 }
1433 return (error);
1434 }
1435
1436 void
sysctl_setup_sctp(void)1437 sysctl_setup_sctp(void)
1438 {
1439 sysctl_add_oid(&sysctl_oid_top, "sendspace", CTLTYPE_INT|CTLFLAG_RW,
1440 &SCTP_BASE_SYSCTL(sctp_sendspace), 0, sctp_sysctl_handle_int,
1441 SCTPCTL_MAXDGRAM_DESC);
1442
1443 sysctl_add_oid(&sysctl_oid_top, "recvspace", CTLTYPE_INT|CTLFLAG_RW,
1444 &SCTP_BASE_SYSCTL(sctp_recvspace), 0, sctp_sysctl_handle_int,
1445 SCTPCTL_RECVSPACE_DESC);
1446
1447 sysctl_add_oid(&sysctl_oid_top, "auto_asconf", CTLTYPE_INT|CTLFLAG_RW,
1448 &SCTP_BASE_SYSCTL(sctp_auto_asconf), 0, sctp_sysctl_handle_int,
1449 SCTPCTL_AUTOASCONF_DESC);
1450
1451 sysctl_add_oid(&sysctl_oid_top, "ecn_enable", CTLTYPE_INT|CTLFLAG_RW,
1452 &SCTP_BASE_SYSCTL(sctp_ecn_enable), 0, sctp_sysctl_handle_int,
1453 SCTPCTL_ECN_ENABLE_DESC);
1454
1455 sysctl_add_oid(&sysctl_oid_top, "pr_enable", CTLTYPE_INT|CTLFLAG_RW,
1456 &SCTP_BASE_SYSCTL(sctp_pr_enable), 0, sctp_sysctl_handle_int,
1457 SCTPCTL_PR_ENABLE_DESC);
1458
1459 sysctl_add_oid(&sysctl_oid_top, "auth_enable", CTLTYPE_INT|CTLFLAG_RW,
1460 &SCTP_BASE_SYSCTL(sctp_auth_enable), 0, sctp_sysctl_handle_auth,
1461 SCTPCTL_AUTH_ENABLE_DESC);
1462
1463 sysctl_add_oid(&sysctl_oid_top, "asconf_enable", CTLTYPE_INT|CTLFLAG_RW,
1464 &SCTP_BASE_SYSCTL(sctp_asconf_enable), 0, sctp_sysctl_handle_asconf,
1465 SCTPCTL_ASCONF_ENABLE_DESC);
1466
1467 sysctl_add_oid(&sysctl_oid_top, "reconfig_enable", CTLTYPE_INT|CTLFLAG_RW,
1468 &SCTP_BASE_SYSCTL(sctp_reconfig_enable), 0, sctp_sysctl_handle_int,
1469 SCTPCTL_RECONFIG_ENABLE_DESC);
1470
1471 sysctl_add_oid(&sysctl_oid_top, "nrsack_enable", CTLTYPE_INT|CTLFLAG_RW,
1472 &SCTP_BASE_SYSCTL(sctp_nrsack_enable), 0, sctp_sysctl_handle_int,
1473 SCTPCTL_NRSACK_ENABLE_DESC);
1474
1475 sysctl_add_oid(&sysctl_oid_top, "pktdrop_enable", CTLTYPE_INT|CTLFLAG_RW,
1476 &SCTP_BASE_SYSCTL(sctp_pktdrop_enable), 0, sctp_sysctl_handle_int,
1477 SCTPCTL_PKTDROP_ENABLE_DESC);
1478
1479 sysctl_add_oid(&sysctl_oid_top, "loopback_nocsum", CTLTYPE_INT|CTLFLAG_RW,
1480 &SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback), 0, sctp_sysctl_handle_int,
1481 SCTPCTL_LOOPBACK_NOCSUM_DESC);
1482
1483 sysctl_add_oid(&sysctl_oid_top, "peer_chkoh", CTLTYPE_INT|CTLFLAG_RW,
1484 &SCTP_BASE_SYSCTL(sctp_peer_chunk_oh), 0, sctp_sysctl_handle_int,
1485 SCTPCTL_PEER_CHKOH_DESC);
1486
1487 sysctl_add_oid(&sysctl_oid_top, "maxburst", CTLTYPE_INT|CTLFLAG_RW,
1488 &SCTP_BASE_SYSCTL(sctp_max_burst_default), 0, sctp_sysctl_handle_int,
1489 SCTPCTL_MAXBURST_DESC);
1490
1491 sysctl_add_oid(&sysctl_oid_top, "fr_maxburst", CTLTYPE_INT|CTLFLAG_RW,
1492 &SCTP_BASE_SYSCTL(sctp_fr_max_burst_default), 0, sctp_sysctl_handle_int,
1493 SCTPCTL_FRMAXBURST_DESC);
1494
1495 sysctl_add_oid(&sysctl_oid_top, "maxchunks", CTLTYPE_INT|CTLFLAG_RW,
1496 &SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue), 0, sctp_sysctl_handle_int,
1497 SCTPCTL_MAXCHUNKS_DESC);
1498
1499 sysctl_add_oid(&sysctl_oid_top, "tcbhashsize", CTLTYPE_INT|CTLFLAG_RW,
1500 &SCTP_BASE_SYSCTL(sctp_hashtblsize), 0, sctp_sysctl_handle_int,
1501 SCTPCTL_TCBHASHSIZE_DESC);
1502
1503 sysctl_add_oid(&sysctl_oid_top, "pcbhashsize", CTLTYPE_INT|CTLFLAG_RW,
1504 &SCTP_BASE_SYSCTL(sctp_pcbtblsize), 0, sctp_sysctl_handle_int,
1505 SCTPCTL_PCBHASHSIZE_DESC);
1506
1507 sysctl_add_oid(&sysctl_oid_top, "min_split_point", CTLTYPE_INT|CTLFLAG_RW,
1508 &SCTP_BASE_SYSCTL(sctp_min_split_point), 0, sctp_sysctl_handle_int,
1509 SCTPCTL_MIN_SPLIT_POINT_DESC);
1510
1511 sysctl_add_oid(&sysctl_oid_top, "chunkscale", CTLTYPE_INT|CTLFLAG_RW,
1512 &SCTP_BASE_SYSCTL(sctp_chunkscale), 0, sctp_sysctl_handle_int,
1513 SCTPCTL_CHUNKSCALE_DESC);
1514
1515 sysctl_add_oid(&sysctl_oid_top, "delayed_sack_time", CTLTYPE_INT|CTLFLAG_RW,
1516 &SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default), 0, sctp_sysctl_handle_int,
1517 SCTPCTL_DELAYED_SACK_TIME_DESC);
1518
1519 sysctl_add_oid(&sysctl_oid_top, "sack_freq", CTLTYPE_INT|CTLFLAG_RW,
1520 &SCTP_BASE_SYSCTL(sctp_sack_freq_default), 0, sctp_sysctl_handle_int,
1521 SCTPCTL_SACK_FREQ_DESC);
1522
1523 sysctl_add_oid(&sysctl_oid_top, "sys_resource", CTLTYPE_INT|CTLFLAG_RW,
1524 &SCTP_BASE_SYSCTL(sctp_system_free_resc_limit), 0, sctp_sysctl_handle_int,
1525 SCTPCTL_SYS_RESOURCE_DESC);
1526
1527 sysctl_add_oid(&sysctl_oid_top, "asoc_resource", CTLTYPE_INT|CTLFLAG_RW,
1528 &SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit), 0, sctp_sysctl_handle_int,
1529 SCTPCTL_ASOC_RESOURCE_DESC);
1530
1531 sysctl_add_oid(&sysctl_oid_top, "heartbeat_interval", CTLTYPE_INT|CTLFLAG_RW,
1532 &SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default), 0, sctp_sysctl_handle_int,
1533 SCTPCTL_HEARTBEAT_INTERVAL_DESC);
1534
1535 sysctl_add_oid(&sysctl_oid_top, "pmtu_raise_time", CTLTYPE_INT|CTLFLAG_RW,
1536 &SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default), 0, sctp_sysctl_handle_int,
1537 SCTPCTL_PMTU_RAISE_TIME_DESC);
1538
1539 sysctl_add_oid(&sysctl_oid_top, "shutdown_guard_time", CTLTYPE_INT|CTLFLAG_RW,
1540 &SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default), 0, sctp_sysctl_handle_int,
1541 SCTPCTL_SHUTDOWN_GUARD_TIME_DESC);
1542
1543 sysctl_add_oid(&sysctl_oid_top, "secret_lifetime", CTLTYPE_INT|CTLFLAG_RW,
1544 &SCTP_BASE_SYSCTL(sctp_secret_lifetime_default), 0, sctp_sysctl_handle_int,
1545 SCTPCTL_SECRET_LIFETIME_DESC);
1546
1547 sysctl_add_oid(&sysctl_oid_top, "rto_max", CTLTYPE_INT|CTLFLAG_RW,
1548 &SCTP_BASE_SYSCTL(sctp_rto_max_default), 0, sctp_sysctl_handle_int,
1549 SCTPCTL_RTO_MAX_DESC);
1550
1551 sysctl_add_oid(&sysctl_oid_top, "rto_min", CTLTYPE_INT|CTLFLAG_RW,
1552 &SCTP_BASE_SYSCTL(sctp_rto_min_default), 0, sctp_sysctl_handle_int,
1553 SCTPCTL_RTO_MIN_DESC);
1554
1555 sysctl_add_oid(&sysctl_oid_top, "rto_initial", CTLTYPE_INT|CTLFLAG_RW,
1556 &SCTP_BASE_SYSCTL(sctp_rto_initial_default), 0, sctp_sysctl_handle_int,
1557 SCTPCTL_RTO_INITIAL_DESC);
1558
1559 sysctl_add_oid(&sysctl_oid_top, "init_rto_max", CTLTYPE_INT|CTLFLAG_RW,
1560 &SCTP_BASE_SYSCTL(sctp_init_rto_max_default), 0, sctp_sysctl_handle_int,
1561 SCTPCTL_INIT_RTO_MAX_DESC);
1562
1563 sysctl_add_oid(&sysctl_oid_top, "valid_cookie_life", CTLTYPE_INT|CTLFLAG_RW,
1564 &SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default), 0, sctp_sysctl_handle_int,
1565 SCTPCTL_VALID_COOKIE_LIFE_DESC);
1566
1567 sysctl_add_oid(&sysctl_oid_top, "init_rtx_max", CTLTYPE_INT|CTLFLAG_RW,
1568 &SCTP_BASE_SYSCTL(sctp_init_rtx_max_default), 0, sctp_sysctl_handle_int,
1569 SCTPCTL_INIT_RTX_MAX_DESC);
1570
1571 sysctl_add_oid(&sysctl_oid_top, "assoc_rtx_max", CTLTYPE_INT|CTLFLAG_RW,
1572 &SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default), 0, sctp_sysctl_handle_int,
1573 SCTPCTL_ASSOC_RTX_MAX_DESC);
1574
1575 sysctl_add_oid(&sysctl_oid_top, "path_rtx_max", CTLTYPE_INT|CTLFLAG_RW,
1576 &SCTP_BASE_SYSCTL(sctp_path_rtx_max_default), 0, sctp_sysctl_handle_int,
1577 SCTPCTL_PATH_RTX_MAX_DESC);
1578
1579 sysctl_add_oid(&sysctl_oid_top, "path_pf_threshold", CTLTYPE_INT|CTLFLAG_RW,
1580 &SCTP_BASE_SYSCTL(sctp_path_pf_threshold), 0, sctp_sysctl_handle_int,
1581 SCTPCTL_PATH_PF_THRESHOLD_DESC);
1582
1583 sysctl_add_oid(&sysctl_oid_top, "add_more_on_output", CTLTYPE_INT|CTLFLAG_RW,
1584 &SCTP_BASE_SYSCTL(sctp_add_more_threshold), 0, sctp_sysctl_handle_int,
1585 SCTPCTL_ADD_MORE_ON_OUTPUT_DESC);
1586
1587 sysctl_add_oid(&sysctl_oid_top, "incoming_streams", CTLTYPE_INT|CTLFLAG_RW,
1588 &SCTP_BASE_SYSCTL(sctp_nr_incoming_streams_default), 0, sctp_sysctl_handle_int,
1589 SCTPCTL_INCOMING_STREAMS_DESC);
1590
1591 sysctl_add_oid(&sysctl_oid_top, "outgoing_streams", CTLTYPE_INT|CTLFLAG_RW,
1592 &SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default), 0, sctp_sysctl_handle_int,
1593 SCTPCTL_OUTGOING_STREAMS_DESC);
1594
1595 sysctl_add_oid(&sysctl_oid_top, "cmt_on_off", CTLTYPE_INT|CTLFLAG_RW,
1596 &SCTP_BASE_SYSCTL(sctp_cmt_on_off), 0, sctp_sysctl_handle_int,
1597 SCTPCTL_CMT_ON_OFF_DESC);
1598
1599 sysctl_add_oid(&sysctl_oid_top, "cmt_use_dac", CTLTYPE_INT|CTLFLAG_RW,
1600 &SCTP_BASE_SYSCTL(sctp_cmt_use_dac), 0, sctp_sysctl_handle_int,
1601 SCTPCTL_CMT_USE_DAC_DESC);
1602
1603 sysctl_add_oid(&sysctl_oid_top, "cwnd_maxburst", CTLTYPE_INT|CTLFLAG_RW,
1604 &SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst), 0, sctp_sysctl_handle_int,
1605 SCTPCTL_CWND_MAXBURST_DESC);
1606
1607 sysctl_add_oid(&sysctl_oid_top, "nat_friendly", CTLTYPE_INT|CTLFLAG_RW,
1608 &SCTP_BASE_SYSCTL(sctp_nat_friendly), 0, sctp_sysctl_handle_int,
1609 SCTPCTL_NAT_FRIENDLY_DESC);
1610
1611 sysctl_add_oid(&sysctl_oid_top, "abc_l_var", CTLTYPE_INT|CTLFLAG_RW,
1612 &SCTP_BASE_SYSCTL(sctp_L2_abc_variable), 0, sctp_sysctl_handle_int,
1613 SCTPCTL_ABC_L_VAR_DESC);
1614
1615 sysctl_add_oid(&sysctl_oid_top, "max_chained_mbufs", CTLTYPE_INT|CTLFLAG_RW,
1616 &SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count), 0, sctp_sysctl_handle_int,
1617 SCTPCTL_MAX_CHAINED_MBUFS_DESC);
1618
1619 sysctl_add_oid(&sysctl_oid_top, "do_sctp_drain", CTLTYPE_INT|CTLFLAG_RW,
1620 &SCTP_BASE_SYSCTL(sctp_do_drain), 0, sctp_sysctl_handle_int,
1621 SCTPCTL_DO_SCTP_DRAIN_DESC);
1622
1623 sysctl_add_oid(&sysctl_oid_top, "hb_max_burst", CTLTYPE_INT|CTLFLAG_RW,
1624 &SCTP_BASE_SYSCTL(sctp_hb_maxburst), 0, sctp_sysctl_handle_int,
1625 SCTPCTL_HB_MAX_BURST_DESC);
1626
1627 sysctl_add_oid(&sysctl_oid_top, "abort_at_limit", CTLTYPE_INT|CTLFLAG_RW,
1628 &SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit), 0, sctp_sysctl_handle_int,
1629 SCTPCTL_ABORT_AT_LIMIT_DESC);
1630
1631 sysctl_add_oid(&sysctl_oid_top, "min_residual", CTLTYPE_INT|CTLFLAG_RW,
1632 &SCTP_BASE_SYSCTL(sctp_min_residual), 0, sctp_sysctl_handle_int,
1633 SCTPCTL_MIN_RESIDUAL_DESC);
1634
1635 sysctl_add_oid(&sysctl_oid_top, "max_retran_chunk", CTLTYPE_INT|CTLFLAG_RW,
1636 &SCTP_BASE_SYSCTL(sctp_max_retran_chunk), 0, sctp_sysctl_handle_int,
1637 SCTPCTL_MAX_RETRAN_CHUNK_DESC);
1638
1639 sysctl_add_oid(&sysctl_oid_top, "log_level", CTLTYPE_INT|CTLFLAG_RW,
1640 &SCTP_BASE_SYSCTL(sctp_logging_level), 0, sctp_sysctl_handle_int,
1641 SCTPCTL_LOGGING_LEVEL_DESC);
1642
1643 sysctl_add_oid(&sysctl_oid_top, "default_cc_module", CTLTYPE_INT|CTLFLAG_RW,
1644 &SCTP_BASE_SYSCTL(sctp_default_cc_module), 0, sctp_sysctl_handle_int,
1645 SCTPCTL_DEFAULT_CC_MODULE_DESC);
1646
1647 sysctl_add_oid(&sysctl_oid_top, "default_ss_module", CTLTYPE_INT|CTLFLAG_RW,
1648 &SCTP_BASE_SYSCTL(sctp_default_ss_module), 0, sctp_sysctl_handle_int,
1649 SCTPCTL_DEFAULT_SS_MODULE_DESC);
1650
1651 sysctl_add_oid(&sysctl_oid_top, "default_frag_interleave", CTLTYPE_INT|CTLFLAG_RW,
1652 &SCTP_BASE_SYSCTL(sctp_default_frag_interleave), 0, sctp_sysctl_handle_int,
1653 SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DESC);
1654
1655 sysctl_add_oid(&sysctl_oid_top, "mobility_base", CTLTYPE_INT|CTLFLAG_RW,
1656 &SCTP_BASE_SYSCTL(sctp_mobility_base), 0, sctp_sysctl_handle_int,
1657 SCTPCTL_MOBILITY_BASE_DESC);
1658
1659 sysctl_add_oid(&sysctl_oid_top, "mobility_fasthandoff", CTLTYPE_INT|CTLFLAG_RW,
1660 &SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff), 0, sctp_sysctl_handle_int,
1661 SCTPCTL_MOBILITY_FASTHANDOFF_DESC);
1662
1663 #if defined(SCTP_LOCAL_TRACE_BUF)
1664 sysctl_add_oid(&sysctl_oid_top, "sctp_log", CTLTYPE_STRUCT|CTLFLAG_RD,
1665 SCTP_BASE_SYSCTL(sctp_log), sizeof(struct sctp_log), NULL,
1666 "SCTP logging (struct sctp_log)");
1667
1668 sysctl_add_oid(&sysctl_oid_top, "clear_trace", CTLTYPE_INT|CTLFLAG_WR,
1669 NULL, 0, sctp_sysctl_handle_trace_log_clear,
1670 "Clear SCTP Logging buffer");
1671 #endif
1672
1673 sysctl_add_oid(&sysctl_oid_top, "udp_tunneling_port", CTLTYPE_INT|CTLFLAG_RW,
1674 &SCTP_BASE_SYSCTL(sctp_udp_tunneling_port), 0, sctp_sysctl_handle_udp_tunneling,
1675 SCTPCTL_UDP_TUNNELING_PORT_DESC);
1676
1677 sysctl_add_oid(&sysctl_oid_top, "enable_sack_immediately", CTLTYPE_INT|CTLFLAG_RW,
1678 &SCTP_BASE_SYSCTL(sctp_enable_sack_immediately), 0, sctp_sysctl_handle_int,
1679 SCTPCTL_SACK_IMMEDIATELY_ENABLE_DESC);
1680
1681 sysctl_add_oid(&sysctl_oid_top, "nat_friendly_init", CTLTYPE_INT|CTLFLAG_RW,
1682 &SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly), 0, sctp_sysctl_handle_int,
1683 SCTPCTL_NAT_FRIENDLY_DESC);
1684
1685 sysctl_add_oid(&sysctl_oid_top, "vtag_time_wait", CTLTYPE_INT|CTLFLAG_RW,
1686 &SCTP_BASE_SYSCTL(sctp_vtag_time_wait), 0, sctp_sysctl_handle_int,
1687 SCTPCTL_TIME_WAIT_DESC);
1688
1689 sysctl_add_oid(&sysctl_oid_top, "buffer_splitting", CTLTYPE_INT|CTLFLAG_RW,
1690 &SCTP_BASE_SYSCTL(sctp_buffer_splitting), 0, sctp_sysctl_handle_int,
1691 SCTPCTL_BUFFER_SPLITTING_DESC);
1692
1693 sysctl_add_oid(&sysctl_oid_top, "initial_cwnd", CTLTYPE_INT|CTLFLAG_RW,
1694 &SCTP_BASE_SYSCTL(sctp_initial_cwnd), 0, sctp_sysctl_handle_int,
1695 SCTPCTL_INITIAL_CWND_DESC);
1696
1697 sysctl_add_oid(&sysctl_oid_top, "rttvar_bw", CTLTYPE_INT|CTLFLAG_RW,
1698 &SCTP_BASE_SYSCTL(sctp_rttvar_bw), 0, sctp_sysctl_handle_int,
1699 SCTPCTL_RTTVAR_BW_DESC);
1700
1701 sysctl_add_oid(&sysctl_oid_top, "rttvar_rtt", CTLTYPE_INT|CTLFLAG_RW,
1702 &SCTP_BASE_SYSCTL(sctp_rttvar_rtt), 0, sctp_sysctl_handle_int,
1703 SCTPCTL_RTTVAR_RTT_DESC);
1704
1705 sysctl_add_oid(&sysctl_oid_top, "rttvar_eqret", CTLTYPE_INT|CTLFLAG_RW,
1706 &SCTP_BASE_SYSCTL(sctp_rttvar_eqret), 0, sctp_sysctl_handle_int,
1707 SCTPCTL_RTTVAR_EQRET_DESC);
1708
1709 sysctl_add_oid(&sysctl_oid_top, "rttvar_steady_step", CTLTYPE_INT|CTLFLAG_RW,
1710 &SCTP_BASE_SYSCTL(sctp_steady_step), 0, sctp_sysctl_handle_int,
1711 SCTPCTL_RTTVAR_STEADYS_DESC);
1712
1713 sysctl_add_oid(&sysctl_oid_top, "use_dcccecn", CTLTYPE_INT|CTLFLAG_RW,
1714 &SCTP_BASE_SYSCTL(sctp_use_dccc_ecn), 0, sctp_sysctl_handle_int,
1715 SCTPCTL_RTTVAR_DCCCECN_DESC);
1716
1717 sysctl_add_oid(&sysctl_oid_top, "blackhole", CTLTYPE_INT|CTLFLAG_RW,
1718 &SCTP_BASE_SYSCTL(sctp_blackhole), 0, sctp_sysctl_handle_int,
1719 SCTPCTL_BLACKHOLE_DESC);
1720
1721 sysctl_add_oid(&sysctl_oid_top, "sendall_limit", CTLTYPE_INT|CTLFLAG_RW,
1722 &SCTP_BASE_SYSCTL(sctp_sendall_limit), 0, sctp_sysctl_handle_int,
1723 SCTPCTL_SENDALL_LIMIT_DESC);
1724
1725 sysctl_add_oid(&sysctl_oid_top, "diag_info_code", CTLTYPE_INT|CTLFLAG_RW,
1726 &SCTP_BASE_SYSCTL(sctp_diag_info_code), 0, sctp_sysctl_handle_int,
1727 SCTPCTL_DIAG_INFO_CODE_DESC);
1728
1729 #ifdef SCTP_DEBUG
1730 sysctl_add_oid(&sysctl_oid_top, "debug", CTLTYPE_INT|CTLFLAG_RW,
1731 &SCTP_BASE_SYSCTL(sctp_debug_on), 0, sctp_sysctl_handle_int,
1732 SCTPCTL_DEBUG_DESC);
1733 #endif
1734
1735 sysctl_add_oid(&sysctl_oid_top, "stats", CTLTYPE_STRUCT|CTLFLAG_RW,
1736 &SCTP_BASE_STATS, sizeof(SCTP_BASE_STATS), NULL,
1737 "SCTP statistics (struct sctp_stat)");
1738
1739 sysctl_add_oid(&sysctl_oid_top, "assoclist", CTLTYPE_STRUCT|CTLFLAG_RD,
1740 NULL, 0, sctp_assoclist,
1741 "List of active SCTP associations");
1742 }
1743 #endif
1744 #endif
1745