2007-03-15 11:27:14 +00:00
|
|
|
/*-
|
2017-11-20 19:43:44 +00:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*
|
2007-05-08 17:01:12 +00:00
|
|
|
* Copyright (c) 2007, by Cisco Systems, Inc. All rights reserved.
|
2012-05-23 11:26:28 +00:00
|
|
|
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
|
|
|
|
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
|
2007-03-15 11:27:14 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* a) Redistributions of source code must retain the above copyright notice,
|
2011-12-17 19:21:40 +00:00
|
|
|
* this list of conditions and the following disclaimer.
|
2007-03-15 11:27:14 +00:00
|
|
|
*
|
|
|
|
* b) Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
2011-12-17 19:21:40 +00:00
|
|
|
* the documentation and/or other materials provided with the distribution.
|
2007-03-15 11:27:14 +00:00
|
|
|
*
|
|
|
|
* c) Neither the name of Cisco Systems, Inc. nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
|
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
#include <netinet/sctp_os.h>
|
2008-06-14 07:58:05 +00:00
|
|
|
#include <netinet/sctp.h>
|
2007-03-15 11:27:14 +00:00
|
|
|
#include <netinet/sctp_constants.h>
|
|
|
|
#include <netinet/sctp_sysctl.h>
|
|
|
|
#include <netinet/sctp_pcb.h>
|
|
|
|
#include <netinet/sctputil.h>
|
2007-05-28 11:17:24 +00:00
|
|
|
#include <netinet/sctp_output.h>
|
2010-03-24 20:02:40 +00:00
|
|
|
#include <sys/smp.h>
|
2014-08-26 21:15:34 +00:00
|
|
|
#include <sys/sysctl.h>
|
|
|
|
|
|
|
|
FEATURE(sctp, "Stream Control Transmission Protocol");
|
2008-06-14 07:58:05 +00:00
|
|
|
|
2007-03-15 11:27:14 +00:00
|
|
|
/*
|
|
|
|
* sysctl tunable variables
|
|
|
|
*/
|
|
|
|
|
2008-06-14 07:58:05 +00:00
|
|
|
void
|
|
|
|
sctp_init_sysctls()
|
|
|
|
{
|
|
|
|
SCTP_BASE_SYSCTL(sctp_sendspace) = SCTPCTL_MAXDGRAM_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_recvspace) = SCTPCTL_RECVSPACE_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_auto_asconf) = SCTPCTL_AUTOASCONF_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_multiple_asconfs) = SCTPCTL_MULTIPLEASCONFS_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_ecn_enable) = SCTPCTL_ECN_ENABLE_DEFAULT;
|
2014-08-02 21:36:40 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_pr_enable) = SCTPCTL_PR_ENABLE_DEFAULT;
|
2014-08-12 13:13:11 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_auth_enable) = SCTPCTL_AUTH_ENABLE_DEFAULT;
|
2014-08-12 11:30:16 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_asconf_enable) = SCTPCTL_ASCONF_ENABLE_DEFAULT;
|
2014-08-04 20:07:35 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_reconfig_enable) = SCTPCTL_RECONFIG_ENABLE_DEFAULT;
|
2014-08-03 14:10:10 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_nrsack_enable) = SCTPCTL_NRSACK_ENABLE_DEFAULT;
|
2014-08-03 18:12:55 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_pktdrop_enable) = SCTPCTL_PKTDROP_ENABLE_DEFAULT;
|
2008-06-14 07:58:05 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_peer_chunk_oh) = SCTPCTL_PEER_CHKOH_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_max_burst_default) = SCTPCTL_MAXBURST_DEFAULT;
|
2011-02-02 11:13:23 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_fr_max_burst_default) = SCTPCTL_FRMAXBURST_DEFAULT;
|
2008-06-14 07:58:05 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue) = SCTPCTL_MAXCHUNKS_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_hashtblsize) = SCTPCTL_TCBHASHSIZE_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_pcbtblsize) = SCTPCTL_PCBHASHSIZE_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_min_split_point) = SCTPCTL_MIN_SPLIT_POINT_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_chunkscale) = SCTPCTL_CHUNKSCALE_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default) = SCTPCTL_DELAYED_SACK_TIME_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_sack_freq_default) = SCTPCTL_SACK_FREQ_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_system_free_resc_limit) = SCTPCTL_SYS_RESOURCE_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit) = SCTPCTL_ASOC_RESOURCE_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default) = SCTPCTL_HEARTBEAT_INTERVAL_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default) = SCTPCTL_PMTU_RAISE_TIME_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default) = SCTPCTL_SHUTDOWN_GUARD_TIME_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_secret_lifetime_default) = SCTPCTL_SECRET_LIFETIME_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_rto_max_default) = SCTPCTL_RTO_MAX_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_rto_min_default) = SCTPCTL_RTO_MIN_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_rto_initial_default) = SCTPCTL_RTO_INITIAL_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_init_rto_max_default) = SCTPCTL_INIT_RTO_MAX_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default) = SCTPCTL_VALID_COOKIE_LIFE_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_init_rtx_max_default) = SCTPCTL_INIT_RTX_MAX_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default) = SCTPCTL_ASSOC_RTX_MAX_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_path_rtx_max_default) = SCTPCTL_PATH_RTX_MAX_DEFAULT;
|
2011-08-03 20:21:00 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_path_pf_threshold) = SCTPCTL_PATH_PF_THRESHOLD_DEFAULT;
|
2008-06-14 07:58:05 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_add_more_threshold) = SCTPCTL_ADD_MORE_ON_OUTPUT_DEFAULT;
|
2013-07-05 10:08:49 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_nr_incoming_streams_default) = SCTPCTL_INCOMING_STREAMS_DEFAULT;
|
2008-06-14 07:58:05 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default) = SCTPCTL_OUTGOING_STREAMS_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_cmt_on_off) = SCTPCTL_CMT_ON_OFF_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_cmt_use_dac) = SCTPCTL_CMT_USE_DAC_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst) = SCTPCTL_CWND_MAXBURST_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_nat_friendly) = SCTPCTL_NAT_FRIENDLY_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_L2_abc_variable) = SCTPCTL_ABC_L_VAR_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count) = SCTPCTL_MAX_CHAINED_MBUFS_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_do_drain) = SCTPCTL_DO_SCTP_DRAIN_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_hb_maxburst) = SCTPCTL_HB_MAX_BURST_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit) = SCTPCTL_ABORT_AT_LIMIT_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_min_residual) = SCTPCTL_MIN_RESIDUAL_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_max_retran_chunk) = SCTPCTL_MAX_RETRAN_CHUNK_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_logging_level) = SCTPCTL_LOGGING_LEVEL_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_default_cc_module) = SCTPCTL_DEFAULT_CC_MODULE_DEFAULT;
|
2011-01-23 19:36:28 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_default_ss_module) = SCTPCTL_DEFAULT_SS_MODULE_DEFAULT;
|
2008-06-14 07:58:05 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_default_frag_interleave) = SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_mobility_base) = SCTPCTL_MOBILITY_BASE_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff) = SCTPCTL_MOBILITY_FASTHANDOFF_DEFAULT;
|
2009-05-30 11:14:41 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_vtag_time_wait) = SCTPCTL_TIME_WAIT_DEFAULT;
|
2010-09-17 16:20:29 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_buffer_splitting) = SCTPCTL_BUFFER_SPLITTING_DEFAULT;
|
2010-09-17 18:53:07 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_initial_cwnd) = SCTPCTL_INITIAL_CWND_DEFAULT;
|
2011-02-26 15:23:46 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_rttvar_bw) = SCTPCTL_RTTVAR_BW_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_rttvar_rtt) = SCTPCTL_RTTVAR_RTT_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_rttvar_eqret) = SCTPCTL_RTTVAR_EQRET_DEFAULT;
|
2011-03-08 11:58:25 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_steady_step) = SCTPCTL_RTTVAR_STEADYS_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_use_dccc_ecn) = SCTPCTL_RTTVAR_DCCCECN_DEFAULT;
|
2012-01-08 09:56:24 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_blackhole) = SCTPCTL_BLACKHOLE_DEFAULT;
|
2014-03-16 12:32:16 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_diag_info_code) = SCTPCTL_DIAG_INFO_CODE_DEFAULT;
|
2007-09-13 14:43:54 +00:00
|
|
|
#if defined(SCTP_LOCAL_TRACE_BUF)
|
2008-06-14 07:58:05 +00:00
|
|
|
memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log));
|
2007-09-13 14:43:54 +00:00
|
|
|
#endif
|
2008-06-14 07:58:05 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = SCTPCTL_UDP_TUNNELING_PORT_DEFAULT;
|
|
|
|
SCTP_BASE_SYSCTL(sctp_enable_sack_immediately) = SCTPCTL_SACK_IMMEDIATELY_ENABLE_DEFAULT;
|
2009-07-28 15:07:41 +00:00
|
|
|
SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly) = SCTPCTL_NAT_FRIENDLY_INITS_DEFAULT;
|
2008-06-14 07:58:05 +00:00
|
|
|
#if defined(SCTP_DEBUG)
|
|
|
|
SCTP_BASE_SYSCTL(sctp_debug_on) = SCTPCTL_DEBUG_DEFAULT;
|
2007-03-15 11:27:14 +00:00
|
|
|
#endif
|
2008-06-14 07:58:05 +00:00
|
|
|
#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
|
|
|
|
SCTP_BASE_SYSCTL(sctp_output_unlocked) = SCTPCTL_OUTPUT_UNLOCKED_DEFAULT;
|
|
|
|
#endif
|
|
|
|
}
|
2007-05-28 11:17:24 +00:00
|
|
|
|
2009-02-03 11:04:03 +00:00
|
|
|
|
2007-05-28 11:17:24 +00:00
|
|
|
/* It returns an upper limit. No filtering is done here */
|
|
|
|
static unsigned int
|
2014-09-06 19:12:14 +00:00
|
|
|
sctp_sysctl_number_of_addresses(struct sctp_inpcb *inp)
|
2007-05-28 11:17:24 +00:00
|
|
|
{
|
2011-12-17 19:21:40 +00:00
|
|
|
unsigned int cnt;
|
2007-05-28 11:17:24 +00:00
|
|
|
struct sctp_vrf *vrf;
|
|
|
|
struct sctp_ifn *sctp_ifn;
|
|
|
|
struct sctp_ifa *sctp_ifa;
|
|
|
|
struct sctp_laddr *laddr;
|
|
|
|
|
|
|
|
cnt = 0;
|
|
|
|
/* neither Mac OS X nor FreeBSD support mulitple routing functions */
|
|
|
|
if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
|
|
|
|
LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
|
|
|
|
LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
|
2011-04-30 11:18:16 +00:00
|
|
|
switch (sctp_ifa->address.sa.sa_family) {
|
|
|
|
#ifdef INET
|
|
|
|
case AF_INET:
|
|
|
|
#endif
|
|
|
|
#ifdef INET6
|
|
|
|
case AF_INET6:
|
|
|
|
#endif
|
2007-05-28 11:17:24 +00:00
|
|
|
cnt++;
|
2011-04-30 11:18:16 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2007-05-28 11:17:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
|
2011-04-30 11:18:16 +00:00
|
|
|
switch (laddr->ifa->address.sa.sa_family) {
|
|
|
|
#ifdef INET
|
|
|
|
case AF_INET:
|
|
|
|
#endif
|
|
|
|
#ifdef INET6
|
|
|
|
case AF_INET6:
|
|
|
|
#endif
|
2007-05-28 11:17:24 +00:00
|
|
|
cnt++;
|
2011-04-30 11:18:16 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2007-05-28 11:17:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (cnt);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2014-09-06 19:12:14 +00:00
|
|
|
sctp_sysctl_copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sysctl_req *req)
|
2007-05-28 11:17:24 +00:00
|
|
|
{
|
|
|
|
struct sctp_ifn *sctp_ifn;
|
|
|
|
struct sctp_ifa *sctp_ifa;
|
|
|
|
int loopback_scope, ipv4_local_scope, local_scope, site_scope;
|
|
|
|
int ipv4_addr_legal, ipv6_addr_legal;
|
|
|
|
struct sctp_vrf *vrf;
|
|
|
|
struct xsctp_laddr xladdr;
|
|
|
|
struct sctp_laddr *laddr;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
/* Turn on all the appropriate scope */
|
|
|
|
if (stcb) {
|
|
|
|
/* use association specific values */
|
2013-02-09 17:26:14 +00:00
|
|
|
loopback_scope = stcb->asoc.scope.loopback_scope;
|
|
|
|
ipv4_local_scope = stcb->asoc.scope.ipv4_local_scope;
|
|
|
|
local_scope = stcb->asoc.scope.local_scope;
|
|
|
|
site_scope = stcb->asoc.scope.site_scope;
|
|
|
|
ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal;
|
|
|
|
ipv6_addr_legal = stcb->asoc.scope.ipv6_addr_legal;
|
2007-05-28 11:17:24 +00:00
|
|
|
} else {
|
2013-02-09 17:26:14 +00:00
|
|
|
/* Use generic values for endpoints. */
|
2007-05-28 11:17:24 +00:00
|
|
|
loopback_scope = 1;
|
|
|
|
ipv4_local_scope = 1;
|
|
|
|
local_scope = 1;
|
|
|
|
site_scope = 1;
|
2013-02-09 17:26:14 +00:00
|
|
|
if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) {
|
|
|
|
ipv6_addr_legal = 1;
|
|
|
|
if (SCTP_IPV6_V6ONLY(inp)) {
|
|
|
|
ipv4_addr_legal = 0;
|
|
|
|
} else {
|
|
|
|
ipv4_addr_legal = 1;
|
|
|
|
}
|
2007-05-28 11:17:24 +00:00
|
|
|
} else {
|
2013-02-09 17:26:14 +00:00
|
|
|
ipv6_addr_legal = 0;
|
2007-05-28 11:17:24 +00:00
|
|
|
ipv4_addr_legal = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* neither Mac OS X nor FreeBSD support mulitple routing functions */
|
|
|
|
if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) {
|
2007-06-06 00:40:41 +00:00
|
|
|
SCTP_INP_RUNLOCK(inp);
|
|
|
|
SCTP_INP_INFO_RUNLOCK();
|
2007-05-28 11:17:24 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
|
|
|
|
LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
|
|
|
|
if ((loopback_scope == 0) && SCTP_IFN_IS_IFT_LOOP(sctp_ifn))
|
|
|
|
/* Skip loopback if loopback_scope not set */
|
|
|
|
continue;
|
|
|
|
LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
|
|
|
|
if (stcb) {
|
|
|
|
/*
|
|
|
|
* ignore if blacklisted at
|
|
|
|
* association level
|
|
|
|
*/
|
|
|
|
if (sctp_is_addr_restricted(stcb, sctp_ifa))
|
|
|
|
continue;
|
|
|
|
}
|
2008-04-16 17:24:18 +00:00
|
|
|
switch (sctp_ifa->address.sa.sa_family) {
|
2011-04-30 11:18:16 +00:00
|
|
|
#ifdef INET
|
2008-04-16 17:24:18 +00:00
|
|
|
case AF_INET:
|
|
|
|
if (ipv4_addr_legal) {
|
|
|
|
struct sockaddr_in *sin;
|
2007-05-28 11:17:24 +00:00
|
|
|
|
2014-09-07 09:06:26 +00:00
|
|
|
sin = &sctp_ifa->address.sin;
|
2008-04-16 17:24:18 +00:00
|
|
|
if (sin->sin_addr.s_addr == 0)
|
|
|
|
continue;
|
2014-06-20 13:26:49 +00:00
|
|
|
if (prison_check_ip4(inp->ip_inp.inp.inp_cred,
|
|
|
|
&sin->sin_addr) != 0) {
|
|
|
|
continue;
|
|
|
|
}
|
2008-04-16 17:24:18 +00:00
|
|
|
if ((ipv4_local_scope == 0) && (IN4_ISPRIVATE_ADDRESS(&sin->sin_addr)))
|
|
|
|
continue;
|
|
|
|
} else {
|
2007-05-28 11:17:24 +00:00
|
|
|
continue;
|
2008-04-16 17:24:18 +00:00
|
|
|
}
|
|
|
|
break;
|
2011-04-30 11:18:16 +00:00
|
|
|
#endif
|
2008-04-16 17:24:18 +00:00
|
|
|
#ifdef INET6
|
|
|
|
case AF_INET6:
|
|
|
|
if (ipv6_addr_legal) {
|
|
|
|
struct sockaddr_in6 *sin6;
|
2007-05-28 11:17:24 +00:00
|
|
|
|
2014-09-07 09:06:26 +00:00
|
|
|
sin6 = &sctp_ifa->address.sin6;
|
2008-04-16 17:24:18 +00:00
|
|
|
if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr))
|
2007-05-28 11:17:24 +00:00
|
|
|
continue;
|
2014-06-20 13:26:49 +00:00
|
|
|
if (prison_check_ip6(inp->ip_inp.inp.inp_cred,
|
|
|
|
&sin6->sin6_addr) != 0) {
|
|
|
|
continue;
|
|
|
|
}
|
2008-04-16 17:24:18 +00:00
|
|
|
if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
|
|
|
|
if (local_scope == 0)
|
2007-05-28 11:17:24 +00:00
|
|
|
continue;
|
|
|
|
}
|
2008-04-16 17:24:18 +00:00
|
|
|
if ((site_scope == 0) && (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)))
|
|
|
|
continue;
|
|
|
|
} else {
|
2007-05-28 11:17:24 +00:00
|
|
|
continue;
|
2008-04-16 17:24:18 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
2007-05-28 11:17:24 +00:00
|
|
|
continue;
|
2008-04-16 17:24:18 +00:00
|
|
|
}
|
2007-09-08 17:48:46 +00:00
|
|
|
memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
|
2007-05-28 11:17:24 +00:00
|
|
|
memcpy((void *)&xladdr.address, (const void *)&sctp_ifa->address, sizeof(union sctp_sockstore));
|
|
|
|
SCTP_INP_RUNLOCK(inp);
|
|
|
|
SCTP_INP_INFO_RUNLOCK();
|
|
|
|
error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
|
2007-09-08 17:48:46 +00:00
|
|
|
if (error) {
|
2007-05-28 11:17:24 +00:00
|
|
|
return (error);
|
2007-09-08 17:48:46 +00:00
|
|
|
} else {
|
2007-05-28 11:17:24 +00:00
|
|
|
SCTP_INP_INFO_RLOCK();
|
|
|
|
SCTP_INP_RLOCK(inp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
|
|
|
|
/* ignore if blacklisted at association level */
|
|
|
|
if (stcb && sctp_is_addr_restricted(stcb, laddr->ifa))
|
|
|
|
continue;
|
2007-09-08 17:48:46 +00:00
|
|
|
memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
|
2007-05-28 11:17:24 +00:00
|
|
|
memcpy((void *)&xladdr.address, (const void *)&laddr->ifa->address, sizeof(union sctp_sockstore));
|
2018-07-19 20:11:14 +00:00
|
|
|
xladdr.start_time.tv_sec = (uint32_t)laddr->start_time.tv_sec;
|
|
|
|
xladdr.start_time.tv_usec = (uint32_t)laddr->start_time.tv_usec;
|
2007-05-28 11:17:24 +00:00
|
|
|
SCTP_INP_RUNLOCK(inp);
|
|
|
|
SCTP_INP_INFO_RUNLOCK();
|
|
|
|
error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
|
2007-09-08 17:48:46 +00:00
|
|
|
if (error) {
|
2007-05-28 11:17:24 +00:00
|
|
|
return (error);
|
2007-09-08 17:48:46 +00:00
|
|
|
} else {
|
2007-05-28 11:17:24 +00:00
|
|
|
SCTP_INP_INFO_RLOCK();
|
|
|
|
SCTP_INP_RLOCK(inp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-09-08 17:48:46 +00:00
|
|
|
memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr));
|
2007-05-28 11:17:24 +00:00
|
|
|
xladdr.last = 1;
|
2007-06-06 00:40:41 +00:00
|
|
|
SCTP_INP_RUNLOCK(inp);
|
|
|
|
SCTP_INP_INFO_RUNLOCK();
|
2007-05-28 11:17:24 +00:00
|
|
|
error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
|
2007-06-06 00:40:41 +00:00
|
|
|
|
2007-09-08 17:48:46 +00:00
|
|
|
if (error) {
|
2007-05-28 11:17:24 +00:00
|
|
|
return (error);
|
2007-09-08 17:48:46 +00:00
|
|
|
} else {
|
2007-06-06 00:40:41 +00:00
|
|
|
SCTP_INP_INFO_RLOCK();
|
|
|
|
SCTP_INP_RLOCK(inp);
|
2007-05-28 11:17:24 +00:00
|
|
|
return (0);
|
2007-06-06 00:40:41 +00:00
|
|
|
}
|
2007-05-28 11:17:24 +00:00
|
|
|
}
|
|
|
|
|
2007-03-15 11:27:14 +00:00
|
|
|
/*
|
|
|
|
* sysctl functions
|
|
|
|
*/
|
|
|
|
static int
|
2014-09-06 19:12:14 +00:00
|
|
|
sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS)
|
2007-03-15 11:27:14 +00:00
|
|
|
{
|
|
|
|
unsigned int number_of_endpoints;
|
|
|
|
unsigned int number_of_local_addresses;
|
|
|
|
unsigned int number_of_associations;
|
|
|
|
unsigned int number_of_remote_addresses;
|
|
|
|
unsigned int n;
|
|
|
|
int error;
|
|
|
|
struct sctp_inpcb *inp;
|
|
|
|
struct sctp_tcb *stcb;
|
|
|
|
struct sctp_nets *net;
|
|
|
|
struct xsctp_inpcb xinpcb;
|
|
|
|
struct xsctp_tcb xstcb;
|
|
|
|
struct xsctp_raddr xraddr;
|
2010-06-06 20:34:17 +00:00
|
|
|
struct socket *so;
|
2007-03-15 11:27:14 +00:00
|
|
|
|
|
|
|
number_of_endpoints = 0;
|
|
|
|
number_of_local_addresses = 0;
|
|
|
|
number_of_associations = 0;
|
|
|
|
number_of_remote_addresses = 0;
|
|
|
|
|
|
|
|
SCTP_INP_INFO_RLOCK();
|
2014-09-06 19:12:14 +00:00
|
|
|
if (req->oldptr == NULL) {
|
2008-06-14 07:58:05 +00:00
|
|
|
LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
|
2007-03-15 11:27:14 +00:00
|
|
|
SCTP_INP_RLOCK(inp);
|
|
|
|
number_of_endpoints++;
|
2014-09-06 19:12:14 +00:00
|
|
|
number_of_local_addresses += sctp_sysctl_number_of_addresses(inp);
|
2007-03-15 11:27:14 +00:00
|
|
|
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
|
|
|
|
number_of_associations++;
|
2014-09-06 19:12:14 +00:00
|
|
|
number_of_local_addresses += sctp_sysctl_number_of_addresses(inp);
|
2007-03-15 11:27:14 +00:00
|
|
|
TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
|
|
|
|
number_of_remote_addresses++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SCTP_INP_RUNLOCK(inp);
|
|
|
|
}
|
|
|
|
SCTP_INP_INFO_RUNLOCK();
|
|
|
|
n = (number_of_endpoints + 1) * sizeof(struct xsctp_inpcb) +
|
2007-05-28 11:17:24 +00:00
|
|
|
(number_of_local_addresses + number_of_endpoints + number_of_associations) * sizeof(struct xsctp_laddr) +
|
|
|
|
(number_of_associations + number_of_endpoints) * sizeof(struct xsctp_tcb) +
|
|
|
|
(number_of_remote_addresses + number_of_associations) * sizeof(struct xsctp_raddr);
|
|
|
|
|
2007-03-15 11:27:14 +00:00
|
|
|
/* request some more memory than needed */
|
|
|
|
req->oldidx = (n + n / 8);
|
2011-12-27 10:16:24 +00:00
|
|
|
return (0);
|
2007-03-15 11:27:14 +00:00
|
|
|
}
|
2014-09-06 19:12:14 +00:00
|
|
|
if (req->newptr != NULL) {
|
2007-03-15 11:27:14 +00:00
|
|
|
SCTP_INP_INFO_RUNLOCK();
|
2007-08-24 00:53:53 +00:00
|
|
|
SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_SYSCTL, EPERM);
|
2011-12-27 10:16:24 +00:00
|
|
|
return (EPERM);
|
2007-03-15 11:27:14 +00:00
|
|
|
}
|
2018-11-22 20:49:41 +00:00
|
|
|
memset(&xinpcb, 0, sizeof(xinpcb));
|
|
|
|
memset(&xstcb, 0, sizeof(xstcb));
|
|
|
|
memset(&xraddr, 0, sizeof(xraddr));
|
2008-06-14 07:58:05 +00:00
|
|
|
LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) {
|
2007-03-15 11:27:14 +00:00
|
|
|
SCTP_INP_RLOCK(inp);
|
2010-06-06 20:34:17 +00:00
|
|
|
if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
|
|
|
|
/* if its allgone it is being freed - skip it */
|
|
|
|
goto skip;
|
|
|
|
}
|
2007-03-15 11:27:14 +00:00
|
|
|
xinpcb.last = 0;
|
|
|
|
xinpcb.local_port = ntohs(inp->sctp_lport);
|
|
|
|
xinpcb.flags = inp->sctp_flags;
|
2013-08-22 20:29:57 +00:00
|
|
|
xinpcb.features = inp->sctp_features;
|
2007-03-15 11:27:14 +00:00
|
|
|
xinpcb.total_sends = inp->total_sends;
|
|
|
|
xinpcb.total_recvs = inp->total_recvs;
|
|
|
|
xinpcb.total_nospaces = inp->total_nospaces;
|
2007-05-08 00:21:05 +00:00
|
|
|
xinpcb.fragmentation_point = inp->sctp_frag_point;
|
2018-07-19 20:11:14 +00:00
|
|
|
xinpcb.socket = (uintptr_t)inp->sctp_socket;
|
2010-06-06 20:34:17 +00:00
|
|
|
so = inp->sctp_socket;
|
|
|
|
if ((so == NULL) ||
|
2017-05-26 16:29:00 +00:00
|
|
|
(!SCTP_IS_LISTENING(inp)) ||
|
2007-09-08 17:48:46 +00:00
|
|
|
(inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) {
|
|
|
|
xinpcb.qlen = 0;
|
|
|
|
xinpcb.maxqlen = 0;
|
|
|
|
} else {
|
Listening sockets improvements.
o Separate fields of struct socket that belong to listening from
fields that belong to normal dataflow, and unionize them. This
shrinks the structure a bit.
- Take out selinfo's from the socket buffers into the socket. The
first reason is to support braindamaged scenario when a socket is
added to kevent(2) and then listen(2) is cast on it. The second
reason is that there is future plan to make socket buffers pluggable,
so that for a dataflow socket a socket buffer can be changed, and
in this case we also want to keep same selinfos through the lifetime
of a socket.
- Remove struct struct so_accf. Since now listening stuff no longer
affects struct socket size, just move its fields into listening part
of the union.
- Provide sol_upcall field and enforce that so_upcall_set() may be called
only on a dataflow socket, which has buffers, and for listening sockets
provide solisten_upcall_set().
o Remove ACCEPT_LOCK() global.
- Add a mutex to socket, to be used instead of socket buffer lock to lock
fields of struct socket that don't belong to a socket buffer.
- Allow to acquire two socket locks, but the first one must belong to a
listening socket.
- Make soref()/sorele() to use atomic(9). This allows in some situations
to do soref() without owning socket lock. There is place for improvement
here, it is possible to make sorele() also to lock optionally.
- Most protocols aren't touched by this change, except UNIX local sockets.
See below for more information.
o Reduce copy-and-paste in kernel modules that accept connections from
listening sockets: provide function solisten_dequeue(), and use it in
the following modules: ctl(4), iscsi(4), ng_btsocket(4), ng_ksocket(4),
infiniband, rpc.
o UNIX local sockets.
- Removal of ACCEPT_LOCK() global uncovered several races in the UNIX
local sockets. Most races exist around spawning a new socket, when we
are connecting to a local listening socket. To cover them, we need to
hold locks on both PCBs when spawning a third one. This means holding
them across sonewconn(). This creates a LOR between pcb locks and
unp_list_lock.
- To fix the new LOR, abandon the global unp_list_lock in favor of global
unp_link_lock. Indeed, separating these two locks didn't provide us any
extra parralelism in the UNIX sockets.
- Now call into uipc_attach() may happen with unp_link_lock hold if, we
are accepting, or without unp_link_lock in case if we are just creating
a socket.
- Another problem in UNIX sockets is that uipc_close() basicly did nothing
for a listening socket. The vnode remained opened for connections. This
is fixed by removing vnode in uipc_close(). Maybe the right way would be
to do it for all sockets (not only listening), simply move the vnode
teardown from uipc_detach() to uipc_close()?
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D9770
2017-06-08 21:30:34 +00:00
|
|
|
xinpcb.qlen = so->sol_qlen;
|
|
|
|
xinpcb.qlen_old = so->sol_qlen > USHRT_MAX ?
|
2018-07-19 20:11:14 +00:00
|
|
|
USHRT_MAX : (uint16_t)so->sol_qlen;
|
Listening sockets improvements.
o Separate fields of struct socket that belong to listening from
fields that belong to normal dataflow, and unionize them. This
shrinks the structure a bit.
- Take out selinfo's from the socket buffers into the socket. The
first reason is to support braindamaged scenario when a socket is
added to kevent(2) and then listen(2) is cast on it. The second
reason is that there is future plan to make socket buffers pluggable,
so that for a dataflow socket a socket buffer can be changed, and
in this case we also want to keep same selinfos through the lifetime
of a socket.
- Remove struct struct so_accf. Since now listening stuff no longer
affects struct socket size, just move its fields into listening part
of the union.
- Provide sol_upcall field and enforce that so_upcall_set() may be called
only on a dataflow socket, which has buffers, and for listening sockets
provide solisten_upcall_set().
o Remove ACCEPT_LOCK() global.
- Add a mutex to socket, to be used instead of socket buffer lock to lock
fields of struct socket that don't belong to a socket buffer.
- Allow to acquire two socket locks, but the first one must belong to a
listening socket.
- Make soref()/sorele() to use atomic(9). This allows in some situations
to do soref() without owning socket lock. There is place for improvement
here, it is possible to make sorele() also to lock optionally.
- Most protocols aren't touched by this change, except UNIX local sockets.
See below for more information.
o Reduce copy-and-paste in kernel modules that accept connections from
listening sockets: provide function solisten_dequeue(), and use it in
the following modules: ctl(4), iscsi(4), ng_btsocket(4), ng_ksocket(4),
infiniband, rpc.
o UNIX local sockets.
- Removal of ACCEPT_LOCK() global uncovered several races in the UNIX
local sockets. Most races exist around spawning a new socket, when we
are connecting to a local listening socket. To cover them, we need to
hold locks on both PCBs when spawning a third one. This means holding
them across sonewconn(). This creates a LOR between pcb locks and
unp_list_lock.
- To fix the new LOR, abandon the global unp_list_lock in favor of global
unp_link_lock. Indeed, separating these two locks didn't provide us any
extra parralelism in the UNIX sockets.
- Now call into uipc_attach() may happen with unp_link_lock hold if, we
are accepting, or without unp_link_lock in case if we are just creating
a socket.
- Another problem in UNIX sockets is that uipc_close() basicly did nothing
for a listening socket. The vnode remained opened for connections. This
is fixed by removing vnode in uipc_close(). Maybe the right way would be
to do it for all sockets (not only listening), simply move the vnode
teardown from uipc_detach() to uipc_close()?
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D9770
2017-06-08 21:30:34 +00:00
|
|
|
xinpcb.maxqlen = so->sol_qlimit;
|
|
|
|
xinpcb.maxqlen_old = so->sol_qlimit > USHRT_MAX ?
|
2018-07-19 20:11:14 +00:00
|
|
|
USHRT_MAX : (uint16_t)so->sol_qlimit;
|
2007-09-08 17:48:46 +00:00
|
|
|
}
|
2007-03-15 11:27:14 +00:00
|
|
|
SCTP_INP_INCR_REF(inp);
|
|
|
|
SCTP_INP_RUNLOCK(inp);
|
|
|
|
SCTP_INP_INFO_RUNLOCK();
|
|
|
|
error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb));
|
|
|
|
if (error) {
|
2007-05-28 11:17:24 +00:00
|
|
|
SCTP_INP_DECR_REF(inp);
|
2011-12-27 10:16:24 +00:00
|
|
|
return (error);
|
2007-03-15 11:27:14 +00:00
|
|
|
}
|
|
|
|
SCTP_INP_INFO_RLOCK();
|
|
|
|
SCTP_INP_RLOCK(inp);
|
2014-09-06 19:12:14 +00:00
|
|
|
error = sctp_sysctl_copy_out_local_addresses(inp, NULL, req);
|
2007-05-28 11:17:24 +00:00
|
|
|
if (error) {
|
|
|
|
SCTP_INP_DECR_REF(inp);
|
2011-12-27 10:16:24 +00:00
|
|
|
return (error);
|
2007-05-28 11:17:24 +00:00
|
|
|
}
|
2007-03-15 11:27:14 +00:00
|
|
|
LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
|
|
|
|
SCTP_TCB_LOCK(stcb);
|
|
|
|
atomic_add_int(&stcb->asoc.refcnt, 1);
|
|
|
|
SCTP_TCB_UNLOCK(stcb);
|
2007-05-28 11:17:24 +00:00
|
|
|
xstcb.last = 0;
|
|
|
|
xstcb.local_port = ntohs(inp->sctp_lport);
|
|
|
|
xstcb.remote_port = ntohs(stcb->rport);
|
2007-03-15 11:27:14 +00:00
|
|
|
if (stcb->asoc.primary_destination != NULL)
|
2007-05-28 11:17:24 +00:00
|
|
|
xstcb.primary_addr = stcb->asoc.primary_destination->ro._l_addr;
|
|
|
|
xstcb.heartbeat_interval = stcb->asoc.heart_beat_delay;
|
2018-07-19 20:11:14 +00:00
|
|
|
xstcb.state = (uint32_t)sctp_map_assoc_state(stcb->asoc.state);
|
2009-02-13 14:43:46 +00:00
|
|
|
/* 7.0 does not support these */
|
2009-02-03 11:04:03 +00:00
|
|
|
xstcb.assoc_id = sctp_get_associd(stcb);
|
2009-02-13 14:43:46 +00:00
|
|
|
xstcb.peers_rwnd = stcb->asoc.peers_rwnd;
|
2007-05-28 11:17:24 +00:00
|
|
|
xstcb.in_streams = stcb->asoc.streamincnt;
|
|
|
|
xstcb.out_streams = stcb->asoc.streamoutcnt;
|
|
|
|
xstcb.max_nr_retrans = stcb->asoc.overall_error_count;
|
|
|
|
xstcb.primary_process = 0; /* not really supported
|
|
|
|
* yet */
|
|
|
|
xstcb.T1_expireries = stcb->asoc.timoinit + stcb->asoc.timocookie;
|
|
|
|
xstcb.T2_expireries = stcb->asoc.timoshutdown + stcb->asoc.timoshutdownack;
|
|
|
|
xstcb.retransmitted_tsns = stcb->asoc.marked_retrans;
|
2018-07-19 20:11:14 +00:00
|
|
|
xstcb.start_time.tv_sec = (uint32_t)stcb->asoc.start_time.tv_sec;
|
|
|
|
xstcb.start_time.tv_usec = (uint32_t)stcb->asoc.start_time.tv_usec;
|
|
|
|
xstcb.discontinuity_time.tv_sec = (uint32_t)stcb->asoc.discontinuity_time.tv_sec;
|
|
|
|
xstcb.discontinuity_time.tv_usec = (uint32_t)stcb->asoc.discontinuity_time.tv_usec;
|
2007-03-15 11:27:14 +00:00
|
|
|
xstcb.total_sends = stcb->total_sends;
|
|
|
|
xstcb.total_recvs = stcb->total_recvs;
|
|
|
|
xstcb.local_tag = stcb->asoc.my_vtag;
|
|
|
|
xstcb.remote_tag = stcb->asoc.peer_vtag;
|
|
|
|
xstcb.initial_tsn = stcb->asoc.init_seq_number;
|
|
|
|
xstcb.highest_tsn = stcb->asoc.sending_seq - 1;
|
|
|
|
xstcb.cumulative_tsn = stcb->asoc.last_acked_seq;
|
|
|
|
xstcb.cumulative_tsn_ack = stcb->asoc.cumulative_tsn;
|
2007-05-08 00:21:05 +00:00
|
|
|
xstcb.mtu = stcb->asoc.smallest_mtu;
|
2007-05-29 09:29:03 +00:00
|
|
|
xstcb.refcnt = stcb->asoc.refcnt;
|
2007-03-15 11:27:14 +00:00
|
|
|
SCTP_INP_RUNLOCK(inp);
|
|
|
|
SCTP_INP_INFO_RUNLOCK();
|
|
|
|
error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb));
|
|
|
|
if (error) {
|
2007-05-28 11:17:24 +00:00
|
|
|
SCTP_INP_DECR_REF(inp);
|
2007-09-08 17:48:46 +00:00
|
|
|
atomic_subtract_int(&stcb->asoc.refcnt, 1);
|
2011-12-27 10:16:24 +00:00
|
|
|
return (error);
|
2007-05-28 11:17:24 +00:00
|
|
|
}
|
|
|
|
SCTP_INP_INFO_RLOCK();
|
|
|
|
SCTP_INP_RLOCK(inp);
|
2014-09-06 19:12:14 +00:00
|
|
|
error = sctp_sysctl_copy_out_local_addresses(inp, stcb, req);
|
2007-05-28 11:17:24 +00:00
|
|
|
if (error) {
|
|
|
|
SCTP_INP_DECR_REF(inp);
|
2007-09-08 17:48:46 +00:00
|
|
|
atomic_subtract_int(&stcb->asoc.refcnt, 1);
|
2011-12-27 10:16:24 +00:00
|
|
|
return (error);
|
2007-03-15 11:27:14 +00:00
|
|
|
}
|
|
|
|
TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
|
2007-05-28 11:17:24 +00:00
|
|
|
xraddr.last = 0;
|
|
|
|
xraddr.address = net->ro._l_addr;
|
|
|
|
xraddr.active = ((net->dest_state & SCTP_ADDR_REACHABLE) == SCTP_ADDR_REACHABLE);
|
|
|
|
xraddr.confirmed = ((net->dest_state & SCTP_ADDR_UNCONFIRMED) == 0);
|
|
|
|
xraddr.heartbeat_enabled = ((net->dest_state & SCTP_ADDR_NOHB) == 0);
|
2011-08-03 20:21:00 +00:00
|
|
|
xraddr.potentially_failed = ((net->dest_state & SCTP_ADDR_PF) == SCTP_ADDR_PF);
|
2007-05-28 11:17:24 +00:00
|
|
|
xraddr.rto = net->RTO;
|
|
|
|
xraddr.max_path_rtx = net->failure_threshold;
|
|
|
|
xraddr.rtx = net->marked_retrans;
|
|
|
|
xraddr.error_counter = net->error_count;
|
|
|
|
xraddr.cwnd = net->cwnd;
|
|
|
|
xraddr.flight_size = net->flight_size;
|
|
|
|
xraddr.mtu = net->mtu;
|
2011-02-24 22:36:40 +00:00
|
|
|
xraddr.rtt = net->rtt / 1000;
|
2011-08-03 20:21:00 +00:00
|
|
|
xraddr.heartbeat_interval = net->heart_beat_delay;
|
2015-07-07 06:34:28 +00:00
|
|
|
xraddr.ssthresh = net->ssthresh;
|
2017-09-12 21:08:50 +00:00
|
|
|
xraddr.encaps_port = net->port;
|
|
|
|
if (net->dest_state & SCTP_ADDR_UNCONFIRMED) {
|
|
|
|
xraddr.state = SCTP_UNCONFIRMED;
|
|
|
|
} else if (net->dest_state & SCTP_ADDR_REACHABLE) {
|
|
|
|
xraddr.state = SCTP_ACTIVE;
|
|
|
|
} else {
|
|
|
|
xraddr.state = SCTP_INACTIVE;
|
|
|
|
}
|
2018-07-19 20:11:14 +00:00
|
|
|
xraddr.start_time.tv_sec = (uint32_t)net->start_time.tv_sec;
|
|
|
|
xraddr.start_time.tv_usec = (uint32_t)net->start_time.tv_usec;
|
2007-05-28 11:17:24 +00:00
|
|
|
SCTP_INP_RUNLOCK(inp);
|
|
|
|
SCTP_INP_INFO_RUNLOCK();
|
2007-03-15 11:27:14 +00:00
|
|
|
error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr));
|
|
|
|
if (error) {
|
2007-05-28 11:17:24 +00:00
|
|
|
SCTP_INP_DECR_REF(inp);
|
2007-09-08 17:48:46 +00:00
|
|
|
atomic_subtract_int(&stcb->asoc.refcnt, 1);
|
2011-12-27 10:16:24 +00:00
|
|
|
return (error);
|
2007-03-15 11:27:14 +00:00
|
|
|
}
|
2007-05-28 11:17:24 +00:00
|
|
|
SCTP_INP_INFO_RLOCK();
|
|
|
|
SCTP_INP_RLOCK(inp);
|
2007-03-15 11:27:14 +00:00
|
|
|
}
|
2007-09-08 17:48:46 +00:00
|
|
|
atomic_subtract_int(&stcb->asoc.refcnt, 1);
|
2007-05-28 11:17:24 +00:00
|
|
|
memset((void *)&xraddr, 0, sizeof(struct xsctp_raddr));
|
|
|
|
xraddr.last = 1;
|
|
|
|
SCTP_INP_RUNLOCK(inp);
|
|
|
|
SCTP_INP_INFO_RUNLOCK();
|
|
|
|
error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr));
|
|
|
|
if (error) {
|
|
|
|
SCTP_INP_DECR_REF(inp);
|
2011-12-27 10:16:24 +00:00
|
|
|
return (error);
|
2007-05-28 11:17:24 +00:00
|
|
|
}
|
2007-03-15 11:27:14 +00:00
|
|
|
SCTP_INP_INFO_RLOCK();
|
|
|
|
SCTP_INP_RLOCK(inp);
|
|
|
|
}
|
2007-09-08 17:48:46 +00:00
|
|
|
SCTP_INP_DECR_REF(inp);
|
2007-03-15 11:27:14 +00:00
|
|
|
SCTP_INP_RUNLOCK(inp);
|
2007-05-28 11:17:24 +00:00
|
|
|
SCTP_INP_INFO_RUNLOCK();
|
|
|
|
memset((void *)&xstcb, 0, sizeof(struct xsctp_tcb));
|
|
|
|
xstcb.last = 1;
|
|
|
|
error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb));
|
|
|
|
if (error) {
|
2011-12-27 10:16:24 +00:00
|
|
|
return (error);
|
2007-05-28 11:17:24 +00:00
|
|
|
}
|
2010-06-06 20:34:17 +00:00
|
|
|
skip:
|
2007-05-28 11:17:24 +00:00
|
|
|
SCTP_INP_INFO_RLOCK();
|
2007-03-15 11:27:14 +00:00
|
|
|
}
|
|
|
|
SCTP_INP_INFO_RUNLOCK();
|
|
|
|
|
2007-05-28 11:17:24 +00:00
|
|
|
memset((void *)&xinpcb, 0, sizeof(struct xsctp_inpcb));
|
2007-03-15 11:27:14 +00:00
|
|
|
xinpcb.last = 1;
|
|
|
|
error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb));
|
2011-12-27 10:16:24 +00:00
|
|
|
return (error);
|
2007-03-15 11:27:14 +00:00
|
|
|
}
|
|
|
|
|
2008-05-20 13:47:46 +00:00
|
|
|
static int
|
2014-09-06 19:12:14 +00:00
|
|
|
sctp_sysctl_handle_udp_tunneling(SYSCTL_HANDLER_ARGS)
|
2008-05-20 13:47:46 +00:00
|
|
|
{
|
|
|
|
int error;
|
2014-09-06 19:12:14 +00:00
|
|
|
uint32_t old, new;
|
2008-05-20 13:47:46 +00:00
|
|
|
|
2009-02-03 20:33:28 +00:00
|
|
|
SCTP_INP_INFO_RLOCK();
|
2014-09-06 19:12:14 +00:00
|
|
|
old = SCTP_BASE_SYSCTL(sctp_udp_tunneling_port);
|
2009-02-03 20:33:28 +00:00
|
|
|
SCTP_INP_INFO_RUNLOCK();
|
2014-09-06 19:12:14 +00:00
|
|
|
new = old;
|
|
|
|
error = sysctl_handle_int(oidp, &new, 0, req);
|
|
|
|
if ((error == 0) &&
|
|
|
|
(req->newptr != NULL)) {
|
2015-01-20 19:08:55 +00:00
|
|
|
#if (SCTPCTL_UDP_TUNNELING_PORT_MIN == 0)
|
|
|
|
if (new > SCTPCTL_UDP_TUNNELING_PORT_MAX) {
|
|
|
|
#else
|
2014-09-06 19:12:14 +00:00
|
|
|
if ((new < SCTPCTL_UDP_TUNNELING_PORT_MIN) ||
|
|
|
|
(new > SCTPCTL_UDP_TUNNELING_PORT_MAX)) {
|
2015-01-20 19:08:55 +00:00
|
|
|
#endif
|
2014-09-06 19:12:14 +00:00
|
|
|
error = EINVAL;
|
|
|
|
} else {
|
|
|
|
SCTP_INP_INFO_WLOCK();
|
|
|
|
SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = new;
|
|
|
|
if (old != 0) {
|
|
|
|
sctp_over_udp_stop();
|
|
|
|
}
|
|
|
|
if (new != 0) {
|
|
|
|
error = sctp_over_udp_start();
|
2008-05-20 13:47:46 +00:00
|
|
|
}
|
2014-09-06 19:12:14 +00:00
|
|
|
SCTP_INP_INFO_WUNLOCK();
|
2008-05-20 13:47:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2008-06-14 07:58:05 +00:00
|
|
|
|
2007-09-08 17:48:46 +00:00
|
|
|
static int
|
2014-09-06 19:12:14 +00:00
|
|
|
sctp_sysctl_handle_auth(SYSCTL_HANDLER_ARGS)
|
2007-09-08 17:48:46 +00:00
|
|
|
{
|
|
|
|
int error;
|
2014-09-06 19:12:14 +00:00
|
|
|
uint32_t new;
|
|
|
|
|
|
|
|
new = SCTP_BASE_SYSCTL(sctp_auth_enable);
|
|
|
|
error = sysctl_handle_int(oidp, &new, 0, req);
|
|
|
|
if ((error == 0) &&
|
|
|
|
(req->newptr != NULL)) {
|
2015-01-20 19:08:55 +00:00
|
|
|
#if (SCTPCTL_AUTH_ENABLE_MIN == 0)
|
|
|
|
if ((new > SCTPCTL_AUTH_ENABLE_MAX) ||
|
|
|
|
((new == 0) && (SCTP_BASE_SYSCTL(sctp_asconf_enable) == 1))) {
|
|
|
|
#else
|
2014-09-06 19:12:14 +00:00
|
|
|
if ((new < SCTPCTL_AUTH_ENABLE_MIN) ||
|
|
|
|
(new > SCTPCTL_AUTH_ENABLE_MAX) ||
|
|
|
|
((new == 0) && (SCTP_BASE_SYSCTL(sctp_asconf_enable) == 1))) {
|
2015-01-20 19:08:55 +00:00
|
|
|
#endif
|
2014-09-06 19:12:14 +00:00
|
|
|
error = EINVAL;
|
|
|
|
} else {
|
|
|
|
SCTP_BASE_SYSCTL(sctp_auth_enable) = new;
|
|
|
|
}
|
2007-09-08 17:48:46 +00:00
|
|
|
}
|
|
|
|
return (error);
|
|
|
|
}
|
2007-03-15 11:27:14 +00:00
|
|
|
|
2014-08-12 11:30:16 +00:00
|
|
|
static int
|
2014-09-06 19:12:14 +00:00
|
|
|
sctp_sysctl_handle_asconf(SYSCTL_HANDLER_ARGS)
|
2014-08-12 11:30:16 +00:00
|
|
|
{
|
|
|
|
int error;
|
2014-09-06 19:12:14 +00:00
|
|
|
uint32_t new;
|
|
|
|
|
|
|
|
new = SCTP_BASE_SYSCTL(sctp_asconf_enable);
|
|
|
|
error = sysctl_handle_int(oidp, &new, 0, req);
|
|
|
|
if ((error == 0) &&
|
|
|
|
(req->newptr != NULL)) {
|
2015-01-20 19:08:55 +00:00
|
|
|
#if (SCTPCTL_ASCONF_ENABLE_MIN == 0)
|
|
|
|
if ((new > SCTPCTL_ASCONF_ENABLE_MAX) ||
|
|
|
|
((new == 1) && (SCTP_BASE_SYSCTL(sctp_auth_enable) == 0))) {
|
|
|
|
#else
|
2014-09-06 19:12:14 +00:00
|
|
|
if ((new < SCTPCTL_ASCONF_ENABLE_MIN) ||
|
|
|
|
(new > SCTPCTL_ASCONF_ENABLE_MAX) ||
|
|
|
|
((new == 1) && (SCTP_BASE_SYSCTL(sctp_auth_enable) == 0))) {
|
2015-01-20 19:08:55 +00:00
|
|
|
#endif
|
2014-09-06 19:12:14 +00:00
|
|
|
error = EINVAL;
|
|
|
|
} else {
|
|
|
|
SCTP_BASE_SYSCTL(sctp_asconf_enable) = new;
|
2014-08-12 11:30:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2014-09-06 19:12:14 +00:00
|
|
|
sctp_sysctl_handle_stats(SYSCTL_HANDLER_ARGS)
|
2014-08-12 11:30:16 +00:00
|
|
|
{
|
|
|
|
int error;
|
2014-09-06 19:12:14 +00:00
|
|
|
#if defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
|
2014-10-28 12:00:39 +00:00
|
|
|
struct sctpstat *sarry;
|
|
|
|
struct sctpstat sb;
|
2014-09-06 19:12:14 +00:00
|
|
|
int cpu;
|
|
|
|
#endif
|
2014-11-01 10:35:45 +00:00
|
|
|
struct sctpstat sb_temp;
|
2011-02-03 11:52:22 +00:00
|
|
|
|
2014-09-06 19:12:14 +00:00
|
|
|
if ((req->newptr != NULL) &&
|
|
|
|
(req->newlen != sizeof(struct sctpstat))) {
|
2011-02-03 11:52:22 +00:00
|
|
|
return (EINVAL);
|
|
|
|
}
|
2014-11-01 10:35:45 +00:00
|
|
|
memset(&sb_temp, 0, sizeof(struct sctpstat));
|
2014-10-28 12:00:39 +00:00
|
|
|
|
|
|
|
if (req->newptr != NULL) {
|
2014-11-01 10:35:45 +00:00
|
|
|
error = SYSCTL_IN(req, &sb_temp, sizeof(struct sctpstat));
|
|
|
|
if (error != 0) {
|
2014-10-28 12:00:39 +00:00
|
|
|
return (error);
|
2014-11-01 10:35:45 +00:00
|
|
|
}
|
2014-10-28 12:00:39 +00:00
|
|
|
}
|
2014-11-01 10:35:45 +00:00
|
|
|
#if defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
|
|
|
|
memset(&sb, 0, sizeof(sb));
|
2011-02-03 19:22:21 +00:00
|
|
|
for (cpu = 0; cpu < mp_maxid; cpu++) {
|
2010-03-24 20:02:40 +00:00
|
|
|
sarry = &SCTP_BASE_STATS[cpu];
|
|
|
|
if (sarry->sctps_discontinuitytime.tv_sec > sb.sctps_discontinuitytime.tv_sec) {
|
|
|
|
sb.sctps_discontinuitytime.tv_sec = sarry->sctps_discontinuitytime.tv_sec;
|
|
|
|
sb.sctps_discontinuitytime.tv_usec = sarry->sctps_discontinuitytime.tv_usec;
|
|
|
|
}
|
|
|
|
sb.sctps_currestab += sarry->sctps_currestab;
|
|
|
|
sb.sctps_activeestab += sarry->sctps_activeestab;
|
|
|
|
sb.sctps_restartestab += sarry->sctps_restartestab;
|
|
|
|
sb.sctps_collisionestab += sarry->sctps_collisionestab;
|
|
|
|
sb.sctps_passiveestab += sarry->sctps_passiveestab;
|
|
|
|
sb.sctps_aborted += sarry->sctps_aborted;
|
|
|
|
sb.sctps_shutdown += sarry->sctps_shutdown;
|
|
|
|
sb.sctps_outoftheblue += sarry->sctps_outoftheblue;
|
|
|
|
sb.sctps_checksumerrors += sarry->sctps_checksumerrors;
|
|
|
|
sb.sctps_outcontrolchunks += sarry->sctps_outcontrolchunks;
|
|
|
|
sb.sctps_outorderchunks += sarry->sctps_outorderchunks;
|
|
|
|
sb.sctps_outunorderchunks += sarry->sctps_outunorderchunks;
|
|
|
|
sb.sctps_incontrolchunks += sarry->sctps_incontrolchunks;
|
|
|
|
sb.sctps_inorderchunks += sarry->sctps_inorderchunks;
|
|
|
|
sb.sctps_inunorderchunks += sarry->sctps_inunorderchunks;
|
|
|
|
sb.sctps_fragusrmsgs += sarry->sctps_fragusrmsgs;
|
|
|
|
sb.sctps_reasmusrmsgs += sarry->sctps_reasmusrmsgs;
|
|
|
|
sb.sctps_outpackets += sarry->sctps_outpackets;
|
|
|
|
sb.sctps_inpackets += sarry->sctps_inpackets;
|
|
|
|
sb.sctps_recvpackets += sarry->sctps_recvpackets;
|
|
|
|
sb.sctps_recvdatagrams += sarry->sctps_recvdatagrams;
|
|
|
|
sb.sctps_recvpktwithdata += sarry->sctps_recvpktwithdata;
|
|
|
|
sb.sctps_recvsacks += sarry->sctps_recvsacks;
|
|
|
|
sb.sctps_recvdata += sarry->sctps_recvdata;
|
|
|
|
sb.sctps_recvdupdata += sarry->sctps_recvdupdata;
|
|
|
|
sb.sctps_recvheartbeat += sarry->sctps_recvheartbeat;
|
|
|
|
sb.sctps_recvheartbeatack += sarry->sctps_recvheartbeatack;
|
|
|
|
sb.sctps_recvecne += sarry->sctps_recvecne;
|
|
|
|
sb.sctps_recvauth += sarry->sctps_recvauth;
|
|
|
|
sb.sctps_recvauthmissing += sarry->sctps_recvauthmissing;
|
|
|
|
sb.sctps_recvivalhmacid += sarry->sctps_recvivalhmacid;
|
|
|
|
sb.sctps_recvivalkeyid += sarry->sctps_recvivalkeyid;
|
|
|
|
sb.sctps_recvauthfailed += sarry->sctps_recvauthfailed;
|
|
|
|
sb.sctps_recvexpress += sarry->sctps_recvexpress;
|
|
|
|
sb.sctps_recvexpressm += sarry->sctps_recvexpressm;
|
|
|
|
sb.sctps_recvswcrc += sarry->sctps_recvswcrc;
|
|
|
|
sb.sctps_recvhwcrc += sarry->sctps_recvhwcrc;
|
|
|
|
sb.sctps_sendpackets += sarry->sctps_sendpackets;
|
|
|
|
sb.sctps_sendsacks += sarry->sctps_sendsacks;
|
|
|
|
sb.sctps_senddata += sarry->sctps_senddata;
|
|
|
|
sb.sctps_sendretransdata += sarry->sctps_sendretransdata;
|
|
|
|
sb.sctps_sendfastretrans += sarry->sctps_sendfastretrans;
|
|
|
|
sb.sctps_sendmultfastretrans += sarry->sctps_sendmultfastretrans;
|
|
|
|
sb.sctps_sendheartbeat += sarry->sctps_sendheartbeat;
|
|
|
|
sb.sctps_sendecne += sarry->sctps_sendecne;
|
|
|
|
sb.sctps_sendauth += sarry->sctps_sendauth;
|
|
|
|
sb.sctps_senderrors += sarry->sctps_senderrors;
|
|
|
|
sb.sctps_sendswcrc += sarry->sctps_sendswcrc;
|
|
|
|
sb.sctps_sendhwcrc += sarry->sctps_sendhwcrc;
|
|
|
|
sb.sctps_pdrpfmbox += sarry->sctps_pdrpfmbox;
|
|
|
|
sb.sctps_pdrpfehos += sarry->sctps_pdrpfehos;
|
|
|
|
sb.sctps_pdrpmbda += sarry->sctps_pdrpmbda;
|
|
|
|
sb.sctps_pdrpmbct += sarry->sctps_pdrpmbct;
|
|
|
|
sb.sctps_pdrpbwrpt += sarry->sctps_pdrpbwrpt;
|
|
|
|
sb.sctps_pdrpcrupt += sarry->sctps_pdrpcrupt;
|
|
|
|
sb.sctps_pdrpnedat += sarry->sctps_pdrpnedat;
|
|
|
|
sb.sctps_pdrppdbrk += sarry->sctps_pdrppdbrk;
|
|
|
|
sb.sctps_pdrptsnnf += sarry->sctps_pdrptsnnf;
|
|
|
|
sb.sctps_pdrpdnfnd += sarry->sctps_pdrpdnfnd;
|
|
|
|
sb.sctps_pdrpdiwnp += sarry->sctps_pdrpdiwnp;
|
|
|
|
sb.sctps_pdrpdizrw += sarry->sctps_pdrpdizrw;
|
|
|
|
sb.sctps_pdrpbadd += sarry->sctps_pdrpbadd;
|
|
|
|
sb.sctps_pdrpmark += sarry->sctps_pdrpmark;
|
|
|
|
sb.sctps_timoiterator += sarry->sctps_timoiterator;
|
|
|
|
sb.sctps_timodata += sarry->sctps_timodata;
|
|
|
|
sb.sctps_timowindowprobe += sarry->sctps_timowindowprobe;
|
|
|
|
sb.sctps_timoinit += sarry->sctps_timoinit;
|
|
|
|
sb.sctps_timosack += sarry->sctps_timosack;
|
|
|
|
sb.sctps_timoshutdown += sarry->sctps_timoshutdown;
|
|
|
|
sb.sctps_timoheartbeat += sarry->sctps_timoheartbeat;
|
|
|
|
sb.sctps_timocookie += sarry->sctps_timocookie;
|
|
|
|
sb.sctps_timosecret += sarry->sctps_timosecret;
|
|
|
|
sb.sctps_timopathmtu += sarry->sctps_timopathmtu;
|
|
|
|
sb.sctps_timoshutdownack += sarry->sctps_timoshutdownack;
|
|
|
|
sb.sctps_timoshutdownguard += sarry->sctps_timoshutdownguard;
|
|
|
|
sb.sctps_timostrmrst += sarry->sctps_timostrmrst;
|
|
|
|
sb.sctps_timoearlyfr += sarry->sctps_timoearlyfr;
|
|
|
|
sb.sctps_timoasconf += sarry->sctps_timoasconf;
|
|
|
|
sb.sctps_timodelprim += sarry->sctps_timodelprim;
|
|
|
|
sb.sctps_timoautoclose += sarry->sctps_timoautoclose;
|
|
|
|
sb.sctps_timoassockill += sarry->sctps_timoassockill;
|
|
|
|
sb.sctps_timoinpkill += sarry->sctps_timoinpkill;
|
|
|
|
sb.sctps_hdrops += sarry->sctps_hdrops;
|
|
|
|
sb.sctps_badsum += sarry->sctps_badsum;
|
|
|
|
sb.sctps_noport += sarry->sctps_noport;
|
|
|
|
sb.sctps_badvtag += sarry->sctps_badvtag;
|
|
|
|
sb.sctps_badsid += sarry->sctps_badsid;
|
|
|
|
sb.sctps_nomem += sarry->sctps_nomem;
|
|
|
|
sb.sctps_fastretransinrtt += sarry->sctps_fastretransinrtt;
|
|
|
|
sb.sctps_markedretrans += sarry->sctps_markedretrans;
|
|
|
|
sb.sctps_naglesent += sarry->sctps_naglesent;
|
|
|
|
sb.sctps_naglequeued += sarry->sctps_naglequeued;
|
|
|
|
sb.sctps_maxburstqueued += sarry->sctps_maxburstqueued;
|
|
|
|
sb.sctps_ifnomemqueued += sarry->sctps_ifnomemqueued;
|
|
|
|
sb.sctps_windowprobed += sarry->sctps_windowprobed;
|
|
|
|
sb.sctps_lowlevelerr += sarry->sctps_lowlevelerr;
|
|
|
|
sb.sctps_lowlevelerrusr += sarry->sctps_lowlevelerrusr;
|
|
|
|
sb.sctps_datadropchklmt += sarry->sctps_datadropchklmt;
|
|
|
|
sb.sctps_datadroprwnd += sarry->sctps_datadroprwnd;
|
|
|
|
sb.sctps_ecnereducedcwnd += sarry->sctps_ecnereducedcwnd;
|
|
|
|
sb.sctps_vtagexpress += sarry->sctps_vtagexpress;
|
|
|
|
sb.sctps_vtagbogus += sarry->sctps_vtagbogus;
|
|
|
|
sb.sctps_primary_randry += sarry->sctps_primary_randry;
|
|
|
|
sb.sctps_cmt_randry += sarry->sctps_cmt_randry;
|
|
|
|
sb.sctps_slowpath_sack += sarry->sctps_slowpath_sack;
|
|
|
|
sb.sctps_wu_sacks_sent += sarry->sctps_wu_sacks_sent;
|
|
|
|
sb.sctps_sends_with_flags += sarry->sctps_sends_with_flags;
|
|
|
|
sb.sctps_sends_with_unord += sarry->sctps_sends_with_unord;
|
|
|
|
sb.sctps_sends_with_eof += sarry->sctps_sends_with_eof;
|
|
|
|
sb.sctps_sends_with_abort += sarry->sctps_sends_with_abort;
|
|
|
|
sb.sctps_protocol_drain_calls += sarry->sctps_protocol_drain_calls;
|
|
|
|
sb.sctps_protocol_drains_done += sarry->sctps_protocol_drains_done;
|
|
|
|
sb.sctps_read_peeks += sarry->sctps_read_peeks;
|
|
|
|
sb.sctps_cached_chk += sarry->sctps_cached_chk;
|
|
|
|
sb.sctps_cached_strmoq += sarry->sctps_cached_strmoq;
|
|
|
|
sb.sctps_left_abandon += sarry->sctps_left_abandon;
|
|
|
|
sb.sctps_send_burst_avoid += sarry->sctps_send_burst_avoid;
|
|
|
|
sb.sctps_send_cwnd_avoid += sarry->sctps_send_cwnd_avoid;
|
|
|
|
sb.sctps_fwdtsn_map_over += sarry->sctps_fwdtsn_map_over;
|
2014-11-01 10:35:45 +00:00
|
|
|
if (req->newptr != NULL) {
|
2014-10-28 12:00:39 +00:00
|
|
|
memcpy(sarry, &sb_temp, sizeof(struct sctpstat));
|
2014-11-01 10:35:45 +00:00
|
|
|
}
|
2010-03-24 20:02:40 +00:00
|
|
|
}
|
2014-09-06 19:12:14 +00:00
|
|
|
error = SYSCTL_OUT(req, &sb, sizeof(struct sctpstat));
|
|
|
|
#else
|
|
|
|
error = SYSCTL_OUT(req, &SCTP_BASE_STATS, sizeof(struct sctpstat));
|
2014-11-01 10:35:45 +00:00
|
|
|
if (error != 0) {
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
if (req->newptr != NULL) {
|
|
|
|
memcpy(&SCTP_BASE_STATS, &sb_temp, sizeof(struct sctpstat));
|
|
|
|
}
|
2014-09-06 19:12:14 +00:00
|
|
|
#endif
|
2010-03-24 20:02:40 +00:00
|
|
|
return (error);
|
|
|
|
}
|
2008-06-14 07:58:05 +00:00
|
|
|
|
|
|
|
#if defined(SCTP_LOCAL_TRACE_BUF)
|
|
|
|
static int
|
2014-09-06 19:12:14 +00:00
|
|
|
sctp_sysctl_handle_trace_log(SYSCTL_HANDLER_ARGS)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = SYSCTL_OUT(req, &SCTP_BASE_SYSCTL(sctp_log), sizeof(struct sctp_log));
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
sctp_sysctl_handle_trace_log_clear(SYSCTL_HANDLER_ARGS)
|
2008-06-14 07:58:05 +00:00
|
|
|
{
|
2009-02-03 11:04:03 +00:00
|
|
|
int error = 0;
|
|
|
|
|
2008-06-14 07:58:05 +00:00
|
|
|
memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log));
|
2009-02-03 11:04:03 +00:00
|
|
|
return (error);
|
2008-06-14 07:58:05 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-09-06 19:12:14 +00:00
|
|
|
#define SCTP_UINT_SYSCTL(mib_name, var_name, prefix) \
|
|
|
|
static int \
|
|
|
|
sctp_sysctl_handle_##mib_name(SYSCTL_HANDLER_ARGS) \
|
|
|
|
{ \
|
|
|
|
int error; \
|
|
|
|
uint32_t new; \
|
|
|
|
\
|
|
|
|
new = SCTP_BASE_SYSCTL(var_name); \
|
|
|
|
error = sysctl_handle_int(oidp, &new, 0, req); \
|
|
|
|
if ((error == 0) && (req->newptr != NULL)) { \
|
|
|
|
if ((new < prefix##_MIN) || \
|
|
|
|
(new > prefix##_MAX)) { \
|
|
|
|
error = EINVAL; \
|
|
|
|
} else { \
|
|
|
|
SCTP_BASE_SYSCTL(var_name) = new; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
return (error); \
|
|
|
|
} \
|
2014-09-07 07:49:49 +00:00
|
|
|
SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mib_name, \
|
|
|
|
CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW, NULL, 0, \
|
2014-09-06 19:12:14 +00:00
|
|
|
sctp_sysctl_handle_##mib_name, "UI", prefix##_DESC);
|
2008-06-14 07:58:05 +00:00
|
|
|
|
2007-03-15 11:27:14 +00:00
|
|
|
/*
|
|
|
|
* sysctl definitions
|
|
|
|
*/
|
|
|
|
|
2014-09-06 19:12:14 +00:00
|
|
|
SCTP_UINT_SYSCTL(sendspace, sctp_sendspace, SCTPCTL_MAXDGRAM)
|
|
|
|
SCTP_UINT_SYSCTL(recvspace, sctp_recvspace, SCTPCTL_RECVSPACE)
|
|
|
|
SCTP_UINT_SYSCTL(auto_asconf, sctp_auto_asconf, SCTPCTL_AUTOASCONF)
|
|
|
|
SCTP_UINT_SYSCTL(ecn_enable, sctp_ecn_enable, SCTPCTL_ECN_ENABLE)
|
|
|
|
SCTP_UINT_SYSCTL(pr_enable, sctp_pr_enable, SCTPCTL_PR_ENABLE)
|
2014-09-07 07:49:49 +00:00
|
|
|
SYSCTL_PROC(_net_inet_sctp, OID_AUTO, auth_enable, CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW,
|
2014-09-06 19:12:14 +00:00
|
|
|
NULL, 0, sctp_sysctl_handle_auth, "IU", SCTPCTL_AUTH_ENABLE_DESC);
|
2014-09-07 07:49:49 +00:00
|
|
|
SYSCTL_PROC(_net_inet_sctp, OID_AUTO, asconf_enable, CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW,
|
2014-09-06 19:12:14 +00:00
|
|
|
NULL, 0, sctp_sysctl_handle_asconf, "IU", SCTPCTL_ASCONF_ENABLE_DESC);
|
|
|
|
SCTP_UINT_SYSCTL(reconfig_enable, sctp_reconfig_enable, SCTPCTL_RECONFIG_ENABLE)
|
|
|
|
SCTP_UINT_SYSCTL(nrsack_enable, sctp_nrsack_enable, SCTPCTL_NRSACK_ENABLE)
|
|
|
|
SCTP_UINT_SYSCTL(pktdrop_enable, sctp_pktdrop_enable, SCTPCTL_PKTDROP_ENABLE)
|
|
|
|
SCTP_UINT_SYSCTL(peer_chkoh, sctp_peer_chunk_oh, SCTPCTL_PEER_CHKOH)
|
|
|
|
SCTP_UINT_SYSCTL(maxburst, sctp_max_burst_default, SCTPCTL_MAXBURST)
|
|
|
|
SCTP_UINT_SYSCTL(fr_maxburst, sctp_fr_max_burst_default, SCTPCTL_FRMAXBURST)
|
|
|
|
SCTP_UINT_SYSCTL(maxchunks, sctp_max_chunks_on_queue, SCTPCTL_MAXCHUNKS)
|
|
|
|
SCTP_UINT_SYSCTL(tcbhashsize, sctp_hashtblsize, SCTPCTL_TCBHASHSIZE)
|
|
|
|
SCTP_UINT_SYSCTL(pcbhashsize, sctp_pcbtblsize, SCTPCTL_PCBHASHSIZE)
|
|
|
|
SCTP_UINT_SYSCTL(min_split_point, sctp_min_split_point, SCTPCTL_MIN_SPLIT_POINT)
|
|
|
|
SCTP_UINT_SYSCTL(chunkscale, sctp_chunkscale, SCTPCTL_CHUNKSCALE)
|
|
|
|
SCTP_UINT_SYSCTL(delayed_sack_time, sctp_delayed_sack_time_default, SCTPCTL_DELAYED_SACK_TIME)
|
|
|
|
SCTP_UINT_SYSCTL(sack_freq, sctp_sack_freq_default, SCTPCTL_SACK_FREQ)
|
|
|
|
SCTP_UINT_SYSCTL(sys_resource, sctp_system_free_resc_limit, SCTPCTL_SYS_RESOURCE)
|
|
|
|
SCTP_UINT_SYSCTL(asoc_resource, sctp_asoc_free_resc_limit, SCTPCTL_ASOC_RESOURCE)
|
|
|
|
SCTP_UINT_SYSCTL(heartbeat_interval, sctp_heartbeat_interval_default, SCTPCTL_HEARTBEAT_INTERVAL)
|
|
|
|
SCTP_UINT_SYSCTL(pmtu_raise_time, sctp_pmtu_raise_time_default, SCTPCTL_PMTU_RAISE_TIME)
|
|
|
|
SCTP_UINT_SYSCTL(shutdown_guard_time, sctp_shutdown_guard_time_default, SCTPCTL_SHUTDOWN_GUARD_TIME)
|
|
|
|
SCTP_UINT_SYSCTL(secret_lifetime, sctp_secret_lifetime_default, SCTPCTL_SECRET_LIFETIME)
|
|
|
|
SCTP_UINT_SYSCTL(rto_max, sctp_rto_max_default, SCTPCTL_RTO_MAX)
|
|
|
|
SCTP_UINT_SYSCTL(rto_min, sctp_rto_min_default, SCTPCTL_RTO_MIN)
|
|
|
|
SCTP_UINT_SYSCTL(rto_initial, sctp_rto_initial_default, SCTPCTL_RTO_INITIAL)
|
|
|
|
SCTP_UINT_SYSCTL(init_rto_max, sctp_init_rto_max_default, SCTPCTL_INIT_RTO_MAX)
|
|
|
|
SCTP_UINT_SYSCTL(valid_cookie_life, sctp_valid_cookie_life_default, SCTPCTL_VALID_COOKIE_LIFE)
|
|
|
|
SCTP_UINT_SYSCTL(init_rtx_max, sctp_init_rtx_max_default, SCTPCTL_INIT_RTX_MAX)
|
|
|
|
SCTP_UINT_SYSCTL(assoc_rtx_max, sctp_assoc_rtx_max_default, SCTPCTL_ASSOC_RTX_MAX)
|
|
|
|
SCTP_UINT_SYSCTL(path_rtx_max, sctp_path_rtx_max_default, SCTPCTL_PATH_RTX_MAX)
|
|
|
|
SCTP_UINT_SYSCTL(path_pf_threshold, sctp_path_pf_threshold, SCTPCTL_PATH_PF_THRESHOLD)
|
|
|
|
SCTP_UINT_SYSCTL(add_more_on_output, sctp_add_more_threshold, SCTPCTL_ADD_MORE_ON_OUTPUT)
|
|
|
|
SCTP_UINT_SYSCTL(incoming_streams, sctp_nr_incoming_streams_default, SCTPCTL_INCOMING_STREAMS)
|
|
|
|
SCTP_UINT_SYSCTL(outgoing_streams, sctp_nr_outgoing_streams_default, SCTPCTL_OUTGOING_STREAMS)
|
|
|
|
SCTP_UINT_SYSCTL(cmt_on_off, sctp_cmt_on_off, SCTPCTL_CMT_ON_OFF)
|
|
|
|
SCTP_UINT_SYSCTL(cmt_use_dac, sctp_cmt_use_dac, SCTPCTL_CMT_USE_DAC)
|
|
|
|
SCTP_UINT_SYSCTL(cwnd_maxburst, sctp_use_cwnd_based_maxburst, SCTPCTL_CWND_MAXBURST)
|
|
|
|
SCTP_UINT_SYSCTL(nat_friendly, sctp_nat_friendly, SCTPCTL_NAT_FRIENDLY)
|
|
|
|
SCTP_UINT_SYSCTL(abc_l_var, sctp_L2_abc_variable, SCTPCTL_ABC_L_VAR)
|
|
|
|
SCTP_UINT_SYSCTL(max_chained_mbufs, sctp_mbuf_threshold_count, SCTPCTL_MAX_CHAINED_MBUFS)
|
|
|
|
SCTP_UINT_SYSCTL(do_sctp_drain, sctp_do_drain, SCTPCTL_DO_SCTP_DRAIN)
|
|
|
|
SCTP_UINT_SYSCTL(hb_max_burst, sctp_hb_maxburst, SCTPCTL_HB_MAX_BURST)
|
|
|
|
SCTP_UINT_SYSCTL(abort_at_limit, sctp_abort_if_one_2_one_hits_limit, SCTPCTL_ABORT_AT_LIMIT)
|
|
|
|
SCTP_UINT_SYSCTL(min_residual, sctp_min_residual, SCTPCTL_MIN_RESIDUAL)
|
|
|
|
SCTP_UINT_SYSCTL(max_retran_chunk, sctp_max_retran_chunk, SCTPCTL_MAX_RETRAN_CHUNK)
|
|
|
|
SCTP_UINT_SYSCTL(log_level, sctp_logging_level, SCTPCTL_LOGGING_LEVEL)
|
|
|
|
SCTP_UINT_SYSCTL(default_cc_module, sctp_default_cc_module, SCTPCTL_DEFAULT_CC_MODULE)
|
|
|
|
SCTP_UINT_SYSCTL(default_ss_module, sctp_default_ss_module, SCTPCTL_DEFAULT_SS_MODULE)
|
|
|
|
SCTP_UINT_SYSCTL(default_frag_interleave, sctp_default_frag_interleave, SCTPCTL_DEFAULT_FRAG_INTERLEAVE)
|
|
|
|
SCTP_UINT_SYSCTL(mobility_base, sctp_mobility_base, SCTPCTL_MOBILITY_BASE)
|
|
|
|
SCTP_UINT_SYSCTL(mobility_fasthandoff, sctp_mobility_fasthandoff, SCTPCTL_MOBILITY_FASTHANDOFF)
|
2007-09-13 14:43:54 +00:00
|
|
|
#if defined(SCTP_LOCAL_TRACE_BUF)
|
2014-09-07 07:49:49 +00:00
|
|
|
SYSCTL_PROC(_net_inet_sctp, OID_AUTO, log, CTLFLAG_VNET | CTLTYPE_STRUCT | CTLFLAG_RD,
|
2014-09-06 19:12:14 +00:00
|
|
|
NULL, 0, sctp_sysctl_handle_trace_log, "S,sctplog", "SCTP logging (struct sctp_log)");
|
2014-09-07 07:49:49 +00:00
|
|
|
SYSCTL_PROC(_net_inet_sctp, OID_AUTO, clear_trace, CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW,
|
2014-09-06 19:12:14 +00:00
|
|
|
NULL, 0, sctp_sysctl_handle_trace_log_clear, "IU", "Clear SCTP Logging buffer");
|
2007-09-13 14:43:54 +00:00
|
|
|
#endif
|
2014-09-07 07:49:49 +00:00
|
|
|
SYSCTL_PROC(_net_inet_sctp, OID_AUTO, udp_tunneling_port, CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW,
|
2014-09-06 19:12:14 +00:00
|
|
|
NULL, 0, sctp_sysctl_handle_udp_tunneling, "IU", SCTPCTL_UDP_TUNNELING_PORT_DESC);
|
|
|
|
SCTP_UINT_SYSCTL(enable_sack_immediately, sctp_enable_sack_immediately, SCTPCTL_SACK_IMMEDIATELY_ENABLE)
|
|
|
|
SCTP_UINT_SYSCTL(nat_friendly_init, sctp_inits_include_nat_friendly, SCTPCTL_NAT_FRIENDLY_INITS)
|
|
|
|
SCTP_UINT_SYSCTL(vtag_time_wait, sctp_vtag_time_wait, SCTPCTL_TIME_WAIT)
|
|
|
|
SCTP_UINT_SYSCTL(buffer_splitting, sctp_buffer_splitting, SCTPCTL_BUFFER_SPLITTING)
|
|
|
|
SCTP_UINT_SYSCTL(initial_cwnd, sctp_initial_cwnd, SCTPCTL_INITIAL_CWND)
|
|
|
|
SCTP_UINT_SYSCTL(rttvar_bw, sctp_rttvar_bw, SCTPCTL_RTTVAR_BW)
|
|
|
|
SCTP_UINT_SYSCTL(rttvar_rtt, sctp_rttvar_rtt, SCTPCTL_RTTVAR_RTT)
|
|
|
|
SCTP_UINT_SYSCTL(rttvar_eqret, sctp_rttvar_eqret, SCTPCTL_RTTVAR_EQRET)
|
|
|
|
SCTP_UINT_SYSCTL(rttvar_steady_step, sctp_steady_step, SCTPCTL_RTTVAR_STEADYS)
|
|
|
|
SCTP_UINT_SYSCTL(use_dcccecn, sctp_use_dccc_ecn, SCTPCTL_RTTVAR_DCCCECN)
|
|
|
|
SCTP_UINT_SYSCTL(blackhole, sctp_blackhole, SCTPCTL_BLACKHOLE)
|
|
|
|
SCTP_UINT_SYSCTL(diag_info_code, sctp_diag_info_code, SCTPCTL_DIAG_INFO_CODE)
|
2007-03-15 11:27:14 +00:00
|
|
|
#ifdef SCTP_DEBUG
|
2014-09-06 19:12:14 +00:00
|
|
|
SCTP_UINT_SYSCTL(debug, sctp_debug_on, SCTPCTL_DEBUG)
|
2011-02-18 20:30:58 +00:00
|
|
|
#endif
|
2012-06-25 17:15:09 +00:00
|
|
|
#if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
|
2014-09-06 19:12:14 +00:00
|
|
|
SCTP_UINT_SYSCTL(output_unlocked, sctp_output_unlocked, SCTPCTL_OUTPUT_UNLOCKED)
|
2008-06-14 07:58:05 +00:00
|
|
|
#endif
|
2014-09-07 07:49:49 +00:00
|
|
|
SYSCTL_PROC(_net_inet_sctp, OID_AUTO, stats, CTLFLAG_VNET | CTLTYPE_STRUCT | CTLFLAG_RW,
|
2014-09-06 19:12:14 +00:00
|
|
|
NULL, 0, sctp_sysctl_handle_stats, "S,sctpstat", "SCTP statistics (struct sctp_stat)");
|
2014-09-07 07:49:49 +00:00
|
|
|
SYSCTL_PROC(_net_inet_sctp, OID_AUTO, assoclist, CTLFLAG_VNET | CTLTYPE_OPAQUE | CTLFLAG_RD,
|
2014-09-06 19:12:14 +00:00
|
|
|
NULL, 0, sctp_sysctl_handle_assoclist, "S,xassoc", "List of active SCTP associations");
|