xref: /freebsd/sys/netinet/sctp_sysctl.c (revision ff014514ee369a3d8907e5667c0225f2b316a87e)
142551e99SRandall Stewart /*-
2b1006367SRandall Stewart  * Copyright (c) 2007, by Cisco Systems, Inc. All rights reserved.
342551e99SRandall Stewart  *
442551e99SRandall Stewart  * Redistribution and use in source and binary forms, with or without
542551e99SRandall Stewart  * modification, are permitted provided that the following conditions are met:
642551e99SRandall Stewart  *
742551e99SRandall Stewart  * a) Redistributions of source code must retain the above copyright notice,
842551e99SRandall Stewart  *   this list of conditions and the following disclaimer.
942551e99SRandall Stewart  *
1042551e99SRandall Stewart  * b) Redistributions in binary form must reproduce the above copyright
1142551e99SRandall Stewart  *    notice, this list of conditions and the following disclaimer in
1242551e99SRandall Stewart  *   the documentation and/or other materials provided with the distribution.
1342551e99SRandall Stewart  *
1442551e99SRandall Stewart  * c) Neither the name of Cisco Systems, Inc. nor the names of its
1542551e99SRandall Stewart  *    contributors may be used to endorse or promote products derived
1642551e99SRandall Stewart  *    from this software without specific prior written permission.
1742551e99SRandall Stewart  *
1842551e99SRandall Stewart  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1942551e99SRandall Stewart  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
2042551e99SRandall Stewart  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2142551e99SRandall Stewart  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
2242551e99SRandall Stewart  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2342551e99SRandall Stewart  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2442551e99SRandall Stewart  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2542551e99SRandall Stewart  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2642551e99SRandall Stewart  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2742551e99SRandall Stewart  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
2842551e99SRandall Stewart  * THE POSSIBILITY OF SUCH DAMAGE.
2942551e99SRandall Stewart  */
3042551e99SRandall Stewart 
3142551e99SRandall Stewart #include <sys/cdefs.h>
3242551e99SRandall Stewart __FBSDID("$FreeBSD$");
3342551e99SRandall Stewart 
3442551e99SRandall Stewart #include <netinet/sctp_os.h>
35b3f1ea41SRandall Stewart #include <netinet/sctp.h>
3642551e99SRandall Stewart #include <netinet/sctp_constants.h>
3742551e99SRandall Stewart #include <netinet/sctp_sysctl.h>
3842551e99SRandall Stewart #include <netinet/sctp_pcb.h>
3942551e99SRandall Stewart #include <netinet/sctputil.h>
40d61a0ae0SRandall Stewart #include <netinet/sctp_output.h>
41ff014514SRandall Stewart #include <sys/smp.h>
42b3f1ea41SRandall Stewart 
4342551e99SRandall Stewart /*
4442551e99SRandall Stewart  * sysctl tunable variables
4542551e99SRandall Stewart  */
465e54f665SRandall Stewart 
47b3f1ea41SRandall Stewart void
48b3f1ea41SRandall Stewart sctp_init_sysctls()
49b3f1ea41SRandall Stewart {
50b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_sendspace) = SCTPCTL_MAXDGRAM_DEFAULT;
51b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_recvspace) = SCTPCTL_RECVSPACE_DEFAULT;
52b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_auto_asconf) = SCTPCTL_AUTOASCONF_DEFAULT;
53b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_multiple_asconfs) = SCTPCTL_MULTIPLEASCONFS_DEFAULT;
54b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_ecn_enable) = SCTPCTL_ECN_ENABLE_DEFAULT;
55b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_ecn_nonce) = SCTPCTL_ECN_NONCE_DEFAULT;
56b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_strict_sacks) = SCTPCTL_STRICT_SACKS_DEFAULT;
57b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback) = SCTPCTL_LOOPBACK_NOCSUM_DEFAULT;
58b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_strict_init) = SCTPCTL_STRICT_INIT_DEFAULT;
59b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_peer_chunk_oh) = SCTPCTL_PEER_CHKOH_DEFAULT;
60b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_max_burst_default) = SCTPCTL_MAXBURST_DEFAULT;
61b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue) = SCTPCTL_MAXCHUNKS_DEFAULT;
62b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_hashtblsize) = SCTPCTL_TCBHASHSIZE_DEFAULT;
63b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_pcbtblsize) = SCTPCTL_PCBHASHSIZE_DEFAULT;
64b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_min_split_point) = SCTPCTL_MIN_SPLIT_POINT_DEFAULT;
65b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_chunkscale) = SCTPCTL_CHUNKSCALE_DEFAULT;
66b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default) = SCTPCTL_DELAYED_SACK_TIME_DEFAULT;
67b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_sack_freq_default) = SCTPCTL_SACK_FREQ_DEFAULT;
68b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_system_free_resc_limit) = SCTPCTL_SYS_RESOURCE_DEFAULT;
69b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit) = SCTPCTL_ASOC_RESOURCE_DEFAULT;
70b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default) = SCTPCTL_HEARTBEAT_INTERVAL_DEFAULT;
71b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default) = SCTPCTL_PMTU_RAISE_TIME_DEFAULT;
72b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default) = SCTPCTL_SHUTDOWN_GUARD_TIME_DEFAULT;
73b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_secret_lifetime_default) = SCTPCTL_SECRET_LIFETIME_DEFAULT;
74b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_rto_max_default) = SCTPCTL_RTO_MAX_DEFAULT;
75b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_rto_min_default) = SCTPCTL_RTO_MIN_DEFAULT;
76b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_rto_initial_default) = SCTPCTL_RTO_INITIAL_DEFAULT;
77b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_init_rto_max_default) = SCTPCTL_INIT_RTO_MAX_DEFAULT;
78b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default) = SCTPCTL_VALID_COOKIE_LIFE_DEFAULT;
79b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_init_rtx_max_default) = SCTPCTL_INIT_RTX_MAX_DEFAULT;
80b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default) = SCTPCTL_ASSOC_RTX_MAX_DEFAULT;
81b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_path_rtx_max_default) = SCTPCTL_PATH_RTX_MAX_DEFAULT;
82b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_add_more_threshold) = SCTPCTL_ADD_MORE_ON_OUTPUT_DEFAULT;
83b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default) = SCTPCTL_OUTGOING_STREAMS_DEFAULT;
84b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_cmt_on_off) = SCTPCTL_CMT_ON_OFF_DEFAULT;
85830d754dSRandall Stewart 	/* EY */
86830d754dSRandall Stewart 	SCTP_BASE_SYSCTL(sctp_nr_sack_on_off) = SCTPCTL_NR_SACK_ON_OFF_DEFAULT;
87b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_cmt_use_dac) = SCTPCTL_CMT_USE_DAC_DEFAULT;
88b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_cmt_pf) = SCTPCTL_CMT_PF_DEFAULT;
89b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst) = SCTPCTL_CWND_MAXBURST_DEFAULT;
90b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_early_fr) = SCTPCTL_EARLY_FAST_RETRAN_DEFAULT;
91b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_early_fr_msec) = SCTPCTL_EARLY_FAST_RETRAN_MSEC_DEFAULT;
92b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_asconf_auth_nochk) = SCTPCTL_ASCONF_AUTH_NOCHK_DEFAULT;
93b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_auth_disable) = SCTPCTL_AUTH_DISABLE_DEFAULT;
94b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_nat_friendly) = SCTPCTL_NAT_FRIENDLY_DEFAULT;
95b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_L2_abc_variable) = SCTPCTL_ABC_L_VAR_DEFAULT;
96b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count) = SCTPCTL_MAX_CHAINED_MBUFS_DEFAULT;
97b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_do_drain) = SCTPCTL_DO_SCTP_DRAIN_DEFAULT;
98b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_hb_maxburst) = SCTPCTL_HB_MAX_BURST_DEFAULT;
99b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit) = SCTPCTL_ABORT_AT_LIMIT_DEFAULT;
100b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_strict_data_order) = SCTPCTL_STRICT_DATA_ORDER_DEFAULT;
101b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_min_residual) = SCTPCTL_MIN_RESIDUAL_DEFAULT;
102b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_max_retran_chunk) = SCTPCTL_MAX_RETRAN_CHUNK_DEFAULT;
103b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_logging_level) = SCTPCTL_LOGGING_LEVEL_DEFAULT;
104b54d3a6cSRandall Stewart 	/* JRS - Variable for default congestion control module */
105b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_default_cc_module) = SCTPCTL_DEFAULT_CC_MODULE_DEFAULT;
106b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_default_frag_interleave) = SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DEFAULT;
107b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_mobility_base) = SCTPCTL_MOBILITY_BASE_DEFAULT;
108b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff) = SCTPCTL_MOBILITY_FASTHANDOFF_DEFAULT;
109a16ccdceSRandall Stewart 	SCTP_BASE_SYSCTL(sctp_vtag_time_wait) = SCTPCTL_TIME_WAIT_DEFAULT;
110b27a6b7dSRandall Stewart #if defined(SCTP_LOCAL_TRACE_BUF)
111b3f1ea41SRandall Stewart 	memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log));
112b27a6b7dSRandall Stewart #endif
113b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_udp_tunneling_for_client_enable) = SCTPCTL_UDP_TUNNELING_FOR_CLIENT_ENABLE_DEFAULT;
114b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = SCTPCTL_UDP_TUNNELING_PORT_DEFAULT;
115b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_enable_sack_immediately) = SCTPCTL_SACK_IMMEDIATELY_ENABLE_DEFAULT;
116bf3d5177SMichael Tuexen 	SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly) = SCTPCTL_NAT_FRIENDLY_INITS_DEFAULT;
117b3f1ea41SRandall Stewart #if defined(SCTP_DEBUG)
118b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_debug_on) = SCTPCTL_DEBUG_DEFAULT;
11942551e99SRandall Stewart #endif
120b3f1ea41SRandall Stewart #if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
121b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_output_unlocked) = SCTPCTL_OUTPUT_UNLOCKED_DEFAULT;
122b3f1ea41SRandall Stewart #endif
123b3f1ea41SRandall Stewart }
124d61a0ae0SRandall Stewart 
125a99b6783SRandall Stewart 
126d61a0ae0SRandall Stewart /* It returns an upper limit. No filtering is done here */
127d61a0ae0SRandall Stewart static unsigned int
128d61a0ae0SRandall Stewart number_of_addresses(struct sctp_inpcb *inp)
129d61a0ae0SRandall Stewart {
130d61a0ae0SRandall Stewart 	int cnt;
131d61a0ae0SRandall Stewart 	struct sctp_vrf *vrf;
132d61a0ae0SRandall Stewart 	struct sctp_ifn *sctp_ifn;
133d61a0ae0SRandall Stewart 	struct sctp_ifa *sctp_ifa;
134d61a0ae0SRandall Stewart 	struct sctp_laddr *laddr;
135d61a0ae0SRandall Stewart 
136d61a0ae0SRandall Stewart 	cnt = 0;
137d61a0ae0SRandall Stewart 	/* neither Mac OS X nor FreeBSD support mulitple routing functions */
138d61a0ae0SRandall Stewart 	if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) {
139d61a0ae0SRandall Stewart 		return (0);
140d61a0ae0SRandall Stewart 	}
141d61a0ae0SRandall Stewart 	if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
142d61a0ae0SRandall Stewart 		LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
143d61a0ae0SRandall Stewart 			LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
144d61a0ae0SRandall Stewart 				if ((sctp_ifa->address.sa.sa_family == AF_INET) ||
145d61a0ae0SRandall Stewart 				    (sctp_ifa->address.sa.sa_family == AF_INET6)) {
146d61a0ae0SRandall Stewart 					cnt++;
147d61a0ae0SRandall Stewart 				}
148d61a0ae0SRandall Stewart 			}
149d61a0ae0SRandall Stewart 		}
150d61a0ae0SRandall Stewart 	} else {
151d61a0ae0SRandall Stewart 		LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
152d61a0ae0SRandall Stewart 			if ((laddr->ifa->address.sa.sa_family == AF_INET) ||
153d61a0ae0SRandall Stewart 			    (laddr->ifa->address.sa.sa_family == AF_INET6)) {
154d61a0ae0SRandall Stewart 				cnt++;
155d61a0ae0SRandall Stewart 			}
156d61a0ae0SRandall Stewart 		}
157d61a0ae0SRandall Stewart 	}
158d61a0ae0SRandall Stewart 	return (cnt);
159d61a0ae0SRandall Stewart }
160d61a0ae0SRandall Stewart 
161d61a0ae0SRandall Stewart static int
162d61a0ae0SRandall Stewart copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sysctl_req *req)
163d61a0ae0SRandall Stewart {
164d61a0ae0SRandall Stewart 	struct sctp_ifn *sctp_ifn;
165d61a0ae0SRandall Stewart 	struct sctp_ifa *sctp_ifa;
166d61a0ae0SRandall Stewart 	int loopback_scope, ipv4_local_scope, local_scope, site_scope;
167d61a0ae0SRandall Stewart 	int ipv4_addr_legal, ipv6_addr_legal;
168d61a0ae0SRandall Stewart 	struct sctp_vrf *vrf;
169d61a0ae0SRandall Stewart 	struct xsctp_laddr xladdr;
170d61a0ae0SRandall Stewart 	struct sctp_laddr *laddr;
171d61a0ae0SRandall Stewart 	int error;
172d61a0ae0SRandall Stewart 
173d61a0ae0SRandall Stewart 	/* Turn on all the appropriate scope */
174d61a0ae0SRandall Stewart 	if (stcb) {
175d61a0ae0SRandall Stewart 		/* use association specific values */
176d61a0ae0SRandall Stewart 		loopback_scope = stcb->asoc.loopback_scope;
177d61a0ae0SRandall Stewart 		ipv4_local_scope = stcb->asoc.ipv4_local_scope;
178d61a0ae0SRandall Stewart 		local_scope = stcb->asoc.local_scope;
179d61a0ae0SRandall Stewart 		site_scope = stcb->asoc.site_scope;
180d61a0ae0SRandall Stewart 	} else {
181d61a0ae0SRandall Stewart 		/* use generic values for endpoints */
182d61a0ae0SRandall Stewart 		loopback_scope = 1;
183d61a0ae0SRandall Stewart 		ipv4_local_scope = 1;
184d61a0ae0SRandall Stewart 		local_scope = 1;
185d61a0ae0SRandall Stewart 		site_scope = 1;
186d61a0ae0SRandall Stewart 	}
187d61a0ae0SRandall Stewart 
188d61a0ae0SRandall Stewart 	/* use only address families of interest */
189d61a0ae0SRandall Stewart 	if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) {
190d61a0ae0SRandall Stewart 		ipv6_addr_legal = 1;
191d61a0ae0SRandall Stewart 		if (SCTP_IPV6_V6ONLY(inp)) {
192d61a0ae0SRandall Stewart 			ipv4_addr_legal = 0;
193d61a0ae0SRandall Stewart 		} else {
194d61a0ae0SRandall Stewart 			ipv4_addr_legal = 1;
195d61a0ae0SRandall Stewart 		}
196d61a0ae0SRandall Stewart 	} else {
197d61a0ae0SRandall Stewart 		ipv4_addr_legal = 1;
198d61a0ae0SRandall Stewart 		ipv6_addr_legal = 0;
199d61a0ae0SRandall Stewart 	}
200d61a0ae0SRandall Stewart 
201d61a0ae0SRandall Stewart 	error = 0;
202d61a0ae0SRandall Stewart 
203d61a0ae0SRandall Stewart 	/* neither Mac OS X nor FreeBSD support mulitple routing functions */
204d61a0ae0SRandall Stewart 	if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) {
2055f26a41dSRandall Stewart 		SCTP_INP_RUNLOCK(inp);
2065f26a41dSRandall Stewart 		SCTP_INP_INFO_RUNLOCK();
207d61a0ae0SRandall Stewart 		return (-1);
208d61a0ae0SRandall Stewart 	}
209d61a0ae0SRandall Stewart 	if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
210d61a0ae0SRandall Stewart 		LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
211d61a0ae0SRandall Stewart 			if ((loopback_scope == 0) && SCTP_IFN_IS_IFT_LOOP(sctp_ifn))
212d61a0ae0SRandall Stewart 				/* Skip loopback if loopback_scope not set */
213d61a0ae0SRandall Stewart 				continue;
214d61a0ae0SRandall Stewart 			LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
215d61a0ae0SRandall Stewart 				if (stcb) {
216d61a0ae0SRandall Stewart 					/*
217d61a0ae0SRandall Stewart 					 * ignore if blacklisted at
218d61a0ae0SRandall Stewart 					 * association level
219d61a0ae0SRandall Stewart 					 */
220d61a0ae0SRandall Stewart 					if (sctp_is_addr_restricted(stcb, sctp_ifa))
221d61a0ae0SRandall Stewart 						continue;
222d61a0ae0SRandall Stewart 				}
2235e2c2d87SRandall Stewart 				switch (sctp_ifa->address.sa.sa_family) {
2245e2c2d87SRandall Stewart 				case AF_INET:
2255e2c2d87SRandall Stewart 					if (ipv4_addr_legal) {
226d61a0ae0SRandall Stewart 						struct sockaddr_in *sin;
227d61a0ae0SRandall Stewart 
228d61a0ae0SRandall Stewart 						sin = (struct sockaddr_in *)&sctp_ifa->address.sa;
229d61a0ae0SRandall Stewart 						if (sin->sin_addr.s_addr == 0)
230d61a0ae0SRandall Stewart 							continue;
231d61a0ae0SRandall Stewart 						if ((ipv4_local_scope == 0) && (IN4_ISPRIVATE_ADDRESS(&sin->sin_addr)))
232d61a0ae0SRandall Stewart 							continue;
2335e2c2d87SRandall Stewart 					} else {
2345e2c2d87SRandall Stewart 						continue;
2355e2c2d87SRandall Stewart 					}
2365e2c2d87SRandall Stewart 					break;
2375e2c2d87SRandall Stewart #ifdef INET6
2385e2c2d87SRandall Stewart 				case AF_INET6:
2395e2c2d87SRandall Stewart 					if (ipv6_addr_legal) {
240d61a0ae0SRandall Stewart 						struct sockaddr_in6 *sin6;
241d61a0ae0SRandall Stewart 
242d61a0ae0SRandall Stewart 						sin6 = (struct sockaddr_in6 *)&sctp_ifa->address.sa;
243d61a0ae0SRandall Stewart 						if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr))
244d61a0ae0SRandall Stewart 							continue;
245d61a0ae0SRandall Stewart 						if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
246d61a0ae0SRandall Stewart 							if (local_scope == 0)
247d61a0ae0SRandall Stewart 								continue;
248d61a0ae0SRandall Stewart 							if (sin6->sin6_scope_id == 0) {
249d61a0ae0SRandall Stewart 								/*
2505e2c2d87SRandall Stewart 								 * bad link
2515e2c2d87SRandall Stewart 								 * local
252d61a0ae0SRandall Stewart 								 * address
253d61a0ae0SRandall Stewart 								 */
254d61a0ae0SRandall Stewart 								if (sa6_recoverscope(sin6) != 0)
255d61a0ae0SRandall Stewart 									continue;
256d61a0ae0SRandall Stewart 							}
257d61a0ae0SRandall Stewart 						}
258d61a0ae0SRandall Stewart 						if ((site_scope == 0) && (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)))
259d61a0ae0SRandall Stewart 							continue;
2605e2c2d87SRandall Stewart 					} else {
261d61a0ae0SRandall Stewart 						continue;
2625e2c2d87SRandall Stewart 					}
2635e2c2d87SRandall Stewart 					break;
2645e2c2d87SRandall Stewart #endif
2655e2c2d87SRandall Stewart 				default:
2665e2c2d87SRandall Stewart 					continue;
2675e2c2d87SRandall Stewart 				}
268851b7298SRandall Stewart 				memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
269d61a0ae0SRandall Stewart 				memcpy((void *)&xladdr.address, (const void *)&sctp_ifa->address, sizeof(union sctp_sockstore));
270d61a0ae0SRandall Stewart 				SCTP_INP_RUNLOCK(inp);
271d61a0ae0SRandall Stewart 				SCTP_INP_INFO_RUNLOCK();
272d61a0ae0SRandall Stewart 				error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
273851b7298SRandall Stewart 				if (error) {
274d61a0ae0SRandall Stewart 					return (error);
275851b7298SRandall Stewart 				} else {
276d61a0ae0SRandall Stewart 					SCTP_INP_INFO_RLOCK();
277d61a0ae0SRandall Stewart 					SCTP_INP_RLOCK(inp);
278d61a0ae0SRandall Stewart 				}
279d61a0ae0SRandall Stewart 			}
280d61a0ae0SRandall Stewart 		}
281d61a0ae0SRandall Stewart 	} else {
282d61a0ae0SRandall Stewart 		LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
283d61a0ae0SRandall Stewart 			/* ignore if blacklisted at association level */
284d61a0ae0SRandall Stewart 			if (stcb && sctp_is_addr_restricted(stcb, laddr->ifa))
285d61a0ae0SRandall Stewart 				continue;
286851b7298SRandall Stewart 			memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
287d61a0ae0SRandall Stewart 			memcpy((void *)&xladdr.address, (const void *)&laddr->ifa->address, sizeof(union sctp_sockstore));
288851b7298SRandall Stewart 			xladdr.start_time.tv_sec = (uint32_t) laddr->start_time.tv_sec;
289851b7298SRandall Stewart 			xladdr.start_time.tv_usec = (uint32_t) laddr->start_time.tv_usec;
290d61a0ae0SRandall Stewart 			SCTP_INP_RUNLOCK(inp);
291d61a0ae0SRandall Stewart 			SCTP_INP_INFO_RUNLOCK();
292d61a0ae0SRandall Stewart 			error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
293851b7298SRandall Stewart 			if (error) {
294d61a0ae0SRandall Stewart 				return (error);
295851b7298SRandall Stewart 			} else {
296d61a0ae0SRandall Stewart 				SCTP_INP_INFO_RLOCK();
297d61a0ae0SRandall Stewart 				SCTP_INP_RLOCK(inp);
298d61a0ae0SRandall Stewart 			}
299d61a0ae0SRandall Stewart 		}
300d61a0ae0SRandall Stewart 	}
301851b7298SRandall Stewart 	memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
302d61a0ae0SRandall Stewart 	xladdr.last = 1;
3035f26a41dSRandall Stewart 	SCTP_INP_RUNLOCK(inp);
3045f26a41dSRandall Stewart 	SCTP_INP_INFO_RUNLOCK();
305d61a0ae0SRandall Stewart 	error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
3065f26a41dSRandall Stewart 
307851b7298SRandall Stewart 	if (error) {
308d61a0ae0SRandall Stewart 		return (error);
309851b7298SRandall Stewart 	} else {
3105f26a41dSRandall Stewart 		SCTP_INP_INFO_RLOCK();
3115f26a41dSRandall Stewart 		SCTP_INP_RLOCK(inp);
312d61a0ae0SRandall Stewart 		return (0);
313d61a0ae0SRandall Stewart 	}
3145f26a41dSRandall Stewart }
315d61a0ae0SRandall Stewart 
31642551e99SRandall Stewart /*
31742551e99SRandall Stewart  * sysctl functions
31842551e99SRandall Stewart  */
31942551e99SRandall Stewart static int
32042551e99SRandall Stewart sctp_assoclist(SYSCTL_HANDLER_ARGS)
32142551e99SRandall Stewart {
32242551e99SRandall Stewart 	unsigned int number_of_endpoints;
32342551e99SRandall Stewart 	unsigned int number_of_local_addresses;
32442551e99SRandall Stewart 	unsigned int number_of_associations;
32542551e99SRandall Stewart 	unsigned int number_of_remote_addresses;
32642551e99SRandall Stewart 	unsigned int n;
32742551e99SRandall Stewart 	int error;
32842551e99SRandall Stewart 	struct sctp_inpcb *inp;
32942551e99SRandall Stewart 	struct sctp_tcb *stcb;
33042551e99SRandall Stewart 	struct sctp_nets *net;
33142551e99SRandall Stewart 	struct xsctp_inpcb xinpcb;
33242551e99SRandall Stewart 	struct xsctp_tcb xstcb;
33342551e99SRandall Stewart 	struct xsctp_raddr xraddr;
33442551e99SRandall Stewart 
33542551e99SRandall Stewart 	number_of_endpoints = 0;
33642551e99SRandall Stewart 	number_of_local_addresses = 0;
33742551e99SRandall Stewart 	number_of_associations = 0;
33842551e99SRandall Stewart 	number_of_remote_addresses = 0;
33942551e99SRandall Stewart 
34042551e99SRandall Stewart 	SCTP_INP_INFO_RLOCK();
34142551e99SRandall Stewart 	if (req->oldptr == USER_ADDR_NULL) {
342b3f1ea41SRandall Stewart 		LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
34342551e99SRandall Stewart 			SCTP_INP_RLOCK(inp);
34442551e99SRandall Stewart 			number_of_endpoints++;
345d61a0ae0SRandall Stewart 			number_of_local_addresses += number_of_addresses(inp);
34642551e99SRandall Stewart 			LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
34742551e99SRandall Stewart 				number_of_associations++;
348d61a0ae0SRandall Stewart 				number_of_local_addresses += number_of_addresses(inp);
34942551e99SRandall Stewart 				TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
35042551e99SRandall Stewart 					number_of_remote_addresses++;
35142551e99SRandall Stewart 				}
35242551e99SRandall Stewart 			}
35342551e99SRandall Stewart 			SCTP_INP_RUNLOCK(inp);
35442551e99SRandall Stewart 		}
35542551e99SRandall Stewart 		SCTP_INP_INFO_RUNLOCK();
35642551e99SRandall Stewart 		n = (number_of_endpoints + 1) * sizeof(struct xsctp_inpcb) +
357d61a0ae0SRandall Stewart 		    (number_of_local_addresses + number_of_endpoints + number_of_associations) * sizeof(struct xsctp_laddr) +
358d61a0ae0SRandall Stewart 		    (number_of_associations + number_of_endpoints) * sizeof(struct xsctp_tcb) +
359d61a0ae0SRandall Stewart 		    (number_of_remote_addresses + number_of_associations) * sizeof(struct xsctp_raddr);
360d61a0ae0SRandall Stewart 
36142551e99SRandall Stewart 		/* request some more memory than needed */
36242551e99SRandall Stewart 		req->oldidx = (n + n / 8);
36342551e99SRandall Stewart 		return 0;
36442551e99SRandall Stewart 	}
36542551e99SRandall Stewart 	if (req->newptr != USER_ADDR_NULL) {
36642551e99SRandall Stewart 		SCTP_INP_INFO_RUNLOCK();
367c4739e2fSRandall Stewart 		SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_SYSCTL, EPERM);
36842551e99SRandall Stewart 		return EPERM;
36942551e99SRandall Stewart 	}
370b3f1ea41SRandall Stewart 	LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
37142551e99SRandall Stewart 		SCTP_INP_RLOCK(inp);
37242551e99SRandall Stewart 		xinpcb.last = 0;
37342551e99SRandall Stewart 		xinpcb.local_port = ntohs(inp->sctp_lport);
37442551e99SRandall Stewart 		xinpcb.flags = inp->sctp_flags;
37542551e99SRandall Stewart 		xinpcb.features = inp->sctp_features;
37642551e99SRandall Stewart 		xinpcb.total_sends = inp->total_sends;
37742551e99SRandall Stewart 		xinpcb.total_recvs = inp->total_recvs;
37842551e99SRandall Stewart 		xinpcb.total_nospaces = inp->total_nospaces;
37917205eccSRandall Stewart 		xinpcb.fragmentation_point = inp->sctp_frag_point;
380851b7298SRandall Stewart 		if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
381851b7298SRandall Stewart 		    (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) {
382851b7298SRandall Stewart 			xinpcb.qlen = 0;
383851b7298SRandall Stewart 			xinpcb.maxqlen = 0;
384851b7298SRandall Stewart 		} else {
385d61a0ae0SRandall Stewart 			xinpcb.qlen = inp->sctp_socket->so_qlen;
386d61a0ae0SRandall Stewart 			xinpcb.maxqlen = inp->sctp_socket->so_qlimit;
387851b7298SRandall Stewart 		}
38842551e99SRandall Stewart 		SCTP_INP_INCR_REF(inp);
38942551e99SRandall Stewart 		SCTP_INP_RUNLOCK(inp);
39042551e99SRandall Stewart 		SCTP_INP_INFO_RUNLOCK();
39142551e99SRandall Stewart 		error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb));
39242551e99SRandall Stewart 		if (error) {
393d61a0ae0SRandall Stewart 			SCTP_INP_DECR_REF(inp);
39442551e99SRandall Stewart 			return error;
39542551e99SRandall Stewart 		}
39642551e99SRandall Stewart 		SCTP_INP_INFO_RLOCK();
39742551e99SRandall Stewart 		SCTP_INP_RLOCK(inp);
398d61a0ae0SRandall Stewart 		error = copy_out_local_addresses(inp, NULL, req);
399d61a0ae0SRandall Stewart 		if (error) {
400d61a0ae0SRandall Stewart 			SCTP_INP_DECR_REF(inp);
401d61a0ae0SRandall Stewart 			return error;
402d61a0ae0SRandall Stewart 		}
40342551e99SRandall Stewart 		LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
40442551e99SRandall Stewart 			SCTP_TCB_LOCK(stcb);
40542551e99SRandall Stewart 			atomic_add_int(&stcb->asoc.refcnt, 1);
40642551e99SRandall Stewart 			SCTP_TCB_UNLOCK(stcb);
407d61a0ae0SRandall Stewart 			xstcb.last = 0;
408d61a0ae0SRandall Stewart 			xstcb.local_port = ntohs(inp->sctp_lport);
409d61a0ae0SRandall Stewart 			xstcb.remote_port = ntohs(stcb->rport);
41042551e99SRandall Stewart 			if (stcb->asoc.primary_destination != NULL)
411d61a0ae0SRandall Stewart 				xstcb.primary_addr = stcb->asoc.primary_destination->ro._l_addr;
412d61a0ae0SRandall Stewart 			xstcb.heartbeat_interval = stcb->asoc.heart_beat_delay;
413d61a0ae0SRandall Stewart 			xstcb.state = SCTP_GET_STATE(&stcb->asoc);	/* FIXME */
4144f6b4933SRandall Stewart 			/* 7.0 does not support these */
415a99b6783SRandall Stewart 			xstcb.assoc_id = sctp_get_associd(stcb);
4164f6b4933SRandall Stewart 			xstcb.peers_rwnd = stcb->asoc.peers_rwnd;
417d61a0ae0SRandall Stewart 			xstcb.in_streams = stcb->asoc.streamincnt;
418d61a0ae0SRandall Stewart 			xstcb.out_streams = stcb->asoc.streamoutcnt;
419d61a0ae0SRandall Stewart 			xstcb.max_nr_retrans = stcb->asoc.overall_error_count;
420d61a0ae0SRandall Stewart 			xstcb.primary_process = 0;	/* not really supported
421d61a0ae0SRandall Stewart 							 * yet */
422d61a0ae0SRandall Stewart 			xstcb.T1_expireries = stcb->asoc.timoinit + stcb->asoc.timocookie;
423d61a0ae0SRandall Stewart 			xstcb.T2_expireries = stcb->asoc.timoshutdown + stcb->asoc.timoshutdownack;
424d61a0ae0SRandall Stewart 			xstcb.retransmitted_tsns = stcb->asoc.marked_retrans;
425851b7298SRandall Stewart 			xstcb.start_time.tv_sec = (uint32_t) stcb->asoc.start_time.tv_sec;
426851b7298SRandall Stewart 			xstcb.start_time.tv_usec = (uint32_t) stcb->asoc.start_time.tv_usec;
427851b7298SRandall Stewart 			xstcb.discontinuity_time.tv_sec = (uint32_t) stcb->asoc.discontinuity_time.tv_sec;
428851b7298SRandall Stewart 			xstcb.discontinuity_time.tv_usec = (uint32_t) stcb->asoc.discontinuity_time.tv_usec;
42942551e99SRandall Stewart 			xstcb.total_sends = stcb->total_sends;
43042551e99SRandall Stewart 			xstcb.total_recvs = stcb->total_recvs;
43142551e99SRandall Stewart 			xstcb.local_tag = stcb->asoc.my_vtag;
43242551e99SRandall Stewart 			xstcb.remote_tag = stcb->asoc.peer_vtag;
43342551e99SRandall Stewart 			xstcb.initial_tsn = stcb->asoc.init_seq_number;
43442551e99SRandall Stewart 			xstcb.highest_tsn = stcb->asoc.sending_seq - 1;
43542551e99SRandall Stewart 			xstcb.cumulative_tsn = stcb->asoc.last_acked_seq;
43642551e99SRandall Stewart 			xstcb.cumulative_tsn_ack = stcb->asoc.cumulative_tsn;
43717205eccSRandall Stewart 			xstcb.mtu = stcb->asoc.smallest_mtu;
438207304d4SRandall Stewart 			xstcb.refcnt = stcb->asoc.refcnt;
43942551e99SRandall Stewart 			SCTP_INP_RUNLOCK(inp);
44042551e99SRandall Stewart 			SCTP_INP_INFO_RUNLOCK();
44142551e99SRandall Stewart 			error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb));
44242551e99SRandall Stewart 			if (error) {
443d61a0ae0SRandall Stewart 				SCTP_INP_DECR_REF(inp);
444851b7298SRandall Stewart 				atomic_subtract_int(&stcb->asoc.refcnt, 1);
445d61a0ae0SRandall Stewart 				return error;
446d61a0ae0SRandall Stewart 			}
447d61a0ae0SRandall Stewart 			SCTP_INP_INFO_RLOCK();
448d61a0ae0SRandall Stewart 			SCTP_INP_RLOCK(inp);
449d61a0ae0SRandall Stewart 			error = copy_out_local_addresses(inp, stcb, req);
450d61a0ae0SRandall Stewart 			if (error) {
451d61a0ae0SRandall Stewart 				SCTP_INP_DECR_REF(inp);
452851b7298SRandall Stewart 				atomic_subtract_int(&stcb->asoc.refcnt, 1);
45342551e99SRandall Stewart 				return error;
45442551e99SRandall Stewart 			}
45542551e99SRandall Stewart 			TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
456d61a0ae0SRandall Stewart 				xraddr.last = 0;
457d61a0ae0SRandall Stewart 				xraddr.address = net->ro._l_addr;
458d61a0ae0SRandall Stewart 				xraddr.active = ((net->dest_state & SCTP_ADDR_REACHABLE) == SCTP_ADDR_REACHABLE);
459d61a0ae0SRandall Stewart 				xraddr.confirmed = ((net->dest_state & SCTP_ADDR_UNCONFIRMED) == 0);
460d61a0ae0SRandall Stewart 				xraddr.heartbeat_enabled = ((net->dest_state & SCTP_ADDR_NOHB) == 0);
461d61a0ae0SRandall Stewart 				xraddr.rto = net->RTO;
462d61a0ae0SRandall Stewart 				xraddr.max_path_rtx = net->failure_threshold;
463d61a0ae0SRandall Stewart 				xraddr.rtx = net->marked_retrans;
464d61a0ae0SRandall Stewart 				xraddr.error_counter = net->error_count;
465d61a0ae0SRandall Stewart 				xraddr.cwnd = net->cwnd;
466d61a0ae0SRandall Stewart 				xraddr.flight_size = net->flight_size;
467d61a0ae0SRandall Stewart 				xraddr.mtu = net->mtu;
468e29d4aa6SRandall Stewart 				xraddr.rtt = net->rtt;
469851b7298SRandall Stewart 				xraddr.start_time.tv_sec = (uint32_t) net->start_time.tv_sec;
470851b7298SRandall Stewart 				xraddr.start_time.tv_usec = (uint32_t) net->start_time.tv_usec;
471d61a0ae0SRandall Stewart 				SCTP_INP_RUNLOCK(inp);
472d61a0ae0SRandall Stewart 				SCTP_INP_INFO_RUNLOCK();
47342551e99SRandall Stewart 				error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr));
47442551e99SRandall Stewart 				if (error) {
475d61a0ae0SRandall Stewart 					SCTP_INP_DECR_REF(inp);
476851b7298SRandall Stewart 					atomic_subtract_int(&stcb->asoc.refcnt, 1);
47742551e99SRandall Stewart 					return error;
47842551e99SRandall Stewart 				}
47942551e99SRandall Stewart 				SCTP_INP_INFO_RLOCK();
48042551e99SRandall Stewart 				SCTP_INP_RLOCK(inp);
48142551e99SRandall Stewart 			}
482851b7298SRandall Stewart 			atomic_subtract_int(&stcb->asoc.refcnt, 1);
483d61a0ae0SRandall Stewart 			memset((void *)&xraddr, 0, sizeof(struct xsctp_raddr));
484d61a0ae0SRandall Stewart 			xraddr.last = 1;
48542551e99SRandall Stewart 			SCTP_INP_RUNLOCK(inp);
486d61a0ae0SRandall Stewart 			SCTP_INP_INFO_RUNLOCK();
487d61a0ae0SRandall Stewart 			error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr));
488d61a0ae0SRandall Stewart 			if (error) {
489d61a0ae0SRandall Stewart 				SCTP_INP_DECR_REF(inp);
490d61a0ae0SRandall Stewart 				return error;
491d61a0ae0SRandall Stewart 			}
492d61a0ae0SRandall Stewart 			SCTP_INP_INFO_RLOCK();
493d61a0ae0SRandall Stewart 			SCTP_INP_RLOCK(inp);
494d61a0ae0SRandall Stewart 		}
495851b7298SRandall Stewart 		SCTP_INP_DECR_REF(inp);
496d61a0ae0SRandall Stewart 		SCTP_INP_RUNLOCK(inp);
497d61a0ae0SRandall Stewart 		SCTP_INP_INFO_RUNLOCK();
498d61a0ae0SRandall Stewart 		memset((void *)&xstcb, 0, sizeof(struct xsctp_tcb));
499d61a0ae0SRandall Stewart 		xstcb.last = 1;
500d61a0ae0SRandall Stewart 		error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb));
501d61a0ae0SRandall Stewart 		if (error) {
502d61a0ae0SRandall Stewart 			return error;
503d61a0ae0SRandall Stewart 		}
504d61a0ae0SRandall Stewart 		SCTP_INP_INFO_RLOCK();
50542551e99SRandall Stewart 	}
50642551e99SRandall Stewart 	SCTP_INP_INFO_RUNLOCK();
50742551e99SRandall Stewart 
508d61a0ae0SRandall Stewart 	memset((void *)&xinpcb, 0, sizeof(struct xsctp_inpcb));
50942551e99SRandall Stewart 	xinpcb.last = 1;
51042551e99SRandall Stewart 	error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb));
51142551e99SRandall Stewart 	return error;
51242551e99SRandall Stewart }
51342551e99SRandall Stewart 
514c54a18d2SRandall Stewart 
515851b7298SRandall Stewart #define RANGECHK(var, min, max) \
516851b7298SRandall Stewart 	if ((var) < (min)) { (var) = (min); } \
517851b7298SRandall Stewart 	else if ((var) > (max)) { (var) = (max); }
518851b7298SRandall Stewart 
519851b7298SRandall Stewart static int
520c54a18d2SRandall Stewart sysctl_sctp_udp_tunneling_check(SYSCTL_HANDLER_ARGS)
521c54a18d2SRandall Stewart {
522c54a18d2SRandall Stewart 	int error;
523c54a18d2SRandall Stewart 	uint32_t old_sctp_udp_tunneling_port;
524c54a18d2SRandall Stewart 
525be27fdd0SRandall Stewart 	SCTP_INP_INFO_RLOCK();
526b3f1ea41SRandall Stewart 	old_sctp_udp_tunneling_port = SCTP_BASE_SYSCTL(sctp_udp_tunneling_port);
527be27fdd0SRandall Stewart 	SCTP_INP_INFO_RUNLOCK();
528c54a18d2SRandall Stewart 	error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
529c54a18d2SRandall Stewart 	if (error == 0) {
530b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port), SCTPCTL_UDP_TUNNELING_PORT_MIN, SCTPCTL_UDP_TUNNELING_PORT_MAX);
531a99b6783SRandall Stewart 		if (old_sctp_udp_tunneling_port == SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)) {
532a99b6783SRandall Stewart 			error = 0;
533a99b6783SRandall Stewart 			goto out;
534a99b6783SRandall Stewart 		}
535be27fdd0SRandall Stewart 		SCTP_INP_INFO_WLOCK();
536c54a18d2SRandall Stewart 		if (old_sctp_udp_tunneling_port) {
537c54a18d2SRandall Stewart 			sctp_over_udp_stop();
538c54a18d2SRandall Stewart 		}
539b3f1ea41SRandall Stewart 		if (SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)) {
540c54a18d2SRandall Stewart 			if (sctp_over_udp_start()) {
541b3f1ea41SRandall Stewart 				SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = 0;
542c54a18d2SRandall Stewart 			}
543c54a18d2SRandall Stewart 		}
544be27fdd0SRandall Stewart 		SCTP_INP_INFO_WUNLOCK();
545c54a18d2SRandall Stewart 	}
546a99b6783SRandall Stewart out:
547c54a18d2SRandall Stewart 	return (error);
548c54a18d2SRandall Stewart }
549c54a18d2SRandall Stewart 
550b3f1ea41SRandall Stewart 
551c54a18d2SRandall Stewart static int
552851b7298SRandall Stewart sysctl_sctp_check(SYSCTL_HANDLER_ARGS)
553851b7298SRandall Stewart {
554851b7298SRandall Stewart 	int error;
555851b7298SRandall Stewart 
556851b7298SRandall Stewart 	error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
557851b7298SRandall Stewart 	if (error == 0) {
558b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_sendspace), SCTPCTL_MAXDGRAM_MIN, SCTPCTL_MAXDGRAM_MAX);
559b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_recvspace), SCTPCTL_RECVSPACE_MIN, SCTPCTL_RECVSPACE_MAX);
560b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_auto_asconf), SCTPCTL_AUTOASCONF_MIN, SCTPCTL_AUTOASCONF_MAX);
561b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_ecn_enable), SCTPCTL_ECN_ENABLE_MIN, SCTPCTL_ECN_ENABLE_MAX);
562b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_ecn_nonce), SCTPCTL_ECN_NONCE_MIN, SCTPCTL_ECN_NONCE_MAX);
563b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_strict_sacks), SCTPCTL_STRICT_SACKS_MIN, SCTPCTL_STRICT_SACKS_MAX);
564b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback), SCTPCTL_LOOPBACK_NOCSUM_MIN, SCTPCTL_LOOPBACK_NOCSUM_MAX);
565b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_strict_init), SCTPCTL_STRICT_INIT_MIN, SCTPCTL_STRICT_INIT_MAX);
566b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_peer_chunk_oh), SCTPCTL_PEER_CHKOH_MIN, SCTPCTL_PEER_CHKOH_MAX);
567b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_max_burst_default), SCTPCTL_MAXBURST_MIN, SCTPCTL_MAXBURST_MAX);
568b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue), SCTPCTL_MAXCHUNKS_MIN, SCTPCTL_MAXCHUNKS_MAX);
569b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_hashtblsize), SCTPCTL_TCBHASHSIZE_MIN, SCTPCTL_TCBHASHSIZE_MAX);
570b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_pcbtblsize), SCTPCTL_PCBHASHSIZE_MIN, SCTPCTL_PCBHASHSIZE_MAX);
571b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_min_split_point), SCTPCTL_MIN_SPLIT_POINT_MIN, SCTPCTL_MIN_SPLIT_POINT_MAX);
572b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_chunkscale), SCTPCTL_CHUNKSCALE_MIN, SCTPCTL_CHUNKSCALE_MAX);
573b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default), SCTPCTL_DELAYED_SACK_TIME_MIN, SCTPCTL_DELAYED_SACK_TIME_MAX);
574b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_sack_freq_default), SCTPCTL_SACK_FREQ_MIN, SCTPCTL_SACK_FREQ_MAX);
575b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_system_free_resc_limit), SCTPCTL_SYS_RESOURCE_MIN, SCTPCTL_SYS_RESOURCE_MAX);
576b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit), SCTPCTL_ASOC_RESOURCE_MIN, SCTPCTL_ASOC_RESOURCE_MAX);
577b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default), SCTPCTL_HEARTBEAT_INTERVAL_MIN, SCTPCTL_HEARTBEAT_INTERVAL_MAX);
578b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default), SCTPCTL_PMTU_RAISE_TIME_MIN, SCTPCTL_PMTU_RAISE_TIME_MAX);
579b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default), SCTPCTL_SHUTDOWN_GUARD_TIME_MIN, SCTPCTL_SHUTDOWN_GUARD_TIME_MAX);
580b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_secret_lifetime_default), SCTPCTL_SECRET_LIFETIME_MIN, SCTPCTL_SECRET_LIFETIME_MAX);
581b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_max_default), SCTPCTL_RTO_MAX_MIN, SCTPCTL_RTO_MAX_MAX);
582b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_min_default), SCTPCTL_RTO_MIN_MIN, SCTPCTL_RTO_MIN_MAX);
583b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_initial_default), SCTPCTL_RTO_INITIAL_MIN, SCTPCTL_RTO_INITIAL_MAX);
584b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_init_rto_max_default), SCTPCTL_INIT_RTO_MAX_MIN, SCTPCTL_INIT_RTO_MAX_MAX);
585b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default), SCTPCTL_VALID_COOKIE_LIFE_MIN, SCTPCTL_VALID_COOKIE_LIFE_MAX);
586b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_init_rtx_max_default), SCTPCTL_INIT_RTX_MAX_MIN, SCTPCTL_INIT_RTX_MAX_MAX);
587b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default), SCTPCTL_ASSOC_RTX_MAX_MIN, SCTPCTL_ASSOC_RTX_MAX_MAX);
588b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_path_rtx_max_default), SCTPCTL_PATH_RTX_MAX_MIN, SCTPCTL_PATH_RTX_MAX_MAX);
589b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_add_more_threshold), SCTPCTL_ADD_MORE_ON_OUTPUT_MIN, SCTPCTL_ADD_MORE_ON_OUTPUT_MAX);
590b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default), SCTPCTL_OUTGOING_STREAMS_MIN, SCTPCTL_OUTGOING_STREAMS_MAX);
591b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_on_off), SCTPCTL_CMT_ON_OFF_MIN, SCTPCTL_CMT_ON_OFF_MAX);
592830d754dSRandall Stewart 		/* EY */
593830d754dSRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_nr_sack_on_off), SCTPCTL_NR_SACK_ON_OFF_MIN, SCTPCTL_NR_SACK_ON_OFF_MAX);
594b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_use_dac), SCTPCTL_CMT_USE_DAC_MIN, SCTPCTL_CMT_USE_DAC_MAX);
595b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_pf), SCTPCTL_CMT_PF_MIN, SCTPCTL_CMT_PF_MAX);
596b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst), SCTPCTL_CWND_MAXBURST_MIN, SCTPCTL_CWND_MAXBURST_MAX);
597b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_early_fr), SCTPCTL_EARLY_FAST_RETRAN_MIN, SCTPCTL_EARLY_FAST_RETRAN_MAX);
598b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_early_fr_msec), SCTPCTL_EARLY_FAST_RETRAN_MSEC_MIN, SCTPCTL_EARLY_FAST_RETRAN_MSEC_MAX);
599b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_asconf_auth_nochk), SCTPCTL_ASCONF_AUTH_NOCHK_MIN, SCTPCTL_ASCONF_AUTH_NOCHK_MAX);
600b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_auth_disable), SCTPCTL_AUTH_DISABLE_MIN, SCTPCTL_AUTH_DISABLE_MAX);
601b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_nat_friendly), SCTPCTL_NAT_FRIENDLY_MIN, SCTPCTL_NAT_FRIENDLY_MAX);
602b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_L2_abc_variable), SCTPCTL_ABC_L_VAR_MIN, SCTPCTL_ABC_L_VAR_MAX);
603b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count), SCTPCTL_MAX_CHAINED_MBUFS_MIN, SCTPCTL_MAX_CHAINED_MBUFS_MAX);
604b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_do_drain), SCTPCTL_DO_SCTP_DRAIN_MIN, SCTPCTL_DO_SCTP_DRAIN_MAX);
605b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_hb_maxburst), SCTPCTL_HB_MAX_BURST_MIN, SCTPCTL_HB_MAX_BURST_MAX);
606b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit), SCTPCTL_ABORT_AT_LIMIT_MIN, SCTPCTL_ABORT_AT_LIMIT_MAX);
607b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_strict_data_order), SCTPCTL_STRICT_DATA_ORDER_MIN, SCTPCTL_STRICT_DATA_ORDER_MAX);
608b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_min_residual), SCTPCTL_MIN_RESIDUAL_MIN, SCTPCTL_MIN_RESIDUAL_MAX);
609b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_max_retran_chunk), SCTPCTL_MAX_RETRAN_CHUNK_MIN, SCTPCTL_MAX_RETRAN_CHUNK_MAX);
610b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_logging_level), SCTPCTL_LOGGING_LEVEL_MIN, SCTPCTL_LOGGING_LEVEL_MAX);
611b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_default_cc_module), SCTPCTL_DEFAULT_CC_MODULE_MIN, SCTPCTL_DEFAULT_CC_MODULE_MAX);
612b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_default_frag_interleave), SCTPCTL_DEFAULT_FRAG_INTERLEAVE_MIN, SCTPCTL_DEFAULT_FRAG_INTERLEAVE_MAX);
613a16ccdceSRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_vtag_time_wait), SCTPCTL_TIME_WAIT_MIN, SCTPCTL_TIME_WAIT_MAX);
614a16ccdceSRandall Stewart 
615b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_mobility_base), SCTPCTL_MOBILITY_BASE_MIN, SCTPCTL_MOBILITY_BASE_MAX);
616b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff), SCTPCTL_MOBILITY_FASTHANDOFF_MIN, SCTPCTL_MOBILITY_FASTHANDOFF_MAX);
617b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_udp_tunneling_for_client_enable), SCTPCTL_UDP_TUNNELING_FOR_CLIENT_ENABLE_MIN, SCTPCTL_UDP_TUNNELING_FOR_CLIENT_ENABLE_MAX);
618b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_enable_sack_immediately), SCTPCTL_SACK_IMMEDIATELY_ENABLE_MIN, SCTPCTL_SACK_IMMEDIATELY_ENABLE_MAX);
619bf3d5177SMichael Tuexen 		RANGECHK(SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly), SCTPCTL_NAT_FRIENDLY_INITS_MIN, SCTPCTL_NAT_FRIENDLY_INITS_MAX);
620830d754dSRandall Stewart 
621851b7298SRandall Stewart #ifdef SCTP_DEBUG
622b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_debug_on), SCTPCTL_DEBUG_MIN, SCTPCTL_DEBUG_MAX);
623b3f1ea41SRandall Stewart #endif
624b3f1ea41SRandall Stewart #if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
625b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_output_unlocked), SCTPCTL_OUTPUT_UNLOCKED_MIN, SCTPCTL_OUTPUT_UNLOCKED_MAX);
626851b7298SRandall Stewart #endif
627851b7298SRandall Stewart 	}
628851b7298SRandall Stewart 	return (error);
629851b7298SRandall Stewart }
63042551e99SRandall Stewart 
631ff014514SRandall Stewart #if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
632ff014514SRandall Stewart static int
633ff014514SRandall Stewart sysctl_stat_get(SYSCTL_HANDLER_ARGS)
634ff014514SRandall Stewart {
635ff014514SRandall Stewart 	int cpu, error;
636ff014514SRandall Stewart 	struct sctpstat sb, *sarry;
637b3f1ea41SRandall Stewart 
638ff014514SRandall Stewart 	memset(&sb, 0, sizeof(sb));
639ff014514SRandall Stewart 	for (cpu = 0; cpu < mp_ncpus; cpu++) {
640ff014514SRandall Stewart 		sarry = &SCTP_BASE_STATS[cpu];
641ff014514SRandall Stewart 		if (sarry->sctps_discontinuitytime.tv_sec > sb.sctps_discontinuitytime.tv_sec) {
642ff014514SRandall Stewart 			sb.sctps_discontinuitytime.tv_sec = sarry->sctps_discontinuitytime.tv_sec;
643ff014514SRandall Stewart 			sb.sctps_discontinuitytime.tv_usec = sarry->sctps_discontinuitytime.tv_usec;
644ff014514SRandall Stewart 		}
645ff014514SRandall Stewart 		sb.sctps_currestab += sarry->sctps_currestab;
646ff014514SRandall Stewart 		sb.sctps_activeestab += sarry->sctps_activeestab;
647ff014514SRandall Stewart 		sb.sctps_restartestab += sarry->sctps_restartestab;
648ff014514SRandall Stewart 		sb.sctps_collisionestab += sarry->sctps_collisionestab;
649ff014514SRandall Stewart 		sb.sctps_passiveestab += sarry->sctps_passiveestab;
650ff014514SRandall Stewart 		sb.sctps_aborted += sarry->sctps_aborted;
651ff014514SRandall Stewart 		sb.sctps_shutdown += sarry->sctps_shutdown;
652ff014514SRandall Stewart 		sb.sctps_outoftheblue += sarry->sctps_outoftheblue;
653ff014514SRandall Stewart 		sb.sctps_checksumerrors += sarry->sctps_checksumerrors;
654ff014514SRandall Stewart 		sb.sctps_outcontrolchunks += sarry->sctps_outcontrolchunks;
655ff014514SRandall Stewart 		sb.sctps_outorderchunks += sarry->sctps_outorderchunks;
656ff014514SRandall Stewart 		sb.sctps_outunorderchunks += sarry->sctps_outunorderchunks;
657ff014514SRandall Stewart 		sb.sctps_incontrolchunks += sarry->sctps_incontrolchunks;
658ff014514SRandall Stewart 		sb.sctps_inorderchunks += sarry->sctps_inorderchunks;
659ff014514SRandall Stewart 		sb.sctps_inunorderchunks += sarry->sctps_inunorderchunks;
660ff014514SRandall Stewart 		sb.sctps_fragusrmsgs += sarry->sctps_fragusrmsgs;
661ff014514SRandall Stewart 		sb.sctps_reasmusrmsgs += sarry->sctps_reasmusrmsgs;
662ff014514SRandall Stewart 		sb.sctps_outpackets += sarry->sctps_outpackets;
663ff014514SRandall Stewart 		sb.sctps_inpackets += sarry->sctps_inpackets;
664ff014514SRandall Stewart 		sb.sctps_recvpackets += sarry->sctps_recvpackets;
665ff014514SRandall Stewart 		sb.sctps_recvdatagrams += sarry->sctps_recvdatagrams;
666ff014514SRandall Stewart 		sb.sctps_recvpktwithdata += sarry->sctps_recvpktwithdata;
667ff014514SRandall Stewart 		sb.sctps_recvsacks += sarry->sctps_recvsacks;
668ff014514SRandall Stewart 		sb.sctps_recvdata += sarry->sctps_recvdata;
669ff014514SRandall Stewart 		sb.sctps_recvdupdata += sarry->sctps_recvdupdata;
670ff014514SRandall Stewart 		sb.sctps_recvheartbeat += sarry->sctps_recvheartbeat;
671ff014514SRandall Stewart 		sb.sctps_recvheartbeatack += sarry->sctps_recvheartbeatack;
672ff014514SRandall Stewart 		sb.sctps_recvecne += sarry->sctps_recvecne;
673ff014514SRandall Stewart 		sb.sctps_recvauth += sarry->sctps_recvauth;
674ff014514SRandall Stewart 		sb.sctps_recvauthmissing += sarry->sctps_recvauthmissing;
675ff014514SRandall Stewart 		sb.sctps_recvivalhmacid += sarry->sctps_recvivalhmacid;
676ff014514SRandall Stewart 		sb.sctps_recvivalkeyid += sarry->sctps_recvivalkeyid;
677ff014514SRandall Stewart 		sb.sctps_recvauthfailed += sarry->sctps_recvauthfailed;
678ff014514SRandall Stewart 		sb.sctps_recvexpress += sarry->sctps_recvexpress;
679ff014514SRandall Stewart 		sb.sctps_recvexpressm += sarry->sctps_recvexpressm;
680ff014514SRandall Stewart 		sb.sctps_recvnocrc += sarry->sctps_recvnocrc;
681ff014514SRandall Stewart 		sb.sctps_recvswcrc += sarry->sctps_recvswcrc;
682ff014514SRandall Stewart 		sb.sctps_recvhwcrc += sarry->sctps_recvhwcrc;
683ff014514SRandall Stewart 		sb.sctps_sendpackets += sarry->sctps_sendpackets;
684ff014514SRandall Stewart 		sb.sctps_sendsacks += sarry->sctps_sendsacks;
685ff014514SRandall Stewart 		sb.sctps_senddata += sarry->sctps_senddata;
686ff014514SRandall Stewart 		sb.sctps_sendretransdata += sarry->sctps_sendretransdata;
687ff014514SRandall Stewart 		sb.sctps_sendfastretrans += sarry->sctps_sendfastretrans;
688ff014514SRandall Stewart 		sb.sctps_sendmultfastretrans += sarry->sctps_sendmultfastretrans;
689ff014514SRandall Stewart 		sb.sctps_sendheartbeat += sarry->sctps_sendheartbeat;
690ff014514SRandall Stewart 		sb.sctps_sendecne += sarry->sctps_sendecne;
691ff014514SRandall Stewart 		sb.sctps_sendauth += sarry->sctps_sendauth;
692ff014514SRandall Stewart 		sb.sctps_senderrors += sarry->sctps_senderrors;
693ff014514SRandall Stewart 		sb.sctps_sendnocrc += sarry->sctps_sendnocrc;
694ff014514SRandall Stewart 		sb.sctps_sendswcrc += sarry->sctps_sendswcrc;
695ff014514SRandall Stewart 		sb.sctps_sendhwcrc += sarry->sctps_sendhwcrc;
696ff014514SRandall Stewart 		sb.sctps_pdrpfmbox += sarry->sctps_pdrpfmbox;
697ff014514SRandall Stewart 		sb.sctps_pdrpfehos += sarry->sctps_pdrpfehos;
698ff014514SRandall Stewart 		sb.sctps_pdrpmbda += sarry->sctps_pdrpmbda;
699ff014514SRandall Stewart 		sb.sctps_pdrpmbct += sarry->sctps_pdrpmbct;
700ff014514SRandall Stewart 		sb.sctps_pdrpbwrpt += sarry->sctps_pdrpbwrpt;
701ff014514SRandall Stewart 		sb.sctps_pdrpcrupt += sarry->sctps_pdrpcrupt;
702ff014514SRandall Stewart 		sb.sctps_pdrpnedat += sarry->sctps_pdrpnedat;
703ff014514SRandall Stewart 		sb.sctps_pdrppdbrk += sarry->sctps_pdrppdbrk;
704ff014514SRandall Stewart 		sb.sctps_pdrptsnnf += sarry->sctps_pdrptsnnf;
705ff014514SRandall Stewart 		sb.sctps_pdrpdnfnd += sarry->sctps_pdrpdnfnd;
706ff014514SRandall Stewart 		sb.sctps_pdrpdiwnp += sarry->sctps_pdrpdiwnp;
707ff014514SRandall Stewart 		sb.sctps_pdrpdizrw += sarry->sctps_pdrpdizrw;
708ff014514SRandall Stewart 		sb.sctps_pdrpbadd += sarry->sctps_pdrpbadd;
709ff014514SRandall Stewart 		sb.sctps_pdrpmark += sarry->sctps_pdrpmark;
710ff014514SRandall Stewart 		sb.sctps_timoiterator += sarry->sctps_timoiterator;
711ff014514SRandall Stewart 		sb.sctps_timodata += sarry->sctps_timodata;
712ff014514SRandall Stewart 		sb.sctps_timowindowprobe += sarry->sctps_timowindowprobe;
713ff014514SRandall Stewart 		sb.sctps_timoinit += sarry->sctps_timoinit;
714ff014514SRandall Stewart 		sb.sctps_timosack += sarry->sctps_timosack;
715ff014514SRandall Stewart 		sb.sctps_timoshutdown += sarry->sctps_timoshutdown;
716ff014514SRandall Stewart 		sb.sctps_timoheartbeat += sarry->sctps_timoheartbeat;
717ff014514SRandall Stewart 		sb.sctps_timocookie += sarry->sctps_timocookie;
718ff014514SRandall Stewart 		sb.sctps_timosecret += sarry->sctps_timosecret;
719ff014514SRandall Stewart 		sb.sctps_timopathmtu += sarry->sctps_timopathmtu;
720ff014514SRandall Stewart 		sb.sctps_timoshutdownack += sarry->sctps_timoshutdownack;
721ff014514SRandall Stewart 		sb.sctps_timoshutdownguard += sarry->sctps_timoshutdownguard;
722ff014514SRandall Stewart 		sb.sctps_timostrmrst += sarry->sctps_timostrmrst;
723ff014514SRandall Stewart 		sb.sctps_timoearlyfr += sarry->sctps_timoearlyfr;
724ff014514SRandall Stewart 		sb.sctps_timoasconf += sarry->sctps_timoasconf;
725ff014514SRandall Stewart 		sb.sctps_timodelprim += sarry->sctps_timodelprim;
726ff014514SRandall Stewart 		sb.sctps_timoautoclose += sarry->sctps_timoautoclose;
727ff014514SRandall Stewart 		sb.sctps_timoassockill += sarry->sctps_timoassockill;
728ff014514SRandall Stewart 		sb.sctps_timoinpkill += sarry->sctps_timoinpkill;
729ff014514SRandall Stewart 		sb.sctps_earlyfrstart += sarry->sctps_earlyfrstart;
730ff014514SRandall Stewart 		sb.sctps_earlyfrstop += sarry->sctps_earlyfrstop;
731ff014514SRandall Stewart 		sb.sctps_earlyfrmrkretrans += sarry->sctps_earlyfrmrkretrans;
732ff014514SRandall Stewart 		sb.sctps_earlyfrstpout += sarry->sctps_earlyfrstpout;
733ff014514SRandall Stewart 		sb.sctps_earlyfrstpidsck1 += sarry->sctps_earlyfrstpidsck1;
734ff014514SRandall Stewart 		sb.sctps_earlyfrstpidsck2 += sarry->sctps_earlyfrstpidsck2;
735ff014514SRandall Stewart 		sb.sctps_earlyfrstpidsck3 += sarry->sctps_earlyfrstpidsck3;
736ff014514SRandall Stewart 		sb.sctps_earlyfrstpidsck4 += sarry->sctps_earlyfrstpidsck4;
737ff014514SRandall Stewart 		sb.sctps_earlyfrstrid += sarry->sctps_earlyfrstrid;
738ff014514SRandall Stewart 		sb.sctps_earlyfrstrout += sarry->sctps_earlyfrstrout;
739ff014514SRandall Stewart 		sb.sctps_earlyfrstrtmr += sarry->sctps_earlyfrstrtmr;
740ff014514SRandall Stewart 		sb.sctps_hdrops += sarry->sctps_hdrops;
741ff014514SRandall Stewart 		sb.sctps_badsum += sarry->sctps_badsum;
742ff014514SRandall Stewart 		sb.sctps_noport += sarry->sctps_noport;
743ff014514SRandall Stewart 		sb.sctps_badvtag += sarry->sctps_badvtag;
744ff014514SRandall Stewart 		sb.sctps_badsid += sarry->sctps_badsid;
745ff014514SRandall Stewart 		sb.sctps_nomem += sarry->sctps_nomem;
746ff014514SRandall Stewart 		sb.sctps_fastretransinrtt += sarry->sctps_fastretransinrtt;
747ff014514SRandall Stewart 		sb.sctps_markedretrans += sarry->sctps_markedretrans;
748ff014514SRandall Stewart 		sb.sctps_naglesent += sarry->sctps_naglesent;
749ff014514SRandall Stewart 		sb.sctps_naglequeued += sarry->sctps_naglequeued;
750ff014514SRandall Stewart 		sb.sctps_maxburstqueued += sarry->sctps_maxburstqueued;
751ff014514SRandall Stewart 		sb.sctps_ifnomemqueued += sarry->sctps_ifnomemqueued;
752ff014514SRandall Stewart 		sb.sctps_windowprobed += sarry->sctps_windowprobed;
753ff014514SRandall Stewart 		sb.sctps_lowlevelerr += sarry->sctps_lowlevelerr;
754ff014514SRandall Stewart 		sb.sctps_lowlevelerrusr += sarry->sctps_lowlevelerrusr;
755ff014514SRandall Stewart 		sb.sctps_datadropchklmt += sarry->sctps_datadropchklmt;
756ff014514SRandall Stewart 		sb.sctps_datadroprwnd += sarry->sctps_datadroprwnd;
757ff014514SRandall Stewart 		sb.sctps_ecnereducedcwnd += sarry->sctps_ecnereducedcwnd;
758ff014514SRandall Stewart 		sb.sctps_vtagexpress += sarry->sctps_vtagexpress;
759ff014514SRandall Stewart 		sb.sctps_vtagbogus += sarry->sctps_vtagbogus;
760ff014514SRandall Stewart 		sb.sctps_primary_randry += sarry->sctps_primary_randry;
761ff014514SRandall Stewart 		sb.sctps_cmt_randry += sarry->sctps_cmt_randry;
762ff014514SRandall Stewart 		sb.sctps_slowpath_sack += sarry->sctps_slowpath_sack;
763ff014514SRandall Stewart 		sb.sctps_wu_sacks_sent += sarry->sctps_wu_sacks_sent;
764ff014514SRandall Stewart 		sb.sctps_sends_with_flags += sarry->sctps_sends_with_flags;
765ff014514SRandall Stewart 		sb.sctps_sends_with_unord += sarry->sctps_sends_with_unord;
766ff014514SRandall Stewart 		sb.sctps_sends_with_eof += sarry->sctps_sends_with_eof;
767ff014514SRandall Stewart 		sb.sctps_sends_with_abort += sarry->sctps_sends_with_abort;
768ff014514SRandall Stewart 		sb.sctps_protocol_drain_calls += sarry->sctps_protocol_drain_calls;
769ff014514SRandall Stewart 		sb.sctps_protocol_drains_done += sarry->sctps_protocol_drains_done;
770ff014514SRandall Stewart 		sb.sctps_read_peeks += sarry->sctps_read_peeks;
771ff014514SRandall Stewart 		sb.sctps_cached_chk += sarry->sctps_cached_chk;
772ff014514SRandall Stewart 		sb.sctps_cached_strmoq += sarry->sctps_cached_strmoq;
773ff014514SRandall Stewart 		sb.sctps_left_abandon += sarry->sctps_left_abandon;
774ff014514SRandall Stewart 		sb.sctps_send_burst_avoid += sarry->sctps_send_burst_avoid;
775ff014514SRandall Stewart 		sb.sctps_send_cwnd_avoid += sarry->sctps_send_cwnd_avoid;
776ff014514SRandall Stewart 		sb.sctps_fwdtsn_map_over += sarry->sctps_fwdtsn_map_over;
777ff014514SRandall Stewart 	}
778ff014514SRandall Stewart 	error = SYSCTL_OUT(req, &sb, sizeof(sb));
779ff014514SRandall Stewart 	return (error);
780ff014514SRandall Stewart }
781ff014514SRandall Stewart 
782ff014514SRandall Stewart #endif
783b3f1ea41SRandall Stewart 
784b3f1ea41SRandall Stewart #if defined(SCTP_LOCAL_TRACE_BUF)
785b3f1ea41SRandall Stewart static int
786b3f1ea41SRandall Stewart sysctl_sctp_cleartrace(SYSCTL_HANDLER_ARGS)
787b3f1ea41SRandall Stewart {
788a99b6783SRandall Stewart 	int error = 0;
789a99b6783SRandall Stewart 
790b3f1ea41SRandall Stewart 	memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log));
791a99b6783SRandall Stewart 	return (error);
792b3f1ea41SRandall Stewart }
793b3f1ea41SRandall Stewart 
794b3f1ea41SRandall Stewart #endif
795b3f1ea41SRandall Stewart 
796b3f1ea41SRandall Stewart 
79742551e99SRandall Stewart /*
79842551e99SRandall Stewart  * sysctl definitions
79942551e99SRandall Stewart  */
80042551e99SRandall Stewart 
801851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, sendspace, CTLTYPE_INT | CTLFLAG_RW,
802b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_sendspace), 0, sysctl_sctp_check, "IU",
803851b7298SRandall Stewart     SCTPCTL_MAXDGRAM_DESC);
80442551e99SRandall Stewart 
805851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, recvspace, CTLTYPE_INT | CTLFLAG_RW,
806b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_recvspace), 0, sysctl_sctp_check, "IU",
807851b7298SRandall Stewart     SCTPCTL_RECVSPACE_DESC);
80842551e99SRandall Stewart 
809851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, auto_asconf, CTLTYPE_INT | CTLFLAG_RW,
810b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_auto_asconf), 0, sysctl_sctp_check, "IU",
811851b7298SRandall Stewart     SCTPCTL_AUTOASCONF_DESC);
81242551e99SRandall Stewart 
813851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, ecn_enable, CTLTYPE_INT | CTLFLAG_RW,
814b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_ecn_enable), 0, sysctl_sctp_check, "IU",
815851b7298SRandall Stewart     SCTPCTL_ECN_ENABLE_DESC);
81642551e99SRandall Stewart 
817851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, ecn_nonce, CTLTYPE_INT | CTLFLAG_RW,
818b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_ecn_nonce), 0, sysctl_sctp_check, "IU",
819851b7298SRandall Stewart     SCTPCTL_ECN_NONCE_DESC);
82042551e99SRandall Stewart 
821851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, strict_sacks, CTLTYPE_INT | CTLFLAG_RW,
822b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_strict_sacks), 0, sysctl_sctp_check, "IU",
823851b7298SRandall Stewart     SCTPCTL_STRICT_SACKS_DESC);
82442551e99SRandall Stewart 
825851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, loopback_nocsum, CTLTYPE_INT | CTLFLAG_RW,
826b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback), 0, sysctl_sctp_check, "IU",
827851b7298SRandall Stewart     SCTPCTL_LOOPBACK_NOCSUM_DESC);
82842551e99SRandall Stewart 
829851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, strict_init, CTLTYPE_INT | CTLFLAG_RW,
830b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_strict_init), 0, sysctl_sctp_check, "IU",
831851b7298SRandall Stewart     SCTPCTL_STRICT_INIT_DESC);
83242551e99SRandall Stewart 
833851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, peer_chkoh, CTLTYPE_INT | CTLFLAG_RW,
834b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_peer_chunk_oh), 0, sysctl_sctp_check, "IU",
835851b7298SRandall Stewart     SCTPCTL_PEER_CHKOH_DESC);
83642551e99SRandall Stewart 
837851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, maxburst, CTLTYPE_INT | CTLFLAG_RW,
838b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_max_burst_default), 0, sysctl_sctp_check, "IU",
839851b7298SRandall Stewart     SCTPCTL_MAXBURST_DESC);
84042551e99SRandall Stewart 
841851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, maxchunks, CTLTYPE_INT | CTLFLAG_RW,
842b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue), 0, sysctl_sctp_check, "IU",
843851b7298SRandall Stewart     SCTPCTL_MAXCHUNKS_DESC);
84442551e99SRandall Stewart 
845851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, tcbhashsize, CTLTYPE_INT | CTLFLAG_RW,
846b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_hashtblsize), 0, sysctl_sctp_check, "IU",
847851b7298SRandall Stewart     SCTPCTL_TCBHASHSIZE_DESC);
84842551e99SRandall Stewart 
849851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, pcbhashsize, CTLTYPE_INT | CTLFLAG_RW,
850b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_pcbtblsize), 0, sysctl_sctp_check, "IU",
851851b7298SRandall Stewart     SCTPCTL_PCBHASHSIZE_DESC);
85242551e99SRandall Stewart 
853851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, min_split_point, CTLTYPE_INT | CTLFLAG_RW,
854b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_min_split_point), 0, sysctl_sctp_check, "IU",
855851b7298SRandall Stewart     SCTPCTL_MIN_SPLIT_POINT_DESC);
85642551e99SRandall Stewart 
857851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, chunkscale, CTLTYPE_INT | CTLFLAG_RW,
858b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_chunkscale), 0, sysctl_sctp_check, "IU",
859851b7298SRandall Stewart     SCTPCTL_CHUNKSCALE_DESC);
86042551e99SRandall Stewart 
861851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, delayed_sack_time, CTLTYPE_INT | CTLFLAG_RW,
862b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default), 0, sysctl_sctp_check, "IU",
863851b7298SRandall Stewart     SCTPCTL_DELAYED_SACK_TIME_DESC);
86442551e99SRandall Stewart 
865851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, sack_freq, CTLTYPE_INT | CTLFLAG_RW,
866b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_sack_freq_default), 0, sysctl_sctp_check, "IU",
867851b7298SRandall Stewart     SCTPCTL_SACK_FREQ_DESC);
86842551e99SRandall Stewart 
869851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, sys_resource, CTLTYPE_INT | CTLFLAG_RW,
870b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_system_free_resc_limit), 0, sysctl_sctp_check, "IU",
871851b7298SRandall Stewart     SCTPCTL_SYS_RESOURCE_DESC);
87242551e99SRandall Stewart 
873851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, asoc_resource, CTLTYPE_INT | CTLFLAG_RW,
874b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit), 0, sysctl_sctp_check, "IU",
875851b7298SRandall Stewart     SCTPCTL_ASOC_RESOURCE_DESC);
87642551e99SRandall Stewart 
877851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, heartbeat_interval, CTLTYPE_INT | CTLFLAG_RW,
878b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default), 0, sysctl_sctp_check, "IU",
879851b7298SRandall Stewart     SCTPCTL_HEARTBEAT_INTERVAL_DESC);
88042551e99SRandall Stewart 
881851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, pmtu_raise_time, CTLTYPE_INT | CTLFLAG_RW,
882b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default), 0, sysctl_sctp_check, "IU",
883851b7298SRandall Stewart     SCTPCTL_PMTU_RAISE_TIME_DESC);
88442551e99SRandall Stewart 
885851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, shutdown_guard_time, CTLTYPE_INT | CTLFLAG_RW,
886b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default), 0, sysctl_sctp_check, "IU",
887851b7298SRandall Stewart     SCTPCTL_SHUTDOWN_GUARD_TIME_DESC);
88842551e99SRandall Stewart 
889851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, secret_lifetime, CTLTYPE_INT | CTLFLAG_RW,
890b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_secret_lifetime_default), 0, sysctl_sctp_check, "IU",
891851b7298SRandall Stewart     SCTPCTL_SECRET_LIFETIME_DESC);
89242551e99SRandall Stewart 
893851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, rto_max, CTLTYPE_INT | CTLFLAG_RW,
894b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_rto_max_default), 0, sysctl_sctp_check, "IU",
895851b7298SRandall Stewart     SCTPCTL_RTO_MAX_DESC);
89642551e99SRandall Stewart 
897851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, rto_min, CTLTYPE_INT | CTLFLAG_RW,
898b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_rto_min_default), 0, sysctl_sctp_check, "IU",
899851b7298SRandall Stewart     SCTPCTL_RTO_MIN_DESC);
90042551e99SRandall Stewart 
901851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, rto_initial, CTLTYPE_INT | CTLFLAG_RW,
902b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_rto_initial_default), 0, sysctl_sctp_check, "IU",
903851b7298SRandall Stewart     SCTPCTL_RTO_INITIAL_DESC);
90442551e99SRandall Stewart 
905851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, init_rto_max, CTLTYPE_INT | CTLFLAG_RW,
906b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_init_rto_max_default), 0, sysctl_sctp_check, "IU",
907851b7298SRandall Stewart     SCTPCTL_INIT_RTO_MAX_DESC);
90842551e99SRandall Stewart 
909851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, valid_cookie_life, CTLTYPE_INT | CTLFLAG_RW,
910b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default), 0, sysctl_sctp_check, "IU",
911851b7298SRandall Stewart     SCTPCTL_VALID_COOKIE_LIFE_DESC);
91242551e99SRandall Stewart 
913851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, init_rtx_max, CTLTYPE_INT | CTLFLAG_RW,
914b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_init_rtx_max_default), 0, sysctl_sctp_check, "IU",
915851b7298SRandall Stewart     SCTPCTL_INIT_RTX_MAX_DESC);
91642551e99SRandall Stewart 
917851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, assoc_rtx_max, CTLTYPE_INT | CTLFLAG_RW,
918b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default), 0, sysctl_sctp_check, "IU",
919851b7298SRandall Stewart     SCTPCTL_ASSOC_RTX_MAX_DESC);
92042551e99SRandall Stewart 
921851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, path_rtx_max, CTLTYPE_INT | CTLFLAG_RW,
922b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_path_rtx_max_default), 0, sysctl_sctp_check, "IU",
923851b7298SRandall Stewart     SCTPCTL_PATH_RTX_MAX_DESC);
92442551e99SRandall Stewart 
925851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, add_more_on_output, CTLTYPE_INT | CTLFLAG_RW,
926b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_add_more_threshold), 0, sysctl_sctp_check, "IU",
927851b7298SRandall Stewart     SCTPCTL_ADD_MORE_ON_OUTPUT_DESC);
92842551e99SRandall Stewart 
929851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, outgoing_streams, CTLTYPE_INT | CTLFLAG_RW,
930b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default), 0, sysctl_sctp_check, "IU",
931851b7298SRandall Stewart     SCTPCTL_OUTGOING_STREAMS_DESC);
93242551e99SRandall Stewart 
933851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, cmt_on_off, CTLTYPE_INT | CTLFLAG_RW,
934b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_cmt_on_off), 0, sysctl_sctp_check, "IU",
935851b7298SRandall Stewart     SCTPCTL_CMT_ON_OFF_DESC);
93642551e99SRandall Stewart 
937830d754dSRandall Stewart /* EY */
938830d754dSRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, nr_sack_on_off, CTLTYPE_INT | CTLFLAG_RW,
939830d754dSRandall Stewart     &SCTP_BASE_SYSCTL(sctp_nr_sack_on_off), 0, sysctl_sctp_check, "IU",
940830d754dSRandall Stewart     SCTPCTL_NR_SACK_ON_OFF_DESC);
941830d754dSRandall Stewart 
942851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, cmt_use_dac, CTLTYPE_INT | CTLFLAG_RW,
943b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_cmt_use_dac), 0, sysctl_sctp_check, "IU",
944851b7298SRandall Stewart     SCTPCTL_CMT_USE_DAC_DESC);
945b54d3a6cSRandall Stewart 
946851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, cmt_pf, CTLTYPE_INT | CTLFLAG_RW,
947b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_cmt_pf), 0, sysctl_sctp_check, "IU",
948851b7298SRandall Stewart     SCTPCTL_CMT_PF_DESC);
949b54d3a6cSRandall Stewart 
950851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, cwnd_maxburst, CTLTYPE_INT | CTLFLAG_RW,
951b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst), 0, sysctl_sctp_check, "IU",
952851b7298SRandall Stewart     SCTPCTL_CWND_MAXBURST_DESC);
953c4739e2fSRandall Stewart 
954851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, early_fast_retran, CTLTYPE_INT | CTLFLAG_RW,
955b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_early_fr), 0, sysctl_sctp_check, "IU",
956851b7298SRandall Stewart     SCTPCTL_EARLY_FAST_RETRAN_DESC);
957851b7298SRandall Stewart 
958851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, early_fast_retran_msec, CTLTYPE_INT | CTLFLAG_RW,
959b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_early_fr_msec), 0, sysctl_sctp_check, "IU",
960851b7298SRandall Stewart     SCTPCTL_EARLY_FAST_RETRAN_MSEC_DESC);
961851b7298SRandall Stewart 
962851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, asconf_auth_nochk, CTLTYPE_INT | CTLFLAG_RW,
963b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_asconf_auth_nochk), 0, sysctl_sctp_check, "IU",
964851b7298SRandall Stewart     SCTPCTL_ASCONF_AUTH_NOCHK_DESC);
965851b7298SRandall Stewart 
966851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, auth_disable, CTLTYPE_INT | CTLFLAG_RW,
967b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_auth_disable), 0, sysctl_sctp_check, "IU",
968851b7298SRandall Stewart     SCTPCTL_AUTH_DISABLE_DESC);
969851b7298SRandall Stewart 
970851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, nat_friendly, CTLTYPE_INT | CTLFLAG_RW,
971b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_nat_friendly), 0, sysctl_sctp_check, "IU",
972851b7298SRandall Stewart     SCTPCTL_NAT_FRIENDLY_DESC);
973851b7298SRandall Stewart 
974851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, abc_l_var, CTLTYPE_INT | CTLFLAG_RW,
975b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_L2_abc_variable), 0, sysctl_sctp_check, "IU",
976851b7298SRandall Stewart     SCTPCTL_ABC_L_VAR_DESC);
977851b7298SRandall Stewart 
978851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, max_chained_mbufs, CTLTYPE_INT | CTLFLAG_RW,
979b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count), 0, sysctl_sctp_check, "IU",
980851b7298SRandall Stewart     SCTPCTL_MAX_CHAINED_MBUFS_DESC);
981851b7298SRandall Stewart 
982851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, do_sctp_drain, CTLTYPE_INT | CTLFLAG_RW,
983b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_do_drain), 0, sysctl_sctp_check, "IU",
984851b7298SRandall Stewart     SCTPCTL_DO_SCTP_DRAIN_DESC);
985851b7298SRandall Stewart 
986851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, hb_max_burst, CTLTYPE_INT | CTLFLAG_RW,
987b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_hb_maxburst), 0, sysctl_sctp_check, "IU",
988851b7298SRandall Stewart     SCTPCTL_HB_MAX_BURST_DESC);
989851b7298SRandall Stewart 
990851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, abort_at_limit, CTLTYPE_INT | CTLFLAG_RW,
991b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit), 0, sysctl_sctp_check, "IU",
992851b7298SRandall Stewart     SCTPCTL_ABORT_AT_LIMIT_DESC);
993851b7298SRandall Stewart 
994851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, strict_data_order, CTLTYPE_INT | CTLFLAG_RW,
995b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_strict_data_order), 0, sysctl_sctp_check, "IU",
996851b7298SRandall Stewart     SCTPCTL_STRICT_DATA_ORDER_DESC);
997851b7298SRandall Stewart 
998851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, min_residual, CTLTYPE_INT | CTLFLAG_RW,
999b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_min_residual), 0, sysctl_sctp_check, "IU",
1000851b7298SRandall Stewart     SCTPCTL_MIN_RESIDUAL_DESC);
1001851b7298SRandall Stewart 
1002851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, max_retran_chunk, CTLTYPE_INT | CTLFLAG_RW,
1003b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_max_retran_chunk), 0, sysctl_sctp_check, "IU",
1004851b7298SRandall Stewart     SCTPCTL_MAX_RETRAN_CHUNK_DESC);
1005851b7298SRandall Stewart 
1006b27a6b7dSRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, log_level, CTLTYPE_INT | CTLFLAG_RW,
1007b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_logging_level), 0, sysctl_sctp_check, "IU",
1008851b7298SRandall Stewart     SCTPCTL_LOGGING_LEVEL_DESC);
1009851b7298SRandall Stewart 
1010851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, default_cc_module, CTLTYPE_INT | CTLFLAG_RW,
1011b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_default_cc_module), 0, sysctl_sctp_check, "IU",
1012851b7298SRandall Stewart     SCTPCTL_DEFAULT_CC_MODULE_DESC);
1013851b7298SRandall Stewart 
1014851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, default_frag_interleave, CTLTYPE_INT | CTLFLAG_RW,
1015b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_default_frag_interleave), 0, sysctl_sctp_check, "IU",
1016c4739e2fSRandall Stewart     SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DESC);
1017c4739e2fSRandall Stewart 
1018851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mobility_base, CTLTYPE_INT | CTLFLAG_RW,
1019b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_mobility_base), 0, sysctl_sctp_check, "IU",
1020851b7298SRandall Stewart     SCTPCTL_MOBILITY_BASE_DESC);
102142551e99SRandall Stewart 
1022851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mobility_fasthandoff, CTLTYPE_INT | CTLFLAG_RW,
1023b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff), 0, sysctl_sctp_check, "IU",
1024851b7298SRandall Stewart     SCTPCTL_MOBILITY_FASTHANDOFF_DESC);
102542551e99SRandall Stewart 
1026b27a6b7dSRandall Stewart #if defined(SCTP_LOCAL_TRACE_BUF)
1027b27a6b7dSRandall Stewart SYSCTL_STRUCT(_net_inet_sctp, OID_AUTO, log, CTLFLAG_RD,
1028b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_log), sctp_log,
1029b27a6b7dSRandall Stewart     "SCTP logging (struct sctp_log)");
1030b3f1ea41SRandall Stewart 
1031b3f1ea41SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, clear_trace, CTLTYPE_OPAQUE | CTLFLAG_RW,
1032b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_log), 0, sysctl_sctp_cleartrace, "IU",
1033b3f1ea41SRandall Stewart     "Clear SCTP Logging buffer");
1034b3f1ea41SRandall Stewart 
1035b3f1ea41SRandall Stewart 
1036b3f1ea41SRandall Stewart 
1037b27a6b7dSRandall Stewart #endif
1038b27a6b7dSRandall Stewart 
1039c54a18d2SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, udp_tunneling_for_client_enable, CTLTYPE_INT | CTLFLAG_RW,
1040b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_udp_tunneling_for_client_enable), 0, sysctl_sctp_check, "IU",
1041c54a18d2SRandall Stewart     SCTPCTL_UDP_TUNNELING_FOR_CLIENT_ENABLE_DESC);
1042c54a18d2SRandall Stewart 
1043c54a18d2SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, udp_tunneling_port, CTLTYPE_INT | CTLFLAG_RW,
1044b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_udp_tunneling_port), 0, sysctl_sctp_udp_tunneling_check, "IU",
1045c54a18d2SRandall Stewart     SCTPCTL_UDP_TUNNELING_PORT_DESC);
1046c54a18d2SRandall Stewart 
1047b3f1ea41SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, enable_sack_immediately, CTLTYPE_INT | CTLFLAG_RW,
1048b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_enable_sack_immediately), 0, sysctl_sctp_check, "IU",
1049b3f1ea41SRandall Stewart     SCTPCTL_SACK_IMMEDIATELY_ENABLE_DESC);
1050b3f1ea41SRandall Stewart 
1051830d754dSRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, nat_friendly_init, CTLTYPE_INT | CTLFLAG_RW,
1052830d754dSRandall Stewart     &SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly), 0, sysctl_sctp_check, "IU",
1053bf3d5177SMichael Tuexen     SCTPCTL_NAT_FRIENDLY_INITS_DESC);
1054830d754dSRandall Stewart 
1055a16ccdceSRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, vtag_time_wait, CTLTYPE_INT | CTLFLAG_RW,
1056a16ccdceSRandall Stewart     &SCTP_BASE_SYSCTL(sctp_vtag_time_wait), 0, sysctl_sctp_check, "IU",
1057a16ccdceSRandall Stewart     SCTPCTL_TIME_WAIT_DESC);
1058a16ccdceSRandall Stewart 
1059851b7298SRandall Stewart #ifdef SCTP_DEBUG
1060851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, debug, CTLTYPE_INT | CTLFLAG_RW,
1061b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_debug_on), 0, sysctl_sctp_check, "IU",
1062851b7298SRandall Stewart     SCTPCTL_DEBUG_DESC);
1063851b7298SRandall Stewart #endif				/* SCTP_DEBUG */
106442551e99SRandall Stewart 
106542551e99SRandall Stewart 
1066b3f1ea41SRandall Stewart #if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
1067b3f1ea41SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, output_unlocked, CTLTYPE_INT | CTLFLAG_RW,
1068b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_output_unlocked), 0, sysctl_sctp_check, "IU",
1069b3f1ea41SRandall Stewart     SCTPCTL_OUTPUT_UNLOCKED_DESC);
1070b3f1ea41SRandall Stewart #endif
1071ff014514SRandall Stewart #if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
1072ff014514SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, stats,
1073ff014514SRandall Stewart     CTLTYPE_STRUCT | CTLFLAG_RD,
1074ff014514SRandall Stewart     0, 0, sysctl_stat_get, "S,sctpstat",
1075ff014514SRandall Stewart     "SCTP statistics (struct sctp_stat)");
1076ff014514SRandall Stewart #else
107742551e99SRandall Stewart SYSCTL_STRUCT(_net_inet_sctp, OID_AUTO, stats, CTLFLAG_RW,
10788518270eSMichael Tuexen     &SCTP_BASE_STATS_SYSCTL, sctpstat,
1079b27a6b7dSRandall Stewart     "SCTP statistics (struct sctp_stat)");
1080ff014514SRandall Stewart #endif
108142551e99SRandall Stewart 
108242551e99SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, assoclist, CTLFLAG_RD,
108342551e99SRandall Stewart     0, 0, sctp_assoclist,
108442551e99SRandall Stewart     "S,xassoc", "List of active SCTP associations");
1085