xref: /freebsd/sys/netinet/sctp_sysctl.c (revision 8ce4a9a2556f92ccc058efae9b381a7fc32a0a70)
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;
334*8ce4a9a2SRandall Stewart 	struct socket *so;
33542551e99SRandall Stewart 
33642551e99SRandall Stewart 	number_of_endpoints = 0;
33742551e99SRandall Stewart 	number_of_local_addresses = 0;
33842551e99SRandall Stewart 	number_of_associations = 0;
33942551e99SRandall Stewart 	number_of_remote_addresses = 0;
34042551e99SRandall Stewart 
34142551e99SRandall Stewart 	SCTP_INP_INFO_RLOCK();
34242551e99SRandall Stewart 	if (req->oldptr == USER_ADDR_NULL) {
343b3f1ea41SRandall Stewart 		LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
34442551e99SRandall Stewart 			SCTP_INP_RLOCK(inp);
34542551e99SRandall Stewart 			number_of_endpoints++;
346d61a0ae0SRandall Stewart 			number_of_local_addresses += number_of_addresses(inp);
34742551e99SRandall Stewart 			LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
34842551e99SRandall Stewart 				number_of_associations++;
349d61a0ae0SRandall Stewart 				number_of_local_addresses += number_of_addresses(inp);
35042551e99SRandall Stewart 				TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
35142551e99SRandall Stewart 					number_of_remote_addresses++;
35242551e99SRandall Stewart 				}
35342551e99SRandall Stewart 			}
35442551e99SRandall Stewart 			SCTP_INP_RUNLOCK(inp);
35542551e99SRandall Stewart 		}
35642551e99SRandall Stewart 		SCTP_INP_INFO_RUNLOCK();
35742551e99SRandall Stewart 		n = (number_of_endpoints + 1) * sizeof(struct xsctp_inpcb) +
358d61a0ae0SRandall Stewart 		    (number_of_local_addresses + number_of_endpoints + number_of_associations) * sizeof(struct xsctp_laddr) +
359d61a0ae0SRandall Stewart 		    (number_of_associations + number_of_endpoints) * sizeof(struct xsctp_tcb) +
360d61a0ae0SRandall Stewart 		    (number_of_remote_addresses + number_of_associations) * sizeof(struct xsctp_raddr);
361d61a0ae0SRandall Stewart 
36242551e99SRandall Stewart 		/* request some more memory than needed */
36342551e99SRandall Stewart 		req->oldidx = (n + n / 8);
36442551e99SRandall Stewart 		return 0;
36542551e99SRandall Stewart 	}
36642551e99SRandall Stewart 	if (req->newptr != USER_ADDR_NULL) {
36742551e99SRandall Stewart 		SCTP_INP_INFO_RUNLOCK();
368c4739e2fSRandall Stewart 		SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_SYSCTL, EPERM);
36942551e99SRandall Stewart 		return EPERM;
37042551e99SRandall Stewart 	}
371b3f1ea41SRandall Stewart 	LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
37242551e99SRandall Stewart 		SCTP_INP_RLOCK(inp);
373*8ce4a9a2SRandall Stewart 		if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
374*8ce4a9a2SRandall Stewart 			/* if its allgone it is being freed - skip it  */
375*8ce4a9a2SRandall Stewart 			goto skip;
376*8ce4a9a2SRandall Stewart 		}
37742551e99SRandall Stewart 		xinpcb.last = 0;
37842551e99SRandall Stewart 		xinpcb.local_port = ntohs(inp->sctp_lport);
37942551e99SRandall Stewart 		xinpcb.flags = inp->sctp_flags;
38042551e99SRandall Stewart 		xinpcb.features = inp->sctp_features;
38142551e99SRandall Stewart 		xinpcb.total_sends = inp->total_sends;
38242551e99SRandall Stewart 		xinpcb.total_recvs = inp->total_recvs;
38342551e99SRandall Stewart 		xinpcb.total_nospaces = inp->total_nospaces;
38417205eccSRandall Stewart 		xinpcb.fragmentation_point = inp->sctp_frag_point;
385*8ce4a9a2SRandall Stewart 		so = inp->sctp_socket;
386*8ce4a9a2SRandall Stewart 		if ((so == NULL) ||
387851b7298SRandall Stewart 		    (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) {
388851b7298SRandall Stewart 			xinpcb.qlen = 0;
389851b7298SRandall Stewart 			xinpcb.maxqlen = 0;
390851b7298SRandall Stewart 		} else {
391*8ce4a9a2SRandall Stewart 			xinpcb.qlen = so->so_qlen;
392*8ce4a9a2SRandall Stewart 			xinpcb.maxqlen = so->so_qlimit;
393851b7298SRandall Stewart 		}
39442551e99SRandall Stewart 		SCTP_INP_INCR_REF(inp);
39542551e99SRandall Stewart 		SCTP_INP_RUNLOCK(inp);
39642551e99SRandall Stewart 		SCTP_INP_INFO_RUNLOCK();
39742551e99SRandall Stewart 		error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb));
39842551e99SRandall Stewart 		if (error) {
399d61a0ae0SRandall Stewart 			SCTP_INP_DECR_REF(inp);
40042551e99SRandall Stewart 			return error;
40142551e99SRandall Stewart 		}
40242551e99SRandall Stewart 		SCTP_INP_INFO_RLOCK();
40342551e99SRandall Stewart 		SCTP_INP_RLOCK(inp);
404d61a0ae0SRandall Stewart 		error = copy_out_local_addresses(inp, NULL, req);
405d61a0ae0SRandall Stewart 		if (error) {
406d61a0ae0SRandall Stewart 			SCTP_INP_DECR_REF(inp);
407d61a0ae0SRandall Stewart 			return error;
408d61a0ae0SRandall Stewart 		}
40942551e99SRandall Stewart 		LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
41042551e99SRandall Stewart 			SCTP_TCB_LOCK(stcb);
41142551e99SRandall Stewart 			atomic_add_int(&stcb->asoc.refcnt, 1);
41242551e99SRandall Stewart 			SCTP_TCB_UNLOCK(stcb);
413d61a0ae0SRandall Stewart 			xstcb.last = 0;
414d61a0ae0SRandall Stewart 			xstcb.local_port = ntohs(inp->sctp_lport);
415d61a0ae0SRandall Stewart 			xstcb.remote_port = ntohs(stcb->rport);
41642551e99SRandall Stewart 			if (stcb->asoc.primary_destination != NULL)
417d61a0ae0SRandall Stewart 				xstcb.primary_addr = stcb->asoc.primary_destination->ro._l_addr;
418d61a0ae0SRandall Stewart 			xstcb.heartbeat_interval = stcb->asoc.heart_beat_delay;
419d61a0ae0SRandall Stewart 			xstcb.state = SCTP_GET_STATE(&stcb->asoc);	/* FIXME */
4204f6b4933SRandall Stewart 			/* 7.0 does not support these */
421a99b6783SRandall Stewart 			xstcb.assoc_id = sctp_get_associd(stcb);
4224f6b4933SRandall Stewart 			xstcb.peers_rwnd = stcb->asoc.peers_rwnd;
423d61a0ae0SRandall Stewart 			xstcb.in_streams = stcb->asoc.streamincnt;
424d61a0ae0SRandall Stewart 			xstcb.out_streams = stcb->asoc.streamoutcnt;
425d61a0ae0SRandall Stewart 			xstcb.max_nr_retrans = stcb->asoc.overall_error_count;
426d61a0ae0SRandall Stewart 			xstcb.primary_process = 0;	/* not really supported
427d61a0ae0SRandall Stewart 							 * yet */
428d61a0ae0SRandall Stewart 			xstcb.T1_expireries = stcb->asoc.timoinit + stcb->asoc.timocookie;
429d61a0ae0SRandall Stewart 			xstcb.T2_expireries = stcb->asoc.timoshutdown + stcb->asoc.timoshutdownack;
430d61a0ae0SRandall Stewart 			xstcb.retransmitted_tsns = stcb->asoc.marked_retrans;
431851b7298SRandall Stewart 			xstcb.start_time.tv_sec = (uint32_t) stcb->asoc.start_time.tv_sec;
432851b7298SRandall Stewart 			xstcb.start_time.tv_usec = (uint32_t) stcb->asoc.start_time.tv_usec;
433851b7298SRandall Stewart 			xstcb.discontinuity_time.tv_sec = (uint32_t) stcb->asoc.discontinuity_time.tv_sec;
434851b7298SRandall Stewart 			xstcb.discontinuity_time.tv_usec = (uint32_t) stcb->asoc.discontinuity_time.tv_usec;
43542551e99SRandall Stewart 			xstcb.total_sends = stcb->total_sends;
43642551e99SRandall Stewart 			xstcb.total_recvs = stcb->total_recvs;
43742551e99SRandall Stewart 			xstcb.local_tag = stcb->asoc.my_vtag;
43842551e99SRandall Stewart 			xstcb.remote_tag = stcb->asoc.peer_vtag;
43942551e99SRandall Stewart 			xstcb.initial_tsn = stcb->asoc.init_seq_number;
44042551e99SRandall Stewart 			xstcb.highest_tsn = stcb->asoc.sending_seq - 1;
44142551e99SRandall Stewart 			xstcb.cumulative_tsn = stcb->asoc.last_acked_seq;
44242551e99SRandall Stewart 			xstcb.cumulative_tsn_ack = stcb->asoc.cumulative_tsn;
44317205eccSRandall Stewart 			xstcb.mtu = stcb->asoc.smallest_mtu;
444207304d4SRandall Stewart 			xstcb.refcnt = stcb->asoc.refcnt;
44542551e99SRandall Stewart 			SCTP_INP_RUNLOCK(inp);
44642551e99SRandall Stewart 			SCTP_INP_INFO_RUNLOCK();
44742551e99SRandall Stewart 			error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb));
44842551e99SRandall Stewart 			if (error) {
449d61a0ae0SRandall Stewart 				SCTP_INP_DECR_REF(inp);
450851b7298SRandall Stewart 				atomic_subtract_int(&stcb->asoc.refcnt, 1);
451d61a0ae0SRandall Stewart 				return error;
452d61a0ae0SRandall Stewart 			}
453d61a0ae0SRandall Stewart 			SCTP_INP_INFO_RLOCK();
454d61a0ae0SRandall Stewart 			SCTP_INP_RLOCK(inp);
455d61a0ae0SRandall Stewart 			error = copy_out_local_addresses(inp, stcb, req);
456d61a0ae0SRandall Stewart 			if (error) {
457d61a0ae0SRandall Stewart 				SCTP_INP_DECR_REF(inp);
458851b7298SRandall Stewart 				atomic_subtract_int(&stcb->asoc.refcnt, 1);
45942551e99SRandall Stewart 				return error;
46042551e99SRandall Stewart 			}
46142551e99SRandall Stewart 			TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
462d61a0ae0SRandall Stewart 				xraddr.last = 0;
463d61a0ae0SRandall Stewart 				xraddr.address = net->ro._l_addr;
464d61a0ae0SRandall Stewart 				xraddr.active = ((net->dest_state & SCTP_ADDR_REACHABLE) == SCTP_ADDR_REACHABLE);
465d61a0ae0SRandall Stewart 				xraddr.confirmed = ((net->dest_state & SCTP_ADDR_UNCONFIRMED) == 0);
466d61a0ae0SRandall Stewart 				xraddr.heartbeat_enabled = ((net->dest_state & SCTP_ADDR_NOHB) == 0);
467d61a0ae0SRandall Stewart 				xraddr.rto = net->RTO;
468d61a0ae0SRandall Stewart 				xraddr.max_path_rtx = net->failure_threshold;
469d61a0ae0SRandall Stewart 				xraddr.rtx = net->marked_retrans;
470d61a0ae0SRandall Stewart 				xraddr.error_counter = net->error_count;
471d61a0ae0SRandall Stewart 				xraddr.cwnd = net->cwnd;
472d61a0ae0SRandall Stewart 				xraddr.flight_size = net->flight_size;
473d61a0ae0SRandall Stewart 				xraddr.mtu = net->mtu;
474e29d4aa6SRandall Stewart 				xraddr.rtt = net->rtt;
475851b7298SRandall Stewart 				xraddr.start_time.tv_sec = (uint32_t) net->start_time.tv_sec;
476851b7298SRandall Stewart 				xraddr.start_time.tv_usec = (uint32_t) net->start_time.tv_usec;
477d61a0ae0SRandall Stewart 				SCTP_INP_RUNLOCK(inp);
478d61a0ae0SRandall Stewart 				SCTP_INP_INFO_RUNLOCK();
47942551e99SRandall Stewart 				error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr));
48042551e99SRandall Stewart 				if (error) {
481d61a0ae0SRandall Stewart 					SCTP_INP_DECR_REF(inp);
482851b7298SRandall Stewart 					atomic_subtract_int(&stcb->asoc.refcnt, 1);
48342551e99SRandall Stewart 					return error;
48442551e99SRandall Stewart 				}
48542551e99SRandall Stewart 				SCTP_INP_INFO_RLOCK();
48642551e99SRandall Stewart 				SCTP_INP_RLOCK(inp);
48742551e99SRandall Stewart 			}
488851b7298SRandall Stewart 			atomic_subtract_int(&stcb->asoc.refcnt, 1);
489d61a0ae0SRandall Stewart 			memset((void *)&xraddr, 0, sizeof(struct xsctp_raddr));
490d61a0ae0SRandall Stewart 			xraddr.last = 1;
49142551e99SRandall Stewart 			SCTP_INP_RUNLOCK(inp);
492d61a0ae0SRandall Stewart 			SCTP_INP_INFO_RUNLOCK();
493d61a0ae0SRandall Stewart 			error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr));
494d61a0ae0SRandall Stewart 			if (error) {
495d61a0ae0SRandall Stewart 				SCTP_INP_DECR_REF(inp);
496d61a0ae0SRandall Stewart 				return error;
497d61a0ae0SRandall Stewart 			}
498d61a0ae0SRandall Stewart 			SCTP_INP_INFO_RLOCK();
499d61a0ae0SRandall Stewart 			SCTP_INP_RLOCK(inp);
500d61a0ae0SRandall Stewart 		}
501851b7298SRandall Stewart 		SCTP_INP_DECR_REF(inp);
502d61a0ae0SRandall Stewart 		SCTP_INP_RUNLOCK(inp);
503d61a0ae0SRandall Stewart 		SCTP_INP_INFO_RUNLOCK();
504d61a0ae0SRandall Stewart 		memset((void *)&xstcb, 0, sizeof(struct xsctp_tcb));
505d61a0ae0SRandall Stewart 		xstcb.last = 1;
506d61a0ae0SRandall Stewart 		error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb));
507d61a0ae0SRandall Stewart 		if (error) {
508d61a0ae0SRandall Stewart 			return error;
509d61a0ae0SRandall Stewart 		}
510*8ce4a9a2SRandall Stewart skip:
511d61a0ae0SRandall Stewart 		SCTP_INP_INFO_RLOCK();
51242551e99SRandall Stewart 	}
51342551e99SRandall Stewart 	SCTP_INP_INFO_RUNLOCK();
51442551e99SRandall Stewart 
515d61a0ae0SRandall Stewart 	memset((void *)&xinpcb, 0, sizeof(struct xsctp_inpcb));
51642551e99SRandall Stewart 	xinpcb.last = 1;
51742551e99SRandall Stewart 	error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb));
51842551e99SRandall Stewart 	return error;
51942551e99SRandall Stewart }
52042551e99SRandall Stewart 
521c54a18d2SRandall Stewart 
522851b7298SRandall Stewart #define RANGECHK(var, min, max) \
523851b7298SRandall Stewart 	if ((var) < (min)) { (var) = (min); } \
524851b7298SRandall Stewart 	else if ((var) > (max)) { (var) = (max); }
525851b7298SRandall Stewart 
526851b7298SRandall Stewart static int
527c54a18d2SRandall Stewart sysctl_sctp_udp_tunneling_check(SYSCTL_HANDLER_ARGS)
528c54a18d2SRandall Stewart {
529c54a18d2SRandall Stewart 	int error;
530c54a18d2SRandall Stewart 	uint32_t old_sctp_udp_tunneling_port;
531c54a18d2SRandall Stewart 
532be27fdd0SRandall Stewart 	SCTP_INP_INFO_RLOCK();
533b3f1ea41SRandall Stewart 	old_sctp_udp_tunneling_port = SCTP_BASE_SYSCTL(sctp_udp_tunneling_port);
534be27fdd0SRandall Stewart 	SCTP_INP_INFO_RUNLOCK();
535c54a18d2SRandall Stewart 	error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
536c54a18d2SRandall Stewart 	if (error == 0) {
537b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port), SCTPCTL_UDP_TUNNELING_PORT_MIN, SCTPCTL_UDP_TUNNELING_PORT_MAX);
538a99b6783SRandall Stewart 		if (old_sctp_udp_tunneling_port == SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)) {
539a99b6783SRandall Stewart 			error = 0;
540a99b6783SRandall Stewart 			goto out;
541a99b6783SRandall Stewart 		}
542be27fdd0SRandall Stewart 		SCTP_INP_INFO_WLOCK();
543c54a18d2SRandall Stewart 		if (old_sctp_udp_tunneling_port) {
544c54a18d2SRandall Stewart 			sctp_over_udp_stop();
545c54a18d2SRandall Stewart 		}
546b3f1ea41SRandall Stewart 		if (SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)) {
547c54a18d2SRandall Stewart 			if (sctp_over_udp_start()) {
548b3f1ea41SRandall Stewart 				SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = 0;
549c54a18d2SRandall Stewart 			}
550c54a18d2SRandall Stewart 		}
551be27fdd0SRandall Stewart 		SCTP_INP_INFO_WUNLOCK();
552c54a18d2SRandall Stewart 	}
553a99b6783SRandall Stewart out:
554c54a18d2SRandall Stewart 	return (error);
555c54a18d2SRandall Stewart }
556c54a18d2SRandall Stewart 
557b3f1ea41SRandall Stewart 
558c54a18d2SRandall Stewart static int
559851b7298SRandall Stewart sysctl_sctp_check(SYSCTL_HANDLER_ARGS)
560851b7298SRandall Stewart {
561851b7298SRandall Stewart 	int error;
562851b7298SRandall Stewart 
563851b7298SRandall Stewart 	error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
564851b7298SRandall Stewart 	if (error == 0) {
565b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_sendspace), SCTPCTL_MAXDGRAM_MIN, SCTPCTL_MAXDGRAM_MAX);
566b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_recvspace), SCTPCTL_RECVSPACE_MIN, SCTPCTL_RECVSPACE_MAX);
567b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_auto_asconf), SCTPCTL_AUTOASCONF_MIN, SCTPCTL_AUTOASCONF_MAX);
568b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_ecn_enable), SCTPCTL_ECN_ENABLE_MIN, SCTPCTL_ECN_ENABLE_MAX);
569b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_ecn_nonce), SCTPCTL_ECN_NONCE_MIN, SCTPCTL_ECN_NONCE_MAX);
570b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_strict_sacks), SCTPCTL_STRICT_SACKS_MIN, SCTPCTL_STRICT_SACKS_MAX);
571b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback), SCTPCTL_LOOPBACK_NOCSUM_MIN, SCTPCTL_LOOPBACK_NOCSUM_MAX);
572b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_strict_init), SCTPCTL_STRICT_INIT_MIN, SCTPCTL_STRICT_INIT_MAX);
573b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_peer_chunk_oh), SCTPCTL_PEER_CHKOH_MIN, SCTPCTL_PEER_CHKOH_MAX);
574b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_max_burst_default), SCTPCTL_MAXBURST_MIN, SCTPCTL_MAXBURST_MAX);
575b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue), SCTPCTL_MAXCHUNKS_MIN, SCTPCTL_MAXCHUNKS_MAX);
576b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_hashtblsize), SCTPCTL_TCBHASHSIZE_MIN, SCTPCTL_TCBHASHSIZE_MAX);
577b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_pcbtblsize), SCTPCTL_PCBHASHSIZE_MIN, SCTPCTL_PCBHASHSIZE_MAX);
578b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_min_split_point), SCTPCTL_MIN_SPLIT_POINT_MIN, SCTPCTL_MIN_SPLIT_POINT_MAX);
579b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_chunkscale), SCTPCTL_CHUNKSCALE_MIN, SCTPCTL_CHUNKSCALE_MAX);
580b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default), SCTPCTL_DELAYED_SACK_TIME_MIN, SCTPCTL_DELAYED_SACK_TIME_MAX);
581b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_sack_freq_default), SCTPCTL_SACK_FREQ_MIN, SCTPCTL_SACK_FREQ_MAX);
582b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_system_free_resc_limit), SCTPCTL_SYS_RESOURCE_MIN, SCTPCTL_SYS_RESOURCE_MAX);
583b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit), SCTPCTL_ASOC_RESOURCE_MIN, SCTPCTL_ASOC_RESOURCE_MAX);
584b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default), SCTPCTL_HEARTBEAT_INTERVAL_MIN, SCTPCTL_HEARTBEAT_INTERVAL_MAX);
585b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default), SCTPCTL_PMTU_RAISE_TIME_MIN, SCTPCTL_PMTU_RAISE_TIME_MAX);
586b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default), SCTPCTL_SHUTDOWN_GUARD_TIME_MIN, SCTPCTL_SHUTDOWN_GUARD_TIME_MAX);
587b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_secret_lifetime_default), SCTPCTL_SECRET_LIFETIME_MIN, SCTPCTL_SECRET_LIFETIME_MAX);
588b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_max_default), SCTPCTL_RTO_MAX_MIN, SCTPCTL_RTO_MAX_MAX);
589b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_min_default), SCTPCTL_RTO_MIN_MIN, SCTPCTL_RTO_MIN_MAX);
590b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_initial_default), SCTPCTL_RTO_INITIAL_MIN, SCTPCTL_RTO_INITIAL_MAX);
591b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_init_rto_max_default), SCTPCTL_INIT_RTO_MAX_MIN, SCTPCTL_INIT_RTO_MAX_MAX);
592b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default), SCTPCTL_VALID_COOKIE_LIFE_MIN, SCTPCTL_VALID_COOKIE_LIFE_MAX);
593b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_init_rtx_max_default), SCTPCTL_INIT_RTX_MAX_MIN, SCTPCTL_INIT_RTX_MAX_MAX);
594b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default), SCTPCTL_ASSOC_RTX_MAX_MIN, SCTPCTL_ASSOC_RTX_MAX_MAX);
595b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_path_rtx_max_default), SCTPCTL_PATH_RTX_MAX_MIN, SCTPCTL_PATH_RTX_MAX_MAX);
596b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_add_more_threshold), SCTPCTL_ADD_MORE_ON_OUTPUT_MIN, SCTPCTL_ADD_MORE_ON_OUTPUT_MAX);
597b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default), SCTPCTL_OUTGOING_STREAMS_MIN, SCTPCTL_OUTGOING_STREAMS_MAX);
598b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_on_off), SCTPCTL_CMT_ON_OFF_MIN, SCTPCTL_CMT_ON_OFF_MAX);
599830d754dSRandall Stewart 		/* EY */
600830d754dSRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_nr_sack_on_off), SCTPCTL_NR_SACK_ON_OFF_MIN, SCTPCTL_NR_SACK_ON_OFF_MAX);
601b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_use_dac), SCTPCTL_CMT_USE_DAC_MIN, SCTPCTL_CMT_USE_DAC_MAX);
602b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_pf), SCTPCTL_CMT_PF_MIN, SCTPCTL_CMT_PF_MAX);
603b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst), SCTPCTL_CWND_MAXBURST_MIN, SCTPCTL_CWND_MAXBURST_MAX);
604b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_early_fr), SCTPCTL_EARLY_FAST_RETRAN_MIN, SCTPCTL_EARLY_FAST_RETRAN_MAX);
605b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_early_fr_msec), SCTPCTL_EARLY_FAST_RETRAN_MSEC_MIN, SCTPCTL_EARLY_FAST_RETRAN_MSEC_MAX);
606b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_asconf_auth_nochk), SCTPCTL_ASCONF_AUTH_NOCHK_MIN, SCTPCTL_ASCONF_AUTH_NOCHK_MAX);
607b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_auth_disable), SCTPCTL_AUTH_DISABLE_MIN, SCTPCTL_AUTH_DISABLE_MAX);
608b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_nat_friendly), SCTPCTL_NAT_FRIENDLY_MIN, SCTPCTL_NAT_FRIENDLY_MAX);
609b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_L2_abc_variable), SCTPCTL_ABC_L_VAR_MIN, SCTPCTL_ABC_L_VAR_MAX);
610b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count), SCTPCTL_MAX_CHAINED_MBUFS_MIN, SCTPCTL_MAX_CHAINED_MBUFS_MAX);
611b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_do_drain), SCTPCTL_DO_SCTP_DRAIN_MIN, SCTPCTL_DO_SCTP_DRAIN_MAX);
612b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_hb_maxburst), SCTPCTL_HB_MAX_BURST_MIN, SCTPCTL_HB_MAX_BURST_MAX);
613b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit), SCTPCTL_ABORT_AT_LIMIT_MIN, SCTPCTL_ABORT_AT_LIMIT_MAX);
614b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_strict_data_order), SCTPCTL_STRICT_DATA_ORDER_MIN, SCTPCTL_STRICT_DATA_ORDER_MAX);
615b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_min_residual), SCTPCTL_MIN_RESIDUAL_MIN, SCTPCTL_MIN_RESIDUAL_MAX);
616b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_max_retran_chunk), SCTPCTL_MAX_RETRAN_CHUNK_MIN, SCTPCTL_MAX_RETRAN_CHUNK_MAX);
617b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_logging_level), SCTPCTL_LOGGING_LEVEL_MIN, SCTPCTL_LOGGING_LEVEL_MAX);
618b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_default_cc_module), SCTPCTL_DEFAULT_CC_MODULE_MIN, SCTPCTL_DEFAULT_CC_MODULE_MAX);
619b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_default_frag_interleave), SCTPCTL_DEFAULT_FRAG_INTERLEAVE_MIN, SCTPCTL_DEFAULT_FRAG_INTERLEAVE_MAX);
620a16ccdceSRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_vtag_time_wait), SCTPCTL_TIME_WAIT_MIN, SCTPCTL_TIME_WAIT_MAX);
621a16ccdceSRandall Stewart 
622b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_mobility_base), SCTPCTL_MOBILITY_BASE_MIN, SCTPCTL_MOBILITY_BASE_MAX);
623b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff), SCTPCTL_MOBILITY_FASTHANDOFF_MIN, SCTPCTL_MOBILITY_FASTHANDOFF_MAX);
624b3f1ea41SRandall 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);
625b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_enable_sack_immediately), SCTPCTL_SACK_IMMEDIATELY_ENABLE_MIN, SCTPCTL_SACK_IMMEDIATELY_ENABLE_MAX);
626bf3d5177SMichael Tuexen 		RANGECHK(SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly), SCTPCTL_NAT_FRIENDLY_INITS_MIN, SCTPCTL_NAT_FRIENDLY_INITS_MAX);
627830d754dSRandall Stewart 
628851b7298SRandall Stewart #ifdef SCTP_DEBUG
629b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_debug_on), SCTPCTL_DEBUG_MIN, SCTPCTL_DEBUG_MAX);
630b3f1ea41SRandall Stewart #endif
631b3f1ea41SRandall Stewart #if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
632b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_output_unlocked), SCTPCTL_OUTPUT_UNLOCKED_MIN, SCTPCTL_OUTPUT_UNLOCKED_MAX);
633851b7298SRandall Stewart #endif
634851b7298SRandall Stewart 	}
635851b7298SRandall Stewart 	return (error);
636851b7298SRandall Stewart }
63742551e99SRandall Stewart 
638ff014514SRandall Stewart #if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
639ff014514SRandall Stewart static int
640ff014514SRandall Stewart sysctl_stat_get(SYSCTL_HANDLER_ARGS)
641ff014514SRandall Stewart {
642ff014514SRandall Stewart 	int cpu, error;
643ff014514SRandall Stewart 	struct sctpstat sb, *sarry;
644b3f1ea41SRandall Stewart 
645ff014514SRandall Stewart 	memset(&sb, 0, sizeof(sb));
646ff014514SRandall Stewart 	for (cpu = 0; cpu < mp_ncpus; cpu++) {
647ff014514SRandall Stewart 		sarry = &SCTP_BASE_STATS[cpu];
648ff014514SRandall Stewart 		if (sarry->sctps_discontinuitytime.tv_sec > sb.sctps_discontinuitytime.tv_sec) {
649ff014514SRandall Stewart 			sb.sctps_discontinuitytime.tv_sec = sarry->sctps_discontinuitytime.tv_sec;
650ff014514SRandall Stewart 			sb.sctps_discontinuitytime.tv_usec = sarry->sctps_discontinuitytime.tv_usec;
651ff014514SRandall Stewart 		}
652ff014514SRandall Stewart 		sb.sctps_currestab += sarry->sctps_currestab;
653ff014514SRandall Stewart 		sb.sctps_activeestab += sarry->sctps_activeestab;
654ff014514SRandall Stewart 		sb.sctps_restartestab += sarry->sctps_restartestab;
655ff014514SRandall Stewart 		sb.sctps_collisionestab += sarry->sctps_collisionestab;
656ff014514SRandall Stewart 		sb.sctps_passiveestab += sarry->sctps_passiveestab;
657ff014514SRandall Stewart 		sb.sctps_aborted += sarry->sctps_aborted;
658ff014514SRandall Stewart 		sb.sctps_shutdown += sarry->sctps_shutdown;
659ff014514SRandall Stewart 		sb.sctps_outoftheblue += sarry->sctps_outoftheblue;
660ff014514SRandall Stewart 		sb.sctps_checksumerrors += sarry->sctps_checksumerrors;
661ff014514SRandall Stewart 		sb.sctps_outcontrolchunks += sarry->sctps_outcontrolchunks;
662ff014514SRandall Stewart 		sb.sctps_outorderchunks += sarry->sctps_outorderchunks;
663ff014514SRandall Stewart 		sb.sctps_outunorderchunks += sarry->sctps_outunorderchunks;
664ff014514SRandall Stewart 		sb.sctps_incontrolchunks += sarry->sctps_incontrolchunks;
665ff014514SRandall Stewart 		sb.sctps_inorderchunks += sarry->sctps_inorderchunks;
666ff014514SRandall Stewart 		sb.sctps_inunorderchunks += sarry->sctps_inunorderchunks;
667ff014514SRandall Stewart 		sb.sctps_fragusrmsgs += sarry->sctps_fragusrmsgs;
668ff014514SRandall Stewart 		sb.sctps_reasmusrmsgs += sarry->sctps_reasmusrmsgs;
669ff014514SRandall Stewart 		sb.sctps_outpackets += sarry->sctps_outpackets;
670ff014514SRandall Stewart 		sb.sctps_inpackets += sarry->sctps_inpackets;
671ff014514SRandall Stewart 		sb.sctps_recvpackets += sarry->sctps_recvpackets;
672ff014514SRandall Stewart 		sb.sctps_recvdatagrams += sarry->sctps_recvdatagrams;
673ff014514SRandall Stewart 		sb.sctps_recvpktwithdata += sarry->sctps_recvpktwithdata;
674ff014514SRandall Stewart 		sb.sctps_recvsacks += sarry->sctps_recvsacks;
675ff014514SRandall Stewart 		sb.sctps_recvdata += sarry->sctps_recvdata;
676ff014514SRandall Stewart 		sb.sctps_recvdupdata += sarry->sctps_recvdupdata;
677ff014514SRandall Stewart 		sb.sctps_recvheartbeat += sarry->sctps_recvheartbeat;
678ff014514SRandall Stewart 		sb.sctps_recvheartbeatack += sarry->sctps_recvheartbeatack;
679ff014514SRandall Stewart 		sb.sctps_recvecne += sarry->sctps_recvecne;
680ff014514SRandall Stewart 		sb.sctps_recvauth += sarry->sctps_recvauth;
681ff014514SRandall Stewart 		sb.sctps_recvauthmissing += sarry->sctps_recvauthmissing;
682ff014514SRandall Stewart 		sb.sctps_recvivalhmacid += sarry->sctps_recvivalhmacid;
683ff014514SRandall Stewart 		sb.sctps_recvivalkeyid += sarry->sctps_recvivalkeyid;
684ff014514SRandall Stewart 		sb.sctps_recvauthfailed += sarry->sctps_recvauthfailed;
685ff014514SRandall Stewart 		sb.sctps_recvexpress += sarry->sctps_recvexpress;
686ff014514SRandall Stewart 		sb.sctps_recvexpressm += sarry->sctps_recvexpressm;
687ff014514SRandall Stewart 		sb.sctps_recvnocrc += sarry->sctps_recvnocrc;
688ff014514SRandall Stewart 		sb.sctps_recvswcrc += sarry->sctps_recvswcrc;
689ff014514SRandall Stewart 		sb.sctps_recvhwcrc += sarry->sctps_recvhwcrc;
690ff014514SRandall Stewart 		sb.sctps_sendpackets += sarry->sctps_sendpackets;
691ff014514SRandall Stewart 		sb.sctps_sendsacks += sarry->sctps_sendsacks;
692ff014514SRandall Stewart 		sb.sctps_senddata += sarry->sctps_senddata;
693ff014514SRandall Stewart 		sb.sctps_sendretransdata += sarry->sctps_sendretransdata;
694ff014514SRandall Stewart 		sb.sctps_sendfastretrans += sarry->sctps_sendfastretrans;
695ff014514SRandall Stewart 		sb.sctps_sendmultfastretrans += sarry->sctps_sendmultfastretrans;
696ff014514SRandall Stewart 		sb.sctps_sendheartbeat += sarry->sctps_sendheartbeat;
697ff014514SRandall Stewart 		sb.sctps_sendecne += sarry->sctps_sendecne;
698ff014514SRandall Stewart 		sb.sctps_sendauth += sarry->sctps_sendauth;
699ff014514SRandall Stewart 		sb.sctps_senderrors += sarry->sctps_senderrors;
700ff014514SRandall Stewart 		sb.sctps_sendnocrc += sarry->sctps_sendnocrc;
701ff014514SRandall Stewart 		sb.sctps_sendswcrc += sarry->sctps_sendswcrc;
702ff014514SRandall Stewart 		sb.sctps_sendhwcrc += sarry->sctps_sendhwcrc;
703ff014514SRandall Stewart 		sb.sctps_pdrpfmbox += sarry->sctps_pdrpfmbox;
704ff014514SRandall Stewart 		sb.sctps_pdrpfehos += sarry->sctps_pdrpfehos;
705ff014514SRandall Stewart 		sb.sctps_pdrpmbda += sarry->sctps_pdrpmbda;
706ff014514SRandall Stewart 		sb.sctps_pdrpmbct += sarry->sctps_pdrpmbct;
707ff014514SRandall Stewart 		sb.sctps_pdrpbwrpt += sarry->sctps_pdrpbwrpt;
708ff014514SRandall Stewart 		sb.sctps_pdrpcrupt += sarry->sctps_pdrpcrupt;
709ff014514SRandall Stewart 		sb.sctps_pdrpnedat += sarry->sctps_pdrpnedat;
710ff014514SRandall Stewart 		sb.sctps_pdrppdbrk += sarry->sctps_pdrppdbrk;
711ff014514SRandall Stewart 		sb.sctps_pdrptsnnf += sarry->sctps_pdrptsnnf;
712ff014514SRandall Stewart 		sb.sctps_pdrpdnfnd += sarry->sctps_pdrpdnfnd;
713ff014514SRandall Stewart 		sb.sctps_pdrpdiwnp += sarry->sctps_pdrpdiwnp;
714ff014514SRandall Stewart 		sb.sctps_pdrpdizrw += sarry->sctps_pdrpdizrw;
715ff014514SRandall Stewart 		sb.sctps_pdrpbadd += sarry->sctps_pdrpbadd;
716ff014514SRandall Stewart 		sb.sctps_pdrpmark += sarry->sctps_pdrpmark;
717ff014514SRandall Stewart 		sb.sctps_timoiterator += sarry->sctps_timoiterator;
718ff014514SRandall Stewart 		sb.sctps_timodata += sarry->sctps_timodata;
719ff014514SRandall Stewart 		sb.sctps_timowindowprobe += sarry->sctps_timowindowprobe;
720ff014514SRandall Stewart 		sb.sctps_timoinit += sarry->sctps_timoinit;
721ff014514SRandall Stewart 		sb.sctps_timosack += sarry->sctps_timosack;
722ff014514SRandall Stewart 		sb.sctps_timoshutdown += sarry->sctps_timoshutdown;
723ff014514SRandall Stewart 		sb.sctps_timoheartbeat += sarry->sctps_timoheartbeat;
724ff014514SRandall Stewart 		sb.sctps_timocookie += sarry->sctps_timocookie;
725ff014514SRandall Stewart 		sb.sctps_timosecret += sarry->sctps_timosecret;
726ff014514SRandall Stewart 		sb.sctps_timopathmtu += sarry->sctps_timopathmtu;
727ff014514SRandall Stewart 		sb.sctps_timoshutdownack += sarry->sctps_timoshutdownack;
728ff014514SRandall Stewart 		sb.sctps_timoshutdownguard += sarry->sctps_timoshutdownguard;
729ff014514SRandall Stewart 		sb.sctps_timostrmrst += sarry->sctps_timostrmrst;
730ff014514SRandall Stewart 		sb.sctps_timoearlyfr += sarry->sctps_timoearlyfr;
731ff014514SRandall Stewart 		sb.sctps_timoasconf += sarry->sctps_timoasconf;
732ff014514SRandall Stewart 		sb.sctps_timodelprim += sarry->sctps_timodelprim;
733ff014514SRandall Stewart 		sb.sctps_timoautoclose += sarry->sctps_timoautoclose;
734ff014514SRandall Stewart 		sb.sctps_timoassockill += sarry->sctps_timoassockill;
735ff014514SRandall Stewart 		sb.sctps_timoinpkill += sarry->sctps_timoinpkill;
736ff014514SRandall Stewart 		sb.sctps_earlyfrstart += sarry->sctps_earlyfrstart;
737ff014514SRandall Stewart 		sb.sctps_earlyfrstop += sarry->sctps_earlyfrstop;
738ff014514SRandall Stewart 		sb.sctps_earlyfrmrkretrans += sarry->sctps_earlyfrmrkretrans;
739ff014514SRandall Stewart 		sb.sctps_earlyfrstpout += sarry->sctps_earlyfrstpout;
740ff014514SRandall Stewart 		sb.sctps_earlyfrstpidsck1 += sarry->sctps_earlyfrstpidsck1;
741ff014514SRandall Stewart 		sb.sctps_earlyfrstpidsck2 += sarry->sctps_earlyfrstpidsck2;
742ff014514SRandall Stewart 		sb.sctps_earlyfrstpidsck3 += sarry->sctps_earlyfrstpidsck3;
743ff014514SRandall Stewart 		sb.sctps_earlyfrstpidsck4 += sarry->sctps_earlyfrstpidsck4;
744ff014514SRandall Stewart 		sb.sctps_earlyfrstrid += sarry->sctps_earlyfrstrid;
745ff014514SRandall Stewart 		sb.sctps_earlyfrstrout += sarry->sctps_earlyfrstrout;
746ff014514SRandall Stewart 		sb.sctps_earlyfrstrtmr += sarry->sctps_earlyfrstrtmr;
747ff014514SRandall Stewart 		sb.sctps_hdrops += sarry->sctps_hdrops;
748ff014514SRandall Stewart 		sb.sctps_badsum += sarry->sctps_badsum;
749ff014514SRandall Stewart 		sb.sctps_noport += sarry->sctps_noport;
750ff014514SRandall Stewart 		sb.sctps_badvtag += sarry->sctps_badvtag;
751ff014514SRandall Stewart 		sb.sctps_badsid += sarry->sctps_badsid;
752ff014514SRandall Stewart 		sb.sctps_nomem += sarry->sctps_nomem;
753ff014514SRandall Stewart 		sb.sctps_fastretransinrtt += sarry->sctps_fastretransinrtt;
754ff014514SRandall Stewart 		sb.sctps_markedretrans += sarry->sctps_markedretrans;
755ff014514SRandall Stewart 		sb.sctps_naglesent += sarry->sctps_naglesent;
756ff014514SRandall Stewart 		sb.sctps_naglequeued += sarry->sctps_naglequeued;
757ff014514SRandall Stewart 		sb.sctps_maxburstqueued += sarry->sctps_maxburstqueued;
758ff014514SRandall Stewart 		sb.sctps_ifnomemqueued += sarry->sctps_ifnomemqueued;
759ff014514SRandall Stewart 		sb.sctps_windowprobed += sarry->sctps_windowprobed;
760ff014514SRandall Stewart 		sb.sctps_lowlevelerr += sarry->sctps_lowlevelerr;
761ff014514SRandall Stewart 		sb.sctps_lowlevelerrusr += sarry->sctps_lowlevelerrusr;
762ff014514SRandall Stewart 		sb.sctps_datadropchklmt += sarry->sctps_datadropchklmt;
763ff014514SRandall Stewart 		sb.sctps_datadroprwnd += sarry->sctps_datadroprwnd;
764ff014514SRandall Stewart 		sb.sctps_ecnereducedcwnd += sarry->sctps_ecnereducedcwnd;
765ff014514SRandall Stewart 		sb.sctps_vtagexpress += sarry->sctps_vtagexpress;
766ff014514SRandall Stewart 		sb.sctps_vtagbogus += sarry->sctps_vtagbogus;
767ff014514SRandall Stewart 		sb.sctps_primary_randry += sarry->sctps_primary_randry;
768ff014514SRandall Stewart 		sb.sctps_cmt_randry += sarry->sctps_cmt_randry;
769ff014514SRandall Stewart 		sb.sctps_slowpath_sack += sarry->sctps_slowpath_sack;
770ff014514SRandall Stewart 		sb.sctps_wu_sacks_sent += sarry->sctps_wu_sacks_sent;
771ff014514SRandall Stewart 		sb.sctps_sends_with_flags += sarry->sctps_sends_with_flags;
772ff014514SRandall Stewart 		sb.sctps_sends_with_unord += sarry->sctps_sends_with_unord;
773ff014514SRandall Stewart 		sb.sctps_sends_with_eof += sarry->sctps_sends_with_eof;
774ff014514SRandall Stewart 		sb.sctps_sends_with_abort += sarry->sctps_sends_with_abort;
775ff014514SRandall Stewart 		sb.sctps_protocol_drain_calls += sarry->sctps_protocol_drain_calls;
776ff014514SRandall Stewart 		sb.sctps_protocol_drains_done += sarry->sctps_protocol_drains_done;
777ff014514SRandall Stewart 		sb.sctps_read_peeks += sarry->sctps_read_peeks;
778ff014514SRandall Stewart 		sb.sctps_cached_chk += sarry->sctps_cached_chk;
779ff014514SRandall Stewart 		sb.sctps_cached_strmoq += sarry->sctps_cached_strmoq;
780ff014514SRandall Stewart 		sb.sctps_left_abandon += sarry->sctps_left_abandon;
781ff014514SRandall Stewart 		sb.sctps_send_burst_avoid += sarry->sctps_send_burst_avoid;
782ff014514SRandall Stewart 		sb.sctps_send_cwnd_avoid += sarry->sctps_send_cwnd_avoid;
783ff014514SRandall Stewart 		sb.sctps_fwdtsn_map_over += sarry->sctps_fwdtsn_map_over;
784ff014514SRandall Stewart 	}
785ff014514SRandall Stewart 	error = SYSCTL_OUT(req, &sb, sizeof(sb));
786ff014514SRandall Stewart 	return (error);
787ff014514SRandall Stewart }
788ff014514SRandall Stewart 
789ff014514SRandall Stewart #endif
790b3f1ea41SRandall Stewart 
791b3f1ea41SRandall Stewart #if defined(SCTP_LOCAL_TRACE_BUF)
792b3f1ea41SRandall Stewart static int
793b3f1ea41SRandall Stewart sysctl_sctp_cleartrace(SYSCTL_HANDLER_ARGS)
794b3f1ea41SRandall Stewart {
795a99b6783SRandall Stewart 	int error = 0;
796a99b6783SRandall Stewart 
797b3f1ea41SRandall Stewart 	memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log));
798a99b6783SRandall Stewart 	return (error);
799b3f1ea41SRandall Stewart }
800b3f1ea41SRandall Stewart 
801b3f1ea41SRandall Stewart #endif
802b3f1ea41SRandall Stewart 
803b3f1ea41SRandall Stewart 
80442551e99SRandall Stewart /*
80542551e99SRandall Stewart  * sysctl definitions
80642551e99SRandall Stewart  */
80742551e99SRandall Stewart 
808851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, sendspace, CTLTYPE_INT | CTLFLAG_RW,
809b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_sendspace), 0, sysctl_sctp_check, "IU",
810851b7298SRandall Stewart     SCTPCTL_MAXDGRAM_DESC);
81142551e99SRandall Stewart 
812851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, recvspace, CTLTYPE_INT | CTLFLAG_RW,
813b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_recvspace), 0, sysctl_sctp_check, "IU",
814851b7298SRandall Stewart     SCTPCTL_RECVSPACE_DESC);
81542551e99SRandall Stewart 
816851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, auto_asconf, CTLTYPE_INT | CTLFLAG_RW,
817b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_auto_asconf), 0, sysctl_sctp_check, "IU",
818851b7298SRandall Stewart     SCTPCTL_AUTOASCONF_DESC);
81942551e99SRandall Stewart 
820851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, ecn_enable, CTLTYPE_INT | CTLFLAG_RW,
821b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_ecn_enable), 0, sysctl_sctp_check, "IU",
822851b7298SRandall Stewart     SCTPCTL_ECN_ENABLE_DESC);
82342551e99SRandall Stewart 
824851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, ecn_nonce, CTLTYPE_INT | CTLFLAG_RW,
825b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_ecn_nonce), 0, sysctl_sctp_check, "IU",
826851b7298SRandall Stewart     SCTPCTL_ECN_NONCE_DESC);
82742551e99SRandall Stewart 
828851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, strict_sacks, CTLTYPE_INT | CTLFLAG_RW,
829b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_strict_sacks), 0, sysctl_sctp_check, "IU",
830851b7298SRandall Stewart     SCTPCTL_STRICT_SACKS_DESC);
83142551e99SRandall Stewart 
832851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, loopback_nocsum, CTLTYPE_INT | CTLFLAG_RW,
833b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback), 0, sysctl_sctp_check, "IU",
834851b7298SRandall Stewart     SCTPCTL_LOOPBACK_NOCSUM_DESC);
83542551e99SRandall Stewart 
836851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, strict_init, CTLTYPE_INT | CTLFLAG_RW,
837b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_strict_init), 0, sysctl_sctp_check, "IU",
838851b7298SRandall Stewart     SCTPCTL_STRICT_INIT_DESC);
83942551e99SRandall Stewart 
840851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, peer_chkoh, CTLTYPE_INT | CTLFLAG_RW,
841b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_peer_chunk_oh), 0, sysctl_sctp_check, "IU",
842851b7298SRandall Stewart     SCTPCTL_PEER_CHKOH_DESC);
84342551e99SRandall Stewart 
844851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, maxburst, CTLTYPE_INT | CTLFLAG_RW,
845b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_max_burst_default), 0, sysctl_sctp_check, "IU",
846851b7298SRandall Stewart     SCTPCTL_MAXBURST_DESC);
84742551e99SRandall Stewart 
848851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, maxchunks, CTLTYPE_INT | CTLFLAG_RW,
849b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue), 0, sysctl_sctp_check, "IU",
850851b7298SRandall Stewart     SCTPCTL_MAXCHUNKS_DESC);
85142551e99SRandall Stewart 
852851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, tcbhashsize, CTLTYPE_INT | CTLFLAG_RW,
853b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_hashtblsize), 0, sysctl_sctp_check, "IU",
854851b7298SRandall Stewart     SCTPCTL_TCBHASHSIZE_DESC);
85542551e99SRandall Stewart 
856851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, pcbhashsize, CTLTYPE_INT | CTLFLAG_RW,
857b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_pcbtblsize), 0, sysctl_sctp_check, "IU",
858851b7298SRandall Stewart     SCTPCTL_PCBHASHSIZE_DESC);
85942551e99SRandall Stewart 
860851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, min_split_point, CTLTYPE_INT | CTLFLAG_RW,
861b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_min_split_point), 0, sysctl_sctp_check, "IU",
862851b7298SRandall Stewart     SCTPCTL_MIN_SPLIT_POINT_DESC);
86342551e99SRandall Stewart 
864851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, chunkscale, CTLTYPE_INT | CTLFLAG_RW,
865b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_chunkscale), 0, sysctl_sctp_check, "IU",
866851b7298SRandall Stewart     SCTPCTL_CHUNKSCALE_DESC);
86742551e99SRandall Stewart 
868851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, delayed_sack_time, CTLTYPE_INT | CTLFLAG_RW,
869b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default), 0, sysctl_sctp_check, "IU",
870851b7298SRandall Stewart     SCTPCTL_DELAYED_SACK_TIME_DESC);
87142551e99SRandall Stewart 
872851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, sack_freq, CTLTYPE_INT | CTLFLAG_RW,
873b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_sack_freq_default), 0, sysctl_sctp_check, "IU",
874851b7298SRandall Stewart     SCTPCTL_SACK_FREQ_DESC);
87542551e99SRandall Stewart 
876851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, sys_resource, CTLTYPE_INT | CTLFLAG_RW,
877b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_system_free_resc_limit), 0, sysctl_sctp_check, "IU",
878851b7298SRandall Stewart     SCTPCTL_SYS_RESOURCE_DESC);
87942551e99SRandall Stewart 
880851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, asoc_resource, CTLTYPE_INT | CTLFLAG_RW,
881b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit), 0, sysctl_sctp_check, "IU",
882851b7298SRandall Stewart     SCTPCTL_ASOC_RESOURCE_DESC);
88342551e99SRandall Stewart 
884851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, heartbeat_interval, CTLTYPE_INT | CTLFLAG_RW,
885b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default), 0, sysctl_sctp_check, "IU",
886851b7298SRandall Stewart     SCTPCTL_HEARTBEAT_INTERVAL_DESC);
88742551e99SRandall Stewart 
888851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, pmtu_raise_time, CTLTYPE_INT | CTLFLAG_RW,
889b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default), 0, sysctl_sctp_check, "IU",
890851b7298SRandall Stewart     SCTPCTL_PMTU_RAISE_TIME_DESC);
89142551e99SRandall Stewart 
892851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, shutdown_guard_time, CTLTYPE_INT | CTLFLAG_RW,
893b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default), 0, sysctl_sctp_check, "IU",
894851b7298SRandall Stewart     SCTPCTL_SHUTDOWN_GUARD_TIME_DESC);
89542551e99SRandall Stewart 
896851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, secret_lifetime, CTLTYPE_INT | CTLFLAG_RW,
897b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_secret_lifetime_default), 0, sysctl_sctp_check, "IU",
898851b7298SRandall Stewart     SCTPCTL_SECRET_LIFETIME_DESC);
89942551e99SRandall Stewart 
900851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, rto_max, CTLTYPE_INT | CTLFLAG_RW,
901b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_rto_max_default), 0, sysctl_sctp_check, "IU",
902851b7298SRandall Stewart     SCTPCTL_RTO_MAX_DESC);
90342551e99SRandall Stewart 
904851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, rto_min, CTLTYPE_INT | CTLFLAG_RW,
905b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_rto_min_default), 0, sysctl_sctp_check, "IU",
906851b7298SRandall Stewart     SCTPCTL_RTO_MIN_DESC);
90742551e99SRandall Stewart 
908851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, rto_initial, CTLTYPE_INT | CTLFLAG_RW,
909b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_rto_initial_default), 0, sysctl_sctp_check, "IU",
910851b7298SRandall Stewart     SCTPCTL_RTO_INITIAL_DESC);
91142551e99SRandall Stewart 
912851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, init_rto_max, CTLTYPE_INT | CTLFLAG_RW,
913b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_init_rto_max_default), 0, sysctl_sctp_check, "IU",
914851b7298SRandall Stewart     SCTPCTL_INIT_RTO_MAX_DESC);
91542551e99SRandall Stewart 
916851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, valid_cookie_life, CTLTYPE_INT | CTLFLAG_RW,
917b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default), 0, sysctl_sctp_check, "IU",
918851b7298SRandall Stewart     SCTPCTL_VALID_COOKIE_LIFE_DESC);
91942551e99SRandall Stewart 
920851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, init_rtx_max, CTLTYPE_INT | CTLFLAG_RW,
921b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_init_rtx_max_default), 0, sysctl_sctp_check, "IU",
922851b7298SRandall Stewart     SCTPCTL_INIT_RTX_MAX_DESC);
92342551e99SRandall Stewart 
924851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, assoc_rtx_max, CTLTYPE_INT | CTLFLAG_RW,
925b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default), 0, sysctl_sctp_check, "IU",
926851b7298SRandall Stewart     SCTPCTL_ASSOC_RTX_MAX_DESC);
92742551e99SRandall Stewart 
928851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, path_rtx_max, CTLTYPE_INT | CTLFLAG_RW,
929b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_path_rtx_max_default), 0, sysctl_sctp_check, "IU",
930851b7298SRandall Stewart     SCTPCTL_PATH_RTX_MAX_DESC);
93142551e99SRandall Stewart 
932851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, add_more_on_output, CTLTYPE_INT | CTLFLAG_RW,
933b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_add_more_threshold), 0, sysctl_sctp_check, "IU",
934851b7298SRandall Stewart     SCTPCTL_ADD_MORE_ON_OUTPUT_DESC);
93542551e99SRandall Stewart 
936851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, outgoing_streams, CTLTYPE_INT | CTLFLAG_RW,
937b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default), 0, sysctl_sctp_check, "IU",
938851b7298SRandall Stewart     SCTPCTL_OUTGOING_STREAMS_DESC);
93942551e99SRandall Stewart 
940851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, cmt_on_off, CTLTYPE_INT | CTLFLAG_RW,
941b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_cmt_on_off), 0, sysctl_sctp_check, "IU",
942851b7298SRandall Stewart     SCTPCTL_CMT_ON_OFF_DESC);
94342551e99SRandall Stewart 
944830d754dSRandall Stewart /* EY */
945830d754dSRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, nr_sack_on_off, CTLTYPE_INT | CTLFLAG_RW,
946830d754dSRandall Stewart     &SCTP_BASE_SYSCTL(sctp_nr_sack_on_off), 0, sysctl_sctp_check, "IU",
947830d754dSRandall Stewart     SCTPCTL_NR_SACK_ON_OFF_DESC);
948830d754dSRandall Stewart 
949851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, cmt_use_dac, CTLTYPE_INT | CTLFLAG_RW,
950b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_cmt_use_dac), 0, sysctl_sctp_check, "IU",
951851b7298SRandall Stewart     SCTPCTL_CMT_USE_DAC_DESC);
952b54d3a6cSRandall Stewart 
953851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, cmt_pf, CTLTYPE_INT | CTLFLAG_RW,
954b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_cmt_pf), 0, sysctl_sctp_check, "IU",
955851b7298SRandall Stewart     SCTPCTL_CMT_PF_DESC);
956b54d3a6cSRandall Stewart 
957851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, cwnd_maxburst, CTLTYPE_INT | CTLFLAG_RW,
958b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst), 0, sysctl_sctp_check, "IU",
959851b7298SRandall Stewart     SCTPCTL_CWND_MAXBURST_DESC);
960c4739e2fSRandall Stewart 
961851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, early_fast_retran, CTLTYPE_INT | CTLFLAG_RW,
962b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_early_fr), 0, sysctl_sctp_check, "IU",
963851b7298SRandall Stewart     SCTPCTL_EARLY_FAST_RETRAN_DESC);
964851b7298SRandall Stewart 
965851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, early_fast_retran_msec, CTLTYPE_INT | CTLFLAG_RW,
966b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_early_fr_msec), 0, sysctl_sctp_check, "IU",
967851b7298SRandall Stewart     SCTPCTL_EARLY_FAST_RETRAN_MSEC_DESC);
968851b7298SRandall Stewart 
969851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, asconf_auth_nochk, CTLTYPE_INT | CTLFLAG_RW,
970b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_asconf_auth_nochk), 0, sysctl_sctp_check, "IU",
971851b7298SRandall Stewart     SCTPCTL_ASCONF_AUTH_NOCHK_DESC);
972851b7298SRandall Stewart 
973851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, auth_disable, CTLTYPE_INT | CTLFLAG_RW,
974b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_auth_disable), 0, sysctl_sctp_check, "IU",
975851b7298SRandall Stewart     SCTPCTL_AUTH_DISABLE_DESC);
976851b7298SRandall Stewart 
977851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, nat_friendly, CTLTYPE_INT | CTLFLAG_RW,
978b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_nat_friendly), 0, sysctl_sctp_check, "IU",
979851b7298SRandall Stewart     SCTPCTL_NAT_FRIENDLY_DESC);
980851b7298SRandall Stewart 
981851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, abc_l_var, CTLTYPE_INT | CTLFLAG_RW,
982b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_L2_abc_variable), 0, sysctl_sctp_check, "IU",
983851b7298SRandall Stewart     SCTPCTL_ABC_L_VAR_DESC);
984851b7298SRandall Stewart 
985851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, max_chained_mbufs, CTLTYPE_INT | CTLFLAG_RW,
986b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count), 0, sysctl_sctp_check, "IU",
987851b7298SRandall Stewart     SCTPCTL_MAX_CHAINED_MBUFS_DESC);
988851b7298SRandall Stewart 
989851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, do_sctp_drain, CTLTYPE_INT | CTLFLAG_RW,
990b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_do_drain), 0, sysctl_sctp_check, "IU",
991851b7298SRandall Stewart     SCTPCTL_DO_SCTP_DRAIN_DESC);
992851b7298SRandall Stewart 
993851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, hb_max_burst, CTLTYPE_INT | CTLFLAG_RW,
994b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_hb_maxburst), 0, sysctl_sctp_check, "IU",
995851b7298SRandall Stewart     SCTPCTL_HB_MAX_BURST_DESC);
996851b7298SRandall Stewart 
997851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, abort_at_limit, CTLTYPE_INT | CTLFLAG_RW,
998b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit), 0, sysctl_sctp_check, "IU",
999851b7298SRandall Stewart     SCTPCTL_ABORT_AT_LIMIT_DESC);
1000851b7298SRandall Stewart 
1001851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, strict_data_order, CTLTYPE_INT | CTLFLAG_RW,
1002b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_strict_data_order), 0, sysctl_sctp_check, "IU",
1003851b7298SRandall Stewart     SCTPCTL_STRICT_DATA_ORDER_DESC);
1004851b7298SRandall Stewart 
1005851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, min_residual, CTLTYPE_INT | CTLFLAG_RW,
1006b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_min_residual), 0, sysctl_sctp_check, "IU",
1007851b7298SRandall Stewart     SCTPCTL_MIN_RESIDUAL_DESC);
1008851b7298SRandall Stewart 
1009851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, max_retran_chunk, CTLTYPE_INT | CTLFLAG_RW,
1010b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_max_retran_chunk), 0, sysctl_sctp_check, "IU",
1011851b7298SRandall Stewart     SCTPCTL_MAX_RETRAN_CHUNK_DESC);
1012851b7298SRandall Stewart 
1013b27a6b7dSRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, log_level, CTLTYPE_INT | CTLFLAG_RW,
1014b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_logging_level), 0, sysctl_sctp_check, "IU",
1015851b7298SRandall Stewart     SCTPCTL_LOGGING_LEVEL_DESC);
1016851b7298SRandall Stewart 
1017851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, default_cc_module, CTLTYPE_INT | CTLFLAG_RW,
1018b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_default_cc_module), 0, sysctl_sctp_check, "IU",
1019851b7298SRandall Stewart     SCTPCTL_DEFAULT_CC_MODULE_DESC);
1020851b7298SRandall Stewart 
1021851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, default_frag_interleave, CTLTYPE_INT | CTLFLAG_RW,
1022b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_default_frag_interleave), 0, sysctl_sctp_check, "IU",
1023c4739e2fSRandall Stewart     SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DESC);
1024c4739e2fSRandall Stewart 
1025851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mobility_base, CTLTYPE_INT | CTLFLAG_RW,
1026b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_mobility_base), 0, sysctl_sctp_check, "IU",
1027851b7298SRandall Stewart     SCTPCTL_MOBILITY_BASE_DESC);
102842551e99SRandall Stewart 
1029851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mobility_fasthandoff, CTLTYPE_INT | CTLFLAG_RW,
1030b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff), 0, sysctl_sctp_check, "IU",
1031851b7298SRandall Stewart     SCTPCTL_MOBILITY_FASTHANDOFF_DESC);
103242551e99SRandall Stewart 
1033b27a6b7dSRandall Stewart #if defined(SCTP_LOCAL_TRACE_BUF)
1034b27a6b7dSRandall Stewart SYSCTL_STRUCT(_net_inet_sctp, OID_AUTO, log, CTLFLAG_RD,
1035b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_log), sctp_log,
1036b27a6b7dSRandall Stewart     "SCTP logging (struct sctp_log)");
1037b3f1ea41SRandall Stewart 
1038b3f1ea41SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, clear_trace, CTLTYPE_OPAQUE | CTLFLAG_RW,
1039b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_log), 0, sysctl_sctp_cleartrace, "IU",
1040b3f1ea41SRandall Stewart     "Clear SCTP Logging buffer");
1041b3f1ea41SRandall Stewart 
1042b3f1ea41SRandall Stewart 
1043b3f1ea41SRandall Stewart 
1044b27a6b7dSRandall Stewart #endif
1045b27a6b7dSRandall Stewart 
1046c54a18d2SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, udp_tunneling_for_client_enable, CTLTYPE_INT | CTLFLAG_RW,
1047b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_udp_tunneling_for_client_enable), 0, sysctl_sctp_check, "IU",
1048c54a18d2SRandall Stewart     SCTPCTL_UDP_TUNNELING_FOR_CLIENT_ENABLE_DESC);
1049c54a18d2SRandall Stewart 
1050c54a18d2SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, udp_tunneling_port, CTLTYPE_INT | CTLFLAG_RW,
1051b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_udp_tunneling_port), 0, sysctl_sctp_udp_tunneling_check, "IU",
1052c54a18d2SRandall Stewart     SCTPCTL_UDP_TUNNELING_PORT_DESC);
1053c54a18d2SRandall Stewart 
1054b3f1ea41SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, enable_sack_immediately, CTLTYPE_INT | CTLFLAG_RW,
1055b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_enable_sack_immediately), 0, sysctl_sctp_check, "IU",
1056b3f1ea41SRandall Stewart     SCTPCTL_SACK_IMMEDIATELY_ENABLE_DESC);
1057b3f1ea41SRandall Stewart 
1058830d754dSRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, nat_friendly_init, CTLTYPE_INT | CTLFLAG_RW,
1059830d754dSRandall Stewart     &SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly), 0, sysctl_sctp_check, "IU",
1060bf3d5177SMichael Tuexen     SCTPCTL_NAT_FRIENDLY_INITS_DESC);
1061830d754dSRandall Stewart 
1062a16ccdceSRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, vtag_time_wait, CTLTYPE_INT | CTLFLAG_RW,
1063a16ccdceSRandall Stewart     &SCTP_BASE_SYSCTL(sctp_vtag_time_wait), 0, sysctl_sctp_check, "IU",
1064a16ccdceSRandall Stewart     SCTPCTL_TIME_WAIT_DESC);
1065a16ccdceSRandall Stewart 
1066851b7298SRandall Stewart #ifdef SCTP_DEBUG
1067851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, debug, CTLTYPE_INT | CTLFLAG_RW,
1068b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_debug_on), 0, sysctl_sctp_check, "IU",
1069851b7298SRandall Stewart     SCTPCTL_DEBUG_DESC);
1070851b7298SRandall Stewart #endif				/* SCTP_DEBUG */
107142551e99SRandall Stewart 
107242551e99SRandall Stewart 
1073b3f1ea41SRandall Stewart #if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
1074b3f1ea41SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, output_unlocked, CTLTYPE_INT | CTLFLAG_RW,
1075b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_output_unlocked), 0, sysctl_sctp_check, "IU",
1076b3f1ea41SRandall Stewart     SCTPCTL_OUTPUT_UNLOCKED_DESC);
1077b3f1ea41SRandall Stewart #endif
1078ff014514SRandall Stewart #if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
1079ff014514SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, stats,
1080ff014514SRandall Stewart     CTLTYPE_STRUCT | CTLFLAG_RD,
1081ff014514SRandall Stewart     0, 0, sysctl_stat_get, "S,sctpstat",
1082ff014514SRandall Stewart     "SCTP statistics (struct sctp_stat)");
1083ff014514SRandall Stewart #else
108442551e99SRandall Stewart SYSCTL_STRUCT(_net_inet_sctp, OID_AUTO, stats, CTLFLAG_RW,
10858518270eSMichael Tuexen     &SCTP_BASE_STATS_SYSCTL, sctpstat,
1086b27a6b7dSRandall Stewart     "SCTP statistics (struct sctp_stat)");
1087ff014514SRandall Stewart #endif
108842551e99SRandall Stewart 
108942551e99SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, assoclist, CTLFLAG_RD,
109042551e99SRandall Stewart     0, 0, sctp_assoclist,
109142551e99SRandall Stewart     "S,xassoc", "List of active SCTP associations");
1092