xref: /freebsd/sys/netinet/sctp_sysctl.c (revision 2f6a179eb910129fb812c1ad1bdc300da1203dc0)
1 /*-
2  * Copyright (c) 2007, by Cisco Systems, Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * a) Redistributions of source code must retain the above copyright notice,
8  *   this list of conditions and the following disclaimer.
9  *
10  * b) Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in
12  *   the documentation and/or other materials provided with the distribution.
13  *
14  * c) Neither the name of Cisco Systems, Inc. nor the names of its
15  *    contributors may be used to endorse or promote products derived
16  *    from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28  * THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
33 
34 #include <netinet/sctp_os.h>
35 #include <netinet/sctp.h>
36 #include <netinet/sctp_constants.h>
37 #include <netinet/sctp_sysctl.h>
38 #include <netinet/sctp_pcb.h>
39 #include <netinet/sctputil.h>
40 #include <netinet/sctp_output.h>
41 
42 /*
43  * sysctl tunable variables
44  */
45 
46 void
47 sctp_init_sysctls()
48 {
49 	SCTP_BASE_SYSCTL(sctp_sendspace) = SCTPCTL_MAXDGRAM_DEFAULT;
50 	SCTP_BASE_SYSCTL(sctp_recvspace) = SCTPCTL_RECVSPACE_DEFAULT;
51 	SCTP_BASE_SYSCTL(sctp_auto_asconf) = SCTPCTL_AUTOASCONF_DEFAULT;
52 	SCTP_BASE_SYSCTL(sctp_multiple_asconfs) = SCTPCTL_MULTIPLEASCONFS_DEFAULT;
53 	SCTP_BASE_SYSCTL(sctp_ecn_enable) = SCTPCTL_ECN_ENABLE_DEFAULT;
54 	SCTP_BASE_SYSCTL(sctp_ecn_nonce) = SCTPCTL_ECN_NONCE_DEFAULT;
55 	SCTP_BASE_SYSCTL(sctp_strict_sacks) = SCTPCTL_STRICT_SACKS_DEFAULT;
56 	SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback) = SCTPCTL_LOOPBACK_NOCSUM_DEFAULT;
57 	SCTP_BASE_SYSCTL(sctp_strict_init) = SCTPCTL_STRICT_INIT_DEFAULT;
58 	SCTP_BASE_SYSCTL(sctp_peer_chunk_oh) = SCTPCTL_PEER_CHKOH_DEFAULT;
59 	SCTP_BASE_SYSCTL(sctp_max_burst_default) = SCTPCTL_MAXBURST_DEFAULT;
60 	SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue) = SCTPCTL_MAXCHUNKS_DEFAULT;
61 	SCTP_BASE_SYSCTL(sctp_hashtblsize) = SCTPCTL_TCBHASHSIZE_DEFAULT;
62 	SCTP_BASE_SYSCTL(sctp_pcbtblsize) = SCTPCTL_PCBHASHSIZE_DEFAULT;
63 	SCTP_BASE_SYSCTL(sctp_min_split_point) = SCTPCTL_MIN_SPLIT_POINT_DEFAULT;
64 	SCTP_BASE_SYSCTL(sctp_chunkscale) = SCTPCTL_CHUNKSCALE_DEFAULT;
65 	SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default) = SCTPCTL_DELAYED_SACK_TIME_DEFAULT;
66 	SCTP_BASE_SYSCTL(sctp_sack_freq_default) = SCTPCTL_SACK_FREQ_DEFAULT;
67 	SCTP_BASE_SYSCTL(sctp_system_free_resc_limit) = SCTPCTL_SYS_RESOURCE_DEFAULT;
68 	SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit) = SCTPCTL_ASOC_RESOURCE_DEFAULT;
69 	SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default) = SCTPCTL_HEARTBEAT_INTERVAL_DEFAULT;
70 	SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default) = SCTPCTL_PMTU_RAISE_TIME_DEFAULT;
71 	SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default) = SCTPCTL_SHUTDOWN_GUARD_TIME_DEFAULT;
72 	SCTP_BASE_SYSCTL(sctp_secret_lifetime_default) = SCTPCTL_SECRET_LIFETIME_DEFAULT;
73 	SCTP_BASE_SYSCTL(sctp_rto_max_default) = SCTPCTL_RTO_MAX_DEFAULT;
74 	SCTP_BASE_SYSCTL(sctp_rto_min_default) = SCTPCTL_RTO_MIN_DEFAULT;
75 	SCTP_BASE_SYSCTL(sctp_rto_initial_default) = SCTPCTL_RTO_INITIAL_DEFAULT;
76 	SCTP_BASE_SYSCTL(sctp_init_rto_max_default) = SCTPCTL_INIT_RTO_MAX_DEFAULT;
77 	SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default) = SCTPCTL_VALID_COOKIE_LIFE_DEFAULT;
78 	SCTP_BASE_SYSCTL(sctp_init_rtx_max_default) = SCTPCTL_INIT_RTX_MAX_DEFAULT;
79 	SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default) = SCTPCTL_ASSOC_RTX_MAX_DEFAULT;
80 	SCTP_BASE_SYSCTL(sctp_path_rtx_max_default) = SCTPCTL_PATH_RTX_MAX_DEFAULT;
81 	SCTP_BASE_SYSCTL(sctp_add_more_threshold) = SCTPCTL_ADD_MORE_ON_OUTPUT_DEFAULT;
82 	SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default) = SCTPCTL_OUTGOING_STREAMS_DEFAULT;
83 	SCTP_BASE_SYSCTL(sctp_cmt_on_off) = SCTPCTL_CMT_ON_OFF_DEFAULT;
84 	SCTP_BASE_SYSCTL(sctp_cmt_use_dac) = SCTPCTL_CMT_USE_DAC_DEFAULT;
85 	SCTP_BASE_SYSCTL(sctp_cmt_pf) = SCTPCTL_CMT_PF_DEFAULT;
86 	SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst) = SCTPCTL_CWND_MAXBURST_DEFAULT;
87 	SCTP_BASE_SYSCTL(sctp_early_fr) = SCTPCTL_EARLY_FAST_RETRAN_DEFAULT;
88 	SCTP_BASE_SYSCTL(sctp_early_fr_msec) = SCTPCTL_EARLY_FAST_RETRAN_MSEC_DEFAULT;
89 	SCTP_BASE_SYSCTL(sctp_asconf_auth_nochk) = SCTPCTL_ASCONF_AUTH_NOCHK_DEFAULT;
90 	SCTP_BASE_SYSCTL(sctp_auth_disable) = SCTPCTL_AUTH_DISABLE_DEFAULT;
91 	SCTP_BASE_SYSCTL(sctp_nat_friendly) = SCTPCTL_NAT_FRIENDLY_DEFAULT;
92 	SCTP_BASE_SYSCTL(sctp_L2_abc_variable) = SCTPCTL_ABC_L_VAR_DEFAULT;
93 	SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count) = SCTPCTL_MAX_CHAINED_MBUFS_DEFAULT;
94 	SCTP_BASE_SYSCTL(sctp_do_drain) = SCTPCTL_DO_SCTP_DRAIN_DEFAULT;
95 	SCTP_BASE_SYSCTL(sctp_hb_maxburst) = SCTPCTL_HB_MAX_BURST_DEFAULT;
96 	SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit) = SCTPCTL_ABORT_AT_LIMIT_DEFAULT;
97 	SCTP_BASE_SYSCTL(sctp_strict_data_order) = SCTPCTL_STRICT_DATA_ORDER_DEFAULT;
98 	SCTP_BASE_SYSCTL(sctp_min_residual) = SCTPCTL_MIN_RESIDUAL_DEFAULT;
99 	SCTP_BASE_SYSCTL(sctp_max_retran_chunk) = SCTPCTL_MAX_RETRAN_CHUNK_DEFAULT;
100 	SCTP_BASE_SYSCTL(sctp_logging_level) = SCTPCTL_LOGGING_LEVEL_DEFAULT;
101 	/* JRS - Variable for default congestion control module */
102 	SCTP_BASE_SYSCTL(sctp_default_cc_module) = SCTPCTL_DEFAULT_CC_MODULE_DEFAULT;
103 	SCTP_BASE_SYSCTL(sctp_default_frag_interleave) = SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DEFAULT;
104 	SCTP_BASE_SYSCTL(sctp_mobility_base) = SCTPCTL_MOBILITY_BASE_DEFAULT;
105 	SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff) = SCTPCTL_MOBILITY_FASTHANDOFF_DEFAULT;
106 #if defined(SCTP_LOCAL_TRACE_BUF)
107 	memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log));
108 #endif
109 	SCTP_BASE_SYSCTL(sctp_udp_tunneling_for_client_enable) = SCTPCTL_UDP_TUNNELING_FOR_CLIENT_ENABLE_DEFAULT;
110 	SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = SCTPCTL_UDP_TUNNELING_PORT_DEFAULT;
111 	SCTP_BASE_SYSCTL(sctp_enable_sack_immediately) = SCTPCTL_SACK_IMMEDIATELY_ENABLE_DEFAULT;
112 #if defined(SCTP_DEBUG)
113 	SCTP_BASE_SYSCTL(sctp_debug_on) = SCTPCTL_DEBUG_DEFAULT;
114 #endif
115 #if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
116 	SCTP_BASE_SYSCTL(sctp_output_unlocked) = SCTPCTL_OUTPUT_UNLOCKED_DEFAULT;
117 #endif
118 }
119 
120 /* It returns an upper limit. No filtering is done here */
121 static unsigned int
122 number_of_addresses(struct sctp_inpcb *inp)
123 {
124 	int cnt;
125 	struct sctp_vrf *vrf;
126 	struct sctp_ifn *sctp_ifn;
127 	struct sctp_ifa *sctp_ifa;
128 	struct sctp_laddr *laddr;
129 
130 	cnt = 0;
131 	/* neither Mac OS X nor FreeBSD support mulitple routing functions */
132 	if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) {
133 		return (0);
134 	}
135 	if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
136 		LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
137 			LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
138 				if ((sctp_ifa->address.sa.sa_family == AF_INET) ||
139 				    (sctp_ifa->address.sa.sa_family == AF_INET6)) {
140 					cnt++;
141 				}
142 			}
143 		}
144 	} else {
145 		LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
146 			if ((laddr->ifa->address.sa.sa_family == AF_INET) ||
147 			    (laddr->ifa->address.sa.sa_family == AF_INET6)) {
148 				cnt++;
149 			}
150 		}
151 	}
152 	return (cnt);
153 }
154 
155 static int
156 copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sysctl_req *req)
157 {
158 	struct sctp_ifn *sctp_ifn;
159 	struct sctp_ifa *sctp_ifa;
160 	int loopback_scope, ipv4_local_scope, local_scope, site_scope;
161 	int ipv4_addr_legal, ipv6_addr_legal;
162 	struct sctp_vrf *vrf;
163 	struct xsctp_laddr xladdr;
164 	struct sctp_laddr *laddr;
165 	int error;
166 
167 	/* Turn on all the appropriate scope */
168 	if (stcb) {
169 		/* use association specific values */
170 		loopback_scope = stcb->asoc.loopback_scope;
171 		ipv4_local_scope = stcb->asoc.ipv4_local_scope;
172 		local_scope = stcb->asoc.local_scope;
173 		site_scope = stcb->asoc.site_scope;
174 	} else {
175 		/* use generic values for endpoints */
176 		loopback_scope = 1;
177 		ipv4_local_scope = 1;
178 		local_scope = 1;
179 		site_scope = 1;
180 	}
181 
182 	/* use only address families of interest */
183 	if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) {
184 		ipv6_addr_legal = 1;
185 		if (SCTP_IPV6_V6ONLY(inp)) {
186 			ipv4_addr_legal = 0;
187 		} else {
188 			ipv4_addr_legal = 1;
189 		}
190 	} else {
191 		ipv4_addr_legal = 1;
192 		ipv6_addr_legal = 0;
193 	}
194 
195 	error = 0;
196 
197 	/* neither Mac OS X nor FreeBSD support mulitple routing functions */
198 	if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) {
199 		SCTP_INP_RUNLOCK(inp);
200 		SCTP_INP_INFO_RUNLOCK();
201 		return (-1);
202 	}
203 	if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
204 		LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
205 			if ((loopback_scope == 0) && SCTP_IFN_IS_IFT_LOOP(sctp_ifn))
206 				/* Skip loopback if loopback_scope not set */
207 				continue;
208 			LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
209 				if (stcb) {
210 					/*
211 					 * ignore if blacklisted at
212 					 * association level
213 					 */
214 					if (sctp_is_addr_restricted(stcb, sctp_ifa))
215 						continue;
216 				}
217 				switch (sctp_ifa->address.sa.sa_family) {
218 				case AF_INET:
219 					if (ipv4_addr_legal) {
220 						struct sockaddr_in *sin;
221 
222 						sin = (struct sockaddr_in *)&sctp_ifa->address.sa;
223 						if (sin->sin_addr.s_addr == 0)
224 							continue;
225 						if ((ipv4_local_scope == 0) && (IN4_ISPRIVATE_ADDRESS(&sin->sin_addr)))
226 							continue;
227 					} else {
228 						continue;
229 					}
230 					break;
231 #ifdef INET6
232 				case AF_INET6:
233 					if (ipv6_addr_legal) {
234 						struct sockaddr_in6 *sin6;
235 
236 						sin6 = (struct sockaddr_in6 *)&sctp_ifa->address.sa;
237 						if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr))
238 							continue;
239 						if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
240 							if (local_scope == 0)
241 								continue;
242 							if (sin6->sin6_scope_id == 0) {
243 								/*
244 								 * bad link
245 								 * local
246 								 * address
247 								 */
248 								if (sa6_recoverscope(sin6) != 0)
249 									continue;
250 							}
251 						}
252 						if ((site_scope == 0) && (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)))
253 							continue;
254 					} else {
255 						continue;
256 					}
257 					break;
258 #endif
259 				default:
260 					continue;
261 				}
262 				memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
263 				memcpy((void *)&xladdr.address, (const void *)&sctp_ifa->address, sizeof(union sctp_sockstore));
264 				SCTP_INP_RUNLOCK(inp);
265 				SCTP_INP_INFO_RUNLOCK();
266 				error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
267 				if (error) {
268 					return (error);
269 				} else {
270 					SCTP_INP_INFO_RLOCK();
271 					SCTP_INP_RLOCK(inp);
272 				}
273 			}
274 		}
275 	} else {
276 		LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
277 			/* ignore if blacklisted at association level */
278 			if (stcb && sctp_is_addr_restricted(stcb, laddr->ifa))
279 				continue;
280 			memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
281 			memcpy((void *)&xladdr.address, (const void *)&laddr->ifa->address, sizeof(union sctp_sockstore));
282 			xladdr.start_time.tv_sec = (uint32_t) laddr->start_time.tv_sec;
283 			xladdr.start_time.tv_usec = (uint32_t) laddr->start_time.tv_usec;
284 			SCTP_INP_RUNLOCK(inp);
285 			SCTP_INP_INFO_RUNLOCK();
286 			error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
287 			if (error) {
288 				return (error);
289 			} else {
290 				SCTP_INP_INFO_RLOCK();
291 				SCTP_INP_RLOCK(inp);
292 			}
293 		}
294 	}
295 	memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
296 	xladdr.last = 1;
297 	SCTP_INP_RUNLOCK(inp);
298 	SCTP_INP_INFO_RUNLOCK();
299 	error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
300 
301 	if (error) {
302 		return (error);
303 	} else {
304 		SCTP_INP_INFO_RLOCK();
305 		SCTP_INP_RLOCK(inp);
306 		return (0);
307 	}
308 }
309 
310 /*
311  * sysctl functions
312  */
313 static int
314 sctp_assoclist(SYSCTL_HANDLER_ARGS)
315 {
316 	unsigned int number_of_endpoints;
317 	unsigned int number_of_local_addresses;
318 	unsigned int number_of_associations;
319 	unsigned int number_of_remote_addresses;
320 	unsigned int n;
321 	int error;
322 	struct sctp_inpcb *inp;
323 	struct sctp_tcb *stcb;
324 	struct sctp_nets *net;
325 	struct xsctp_inpcb xinpcb;
326 	struct xsctp_tcb xstcb;
327 	struct xsctp_raddr xraddr;
328 
329 	number_of_endpoints = 0;
330 	number_of_local_addresses = 0;
331 	number_of_associations = 0;
332 	number_of_remote_addresses = 0;
333 
334 	SCTP_INP_INFO_RLOCK();
335 	if (req->oldptr == USER_ADDR_NULL) {
336 		LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
337 			SCTP_INP_RLOCK(inp);
338 			number_of_endpoints++;
339 			number_of_local_addresses += number_of_addresses(inp);
340 			LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
341 				number_of_associations++;
342 				number_of_local_addresses += number_of_addresses(inp);
343 				TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
344 					number_of_remote_addresses++;
345 				}
346 			}
347 			SCTP_INP_RUNLOCK(inp);
348 		}
349 		SCTP_INP_INFO_RUNLOCK();
350 		n = (number_of_endpoints + 1) * sizeof(struct xsctp_inpcb) +
351 		    (number_of_local_addresses + number_of_endpoints + number_of_associations) * sizeof(struct xsctp_laddr) +
352 		    (number_of_associations + number_of_endpoints) * sizeof(struct xsctp_tcb) +
353 		    (number_of_remote_addresses + number_of_associations) * sizeof(struct xsctp_raddr);
354 
355 		/* request some more memory than needed */
356 		req->oldidx = (n + n / 8);
357 		return 0;
358 	}
359 	if (req->newptr != USER_ADDR_NULL) {
360 		SCTP_INP_INFO_RUNLOCK();
361 		SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_SYSCTL, EPERM);
362 		return EPERM;
363 	}
364 	LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
365 		SCTP_INP_RLOCK(inp);
366 		xinpcb.last = 0;
367 		xinpcb.local_port = ntohs(inp->sctp_lport);
368 		xinpcb.flags = inp->sctp_flags;
369 		xinpcb.features = inp->sctp_features;
370 		xinpcb.total_sends = inp->total_sends;
371 		xinpcb.total_recvs = inp->total_recvs;
372 		xinpcb.total_nospaces = inp->total_nospaces;
373 		xinpcb.fragmentation_point = inp->sctp_frag_point;
374 		if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
375 		    (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) {
376 			xinpcb.qlen = 0;
377 			xinpcb.maxqlen = 0;
378 		} else {
379 			xinpcb.qlen = inp->sctp_socket->so_qlen;
380 			xinpcb.maxqlen = inp->sctp_socket->so_qlimit;
381 		}
382 		SCTP_INP_INCR_REF(inp);
383 		SCTP_INP_RUNLOCK(inp);
384 		SCTP_INP_INFO_RUNLOCK();
385 		error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb));
386 		if (error) {
387 			SCTP_INP_DECR_REF(inp);
388 			return error;
389 		}
390 		SCTP_INP_INFO_RLOCK();
391 		SCTP_INP_RLOCK(inp);
392 		error = copy_out_local_addresses(inp, NULL, req);
393 		if (error) {
394 			SCTP_INP_DECR_REF(inp);
395 			return error;
396 		}
397 		LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
398 			SCTP_TCB_LOCK(stcb);
399 			atomic_add_int(&stcb->asoc.refcnt, 1);
400 			SCTP_TCB_UNLOCK(stcb);
401 			xstcb.last = 0;
402 			xstcb.local_port = ntohs(inp->sctp_lport);
403 			xstcb.remote_port = ntohs(stcb->rport);
404 			if (stcb->asoc.primary_destination != NULL)
405 				xstcb.primary_addr = stcb->asoc.primary_destination->ro._l_addr;
406 			xstcb.heartbeat_interval = stcb->asoc.heart_beat_delay;
407 			xstcb.state = SCTP_GET_STATE(&stcb->asoc);	/* FIXME */
408 			xstcb.in_streams = stcb->asoc.streamincnt;
409 			xstcb.out_streams = stcb->asoc.streamoutcnt;
410 			xstcb.max_nr_retrans = stcb->asoc.overall_error_count;
411 			xstcb.primary_process = 0;	/* not really supported
412 							 * yet */
413 			xstcb.T1_expireries = stcb->asoc.timoinit + stcb->asoc.timocookie;
414 			xstcb.T2_expireries = stcb->asoc.timoshutdown + stcb->asoc.timoshutdownack;
415 			xstcb.retransmitted_tsns = stcb->asoc.marked_retrans;
416 			xstcb.start_time.tv_sec = (uint32_t) stcb->asoc.start_time.tv_sec;
417 			xstcb.start_time.tv_usec = (uint32_t) stcb->asoc.start_time.tv_usec;
418 			xstcb.discontinuity_time.tv_sec = (uint32_t) stcb->asoc.discontinuity_time.tv_sec;
419 			xstcb.discontinuity_time.tv_usec = (uint32_t) stcb->asoc.discontinuity_time.tv_usec;
420 			xstcb.total_sends = stcb->total_sends;
421 			xstcb.total_recvs = stcb->total_recvs;
422 			xstcb.local_tag = stcb->asoc.my_vtag;
423 			xstcb.remote_tag = stcb->asoc.peer_vtag;
424 			xstcb.initial_tsn = stcb->asoc.init_seq_number;
425 			xstcb.highest_tsn = stcb->asoc.sending_seq - 1;
426 			xstcb.cumulative_tsn = stcb->asoc.last_acked_seq;
427 			xstcb.cumulative_tsn_ack = stcb->asoc.cumulative_tsn;
428 			xstcb.mtu = stcb->asoc.smallest_mtu;
429 			xstcb.refcnt = stcb->asoc.refcnt;
430 			SCTP_INP_RUNLOCK(inp);
431 			SCTP_INP_INFO_RUNLOCK();
432 			error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb));
433 			if (error) {
434 				SCTP_INP_DECR_REF(inp);
435 				atomic_subtract_int(&stcb->asoc.refcnt, 1);
436 				return error;
437 			}
438 			SCTP_INP_INFO_RLOCK();
439 			SCTP_INP_RLOCK(inp);
440 			error = copy_out_local_addresses(inp, stcb, req);
441 			if (error) {
442 				SCTP_INP_DECR_REF(inp);
443 				atomic_subtract_int(&stcb->asoc.refcnt, 1);
444 				return error;
445 			}
446 			TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
447 				xraddr.last = 0;
448 				xraddr.address = net->ro._l_addr;
449 				xraddr.active = ((net->dest_state & SCTP_ADDR_REACHABLE) == SCTP_ADDR_REACHABLE);
450 				xraddr.confirmed = ((net->dest_state & SCTP_ADDR_UNCONFIRMED) == 0);
451 				xraddr.heartbeat_enabled = ((net->dest_state & SCTP_ADDR_NOHB) == 0);
452 				xraddr.rto = net->RTO;
453 				xraddr.max_path_rtx = net->failure_threshold;
454 				xraddr.rtx = net->marked_retrans;
455 				xraddr.error_counter = net->error_count;
456 				xraddr.cwnd = net->cwnd;
457 				xraddr.flight_size = net->flight_size;
458 				xraddr.mtu = net->mtu;
459 				xraddr.start_time.tv_sec = (uint32_t) net->start_time.tv_sec;
460 				xraddr.start_time.tv_usec = (uint32_t) net->start_time.tv_usec;
461 				SCTP_INP_RUNLOCK(inp);
462 				SCTP_INP_INFO_RUNLOCK();
463 				error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr));
464 				if (error) {
465 					SCTP_INP_DECR_REF(inp);
466 					atomic_subtract_int(&stcb->asoc.refcnt, 1);
467 					return error;
468 				}
469 				SCTP_INP_INFO_RLOCK();
470 				SCTP_INP_RLOCK(inp);
471 			}
472 			atomic_subtract_int(&stcb->asoc.refcnt, 1);
473 			memset((void *)&xraddr, 0, sizeof(struct xsctp_raddr));
474 			xraddr.last = 1;
475 			SCTP_INP_RUNLOCK(inp);
476 			SCTP_INP_INFO_RUNLOCK();
477 			error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr));
478 			if (error) {
479 				SCTP_INP_DECR_REF(inp);
480 				return error;
481 			}
482 			SCTP_INP_INFO_RLOCK();
483 			SCTP_INP_RLOCK(inp);
484 		}
485 		SCTP_INP_DECR_REF(inp);
486 		SCTP_INP_RUNLOCK(inp);
487 		SCTP_INP_INFO_RUNLOCK();
488 		memset((void *)&xstcb, 0, sizeof(struct xsctp_tcb));
489 		xstcb.last = 1;
490 		error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb));
491 		if (error) {
492 			return error;
493 		}
494 		SCTP_INP_INFO_RLOCK();
495 	}
496 	SCTP_INP_INFO_RUNLOCK();
497 
498 	memset((void *)&xinpcb, 0, sizeof(struct xsctp_inpcb));
499 	xinpcb.last = 1;
500 	error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb));
501 	return error;
502 }
503 
504 
505 
506 #define RANGECHK(var, min, max) \
507 	if ((var) < (min)) { (var) = (min); } \
508 	else if ((var) > (max)) { (var) = (max); }
509 
510 static int
511 sysctl_sctp_udp_tunneling_check(SYSCTL_HANDLER_ARGS)
512 {
513 	int error;
514 	uint32_t old_sctp_udp_tunneling_port;
515 
516 	old_sctp_udp_tunneling_port = SCTP_BASE_SYSCTL(sctp_udp_tunneling_port);
517 	error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
518 	if (error == 0) {
519 		RANGECHK(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port), SCTPCTL_UDP_TUNNELING_PORT_MIN, SCTPCTL_UDP_TUNNELING_PORT_MAX);
520 		if (old_sctp_udp_tunneling_port) {
521 			sctp_over_udp_stop();
522 		}
523 		if (SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)) {
524 			if (sctp_over_udp_start()) {
525 				SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = 0;
526 			}
527 		}
528 	}
529 	return (error);
530 }
531 
532 
533 static int
534 sysctl_sctp_check(SYSCTL_HANDLER_ARGS)
535 {
536 	int error;
537 
538 	error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
539 	if (error == 0) {
540 		RANGECHK(SCTP_BASE_SYSCTL(sctp_sendspace), SCTPCTL_MAXDGRAM_MIN, SCTPCTL_MAXDGRAM_MAX);
541 		RANGECHK(SCTP_BASE_SYSCTL(sctp_recvspace), SCTPCTL_RECVSPACE_MIN, SCTPCTL_RECVSPACE_MAX);
542 #if defined(__FreeBSD__) || defined(SCTP_APPLE_AUTO_ASCONF)
543 		RANGECHK(SCTP_BASE_SYSCTL(sctp_auto_asconf), SCTPCTL_AUTOASCONF_MIN, SCTPCTL_AUTOASCONF_MAX);
544 #endif
545 		RANGECHK(SCTP_BASE_SYSCTL(sctp_ecn_enable), SCTPCTL_ECN_ENABLE_MIN, SCTPCTL_ECN_ENABLE_MAX);
546 		RANGECHK(SCTP_BASE_SYSCTL(sctp_ecn_nonce), SCTPCTL_ECN_NONCE_MIN, SCTPCTL_ECN_NONCE_MAX);
547 		RANGECHK(SCTP_BASE_SYSCTL(sctp_strict_sacks), SCTPCTL_STRICT_SACKS_MIN, SCTPCTL_STRICT_SACKS_MAX);
548 		RANGECHK(SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback), SCTPCTL_LOOPBACK_NOCSUM_MIN, SCTPCTL_LOOPBACK_NOCSUM_MAX);
549 		RANGECHK(SCTP_BASE_SYSCTL(sctp_strict_init), SCTPCTL_STRICT_INIT_MIN, SCTPCTL_STRICT_INIT_MAX);
550 		RANGECHK(SCTP_BASE_SYSCTL(sctp_peer_chunk_oh), SCTPCTL_PEER_CHKOH_MIN, SCTPCTL_PEER_CHKOH_MAX);
551 		RANGECHK(SCTP_BASE_SYSCTL(sctp_max_burst_default), SCTPCTL_MAXBURST_MIN, SCTPCTL_MAXBURST_MAX);
552 		RANGECHK(SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue), SCTPCTL_MAXCHUNKS_MIN, SCTPCTL_MAXCHUNKS_MAX);
553 		RANGECHK(SCTP_BASE_SYSCTL(sctp_hashtblsize), SCTPCTL_TCBHASHSIZE_MIN, SCTPCTL_TCBHASHSIZE_MAX);
554 		RANGECHK(SCTP_BASE_SYSCTL(sctp_pcbtblsize), SCTPCTL_PCBHASHSIZE_MIN, SCTPCTL_PCBHASHSIZE_MAX);
555 		RANGECHK(SCTP_BASE_SYSCTL(sctp_min_split_point), SCTPCTL_MIN_SPLIT_POINT_MIN, SCTPCTL_MIN_SPLIT_POINT_MAX);
556 		RANGECHK(SCTP_BASE_SYSCTL(sctp_chunkscale), SCTPCTL_CHUNKSCALE_MIN, SCTPCTL_CHUNKSCALE_MAX);
557 		RANGECHK(SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default), SCTPCTL_DELAYED_SACK_TIME_MIN, SCTPCTL_DELAYED_SACK_TIME_MAX);
558 		RANGECHK(SCTP_BASE_SYSCTL(sctp_sack_freq_default), SCTPCTL_SACK_FREQ_MIN, SCTPCTL_SACK_FREQ_MAX);
559 		RANGECHK(SCTP_BASE_SYSCTL(sctp_system_free_resc_limit), SCTPCTL_SYS_RESOURCE_MIN, SCTPCTL_SYS_RESOURCE_MAX);
560 		RANGECHK(SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit), SCTPCTL_ASOC_RESOURCE_MIN, SCTPCTL_ASOC_RESOURCE_MAX);
561 		RANGECHK(SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default), SCTPCTL_HEARTBEAT_INTERVAL_MIN, SCTPCTL_HEARTBEAT_INTERVAL_MAX);
562 		RANGECHK(SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default), SCTPCTL_PMTU_RAISE_TIME_MIN, SCTPCTL_PMTU_RAISE_TIME_MAX);
563 		RANGECHK(SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default), SCTPCTL_SHUTDOWN_GUARD_TIME_MIN, SCTPCTL_SHUTDOWN_GUARD_TIME_MAX);
564 		RANGECHK(SCTP_BASE_SYSCTL(sctp_secret_lifetime_default), SCTPCTL_SECRET_LIFETIME_MIN, SCTPCTL_SECRET_LIFETIME_MAX);
565 		RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_max_default), SCTPCTL_RTO_MAX_MIN, SCTPCTL_RTO_MAX_MAX);
566 		RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_min_default), SCTPCTL_RTO_MIN_MIN, SCTPCTL_RTO_MIN_MAX);
567 		RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_initial_default), SCTPCTL_RTO_INITIAL_MIN, SCTPCTL_RTO_INITIAL_MAX);
568 		RANGECHK(SCTP_BASE_SYSCTL(sctp_init_rto_max_default), SCTPCTL_INIT_RTO_MAX_MIN, SCTPCTL_INIT_RTO_MAX_MAX);
569 		RANGECHK(SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default), SCTPCTL_VALID_COOKIE_LIFE_MIN, SCTPCTL_VALID_COOKIE_LIFE_MAX);
570 		RANGECHK(SCTP_BASE_SYSCTL(sctp_init_rtx_max_default), SCTPCTL_INIT_RTX_MAX_MIN, SCTPCTL_INIT_RTX_MAX_MAX);
571 		RANGECHK(SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default), SCTPCTL_ASSOC_RTX_MAX_MIN, SCTPCTL_ASSOC_RTX_MAX_MAX);
572 		RANGECHK(SCTP_BASE_SYSCTL(sctp_path_rtx_max_default), SCTPCTL_PATH_RTX_MAX_MIN, SCTPCTL_PATH_RTX_MAX_MAX);
573 		RANGECHK(SCTP_BASE_SYSCTL(sctp_add_more_threshold), SCTPCTL_ADD_MORE_ON_OUTPUT_MIN, SCTPCTL_ADD_MORE_ON_OUTPUT_MAX);
574 		RANGECHK(SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default), SCTPCTL_OUTGOING_STREAMS_MIN, SCTPCTL_OUTGOING_STREAMS_MAX);
575 		RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_on_off), SCTPCTL_CMT_ON_OFF_MIN, SCTPCTL_CMT_ON_OFF_MAX);
576 		RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_use_dac), SCTPCTL_CMT_USE_DAC_MIN, SCTPCTL_CMT_USE_DAC_MAX);
577 		RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_pf), SCTPCTL_CMT_PF_MIN, SCTPCTL_CMT_PF_MAX);
578 		RANGECHK(SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst), SCTPCTL_CWND_MAXBURST_MIN, SCTPCTL_CWND_MAXBURST_MAX);
579 		RANGECHK(SCTP_BASE_SYSCTL(sctp_early_fr), SCTPCTL_EARLY_FAST_RETRAN_MIN, SCTPCTL_EARLY_FAST_RETRAN_MAX);
580 		RANGECHK(SCTP_BASE_SYSCTL(sctp_early_fr_msec), SCTPCTL_EARLY_FAST_RETRAN_MSEC_MIN, SCTPCTL_EARLY_FAST_RETRAN_MSEC_MAX);
581 		RANGECHK(SCTP_BASE_SYSCTL(sctp_asconf_auth_nochk), SCTPCTL_ASCONF_AUTH_NOCHK_MIN, SCTPCTL_ASCONF_AUTH_NOCHK_MAX);
582 		RANGECHK(SCTP_BASE_SYSCTL(sctp_auth_disable), SCTPCTL_AUTH_DISABLE_MIN, SCTPCTL_AUTH_DISABLE_MAX);
583 		RANGECHK(SCTP_BASE_SYSCTL(sctp_nat_friendly), SCTPCTL_NAT_FRIENDLY_MIN, SCTPCTL_NAT_FRIENDLY_MAX);
584 		RANGECHK(SCTP_BASE_SYSCTL(sctp_L2_abc_variable), SCTPCTL_ABC_L_VAR_MIN, SCTPCTL_ABC_L_VAR_MAX);
585 		RANGECHK(SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count), SCTPCTL_MAX_CHAINED_MBUFS_MIN, SCTPCTL_MAX_CHAINED_MBUFS_MAX);
586 		RANGECHK(SCTP_BASE_SYSCTL(sctp_do_drain), SCTPCTL_DO_SCTP_DRAIN_MIN, SCTPCTL_DO_SCTP_DRAIN_MAX);
587 		RANGECHK(SCTP_BASE_SYSCTL(sctp_hb_maxburst), SCTPCTL_HB_MAX_BURST_MIN, SCTPCTL_HB_MAX_BURST_MAX);
588 		RANGECHK(SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit), SCTPCTL_ABORT_AT_LIMIT_MIN, SCTPCTL_ABORT_AT_LIMIT_MAX);
589 		RANGECHK(SCTP_BASE_SYSCTL(sctp_strict_data_order), SCTPCTL_STRICT_DATA_ORDER_MIN, SCTPCTL_STRICT_DATA_ORDER_MAX);
590 		RANGECHK(SCTP_BASE_SYSCTL(sctp_min_residual), SCTPCTL_MIN_RESIDUAL_MIN, SCTPCTL_MIN_RESIDUAL_MAX);
591 		RANGECHK(SCTP_BASE_SYSCTL(sctp_max_retran_chunk), SCTPCTL_MAX_RETRAN_CHUNK_MIN, SCTPCTL_MAX_RETRAN_CHUNK_MAX);
592 		RANGECHK(SCTP_BASE_SYSCTL(sctp_logging_level), SCTPCTL_LOGGING_LEVEL_MIN, SCTPCTL_LOGGING_LEVEL_MAX);
593 		RANGECHK(SCTP_BASE_SYSCTL(sctp_default_cc_module), SCTPCTL_DEFAULT_CC_MODULE_MIN, SCTPCTL_DEFAULT_CC_MODULE_MAX);
594 		RANGECHK(SCTP_BASE_SYSCTL(sctp_default_frag_interleave), SCTPCTL_DEFAULT_FRAG_INTERLEAVE_MIN, SCTPCTL_DEFAULT_FRAG_INTERLEAVE_MAX);
595 #if defined(__FreeBSD__) || defined(SCTP_APPLE_MOBILITY_BASE)
596 		RANGECHK(SCTP_BASE_SYSCTL(sctp_mobility_base), SCTPCTL_MOBILITY_BASE_MIN, SCTPCTL_MOBILITY_BASE_MAX);
597 #endif
598 #if defined(__FreeBSD__) || defined(SCTP_APPLE_MOBILITY_FASTHANDOFF)
599 		RANGECHK(SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff), SCTPCTL_MOBILITY_FASTHANDOFF_MIN, SCTPCTL_MOBILITY_FASTHANDOFF_MAX);
600 #endif
601 		RANGECHK(SCTP_BASE_SYSCTL(sctp_udp_tunneling_for_client_enable), SCTPCTL_UDP_TUNNELING_FOR_CLIENT_ENABLE_MIN, SCTPCTL_UDP_TUNNELING_FOR_CLIENT_ENABLE_MAX);
602 		RANGECHK(SCTP_BASE_SYSCTL(sctp_enable_sack_immediately), SCTPCTL_SACK_IMMEDIATELY_ENABLE_MIN, SCTPCTL_SACK_IMMEDIATELY_ENABLE_MAX);
603 #ifdef SCTP_DEBUG
604 		RANGECHK(SCTP_BASE_SYSCTL(sctp_debug_on), SCTPCTL_DEBUG_MIN, SCTPCTL_DEBUG_MAX);
605 #endif
606 #if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
607 		RANGECHK(SCTP_BASE_SYSCTL(sctp_output_unlocked), SCTPCTL_OUTPUT_UNLOCKED_MIN, SCTPCTL_OUTPUT_UNLOCKED_MAX);
608 #endif
609 	}
610 	return (error);
611 }
612 
613 
614 
615 #if defined(SCTP_LOCAL_TRACE_BUF)
616 static int
617 sysctl_sctp_cleartrace(SYSCTL_HANDLER_ARGS)
618 {
619 	memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log));
620 	return (0);
621 }
622 
623 #endif
624 
625 
626 
627 /*
628  * sysctl definitions
629  */
630 
631 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, sendspace, CTLTYPE_INT | CTLFLAG_RW,
632     &SCTP_BASE_SYSCTL(sctp_sendspace), 0, sysctl_sctp_check, "IU",
633     SCTPCTL_MAXDGRAM_DESC);
634 
635 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, recvspace, CTLTYPE_INT | CTLFLAG_RW,
636     &SCTP_BASE_SYSCTL(sctp_recvspace), 0, sysctl_sctp_check, "IU",
637     SCTPCTL_RECVSPACE_DESC);
638 
639 #if defined(__FreeBSD__) || defined(SCTP_APPLE_AUTO_ASCONF)
640 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, auto_asconf, CTLTYPE_INT | CTLFLAG_RW,
641     &SCTP_BASE_SYSCTL(sctp_auto_asconf), 0, sysctl_sctp_check, "IU",
642     SCTPCTL_AUTOASCONF_DESC);
643 #endif
644 
645 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, ecn_enable, CTLTYPE_INT | CTLFLAG_RW,
646     &SCTP_BASE_SYSCTL(sctp_ecn_enable), 0, sysctl_sctp_check, "IU",
647     SCTPCTL_ECN_ENABLE_DESC);
648 
649 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, ecn_nonce, CTLTYPE_INT | CTLFLAG_RW,
650     &SCTP_BASE_SYSCTL(sctp_ecn_nonce), 0, sysctl_sctp_check, "IU",
651     SCTPCTL_ECN_NONCE_DESC);
652 
653 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, strict_sacks, CTLTYPE_INT | CTLFLAG_RW,
654     &SCTP_BASE_SYSCTL(sctp_strict_sacks), 0, sysctl_sctp_check, "IU",
655     SCTPCTL_STRICT_SACKS_DESC);
656 
657 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, loopback_nocsum, CTLTYPE_INT | CTLFLAG_RW,
658     &SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback), 0, sysctl_sctp_check, "IU",
659     SCTPCTL_LOOPBACK_NOCSUM_DESC);
660 
661 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, strict_init, CTLTYPE_INT | CTLFLAG_RW,
662     &SCTP_BASE_SYSCTL(sctp_strict_init), 0, sysctl_sctp_check, "IU",
663     SCTPCTL_STRICT_INIT_DESC);
664 
665 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, peer_chkoh, CTLTYPE_INT | CTLFLAG_RW,
666     &SCTP_BASE_SYSCTL(sctp_peer_chunk_oh), 0, sysctl_sctp_check, "IU",
667     SCTPCTL_PEER_CHKOH_DESC);
668 
669 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, maxburst, CTLTYPE_INT | CTLFLAG_RW,
670     &SCTP_BASE_SYSCTL(sctp_max_burst_default), 0, sysctl_sctp_check, "IU",
671     SCTPCTL_MAXBURST_DESC);
672 
673 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, maxchunks, CTLTYPE_INT | CTLFLAG_RW,
674     &SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue), 0, sysctl_sctp_check, "IU",
675     SCTPCTL_MAXCHUNKS_DESC);
676 
677 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, tcbhashsize, CTLTYPE_INT | CTLFLAG_RW,
678     &SCTP_BASE_SYSCTL(sctp_hashtblsize), 0, sysctl_sctp_check, "IU",
679     SCTPCTL_TCBHASHSIZE_DESC);
680 
681 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, pcbhashsize, CTLTYPE_INT | CTLFLAG_RW,
682     &SCTP_BASE_SYSCTL(sctp_pcbtblsize), 0, sysctl_sctp_check, "IU",
683     SCTPCTL_PCBHASHSIZE_DESC);
684 
685 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, min_split_point, CTLTYPE_INT | CTLFLAG_RW,
686     &SCTP_BASE_SYSCTL(sctp_min_split_point), 0, sysctl_sctp_check, "IU",
687     SCTPCTL_MIN_SPLIT_POINT_DESC);
688 
689 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, chunkscale, CTLTYPE_INT | CTLFLAG_RW,
690     &SCTP_BASE_SYSCTL(sctp_chunkscale), 0, sysctl_sctp_check, "IU",
691     SCTPCTL_CHUNKSCALE_DESC);
692 
693 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, delayed_sack_time, CTLTYPE_INT | CTLFLAG_RW,
694     &SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default), 0, sysctl_sctp_check, "IU",
695     SCTPCTL_DELAYED_SACK_TIME_DESC);
696 
697 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, sack_freq, CTLTYPE_INT | CTLFLAG_RW,
698     &SCTP_BASE_SYSCTL(sctp_sack_freq_default), 0, sysctl_sctp_check, "IU",
699     SCTPCTL_SACK_FREQ_DESC);
700 
701 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, sys_resource, CTLTYPE_INT | CTLFLAG_RW,
702     &SCTP_BASE_SYSCTL(sctp_system_free_resc_limit), 0, sysctl_sctp_check, "IU",
703     SCTPCTL_SYS_RESOURCE_DESC);
704 
705 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, asoc_resource, CTLTYPE_INT | CTLFLAG_RW,
706     &SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit), 0, sysctl_sctp_check, "IU",
707     SCTPCTL_ASOC_RESOURCE_DESC);
708 
709 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, heartbeat_interval, CTLTYPE_INT | CTLFLAG_RW,
710     &SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default), 0, sysctl_sctp_check, "IU",
711     SCTPCTL_HEARTBEAT_INTERVAL_DESC);
712 
713 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, pmtu_raise_time, CTLTYPE_INT | CTLFLAG_RW,
714     &SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default), 0, sysctl_sctp_check, "IU",
715     SCTPCTL_PMTU_RAISE_TIME_DESC);
716 
717 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, shutdown_guard_time, CTLTYPE_INT | CTLFLAG_RW,
718     &SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default), 0, sysctl_sctp_check, "IU",
719     SCTPCTL_SHUTDOWN_GUARD_TIME_DESC);
720 
721 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, secret_lifetime, CTLTYPE_INT | CTLFLAG_RW,
722     &SCTP_BASE_SYSCTL(sctp_secret_lifetime_default), 0, sysctl_sctp_check, "IU",
723     SCTPCTL_SECRET_LIFETIME_DESC);
724 
725 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, rto_max, CTLTYPE_INT | CTLFLAG_RW,
726     &SCTP_BASE_SYSCTL(sctp_rto_max_default), 0, sysctl_sctp_check, "IU",
727     SCTPCTL_RTO_MAX_DESC);
728 
729 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, rto_min, CTLTYPE_INT | CTLFLAG_RW,
730     &SCTP_BASE_SYSCTL(sctp_rto_min_default), 0, sysctl_sctp_check, "IU",
731     SCTPCTL_RTO_MIN_DESC);
732 
733 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, rto_initial, CTLTYPE_INT | CTLFLAG_RW,
734     &SCTP_BASE_SYSCTL(sctp_rto_initial_default), 0, sysctl_sctp_check, "IU",
735     SCTPCTL_RTO_INITIAL_DESC);
736 
737 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, init_rto_max, CTLTYPE_INT | CTLFLAG_RW,
738     &SCTP_BASE_SYSCTL(sctp_init_rto_max_default), 0, sysctl_sctp_check, "IU",
739     SCTPCTL_INIT_RTO_MAX_DESC);
740 
741 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, valid_cookie_life, CTLTYPE_INT | CTLFLAG_RW,
742     &SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default), 0, sysctl_sctp_check, "IU",
743     SCTPCTL_VALID_COOKIE_LIFE_DESC);
744 
745 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, init_rtx_max, CTLTYPE_INT | CTLFLAG_RW,
746     &SCTP_BASE_SYSCTL(sctp_init_rtx_max_default), 0, sysctl_sctp_check, "IU",
747     SCTPCTL_INIT_RTX_MAX_DESC);
748 
749 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, assoc_rtx_max, CTLTYPE_INT | CTLFLAG_RW,
750     &SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default), 0, sysctl_sctp_check, "IU",
751     SCTPCTL_ASSOC_RTX_MAX_DESC);
752 
753 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, path_rtx_max, CTLTYPE_INT | CTLFLAG_RW,
754     &SCTP_BASE_SYSCTL(sctp_path_rtx_max_default), 0, sysctl_sctp_check, "IU",
755     SCTPCTL_PATH_RTX_MAX_DESC);
756 
757 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, add_more_on_output, CTLTYPE_INT | CTLFLAG_RW,
758     &SCTP_BASE_SYSCTL(sctp_add_more_threshold), 0, sysctl_sctp_check, "IU",
759     SCTPCTL_ADD_MORE_ON_OUTPUT_DESC);
760 
761 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, outgoing_streams, CTLTYPE_INT | CTLFLAG_RW,
762     &SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default), 0, sysctl_sctp_check, "IU",
763     SCTPCTL_OUTGOING_STREAMS_DESC);
764 
765 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, cmt_on_off, CTLTYPE_INT | CTLFLAG_RW,
766     &SCTP_BASE_SYSCTL(sctp_cmt_on_off), 0, sysctl_sctp_check, "IU",
767     SCTPCTL_CMT_ON_OFF_DESC);
768 
769 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, cmt_use_dac, CTLTYPE_INT | CTLFLAG_RW,
770     &SCTP_BASE_SYSCTL(sctp_cmt_use_dac), 0, sysctl_sctp_check, "IU",
771     SCTPCTL_CMT_USE_DAC_DESC);
772 
773 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, cmt_pf, CTLTYPE_INT | CTLFLAG_RW,
774     &SCTP_BASE_SYSCTL(sctp_cmt_pf), 0, sysctl_sctp_check, "IU",
775     SCTPCTL_CMT_PF_DESC);
776 
777 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, cwnd_maxburst, CTLTYPE_INT | CTLFLAG_RW,
778     &SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst), 0, sysctl_sctp_check, "IU",
779     SCTPCTL_CWND_MAXBURST_DESC);
780 
781 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, early_fast_retran, CTLTYPE_INT | CTLFLAG_RW,
782     &SCTP_BASE_SYSCTL(sctp_early_fr), 0, sysctl_sctp_check, "IU",
783     SCTPCTL_EARLY_FAST_RETRAN_DESC);
784 
785 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, early_fast_retran_msec, CTLTYPE_INT | CTLFLAG_RW,
786     &SCTP_BASE_SYSCTL(sctp_early_fr_msec), 0, sysctl_sctp_check, "IU",
787     SCTPCTL_EARLY_FAST_RETRAN_MSEC_DESC);
788 
789 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, asconf_auth_nochk, CTLTYPE_INT | CTLFLAG_RW,
790     &SCTP_BASE_SYSCTL(sctp_asconf_auth_nochk), 0, sysctl_sctp_check, "IU",
791     SCTPCTL_ASCONF_AUTH_NOCHK_DESC);
792 
793 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, auth_disable, CTLTYPE_INT | CTLFLAG_RW,
794     &SCTP_BASE_SYSCTL(sctp_auth_disable), 0, sysctl_sctp_check, "IU",
795     SCTPCTL_AUTH_DISABLE_DESC);
796 
797 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, nat_friendly, CTLTYPE_INT | CTLFLAG_RW,
798     &SCTP_BASE_SYSCTL(sctp_nat_friendly), 0, sysctl_sctp_check, "IU",
799     SCTPCTL_NAT_FRIENDLY_DESC);
800 
801 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, abc_l_var, CTLTYPE_INT | CTLFLAG_RW,
802     &SCTP_BASE_SYSCTL(sctp_L2_abc_variable), 0, sysctl_sctp_check, "IU",
803     SCTPCTL_ABC_L_VAR_DESC);
804 
805 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, max_chained_mbufs, CTLTYPE_INT | CTLFLAG_RW,
806     &SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count), 0, sysctl_sctp_check, "IU",
807     SCTPCTL_MAX_CHAINED_MBUFS_DESC);
808 
809 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, do_sctp_drain, CTLTYPE_INT | CTLFLAG_RW,
810     &SCTP_BASE_SYSCTL(sctp_do_drain), 0, sysctl_sctp_check, "IU",
811     SCTPCTL_DO_SCTP_DRAIN_DESC);
812 
813 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, hb_max_burst, CTLTYPE_INT | CTLFLAG_RW,
814     &SCTP_BASE_SYSCTL(sctp_hb_maxburst), 0, sysctl_sctp_check, "IU",
815     SCTPCTL_HB_MAX_BURST_DESC);
816 
817 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, abort_at_limit, CTLTYPE_INT | CTLFLAG_RW,
818     &SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit), 0, sysctl_sctp_check, "IU",
819     SCTPCTL_ABORT_AT_LIMIT_DESC);
820 
821 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, strict_data_order, CTLTYPE_INT | CTLFLAG_RW,
822     &SCTP_BASE_SYSCTL(sctp_strict_data_order), 0, sysctl_sctp_check, "IU",
823     SCTPCTL_STRICT_DATA_ORDER_DESC);
824 
825 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, min_residual, CTLTYPE_INT | CTLFLAG_RW,
826     &SCTP_BASE_SYSCTL(sctp_min_residual), 0, sysctl_sctp_check, "IU",
827     SCTPCTL_MIN_RESIDUAL_DESC);
828 
829 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, max_retran_chunk, CTLTYPE_INT | CTLFLAG_RW,
830     &SCTP_BASE_SYSCTL(sctp_max_retran_chunk), 0, sysctl_sctp_check, "IU",
831     SCTPCTL_MAX_RETRAN_CHUNK_DESC);
832 
833 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, log_level, CTLTYPE_INT | CTLFLAG_RW,
834     &SCTP_BASE_SYSCTL(sctp_logging_level), 0, sysctl_sctp_check, "IU",
835     SCTPCTL_LOGGING_LEVEL_DESC);
836 
837 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, default_cc_module, CTLTYPE_INT | CTLFLAG_RW,
838     &SCTP_BASE_SYSCTL(sctp_default_cc_module), 0, sysctl_sctp_check, "IU",
839     SCTPCTL_DEFAULT_CC_MODULE_DESC);
840 
841 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, default_frag_interleave, CTLTYPE_INT | CTLFLAG_RW,
842     &SCTP_BASE_SYSCTL(sctp_default_frag_interleave), 0, sysctl_sctp_check, "IU",
843     SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DESC);
844 
845 #if defined(__FreeBSD__) || defined(SCTP_APPLE_MOBILITY_BASE)
846 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mobility_base, CTLTYPE_INT | CTLFLAG_RW,
847     &SCTP_BASE_SYSCTL(sctp_mobility_base), 0, sysctl_sctp_check, "IU",
848     SCTPCTL_MOBILITY_BASE_DESC);
849 #endif
850 
851 #if defined(__FreeBSD__) || defined(SCTP_APPLE_MOBILITY_FASTHANDOFF)
852 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mobility_fasthandoff, CTLTYPE_INT | CTLFLAG_RW,
853     &SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff), 0, sysctl_sctp_check, "IU",
854     SCTPCTL_MOBILITY_FASTHANDOFF_DESC);
855 #endif
856 
857 #if defined(SCTP_LOCAL_TRACE_BUF)
858 SYSCTL_STRUCT(_net_inet_sctp, OID_AUTO, log, CTLFLAG_RD,
859     &SCTP_BASE_SYSCTL(sctp_log), sctp_log,
860     "SCTP logging (struct sctp_log)");
861 
862 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, clear_trace, CTLTYPE_OPAQUE | CTLFLAG_RW,
863     &SCTP_BASE_SYSCTL(sctp_log), 0, sysctl_sctp_cleartrace, "IU",
864     "Clear SCTP Logging buffer");
865 
866 
867 
868 #endif
869 
870 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, udp_tunneling_for_client_enable, CTLTYPE_INT | CTLFLAG_RW,
871     &SCTP_BASE_SYSCTL(sctp_udp_tunneling_for_client_enable), 0, sysctl_sctp_check, "IU",
872     SCTPCTL_UDP_TUNNELING_FOR_CLIENT_ENABLE_DESC);
873 
874 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, udp_tunneling_port, CTLTYPE_INT | CTLFLAG_RW,
875     &SCTP_BASE_SYSCTL(sctp_udp_tunneling_port), 0, sysctl_sctp_udp_tunneling_check, "IU",
876     SCTPCTL_UDP_TUNNELING_PORT_DESC);
877 
878 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, enable_sack_immediately, CTLTYPE_INT | CTLFLAG_RW,
879     &SCTP_BASE_SYSCTL(sctp_enable_sack_immediately), 0, sysctl_sctp_check, "IU",
880     SCTPCTL_SACK_IMMEDIATELY_ENABLE_DESC);
881 
882 #ifdef SCTP_DEBUG
883 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, debug, CTLTYPE_INT | CTLFLAG_RW,
884     &SCTP_BASE_SYSCTL(sctp_debug_on), 0, sysctl_sctp_check, "IU",
885     SCTPCTL_DEBUG_DESC);
886 #endif				/* SCTP_DEBUG */
887 
888 
889 #if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
890 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, output_unlocked, CTLTYPE_INT | CTLFLAG_RW,
891     &SCTP_BASE_SYSCTL(sctp_output_unlocked), 0, sysctl_sctp_check, "IU",
892     SCTPCTL_OUTPUT_UNLOCKED_DESC);
893 #endif
894 
895 SYSCTL_STRUCT(_net_inet_sctp, OID_AUTO, stats, CTLFLAG_RW,
896     &SCTP_BASE_STATS, sctpstat,
897     "SCTP statistics (struct sctp_stat)");
898 
899 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, assoclist, CTLFLAG_RD,
900     0, 0, sctp_assoclist,
901     "S,xassoc", "List of active SCTP associations");
902