1167598Srrs/*-
2169382Srrs * Copyright (c) 2007, by Cisco Systems, Inc. All rights reserved.
3235828Stuexen * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
4235828Stuexen * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
5167598Srrs *
6167598Srrs * Redistribution and use in source and binary forms, with or without
7167598Srrs * modification, are permitted provided that the following conditions are met:
8167598Srrs *
9167598Srrs * a) Redistributions of source code must retain the above copyright notice,
10228653Stuexen *    this list of conditions and the following disclaimer.
11167598Srrs *
12167598Srrs * b) Redistributions in binary form must reproduce the above copyright
13167598Srrs *    notice, this list of conditions and the following disclaimer in
14228653Stuexen *    the documentation and/or other materials provided with the distribution.
15167598Srrs *
16167598Srrs * c) Neither the name of Cisco Systems, Inc. nor the names of its
17167598Srrs *    contributors may be used to endorse or promote products derived
18167598Srrs *    from this software without specific prior written permission.
19167598Srrs *
20167598Srrs * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21167598Srrs * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22167598Srrs * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23167598Srrs * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24167598Srrs * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25167598Srrs * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26167598Srrs * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27167598Srrs * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28167598Srrs * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29167598Srrs * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30167598Srrs * THE POSSIBILITY OF SUCH DAMAGE.
31167598Srrs */
32167598Srrs
33167598Srrs#include <sys/cdefs.h>
34167598Srrs__FBSDID("$FreeBSD: stable/11/sys/netinet/sctp_sysctl.c 340923 2018-11-25 18:00:50Z markj $");
35167598Srrs
36167598Srrs#include <netinet/sctp_os.h>
37179783Srrs#include <netinet/sctp.h>
38167598Srrs#include <netinet/sctp_constants.h>
39167598Srrs#include <netinet/sctp_sysctl.h>
40167598Srrs#include <netinet/sctp_pcb.h>
41167598Srrs#include <netinet/sctputil.h>
42170056Srrs#include <netinet/sctp_output.h>
43205629Srrs#include <sys/smp.h>
44270673Stuexen#include <sys/sysctl.h>
45179783Srrs
46270673StuexenFEATURE(sctp, "Stream Control Transmission Protocol");
47270673Stuexen
48167598Srrs/*
49167598Srrs * sysctl tunable variables
50167598Srrs */
51167598Srrs
52179783Srrsvoid
53179783Srrssctp_init_sysctls()
54179783Srrs{
55179783Srrs	SCTP_BASE_SYSCTL(sctp_sendspace) = SCTPCTL_MAXDGRAM_DEFAULT;
56179783Srrs	SCTP_BASE_SYSCTL(sctp_recvspace) = SCTPCTL_RECVSPACE_DEFAULT;
57179783Srrs	SCTP_BASE_SYSCTL(sctp_auto_asconf) = SCTPCTL_AUTOASCONF_DEFAULT;
58179783Srrs	SCTP_BASE_SYSCTL(sctp_multiple_asconfs) = SCTPCTL_MULTIPLEASCONFS_DEFAULT;
59179783Srrs	SCTP_BASE_SYSCTL(sctp_ecn_enable) = SCTPCTL_ECN_ENABLE_DEFAULT;
60269448Stuexen	SCTP_BASE_SYSCTL(sctp_pr_enable) = SCTPCTL_PR_ENABLE_DEFAULT;
61269874Stuexen	SCTP_BASE_SYSCTL(sctp_auth_enable) = SCTPCTL_AUTH_ENABLE_DEFAULT;
62269858Stuexen	SCTP_BASE_SYSCTL(sctp_asconf_enable) = SCTPCTL_ASCONF_ENABLE_DEFAULT;
63269527Stuexen	SCTP_BASE_SYSCTL(sctp_reconfig_enable) = SCTPCTL_RECONFIG_ENABLE_DEFAULT;
64269475Stuexen	SCTP_BASE_SYSCTL(sctp_nrsack_enable) = SCTPCTL_NRSACK_ENABLE_DEFAULT;
65269481Stuexen	SCTP_BASE_SYSCTL(sctp_pktdrop_enable) = SCTPCTL_PKTDROP_ENABLE_DEFAULT;
66179783Srrs	SCTP_BASE_SYSCTL(sctp_peer_chunk_oh) = SCTPCTL_PEER_CHKOH_DEFAULT;
67179783Srrs	SCTP_BASE_SYSCTL(sctp_max_burst_default) = SCTPCTL_MAXBURST_DEFAULT;
68218186Srrs	SCTP_BASE_SYSCTL(sctp_fr_max_burst_default) = SCTPCTL_FRMAXBURST_DEFAULT;
69179783Srrs	SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue) = SCTPCTL_MAXCHUNKS_DEFAULT;
70179783Srrs	SCTP_BASE_SYSCTL(sctp_hashtblsize) = SCTPCTL_TCBHASHSIZE_DEFAULT;
71179783Srrs	SCTP_BASE_SYSCTL(sctp_pcbtblsize) = SCTPCTL_PCBHASHSIZE_DEFAULT;
72179783Srrs	SCTP_BASE_SYSCTL(sctp_min_split_point) = SCTPCTL_MIN_SPLIT_POINT_DEFAULT;
73179783Srrs	SCTP_BASE_SYSCTL(sctp_chunkscale) = SCTPCTL_CHUNKSCALE_DEFAULT;
74179783Srrs	SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default) = SCTPCTL_DELAYED_SACK_TIME_DEFAULT;
75179783Srrs	SCTP_BASE_SYSCTL(sctp_sack_freq_default) = SCTPCTL_SACK_FREQ_DEFAULT;
76179783Srrs	SCTP_BASE_SYSCTL(sctp_system_free_resc_limit) = SCTPCTL_SYS_RESOURCE_DEFAULT;
77179783Srrs	SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit) = SCTPCTL_ASOC_RESOURCE_DEFAULT;
78179783Srrs	SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default) = SCTPCTL_HEARTBEAT_INTERVAL_DEFAULT;
79179783Srrs	SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default) = SCTPCTL_PMTU_RAISE_TIME_DEFAULT;
80179783Srrs	SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default) = SCTPCTL_SHUTDOWN_GUARD_TIME_DEFAULT;
81179783Srrs	SCTP_BASE_SYSCTL(sctp_secret_lifetime_default) = SCTPCTL_SECRET_LIFETIME_DEFAULT;
82179783Srrs	SCTP_BASE_SYSCTL(sctp_rto_max_default) = SCTPCTL_RTO_MAX_DEFAULT;
83179783Srrs	SCTP_BASE_SYSCTL(sctp_rto_min_default) = SCTPCTL_RTO_MIN_DEFAULT;
84179783Srrs	SCTP_BASE_SYSCTL(sctp_rto_initial_default) = SCTPCTL_RTO_INITIAL_DEFAULT;
85179783Srrs	SCTP_BASE_SYSCTL(sctp_init_rto_max_default) = SCTPCTL_INIT_RTO_MAX_DEFAULT;
86179783Srrs	SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default) = SCTPCTL_VALID_COOKIE_LIFE_DEFAULT;
87179783Srrs	SCTP_BASE_SYSCTL(sctp_init_rtx_max_default) = SCTPCTL_INIT_RTX_MAX_DEFAULT;
88179783Srrs	SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default) = SCTPCTL_ASSOC_RTX_MAX_DEFAULT;
89179783Srrs	SCTP_BASE_SYSCTL(sctp_path_rtx_max_default) = SCTPCTL_PATH_RTX_MAX_DEFAULT;
90224641Stuexen	SCTP_BASE_SYSCTL(sctp_path_pf_threshold) = SCTPCTL_PATH_PF_THRESHOLD_DEFAULT;
91179783Srrs	SCTP_BASE_SYSCTL(sctp_add_more_threshold) = SCTPCTL_ADD_MORE_ON_OUTPUT_DEFAULT;
92252779Stuexen	SCTP_BASE_SYSCTL(sctp_nr_incoming_streams_default) = SCTPCTL_INCOMING_STREAMS_DEFAULT;
93179783Srrs	SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default) = SCTPCTL_OUTGOING_STREAMS_DEFAULT;
94179783Srrs	SCTP_BASE_SYSCTL(sctp_cmt_on_off) = SCTPCTL_CMT_ON_OFF_DEFAULT;
95179783Srrs	SCTP_BASE_SYSCTL(sctp_cmt_use_dac) = SCTPCTL_CMT_USE_DAC_DEFAULT;
96179783Srrs	SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst) = SCTPCTL_CWND_MAXBURST_DEFAULT;
97179783Srrs	SCTP_BASE_SYSCTL(sctp_nat_friendly) = SCTPCTL_NAT_FRIENDLY_DEFAULT;
98179783Srrs	SCTP_BASE_SYSCTL(sctp_L2_abc_variable) = SCTPCTL_ABC_L_VAR_DEFAULT;
99179783Srrs	SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count) = SCTPCTL_MAX_CHAINED_MBUFS_DEFAULT;
100179783Srrs	SCTP_BASE_SYSCTL(sctp_do_drain) = SCTPCTL_DO_SCTP_DRAIN_DEFAULT;
101179783Srrs	SCTP_BASE_SYSCTL(sctp_hb_maxburst) = SCTPCTL_HB_MAX_BURST_DEFAULT;
102179783Srrs	SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit) = SCTPCTL_ABORT_AT_LIMIT_DEFAULT;
103179783Srrs	SCTP_BASE_SYSCTL(sctp_min_residual) = SCTPCTL_MIN_RESIDUAL_DEFAULT;
104179783Srrs	SCTP_BASE_SYSCTL(sctp_max_retran_chunk) = SCTPCTL_MAX_RETRAN_CHUNK_DEFAULT;
105179783Srrs	SCTP_BASE_SYSCTL(sctp_logging_level) = SCTPCTL_LOGGING_LEVEL_DEFAULT;
106179783Srrs	SCTP_BASE_SYSCTL(sctp_default_cc_module) = SCTPCTL_DEFAULT_CC_MODULE_DEFAULT;
107217760Stuexen	SCTP_BASE_SYSCTL(sctp_default_ss_module) = SCTPCTL_DEFAULT_SS_MODULE_DEFAULT;
108179783Srrs	SCTP_BASE_SYSCTL(sctp_default_frag_interleave) = SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DEFAULT;
109179783Srrs	SCTP_BASE_SYSCTL(sctp_mobility_base) = SCTPCTL_MOBILITY_BASE_DEFAULT;
110179783Srrs	SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff) = SCTPCTL_MOBILITY_FASTHANDOFF_DEFAULT;
111193090Srrs	SCTP_BASE_SYSCTL(sctp_vtag_time_wait) = SCTPCTL_TIME_WAIT_DEFAULT;
112212799Stuexen	SCTP_BASE_SYSCTL(sctp_buffer_splitting) = SCTPCTL_BUFFER_SPLITTING_DEFAULT;
113212800Stuexen	SCTP_BASE_SYSCTL(sctp_initial_cwnd) = SCTPCTL_INITIAL_CWND_DEFAULT;
114219057Srrs	SCTP_BASE_SYSCTL(sctp_rttvar_bw) = SCTPCTL_RTTVAR_BW_DEFAULT;
115219057Srrs	SCTP_BASE_SYSCTL(sctp_rttvar_rtt) = SCTPCTL_RTTVAR_RTT_DEFAULT;
116219057Srrs	SCTP_BASE_SYSCTL(sctp_rttvar_eqret) = SCTPCTL_RTTVAR_EQRET_DEFAULT;
117219397Srrs	SCTP_BASE_SYSCTL(sctp_steady_step) = SCTPCTL_RTTVAR_STEADYS_DEFAULT;
118219397Srrs	SCTP_BASE_SYSCTL(sctp_use_dccc_ecn) = SCTPCTL_RTTVAR_DCCCECN_DEFAULT;
119229805Stuexen	SCTP_BASE_SYSCTL(sctp_blackhole) = SCTPCTL_BLACKHOLE_DEFAULT;
120263237Stuexen	SCTP_BASE_SYSCTL(sctp_diag_info_code) = SCTPCTL_DIAG_INFO_CODE_DEFAULT;
121172157Srrs#if defined(SCTP_LOCAL_TRACE_BUF)
122179783Srrs	memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log));
123172157Srrs#endif
124179783Srrs	SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = SCTPCTL_UDP_TUNNELING_PORT_DEFAULT;
125179783Srrs	SCTP_BASE_SYSCTL(sctp_enable_sack_immediately) = SCTPCTL_SACK_IMMEDIATELY_ENABLE_DEFAULT;
126195919Stuexen	SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly) = SCTPCTL_NAT_FRIENDLY_INITS_DEFAULT;
127179783Srrs#if defined(SCTP_DEBUG)
128179783Srrs	SCTP_BASE_SYSCTL(sctp_debug_on) = SCTPCTL_DEBUG_DEFAULT;
129167598Srrs#endif
130179783Srrs#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
131179783Srrs	SCTP_BASE_SYSCTL(sctp_output_unlocked) = SCTPCTL_OUTPUT_UNLOCKED_DEFAULT;
132179783Srrs#endif
133179783Srrs}
134167598Srrs
135188067Srrs
136170056Srrs/* It returns an upper limit. No filtering is done here */
137170056Srrsstatic unsigned int
138271204Stuexensctp_sysctl_number_of_addresses(struct sctp_inpcb *inp)
139170056Srrs{
140228653Stuexen	unsigned int cnt;
141170056Srrs	struct sctp_vrf *vrf;
142170056Srrs	struct sctp_ifn *sctp_ifn;
143170056Srrs	struct sctp_ifa *sctp_ifa;
144170056Srrs	struct sctp_laddr *laddr;
145170056Srrs
146170056Srrs	cnt = 0;
147170056Srrs	/* neither Mac OS X nor FreeBSD support mulitple routing functions */
148170056Srrs	if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) {
149170056Srrs		return (0);
150170056Srrs	}
151170056Srrs	if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
152170056Srrs		LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
153170056Srrs			LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
154221249Stuexen				switch (sctp_ifa->address.sa.sa_family) {
155221249Stuexen#ifdef INET
156221249Stuexen				case AF_INET:
157221249Stuexen#endif
158221249Stuexen#ifdef INET6
159221249Stuexen				case AF_INET6:
160221249Stuexen#endif
161170056Srrs					cnt++;
162221249Stuexen					break;
163221249Stuexen				default:
164221249Stuexen					break;
165170056Srrs				}
166170056Srrs			}
167170056Srrs		}
168170056Srrs	} else {
169170056Srrs		LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
170221249Stuexen			switch (laddr->ifa->address.sa.sa_family) {
171221249Stuexen#ifdef INET
172221249Stuexen			case AF_INET:
173221249Stuexen#endif
174221249Stuexen#ifdef INET6
175221249Stuexen			case AF_INET6:
176221249Stuexen#endif
177170056Srrs				cnt++;
178221249Stuexen				break;
179221249Stuexen			default:
180221249Stuexen				break;
181170056Srrs			}
182170056Srrs		}
183170056Srrs	}
184170056Srrs	return (cnt);
185170056Srrs}
186170056Srrs
187170056Srrsstatic int
188271204Stuexensctp_sysctl_copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sysctl_req *req)
189170056Srrs{
190170056Srrs	struct sctp_ifn *sctp_ifn;
191170056Srrs	struct sctp_ifa *sctp_ifa;
192170056Srrs	int loopback_scope, ipv4_local_scope, local_scope, site_scope;
193170056Srrs	int ipv4_addr_legal, ipv6_addr_legal;
194170056Srrs	struct sctp_vrf *vrf;
195170056Srrs	struct xsctp_laddr xladdr;
196170056Srrs	struct sctp_laddr *laddr;
197170056Srrs	int error;
198170056Srrs
199170056Srrs	/* Turn on all the appropriate scope */
200170056Srrs	if (stcb) {
201170056Srrs		/* use association specific values */
202246595Stuexen		loopback_scope = stcb->asoc.scope.loopback_scope;
203246595Stuexen		ipv4_local_scope = stcb->asoc.scope.ipv4_local_scope;
204246595Stuexen		local_scope = stcb->asoc.scope.local_scope;
205246595Stuexen		site_scope = stcb->asoc.scope.site_scope;
206246595Stuexen		ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal;
207246595Stuexen		ipv6_addr_legal = stcb->asoc.scope.ipv6_addr_legal;
208170056Srrs	} else {
209246595Stuexen		/* Use generic values for endpoints. */
210170056Srrs		loopback_scope = 1;
211170056Srrs		ipv4_local_scope = 1;
212170056Srrs		local_scope = 1;
213170056Srrs		site_scope = 1;
214246595Stuexen		if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) {
215246595Stuexen			ipv6_addr_legal = 1;
216246595Stuexen			if (SCTP_IPV6_V6ONLY(inp)) {
217246595Stuexen				ipv4_addr_legal = 0;
218246595Stuexen			} else {
219246595Stuexen				ipv4_addr_legal = 1;
220246595Stuexen			}
221170056Srrs		} else {
222246595Stuexen			ipv6_addr_legal = 0;
223170056Srrs			ipv4_addr_legal = 1;
224170056Srrs		}
225170056Srrs	}
226170056Srrs
227170056Srrs	/* neither Mac OS X nor FreeBSD support mulitple routing functions */
228170056Srrs	if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) {
229170354Srrs		SCTP_INP_RUNLOCK(inp);
230170354Srrs		SCTP_INP_INFO_RUNLOCK();
231170056Srrs		return (-1);
232170056Srrs	}
233170056Srrs	if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
234170056Srrs		LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
235170056Srrs			if ((loopback_scope == 0) && SCTP_IFN_IS_IFT_LOOP(sctp_ifn))
236170056Srrs				/* Skip loopback if loopback_scope not set */
237170056Srrs				continue;
238170056Srrs			LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
239170056Srrs				if (stcb) {
240170056Srrs					/*
241170056Srrs					 * ignore if blacklisted at
242170056Srrs					 * association level
243170056Srrs					 */
244170056Srrs					if (sctp_is_addr_restricted(stcb, sctp_ifa))
245170056Srrs						continue;
246170056Srrs				}
247178251Srrs				switch (sctp_ifa->address.sa.sa_family) {
248221249Stuexen#ifdef INET
249178251Srrs				case AF_INET:
250178251Srrs					if (ipv4_addr_legal) {
251178251Srrs						struct sockaddr_in *sin;
252170056Srrs
253271221Stuexen						sin = &sctp_ifa->address.sin;
254178251Srrs						if (sin->sin_addr.s_addr == 0)
255178251Srrs							continue;
256267674Stuexen						if (prison_check_ip4(inp->ip_inp.inp.inp_cred,
257267674Stuexen						    &sin->sin_addr) != 0) {
258267674Stuexen							continue;
259267674Stuexen						}
260178251Srrs						if ((ipv4_local_scope == 0) && (IN4_ISPRIVATE_ADDRESS(&sin->sin_addr)))
261178251Srrs							continue;
262178251Srrs					} else {
263170056Srrs						continue;
264178251Srrs					}
265178251Srrs					break;
266221249Stuexen#endif
267178251Srrs#ifdef INET6
268178251Srrs				case AF_INET6:
269178251Srrs					if (ipv6_addr_legal) {
270178251Srrs						struct sockaddr_in6 *sin6;
271170056Srrs
272271221Stuexen						sin6 = &sctp_ifa->address.sin6;
273178251Srrs						if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr))
274170056Srrs							continue;
275267674Stuexen						if (prison_check_ip6(inp->ip_inp.inp.inp_cred,
276267674Stuexen						    &sin6->sin6_addr) != 0) {
277267674Stuexen							continue;
278267674Stuexen						}
279178251Srrs						if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
280178251Srrs							if (local_scope == 0)
281170056Srrs								continue;
282170056Srrs						}
283178251Srrs						if ((site_scope == 0) && (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)))
284178251Srrs							continue;
285178251Srrs					} else {
286178251Srrs						continue;
287170056Srrs					}
288178251Srrs					break;
289178251Srrs#endif
290178251Srrs				default:
291170056Srrs					continue;
292178251Srrs				}
293172091Srrs				memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
294170056Srrs				memcpy((void *)&xladdr.address, (const void *)&sctp_ifa->address, sizeof(union sctp_sockstore));
295170056Srrs				SCTP_INP_RUNLOCK(inp);
296170056Srrs				SCTP_INP_INFO_RUNLOCK();
297170056Srrs				error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
298172091Srrs				if (error) {
299170056Srrs					return (error);
300172091Srrs				} else {
301170056Srrs					SCTP_INP_INFO_RLOCK();
302170056Srrs					SCTP_INP_RLOCK(inp);
303170056Srrs				}
304170056Srrs			}
305170056Srrs		}
306170056Srrs	} else {
307170056Srrs		LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
308170056Srrs			/* ignore if blacklisted at association level */
309170056Srrs			if (stcb && sctp_is_addr_restricted(stcb, laddr->ifa))
310170056Srrs				continue;
311172091Srrs			memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
312170056Srrs			memcpy((void *)&xladdr.address, (const void *)&laddr->ifa->address, sizeof(union sctp_sockstore));
313310773Stuexen			xladdr.start_time.tv_sec = (uint32_t)laddr->start_time.tv_sec;
314310773Stuexen			xladdr.start_time.tv_usec = (uint32_t)laddr->start_time.tv_usec;
315170056Srrs			SCTP_INP_RUNLOCK(inp);
316170056Srrs			SCTP_INP_INFO_RUNLOCK();
317170056Srrs			error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
318172091Srrs			if (error) {
319170056Srrs				return (error);
320172091Srrs			} else {
321170056Srrs				SCTP_INP_INFO_RLOCK();
322170056Srrs				SCTP_INP_RLOCK(inp);
323170056Srrs			}
324170056Srrs		}
325170056Srrs	}
326172091Srrs	memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
327170056Srrs	xladdr.last = 1;
328170354Srrs	SCTP_INP_RUNLOCK(inp);
329170354Srrs	SCTP_INP_INFO_RUNLOCK();
330170056Srrs	error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
331170354Srrs
332172091Srrs	if (error) {
333170056Srrs		return (error);
334172091Srrs	} else {
335170354Srrs		SCTP_INP_INFO_RLOCK();
336170354Srrs		SCTP_INP_RLOCK(inp);
337170056Srrs		return (0);
338170354Srrs	}
339170056Srrs}
340170056Srrs
341167598Srrs/*
342167598Srrs * sysctl functions
343167598Srrs */
344167598Srrsstatic int
345271204Stuexensctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS)
346167598Srrs{
347167598Srrs	unsigned int number_of_endpoints;
348167598Srrs	unsigned int number_of_local_addresses;
349167598Srrs	unsigned int number_of_associations;
350167598Srrs	unsigned int number_of_remote_addresses;
351167598Srrs	unsigned int n;
352167598Srrs	int error;
353167598Srrs	struct sctp_inpcb *inp;
354167598Srrs	struct sctp_tcb *stcb;
355167598Srrs	struct sctp_nets *net;
356167598Srrs	struct xsctp_inpcb xinpcb;
357167598Srrs	struct xsctp_tcb xstcb;
358167598Srrs	struct xsctp_raddr xraddr;
359208879Srrs	struct socket *so;
360167598Srrs
361167598Srrs	number_of_endpoints = 0;
362167598Srrs	number_of_local_addresses = 0;
363167598Srrs	number_of_associations = 0;
364167598Srrs	number_of_remote_addresses = 0;
365167598Srrs
366167598Srrs	SCTP_INP_INFO_RLOCK();
367271204Stuexen	if (req->oldptr == NULL) {
368179783Srrs		LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
369167598Srrs			SCTP_INP_RLOCK(inp);
370167598Srrs			number_of_endpoints++;
371271204Stuexen			number_of_local_addresses += sctp_sysctl_number_of_addresses(inp);
372167598Srrs			LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
373167598Srrs				number_of_associations++;
374271204Stuexen				number_of_local_addresses += sctp_sysctl_number_of_addresses(inp);
375167598Srrs				TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
376167598Srrs					number_of_remote_addresses++;
377167598Srrs				}
378167598Srrs			}
379167598Srrs			SCTP_INP_RUNLOCK(inp);
380167598Srrs		}
381167598Srrs		SCTP_INP_INFO_RUNLOCK();
382167598Srrs		n = (number_of_endpoints + 1) * sizeof(struct xsctp_inpcb) +
383170056Srrs		    (number_of_local_addresses + number_of_endpoints + number_of_associations) * sizeof(struct xsctp_laddr) +
384170056Srrs		    (number_of_associations + number_of_endpoints) * sizeof(struct xsctp_tcb) +
385170056Srrs		    (number_of_remote_addresses + number_of_associations) * sizeof(struct xsctp_raddr);
386170056Srrs
387167598Srrs		/* request some more memory than needed */
388167598Srrs		req->oldidx = (n + n / 8);
389228907Stuexen		return (0);
390167598Srrs	}
391271204Stuexen	if (req->newptr != NULL) {
392167598Srrs		SCTP_INP_INFO_RUNLOCK();
393171943Srrs		SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_SYSCTL, EPERM);
394228907Stuexen		return (EPERM);
395167598Srrs	}
396340923Smarkj	memset(&xinpcb, 0, sizeof(xinpcb));
397340923Smarkj	memset(&xstcb, 0, sizeof(xstcb));
398340923Smarkj	memset(&xraddr, 0, sizeof(xraddr));
399179783Srrs	LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
400167598Srrs		SCTP_INP_RLOCK(inp);
401208879Srrs		if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
402208879Srrs			/* if its allgone it is being freed - skip it  */
403208879Srrs			goto skip;
404208879Srrs		}
405167598Srrs		xinpcb.last = 0;
406167598Srrs		xinpcb.local_port = ntohs(inp->sctp_lport);
407167598Srrs		xinpcb.flags = inp->sctp_flags;
408254672Stuexen		xinpcb.features = inp->sctp_features;
409167598Srrs		xinpcb.total_sends = inp->total_sends;
410167598Srrs		xinpcb.total_recvs = inp->total_recvs;
411167598Srrs		xinpcb.total_nospaces = inp->total_nospaces;
412169352Srrs		xinpcb.fragmentation_point = inp->sctp_frag_point;
413283988Stuexen		xinpcb.socket = inp->sctp_socket;
414208879Srrs		so = inp->sctp_socket;
415208879Srrs		if ((so == NULL) ||
416172091Srrs		    (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) {
417172091Srrs			xinpcb.qlen = 0;
418172091Srrs			xinpcb.maxqlen = 0;
419172091Srrs		} else {
420208879Srrs			xinpcb.qlen = so->so_qlen;
421295541Stuexen			xinpcb.qlen_old = so->so_qlen > USHRT_MAX ?
422310773Stuexen			    USHRT_MAX : (uint16_t)so->so_qlen;
423208879Srrs			xinpcb.maxqlen = so->so_qlimit;
424295541Stuexen			xinpcb.maxqlen_old = so->so_qlimit > USHRT_MAX ?
425310773Stuexen			    USHRT_MAX : (uint16_t)so->so_qlimit;
426172091Srrs		}
427167598Srrs		SCTP_INP_INCR_REF(inp);
428167598Srrs		SCTP_INP_RUNLOCK(inp);
429167598Srrs		SCTP_INP_INFO_RUNLOCK();
430167598Srrs		error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb));
431167598Srrs		if (error) {
432170056Srrs			SCTP_INP_DECR_REF(inp);
433228907Stuexen			return (error);
434167598Srrs		}
435167598Srrs		SCTP_INP_INFO_RLOCK();
436167598Srrs		SCTP_INP_RLOCK(inp);
437271204Stuexen		error = sctp_sysctl_copy_out_local_addresses(inp, NULL, req);
438170056Srrs		if (error) {
439170056Srrs			SCTP_INP_DECR_REF(inp);
440228907Stuexen			return (error);
441170056Srrs		}
442167598Srrs		LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
443167598Srrs			SCTP_TCB_LOCK(stcb);
444167598Srrs			atomic_add_int(&stcb->asoc.refcnt, 1);
445167598Srrs			SCTP_TCB_UNLOCK(stcb);
446170056Srrs			xstcb.last = 0;
447170056Srrs			xstcb.local_port = ntohs(inp->sctp_lport);
448170056Srrs			xstcb.remote_port = ntohs(stcb->rport);
449167598Srrs			if (stcb->asoc.primary_destination != NULL)
450170056Srrs				xstcb.primary_addr = stcb->asoc.primary_destination->ro._l_addr;
451170056Srrs			xstcb.heartbeat_interval = stcb->asoc.heart_beat_delay;
452310773Stuexen			xstcb.state = (uint32_t)sctp_map_assoc_state(stcb->asoc.state);
453188577Srrs			/* 7.0 does not support these */
454188067Srrs			xstcb.assoc_id = sctp_get_associd(stcb);
455188577Srrs			xstcb.peers_rwnd = stcb->asoc.peers_rwnd;
456170056Srrs			xstcb.in_streams = stcb->asoc.streamincnt;
457170056Srrs			xstcb.out_streams = stcb->asoc.streamoutcnt;
458170056Srrs			xstcb.max_nr_retrans = stcb->asoc.overall_error_count;
459170056Srrs			xstcb.primary_process = 0;	/* not really supported
460170056Srrs							 * yet */
461170056Srrs			xstcb.T1_expireries = stcb->asoc.timoinit + stcb->asoc.timocookie;
462170056Srrs			xstcb.T2_expireries = stcb->asoc.timoshutdown + stcb->asoc.timoshutdownack;
463170056Srrs			xstcb.retransmitted_tsns = stcb->asoc.marked_retrans;
464310773Stuexen			xstcb.start_time.tv_sec = (uint32_t)stcb->asoc.start_time.tv_sec;
465310773Stuexen			xstcb.start_time.tv_usec = (uint32_t)stcb->asoc.start_time.tv_usec;
466310773Stuexen			xstcb.discontinuity_time.tv_sec = (uint32_t)stcb->asoc.discontinuity_time.tv_sec;
467310773Stuexen			xstcb.discontinuity_time.tv_usec = (uint32_t)stcb->asoc.discontinuity_time.tv_usec;
468167598Srrs			xstcb.total_sends = stcb->total_sends;
469167598Srrs			xstcb.total_recvs = stcb->total_recvs;
470167598Srrs			xstcb.local_tag = stcb->asoc.my_vtag;
471167598Srrs			xstcb.remote_tag = stcb->asoc.peer_vtag;
472167598Srrs			xstcb.initial_tsn = stcb->asoc.init_seq_number;
473167598Srrs			xstcb.highest_tsn = stcb->asoc.sending_seq - 1;
474167598Srrs			xstcb.cumulative_tsn = stcb->asoc.last_acked_seq;
475167598Srrs			xstcb.cumulative_tsn_ack = stcb->asoc.cumulative_tsn;
476169352Srrs			xstcb.mtu = stcb->asoc.smallest_mtu;
477170091Srrs			xstcb.refcnt = stcb->asoc.refcnt;
478167598Srrs			SCTP_INP_RUNLOCK(inp);
479167598Srrs			SCTP_INP_INFO_RUNLOCK();
480167598Srrs			error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb));
481167598Srrs			if (error) {
482170056Srrs				SCTP_INP_DECR_REF(inp);
483172091Srrs				atomic_subtract_int(&stcb->asoc.refcnt, 1);
484228907Stuexen				return (error);
485167598Srrs			}
486170056Srrs			SCTP_INP_INFO_RLOCK();
487170056Srrs			SCTP_INP_RLOCK(inp);
488271204Stuexen			error = sctp_sysctl_copy_out_local_addresses(inp, stcb, req);
489170056Srrs			if (error) {
490170056Srrs				SCTP_INP_DECR_REF(inp);
491172091Srrs				atomic_subtract_int(&stcb->asoc.refcnt, 1);
492228907Stuexen				return (error);
493170056Srrs			}
494167598Srrs			TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
495170056Srrs				xraddr.last = 0;
496170056Srrs				xraddr.address = net->ro._l_addr;
497170056Srrs				xraddr.active = ((net->dest_state & SCTP_ADDR_REACHABLE) == SCTP_ADDR_REACHABLE);
498170056Srrs				xraddr.confirmed = ((net->dest_state & SCTP_ADDR_UNCONFIRMED) == 0);
499170056Srrs				xraddr.heartbeat_enabled = ((net->dest_state & SCTP_ADDR_NOHB) == 0);
500224641Stuexen				xraddr.potentially_failed = ((net->dest_state & SCTP_ADDR_PF) == SCTP_ADDR_PF);
501170056Srrs				xraddr.rto = net->RTO;
502170056Srrs				xraddr.max_path_rtx = net->failure_threshold;
503170056Srrs				xraddr.rtx = net->marked_retrans;
504170056Srrs				xraddr.error_counter = net->error_count;
505170056Srrs				xraddr.cwnd = net->cwnd;
506170056Srrs				xraddr.flight_size = net->flight_size;
507170056Srrs				xraddr.mtu = net->mtu;
508219013Stuexen				xraddr.rtt = net->rtt / 1000;
509224641Stuexen				xraddr.heartbeat_interval = net->heart_beat_delay;
510285237Stuexen				xraddr.ssthresh = net->ssthresh;
511332188Stuexen				xraddr.encaps_port = net->port;
512332188Stuexen				if (net->dest_state & SCTP_ADDR_UNCONFIRMED) {
513332188Stuexen					xraddr.state = SCTP_UNCONFIRMED;
514332188Stuexen				} else if (net->dest_state & SCTP_ADDR_REACHABLE) {
515332188Stuexen					xraddr.state = SCTP_ACTIVE;
516332188Stuexen				} else {
517332188Stuexen					xraddr.state = SCTP_INACTIVE;
518332188Stuexen				}
519310773Stuexen				xraddr.start_time.tv_sec = (uint32_t)net->start_time.tv_sec;
520310773Stuexen				xraddr.start_time.tv_usec = (uint32_t)net->start_time.tv_usec;
521170056Srrs				SCTP_INP_RUNLOCK(inp);
522170056Srrs				SCTP_INP_INFO_RUNLOCK();
523167598Srrs				error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr));
524167598Srrs				if (error) {
525170056Srrs					SCTP_INP_DECR_REF(inp);
526172091Srrs					atomic_subtract_int(&stcb->asoc.refcnt, 1);
527228907Stuexen					return (error);
528167598Srrs				}
529170056Srrs				SCTP_INP_INFO_RLOCK();
530170056Srrs				SCTP_INP_RLOCK(inp);
531167598Srrs			}
532172091Srrs			atomic_subtract_int(&stcb->asoc.refcnt, 1);
533170056Srrs			memset((void *)&xraddr, 0, sizeof(struct xsctp_raddr));
534170056Srrs			xraddr.last = 1;
535170056Srrs			SCTP_INP_RUNLOCK(inp);
536170056Srrs			SCTP_INP_INFO_RUNLOCK();
537170056Srrs			error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr));
538170056Srrs			if (error) {
539170056Srrs				SCTP_INP_DECR_REF(inp);
540228907Stuexen				return (error);
541170056Srrs			}
542167598Srrs			SCTP_INP_INFO_RLOCK();
543167598Srrs			SCTP_INP_RLOCK(inp);
544167598Srrs		}
545172091Srrs		SCTP_INP_DECR_REF(inp);
546170056Srrs		SCTP_INP_RUNLOCK(inp);
547170056Srrs		SCTP_INP_INFO_RUNLOCK();
548170056Srrs		memset((void *)&xstcb, 0, sizeof(struct xsctp_tcb));
549170056Srrs		xstcb.last = 1;
550170056Srrs		error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb));
551170056Srrs		if (error) {
552228907Stuexen			return (error);
553170056Srrs		}
554208879Srrsskip:
555170056Srrs		SCTP_INP_INFO_RLOCK();
556167598Srrs	}
557167598Srrs	SCTP_INP_INFO_RUNLOCK();
558167598Srrs
559170056Srrs	memset((void *)&xinpcb, 0, sizeof(struct xsctp_inpcb));
560167598Srrs	xinpcb.last = 1;
561167598Srrs	error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb));
562228907Stuexen	return (error);
563167598Srrs}
564167598Srrs
565172091Srrsstatic int
566271204Stuexensctp_sysctl_handle_udp_tunneling(SYSCTL_HANDLER_ARGS)
567179157Srrs{
568179157Srrs	int error;
569271204Stuexen	uint32_t old, new;
570179157Srrs
571188100Srrs	SCTP_INP_INFO_RLOCK();
572271204Stuexen	old = SCTP_BASE_SYSCTL(sctp_udp_tunneling_port);
573188100Srrs	SCTP_INP_INFO_RUNLOCK();
574271204Stuexen	new = old;
575271204Stuexen	error = sysctl_handle_int(oidp, &new, 0, req);
576271204Stuexen	if ((error == 0) &&
577271204Stuexen	    (req->newptr != NULL)) {
578277424Stuexen#if (SCTPCTL_UDP_TUNNELING_PORT_MIN == 0)
579277424Stuexen		if (new > SCTPCTL_UDP_TUNNELING_PORT_MAX) {
580277424Stuexen#else
581271204Stuexen		if ((new < SCTPCTL_UDP_TUNNELING_PORT_MIN) ||
582271204Stuexen		    (new > SCTPCTL_UDP_TUNNELING_PORT_MAX)) {
583277424Stuexen#endif
584271204Stuexen			error = EINVAL;
585271204Stuexen		} else {
586271204Stuexen			SCTP_INP_INFO_WLOCK();
587271204Stuexen			SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = new;
588271204Stuexen			if (old != 0) {
589271204Stuexen				sctp_over_udp_stop();
590179157Srrs			}
591271204Stuexen			if (new != 0) {
592271204Stuexen				error = sctp_over_udp_start();
593271204Stuexen			}
594271204Stuexen			SCTP_INP_INFO_WUNLOCK();
595179157Srrs		}
596179157Srrs	}
597179157Srrs	return (error);
598179157Srrs}
599179157Srrs
600179783Srrs
601179157Srrsstatic int
602271204Stuexensctp_sysctl_handle_auth(SYSCTL_HANDLER_ARGS)
603172091Srrs{
604172091Srrs	int error;
605271204Stuexen	uint32_t new;
606172091Srrs
607271204Stuexen	new = SCTP_BASE_SYSCTL(sctp_auth_enable);
608271204Stuexen	error = sysctl_handle_int(oidp, &new, 0, req);
609271204Stuexen	if ((error == 0) &&
610271204Stuexen	    (req->newptr != NULL)) {
611277424Stuexen#if (SCTPCTL_AUTH_ENABLE_MIN == 0)
612277424Stuexen		if ((new > SCTPCTL_AUTH_ENABLE_MAX) ||
613277424Stuexen		    ((new == 0) && (SCTP_BASE_SYSCTL(sctp_asconf_enable) == 1))) {
614277424Stuexen#else
615271204Stuexen		if ((new < SCTPCTL_AUTH_ENABLE_MIN) ||
616271204Stuexen		    (new > SCTPCTL_AUTH_ENABLE_MAX) ||
617271204Stuexen		    ((new == 0) && (SCTP_BASE_SYSCTL(sctp_asconf_enable) == 1))) {
618277424Stuexen#endif
619271204Stuexen			error = EINVAL;
620271204Stuexen		} else {
621271204Stuexen			SCTP_BASE_SYSCTL(sctp_auth_enable) = new;
622271204Stuexen		}
623172091Srrs	}
624172091Srrs	return (error);
625172091Srrs}
626172091Srrs
627269858Stuexenstatic int
628271204Stuexensctp_sysctl_handle_asconf(SYSCTL_HANDLER_ARGS)
629269858Stuexen{
630269858Stuexen	int error;
631271204Stuexen	uint32_t new;
632269858Stuexen
633271204Stuexen	new = SCTP_BASE_SYSCTL(sctp_asconf_enable);
634271204Stuexen	error = sysctl_handle_int(oidp, &new, 0, req);
635271204Stuexen	if ((error == 0) &&
636271204Stuexen	    (req->newptr != NULL)) {
637277424Stuexen#if (SCTPCTL_ASCONF_ENABLE_MIN == 0)
638277424Stuexen		if ((new > SCTPCTL_ASCONF_ENABLE_MAX) ||
639277424Stuexen		    ((new == 1) && (SCTP_BASE_SYSCTL(sctp_auth_enable) == 0))) {
640277424Stuexen#else
641271204Stuexen		if ((new < SCTPCTL_ASCONF_ENABLE_MIN) ||
642271204Stuexen		    (new > SCTPCTL_ASCONF_ENABLE_MAX) ||
643271204Stuexen		    ((new == 1) && (SCTP_BASE_SYSCTL(sctp_auth_enable) == 0))) {
644277424Stuexen#endif
645271204Stuexen			error = EINVAL;
646271204Stuexen		} else {
647271204Stuexen			SCTP_BASE_SYSCTL(sctp_asconf_enable) = new;
648269858Stuexen		}
649269858Stuexen	}
650269858Stuexen	return (error);
651269858Stuexen}
652269858Stuexen
653269858Stuexenstatic int
654271204Stuexensctp_sysctl_handle_stats(SYSCTL_HANDLER_ARGS)
655269858Stuexen{
656269858Stuexen	int error;
657271204Stuexen#if defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
658273773Shselasky	struct sctpstat *sarry;
659273773Shselasky	struct sctpstat sb;
660271204Stuexen	int cpu;
661271204Stuexen#endif
662273925Stuexen	struct sctpstat sb_temp;
663179783Srrs
664271204Stuexen	if ((req->newptr != NULL) &&
665271204Stuexen	    (req->newlen != sizeof(struct sctpstat))) {
666218219Srrs		return (EINVAL);
667218219Srrs	}
668273925Stuexen	memset(&sb_temp, 0, sizeof(struct sctpstat));
669273773Shselasky
670273773Shselasky	if (req->newptr != NULL) {
671273925Stuexen		error = SYSCTL_IN(req, &sb_temp, sizeof(struct sctpstat));
672273925Stuexen		if (error != 0) {
673273773Shselasky			return (error);
674273925Stuexen		}
675273773Shselasky	}
676273925Stuexen#if defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
677273925Stuexen	memset(&sb, 0, sizeof(sb));
678218232Srrs	for (cpu = 0; cpu < mp_maxid; cpu++) {
679205629Srrs		sarry = &SCTP_BASE_STATS[cpu];
680205629Srrs		if (sarry->sctps_discontinuitytime.tv_sec > sb.sctps_discontinuitytime.tv_sec) {
681205629Srrs			sb.sctps_discontinuitytime.tv_sec = sarry->sctps_discontinuitytime.tv_sec;
682205629Srrs			sb.sctps_discontinuitytime.tv_usec = sarry->sctps_discontinuitytime.tv_usec;
683205629Srrs		}
684205629Srrs		sb.sctps_currestab += sarry->sctps_currestab;
685205629Srrs		sb.sctps_activeestab += sarry->sctps_activeestab;
686205629Srrs		sb.sctps_restartestab += sarry->sctps_restartestab;
687205629Srrs		sb.sctps_collisionestab += sarry->sctps_collisionestab;
688205629Srrs		sb.sctps_passiveestab += sarry->sctps_passiveestab;
689205629Srrs		sb.sctps_aborted += sarry->sctps_aborted;
690205629Srrs		sb.sctps_shutdown += sarry->sctps_shutdown;
691205629Srrs		sb.sctps_outoftheblue += sarry->sctps_outoftheblue;
692205629Srrs		sb.sctps_checksumerrors += sarry->sctps_checksumerrors;
693205629Srrs		sb.sctps_outcontrolchunks += sarry->sctps_outcontrolchunks;
694205629Srrs		sb.sctps_outorderchunks += sarry->sctps_outorderchunks;
695205629Srrs		sb.sctps_outunorderchunks += sarry->sctps_outunorderchunks;
696205629Srrs		sb.sctps_incontrolchunks += sarry->sctps_incontrolchunks;
697205629Srrs		sb.sctps_inorderchunks += sarry->sctps_inorderchunks;
698205629Srrs		sb.sctps_inunorderchunks += sarry->sctps_inunorderchunks;
699205629Srrs		sb.sctps_fragusrmsgs += sarry->sctps_fragusrmsgs;
700205629Srrs		sb.sctps_reasmusrmsgs += sarry->sctps_reasmusrmsgs;
701205629Srrs		sb.sctps_outpackets += sarry->sctps_outpackets;
702205629Srrs		sb.sctps_inpackets += sarry->sctps_inpackets;
703205629Srrs		sb.sctps_recvpackets += sarry->sctps_recvpackets;
704205629Srrs		sb.sctps_recvdatagrams += sarry->sctps_recvdatagrams;
705205629Srrs		sb.sctps_recvpktwithdata += sarry->sctps_recvpktwithdata;
706205629Srrs		sb.sctps_recvsacks += sarry->sctps_recvsacks;
707205629Srrs		sb.sctps_recvdata += sarry->sctps_recvdata;
708205629Srrs		sb.sctps_recvdupdata += sarry->sctps_recvdupdata;
709205629Srrs		sb.sctps_recvheartbeat += sarry->sctps_recvheartbeat;
710205629Srrs		sb.sctps_recvheartbeatack += sarry->sctps_recvheartbeatack;
711205629Srrs		sb.sctps_recvecne += sarry->sctps_recvecne;
712205629Srrs		sb.sctps_recvauth += sarry->sctps_recvauth;
713205629Srrs		sb.sctps_recvauthmissing += sarry->sctps_recvauthmissing;
714205629Srrs		sb.sctps_recvivalhmacid += sarry->sctps_recvivalhmacid;
715205629Srrs		sb.sctps_recvivalkeyid += sarry->sctps_recvivalkeyid;
716205629Srrs		sb.sctps_recvauthfailed += sarry->sctps_recvauthfailed;
717205629Srrs		sb.sctps_recvexpress += sarry->sctps_recvexpress;
718205629Srrs		sb.sctps_recvexpressm += sarry->sctps_recvexpressm;
719205629Srrs		sb.sctps_recvswcrc += sarry->sctps_recvswcrc;
720205629Srrs		sb.sctps_recvhwcrc += sarry->sctps_recvhwcrc;
721205629Srrs		sb.sctps_sendpackets += sarry->sctps_sendpackets;
722205629Srrs		sb.sctps_sendsacks += sarry->sctps_sendsacks;
723205629Srrs		sb.sctps_senddata += sarry->sctps_senddata;
724205629Srrs		sb.sctps_sendretransdata += sarry->sctps_sendretransdata;
725205629Srrs		sb.sctps_sendfastretrans += sarry->sctps_sendfastretrans;
726205629Srrs		sb.sctps_sendmultfastretrans += sarry->sctps_sendmultfastretrans;
727205629Srrs		sb.sctps_sendheartbeat += sarry->sctps_sendheartbeat;
728205629Srrs		sb.sctps_sendecne += sarry->sctps_sendecne;
729205629Srrs		sb.sctps_sendauth += sarry->sctps_sendauth;
730205629Srrs		sb.sctps_senderrors += sarry->sctps_senderrors;
731205629Srrs		sb.sctps_sendswcrc += sarry->sctps_sendswcrc;
732205629Srrs		sb.sctps_sendhwcrc += sarry->sctps_sendhwcrc;
733205629Srrs		sb.sctps_pdrpfmbox += sarry->sctps_pdrpfmbox;
734205629Srrs		sb.sctps_pdrpfehos += sarry->sctps_pdrpfehos;
735205629Srrs		sb.sctps_pdrpmbda += sarry->sctps_pdrpmbda;
736205629Srrs		sb.sctps_pdrpmbct += sarry->sctps_pdrpmbct;
737205629Srrs		sb.sctps_pdrpbwrpt += sarry->sctps_pdrpbwrpt;
738205629Srrs		sb.sctps_pdrpcrupt += sarry->sctps_pdrpcrupt;
739205629Srrs		sb.sctps_pdrpnedat += sarry->sctps_pdrpnedat;
740205629Srrs		sb.sctps_pdrppdbrk += sarry->sctps_pdrppdbrk;
741205629Srrs		sb.sctps_pdrptsnnf += sarry->sctps_pdrptsnnf;
742205629Srrs		sb.sctps_pdrpdnfnd += sarry->sctps_pdrpdnfnd;
743205629Srrs		sb.sctps_pdrpdiwnp += sarry->sctps_pdrpdiwnp;
744205629Srrs		sb.sctps_pdrpdizrw += sarry->sctps_pdrpdizrw;
745205629Srrs		sb.sctps_pdrpbadd += sarry->sctps_pdrpbadd;
746205629Srrs		sb.sctps_pdrpmark += sarry->sctps_pdrpmark;
747205629Srrs		sb.sctps_timoiterator += sarry->sctps_timoiterator;
748205629Srrs		sb.sctps_timodata += sarry->sctps_timodata;
749205629Srrs		sb.sctps_timowindowprobe += sarry->sctps_timowindowprobe;
750205629Srrs		sb.sctps_timoinit += sarry->sctps_timoinit;
751205629Srrs		sb.sctps_timosack += sarry->sctps_timosack;
752205629Srrs		sb.sctps_timoshutdown += sarry->sctps_timoshutdown;
753205629Srrs		sb.sctps_timoheartbeat += sarry->sctps_timoheartbeat;
754205629Srrs		sb.sctps_timocookie += sarry->sctps_timocookie;
755205629Srrs		sb.sctps_timosecret += sarry->sctps_timosecret;
756205629Srrs		sb.sctps_timopathmtu += sarry->sctps_timopathmtu;
757205629Srrs		sb.sctps_timoshutdownack += sarry->sctps_timoshutdownack;
758205629Srrs		sb.sctps_timoshutdownguard += sarry->sctps_timoshutdownguard;
759205629Srrs		sb.sctps_timostrmrst += sarry->sctps_timostrmrst;
760205629Srrs		sb.sctps_timoearlyfr += sarry->sctps_timoearlyfr;
761205629Srrs		sb.sctps_timoasconf += sarry->sctps_timoasconf;
762205629Srrs		sb.sctps_timodelprim += sarry->sctps_timodelprim;
763205629Srrs		sb.sctps_timoautoclose += sarry->sctps_timoautoclose;
764205629Srrs		sb.sctps_timoassockill += sarry->sctps_timoassockill;
765205629Srrs		sb.sctps_timoinpkill += sarry->sctps_timoinpkill;
766205629Srrs		sb.sctps_hdrops += sarry->sctps_hdrops;
767205629Srrs		sb.sctps_badsum += sarry->sctps_badsum;
768205629Srrs		sb.sctps_noport += sarry->sctps_noport;
769205629Srrs		sb.sctps_badvtag += sarry->sctps_badvtag;
770205629Srrs		sb.sctps_badsid += sarry->sctps_badsid;
771205629Srrs		sb.sctps_nomem += sarry->sctps_nomem;
772205629Srrs		sb.sctps_fastretransinrtt += sarry->sctps_fastretransinrtt;
773205629Srrs		sb.sctps_markedretrans += sarry->sctps_markedretrans;
774205629Srrs		sb.sctps_naglesent += sarry->sctps_naglesent;
775205629Srrs		sb.sctps_naglequeued += sarry->sctps_naglequeued;
776205629Srrs		sb.sctps_maxburstqueued += sarry->sctps_maxburstqueued;
777205629Srrs		sb.sctps_ifnomemqueued += sarry->sctps_ifnomemqueued;
778205629Srrs		sb.sctps_windowprobed += sarry->sctps_windowprobed;
779205629Srrs		sb.sctps_lowlevelerr += sarry->sctps_lowlevelerr;
780205629Srrs		sb.sctps_lowlevelerrusr += sarry->sctps_lowlevelerrusr;
781205629Srrs		sb.sctps_datadropchklmt += sarry->sctps_datadropchklmt;
782205629Srrs		sb.sctps_datadroprwnd += sarry->sctps_datadroprwnd;
783205629Srrs		sb.sctps_ecnereducedcwnd += sarry->sctps_ecnereducedcwnd;
784205629Srrs		sb.sctps_vtagexpress += sarry->sctps_vtagexpress;
785205629Srrs		sb.sctps_vtagbogus += sarry->sctps_vtagbogus;
786205629Srrs		sb.sctps_primary_randry += sarry->sctps_primary_randry;
787205629Srrs		sb.sctps_cmt_randry += sarry->sctps_cmt_randry;
788205629Srrs		sb.sctps_slowpath_sack += sarry->sctps_slowpath_sack;
789205629Srrs		sb.sctps_wu_sacks_sent += sarry->sctps_wu_sacks_sent;
790205629Srrs		sb.sctps_sends_with_flags += sarry->sctps_sends_with_flags;
791205629Srrs		sb.sctps_sends_with_unord += sarry->sctps_sends_with_unord;
792205629Srrs		sb.sctps_sends_with_eof += sarry->sctps_sends_with_eof;
793205629Srrs		sb.sctps_sends_with_abort += sarry->sctps_sends_with_abort;
794205629Srrs		sb.sctps_protocol_drain_calls += sarry->sctps_protocol_drain_calls;
795205629Srrs		sb.sctps_protocol_drains_done += sarry->sctps_protocol_drains_done;
796205629Srrs		sb.sctps_read_peeks += sarry->sctps_read_peeks;
797205629Srrs		sb.sctps_cached_chk += sarry->sctps_cached_chk;
798205629Srrs		sb.sctps_cached_strmoq += sarry->sctps_cached_strmoq;
799205629Srrs		sb.sctps_left_abandon += sarry->sctps_left_abandon;
800205629Srrs		sb.sctps_send_burst_avoid += sarry->sctps_send_burst_avoid;
801205629Srrs		sb.sctps_send_cwnd_avoid += sarry->sctps_send_cwnd_avoid;
802205629Srrs		sb.sctps_fwdtsn_map_over += sarry->sctps_fwdtsn_map_over;
803273925Stuexen		if (req->newptr != NULL) {
804273773Shselasky			memcpy(sarry, &sb_temp, sizeof(struct sctpstat));
805273925Stuexen		}
806205629Srrs	}
807271204Stuexen	error = SYSCTL_OUT(req, &sb, sizeof(struct sctpstat));
808271204Stuexen#else
809273925Stuexen	error = SYSCTL_OUT(req, &SCTP_BASE_STATS, sizeof(struct sctpstat));
810273925Stuexen	if (error != 0) {
811273773Shselasky		return (error);
812273925Stuexen	}
813273925Stuexen	if (req->newptr != NULL) {
814273925Stuexen		memcpy(&SCTP_BASE_STATS, &sb_temp, sizeof(struct sctpstat));
815273925Stuexen	}
816271204Stuexen#endif
817205629Srrs	return (error);
818205629Srrs}
819179783Srrs
820179783Srrs#if defined(SCTP_LOCAL_TRACE_BUF)
821179783Srrsstatic int
822271204Stuexensctp_sysctl_handle_trace_log(SYSCTL_HANDLER_ARGS)
823179783Srrs{
824271204Stuexen	int error;
825271204Stuexen
826271204Stuexen	error = SYSCTL_OUT(req, &SCTP_BASE_SYSCTL(sctp_log), sizeof(struct sctp_log));
827271204Stuexen	return (error);
828271204Stuexen}
829271204Stuexen
830271204Stuexenstatic int
831271204Stuexensctp_sysctl_handle_trace_log_clear(SYSCTL_HANDLER_ARGS)
832271204Stuexen{
833188067Srrs	int error = 0;
834188067Srrs
835179783Srrs	memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log));
836188067Srrs	return (error);
837179783Srrs}
838179783Srrs#endif
839179783Srrs
840271204Stuexen#define SCTP_UINT_SYSCTL(mib_name, var_name, prefix)			\
841271204Stuexen	static int							\
842271204Stuexen	sctp_sysctl_handle_##mib_name(SYSCTL_HANDLER_ARGS)		\
843271204Stuexen	{								\
844271204Stuexen		int error;						\
845271204Stuexen		uint32_t new;						\
846271204Stuexen									\
847271204Stuexen		new = SCTP_BASE_SYSCTL(var_name);			\
848271204Stuexen		error = sysctl_handle_int(oidp, &new, 0, req);		\
849271204Stuexen		if ((error == 0) && (req->newptr != NULL)) {		\
850271204Stuexen			if ((new < prefix##_MIN) ||			\
851271204Stuexen			    (new > prefix##_MAX)) {			\
852271204Stuexen				error = EINVAL;				\
853271204Stuexen			} else {					\
854271204Stuexen				SCTP_BASE_SYSCTL(var_name) = new;	\
855271204Stuexen			}						\
856271204Stuexen		}							\
857271204Stuexen		return (error);						\
858271204Stuexen	}								\
859271219Stuexen	SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mib_name,			\
860271219Stuexen	                 CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW, NULL, 0,	\
861271204Stuexen	                 sctp_sysctl_handle_##mib_name, "UI", prefix##_DESC);
862179783Srrs
863167598Srrs/*
864167598Srrs * sysctl definitions
865167598Srrs */
866167598Srrs
867271204StuexenSCTP_UINT_SYSCTL(sendspace, sctp_sendspace, SCTPCTL_MAXDGRAM)
868271204StuexenSCTP_UINT_SYSCTL(recvspace, sctp_recvspace, SCTPCTL_RECVSPACE)
869271204StuexenSCTP_UINT_SYSCTL(auto_asconf, sctp_auto_asconf, SCTPCTL_AUTOASCONF)
870271204StuexenSCTP_UINT_SYSCTL(ecn_enable, sctp_ecn_enable, SCTPCTL_ECN_ENABLE)
871271204StuexenSCTP_UINT_SYSCTL(pr_enable, sctp_pr_enable, SCTPCTL_PR_ENABLE)
872271219StuexenSYSCTL_PROC(_net_inet_sctp, OID_AUTO, auth_enable, CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW,
873271204Stuexen    NULL, 0, sctp_sysctl_handle_auth, "IU", SCTPCTL_AUTH_ENABLE_DESC);
874271219StuexenSYSCTL_PROC(_net_inet_sctp, OID_AUTO, asconf_enable, CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW,
875271204Stuexen    NULL, 0, sctp_sysctl_handle_asconf, "IU", SCTPCTL_ASCONF_ENABLE_DESC);
876271204StuexenSCTP_UINT_SYSCTL(reconfig_enable, sctp_reconfig_enable, SCTPCTL_RECONFIG_ENABLE)
877271204StuexenSCTP_UINT_SYSCTL(nrsack_enable, sctp_nrsack_enable, SCTPCTL_NRSACK_ENABLE)
878271204StuexenSCTP_UINT_SYSCTL(pktdrop_enable, sctp_pktdrop_enable, SCTPCTL_PKTDROP_ENABLE)
879271204StuexenSCTP_UINT_SYSCTL(peer_chkoh, sctp_peer_chunk_oh, SCTPCTL_PEER_CHKOH)
880271204StuexenSCTP_UINT_SYSCTL(maxburst, sctp_max_burst_default, SCTPCTL_MAXBURST)
881271204StuexenSCTP_UINT_SYSCTL(fr_maxburst, sctp_fr_max_burst_default, SCTPCTL_FRMAXBURST)
882271204StuexenSCTP_UINT_SYSCTL(maxchunks, sctp_max_chunks_on_queue, SCTPCTL_MAXCHUNKS)
883271204StuexenSCTP_UINT_SYSCTL(tcbhashsize, sctp_hashtblsize, SCTPCTL_TCBHASHSIZE)
884271204StuexenSCTP_UINT_SYSCTL(pcbhashsize, sctp_pcbtblsize, SCTPCTL_PCBHASHSIZE)
885271204StuexenSCTP_UINT_SYSCTL(min_split_point, sctp_min_split_point, SCTPCTL_MIN_SPLIT_POINT)
886271204StuexenSCTP_UINT_SYSCTL(chunkscale, sctp_chunkscale, SCTPCTL_CHUNKSCALE)
887271204StuexenSCTP_UINT_SYSCTL(delayed_sack_time, sctp_delayed_sack_time_default, SCTPCTL_DELAYED_SACK_TIME)
888271204StuexenSCTP_UINT_SYSCTL(sack_freq, sctp_sack_freq_default, SCTPCTL_SACK_FREQ)
889271204StuexenSCTP_UINT_SYSCTL(sys_resource, sctp_system_free_resc_limit, SCTPCTL_SYS_RESOURCE)
890271204StuexenSCTP_UINT_SYSCTL(asoc_resource, sctp_asoc_free_resc_limit, SCTPCTL_ASOC_RESOURCE)
891271204StuexenSCTP_UINT_SYSCTL(heartbeat_interval, sctp_heartbeat_interval_default, SCTPCTL_HEARTBEAT_INTERVAL)
892271204StuexenSCTP_UINT_SYSCTL(pmtu_raise_time, sctp_pmtu_raise_time_default, SCTPCTL_PMTU_RAISE_TIME)
893271204StuexenSCTP_UINT_SYSCTL(shutdown_guard_time, sctp_shutdown_guard_time_default, SCTPCTL_SHUTDOWN_GUARD_TIME)
894271204StuexenSCTP_UINT_SYSCTL(secret_lifetime, sctp_secret_lifetime_default, SCTPCTL_SECRET_LIFETIME)
895271204StuexenSCTP_UINT_SYSCTL(rto_max, sctp_rto_max_default, SCTPCTL_RTO_MAX)
896271204StuexenSCTP_UINT_SYSCTL(rto_min, sctp_rto_min_default, SCTPCTL_RTO_MIN)
897271204StuexenSCTP_UINT_SYSCTL(rto_initial, sctp_rto_initial_default, SCTPCTL_RTO_INITIAL)
898271204StuexenSCTP_UINT_SYSCTL(init_rto_max, sctp_init_rto_max_default, SCTPCTL_INIT_RTO_MAX)
899271204StuexenSCTP_UINT_SYSCTL(valid_cookie_life, sctp_valid_cookie_life_default, SCTPCTL_VALID_COOKIE_LIFE)
900271204StuexenSCTP_UINT_SYSCTL(init_rtx_max, sctp_init_rtx_max_default, SCTPCTL_INIT_RTX_MAX)
901271204StuexenSCTP_UINT_SYSCTL(assoc_rtx_max, sctp_assoc_rtx_max_default, SCTPCTL_ASSOC_RTX_MAX)
902271204StuexenSCTP_UINT_SYSCTL(path_rtx_max, sctp_path_rtx_max_default, SCTPCTL_PATH_RTX_MAX)
903271204StuexenSCTP_UINT_SYSCTL(path_pf_threshold, sctp_path_pf_threshold, SCTPCTL_PATH_PF_THRESHOLD)
904271204StuexenSCTP_UINT_SYSCTL(add_more_on_output, sctp_add_more_threshold, SCTPCTL_ADD_MORE_ON_OUTPUT)
905271204StuexenSCTP_UINT_SYSCTL(incoming_streams, sctp_nr_incoming_streams_default, SCTPCTL_INCOMING_STREAMS)
906271204StuexenSCTP_UINT_SYSCTL(outgoing_streams, sctp_nr_outgoing_streams_default, SCTPCTL_OUTGOING_STREAMS)
907271204StuexenSCTP_UINT_SYSCTL(cmt_on_off, sctp_cmt_on_off, SCTPCTL_CMT_ON_OFF)
908271204StuexenSCTP_UINT_SYSCTL(cmt_use_dac, sctp_cmt_use_dac, SCTPCTL_CMT_USE_DAC)
909271204StuexenSCTP_UINT_SYSCTL(cwnd_maxburst, sctp_use_cwnd_based_maxburst, SCTPCTL_CWND_MAXBURST)
910271204StuexenSCTP_UINT_SYSCTL(nat_friendly, sctp_nat_friendly, SCTPCTL_NAT_FRIENDLY)
911271204StuexenSCTP_UINT_SYSCTL(abc_l_var, sctp_L2_abc_variable, SCTPCTL_ABC_L_VAR)
912271204StuexenSCTP_UINT_SYSCTL(max_chained_mbufs, sctp_mbuf_threshold_count, SCTPCTL_MAX_CHAINED_MBUFS)
913271204StuexenSCTP_UINT_SYSCTL(do_sctp_drain, sctp_do_drain, SCTPCTL_DO_SCTP_DRAIN)
914271204StuexenSCTP_UINT_SYSCTL(hb_max_burst, sctp_hb_maxburst, SCTPCTL_HB_MAX_BURST)
915271204StuexenSCTP_UINT_SYSCTL(abort_at_limit, sctp_abort_if_one_2_one_hits_limit, SCTPCTL_ABORT_AT_LIMIT)
916271204StuexenSCTP_UINT_SYSCTL(min_residual, sctp_min_residual, SCTPCTL_MIN_RESIDUAL)
917271204StuexenSCTP_UINT_SYSCTL(max_retran_chunk, sctp_max_retran_chunk, SCTPCTL_MAX_RETRAN_CHUNK)
918271204StuexenSCTP_UINT_SYSCTL(log_level, sctp_logging_level, SCTPCTL_LOGGING_LEVEL)
919271204StuexenSCTP_UINT_SYSCTL(default_cc_module, sctp_default_cc_module, SCTPCTL_DEFAULT_CC_MODULE)
920271204StuexenSCTP_UINT_SYSCTL(default_ss_module, sctp_default_ss_module, SCTPCTL_DEFAULT_SS_MODULE)
921271204StuexenSCTP_UINT_SYSCTL(default_frag_interleave, sctp_default_frag_interleave, SCTPCTL_DEFAULT_FRAG_INTERLEAVE)
922271204StuexenSCTP_UINT_SYSCTL(mobility_base, sctp_mobility_base, SCTPCTL_MOBILITY_BASE)
923271204StuexenSCTP_UINT_SYSCTL(mobility_fasthandoff, sctp_mobility_fasthandoff, SCTPCTL_MOBILITY_FASTHANDOFF)
924172157Srrs#if defined(SCTP_LOCAL_TRACE_BUF)
925271219StuexenSYSCTL_PROC(_net_inet_sctp, OID_AUTO, log, CTLFLAG_VNET | CTLTYPE_STRUCT | CTLFLAG_RD,
926271204Stuexen    NULL, 0, sctp_sysctl_handle_trace_log, "S,sctplog", "SCTP logging (struct sctp_log)");
927271219StuexenSYSCTL_PROC(_net_inet_sctp, OID_AUTO, clear_trace, CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW,
928271204Stuexen    NULL, 0, sctp_sysctl_handle_trace_log_clear, "IU", "Clear SCTP Logging buffer");
929172157Srrs#endif
930271219StuexenSYSCTL_PROC(_net_inet_sctp, OID_AUTO, udp_tunneling_port, CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW,
931271204Stuexen    NULL, 0, sctp_sysctl_handle_udp_tunneling, "IU", SCTPCTL_UDP_TUNNELING_PORT_DESC);
932271204StuexenSCTP_UINT_SYSCTL(enable_sack_immediately, sctp_enable_sack_immediately, SCTPCTL_SACK_IMMEDIATELY_ENABLE)
933271204StuexenSCTP_UINT_SYSCTL(nat_friendly_init, sctp_inits_include_nat_friendly, SCTPCTL_NAT_FRIENDLY_INITS)
934271204StuexenSCTP_UINT_SYSCTL(vtag_time_wait, sctp_vtag_time_wait, SCTPCTL_TIME_WAIT)
935271204StuexenSCTP_UINT_SYSCTL(buffer_splitting, sctp_buffer_splitting, SCTPCTL_BUFFER_SPLITTING)
936271204StuexenSCTP_UINT_SYSCTL(initial_cwnd, sctp_initial_cwnd, SCTPCTL_INITIAL_CWND)
937271204StuexenSCTP_UINT_SYSCTL(rttvar_bw, sctp_rttvar_bw, SCTPCTL_RTTVAR_BW)
938271204StuexenSCTP_UINT_SYSCTL(rttvar_rtt, sctp_rttvar_rtt, SCTPCTL_RTTVAR_RTT)
939271204StuexenSCTP_UINT_SYSCTL(rttvar_eqret, sctp_rttvar_eqret, SCTPCTL_RTTVAR_EQRET)
940271204StuexenSCTP_UINT_SYSCTL(rttvar_steady_step, sctp_steady_step, SCTPCTL_RTTVAR_STEADYS)
941271204StuexenSCTP_UINT_SYSCTL(use_dcccecn, sctp_use_dccc_ecn, SCTPCTL_RTTVAR_DCCCECN)
942271204StuexenSCTP_UINT_SYSCTL(blackhole, sctp_blackhole, SCTPCTL_BLACKHOLE)
943271204StuexenSCTP_UINT_SYSCTL(diag_info_code, sctp_diag_info_code, SCTPCTL_DIAG_INFO_CODE)
944167598Srrs#ifdef SCTP_DEBUG
945271204StuexenSCTP_UINT_SYSCTL(debug, sctp_debug_on, SCTPCTL_DEBUG)
946218818Stuexen#endif
947237565Stuexen#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
948271204StuexenSCTP_UINT_SYSCTL(output_unlocked, sctp_output_unlocked, SCTPCTL_OUTPUT_UNLOCKED)
949179783Srrs#endif
950271219StuexenSYSCTL_PROC(_net_inet_sctp, OID_AUTO, stats, CTLFLAG_VNET | CTLTYPE_STRUCT | CTLFLAG_RW,
951271204Stuexen    NULL, 0, sctp_sysctl_handle_stats, "S,sctpstat", "SCTP statistics (struct sctp_stat)");
952271219StuexenSYSCTL_PROC(_net_inet_sctp, OID_AUTO, assoclist, CTLFLAG_VNET | CTLTYPE_OPAQUE | CTLFLAG_RD,
953271204Stuexen    NULL, 0, sctp_sysctl_handle_assoclist, "S,xassoc", "List of active SCTP associations");
954