xref: /freebsd/sys/netinet/sctp_sysctl.c (revision 25a2a18706da5396dde26e3b2271b687c972ee57)
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;
579c7635e1SMichael Tuexen #if !defined(SCTP_WITH_NO_CSUM)
58b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback) = SCTPCTL_LOOPBACK_NOCSUM_DEFAULT;
599c7635e1SMichael Tuexen #endif
60b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_strict_init) = SCTPCTL_STRICT_INIT_DEFAULT;
61b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_peer_chunk_oh) = SCTPCTL_PEER_CHKOH_DEFAULT;
62b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_max_burst_default) = SCTPCTL_MAXBURST_DEFAULT;
63b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue) = SCTPCTL_MAXCHUNKS_DEFAULT;
64b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_hashtblsize) = SCTPCTL_TCBHASHSIZE_DEFAULT;
65b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_pcbtblsize) = SCTPCTL_PCBHASHSIZE_DEFAULT;
66b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_min_split_point) = SCTPCTL_MIN_SPLIT_POINT_DEFAULT;
67b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_chunkscale) = SCTPCTL_CHUNKSCALE_DEFAULT;
68b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default) = SCTPCTL_DELAYED_SACK_TIME_DEFAULT;
69b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_sack_freq_default) = SCTPCTL_SACK_FREQ_DEFAULT;
70b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_system_free_resc_limit) = SCTPCTL_SYS_RESOURCE_DEFAULT;
71b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit) = SCTPCTL_ASOC_RESOURCE_DEFAULT;
72b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default) = SCTPCTL_HEARTBEAT_INTERVAL_DEFAULT;
73b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default) = SCTPCTL_PMTU_RAISE_TIME_DEFAULT;
74b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default) = SCTPCTL_SHUTDOWN_GUARD_TIME_DEFAULT;
75b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_secret_lifetime_default) = SCTPCTL_SECRET_LIFETIME_DEFAULT;
76b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_rto_max_default) = SCTPCTL_RTO_MAX_DEFAULT;
77b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_rto_min_default) = SCTPCTL_RTO_MIN_DEFAULT;
78b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_rto_initial_default) = SCTPCTL_RTO_INITIAL_DEFAULT;
79b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_init_rto_max_default) = SCTPCTL_INIT_RTO_MAX_DEFAULT;
80b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default) = SCTPCTL_VALID_COOKIE_LIFE_DEFAULT;
81b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_init_rtx_max_default) = SCTPCTL_INIT_RTX_MAX_DEFAULT;
82b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default) = SCTPCTL_ASSOC_RTX_MAX_DEFAULT;
83b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_path_rtx_max_default) = SCTPCTL_PATH_RTX_MAX_DEFAULT;
84b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_add_more_threshold) = SCTPCTL_ADD_MORE_ON_OUTPUT_DEFAULT;
85b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default) = SCTPCTL_OUTGOING_STREAMS_DEFAULT;
86b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_cmt_on_off) = SCTPCTL_CMT_ON_OFF_DEFAULT;
87830d754dSRandall Stewart 	/* EY */
88830d754dSRandall Stewart 	SCTP_BASE_SYSCTL(sctp_nr_sack_on_off) = SCTPCTL_NR_SACK_ON_OFF_DEFAULT;
89b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_cmt_use_dac) = SCTPCTL_CMT_USE_DAC_DEFAULT;
90b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_cmt_pf) = SCTPCTL_CMT_PF_DEFAULT;
91b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst) = SCTPCTL_CWND_MAXBURST_DEFAULT;
92b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_early_fr) = SCTPCTL_EARLY_FAST_RETRAN_DEFAULT;
93b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_early_fr_msec) = SCTPCTL_EARLY_FAST_RETRAN_MSEC_DEFAULT;
94b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_asconf_auth_nochk) = SCTPCTL_ASCONF_AUTH_NOCHK_DEFAULT;
95b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_auth_disable) = SCTPCTL_AUTH_DISABLE_DEFAULT;
96b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_nat_friendly) = SCTPCTL_NAT_FRIENDLY_DEFAULT;
97b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_L2_abc_variable) = SCTPCTL_ABC_L_VAR_DEFAULT;
98b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count) = SCTPCTL_MAX_CHAINED_MBUFS_DEFAULT;
99b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_do_drain) = SCTPCTL_DO_SCTP_DRAIN_DEFAULT;
100b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_hb_maxburst) = SCTPCTL_HB_MAX_BURST_DEFAULT;
101b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit) = SCTPCTL_ABORT_AT_LIMIT_DEFAULT;
102b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_strict_data_order) = SCTPCTL_STRICT_DATA_ORDER_DEFAULT;
103b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_min_residual) = SCTPCTL_MIN_RESIDUAL_DEFAULT;
104b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_max_retran_chunk) = SCTPCTL_MAX_RETRAN_CHUNK_DEFAULT;
105b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_logging_level) = SCTPCTL_LOGGING_LEVEL_DEFAULT;
106b54d3a6cSRandall Stewart 	/* JRS - Variable for default congestion control module */
107b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_default_cc_module) = SCTPCTL_DEFAULT_CC_MODULE_DEFAULT;
108b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_default_frag_interleave) = SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DEFAULT;
109b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_mobility_base) = SCTPCTL_MOBILITY_BASE_DEFAULT;
110b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff) = SCTPCTL_MOBILITY_FASTHANDOFF_DEFAULT;
111a16ccdceSRandall Stewart 	SCTP_BASE_SYSCTL(sctp_vtag_time_wait) = SCTPCTL_TIME_WAIT_DEFAULT;
112*25a2a187SMichael Tuexen 	SCTP_BASE_SYSCTL(sctp_buffer_splitting) = SCTPCTL_BUFFER_SPLITTING_DEFAULT;
113b27a6b7dSRandall Stewart #if defined(SCTP_LOCAL_TRACE_BUF)
114b3f1ea41SRandall Stewart 	memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log));
115b27a6b7dSRandall Stewart #endif
116b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_udp_tunneling_for_client_enable) = SCTPCTL_UDP_TUNNELING_FOR_CLIENT_ENABLE_DEFAULT;
117b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = SCTPCTL_UDP_TUNNELING_PORT_DEFAULT;
118b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_enable_sack_immediately) = SCTPCTL_SACK_IMMEDIATELY_ENABLE_DEFAULT;
119bf3d5177SMichael Tuexen 	SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly) = SCTPCTL_NAT_FRIENDLY_INITS_DEFAULT;
120b3f1ea41SRandall Stewart #if defined(SCTP_DEBUG)
121b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_debug_on) = SCTPCTL_DEBUG_DEFAULT;
12242551e99SRandall Stewart #endif
123b3f1ea41SRandall Stewart #if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
124b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_output_unlocked) = SCTPCTL_OUTPUT_UNLOCKED_DEFAULT;
125b3f1ea41SRandall Stewart #endif
126b3f1ea41SRandall Stewart }
127d61a0ae0SRandall Stewart 
128a99b6783SRandall Stewart 
129d61a0ae0SRandall Stewart /* It returns an upper limit. No filtering is done here */
130d61a0ae0SRandall Stewart static unsigned int
131d61a0ae0SRandall Stewart number_of_addresses(struct sctp_inpcb *inp)
132d61a0ae0SRandall Stewart {
133d61a0ae0SRandall Stewart 	int cnt;
134d61a0ae0SRandall Stewart 	struct sctp_vrf *vrf;
135d61a0ae0SRandall Stewart 	struct sctp_ifn *sctp_ifn;
136d61a0ae0SRandall Stewart 	struct sctp_ifa *sctp_ifa;
137d61a0ae0SRandall Stewart 	struct sctp_laddr *laddr;
138d61a0ae0SRandall Stewart 
139d61a0ae0SRandall Stewart 	cnt = 0;
140d61a0ae0SRandall Stewart 	/* neither Mac OS X nor FreeBSD support mulitple routing functions */
141d61a0ae0SRandall Stewart 	if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) {
142d61a0ae0SRandall Stewart 		return (0);
143d61a0ae0SRandall Stewart 	}
144d61a0ae0SRandall Stewart 	if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
145d61a0ae0SRandall Stewart 		LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
146d61a0ae0SRandall Stewart 			LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
147d61a0ae0SRandall Stewart 				if ((sctp_ifa->address.sa.sa_family == AF_INET) ||
148d61a0ae0SRandall Stewart 				    (sctp_ifa->address.sa.sa_family == AF_INET6)) {
149d61a0ae0SRandall Stewart 					cnt++;
150d61a0ae0SRandall Stewart 				}
151d61a0ae0SRandall Stewart 			}
152d61a0ae0SRandall Stewart 		}
153d61a0ae0SRandall Stewart 	} else {
154d61a0ae0SRandall Stewart 		LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
155d61a0ae0SRandall Stewart 			if ((laddr->ifa->address.sa.sa_family == AF_INET) ||
156d61a0ae0SRandall Stewart 			    (laddr->ifa->address.sa.sa_family == AF_INET6)) {
157d61a0ae0SRandall Stewart 				cnt++;
158d61a0ae0SRandall Stewart 			}
159d61a0ae0SRandall Stewart 		}
160d61a0ae0SRandall Stewart 	}
161d61a0ae0SRandall Stewart 	return (cnt);
162d61a0ae0SRandall Stewart }
163d61a0ae0SRandall Stewart 
164d61a0ae0SRandall Stewart static int
165d61a0ae0SRandall Stewart copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sysctl_req *req)
166d61a0ae0SRandall Stewart {
167d61a0ae0SRandall Stewart 	struct sctp_ifn *sctp_ifn;
168d61a0ae0SRandall Stewart 	struct sctp_ifa *sctp_ifa;
169d61a0ae0SRandall Stewart 	int loopback_scope, ipv4_local_scope, local_scope, site_scope;
170d61a0ae0SRandall Stewart 	int ipv4_addr_legal, ipv6_addr_legal;
171d61a0ae0SRandall Stewart 	struct sctp_vrf *vrf;
172d61a0ae0SRandall Stewart 	struct xsctp_laddr xladdr;
173d61a0ae0SRandall Stewart 	struct sctp_laddr *laddr;
174d61a0ae0SRandall Stewart 	int error;
175d61a0ae0SRandall Stewart 
176d61a0ae0SRandall Stewart 	/* Turn on all the appropriate scope */
177d61a0ae0SRandall Stewart 	if (stcb) {
178d61a0ae0SRandall Stewart 		/* use association specific values */
179d61a0ae0SRandall Stewart 		loopback_scope = stcb->asoc.loopback_scope;
180d61a0ae0SRandall Stewart 		ipv4_local_scope = stcb->asoc.ipv4_local_scope;
181d61a0ae0SRandall Stewart 		local_scope = stcb->asoc.local_scope;
182d61a0ae0SRandall Stewart 		site_scope = stcb->asoc.site_scope;
183d61a0ae0SRandall Stewart 	} else {
184d61a0ae0SRandall Stewart 		/* use generic values for endpoints */
185d61a0ae0SRandall Stewart 		loopback_scope = 1;
186d61a0ae0SRandall Stewart 		ipv4_local_scope = 1;
187d61a0ae0SRandall Stewart 		local_scope = 1;
188d61a0ae0SRandall Stewart 		site_scope = 1;
189d61a0ae0SRandall Stewart 	}
190d61a0ae0SRandall Stewart 
191d61a0ae0SRandall Stewart 	/* use only address families of interest */
192d61a0ae0SRandall Stewart 	if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) {
193d61a0ae0SRandall Stewart 		ipv6_addr_legal = 1;
194d61a0ae0SRandall Stewart 		if (SCTP_IPV6_V6ONLY(inp)) {
195d61a0ae0SRandall Stewart 			ipv4_addr_legal = 0;
196d61a0ae0SRandall Stewart 		} else {
197d61a0ae0SRandall Stewart 			ipv4_addr_legal = 1;
198d61a0ae0SRandall Stewart 		}
199d61a0ae0SRandall Stewart 	} else {
200d61a0ae0SRandall Stewart 		ipv4_addr_legal = 1;
201d61a0ae0SRandall Stewart 		ipv6_addr_legal = 0;
202d61a0ae0SRandall Stewart 	}
203d61a0ae0SRandall Stewart 
204d61a0ae0SRandall Stewart 	/* neither Mac OS X nor FreeBSD support mulitple routing functions */
205d61a0ae0SRandall Stewart 	if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) {
2065f26a41dSRandall Stewart 		SCTP_INP_RUNLOCK(inp);
2075f26a41dSRandall Stewart 		SCTP_INP_INFO_RUNLOCK();
208d61a0ae0SRandall Stewart 		return (-1);
209d61a0ae0SRandall Stewart 	}
210d61a0ae0SRandall Stewart 	if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
211d61a0ae0SRandall Stewart 		LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
212d61a0ae0SRandall Stewart 			if ((loopback_scope == 0) && SCTP_IFN_IS_IFT_LOOP(sctp_ifn))
213d61a0ae0SRandall Stewart 				/* Skip loopback if loopback_scope not set */
214d61a0ae0SRandall Stewart 				continue;
215d61a0ae0SRandall Stewart 			LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
216d61a0ae0SRandall Stewart 				if (stcb) {
217d61a0ae0SRandall Stewart 					/*
218d61a0ae0SRandall Stewart 					 * ignore if blacklisted at
219d61a0ae0SRandall Stewart 					 * association level
220d61a0ae0SRandall Stewart 					 */
221d61a0ae0SRandall Stewart 					if (sctp_is_addr_restricted(stcb, sctp_ifa))
222d61a0ae0SRandall Stewart 						continue;
223d61a0ae0SRandall Stewart 				}
2245e2c2d87SRandall Stewart 				switch (sctp_ifa->address.sa.sa_family) {
2255e2c2d87SRandall Stewart 				case AF_INET:
2265e2c2d87SRandall Stewart 					if (ipv4_addr_legal) {
227d61a0ae0SRandall Stewart 						struct sockaddr_in *sin;
228d61a0ae0SRandall Stewart 
229d61a0ae0SRandall Stewart 						sin = (struct sockaddr_in *)&sctp_ifa->address.sa;
230d61a0ae0SRandall Stewart 						if (sin->sin_addr.s_addr == 0)
231d61a0ae0SRandall Stewart 							continue;
232d61a0ae0SRandall Stewart 						if ((ipv4_local_scope == 0) && (IN4_ISPRIVATE_ADDRESS(&sin->sin_addr)))
233d61a0ae0SRandall Stewart 							continue;
2345e2c2d87SRandall Stewart 					} else {
2355e2c2d87SRandall Stewart 						continue;
2365e2c2d87SRandall Stewart 					}
2375e2c2d87SRandall Stewart 					break;
2385e2c2d87SRandall Stewart #ifdef INET6
2395e2c2d87SRandall Stewart 				case AF_INET6:
2405e2c2d87SRandall Stewart 					if (ipv6_addr_legal) {
241d61a0ae0SRandall Stewart 						struct sockaddr_in6 *sin6;
242d61a0ae0SRandall Stewart 
243d61a0ae0SRandall Stewart 						sin6 = (struct sockaddr_in6 *)&sctp_ifa->address.sa;
244d61a0ae0SRandall Stewart 						if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr))
245d61a0ae0SRandall Stewart 							continue;
246d61a0ae0SRandall Stewart 						if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
247d61a0ae0SRandall Stewart 							if (local_scope == 0)
248d61a0ae0SRandall Stewart 								continue;
249d61a0ae0SRandall Stewart 							if (sin6->sin6_scope_id == 0) {
250d61a0ae0SRandall Stewart 								/*
2515e2c2d87SRandall Stewart 								 * bad link
2525e2c2d87SRandall Stewart 								 * local
253d61a0ae0SRandall Stewart 								 * address
254d61a0ae0SRandall Stewart 								 */
255d61a0ae0SRandall Stewart 								if (sa6_recoverscope(sin6) != 0)
256d61a0ae0SRandall Stewart 									continue;
257d61a0ae0SRandall Stewart 							}
258d61a0ae0SRandall Stewart 						}
259d61a0ae0SRandall Stewart 						if ((site_scope == 0) && (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)))
260d61a0ae0SRandall Stewart 							continue;
2615e2c2d87SRandall Stewart 					} else {
262d61a0ae0SRandall Stewart 						continue;
2635e2c2d87SRandall Stewart 					}
2645e2c2d87SRandall Stewart 					break;
2655e2c2d87SRandall Stewart #endif
2665e2c2d87SRandall Stewart 				default:
2675e2c2d87SRandall Stewart 					continue;
2685e2c2d87SRandall Stewart 				}
269851b7298SRandall Stewart 				memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
270d61a0ae0SRandall Stewart 				memcpy((void *)&xladdr.address, (const void *)&sctp_ifa->address, sizeof(union sctp_sockstore));
271d61a0ae0SRandall Stewart 				SCTP_INP_RUNLOCK(inp);
272d61a0ae0SRandall Stewart 				SCTP_INP_INFO_RUNLOCK();
273d61a0ae0SRandall Stewart 				error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
274851b7298SRandall Stewart 				if (error) {
275d61a0ae0SRandall Stewart 					return (error);
276851b7298SRandall Stewart 				} else {
277d61a0ae0SRandall Stewart 					SCTP_INP_INFO_RLOCK();
278d61a0ae0SRandall Stewart 					SCTP_INP_RLOCK(inp);
279d61a0ae0SRandall Stewart 				}
280d61a0ae0SRandall Stewart 			}
281d61a0ae0SRandall Stewart 		}
282d61a0ae0SRandall Stewart 	} else {
283d61a0ae0SRandall Stewart 		LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
284d61a0ae0SRandall Stewart 			/* ignore if blacklisted at association level */
285d61a0ae0SRandall Stewart 			if (stcb && sctp_is_addr_restricted(stcb, laddr->ifa))
286d61a0ae0SRandall Stewart 				continue;
287851b7298SRandall Stewart 			memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
288d61a0ae0SRandall Stewart 			memcpy((void *)&xladdr.address, (const void *)&laddr->ifa->address, sizeof(union sctp_sockstore));
289851b7298SRandall Stewart 			xladdr.start_time.tv_sec = (uint32_t) laddr->start_time.tv_sec;
290851b7298SRandall Stewart 			xladdr.start_time.tv_usec = (uint32_t) laddr->start_time.tv_usec;
291d61a0ae0SRandall Stewart 			SCTP_INP_RUNLOCK(inp);
292d61a0ae0SRandall Stewart 			SCTP_INP_INFO_RUNLOCK();
293d61a0ae0SRandall Stewart 			error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
294851b7298SRandall Stewart 			if (error) {
295d61a0ae0SRandall Stewart 				return (error);
296851b7298SRandall Stewart 			} else {
297d61a0ae0SRandall Stewart 				SCTP_INP_INFO_RLOCK();
298d61a0ae0SRandall Stewart 				SCTP_INP_RLOCK(inp);
299d61a0ae0SRandall Stewart 			}
300d61a0ae0SRandall Stewart 		}
301d61a0ae0SRandall Stewart 	}
302851b7298SRandall Stewart 	memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
303d61a0ae0SRandall Stewart 	xladdr.last = 1;
3045f26a41dSRandall Stewart 	SCTP_INP_RUNLOCK(inp);
3055f26a41dSRandall Stewart 	SCTP_INP_INFO_RUNLOCK();
306d61a0ae0SRandall Stewart 	error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
3075f26a41dSRandall Stewart 
308851b7298SRandall Stewart 	if (error) {
309d61a0ae0SRandall Stewart 		return (error);
310851b7298SRandall Stewart 	} else {
3115f26a41dSRandall Stewart 		SCTP_INP_INFO_RLOCK();
3125f26a41dSRandall Stewart 		SCTP_INP_RLOCK(inp);
313d61a0ae0SRandall Stewart 		return (0);
314d61a0ae0SRandall Stewart 	}
3155f26a41dSRandall Stewart }
316d61a0ae0SRandall Stewart 
31742551e99SRandall Stewart /*
31842551e99SRandall Stewart  * sysctl functions
31942551e99SRandall Stewart  */
32042551e99SRandall Stewart static int
32142551e99SRandall Stewart sctp_assoclist(SYSCTL_HANDLER_ARGS)
32242551e99SRandall Stewart {
32342551e99SRandall Stewart 	unsigned int number_of_endpoints;
32442551e99SRandall Stewart 	unsigned int number_of_local_addresses;
32542551e99SRandall Stewart 	unsigned int number_of_associations;
32642551e99SRandall Stewart 	unsigned int number_of_remote_addresses;
32742551e99SRandall Stewart 	unsigned int n;
32842551e99SRandall Stewart 	int error;
32942551e99SRandall Stewart 	struct sctp_inpcb *inp;
33042551e99SRandall Stewart 	struct sctp_tcb *stcb;
33142551e99SRandall Stewart 	struct sctp_nets *net;
33242551e99SRandall Stewart 	struct xsctp_inpcb xinpcb;
33342551e99SRandall Stewart 	struct xsctp_tcb xstcb;
33442551e99SRandall Stewart 	struct xsctp_raddr xraddr;
3358ce4a9a2SRandall Stewart 	struct socket *so;
33642551e99SRandall Stewart 
33742551e99SRandall Stewart 	number_of_endpoints = 0;
33842551e99SRandall Stewart 	number_of_local_addresses = 0;
33942551e99SRandall Stewart 	number_of_associations = 0;
34042551e99SRandall Stewart 	number_of_remote_addresses = 0;
34142551e99SRandall Stewart 
34242551e99SRandall Stewart 	SCTP_INP_INFO_RLOCK();
34342551e99SRandall Stewart 	if (req->oldptr == USER_ADDR_NULL) {
344b3f1ea41SRandall Stewart 		LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
34542551e99SRandall Stewart 			SCTP_INP_RLOCK(inp);
34642551e99SRandall Stewart 			number_of_endpoints++;
347d61a0ae0SRandall Stewart 			number_of_local_addresses += number_of_addresses(inp);
34842551e99SRandall Stewart 			LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
34942551e99SRandall Stewart 				number_of_associations++;
350d61a0ae0SRandall Stewart 				number_of_local_addresses += number_of_addresses(inp);
35142551e99SRandall Stewart 				TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
35242551e99SRandall Stewart 					number_of_remote_addresses++;
35342551e99SRandall Stewart 				}
35442551e99SRandall Stewart 			}
35542551e99SRandall Stewart 			SCTP_INP_RUNLOCK(inp);
35642551e99SRandall Stewart 		}
35742551e99SRandall Stewart 		SCTP_INP_INFO_RUNLOCK();
35842551e99SRandall Stewart 		n = (number_of_endpoints + 1) * sizeof(struct xsctp_inpcb) +
359d61a0ae0SRandall Stewart 		    (number_of_local_addresses + number_of_endpoints + number_of_associations) * sizeof(struct xsctp_laddr) +
360d61a0ae0SRandall Stewart 		    (number_of_associations + number_of_endpoints) * sizeof(struct xsctp_tcb) +
361d61a0ae0SRandall Stewart 		    (number_of_remote_addresses + number_of_associations) * sizeof(struct xsctp_raddr);
362d61a0ae0SRandall Stewart 
36342551e99SRandall Stewart 		/* request some more memory than needed */
36442551e99SRandall Stewart 		req->oldidx = (n + n / 8);
36542551e99SRandall Stewart 		return 0;
36642551e99SRandall Stewart 	}
36742551e99SRandall Stewart 	if (req->newptr != USER_ADDR_NULL) {
36842551e99SRandall Stewart 		SCTP_INP_INFO_RUNLOCK();
369c4739e2fSRandall Stewart 		SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_SYSCTL, EPERM);
37042551e99SRandall Stewart 		return EPERM;
37142551e99SRandall Stewart 	}
372b3f1ea41SRandall Stewart 	LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
37342551e99SRandall Stewart 		SCTP_INP_RLOCK(inp);
3748ce4a9a2SRandall Stewart 		if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
3758ce4a9a2SRandall Stewart 			/* if its allgone it is being freed - skip it  */
3768ce4a9a2SRandall Stewart 			goto skip;
3778ce4a9a2SRandall Stewart 		}
37842551e99SRandall Stewart 		xinpcb.last = 0;
37942551e99SRandall Stewart 		xinpcb.local_port = ntohs(inp->sctp_lport);
38042551e99SRandall Stewart 		xinpcb.flags = inp->sctp_flags;
38142551e99SRandall Stewart 		xinpcb.features = inp->sctp_features;
38242551e99SRandall Stewart 		xinpcb.total_sends = inp->total_sends;
38342551e99SRandall Stewart 		xinpcb.total_recvs = inp->total_recvs;
38442551e99SRandall Stewart 		xinpcb.total_nospaces = inp->total_nospaces;
38517205eccSRandall Stewart 		xinpcb.fragmentation_point = inp->sctp_frag_point;
3868ce4a9a2SRandall Stewart 		so = inp->sctp_socket;
3878ce4a9a2SRandall Stewart 		if ((so == NULL) ||
388851b7298SRandall Stewart 		    (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) {
389851b7298SRandall Stewart 			xinpcb.qlen = 0;
390851b7298SRandall Stewart 			xinpcb.maxqlen = 0;
391851b7298SRandall Stewart 		} else {
3928ce4a9a2SRandall Stewart 			xinpcb.qlen = so->so_qlen;
3938ce4a9a2SRandall Stewart 			xinpcb.maxqlen = so->so_qlimit;
394851b7298SRandall Stewart 		}
39542551e99SRandall Stewart 		SCTP_INP_INCR_REF(inp);
39642551e99SRandall Stewart 		SCTP_INP_RUNLOCK(inp);
39742551e99SRandall Stewart 		SCTP_INP_INFO_RUNLOCK();
39842551e99SRandall Stewart 		error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb));
39942551e99SRandall Stewart 		if (error) {
400d61a0ae0SRandall Stewart 			SCTP_INP_DECR_REF(inp);
40142551e99SRandall Stewart 			return error;
40242551e99SRandall Stewart 		}
40342551e99SRandall Stewart 		SCTP_INP_INFO_RLOCK();
40442551e99SRandall Stewart 		SCTP_INP_RLOCK(inp);
405d61a0ae0SRandall Stewart 		error = copy_out_local_addresses(inp, NULL, req);
406d61a0ae0SRandall Stewart 		if (error) {
407d61a0ae0SRandall Stewart 			SCTP_INP_DECR_REF(inp);
408d61a0ae0SRandall Stewart 			return error;
409d61a0ae0SRandall Stewart 		}
41042551e99SRandall Stewart 		LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
41142551e99SRandall Stewart 			SCTP_TCB_LOCK(stcb);
41242551e99SRandall Stewart 			atomic_add_int(&stcb->asoc.refcnt, 1);
41342551e99SRandall Stewart 			SCTP_TCB_UNLOCK(stcb);
414d61a0ae0SRandall Stewart 			xstcb.last = 0;
415d61a0ae0SRandall Stewart 			xstcb.local_port = ntohs(inp->sctp_lport);
416d61a0ae0SRandall Stewart 			xstcb.remote_port = ntohs(stcb->rport);
41742551e99SRandall Stewart 			if (stcb->asoc.primary_destination != NULL)
418d61a0ae0SRandall Stewart 				xstcb.primary_addr = stcb->asoc.primary_destination->ro._l_addr;
419d61a0ae0SRandall Stewart 			xstcb.heartbeat_interval = stcb->asoc.heart_beat_delay;
420d61a0ae0SRandall Stewart 			xstcb.state = SCTP_GET_STATE(&stcb->asoc);	/* FIXME */
4214f6b4933SRandall Stewart 			/* 7.0 does not support these */
422a99b6783SRandall Stewart 			xstcb.assoc_id = sctp_get_associd(stcb);
4234f6b4933SRandall Stewart 			xstcb.peers_rwnd = stcb->asoc.peers_rwnd;
424d61a0ae0SRandall Stewart 			xstcb.in_streams = stcb->asoc.streamincnt;
425d61a0ae0SRandall Stewart 			xstcb.out_streams = stcb->asoc.streamoutcnt;
426d61a0ae0SRandall Stewart 			xstcb.max_nr_retrans = stcb->asoc.overall_error_count;
427d61a0ae0SRandall Stewart 			xstcb.primary_process = 0;	/* not really supported
428d61a0ae0SRandall Stewart 							 * yet */
429d61a0ae0SRandall Stewart 			xstcb.T1_expireries = stcb->asoc.timoinit + stcb->asoc.timocookie;
430d61a0ae0SRandall Stewart 			xstcb.T2_expireries = stcb->asoc.timoshutdown + stcb->asoc.timoshutdownack;
431d61a0ae0SRandall Stewart 			xstcb.retransmitted_tsns = stcb->asoc.marked_retrans;
432851b7298SRandall Stewart 			xstcb.start_time.tv_sec = (uint32_t) stcb->asoc.start_time.tv_sec;
433851b7298SRandall Stewart 			xstcb.start_time.tv_usec = (uint32_t) stcb->asoc.start_time.tv_usec;
434851b7298SRandall Stewart 			xstcb.discontinuity_time.tv_sec = (uint32_t) stcb->asoc.discontinuity_time.tv_sec;
435851b7298SRandall Stewart 			xstcb.discontinuity_time.tv_usec = (uint32_t) stcb->asoc.discontinuity_time.tv_usec;
43642551e99SRandall Stewart 			xstcb.total_sends = stcb->total_sends;
43742551e99SRandall Stewart 			xstcb.total_recvs = stcb->total_recvs;
43842551e99SRandall Stewart 			xstcb.local_tag = stcb->asoc.my_vtag;
43942551e99SRandall Stewart 			xstcb.remote_tag = stcb->asoc.peer_vtag;
44042551e99SRandall Stewart 			xstcb.initial_tsn = stcb->asoc.init_seq_number;
44142551e99SRandall Stewart 			xstcb.highest_tsn = stcb->asoc.sending_seq - 1;
44242551e99SRandall Stewart 			xstcb.cumulative_tsn = stcb->asoc.last_acked_seq;
44342551e99SRandall Stewart 			xstcb.cumulative_tsn_ack = stcb->asoc.cumulative_tsn;
44417205eccSRandall Stewart 			xstcb.mtu = stcb->asoc.smallest_mtu;
445207304d4SRandall Stewart 			xstcb.refcnt = stcb->asoc.refcnt;
44642551e99SRandall Stewart 			SCTP_INP_RUNLOCK(inp);
44742551e99SRandall Stewart 			SCTP_INP_INFO_RUNLOCK();
44842551e99SRandall Stewart 			error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb));
44942551e99SRandall Stewart 			if (error) {
450d61a0ae0SRandall Stewart 				SCTP_INP_DECR_REF(inp);
451851b7298SRandall Stewart 				atomic_subtract_int(&stcb->asoc.refcnt, 1);
452d61a0ae0SRandall Stewart 				return error;
453d61a0ae0SRandall Stewart 			}
454d61a0ae0SRandall Stewart 			SCTP_INP_INFO_RLOCK();
455d61a0ae0SRandall Stewart 			SCTP_INP_RLOCK(inp);
456d61a0ae0SRandall Stewart 			error = copy_out_local_addresses(inp, stcb, req);
457d61a0ae0SRandall Stewart 			if (error) {
458d61a0ae0SRandall Stewart 				SCTP_INP_DECR_REF(inp);
459851b7298SRandall Stewart 				atomic_subtract_int(&stcb->asoc.refcnt, 1);
46042551e99SRandall Stewart 				return error;
46142551e99SRandall Stewart 			}
46242551e99SRandall Stewart 			TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
463d61a0ae0SRandall Stewart 				xraddr.last = 0;
464d61a0ae0SRandall Stewart 				xraddr.address = net->ro._l_addr;
465d61a0ae0SRandall Stewart 				xraddr.active = ((net->dest_state & SCTP_ADDR_REACHABLE) == SCTP_ADDR_REACHABLE);
466d61a0ae0SRandall Stewart 				xraddr.confirmed = ((net->dest_state & SCTP_ADDR_UNCONFIRMED) == 0);
467d61a0ae0SRandall Stewart 				xraddr.heartbeat_enabled = ((net->dest_state & SCTP_ADDR_NOHB) == 0);
468d61a0ae0SRandall Stewart 				xraddr.rto = net->RTO;
469d61a0ae0SRandall Stewart 				xraddr.max_path_rtx = net->failure_threshold;
470d61a0ae0SRandall Stewart 				xraddr.rtx = net->marked_retrans;
471d61a0ae0SRandall Stewart 				xraddr.error_counter = net->error_count;
472d61a0ae0SRandall Stewart 				xraddr.cwnd = net->cwnd;
473d61a0ae0SRandall Stewart 				xraddr.flight_size = net->flight_size;
474d61a0ae0SRandall Stewart 				xraddr.mtu = net->mtu;
475e29d4aa6SRandall Stewart 				xraddr.rtt = net->rtt;
476851b7298SRandall Stewart 				xraddr.start_time.tv_sec = (uint32_t) net->start_time.tv_sec;
477851b7298SRandall Stewart 				xraddr.start_time.tv_usec = (uint32_t) net->start_time.tv_usec;
478d61a0ae0SRandall Stewart 				SCTP_INP_RUNLOCK(inp);
479d61a0ae0SRandall Stewart 				SCTP_INP_INFO_RUNLOCK();
48042551e99SRandall Stewart 				error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr));
48142551e99SRandall Stewart 				if (error) {
482d61a0ae0SRandall Stewart 					SCTP_INP_DECR_REF(inp);
483851b7298SRandall Stewart 					atomic_subtract_int(&stcb->asoc.refcnt, 1);
48442551e99SRandall Stewart 					return error;
48542551e99SRandall Stewart 				}
48642551e99SRandall Stewart 				SCTP_INP_INFO_RLOCK();
48742551e99SRandall Stewart 				SCTP_INP_RLOCK(inp);
48842551e99SRandall Stewart 			}
489851b7298SRandall Stewart 			atomic_subtract_int(&stcb->asoc.refcnt, 1);
490d61a0ae0SRandall Stewart 			memset((void *)&xraddr, 0, sizeof(struct xsctp_raddr));
491d61a0ae0SRandall Stewart 			xraddr.last = 1;
49242551e99SRandall Stewart 			SCTP_INP_RUNLOCK(inp);
493d61a0ae0SRandall Stewart 			SCTP_INP_INFO_RUNLOCK();
494d61a0ae0SRandall Stewart 			error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr));
495d61a0ae0SRandall Stewart 			if (error) {
496d61a0ae0SRandall Stewart 				SCTP_INP_DECR_REF(inp);
497d61a0ae0SRandall Stewart 				return error;
498d61a0ae0SRandall Stewart 			}
499d61a0ae0SRandall Stewart 			SCTP_INP_INFO_RLOCK();
500d61a0ae0SRandall Stewart 			SCTP_INP_RLOCK(inp);
501d61a0ae0SRandall Stewart 		}
502851b7298SRandall Stewart 		SCTP_INP_DECR_REF(inp);
503d61a0ae0SRandall Stewart 		SCTP_INP_RUNLOCK(inp);
504d61a0ae0SRandall Stewart 		SCTP_INP_INFO_RUNLOCK();
505d61a0ae0SRandall Stewart 		memset((void *)&xstcb, 0, sizeof(struct xsctp_tcb));
506d61a0ae0SRandall Stewart 		xstcb.last = 1;
507d61a0ae0SRandall Stewart 		error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb));
508d61a0ae0SRandall Stewart 		if (error) {
509d61a0ae0SRandall Stewart 			return error;
510d61a0ae0SRandall Stewart 		}
5118ce4a9a2SRandall Stewart skip:
512d61a0ae0SRandall Stewart 		SCTP_INP_INFO_RLOCK();
51342551e99SRandall Stewart 	}
51442551e99SRandall Stewart 	SCTP_INP_INFO_RUNLOCK();
51542551e99SRandall Stewart 
516d61a0ae0SRandall Stewart 	memset((void *)&xinpcb, 0, sizeof(struct xsctp_inpcb));
51742551e99SRandall Stewart 	xinpcb.last = 1;
51842551e99SRandall Stewart 	error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb));
51942551e99SRandall Stewart 	return error;
52042551e99SRandall Stewart }
52142551e99SRandall Stewart 
522c54a18d2SRandall Stewart 
523851b7298SRandall Stewart #define RANGECHK(var, min, max) \
524851b7298SRandall Stewart 	if ((var) < (min)) { (var) = (min); } \
525851b7298SRandall Stewart 	else if ((var) > (max)) { (var) = (max); }
526851b7298SRandall Stewart 
527851b7298SRandall Stewart static int
528c54a18d2SRandall Stewart sysctl_sctp_udp_tunneling_check(SYSCTL_HANDLER_ARGS)
529c54a18d2SRandall Stewart {
530c54a18d2SRandall Stewart 	int error;
531c54a18d2SRandall Stewart 	uint32_t old_sctp_udp_tunneling_port;
532c54a18d2SRandall Stewart 
533be27fdd0SRandall Stewart 	SCTP_INP_INFO_RLOCK();
534b3f1ea41SRandall Stewart 	old_sctp_udp_tunneling_port = SCTP_BASE_SYSCTL(sctp_udp_tunneling_port);
535be27fdd0SRandall Stewart 	SCTP_INP_INFO_RUNLOCK();
536c54a18d2SRandall Stewart 	error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
537c54a18d2SRandall Stewart 	if (error == 0) {
538b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port), SCTPCTL_UDP_TUNNELING_PORT_MIN, SCTPCTL_UDP_TUNNELING_PORT_MAX);
539a99b6783SRandall Stewart 		if (old_sctp_udp_tunneling_port == SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)) {
540a99b6783SRandall Stewart 			error = 0;
541a99b6783SRandall Stewart 			goto out;
542a99b6783SRandall Stewart 		}
543be27fdd0SRandall Stewart 		SCTP_INP_INFO_WLOCK();
544c54a18d2SRandall Stewart 		if (old_sctp_udp_tunneling_port) {
545c54a18d2SRandall Stewart 			sctp_over_udp_stop();
546c54a18d2SRandall Stewart 		}
547b3f1ea41SRandall Stewart 		if (SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)) {
548c54a18d2SRandall Stewart 			if (sctp_over_udp_start()) {
549b3f1ea41SRandall Stewart 				SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = 0;
550c54a18d2SRandall Stewart 			}
551c54a18d2SRandall Stewart 		}
552be27fdd0SRandall Stewart 		SCTP_INP_INFO_WUNLOCK();
553c54a18d2SRandall Stewart 	}
554a99b6783SRandall Stewart out:
555c54a18d2SRandall Stewart 	return (error);
556c54a18d2SRandall Stewart }
557c54a18d2SRandall Stewart 
558b3f1ea41SRandall Stewart 
559c54a18d2SRandall Stewart static int
560851b7298SRandall Stewart sysctl_sctp_check(SYSCTL_HANDLER_ARGS)
561851b7298SRandall Stewart {
562851b7298SRandall Stewart 	int error;
563851b7298SRandall Stewart 
564851b7298SRandall Stewart 	error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
565851b7298SRandall Stewart 	if (error == 0) {
566b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_sendspace), SCTPCTL_MAXDGRAM_MIN, SCTPCTL_MAXDGRAM_MAX);
567b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_recvspace), SCTPCTL_RECVSPACE_MIN, SCTPCTL_RECVSPACE_MAX);
568b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_auto_asconf), SCTPCTL_AUTOASCONF_MIN, SCTPCTL_AUTOASCONF_MAX);
569b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_ecn_enable), SCTPCTL_ECN_ENABLE_MIN, SCTPCTL_ECN_ENABLE_MAX);
570b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_ecn_nonce), SCTPCTL_ECN_NONCE_MIN, SCTPCTL_ECN_NONCE_MAX);
571b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_strict_sacks), SCTPCTL_STRICT_SACKS_MIN, SCTPCTL_STRICT_SACKS_MAX);
5729c7635e1SMichael Tuexen #if !defined(SCTP_WITH_NO_CSUM)
573b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback), SCTPCTL_LOOPBACK_NOCSUM_MIN, SCTPCTL_LOOPBACK_NOCSUM_MAX);
5749c7635e1SMichael Tuexen #endif
575b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_strict_init), SCTPCTL_STRICT_INIT_MIN, SCTPCTL_STRICT_INIT_MAX);
576b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_peer_chunk_oh), SCTPCTL_PEER_CHKOH_MIN, SCTPCTL_PEER_CHKOH_MAX);
577b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_max_burst_default), SCTPCTL_MAXBURST_MIN, SCTPCTL_MAXBURST_MAX);
578b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue), SCTPCTL_MAXCHUNKS_MIN, SCTPCTL_MAXCHUNKS_MAX);
579b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_hashtblsize), SCTPCTL_TCBHASHSIZE_MIN, SCTPCTL_TCBHASHSIZE_MAX);
580b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_pcbtblsize), SCTPCTL_PCBHASHSIZE_MIN, SCTPCTL_PCBHASHSIZE_MAX);
581b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_min_split_point), SCTPCTL_MIN_SPLIT_POINT_MIN, SCTPCTL_MIN_SPLIT_POINT_MAX);
582b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_chunkscale), SCTPCTL_CHUNKSCALE_MIN, SCTPCTL_CHUNKSCALE_MAX);
583b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default), SCTPCTL_DELAYED_SACK_TIME_MIN, SCTPCTL_DELAYED_SACK_TIME_MAX);
584b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_sack_freq_default), SCTPCTL_SACK_FREQ_MIN, SCTPCTL_SACK_FREQ_MAX);
585b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_system_free_resc_limit), SCTPCTL_SYS_RESOURCE_MIN, SCTPCTL_SYS_RESOURCE_MAX);
586b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit), SCTPCTL_ASOC_RESOURCE_MIN, SCTPCTL_ASOC_RESOURCE_MAX);
587b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default), SCTPCTL_HEARTBEAT_INTERVAL_MIN, SCTPCTL_HEARTBEAT_INTERVAL_MAX);
588b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default), SCTPCTL_PMTU_RAISE_TIME_MIN, SCTPCTL_PMTU_RAISE_TIME_MAX);
589b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default), SCTPCTL_SHUTDOWN_GUARD_TIME_MIN, SCTPCTL_SHUTDOWN_GUARD_TIME_MAX);
590b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_secret_lifetime_default), SCTPCTL_SECRET_LIFETIME_MIN, SCTPCTL_SECRET_LIFETIME_MAX);
591b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_max_default), SCTPCTL_RTO_MAX_MIN, SCTPCTL_RTO_MAX_MAX);
592b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_min_default), SCTPCTL_RTO_MIN_MIN, SCTPCTL_RTO_MIN_MAX);
593b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_initial_default), SCTPCTL_RTO_INITIAL_MIN, SCTPCTL_RTO_INITIAL_MAX);
594b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_init_rto_max_default), SCTPCTL_INIT_RTO_MAX_MIN, SCTPCTL_INIT_RTO_MAX_MAX);
595b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default), SCTPCTL_VALID_COOKIE_LIFE_MIN, SCTPCTL_VALID_COOKIE_LIFE_MAX);
596b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_init_rtx_max_default), SCTPCTL_INIT_RTX_MAX_MIN, SCTPCTL_INIT_RTX_MAX_MAX);
597b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default), SCTPCTL_ASSOC_RTX_MAX_MIN, SCTPCTL_ASSOC_RTX_MAX_MAX);
598b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_path_rtx_max_default), SCTPCTL_PATH_RTX_MAX_MIN, SCTPCTL_PATH_RTX_MAX_MAX);
599b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_add_more_threshold), SCTPCTL_ADD_MORE_ON_OUTPUT_MIN, SCTPCTL_ADD_MORE_ON_OUTPUT_MAX);
600b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default), SCTPCTL_OUTGOING_STREAMS_MIN, SCTPCTL_OUTGOING_STREAMS_MAX);
601b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_on_off), SCTPCTL_CMT_ON_OFF_MIN, SCTPCTL_CMT_ON_OFF_MAX);
602830d754dSRandall Stewart 		/* EY */
603830d754dSRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_nr_sack_on_off), SCTPCTL_NR_SACK_ON_OFF_MIN, SCTPCTL_NR_SACK_ON_OFF_MAX);
604b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_use_dac), SCTPCTL_CMT_USE_DAC_MIN, SCTPCTL_CMT_USE_DAC_MAX);
605b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_pf), SCTPCTL_CMT_PF_MIN, SCTPCTL_CMT_PF_MAX);
606b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst), SCTPCTL_CWND_MAXBURST_MIN, SCTPCTL_CWND_MAXBURST_MAX);
607b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_early_fr), SCTPCTL_EARLY_FAST_RETRAN_MIN, SCTPCTL_EARLY_FAST_RETRAN_MAX);
608b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_early_fr_msec), SCTPCTL_EARLY_FAST_RETRAN_MSEC_MIN, SCTPCTL_EARLY_FAST_RETRAN_MSEC_MAX);
609b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_asconf_auth_nochk), SCTPCTL_ASCONF_AUTH_NOCHK_MIN, SCTPCTL_ASCONF_AUTH_NOCHK_MAX);
610b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_auth_disable), SCTPCTL_AUTH_DISABLE_MIN, SCTPCTL_AUTH_DISABLE_MAX);
611b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_nat_friendly), SCTPCTL_NAT_FRIENDLY_MIN, SCTPCTL_NAT_FRIENDLY_MAX);
612b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_L2_abc_variable), SCTPCTL_ABC_L_VAR_MIN, SCTPCTL_ABC_L_VAR_MAX);
613b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count), SCTPCTL_MAX_CHAINED_MBUFS_MIN, SCTPCTL_MAX_CHAINED_MBUFS_MAX);
614b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_do_drain), SCTPCTL_DO_SCTP_DRAIN_MIN, SCTPCTL_DO_SCTP_DRAIN_MAX);
615b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_hb_maxburst), SCTPCTL_HB_MAX_BURST_MIN, SCTPCTL_HB_MAX_BURST_MAX);
616b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit), SCTPCTL_ABORT_AT_LIMIT_MIN, SCTPCTL_ABORT_AT_LIMIT_MAX);
617b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_strict_data_order), SCTPCTL_STRICT_DATA_ORDER_MIN, SCTPCTL_STRICT_DATA_ORDER_MAX);
618b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_min_residual), SCTPCTL_MIN_RESIDUAL_MIN, SCTPCTL_MIN_RESIDUAL_MAX);
619b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_max_retran_chunk), SCTPCTL_MAX_RETRAN_CHUNK_MIN, SCTPCTL_MAX_RETRAN_CHUNK_MAX);
620b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_logging_level), SCTPCTL_LOGGING_LEVEL_MIN, SCTPCTL_LOGGING_LEVEL_MAX);
621b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_default_cc_module), SCTPCTL_DEFAULT_CC_MODULE_MIN, SCTPCTL_DEFAULT_CC_MODULE_MAX);
622b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_default_frag_interleave), SCTPCTL_DEFAULT_FRAG_INTERLEAVE_MIN, SCTPCTL_DEFAULT_FRAG_INTERLEAVE_MAX);
623a16ccdceSRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_vtag_time_wait), SCTPCTL_TIME_WAIT_MIN, SCTPCTL_TIME_WAIT_MAX);
624*25a2a187SMichael Tuexen 		RANGECHK(SCTP_BASE_SYSCTL(sctp_buffer_splitting), SCTPCTL_BUFFER_SPLITTING_MIN, SCTPCTL_BUFFER_SPLITTING_MAX);
625b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_mobility_base), SCTPCTL_MOBILITY_BASE_MIN, SCTPCTL_MOBILITY_BASE_MAX);
626b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff), SCTPCTL_MOBILITY_FASTHANDOFF_MIN, SCTPCTL_MOBILITY_FASTHANDOFF_MAX);
627b3f1ea41SRandall 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);
628b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_enable_sack_immediately), SCTPCTL_SACK_IMMEDIATELY_ENABLE_MIN, SCTPCTL_SACK_IMMEDIATELY_ENABLE_MAX);
629bf3d5177SMichael Tuexen 		RANGECHK(SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly), SCTPCTL_NAT_FRIENDLY_INITS_MIN, SCTPCTL_NAT_FRIENDLY_INITS_MAX);
630830d754dSRandall Stewart 
631851b7298SRandall Stewart #ifdef SCTP_DEBUG
632b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_debug_on), SCTPCTL_DEBUG_MIN, SCTPCTL_DEBUG_MAX);
633b3f1ea41SRandall Stewart #endif
634b3f1ea41SRandall Stewart #if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
635b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_output_unlocked), SCTPCTL_OUTPUT_UNLOCKED_MIN, SCTPCTL_OUTPUT_UNLOCKED_MAX);
636851b7298SRandall Stewart #endif
637851b7298SRandall Stewart 	}
638851b7298SRandall Stewart 	return (error);
639851b7298SRandall Stewart }
64042551e99SRandall Stewart 
641ff014514SRandall Stewart #if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
642ff014514SRandall Stewart static int
643ff014514SRandall Stewart sysctl_stat_get(SYSCTL_HANDLER_ARGS)
644ff014514SRandall Stewart {
645ff014514SRandall Stewart 	int cpu, error;
646ff014514SRandall Stewart 	struct sctpstat sb, *sarry;
647b3f1ea41SRandall Stewart 
648ff014514SRandall Stewart 	memset(&sb, 0, sizeof(sb));
649ff014514SRandall Stewart 	for (cpu = 0; cpu < mp_ncpus; cpu++) {
650ff014514SRandall Stewart 		sarry = &SCTP_BASE_STATS[cpu];
651ff014514SRandall Stewart 		if (sarry->sctps_discontinuitytime.tv_sec > sb.sctps_discontinuitytime.tv_sec) {
652ff014514SRandall Stewart 			sb.sctps_discontinuitytime.tv_sec = sarry->sctps_discontinuitytime.tv_sec;
653ff014514SRandall Stewart 			sb.sctps_discontinuitytime.tv_usec = sarry->sctps_discontinuitytime.tv_usec;
654ff014514SRandall Stewart 		}
655ff014514SRandall Stewart 		sb.sctps_currestab += sarry->sctps_currestab;
656ff014514SRandall Stewart 		sb.sctps_activeestab += sarry->sctps_activeestab;
657ff014514SRandall Stewart 		sb.sctps_restartestab += sarry->sctps_restartestab;
658ff014514SRandall Stewart 		sb.sctps_collisionestab += sarry->sctps_collisionestab;
659ff014514SRandall Stewart 		sb.sctps_passiveestab += sarry->sctps_passiveestab;
660ff014514SRandall Stewart 		sb.sctps_aborted += sarry->sctps_aborted;
661ff014514SRandall Stewart 		sb.sctps_shutdown += sarry->sctps_shutdown;
662ff014514SRandall Stewart 		sb.sctps_outoftheblue += sarry->sctps_outoftheblue;
663ff014514SRandall Stewart 		sb.sctps_checksumerrors += sarry->sctps_checksumerrors;
664ff014514SRandall Stewart 		sb.sctps_outcontrolchunks += sarry->sctps_outcontrolchunks;
665ff014514SRandall Stewart 		sb.sctps_outorderchunks += sarry->sctps_outorderchunks;
666ff014514SRandall Stewart 		sb.sctps_outunorderchunks += sarry->sctps_outunorderchunks;
667ff014514SRandall Stewart 		sb.sctps_incontrolchunks += sarry->sctps_incontrolchunks;
668ff014514SRandall Stewart 		sb.sctps_inorderchunks += sarry->sctps_inorderchunks;
669ff014514SRandall Stewart 		sb.sctps_inunorderchunks += sarry->sctps_inunorderchunks;
670ff014514SRandall Stewart 		sb.sctps_fragusrmsgs += sarry->sctps_fragusrmsgs;
671ff014514SRandall Stewart 		sb.sctps_reasmusrmsgs += sarry->sctps_reasmusrmsgs;
672ff014514SRandall Stewart 		sb.sctps_outpackets += sarry->sctps_outpackets;
673ff014514SRandall Stewart 		sb.sctps_inpackets += sarry->sctps_inpackets;
674ff014514SRandall Stewart 		sb.sctps_recvpackets += sarry->sctps_recvpackets;
675ff014514SRandall Stewart 		sb.sctps_recvdatagrams += sarry->sctps_recvdatagrams;
676ff014514SRandall Stewart 		sb.sctps_recvpktwithdata += sarry->sctps_recvpktwithdata;
677ff014514SRandall Stewart 		sb.sctps_recvsacks += sarry->sctps_recvsacks;
678ff014514SRandall Stewart 		sb.sctps_recvdata += sarry->sctps_recvdata;
679ff014514SRandall Stewart 		sb.sctps_recvdupdata += sarry->sctps_recvdupdata;
680ff014514SRandall Stewart 		sb.sctps_recvheartbeat += sarry->sctps_recvheartbeat;
681ff014514SRandall Stewart 		sb.sctps_recvheartbeatack += sarry->sctps_recvheartbeatack;
682ff014514SRandall Stewart 		sb.sctps_recvecne += sarry->sctps_recvecne;
683ff014514SRandall Stewart 		sb.sctps_recvauth += sarry->sctps_recvauth;
684ff014514SRandall Stewart 		sb.sctps_recvauthmissing += sarry->sctps_recvauthmissing;
685ff014514SRandall Stewart 		sb.sctps_recvivalhmacid += sarry->sctps_recvivalhmacid;
686ff014514SRandall Stewart 		sb.sctps_recvivalkeyid += sarry->sctps_recvivalkeyid;
687ff014514SRandall Stewart 		sb.sctps_recvauthfailed += sarry->sctps_recvauthfailed;
688ff014514SRandall Stewart 		sb.sctps_recvexpress += sarry->sctps_recvexpress;
689ff014514SRandall Stewart 		sb.sctps_recvexpressm += sarry->sctps_recvexpressm;
690ff014514SRandall Stewart 		sb.sctps_recvnocrc += sarry->sctps_recvnocrc;
691ff014514SRandall Stewart 		sb.sctps_recvswcrc += sarry->sctps_recvswcrc;
692ff014514SRandall Stewart 		sb.sctps_recvhwcrc += sarry->sctps_recvhwcrc;
693ff014514SRandall Stewart 		sb.sctps_sendpackets += sarry->sctps_sendpackets;
694ff014514SRandall Stewart 		sb.sctps_sendsacks += sarry->sctps_sendsacks;
695ff014514SRandall Stewart 		sb.sctps_senddata += sarry->sctps_senddata;
696ff014514SRandall Stewart 		sb.sctps_sendretransdata += sarry->sctps_sendretransdata;
697ff014514SRandall Stewart 		sb.sctps_sendfastretrans += sarry->sctps_sendfastretrans;
698ff014514SRandall Stewart 		sb.sctps_sendmultfastretrans += sarry->sctps_sendmultfastretrans;
699ff014514SRandall Stewart 		sb.sctps_sendheartbeat += sarry->sctps_sendheartbeat;
700ff014514SRandall Stewart 		sb.sctps_sendecne += sarry->sctps_sendecne;
701ff014514SRandall Stewart 		sb.sctps_sendauth += sarry->sctps_sendauth;
702ff014514SRandall Stewart 		sb.sctps_senderrors += sarry->sctps_senderrors;
703ff014514SRandall Stewart 		sb.sctps_sendnocrc += sarry->sctps_sendnocrc;
704ff014514SRandall Stewart 		sb.sctps_sendswcrc += sarry->sctps_sendswcrc;
705ff014514SRandall Stewart 		sb.sctps_sendhwcrc += sarry->sctps_sendhwcrc;
706ff014514SRandall Stewart 		sb.sctps_pdrpfmbox += sarry->sctps_pdrpfmbox;
707ff014514SRandall Stewart 		sb.sctps_pdrpfehos += sarry->sctps_pdrpfehos;
708ff014514SRandall Stewart 		sb.sctps_pdrpmbda += sarry->sctps_pdrpmbda;
709ff014514SRandall Stewart 		sb.sctps_pdrpmbct += sarry->sctps_pdrpmbct;
710ff014514SRandall Stewart 		sb.sctps_pdrpbwrpt += sarry->sctps_pdrpbwrpt;
711ff014514SRandall Stewart 		sb.sctps_pdrpcrupt += sarry->sctps_pdrpcrupt;
712ff014514SRandall Stewart 		sb.sctps_pdrpnedat += sarry->sctps_pdrpnedat;
713ff014514SRandall Stewart 		sb.sctps_pdrppdbrk += sarry->sctps_pdrppdbrk;
714ff014514SRandall Stewart 		sb.sctps_pdrptsnnf += sarry->sctps_pdrptsnnf;
715ff014514SRandall Stewart 		sb.sctps_pdrpdnfnd += sarry->sctps_pdrpdnfnd;
716ff014514SRandall Stewart 		sb.sctps_pdrpdiwnp += sarry->sctps_pdrpdiwnp;
717ff014514SRandall Stewart 		sb.sctps_pdrpdizrw += sarry->sctps_pdrpdizrw;
718ff014514SRandall Stewart 		sb.sctps_pdrpbadd += sarry->sctps_pdrpbadd;
719ff014514SRandall Stewart 		sb.sctps_pdrpmark += sarry->sctps_pdrpmark;
720ff014514SRandall Stewart 		sb.sctps_timoiterator += sarry->sctps_timoiterator;
721ff014514SRandall Stewart 		sb.sctps_timodata += sarry->sctps_timodata;
722ff014514SRandall Stewart 		sb.sctps_timowindowprobe += sarry->sctps_timowindowprobe;
723ff014514SRandall Stewart 		sb.sctps_timoinit += sarry->sctps_timoinit;
724ff014514SRandall Stewart 		sb.sctps_timosack += sarry->sctps_timosack;
725ff014514SRandall Stewart 		sb.sctps_timoshutdown += sarry->sctps_timoshutdown;
726ff014514SRandall Stewart 		sb.sctps_timoheartbeat += sarry->sctps_timoheartbeat;
727ff014514SRandall Stewart 		sb.sctps_timocookie += sarry->sctps_timocookie;
728ff014514SRandall Stewart 		sb.sctps_timosecret += sarry->sctps_timosecret;
729ff014514SRandall Stewart 		sb.sctps_timopathmtu += sarry->sctps_timopathmtu;
730ff014514SRandall Stewart 		sb.sctps_timoshutdownack += sarry->sctps_timoshutdownack;
731ff014514SRandall Stewart 		sb.sctps_timoshutdownguard += sarry->sctps_timoshutdownguard;
732ff014514SRandall Stewart 		sb.sctps_timostrmrst += sarry->sctps_timostrmrst;
733ff014514SRandall Stewart 		sb.sctps_timoearlyfr += sarry->sctps_timoearlyfr;
734ff014514SRandall Stewart 		sb.sctps_timoasconf += sarry->sctps_timoasconf;
735ff014514SRandall Stewart 		sb.sctps_timodelprim += sarry->sctps_timodelprim;
736ff014514SRandall Stewart 		sb.sctps_timoautoclose += sarry->sctps_timoautoclose;
737ff014514SRandall Stewart 		sb.sctps_timoassockill += sarry->sctps_timoassockill;
738ff014514SRandall Stewart 		sb.sctps_timoinpkill += sarry->sctps_timoinpkill;
739ff014514SRandall Stewart 		sb.sctps_earlyfrstart += sarry->sctps_earlyfrstart;
740ff014514SRandall Stewart 		sb.sctps_earlyfrstop += sarry->sctps_earlyfrstop;
741ff014514SRandall Stewart 		sb.sctps_earlyfrmrkretrans += sarry->sctps_earlyfrmrkretrans;
742ff014514SRandall Stewart 		sb.sctps_earlyfrstpout += sarry->sctps_earlyfrstpout;
743ff014514SRandall Stewart 		sb.sctps_earlyfrstpidsck1 += sarry->sctps_earlyfrstpidsck1;
744ff014514SRandall Stewart 		sb.sctps_earlyfrstpidsck2 += sarry->sctps_earlyfrstpidsck2;
745ff014514SRandall Stewart 		sb.sctps_earlyfrstpidsck3 += sarry->sctps_earlyfrstpidsck3;
746ff014514SRandall Stewart 		sb.sctps_earlyfrstpidsck4 += sarry->sctps_earlyfrstpidsck4;
747ff014514SRandall Stewart 		sb.sctps_earlyfrstrid += sarry->sctps_earlyfrstrid;
748ff014514SRandall Stewart 		sb.sctps_earlyfrstrout += sarry->sctps_earlyfrstrout;
749ff014514SRandall Stewart 		sb.sctps_earlyfrstrtmr += sarry->sctps_earlyfrstrtmr;
750ff014514SRandall Stewart 		sb.sctps_hdrops += sarry->sctps_hdrops;
751ff014514SRandall Stewart 		sb.sctps_badsum += sarry->sctps_badsum;
752ff014514SRandall Stewart 		sb.sctps_noport += sarry->sctps_noport;
753ff014514SRandall Stewart 		sb.sctps_badvtag += sarry->sctps_badvtag;
754ff014514SRandall Stewart 		sb.sctps_badsid += sarry->sctps_badsid;
755ff014514SRandall Stewart 		sb.sctps_nomem += sarry->sctps_nomem;
756ff014514SRandall Stewart 		sb.sctps_fastretransinrtt += sarry->sctps_fastretransinrtt;
757ff014514SRandall Stewart 		sb.sctps_markedretrans += sarry->sctps_markedretrans;
758ff014514SRandall Stewart 		sb.sctps_naglesent += sarry->sctps_naglesent;
759ff014514SRandall Stewart 		sb.sctps_naglequeued += sarry->sctps_naglequeued;
760ff014514SRandall Stewart 		sb.sctps_maxburstqueued += sarry->sctps_maxburstqueued;
761ff014514SRandall Stewart 		sb.sctps_ifnomemqueued += sarry->sctps_ifnomemqueued;
762ff014514SRandall Stewart 		sb.sctps_windowprobed += sarry->sctps_windowprobed;
763ff014514SRandall Stewart 		sb.sctps_lowlevelerr += sarry->sctps_lowlevelerr;
764ff014514SRandall Stewart 		sb.sctps_lowlevelerrusr += sarry->sctps_lowlevelerrusr;
765ff014514SRandall Stewart 		sb.sctps_datadropchklmt += sarry->sctps_datadropchklmt;
766ff014514SRandall Stewart 		sb.sctps_datadroprwnd += sarry->sctps_datadroprwnd;
767ff014514SRandall Stewart 		sb.sctps_ecnereducedcwnd += sarry->sctps_ecnereducedcwnd;
768ff014514SRandall Stewart 		sb.sctps_vtagexpress += sarry->sctps_vtagexpress;
769ff014514SRandall Stewart 		sb.sctps_vtagbogus += sarry->sctps_vtagbogus;
770ff014514SRandall Stewart 		sb.sctps_primary_randry += sarry->sctps_primary_randry;
771ff014514SRandall Stewart 		sb.sctps_cmt_randry += sarry->sctps_cmt_randry;
772ff014514SRandall Stewart 		sb.sctps_slowpath_sack += sarry->sctps_slowpath_sack;
773ff014514SRandall Stewart 		sb.sctps_wu_sacks_sent += sarry->sctps_wu_sacks_sent;
774ff014514SRandall Stewart 		sb.sctps_sends_with_flags += sarry->sctps_sends_with_flags;
775ff014514SRandall Stewart 		sb.sctps_sends_with_unord += sarry->sctps_sends_with_unord;
776ff014514SRandall Stewart 		sb.sctps_sends_with_eof += sarry->sctps_sends_with_eof;
777ff014514SRandall Stewart 		sb.sctps_sends_with_abort += sarry->sctps_sends_with_abort;
778ff014514SRandall Stewart 		sb.sctps_protocol_drain_calls += sarry->sctps_protocol_drain_calls;
779ff014514SRandall Stewart 		sb.sctps_protocol_drains_done += sarry->sctps_protocol_drains_done;
780ff014514SRandall Stewart 		sb.sctps_read_peeks += sarry->sctps_read_peeks;
781ff014514SRandall Stewart 		sb.sctps_cached_chk += sarry->sctps_cached_chk;
782ff014514SRandall Stewart 		sb.sctps_cached_strmoq += sarry->sctps_cached_strmoq;
783ff014514SRandall Stewart 		sb.sctps_left_abandon += sarry->sctps_left_abandon;
784ff014514SRandall Stewart 		sb.sctps_send_burst_avoid += sarry->sctps_send_burst_avoid;
785ff014514SRandall Stewart 		sb.sctps_send_cwnd_avoid += sarry->sctps_send_cwnd_avoid;
786ff014514SRandall Stewart 		sb.sctps_fwdtsn_map_over += sarry->sctps_fwdtsn_map_over;
787ff014514SRandall Stewart 	}
788ff014514SRandall Stewart 	error = SYSCTL_OUT(req, &sb, sizeof(sb));
789ff014514SRandall Stewart 	return (error);
790ff014514SRandall Stewart }
791ff014514SRandall Stewart 
792ff014514SRandall Stewart #endif
793b3f1ea41SRandall Stewart 
794b3f1ea41SRandall Stewart #if defined(SCTP_LOCAL_TRACE_BUF)
795b3f1ea41SRandall Stewart static int
796b3f1ea41SRandall Stewart sysctl_sctp_cleartrace(SYSCTL_HANDLER_ARGS)
797b3f1ea41SRandall Stewart {
798a99b6783SRandall Stewart 	int error = 0;
799a99b6783SRandall Stewart 
800b3f1ea41SRandall Stewart 	memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log));
801a99b6783SRandall Stewart 	return (error);
802b3f1ea41SRandall Stewart }
803b3f1ea41SRandall Stewart 
804b3f1ea41SRandall Stewart #endif
805b3f1ea41SRandall Stewart 
806b3f1ea41SRandall Stewart 
80742551e99SRandall Stewart /*
80842551e99SRandall Stewart  * sysctl definitions
80942551e99SRandall Stewart  */
81042551e99SRandall Stewart 
811851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, sendspace, CTLTYPE_INT | CTLFLAG_RW,
812b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_sendspace), 0, sysctl_sctp_check, "IU",
813851b7298SRandall Stewart     SCTPCTL_MAXDGRAM_DESC);
81442551e99SRandall Stewart 
815851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, recvspace, CTLTYPE_INT | CTLFLAG_RW,
816b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_recvspace), 0, sysctl_sctp_check, "IU",
817851b7298SRandall Stewart     SCTPCTL_RECVSPACE_DESC);
81842551e99SRandall Stewart 
819851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, auto_asconf, CTLTYPE_INT | CTLFLAG_RW,
820b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_auto_asconf), 0, sysctl_sctp_check, "IU",
821851b7298SRandall Stewart     SCTPCTL_AUTOASCONF_DESC);
82242551e99SRandall Stewart 
823851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, ecn_enable, CTLTYPE_INT | CTLFLAG_RW,
824b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_ecn_enable), 0, sysctl_sctp_check, "IU",
825851b7298SRandall Stewart     SCTPCTL_ECN_ENABLE_DESC);
82642551e99SRandall Stewart 
827851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, ecn_nonce, CTLTYPE_INT | CTLFLAG_RW,
828b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_ecn_nonce), 0, sysctl_sctp_check, "IU",
829851b7298SRandall Stewart     SCTPCTL_ECN_NONCE_DESC);
83042551e99SRandall Stewart 
831851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, strict_sacks, CTLTYPE_INT | CTLFLAG_RW,
832b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_strict_sacks), 0, sysctl_sctp_check, "IU",
833851b7298SRandall Stewart     SCTPCTL_STRICT_SACKS_DESC);
83442551e99SRandall Stewart 
8359c7635e1SMichael Tuexen #if !defined(SCTP_WITH_NO_CSUM)
836851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, loopback_nocsum, CTLTYPE_INT | CTLFLAG_RW,
837b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback), 0, sysctl_sctp_check, "IU",
838851b7298SRandall Stewart     SCTPCTL_LOOPBACK_NOCSUM_DESC);
8399c7635e1SMichael Tuexen #endif
84042551e99SRandall Stewart 
841851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, strict_init, CTLTYPE_INT | CTLFLAG_RW,
842b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_strict_init), 0, sysctl_sctp_check, "IU",
843851b7298SRandall Stewart     SCTPCTL_STRICT_INIT_DESC);
84442551e99SRandall Stewart 
845851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, peer_chkoh, CTLTYPE_INT | CTLFLAG_RW,
846b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_peer_chunk_oh), 0, sysctl_sctp_check, "IU",
847851b7298SRandall Stewart     SCTPCTL_PEER_CHKOH_DESC);
84842551e99SRandall Stewart 
849851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, maxburst, CTLTYPE_INT | CTLFLAG_RW,
850b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_max_burst_default), 0, sysctl_sctp_check, "IU",
851851b7298SRandall Stewart     SCTPCTL_MAXBURST_DESC);
85242551e99SRandall Stewart 
853851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, maxchunks, CTLTYPE_INT | CTLFLAG_RW,
854b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue), 0, sysctl_sctp_check, "IU",
855851b7298SRandall Stewart     SCTPCTL_MAXCHUNKS_DESC);
85642551e99SRandall Stewart 
857851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, tcbhashsize, CTLTYPE_INT | CTLFLAG_RW,
858b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_hashtblsize), 0, sysctl_sctp_check, "IU",
859851b7298SRandall Stewart     SCTPCTL_TCBHASHSIZE_DESC);
86042551e99SRandall Stewart 
861851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, pcbhashsize, CTLTYPE_INT | CTLFLAG_RW,
862b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_pcbtblsize), 0, sysctl_sctp_check, "IU",
863851b7298SRandall Stewart     SCTPCTL_PCBHASHSIZE_DESC);
86442551e99SRandall Stewart 
865851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, min_split_point, CTLTYPE_INT | CTLFLAG_RW,
866b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_min_split_point), 0, sysctl_sctp_check, "IU",
867851b7298SRandall Stewart     SCTPCTL_MIN_SPLIT_POINT_DESC);
86842551e99SRandall Stewart 
869851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, chunkscale, CTLTYPE_INT | CTLFLAG_RW,
870b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_chunkscale), 0, sysctl_sctp_check, "IU",
871851b7298SRandall Stewart     SCTPCTL_CHUNKSCALE_DESC);
87242551e99SRandall Stewart 
873851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, delayed_sack_time, CTLTYPE_INT | CTLFLAG_RW,
874b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default), 0, sysctl_sctp_check, "IU",
875851b7298SRandall Stewart     SCTPCTL_DELAYED_SACK_TIME_DESC);
87642551e99SRandall Stewart 
877851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, sack_freq, CTLTYPE_INT | CTLFLAG_RW,
878b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_sack_freq_default), 0, sysctl_sctp_check, "IU",
879851b7298SRandall Stewart     SCTPCTL_SACK_FREQ_DESC);
88042551e99SRandall Stewart 
881851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, sys_resource, CTLTYPE_INT | CTLFLAG_RW,
882b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_system_free_resc_limit), 0, sysctl_sctp_check, "IU",
883851b7298SRandall Stewart     SCTPCTL_SYS_RESOURCE_DESC);
88442551e99SRandall Stewart 
885851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, asoc_resource, CTLTYPE_INT | CTLFLAG_RW,
886b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit), 0, sysctl_sctp_check, "IU",
887851b7298SRandall Stewart     SCTPCTL_ASOC_RESOURCE_DESC);
88842551e99SRandall Stewart 
889851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, heartbeat_interval, CTLTYPE_INT | CTLFLAG_RW,
890b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default), 0, sysctl_sctp_check, "IU",
891851b7298SRandall Stewart     SCTPCTL_HEARTBEAT_INTERVAL_DESC);
89242551e99SRandall Stewart 
893851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, pmtu_raise_time, CTLTYPE_INT | CTLFLAG_RW,
894b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default), 0, sysctl_sctp_check, "IU",
895851b7298SRandall Stewart     SCTPCTL_PMTU_RAISE_TIME_DESC);
89642551e99SRandall Stewart 
897851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, shutdown_guard_time, CTLTYPE_INT | CTLFLAG_RW,
898b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default), 0, sysctl_sctp_check, "IU",
899851b7298SRandall Stewart     SCTPCTL_SHUTDOWN_GUARD_TIME_DESC);
90042551e99SRandall Stewart 
901851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, secret_lifetime, CTLTYPE_INT | CTLFLAG_RW,
902b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_secret_lifetime_default), 0, sysctl_sctp_check, "IU",
903851b7298SRandall Stewart     SCTPCTL_SECRET_LIFETIME_DESC);
90442551e99SRandall Stewart 
905851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, rto_max, CTLTYPE_INT | CTLFLAG_RW,
906b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_rto_max_default), 0, sysctl_sctp_check, "IU",
907851b7298SRandall Stewart     SCTPCTL_RTO_MAX_DESC);
90842551e99SRandall Stewart 
909851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, rto_min, CTLTYPE_INT | CTLFLAG_RW,
910b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_rto_min_default), 0, sysctl_sctp_check, "IU",
911851b7298SRandall Stewart     SCTPCTL_RTO_MIN_DESC);
91242551e99SRandall Stewart 
913851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, rto_initial, CTLTYPE_INT | CTLFLAG_RW,
914b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_rto_initial_default), 0, sysctl_sctp_check, "IU",
915851b7298SRandall Stewart     SCTPCTL_RTO_INITIAL_DESC);
91642551e99SRandall Stewart 
917851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, init_rto_max, CTLTYPE_INT | CTLFLAG_RW,
918b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_init_rto_max_default), 0, sysctl_sctp_check, "IU",
919851b7298SRandall Stewart     SCTPCTL_INIT_RTO_MAX_DESC);
92042551e99SRandall Stewart 
921851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, valid_cookie_life, CTLTYPE_INT | CTLFLAG_RW,
922b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default), 0, sysctl_sctp_check, "IU",
923851b7298SRandall Stewart     SCTPCTL_VALID_COOKIE_LIFE_DESC);
92442551e99SRandall Stewart 
925851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, init_rtx_max, CTLTYPE_INT | CTLFLAG_RW,
926b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_init_rtx_max_default), 0, sysctl_sctp_check, "IU",
927851b7298SRandall Stewart     SCTPCTL_INIT_RTX_MAX_DESC);
92842551e99SRandall Stewart 
929851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, assoc_rtx_max, CTLTYPE_INT | CTLFLAG_RW,
930b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default), 0, sysctl_sctp_check, "IU",
931851b7298SRandall Stewart     SCTPCTL_ASSOC_RTX_MAX_DESC);
93242551e99SRandall Stewart 
933851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, path_rtx_max, CTLTYPE_INT | CTLFLAG_RW,
934b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_path_rtx_max_default), 0, sysctl_sctp_check, "IU",
935851b7298SRandall Stewart     SCTPCTL_PATH_RTX_MAX_DESC);
93642551e99SRandall Stewart 
937851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, add_more_on_output, CTLTYPE_INT | CTLFLAG_RW,
938b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_add_more_threshold), 0, sysctl_sctp_check, "IU",
939851b7298SRandall Stewart     SCTPCTL_ADD_MORE_ON_OUTPUT_DESC);
94042551e99SRandall Stewart 
941851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, outgoing_streams, CTLTYPE_INT | CTLFLAG_RW,
942b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default), 0, sysctl_sctp_check, "IU",
943851b7298SRandall Stewart     SCTPCTL_OUTGOING_STREAMS_DESC);
94442551e99SRandall Stewart 
945851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, cmt_on_off, CTLTYPE_INT | CTLFLAG_RW,
946b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_cmt_on_off), 0, sysctl_sctp_check, "IU",
947851b7298SRandall Stewart     SCTPCTL_CMT_ON_OFF_DESC);
94842551e99SRandall Stewart 
949830d754dSRandall Stewart /* EY */
950830d754dSRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, nr_sack_on_off, CTLTYPE_INT | CTLFLAG_RW,
951830d754dSRandall Stewart     &SCTP_BASE_SYSCTL(sctp_nr_sack_on_off), 0, sysctl_sctp_check, "IU",
952830d754dSRandall Stewart     SCTPCTL_NR_SACK_ON_OFF_DESC);
953830d754dSRandall Stewart 
954851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, cmt_use_dac, CTLTYPE_INT | CTLFLAG_RW,
955b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_cmt_use_dac), 0, sysctl_sctp_check, "IU",
956851b7298SRandall Stewart     SCTPCTL_CMT_USE_DAC_DESC);
957b54d3a6cSRandall Stewart 
958851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, cmt_pf, CTLTYPE_INT | CTLFLAG_RW,
959b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_cmt_pf), 0, sysctl_sctp_check, "IU",
960851b7298SRandall Stewart     SCTPCTL_CMT_PF_DESC);
961b54d3a6cSRandall Stewart 
962851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, cwnd_maxburst, CTLTYPE_INT | CTLFLAG_RW,
963b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst), 0, sysctl_sctp_check, "IU",
964851b7298SRandall Stewart     SCTPCTL_CWND_MAXBURST_DESC);
965c4739e2fSRandall Stewart 
966851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, early_fast_retran, CTLTYPE_INT | CTLFLAG_RW,
967b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_early_fr), 0, sysctl_sctp_check, "IU",
968851b7298SRandall Stewart     SCTPCTL_EARLY_FAST_RETRAN_DESC);
969851b7298SRandall Stewart 
970851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, early_fast_retran_msec, CTLTYPE_INT | CTLFLAG_RW,
971b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_early_fr_msec), 0, sysctl_sctp_check, "IU",
972851b7298SRandall Stewart     SCTPCTL_EARLY_FAST_RETRAN_MSEC_DESC);
973851b7298SRandall Stewart 
974851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, asconf_auth_nochk, CTLTYPE_INT | CTLFLAG_RW,
975b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_asconf_auth_nochk), 0, sysctl_sctp_check, "IU",
976851b7298SRandall Stewart     SCTPCTL_ASCONF_AUTH_NOCHK_DESC);
977851b7298SRandall Stewart 
978851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, auth_disable, CTLTYPE_INT | CTLFLAG_RW,
979b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_auth_disable), 0, sysctl_sctp_check, "IU",
980851b7298SRandall Stewart     SCTPCTL_AUTH_DISABLE_DESC);
981851b7298SRandall Stewart 
982851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, nat_friendly, CTLTYPE_INT | CTLFLAG_RW,
983b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_nat_friendly), 0, sysctl_sctp_check, "IU",
984851b7298SRandall Stewart     SCTPCTL_NAT_FRIENDLY_DESC);
985851b7298SRandall Stewart 
986851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, abc_l_var, CTLTYPE_INT | CTLFLAG_RW,
987b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_L2_abc_variable), 0, sysctl_sctp_check, "IU",
988851b7298SRandall Stewart     SCTPCTL_ABC_L_VAR_DESC);
989851b7298SRandall Stewart 
990851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, max_chained_mbufs, CTLTYPE_INT | CTLFLAG_RW,
991b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count), 0, sysctl_sctp_check, "IU",
992851b7298SRandall Stewart     SCTPCTL_MAX_CHAINED_MBUFS_DESC);
993851b7298SRandall Stewart 
994851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, do_sctp_drain, CTLTYPE_INT | CTLFLAG_RW,
995b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_do_drain), 0, sysctl_sctp_check, "IU",
996851b7298SRandall Stewart     SCTPCTL_DO_SCTP_DRAIN_DESC);
997851b7298SRandall Stewart 
998851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, hb_max_burst, CTLTYPE_INT | CTLFLAG_RW,
999b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_hb_maxburst), 0, sysctl_sctp_check, "IU",
1000851b7298SRandall Stewart     SCTPCTL_HB_MAX_BURST_DESC);
1001851b7298SRandall Stewart 
1002851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, abort_at_limit, CTLTYPE_INT | CTLFLAG_RW,
1003b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit), 0, sysctl_sctp_check, "IU",
1004851b7298SRandall Stewart     SCTPCTL_ABORT_AT_LIMIT_DESC);
1005851b7298SRandall Stewart 
1006851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, strict_data_order, CTLTYPE_INT | CTLFLAG_RW,
1007b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_strict_data_order), 0, sysctl_sctp_check, "IU",
1008851b7298SRandall Stewart     SCTPCTL_STRICT_DATA_ORDER_DESC);
1009851b7298SRandall Stewart 
1010851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, min_residual, CTLTYPE_INT | CTLFLAG_RW,
1011b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_min_residual), 0, sysctl_sctp_check, "IU",
1012851b7298SRandall Stewart     SCTPCTL_MIN_RESIDUAL_DESC);
1013851b7298SRandall Stewart 
1014851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, max_retran_chunk, CTLTYPE_INT | CTLFLAG_RW,
1015b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_max_retran_chunk), 0, sysctl_sctp_check, "IU",
1016851b7298SRandall Stewart     SCTPCTL_MAX_RETRAN_CHUNK_DESC);
1017851b7298SRandall Stewart 
1018b27a6b7dSRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, log_level, CTLTYPE_INT | CTLFLAG_RW,
1019b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_logging_level), 0, sysctl_sctp_check, "IU",
1020851b7298SRandall Stewart     SCTPCTL_LOGGING_LEVEL_DESC);
1021851b7298SRandall Stewart 
1022851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, default_cc_module, CTLTYPE_INT | CTLFLAG_RW,
1023b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_default_cc_module), 0, sysctl_sctp_check, "IU",
1024851b7298SRandall Stewart     SCTPCTL_DEFAULT_CC_MODULE_DESC);
1025851b7298SRandall Stewart 
1026851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, default_frag_interleave, CTLTYPE_INT | CTLFLAG_RW,
1027b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_default_frag_interleave), 0, sysctl_sctp_check, "IU",
1028c4739e2fSRandall Stewart     SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DESC);
1029c4739e2fSRandall Stewart 
1030851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mobility_base, CTLTYPE_INT | CTLFLAG_RW,
1031b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_mobility_base), 0, sysctl_sctp_check, "IU",
1032851b7298SRandall Stewart     SCTPCTL_MOBILITY_BASE_DESC);
103342551e99SRandall Stewart 
1034851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mobility_fasthandoff, CTLTYPE_INT | CTLFLAG_RW,
1035b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff), 0, sysctl_sctp_check, "IU",
1036851b7298SRandall Stewart     SCTPCTL_MOBILITY_FASTHANDOFF_DESC);
103742551e99SRandall Stewart 
1038b27a6b7dSRandall Stewart #if defined(SCTP_LOCAL_TRACE_BUF)
1039b27a6b7dSRandall Stewart SYSCTL_STRUCT(_net_inet_sctp, OID_AUTO, log, CTLFLAG_RD,
1040b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_log), sctp_log,
1041b27a6b7dSRandall Stewart     "SCTP logging (struct sctp_log)");
1042b3f1ea41SRandall Stewart 
1043b3f1ea41SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, clear_trace, CTLTYPE_OPAQUE | CTLFLAG_RW,
1044b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_log), 0, sysctl_sctp_cleartrace, "IU",
1045b3f1ea41SRandall Stewart     "Clear SCTP Logging buffer");
1046b3f1ea41SRandall Stewart 
1047b3f1ea41SRandall Stewart 
1048b3f1ea41SRandall Stewart 
1049b27a6b7dSRandall Stewart #endif
1050b27a6b7dSRandall Stewart 
1051c54a18d2SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, udp_tunneling_for_client_enable, CTLTYPE_INT | CTLFLAG_RW,
1052b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_udp_tunneling_for_client_enable), 0, sysctl_sctp_check, "IU",
1053c54a18d2SRandall Stewart     SCTPCTL_UDP_TUNNELING_FOR_CLIENT_ENABLE_DESC);
1054c54a18d2SRandall Stewart 
1055c54a18d2SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, udp_tunneling_port, CTLTYPE_INT | CTLFLAG_RW,
1056b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_udp_tunneling_port), 0, sysctl_sctp_udp_tunneling_check, "IU",
1057c54a18d2SRandall Stewart     SCTPCTL_UDP_TUNNELING_PORT_DESC);
1058c54a18d2SRandall Stewart 
1059b3f1ea41SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, enable_sack_immediately, CTLTYPE_INT | CTLFLAG_RW,
1060b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_enable_sack_immediately), 0, sysctl_sctp_check, "IU",
1061b3f1ea41SRandall Stewart     SCTPCTL_SACK_IMMEDIATELY_ENABLE_DESC);
1062b3f1ea41SRandall Stewart 
1063830d754dSRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, nat_friendly_init, CTLTYPE_INT | CTLFLAG_RW,
1064830d754dSRandall Stewart     &SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly), 0, sysctl_sctp_check, "IU",
1065bf3d5177SMichael Tuexen     SCTPCTL_NAT_FRIENDLY_INITS_DESC);
1066830d754dSRandall Stewart 
1067a16ccdceSRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, vtag_time_wait, CTLTYPE_INT | CTLFLAG_RW,
1068a16ccdceSRandall Stewart     &SCTP_BASE_SYSCTL(sctp_vtag_time_wait), 0, sysctl_sctp_check, "IU",
1069a16ccdceSRandall Stewart     SCTPCTL_TIME_WAIT_DESC);
1070a16ccdceSRandall Stewart 
1071*25a2a187SMichael Tuexen SYSCTL_PROC(_net_inet_sctp, OID_AUTO, buffer_splitting, CTLTYPE_INT | CTLFLAG_RW,
1072*25a2a187SMichael Tuexen     &SCTP_BASE_SYSCTL(sctp_buffer_splitting), 0, sysctl_sctp_check, "IU",
1073*25a2a187SMichael Tuexen     SCTPCTL_BUFFER_SPLITTING_DESC);
1074*25a2a187SMichael Tuexen 
1075851b7298SRandall Stewart #ifdef SCTP_DEBUG
1076851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, debug, CTLTYPE_INT | CTLFLAG_RW,
1077b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_debug_on), 0, sysctl_sctp_check, "IU",
1078851b7298SRandall Stewart     SCTPCTL_DEBUG_DESC);
1079851b7298SRandall Stewart #endif				/* SCTP_DEBUG */
108042551e99SRandall Stewart 
108142551e99SRandall Stewart 
1082b3f1ea41SRandall Stewart #if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
1083b3f1ea41SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, output_unlocked, CTLTYPE_INT | CTLFLAG_RW,
1084b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_output_unlocked), 0, sysctl_sctp_check, "IU",
1085b3f1ea41SRandall Stewart     SCTPCTL_OUTPUT_UNLOCKED_DESC);
1086b3f1ea41SRandall Stewart #endif
1087ff014514SRandall Stewart #if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
1088ff014514SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, stats,
1089ff014514SRandall Stewart     CTLTYPE_STRUCT | CTLFLAG_RD,
1090ff014514SRandall Stewart     0, 0, sysctl_stat_get, "S,sctpstat",
1091ff014514SRandall Stewart     "SCTP statistics (struct sctp_stat)");
1092ff014514SRandall Stewart #else
109342551e99SRandall Stewart SYSCTL_STRUCT(_net_inet_sctp, OID_AUTO, stats, CTLFLAG_RW,
10948518270eSMichael Tuexen     &SCTP_BASE_STATS_SYSCTL, sctpstat,
1095b27a6b7dSRandall Stewart     "SCTP statistics (struct sctp_stat)");
1096ff014514SRandall Stewart #endif
109742551e99SRandall Stewart 
109842551e99SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, assoclist, CTLFLAG_RD,
109942551e99SRandall Stewart     0, 0, sctp_assoclist,
110042551e99SRandall Stewart     "S,xassoc", "List of active SCTP associations");
1101