xref: /freebsd/sys/netinet/sctp_sysctl.c (revision b3f1ea41fdf4567ea8639aa1fd94f1a89de2d042)
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>
41b3f1ea41SRandall Stewart 
4242551e99SRandall Stewart /*
4342551e99SRandall Stewart  * sysctl tunable variables
4442551e99SRandall Stewart  */
455e54f665SRandall Stewart 
46b3f1ea41SRandall Stewart void
47b3f1ea41SRandall Stewart sctp_init_sysctls()
48b3f1ea41SRandall Stewart {
49b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_sendspace) = SCTPCTL_MAXDGRAM_DEFAULT;
50b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_recvspace) = SCTPCTL_RECVSPACE_DEFAULT;
51b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_auto_asconf) = SCTPCTL_AUTOASCONF_DEFAULT;
52b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_multiple_asconfs) = SCTPCTL_MULTIPLEASCONFS_DEFAULT;
53b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_ecn_enable) = SCTPCTL_ECN_ENABLE_DEFAULT;
54b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_ecn_nonce) = SCTPCTL_ECN_NONCE_DEFAULT;
55b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_strict_sacks) = SCTPCTL_STRICT_SACKS_DEFAULT;
56b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback) = SCTPCTL_LOOPBACK_NOCSUM_DEFAULT;
57b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_strict_init) = SCTPCTL_STRICT_INIT_DEFAULT;
58b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_peer_chunk_oh) = SCTPCTL_PEER_CHKOH_DEFAULT;
59b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_max_burst_default) = SCTPCTL_MAXBURST_DEFAULT;
60b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue) = SCTPCTL_MAXCHUNKS_DEFAULT;
61b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_hashtblsize) = SCTPCTL_TCBHASHSIZE_DEFAULT;
62b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_pcbtblsize) = SCTPCTL_PCBHASHSIZE_DEFAULT;
63b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_min_split_point) = SCTPCTL_MIN_SPLIT_POINT_DEFAULT;
64b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_chunkscale) = SCTPCTL_CHUNKSCALE_DEFAULT;
65b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default) = SCTPCTL_DELAYED_SACK_TIME_DEFAULT;
66b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_sack_freq_default) = SCTPCTL_SACK_FREQ_DEFAULT;
67b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_system_free_resc_limit) = SCTPCTL_SYS_RESOURCE_DEFAULT;
68b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit) = SCTPCTL_ASOC_RESOURCE_DEFAULT;
69b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default) = SCTPCTL_HEARTBEAT_INTERVAL_DEFAULT;
70b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default) = SCTPCTL_PMTU_RAISE_TIME_DEFAULT;
71b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default) = SCTPCTL_SHUTDOWN_GUARD_TIME_DEFAULT;
72b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_secret_lifetime_default) = SCTPCTL_SECRET_LIFETIME_DEFAULT;
73b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_rto_max_default) = SCTPCTL_RTO_MAX_DEFAULT;
74b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_rto_min_default) = SCTPCTL_RTO_MIN_DEFAULT;
75b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_rto_initial_default) = SCTPCTL_RTO_INITIAL_DEFAULT;
76b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_init_rto_max_default) = SCTPCTL_INIT_RTO_MAX_DEFAULT;
77b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default) = SCTPCTL_VALID_COOKIE_LIFE_DEFAULT;
78b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_init_rtx_max_default) = SCTPCTL_INIT_RTX_MAX_DEFAULT;
79b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default) = SCTPCTL_ASSOC_RTX_MAX_DEFAULT;
80b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_path_rtx_max_default) = SCTPCTL_PATH_RTX_MAX_DEFAULT;
81b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_add_more_threshold) = SCTPCTL_ADD_MORE_ON_OUTPUT_DEFAULT;
82b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default) = SCTPCTL_OUTGOING_STREAMS_DEFAULT;
83b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_cmt_on_off) = SCTPCTL_CMT_ON_OFF_DEFAULT;
84b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_cmt_use_dac) = SCTPCTL_CMT_USE_DAC_DEFAULT;
85b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_cmt_pf) = SCTPCTL_CMT_PF_DEFAULT;
86b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst) = SCTPCTL_CWND_MAXBURST_DEFAULT;
87b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_early_fr) = SCTPCTL_EARLY_FAST_RETRAN_DEFAULT;
88b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_early_fr_msec) = SCTPCTL_EARLY_FAST_RETRAN_MSEC_DEFAULT;
89b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_asconf_auth_nochk) = SCTPCTL_ASCONF_AUTH_NOCHK_DEFAULT;
90b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_auth_disable) = SCTPCTL_AUTH_DISABLE_DEFAULT;
91b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_nat_friendly) = SCTPCTL_NAT_FRIENDLY_DEFAULT;
92b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_L2_abc_variable) = SCTPCTL_ABC_L_VAR_DEFAULT;
93b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count) = SCTPCTL_MAX_CHAINED_MBUFS_DEFAULT;
94b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_do_drain) = SCTPCTL_DO_SCTP_DRAIN_DEFAULT;
95b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_hb_maxburst) = SCTPCTL_HB_MAX_BURST_DEFAULT;
96b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit) = SCTPCTL_ABORT_AT_LIMIT_DEFAULT;
97b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_strict_data_order) = SCTPCTL_STRICT_DATA_ORDER_DEFAULT;
98b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_min_residual) = SCTPCTL_MIN_RESIDUAL_DEFAULT;
99b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_max_retran_chunk) = SCTPCTL_MAX_RETRAN_CHUNK_DEFAULT;
100b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_logging_level) = SCTPCTL_LOGGING_LEVEL_DEFAULT;
101b54d3a6cSRandall Stewart 	/* JRS - Variable for default congestion control module */
102b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_default_cc_module) = SCTPCTL_DEFAULT_CC_MODULE_DEFAULT;
103b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_default_frag_interleave) = SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DEFAULT;
104b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_mobility_base) = SCTPCTL_MOBILITY_BASE_DEFAULT;
105b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff) = SCTPCTL_MOBILITY_FASTHANDOFF_DEFAULT;
106b27a6b7dSRandall Stewart #if defined(SCTP_LOCAL_TRACE_BUF)
107b3f1ea41SRandall Stewart 	memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log));
108b27a6b7dSRandall Stewart #endif
109b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_udp_tunneling_for_client_enable) = SCTPCTL_UDP_TUNNELING_FOR_CLIENT_ENABLE_DEFAULT;
110b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = SCTPCTL_UDP_TUNNELING_PORT_DEFAULT;
111b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_enable_sack_immediately) = SCTPCTL_SACK_IMMEDIATELY_ENABLE_DEFAULT;
112b3f1ea41SRandall Stewart #if defined(SCTP_DEBUG)
113b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_debug_on) = SCTPCTL_DEBUG_DEFAULT;
11442551e99SRandall Stewart #endif
115b3f1ea41SRandall Stewart #if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
116b3f1ea41SRandall Stewart 	SCTP_BASE_SYSCTL(sctp_output_unlocked) = SCTPCTL_OUTPUT_UNLOCKED_DEFAULT;
117b3f1ea41SRandall Stewart #endif
118b3f1ea41SRandall Stewart }
119d61a0ae0SRandall Stewart 
120d61a0ae0SRandall Stewart /* It returns an upper limit. No filtering is done here */
121d61a0ae0SRandall Stewart static unsigned int
122d61a0ae0SRandall Stewart number_of_addresses(struct sctp_inpcb *inp)
123d61a0ae0SRandall Stewart {
124d61a0ae0SRandall Stewart 	int cnt;
125d61a0ae0SRandall Stewart 	struct sctp_vrf *vrf;
126d61a0ae0SRandall Stewart 	struct sctp_ifn *sctp_ifn;
127d61a0ae0SRandall Stewart 	struct sctp_ifa *sctp_ifa;
128d61a0ae0SRandall Stewart 	struct sctp_laddr *laddr;
129d61a0ae0SRandall Stewart 
130d61a0ae0SRandall Stewart 	cnt = 0;
131d61a0ae0SRandall Stewart 	/* neither Mac OS X nor FreeBSD support mulitple routing functions */
132d61a0ae0SRandall Stewart 	if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) {
133d61a0ae0SRandall Stewart 		return (0);
134d61a0ae0SRandall Stewart 	}
135d61a0ae0SRandall Stewart 	if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
136d61a0ae0SRandall Stewart 		LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
137d61a0ae0SRandall Stewart 			LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
138d61a0ae0SRandall Stewart 				if ((sctp_ifa->address.sa.sa_family == AF_INET) ||
139d61a0ae0SRandall Stewart 				    (sctp_ifa->address.sa.sa_family == AF_INET6)) {
140d61a0ae0SRandall Stewart 					cnt++;
141d61a0ae0SRandall Stewart 				}
142d61a0ae0SRandall Stewart 			}
143d61a0ae0SRandall Stewart 		}
144d61a0ae0SRandall Stewart 	} else {
145d61a0ae0SRandall Stewart 		LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
146d61a0ae0SRandall Stewart 			if ((laddr->ifa->address.sa.sa_family == AF_INET) ||
147d61a0ae0SRandall Stewart 			    (laddr->ifa->address.sa.sa_family == AF_INET6)) {
148d61a0ae0SRandall Stewart 				cnt++;
149d61a0ae0SRandall Stewart 			}
150d61a0ae0SRandall Stewart 		}
151d61a0ae0SRandall Stewart 	}
152d61a0ae0SRandall Stewart 	return (cnt);
153d61a0ae0SRandall Stewart }
154d61a0ae0SRandall Stewart 
155d61a0ae0SRandall Stewart static int
156d61a0ae0SRandall Stewart copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sysctl_req *req)
157d61a0ae0SRandall Stewart {
158d61a0ae0SRandall Stewart 	struct sctp_ifn *sctp_ifn;
159d61a0ae0SRandall Stewart 	struct sctp_ifa *sctp_ifa;
160d61a0ae0SRandall Stewart 	int loopback_scope, ipv4_local_scope, local_scope, site_scope;
161d61a0ae0SRandall Stewart 	int ipv4_addr_legal, ipv6_addr_legal;
162d61a0ae0SRandall Stewart 	struct sctp_vrf *vrf;
163d61a0ae0SRandall Stewart 	struct xsctp_laddr xladdr;
164d61a0ae0SRandall Stewart 	struct sctp_laddr *laddr;
165d61a0ae0SRandall Stewart 	int error;
166d61a0ae0SRandall Stewart 
167d61a0ae0SRandall Stewart 	/* Turn on all the appropriate scope */
168d61a0ae0SRandall Stewart 	if (stcb) {
169d61a0ae0SRandall Stewart 		/* use association specific values */
170d61a0ae0SRandall Stewart 		loopback_scope = stcb->asoc.loopback_scope;
171d61a0ae0SRandall Stewart 		ipv4_local_scope = stcb->asoc.ipv4_local_scope;
172d61a0ae0SRandall Stewart 		local_scope = stcb->asoc.local_scope;
173d61a0ae0SRandall Stewart 		site_scope = stcb->asoc.site_scope;
174d61a0ae0SRandall Stewart 	} else {
175d61a0ae0SRandall Stewart 		/* use generic values for endpoints */
176d61a0ae0SRandall Stewart 		loopback_scope = 1;
177d61a0ae0SRandall Stewart 		ipv4_local_scope = 1;
178d61a0ae0SRandall Stewart 		local_scope = 1;
179d61a0ae0SRandall Stewart 		site_scope = 1;
180d61a0ae0SRandall Stewart 	}
181d61a0ae0SRandall Stewart 
182d61a0ae0SRandall Stewart 	/* use only address families of interest */
183d61a0ae0SRandall Stewart 	if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) {
184d61a0ae0SRandall Stewart 		ipv6_addr_legal = 1;
185d61a0ae0SRandall Stewart 		if (SCTP_IPV6_V6ONLY(inp)) {
186d61a0ae0SRandall Stewart 			ipv4_addr_legal = 0;
187d61a0ae0SRandall Stewart 		} else {
188d61a0ae0SRandall Stewart 			ipv4_addr_legal = 1;
189d61a0ae0SRandall Stewart 		}
190d61a0ae0SRandall Stewart 	} else {
191d61a0ae0SRandall Stewart 		ipv4_addr_legal = 1;
192d61a0ae0SRandall Stewart 		ipv6_addr_legal = 0;
193d61a0ae0SRandall Stewart 	}
194d61a0ae0SRandall Stewart 
195d61a0ae0SRandall Stewart 	error = 0;
196d61a0ae0SRandall Stewart 
197d61a0ae0SRandall Stewart 	/* neither Mac OS X nor FreeBSD support mulitple routing functions */
198d61a0ae0SRandall Stewart 	if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) {
1995f26a41dSRandall Stewart 		SCTP_INP_RUNLOCK(inp);
2005f26a41dSRandall Stewart 		SCTP_INP_INFO_RUNLOCK();
201d61a0ae0SRandall Stewart 		return (-1);
202d61a0ae0SRandall Stewart 	}
203d61a0ae0SRandall Stewart 	if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
204d61a0ae0SRandall Stewart 		LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
205d61a0ae0SRandall Stewart 			if ((loopback_scope == 0) && SCTP_IFN_IS_IFT_LOOP(sctp_ifn))
206d61a0ae0SRandall Stewart 				/* Skip loopback if loopback_scope not set */
207d61a0ae0SRandall Stewart 				continue;
208d61a0ae0SRandall Stewart 			LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
209d61a0ae0SRandall Stewart 				if (stcb) {
210d61a0ae0SRandall Stewart 					/*
211d61a0ae0SRandall Stewart 					 * ignore if blacklisted at
212d61a0ae0SRandall Stewart 					 * association level
213d61a0ae0SRandall Stewart 					 */
214d61a0ae0SRandall Stewart 					if (sctp_is_addr_restricted(stcb, sctp_ifa))
215d61a0ae0SRandall Stewart 						continue;
216d61a0ae0SRandall Stewart 				}
2175e2c2d87SRandall Stewart 				switch (sctp_ifa->address.sa.sa_family) {
2185e2c2d87SRandall Stewart 				case AF_INET:
2195e2c2d87SRandall Stewart 					if (ipv4_addr_legal) {
220d61a0ae0SRandall Stewart 						struct sockaddr_in *sin;
221d61a0ae0SRandall Stewart 
222d61a0ae0SRandall Stewart 						sin = (struct sockaddr_in *)&sctp_ifa->address.sa;
223d61a0ae0SRandall Stewart 						if (sin->sin_addr.s_addr == 0)
224d61a0ae0SRandall Stewart 							continue;
225d61a0ae0SRandall Stewart 						if ((ipv4_local_scope == 0) && (IN4_ISPRIVATE_ADDRESS(&sin->sin_addr)))
226d61a0ae0SRandall Stewart 							continue;
2275e2c2d87SRandall Stewart 					} else {
2285e2c2d87SRandall Stewart 						continue;
2295e2c2d87SRandall Stewart 					}
2305e2c2d87SRandall Stewart 					break;
2315e2c2d87SRandall Stewart #ifdef INET6
2325e2c2d87SRandall Stewart 				case AF_INET6:
2335e2c2d87SRandall Stewart 					if (ipv6_addr_legal) {
234d61a0ae0SRandall Stewart 						struct sockaddr_in6 *sin6;
235d61a0ae0SRandall Stewart 
236d61a0ae0SRandall Stewart 						sin6 = (struct sockaddr_in6 *)&sctp_ifa->address.sa;
237d61a0ae0SRandall Stewart 						if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr))
238d61a0ae0SRandall Stewart 							continue;
239d61a0ae0SRandall Stewart 						if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
240d61a0ae0SRandall Stewart 							if (local_scope == 0)
241d61a0ae0SRandall Stewart 								continue;
242d61a0ae0SRandall Stewart 							if (sin6->sin6_scope_id == 0) {
243d61a0ae0SRandall Stewart 								/*
2445e2c2d87SRandall Stewart 								 * bad link
2455e2c2d87SRandall Stewart 								 * local
246d61a0ae0SRandall Stewart 								 * address
247d61a0ae0SRandall Stewart 								 */
248d61a0ae0SRandall Stewart 								if (sa6_recoverscope(sin6) != 0)
249d61a0ae0SRandall Stewart 									continue;
250d61a0ae0SRandall Stewart 							}
251d61a0ae0SRandall Stewart 						}
252d61a0ae0SRandall Stewart 						if ((site_scope == 0) && (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)))
253d61a0ae0SRandall Stewart 							continue;
2545e2c2d87SRandall Stewart 					} else {
255d61a0ae0SRandall Stewart 						continue;
2565e2c2d87SRandall Stewart 					}
2575e2c2d87SRandall Stewart 					break;
2585e2c2d87SRandall Stewart #endif
2595e2c2d87SRandall Stewart 				default:
2605e2c2d87SRandall Stewart 					continue;
2615e2c2d87SRandall Stewart 				}
262851b7298SRandall Stewart 				memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
263d61a0ae0SRandall Stewart 				memcpy((void *)&xladdr.address, (const void *)&sctp_ifa->address, sizeof(union sctp_sockstore));
264d61a0ae0SRandall Stewart 				SCTP_INP_RUNLOCK(inp);
265d61a0ae0SRandall Stewart 				SCTP_INP_INFO_RUNLOCK();
266d61a0ae0SRandall Stewart 				error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
267851b7298SRandall Stewart 				if (error) {
268d61a0ae0SRandall Stewart 					return (error);
269851b7298SRandall Stewart 				} else {
270d61a0ae0SRandall Stewart 					SCTP_INP_INFO_RLOCK();
271d61a0ae0SRandall Stewart 					SCTP_INP_RLOCK(inp);
272d61a0ae0SRandall Stewart 				}
273d61a0ae0SRandall Stewart 			}
274d61a0ae0SRandall Stewart 		}
275d61a0ae0SRandall Stewart 	} else {
276d61a0ae0SRandall Stewart 		LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
277d61a0ae0SRandall Stewart 			/* ignore if blacklisted at association level */
278d61a0ae0SRandall Stewart 			if (stcb && sctp_is_addr_restricted(stcb, laddr->ifa))
279d61a0ae0SRandall Stewart 				continue;
280851b7298SRandall Stewart 			memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
281d61a0ae0SRandall Stewart 			memcpy((void *)&xladdr.address, (const void *)&laddr->ifa->address, sizeof(union sctp_sockstore));
282851b7298SRandall Stewart 			xladdr.start_time.tv_sec = (uint32_t) laddr->start_time.tv_sec;
283851b7298SRandall Stewart 			xladdr.start_time.tv_usec = (uint32_t) laddr->start_time.tv_usec;
284d61a0ae0SRandall Stewart 			SCTP_INP_RUNLOCK(inp);
285d61a0ae0SRandall Stewart 			SCTP_INP_INFO_RUNLOCK();
286d61a0ae0SRandall Stewart 			error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
287851b7298SRandall Stewart 			if (error) {
288d61a0ae0SRandall Stewart 				return (error);
289851b7298SRandall Stewart 			} else {
290d61a0ae0SRandall Stewart 				SCTP_INP_INFO_RLOCK();
291d61a0ae0SRandall Stewart 				SCTP_INP_RLOCK(inp);
292d61a0ae0SRandall Stewart 			}
293d61a0ae0SRandall Stewart 		}
294d61a0ae0SRandall Stewart 	}
295851b7298SRandall Stewart 	memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
296d61a0ae0SRandall Stewart 	xladdr.last = 1;
2975f26a41dSRandall Stewart 	SCTP_INP_RUNLOCK(inp);
2985f26a41dSRandall Stewart 	SCTP_INP_INFO_RUNLOCK();
299d61a0ae0SRandall Stewart 	error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
3005f26a41dSRandall Stewart 
301851b7298SRandall Stewart 	if (error) {
302d61a0ae0SRandall Stewart 		return (error);
303851b7298SRandall Stewart 	} else {
3045f26a41dSRandall Stewart 		SCTP_INP_INFO_RLOCK();
3055f26a41dSRandall Stewart 		SCTP_INP_RLOCK(inp);
306d61a0ae0SRandall Stewart 		return (0);
307d61a0ae0SRandall Stewart 	}
3085f26a41dSRandall Stewart }
309d61a0ae0SRandall Stewart 
31042551e99SRandall Stewart /*
31142551e99SRandall Stewart  * sysctl functions
31242551e99SRandall Stewart  */
31342551e99SRandall Stewart static int
31442551e99SRandall Stewart sctp_assoclist(SYSCTL_HANDLER_ARGS)
31542551e99SRandall Stewart {
31642551e99SRandall Stewart 	unsigned int number_of_endpoints;
31742551e99SRandall Stewart 	unsigned int number_of_local_addresses;
31842551e99SRandall Stewart 	unsigned int number_of_associations;
31942551e99SRandall Stewart 	unsigned int number_of_remote_addresses;
32042551e99SRandall Stewart 	unsigned int n;
32142551e99SRandall Stewart 	int error;
32242551e99SRandall Stewart 	struct sctp_inpcb *inp;
32342551e99SRandall Stewart 	struct sctp_tcb *stcb;
32442551e99SRandall Stewart 	struct sctp_nets *net;
32542551e99SRandall Stewart 	struct xsctp_inpcb xinpcb;
32642551e99SRandall Stewart 	struct xsctp_tcb xstcb;
32742551e99SRandall Stewart 	struct xsctp_raddr xraddr;
32842551e99SRandall Stewart 
32942551e99SRandall Stewart 	number_of_endpoints = 0;
33042551e99SRandall Stewart 	number_of_local_addresses = 0;
33142551e99SRandall Stewart 	number_of_associations = 0;
33242551e99SRandall Stewart 	number_of_remote_addresses = 0;
33342551e99SRandall Stewart 
33442551e99SRandall Stewart 	SCTP_INP_INFO_RLOCK();
33542551e99SRandall Stewart 	if (req->oldptr == USER_ADDR_NULL) {
336b3f1ea41SRandall Stewart 		LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
33742551e99SRandall Stewart 			SCTP_INP_RLOCK(inp);
33842551e99SRandall Stewart 			number_of_endpoints++;
339d61a0ae0SRandall Stewart 			number_of_local_addresses += number_of_addresses(inp);
34042551e99SRandall Stewart 			LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
34142551e99SRandall Stewart 				number_of_associations++;
342d61a0ae0SRandall Stewart 				number_of_local_addresses += number_of_addresses(inp);
34342551e99SRandall Stewart 				TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
34442551e99SRandall Stewart 					number_of_remote_addresses++;
34542551e99SRandall Stewart 				}
34642551e99SRandall Stewart 			}
34742551e99SRandall Stewart 			SCTP_INP_RUNLOCK(inp);
34842551e99SRandall Stewart 		}
34942551e99SRandall Stewart 		SCTP_INP_INFO_RUNLOCK();
35042551e99SRandall Stewart 		n = (number_of_endpoints + 1) * sizeof(struct xsctp_inpcb) +
351d61a0ae0SRandall Stewart 		    (number_of_local_addresses + number_of_endpoints + number_of_associations) * sizeof(struct xsctp_laddr) +
352d61a0ae0SRandall Stewart 		    (number_of_associations + number_of_endpoints) * sizeof(struct xsctp_tcb) +
353d61a0ae0SRandall Stewart 		    (number_of_remote_addresses + number_of_associations) * sizeof(struct xsctp_raddr);
354d61a0ae0SRandall Stewart 
35542551e99SRandall Stewart 		/* request some more memory than needed */
35642551e99SRandall Stewart 		req->oldidx = (n + n / 8);
35742551e99SRandall Stewart 		return 0;
35842551e99SRandall Stewart 	}
35942551e99SRandall Stewart 	if (req->newptr != USER_ADDR_NULL) {
36042551e99SRandall Stewart 		SCTP_INP_INFO_RUNLOCK();
361c4739e2fSRandall Stewart 		SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_SYSCTL, EPERM);
36242551e99SRandall Stewart 		return EPERM;
36342551e99SRandall Stewart 	}
364b3f1ea41SRandall Stewart 	LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
36542551e99SRandall Stewart 		SCTP_INP_RLOCK(inp);
36642551e99SRandall Stewart 		xinpcb.last = 0;
36742551e99SRandall Stewart 		xinpcb.local_port = ntohs(inp->sctp_lport);
36842551e99SRandall Stewart 		xinpcb.flags = inp->sctp_flags;
36942551e99SRandall Stewart 		xinpcb.features = inp->sctp_features;
37042551e99SRandall Stewart 		xinpcb.total_sends = inp->total_sends;
37142551e99SRandall Stewart 		xinpcb.total_recvs = inp->total_recvs;
37242551e99SRandall Stewart 		xinpcb.total_nospaces = inp->total_nospaces;
37317205eccSRandall Stewart 		xinpcb.fragmentation_point = inp->sctp_frag_point;
374851b7298SRandall Stewart 		if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) ||
375851b7298SRandall Stewart 		    (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) {
376851b7298SRandall Stewart 			xinpcb.qlen = 0;
377851b7298SRandall Stewart 			xinpcb.maxqlen = 0;
378851b7298SRandall Stewart 		} else {
379d61a0ae0SRandall Stewart 			xinpcb.qlen = inp->sctp_socket->so_qlen;
380d61a0ae0SRandall Stewart 			xinpcb.maxqlen = inp->sctp_socket->so_qlimit;
381851b7298SRandall Stewart 		}
38242551e99SRandall Stewart 		SCTP_INP_INCR_REF(inp);
38342551e99SRandall Stewart 		SCTP_INP_RUNLOCK(inp);
38442551e99SRandall Stewart 		SCTP_INP_INFO_RUNLOCK();
38542551e99SRandall Stewart 		error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb));
38642551e99SRandall Stewart 		if (error) {
387d61a0ae0SRandall Stewart 			SCTP_INP_DECR_REF(inp);
38842551e99SRandall Stewart 			return error;
38942551e99SRandall Stewart 		}
39042551e99SRandall Stewart 		SCTP_INP_INFO_RLOCK();
39142551e99SRandall Stewart 		SCTP_INP_RLOCK(inp);
392d61a0ae0SRandall Stewart 		error = copy_out_local_addresses(inp, NULL, req);
393d61a0ae0SRandall Stewart 		if (error) {
394d61a0ae0SRandall Stewart 			SCTP_INP_DECR_REF(inp);
395d61a0ae0SRandall Stewart 			return error;
396d61a0ae0SRandall Stewart 		}
39742551e99SRandall Stewart 		LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
39842551e99SRandall Stewart 			SCTP_TCB_LOCK(stcb);
39942551e99SRandall Stewart 			atomic_add_int(&stcb->asoc.refcnt, 1);
40042551e99SRandall Stewart 			SCTP_TCB_UNLOCK(stcb);
401d61a0ae0SRandall Stewart 			xstcb.last = 0;
402d61a0ae0SRandall Stewart 			xstcb.local_port = ntohs(inp->sctp_lport);
403d61a0ae0SRandall Stewart 			xstcb.remote_port = ntohs(stcb->rport);
40442551e99SRandall Stewart 			if (stcb->asoc.primary_destination != NULL)
405d61a0ae0SRandall Stewart 				xstcb.primary_addr = stcb->asoc.primary_destination->ro._l_addr;
406d61a0ae0SRandall Stewart 			xstcb.heartbeat_interval = stcb->asoc.heart_beat_delay;
407d61a0ae0SRandall Stewart 			xstcb.state = SCTP_GET_STATE(&stcb->asoc);	/* FIXME */
408d61a0ae0SRandall Stewart 			xstcb.in_streams = stcb->asoc.streamincnt;
409d61a0ae0SRandall Stewart 			xstcb.out_streams = stcb->asoc.streamoutcnt;
410d61a0ae0SRandall Stewart 			xstcb.max_nr_retrans = stcb->asoc.overall_error_count;
411d61a0ae0SRandall Stewart 			xstcb.primary_process = 0;	/* not really supported
412d61a0ae0SRandall Stewart 							 * yet */
413d61a0ae0SRandall Stewart 			xstcb.T1_expireries = stcb->asoc.timoinit + stcb->asoc.timocookie;
414d61a0ae0SRandall Stewart 			xstcb.T2_expireries = stcb->asoc.timoshutdown + stcb->asoc.timoshutdownack;
415d61a0ae0SRandall Stewart 			xstcb.retransmitted_tsns = stcb->asoc.marked_retrans;
416851b7298SRandall Stewart 			xstcb.start_time.tv_sec = (uint32_t) stcb->asoc.start_time.tv_sec;
417851b7298SRandall Stewart 			xstcb.start_time.tv_usec = (uint32_t) stcb->asoc.start_time.tv_usec;
418851b7298SRandall Stewart 			xstcb.discontinuity_time.tv_sec = (uint32_t) stcb->asoc.discontinuity_time.tv_sec;
419851b7298SRandall Stewart 			xstcb.discontinuity_time.tv_usec = (uint32_t) stcb->asoc.discontinuity_time.tv_usec;
42042551e99SRandall Stewart 			xstcb.total_sends = stcb->total_sends;
42142551e99SRandall Stewart 			xstcb.total_recvs = stcb->total_recvs;
42242551e99SRandall Stewart 			xstcb.local_tag = stcb->asoc.my_vtag;
42342551e99SRandall Stewart 			xstcb.remote_tag = stcb->asoc.peer_vtag;
42442551e99SRandall Stewart 			xstcb.initial_tsn = stcb->asoc.init_seq_number;
42542551e99SRandall Stewart 			xstcb.highest_tsn = stcb->asoc.sending_seq - 1;
42642551e99SRandall Stewart 			xstcb.cumulative_tsn = stcb->asoc.last_acked_seq;
42742551e99SRandall Stewart 			xstcb.cumulative_tsn_ack = stcb->asoc.cumulative_tsn;
42817205eccSRandall Stewart 			xstcb.mtu = stcb->asoc.smallest_mtu;
429207304d4SRandall Stewart 			xstcb.refcnt = stcb->asoc.refcnt;
43042551e99SRandall Stewart 			SCTP_INP_RUNLOCK(inp);
43142551e99SRandall Stewart 			SCTP_INP_INFO_RUNLOCK();
43242551e99SRandall Stewart 			error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb));
43342551e99SRandall Stewart 			if (error) {
434d61a0ae0SRandall Stewart 				SCTP_INP_DECR_REF(inp);
435851b7298SRandall Stewart 				atomic_subtract_int(&stcb->asoc.refcnt, 1);
436d61a0ae0SRandall Stewart 				return error;
437d61a0ae0SRandall Stewart 			}
438d61a0ae0SRandall Stewart 			SCTP_INP_INFO_RLOCK();
439d61a0ae0SRandall Stewart 			SCTP_INP_RLOCK(inp);
440d61a0ae0SRandall Stewart 			error = copy_out_local_addresses(inp, stcb, req);
441d61a0ae0SRandall Stewart 			if (error) {
442d61a0ae0SRandall Stewart 				SCTP_INP_DECR_REF(inp);
443851b7298SRandall Stewart 				atomic_subtract_int(&stcb->asoc.refcnt, 1);
44442551e99SRandall Stewart 				return error;
44542551e99SRandall Stewart 			}
44642551e99SRandall Stewart 			TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
447d61a0ae0SRandall Stewart 				xraddr.last = 0;
448d61a0ae0SRandall Stewart 				xraddr.address = net->ro._l_addr;
449d61a0ae0SRandall Stewart 				xraddr.active = ((net->dest_state & SCTP_ADDR_REACHABLE) == SCTP_ADDR_REACHABLE);
450d61a0ae0SRandall Stewart 				xraddr.confirmed = ((net->dest_state & SCTP_ADDR_UNCONFIRMED) == 0);
451d61a0ae0SRandall Stewart 				xraddr.heartbeat_enabled = ((net->dest_state & SCTP_ADDR_NOHB) == 0);
452d61a0ae0SRandall Stewart 				xraddr.rto = net->RTO;
453d61a0ae0SRandall Stewart 				xraddr.max_path_rtx = net->failure_threshold;
454d61a0ae0SRandall Stewart 				xraddr.rtx = net->marked_retrans;
455d61a0ae0SRandall Stewart 				xraddr.error_counter = net->error_count;
456d61a0ae0SRandall Stewart 				xraddr.cwnd = net->cwnd;
457d61a0ae0SRandall Stewart 				xraddr.flight_size = net->flight_size;
458d61a0ae0SRandall Stewart 				xraddr.mtu = net->mtu;
459851b7298SRandall Stewart 				xraddr.start_time.tv_sec = (uint32_t) net->start_time.tv_sec;
460851b7298SRandall Stewart 				xraddr.start_time.tv_usec = (uint32_t) net->start_time.tv_usec;
461d61a0ae0SRandall Stewart 				SCTP_INP_RUNLOCK(inp);
462d61a0ae0SRandall Stewart 				SCTP_INP_INFO_RUNLOCK();
46342551e99SRandall Stewart 				error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr));
46442551e99SRandall Stewart 				if (error) {
465d61a0ae0SRandall Stewart 					SCTP_INP_DECR_REF(inp);
466851b7298SRandall Stewart 					atomic_subtract_int(&stcb->asoc.refcnt, 1);
46742551e99SRandall Stewart 					return error;
46842551e99SRandall Stewart 				}
46942551e99SRandall Stewart 				SCTP_INP_INFO_RLOCK();
47042551e99SRandall Stewart 				SCTP_INP_RLOCK(inp);
47142551e99SRandall Stewart 			}
472851b7298SRandall Stewart 			atomic_subtract_int(&stcb->asoc.refcnt, 1);
473d61a0ae0SRandall Stewart 			memset((void *)&xraddr, 0, sizeof(struct xsctp_raddr));
474d61a0ae0SRandall Stewart 			xraddr.last = 1;
47542551e99SRandall Stewart 			SCTP_INP_RUNLOCK(inp);
476d61a0ae0SRandall Stewart 			SCTP_INP_INFO_RUNLOCK();
477d61a0ae0SRandall Stewart 			error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr));
478d61a0ae0SRandall Stewart 			if (error) {
479d61a0ae0SRandall Stewart 				SCTP_INP_DECR_REF(inp);
480d61a0ae0SRandall Stewart 				return error;
481d61a0ae0SRandall Stewart 			}
482d61a0ae0SRandall Stewart 			SCTP_INP_INFO_RLOCK();
483d61a0ae0SRandall Stewart 			SCTP_INP_RLOCK(inp);
484d61a0ae0SRandall Stewart 		}
485851b7298SRandall Stewart 		SCTP_INP_DECR_REF(inp);
486d61a0ae0SRandall Stewart 		SCTP_INP_RUNLOCK(inp);
487d61a0ae0SRandall Stewart 		SCTP_INP_INFO_RUNLOCK();
488d61a0ae0SRandall Stewart 		memset((void *)&xstcb, 0, sizeof(struct xsctp_tcb));
489d61a0ae0SRandall Stewart 		xstcb.last = 1;
490d61a0ae0SRandall Stewart 		error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb));
491d61a0ae0SRandall Stewart 		if (error) {
492d61a0ae0SRandall Stewart 			return error;
493d61a0ae0SRandall Stewart 		}
494d61a0ae0SRandall Stewart 		SCTP_INP_INFO_RLOCK();
49542551e99SRandall Stewart 	}
49642551e99SRandall Stewart 	SCTP_INP_INFO_RUNLOCK();
49742551e99SRandall Stewart 
498d61a0ae0SRandall Stewart 	memset((void *)&xinpcb, 0, sizeof(struct xsctp_inpcb));
49942551e99SRandall Stewart 	xinpcb.last = 1;
50042551e99SRandall Stewart 	error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb));
50142551e99SRandall Stewart 	return error;
50242551e99SRandall Stewart }
50342551e99SRandall Stewart 
504c54a18d2SRandall Stewart 
505c54a18d2SRandall Stewart 
506851b7298SRandall Stewart #define RANGECHK(var, min, max) \
507851b7298SRandall Stewart 	if ((var) < (min)) { (var) = (min); } \
508851b7298SRandall Stewart 	else if ((var) > (max)) { (var) = (max); }
509851b7298SRandall Stewart 
510851b7298SRandall Stewart static int
511c54a18d2SRandall Stewart sysctl_sctp_udp_tunneling_check(SYSCTL_HANDLER_ARGS)
512c54a18d2SRandall Stewart {
513c54a18d2SRandall Stewart 	int error;
514c54a18d2SRandall Stewart 	uint32_t old_sctp_udp_tunneling_port;
515c54a18d2SRandall Stewart 
516b3f1ea41SRandall Stewart 	old_sctp_udp_tunneling_port = SCTP_BASE_SYSCTL(sctp_udp_tunneling_port);
517c54a18d2SRandall Stewart 	error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
518c54a18d2SRandall Stewart 	if (error == 0) {
519b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port), SCTPCTL_UDP_TUNNELING_PORT_MIN, SCTPCTL_UDP_TUNNELING_PORT_MAX);
520c54a18d2SRandall Stewart 		if (old_sctp_udp_tunneling_port) {
521c54a18d2SRandall Stewart 			sctp_over_udp_stop();
522c54a18d2SRandall Stewart 		}
523b3f1ea41SRandall Stewart 		if (SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)) {
524c54a18d2SRandall Stewart 			if (sctp_over_udp_start()) {
525b3f1ea41SRandall Stewart 				SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = 0;
526c54a18d2SRandall Stewart 			}
527c54a18d2SRandall Stewart 		}
528c54a18d2SRandall Stewart 	}
529c54a18d2SRandall Stewart 	return (error);
530c54a18d2SRandall Stewart }
531c54a18d2SRandall Stewart 
532b3f1ea41SRandall Stewart 
533c54a18d2SRandall Stewart static int
534851b7298SRandall Stewart sysctl_sctp_check(SYSCTL_HANDLER_ARGS)
535851b7298SRandall Stewart {
536851b7298SRandall Stewart 	int error;
537851b7298SRandall Stewart 
538851b7298SRandall Stewart 	error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
539851b7298SRandall Stewart 	if (error == 0) {
540b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_sendspace), SCTPCTL_MAXDGRAM_MIN, SCTPCTL_MAXDGRAM_MAX);
541b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_recvspace), SCTPCTL_RECVSPACE_MIN, SCTPCTL_RECVSPACE_MAX);
542851b7298SRandall Stewart #if defined(__FreeBSD__) || defined(SCTP_APPLE_AUTO_ASCONF)
543b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_auto_asconf), SCTPCTL_AUTOASCONF_MIN, SCTPCTL_AUTOASCONF_MAX);
544851b7298SRandall Stewart #endif
545b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_ecn_enable), SCTPCTL_ECN_ENABLE_MIN, SCTPCTL_ECN_ENABLE_MAX);
546b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_ecn_nonce), SCTPCTL_ECN_NONCE_MIN, SCTPCTL_ECN_NONCE_MAX);
547b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_strict_sacks), SCTPCTL_STRICT_SACKS_MIN, SCTPCTL_STRICT_SACKS_MAX);
548b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback), SCTPCTL_LOOPBACK_NOCSUM_MIN, SCTPCTL_LOOPBACK_NOCSUM_MAX);
549b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_strict_init), SCTPCTL_STRICT_INIT_MIN, SCTPCTL_STRICT_INIT_MAX);
550b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_peer_chunk_oh), SCTPCTL_PEER_CHKOH_MIN, SCTPCTL_PEER_CHKOH_MAX);
551b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_max_burst_default), SCTPCTL_MAXBURST_MIN, SCTPCTL_MAXBURST_MAX);
552b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue), SCTPCTL_MAXCHUNKS_MIN, SCTPCTL_MAXCHUNKS_MAX);
553b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_hashtblsize), SCTPCTL_TCBHASHSIZE_MIN, SCTPCTL_TCBHASHSIZE_MAX);
554b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_pcbtblsize), SCTPCTL_PCBHASHSIZE_MIN, SCTPCTL_PCBHASHSIZE_MAX);
555b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_min_split_point), SCTPCTL_MIN_SPLIT_POINT_MIN, SCTPCTL_MIN_SPLIT_POINT_MAX);
556b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_chunkscale), SCTPCTL_CHUNKSCALE_MIN, SCTPCTL_CHUNKSCALE_MAX);
557b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default), SCTPCTL_DELAYED_SACK_TIME_MIN, SCTPCTL_DELAYED_SACK_TIME_MAX);
558b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_sack_freq_default), SCTPCTL_SACK_FREQ_MIN, SCTPCTL_SACK_FREQ_MAX);
559b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_system_free_resc_limit), SCTPCTL_SYS_RESOURCE_MIN, SCTPCTL_SYS_RESOURCE_MAX);
560b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit), SCTPCTL_ASOC_RESOURCE_MIN, SCTPCTL_ASOC_RESOURCE_MAX);
561b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default), SCTPCTL_HEARTBEAT_INTERVAL_MIN, SCTPCTL_HEARTBEAT_INTERVAL_MAX);
562b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default), SCTPCTL_PMTU_RAISE_TIME_MIN, SCTPCTL_PMTU_RAISE_TIME_MAX);
563b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default), SCTPCTL_SHUTDOWN_GUARD_TIME_MIN, SCTPCTL_SHUTDOWN_GUARD_TIME_MAX);
564b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_secret_lifetime_default), SCTPCTL_SECRET_LIFETIME_MIN, SCTPCTL_SECRET_LIFETIME_MAX);
565b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_max_default), SCTPCTL_RTO_MAX_MIN, SCTPCTL_RTO_MAX_MAX);
566b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_min_default), SCTPCTL_RTO_MIN_MIN, SCTPCTL_RTO_MIN_MAX);
567b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_initial_default), SCTPCTL_RTO_INITIAL_MIN, SCTPCTL_RTO_INITIAL_MAX);
568b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_init_rto_max_default), SCTPCTL_INIT_RTO_MAX_MIN, SCTPCTL_INIT_RTO_MAX_MAX);
569b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default), SCTPCTL_VALID_COOKIE_LIFE_MIN, SCTPCTL_VALID_COOKIE_LIFE_MAX);
570b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_init_rtx_max_default), SCTPCTL_INIT_RTX_MAX_MIN, SCTPCTL_INIT_RTX_MAX_MAX);
571b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default), SCTPCTL_ASSOC_RTX_MAX_MIN, SCTPCTL_ASSOC_RTX_MAX_MAX);
572b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_path_rtx_max_default), SCTPCTL_PATH_RTX_MAX_MIN, SCTPCTL_PATH_RTX_MAX_MAX);
573b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_add_more_threshold), SCTPCTL_ADD_MORE_ON_OUTPUT_MIN, SCTPCTL_ADD_MORE_ON_OUTPUT_MAX);
574b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default), SCTPCTL_OUTGOING_STREAMS_MIN, SCTPCTL_OUTGOING_STREAMS_MAX);
575b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_on_off), SCTPCTL_CMT_ON_OFF_MIN, SCTPCTL_CMT_ON_OFF_MAX);
576b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_use_dac), SCTPCTL_CMT_USE_DAC_MIN, SCTPCTL_CMT_USE_DAC_MAX);
577b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_pf), SCTPCTL_CMT_PF_MIN, SCTPCTL_CMT_PF_MAX);
578b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst), SCTPCTL_CWND_MAXBURST_MIN, SCTPCTL_CWND_MAXBURST_MAX);
579b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_early_fr), SCTPCTL_EARLY_FAST_RETRAN_MIN, SCTPCTL_EARLY_FAST_RETRAN_MAX);
580b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_early_fr_msec), SCTPCTL_EARLY_FAST_RETRAN_MSEC_MIN, SCTPCTL_EARLY_FAST_RETRAN_MSEC_MAX);
581b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_asconf_auth_nochk), SCTPCTL_ASCONF_AUTH_NOCHK_MIN, SCTPCTL_ASCONF_AUTH_NOCHK_MAX);
582b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_auth_disable), SCTPCTL_AUTH_DISABLE_MIN, SCTPCTL_AUTH_DISABLE_MAX);
583b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_nat_friendly), SCTPCTL_NAT_FRIENDLY_MIN, SCTPCTL_NAT_FRIENDLY_MAX);
584b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_L2_abc_variable), SCTPCTL_ABC_L_VAR_MIN, SCTPCTL_ABC_L_VAR_MAX);
585b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count), SCTPCTL_MAX_CHAINED_MBUFS_MIN, SCTPCTL_MAX_CHAINED_MBUFS_MAX);
586b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_do_drain), SCTPCTL_DO_SCTP_DRAIN_MIN, SCTPCTL_DO_SCTP_DRAIN_MAX);
587b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_hb_maxburst), SCTPCTL_HB_MAX_BURST_MIN, SCTPCTL_HB_MAX_BURST_MAX);
588b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit), SCTPCTL_ABORT_AT_LIMIT_MIN, SCTPCTL_ABORT_AT_LIMIT_MAX);
589b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_strict_data_order), SCTPCTL_STRICT_DATA_ORDER_MIN, SCTPCTL_STRICT_DATA_ORDER_MAX);
590b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_min_residual), SCTPCTL_MIN_RESIDUAL_MIN, SCTPCTL_MIN_RESIDUAL_MAX);
591b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_max_retran_chunk), SCTPCTL_MAX_RETRAN_CHUNK_MIN, SCTPCTL_MAX_RETRAN_CHUNK_MAX);
592b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_logging_level), SCTPCTL_LOGGING_LEVEL_MIN, SCTPCTL_LOGGING_LEVEL_MAX);
593b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_default_cc_module), SCTPCTL_DEFAULT_CC_MODULE_MIN, SCTPCTL_DEFAULT_CC_MODULE_MAX);
594b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_default_frag_interleave), SCTPCTL_DEFAULT_FRAG_INTERLEAVE_MIN, SCTPCTL_DEFAULT_FRAG_INTERLEAVE_MAX);
595851b7298SRandall Stewart #if defined(__FreeBSD__) || defined(SCTP_APPLE_MOBILITY_BASE)
596b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_mobility_base), SCTPCTL_MOBILITY_BASE_MIN, SCTPCTL_MOBILITY_BASE_MAX);
597851b7298SRandall Stewart #endif
598851b7298SRandall Stewart #if defined(__FreeBSD__) || defined(SCTP_APPLE_MOBILITY_FASTHANDOFF)
599b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff), SCTPCTL_MOBILITY_FASTHANDOFF_MIN, SCTPCTL_MOBILITY_FASTHANDOFF_MAX);
600851b7298SRandall Stewart #endif
601b3f1ea41SRandall 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);
602b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_enable_sack_immediately), SCTPCTL_SACK_IMMEDIATELY_ENABLE_MIN, SCTPCTL_SACK_IMMEDIATELY_ENABLE_MAX);
603851b7298SRandall Stewart #ifdef SCTP_DEBUG
604b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_debug_on), SCTPCTL_DEBUG_MIN, SCTPCTL_DEBUG_MAX);
605b3f1ea41SRandall Stewart #endif
606b3f1ea41SRandall Stewart #if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
607b3f1ea41SRandall Stewart 		RANGECHK(SCTP_BASE_SYSCTL(sctp_output_unlocked), SCTPCTL_OUTPUT_UNLOCKED_MIN, SCTPCTL_OUTPUT_UNLOCKED_MAX);
608851b7298SRandall Stewart #endif
609851b7298SRandall Stewart 	}
610851b7298SRandall Stewart 	return (error);
611851b7298SRandall Stewart }
61242551e99SRandall Stewart 
613b3f1ea41SRandall Stewart 
614b3f1ea41SRandall Stewart 
615b3f1ea41SRandall Stewart #if defined(SCTP_LOCAL_TRACE_BUF)
616b3f1ea41SRandall Stewart static int
617b3f1ea41SRandall Stewart sysctl_sctp_cleartrace(SYSCTL_HANDLER_ARGS)
618b3f1ea41SRandall Stewart {
619b3f1ea41SRandall Stewart 	memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log));
620b3f1ea41SRandall Stewart 	return (0);
621b3f1ea41SRandall Stewart }
622b3f1ea41SRandall Stewart 
623b3f1ea41SRandall Stewart #endif
624b3f1ea41SRandall Stewart 
625b3f1ea41SRandall Stewart 
626b3f1ea41SRandall Stewart 
62742551e99SRandall Stewart /*
62842551e99SRandall Stewart  * sysctl definitions
62942551e99SRandall Stewart  */
63042551e99SRandall Stewart 
631851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, sendspace, CTLTYPE_INT | CTLFLAG_RW,
632b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_sendspace), 0, sysctl_sctp_check, "IU",
633851b7298SRandall Stewart     SCTPCTL_MAXDGRAM_DESC);
63442551e99SRandall Stewart 
635851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, recvspace, CTLTYPE_INT | CTLFLAG_RW,
636b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_recvspace), 0, sysctl_sctp_check, "IU",
637851b7298SRandall Stewart     SCTPCTL_RECVSPACE_DESC);
63842551e99SRandall Stewart 
63942551e99SRandall Stewart #if defined(__FreeBSD__) || defined(SCTP_APPLE_AUTO_ASCONF)
640851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, auto_asconf, CTLTYPE_INT | CTLFLAG_RW,
641b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_auto_asconf), 0, sysctl_sctp_check, "IU",
642851b7298SRandall Stewart     SCTPCTL_AUTOASCONF_DESC);
64342551e99SRandall Stewart #endif
64442551e99SRandall Stewart 
645851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, ecn_enable, CTLTYPE_INT | CTLFLAG_RW,
646b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_ecn_enable), 0, sysctl_sctp_check, "IU",
647851b7298SRandall Stewart     SCTPCTL_ECN_ENABLE_DESC);
64842551e99SRandall Stewart 
649851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, ecn_nonce, CTLTYPE_INT | CTLFLAG_RW,
650b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_ecn_nonce), 0, sysctl_sctp_check, "IU",
651851b7298SRandall Stewart     SCTPCTL_ECN_NONCE_DESC);
65242551e99SRandall Stewart 
653851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, strict_sacks, CTLTYPE_INT | CTLFLAG_RW,
654b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_strict_sacks), 0, sysctl_sctp_check, "IU",
655851b7298SRandall Stewart     SCTPCTL_STRICT_SACKS_DESC);
65642551e99SRandall Stewart 
657851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, loopback_nocsum, CTLTYPE_INT | CTLFLAG_RW,
658b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback), 0, sysctl_sctp_check, "IU",
659851b7298SRandall Stewart     SCTPCTL_LOOPBACK_NOCSUM_DESC);
66042551e99SRandall Stewart 
661851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, strict_init, CTLTYPE_INT | CTLFLAG_RW,
662b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_strict_init), 0, sysctl_sctp_check, "IU",
663851b7298SRandall Stewart     SCTPCTL_STRICT_INIT_DESC);
66442551e99SRandall Stewart 
665851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, peer_chkoh, CTLTYPE_INT | CTLFLAG_RW,
666b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_peer_chunk_oh), 0, sysctl_sctp_check, "IU",
667851b7298SRandall Stewart     SCTPCTL_PEER_CHKOH_DESC);
66842551e99SRandall Stewart 
669851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, maxburst, CTLTYPE_INT | CTLFLAG_RW,
670b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_max_burst_default), 0, sysctl_sctp_check, "IU",
671851b7298SRandall Stewart     SCTPCTL_MAXBURST_DESC);
67242551e99SRandall Stewart 
673851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, maxchunks, CTLTYPE_INT | CTLFLAG_RW,
674b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue), 0, sysctl_sctp_check, "IU",
675851b7298SRandall Stewart     SCTPCTL_MAXCHUNKS_DESC);
67642551e99SRandall Stewart 
677851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, tcbhashsize, CTLTYPE_INT | CTLFLAG_RW,
678b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_hashtblsize), 0, sysctl_sctp_check, "IU",
679851b7298SRandall Stewart     SCTPCTL_TCBHASHSIZE_DESC);
68042551e99SRandall Stewart 
681851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, pcbhashsize, CTLTYPE_INT | CTLFLAG_RW,
682b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_pcbtblsize), 0, sysctl_sctp_check, "IU",
683851b7298SRandall Stewart     SCTPCTL_PCBHASHSIZE_DESC);
68442551e99SRandall Stewart 
685851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, min_split_point, CTLTYPE_INT | CTLFLAG_RW,
686b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_min_split_point), 0, sysctl_sctp_check, "IU",
687851b7298SRandall Stewart     SCTPCTL_MIN_SPLIT_POINT_DESC);
68842551e99SRandall Stewart 
689851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, chunkscale, CTLTYPE_INT | CTLFLAG_RW,
690b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_chunkscale), 0, sysctl_sctp_check, "IU",
691851b7298SRandall Stewart     SCTPCTL_CHUNKSCALE_DESC);
69242551e99SRandall Stewart 
693851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, delayed_sack_time, CTLTYPE_INT | CTLFLAG_RW,
694b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default), 0, sysctl_sctp_check, "IU",
695851b7298SRandall Stewart     SCTPCTL_DELAYED_SACK_TIME_DESC);
69642551e99SRandall Stewart 
697851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, sack_freq, CTLTYPE_INT | CTLFLAG_RW,
698b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_sack_freq_default), 0, sysctl_sctp_check, "IU",
699851b7298SRandall Stewart     SCTPCTL_SACK_FREQ_DESC);
70042551e99SRandall Stewart 
701851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, sys_resource, CTLTYPE_INT | CTLFLAG_RW,
702b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_system_free_resc_limit), 0, sysctl_sctp_check, "IU",
703851b7298SRandall Stewart     SCTPCTL_SYS_RESOURCE_DESC);
70442551e99SRandall Stewart 
705851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, asoc_resource, CTLTYPE_INT | CTLFLAG_RW,
706b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit), 0, sysctl_sctp_check, "IU",
707851b7298SRandall Stewart     SCTPCTL_ASOC_RESOURCE_DESC);
70842551e99SRandall Stewart 
709851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, heartbeat_interval, CTLTYPE_INT | CTLFLAG_RW,
710b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default), 0, sysctl_sctp_check, "IU",
711851b7298SRandall Stewart     SCTPCTL_HEARTBEAT_INTERVAL_DESC);
71242551e99SRandall Stewart 
713851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, pmtu_raise_time, CTLTYPE_INT | CTLFLAG_RW,
714b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default), 0, sysctl_sctp_check, "IU",
715851b7298SRandall Stewart     SCTPCTL_PMTU_RAISE_TIME_DESC);
71642551e99SRandall Stewart 
717851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, shutdown_guard_time, CTLTYPE_INT | CTLFLAG_RW,
718b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default), 0, sysctl_sctp_check, "IU",
719851b7298SRandall Stewart     SCTPCTL_SHUTDOWN_GUARD_TIME_DESC);
72042551e99SRandall Stewart 
721851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, secret_lifetime, CTLTYPE_INT | CTLFLAG_RW,
722b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_secret_lifetime_default), 0, sysctl_sctp_check, "IU",
723851b7298SRandall Stewart     SCTPCTL_SECRET_LIFETIME_DESC);
72442551e99SRandall Stewart 
725851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, rto_max, CTLTYPE_INT | CTLFLAG_RW,
726b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_rto_max_default), 0, sysctl_sctp_check, "IU",
727851b7298SRandall Stewart     SCTPCTL_RTO_MAX_DESC);
72842551e99SRandall Stewart 
729851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, rto_min, CTLTYPE_INT | CTLFLAG_RW,
730b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_rto_min_default), 0, sysctl_sctp_check, "IU",
731851b7298SRandall Stewart     SCTPCTL_RTO_MIN_DESC);
73242551e99SRandall Stewart 
733851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, rto_initial, CTLTYPE_INT | CTLFLAG_RW,
734b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_rto_initial_default), 0, sysctl_sctp_check, "IU",
735851b7298SRandall Stewart     SCTPCTL_RTO_INITIAL_DESC);
73642551e99SRandall Stewart 
737851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, init_rto_max, CTLTYPE_INT | CTLFLAG_RW,
738b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_init_rto_max_default), 0, sysctl_sctp_check, "IU",
739851b7298SRandall Stewart     SCTPCTL_INIT_RTO_MAX_DESC);
74042551e99SRandall Stewart 
741851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, valid_cookie_life, CTLTYPE_INT | CTLFLAG_RW,
742b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default), 0, sysctl_sctp_check, "IU",
743851b7298SRandall Stewart     SCTPCTL_VALID_COOKIE_LIFE_DESC);
74442551e99SRandall Stewart 
745851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, init_rtx_max, CTLTYPE_INT | CTLFLAG_RW,
746b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_init_rtx_max_default), 0, sysctl_sctp_check, "IU",
747851b7298SRandall Stewart     SCTPCTL_INIT_RTX_MAX_DESC);
74842551e99SRandall Stewart 
749851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, assoc_rtx_max, CTLTYPE_INT | CTLFLAG_RW,
750b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default), 0, sysctl_sctp_check, "IU",
751851b7298SRandall Stewart     SCTPCTL_ASSOC_RTX_MAX_DESC);
75242551e99SRandall Stewart 
753851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, path_rtx_max, CTLTYPE_INT | CTLFLAG_RW,
754b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_path_rtx_max_default), 0, sysctl_sctp_check, "IU",
755851b7298SRandall Stewart     SCTPCTL_PATH_RTX_MAX_DESC);
75642551e99SRandall Stewart 
757851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, add_more_on_output, CTLTYPE_INT | CTLFLAG_RW,
758b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_add_more_threshold), 0, sysctl_sctp_check, "IU",
759851b7298SRandall Stewart     SCTPCTL_ADD_MORE_ON_OUTPUT_DESC);
76042551e99SRandall Stewart 
761851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, outgoing_streams, CTLTYPE_INT | CTLFLAG_RW,
762b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default), 0, sysctl_sctp_check, "IU",
763851b7298SRandall Stewart     SCTPCTL_OUTGOING_STREAMS_DESC);
76442551e99SRandall Stewart 
765851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, cmt_on_off, CTLTYPE_INT | CTLFLAG_RW,
766b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_cmt_on_off), 0, sysctl_sctp_check, "IU",
767851b7298SRandall Stewart     SCTPCTL_CMT_ON_OFF_DESC);
76842551e99SRandall Stewart 
769851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, cmt_use_dac, CTLTYPE_INT | CTLFLAG_RW,
770b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_cmt_use_dac), 0, sysctl_sctp_check, "IU",
771851b7298SRandall Stewart     SCTPCTL_CMT_USE_DAC_DESC);
772b54d3a6cSRandall Stewart 
773851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, cmt_pf, CTLTYPE_INT | CTLFLAG_RW,
774b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_cmt_pf), 0, sysctl_sctp_check, "IU",
775851b7298SRandall Stewart     SCTPCTL_CMT_PF_DESC);
776b54d3a6cSRandall Stewart 
777851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, cwnd_maxburst, CTLTYPE_INT | CTLFLAG_RW,
778b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst), 0, sysctl_sctp_check, "IU",
779851b7298SRandall Stewart     SCTPCTL_CWND_MAXBURST_DESC);
780c4739e2fSRandall Stewart 
781851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, early_fast_retran, CTLTYPE_INT | CTLFLAG_RW,
782b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_early_fr), 0, sysctl_sctp_check, "IU",
783851b7298SRandall Stewart     SCTPCTL_EARLY_FAST_RETRAN_DESC);
784851b7298SRandall Stewart 
785851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, early_fast_retran_msec, CTLTYPE_INT | CTLFLAG_RW,
786b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_early_fr_msec), 0, sysctl_sctp_check, "IU",
787851b7298SRandall Stewart     SCTPCTL_EARLY_FAST_RETRAN_MSEC_DESC);
788851b7298SRandall Stewart 
789851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, asconf_auth_nochk, CTLTYPE_INT | CTLFLAG_RW,
790b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_asconf_auth_nochk), 0, sysctl_sctp_check, "IU",
791851b7298SRandall Stewart     SCTPCTL_ASCONF_AUTH_NOCHK_DESC);
792851b7298SRandall Stewart 
793851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, auth_disable, CTLTYPE_INT | CTLFLAG_RW,
794b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_auth_disable), 0, sysctl_sctp_check, "IU",
795851b7298SRandall Stewart     SCTPCTL_AUTH_DISABLE_DESC);
796851b7298SRandall Stewart 
797851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, nat_friendly, CTLTYPE_INT | CTLFLAG_RW,
798b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_nat_friendly), 0, sysctl_sctp_check, "IU",
799851b7298SRandall Stewart     SCTPCTL_NAT_FRIENDLY_DESC);
800851b7298SRandall Stewart 
801851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, abc_l_var, CTLTYPE_INT | CTLFLAG_RW,
802b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_L2_abc_variable), 0, sysctl_sctp_check, "IU",
803851b7298SRandall Stewart     SCTPCTL_ABC_L_VAR_DESC);
804851b7298SRandall Stewart 
805851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, max_chained_mbufs, CTLTYPE_INT | CTLFLAG_RW,
806b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count), 0, sysctl_sctp_check, "IU",
807851b7298SRandall Stewart     SCTPCTL_MAX_CHAINED_MBUFS_DESC);
808851b7298SRandall Stewart 
809851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, do_sctp_drain, CTLTYPE_INT | CTLFLAG_RW,
810b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_do_drain), 0, sysctl_sctp_check, "IU",
811851b7298SRandall Stewart     SCTPCTL_DO_SCTP_DRAIN_DESC);
812851b7298SRandall Stewart 
813851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, hb_max_burst, CTLTYPE_INT | CTLFLAG_RW,
814b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_hb_maxburst), 0, sysctl_sctp_check, "IU",
815851b7298SRandall Stewart     SCTPCTL_HB_MAX_BURST_DESC);
816851b7298SRandall Stewart 
817851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, abort_at_limit, CTLTYPE_INT | CTLFLAG_RW,
818b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit), 0, sysctl_sctp_check, "IU",
819851b7298SRandall Stewart     SCTPCTL_ABORT_AT_LIMIT_DESC);
820851b7298SRandall Stewart 
821851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, strict_data_order, CTLTYPE_INT | CTLFLAG_RW,
822b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_strict_data_order), 0, sysctl_sctp_check, "IU",
823851b7298SRandall Stewart     SCTPCTL_STRICT_DATA_ORDER_DESC);
824851b7298SRandall Stewart 
825851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, min_residual, CTLTYPE_INT | CTLFLAG_RW,
826b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_min_residual), 0, sysctl_sctp_check, "IU",
827851b7298SRandall Stewart     SCTPCTL_MIN_RESIDUAL_DESC);
828851b7298SRandall Stewart 
829851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, max_retran_chunk, CTLTYPE_INT | CTLFLAG_RW,
830b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_max_retran_chunk), 0, sysctl_sctp_check, "IU",
831851b7298SRandall Stewart     SCTPCTL_MAX_RETRAN_CHUNK_DESC);
832851b7298SRandall Stewart 
833b27a6b7dSRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, log_level, CTLTYPE_INT | CTLFLAG_RW,
834b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_logging_level), 0, sysctl_sctp_check, "IU",
835851b7298SRandall Stewart     SCTPCTL_LOGGING_LEVEL_DESC);
836851b7298SRandall Stewart 
837851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, default_cc_module, CTLTYPE_INT | CTLFLAG_RW,
838b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_default_cc_module), 0, sysctl_sctp_check, "IU",
839851b7298SRandall Stewart     SCTPCTL_DEFAULT_CC_MODULE_DESC);
840851b7298SRandall Stewart 
841851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, default_frag_interleave, CTLTYPE_INT | CTLFLAG_RW,
842b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_default_frag_interleave), 0, sysctl_sctp_check, "IU",
843c4739e2fSRandall Stewart     SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DESC);
844c4739e2fSRandall Stewart 
845851b7298SRandall Stewart #if defined(__FreeBSD__) || defined(SCTP_APPLE_MOBILITY_BASE)
846851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mobility_base, CTLTYPE_INT | CTLFLAG_RW,
847b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_mobility_base), 0, sysctl_sctp_check, "IU",
848851b7298SRandall Stewart     SCTPCTL_MOBILITY_BASE_DESC);
849851b7298SRandall Stewart #endif
85042551e99SRandall Stewart 
851851b7298SRandall Stewart #if defined(__FreeBSD__) || defined(SCTP_APPLE_MOBILITY_FASTHANDOFF)
852851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mobility_fasthandoff, CTLTYPE_INT | CTLFLAG_RW,
853b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff), 0, sysctl_sctp_check, "IU",
854851b7298SRandall Stewart     SCTPCTL_MOBILITY_FASTHANDOFF_DESC);
855851b7298SRandall Stewart #endif
85642551e99SRandall Stewart 
857b27a6b7dSRandall Stewart #if defined(SCTP_LOCAL_TRACE_BUF)
858b27a6b7dSRandall Stewart SYSCTL_STRUCT(_net_inet_sctp, OID_AUTO, log, CTLFLAG_RD,
859b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_log), sctp_log,
860b27a6b7dSRandall Stewart     "SCTP logging (struct sctp_log)");
861b3f1ea41SRandall Stewart 
862b3f1ea41SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, clear_trace, CTLTYPE_OPAQUE | CTLFLAG_RW,
863b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_log), 0, sysctl_sctp_cleartrace, "IU",
864b3f1ea41SRandall Stewart     "Clear SCTP Logging buffer");
865b3f1ea41SRandall Stewart 
866b3f1ea41SRandall Stewart 
867b3f1ea41SRandall Stewart 
868b27a6b7dSRandall Stewart #endif
869b27a6b7dSRandall Stewart 
870c54a18d2SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, udp_tunneling_for_client_enable, CTLTYPE_INT | CTLFLAG_RW,
871b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_udp_tunneling_for_client_enable), 0, sysctl_sctp_check, "IU",
872c54a18d2SRandall Stewart     SCTPCTL_UDP_TUNNELING_FOR_CLIENT_ENABLE_DESC);
873c54a18d2SRandall Stewart 
874c54a18d2SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, udp_tunneling_port, CTLTYPE_INT | CTLFLAG_RW,
875b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_udp_tunneling_port), 0, sysctl_sctp_udp_tunneling_check, "IU",
876c54a18d2SRandall Stewart     SCTPCTL_UDP_TUNNELING_PORT_DESC);
877c54a18d2SRandall Stewart 
878b3f1ea41SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, enable_sack_immediately, CTLTYPE_INT | CTLFLAG_RW,
879b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_enable_sack_immediately), 0, sysctl_sctp_check, "IU",
880b3f1ea41SRandall Stewart     SCTPCTL_SACK_IMMEDIATELY_ENABLE_DESC);
881b3f1ea41SRandall Stewart 
882851b7298SRandall Stewart #ifdef SCTP_DEBUG
883851b7298SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, debug, CTLTYPE_INT | CTLFLAG_RW,
884b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_debug_on), 0, sysctl_sctp_check, "IU",
885851b7298SRandall Stewart     SCTPCTL_DEBUG_DESC);
886851b7298SRandall Stewart #endif				/* SCTP_DEBUG */
88742551e99SRandall Stewart 
88842551e99SRandall Stewart 
889b3f1ea41SRandall Stewart #if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
890b3f1ea41SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, output_unlocked, CTLTYPE_INT | CTLFLAG_RW,
891b3f1ea41SRandall Stewart     &SCTP_BASE_SYSCTL(sctp_output_unlocked), 0, sysctl_sctp_check, "IU",
892b3f1ea41SRandall Stewart     SCTPCTL_OUTPUT_UNLOCKED_DESC);
893b3f1ea41SRandall Stewart #endif
894b3f1ea41SRandall Stewart 
89542551e99SRandall Stewart SYSCTL_STRUCT(_net_inet_sctp, OID_AUTO, stats, CTLFLAG_RW,
896b3f1ea41SRandall Stewart     &SCTP_BASE_STATS, sctpstat,
897b27a6b7dSRandall Stewart     "SCTP statistics (struct sctp_stat)");
89842551e99SRandall Stewart 
89942551e99SRandall Stewart SYSCTL_PROC(_net_inet_sctp, OID_AUTO, assoclist, CTLFLAG_RD,
90042551e99SRandall Stewart     0, 0, sctp_assoclist,
90142551e99SRandall Stewart     "S,xassoc", "List of active SCTP associations");
902