142551e99SRandall Stewart /*- 251369649SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 351369649SPedro F. Giffuni * 4b1006367SRandall Stewart * Copyright (c) 2007, by Cisco Systems, Inc. All rights reserved. 5807aad63SMichael Tuexen * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 6807aad63SMichael Tuexen * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. 742551e99SRandall Stewart * 842551e99SRandall Stewart * Redistribution and use in source and binary forms, with or without 942551e99SRandall Stewart * modification, are permitted provided that the following conditions are met: 1042551e99SRandall Stewart * 1142551e99SRandall Stewart * a) Redistributions of source code must retain the above copyright notice, 1242551e99SRandall Stewart * this list of conditions and the following disclaimer. 1342551e99SRandall Stewart * 1442551e99SRandall Stewart * b) Redistributions in binary form must reproduce the above copyright 1542551e99SRandall Stewart * notice, this list of conditions and the following disclaimer in 1642551e99SRandall Stewart * the documentation and/or other materials provided with the distribution. 1742551e99SRandall Stewart * 1842551e99SRandall Stewart * c) Neither the name of Cisco Systems, Inc. nor the names of its 1942551e99SRandall Stewart * contributors may be used to endorse or promote products derived 2042551e99SRandall Stewart * from this software without specific prior written permission. 2142551e99SRandall Stewart * 2242551e99SRandall Stewart * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2342551e99SRandall Stewart * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 2442551e99SRandall Stewart * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2542551e99SRandall Stewart * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 2642551e99SRandall Stewart * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2742551e99SRandall Stewart * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2842551e99SRandall Stewart * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2942551e99SRandall Stewart * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 3042551e99SRandall Stewart * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 3142551e99SRandall Stewart * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 3242551e99SRandall Stewart * THE POSSIBILITY OF SUCH DAMAGE. 3342551e99SRandall Stewart */ 3442551e99SRandall Stewart 3542551e99SRandall Stewart #include <sys/cdefs.h> 3642551e99SRandall Stewart __FBSDID("$FreeBSD$"); 3742551e99SRandall Stewart 3842551e99SRandall Stewart #include <netinet/sctp_os.h> 39b3f1ea41SRandall Stewart #include <netinet/sctp.h> 4042551e99SRandall Stewart #include <netinet/sctp_constants.h> 4142551e99SRandall Stewart #include <netinet/sctp_sysctl.h> 4242551e99SRandall Stewart #include <netinet/sctp_pcb.h> 4342551e99SRandall Stewart #include <netinet/sctputil.h> 44d61a0ae0SRandall Stewart #include <netinet/sctp_output.h> 45ff014514SRandall Stewart #include <sys/smp.h> 4676031b19SMichael Tuexen #include <sys/sysctl.h> 4776031b19SMichael Tuexen 4876031b19SMichael Tuexen FEATURE(sctp, "Stream Control Transmission Protocol"); 49b3f1ea41SRandall Stewart 5042551e99SRandall Stewart /* 5142551e99SRandall Stewart * sysctl tunable variables 5242551e99SRandall Stewart */ 535e54f665SRandall Stewart 54b3f1ea41SRandall Stewart void 55b3f1ea41SRandall Stewart sctp_init_sysctls() 56b3f1ea41SRandall Stewart { 57b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_sendspace) = SCTPCTL_MAXDGRAM_DEFAULT; 58b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_recvspace) = SCTPCTL_RECVSPACE_DEFAULT; 59b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_auto_asconf) = SCTPCTL_AUTOASCONF_DEFAULT; 60b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_multiple_asconfs) = SCTPCTL_MULTIPLEASCONFS_DEFAULT; 61b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_ecn_enable) = SCTPCTL_ECN_ENABLE_DEFAULT; 62dd973b0eSMichael Tuexen SCTP_BASE_SYSCTL(sctp_pr_enable) = SCTPCTL_PR_ENABLE_DEFAULT; 6397a0ca5bSMichael Tuexen SCTP_BASE_SYSCTL(sctp_auth_enable) = SCTPCTL_AUTH_ENABLE_DEFAULT; 64c79bec9cSMichael Tuexen SCTP_BASE_SYSCTL(sctp_asconf_enable) = SCTPCTL_ASCONF_ENABLE_DEFAULT; 65317e00efSMichael Tuexen SCTP_BASE_SYSCTL(sctp_reconfig_enable) = SCTPCTL_RECONFIG_ENABLE_DEFAULT; 66caea9879SMichael Tuexen SCTP_BASE_SYSCTL(sctp_nrsack_enable) = SCTPCTL_NRSACK_ENABLE_DEFAULT; 67cb9b8e6fSMichael Tuexen SCTP_BASE_SYSCTL(sctp_pktdrop_enable) = SCTPCTL_PKTDROP_ENABLE_DEFAULT; 68b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_peer_chunk_oh) = SCTPCTL_PEER_CHKOH_DEFAULT; 69b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_max_burst_default) = SCTPCTL_MAXBURST_DEFAULT; 70899288aeSRandall Stewart SCTP_BASE_SYSCTL(sctp_fr_max_burst_default) = SCTPCTL_FRMAXBURST_DEFAULT; 71b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue) = SCTPCTL_MAXCHUNKS_DEFAULT; 72b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_hashtblsize) = SCTPCTL_TCBHASHSIZE_DEFAULT; 73b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_pcbtblsize) = SCTPCTL_PCBHASHSIZE_DEFAULT; 74b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_min_split_point) = SCTPCTL_MIN_SPLIT_POINT_DEFAULT; 75b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_chunkscale) = SCTPCTL_CHUNKSCALE_DEFAULT; 76b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default) = SCTPCTL_DELAYED_SACK_TIME_DEFAULT; 77b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_sack_freq_default) = SCTPCTL_SACK_FREQ_DEFAULT; 78b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_system_free_resc_limit) = SCTPCTL_SYS_RESOURCE_DEFAULT; 79b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit) = SCTPCTL_ASOC_RESOURCE_DEFAULT; 80b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default) = SCTPCTL_HEARTBEAT_INTERVAL_DEFAULT; 81b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default) = SCTPCTL_PMTU_RAISE_TIME_DEFAULT; 82b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default) = SCTPCTL_SHUTDOWN_GUARD_TIME_DEFAULT; 83b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_secret_lifetime_default) = SCTPCTL_SECRET_LIFETIME_DEFAULT; 84b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_rto_max_default) = SCTPCTL_RTO_MAX_DEFAULT; 85b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_rto_min_default) = SCTPCTL_RTO_MIN_DEFAULT; 86b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_rto_initial_default) = SCTPCTL_RTO_INITIAL_DEFAULT; 87b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_init_rto_max_default) = SCTPCTL_INIT_RTO_MAX_DEFAULT; 88b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default) = SCTPCTL_VALID_COOKIE_LIFE_DEFAULT; 89b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_init_rtx_max_default) = SCTPCTL_INIT_RTX_MAX_DEFAULT; 90b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default) = SCTPCTL_ASSOC_RTX_MAX_DEFAULT; 91b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_path_rtx_max_default) = SCTPCTL_PATH_RTX_MAX_DEFAULT; 92ca85e948SMichael Tuexen SCTP_BASE_SYSCTL(sctp_path_pf_threshold) = SCTPCTL_PATH_PF_THRESHOLD_DEFAULT; 93b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_add_more_threshold) = SCTPCTL_ADD_MORE_ON_OUTPUT_DEFAULT; 94ee1ccd92SMichael Tuexen SCTP_BASE_SYSCTL(sctp_nr_incoming_streams_default) = SCTPCTL_INCOMING_STREAMS_DEFAULT; 95b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default) = SCTPCTL_OUTGOING_STREAMS_DEFAULT; 96b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_cmt_on_off) = SCTPCTL_CMT_ON_OFF_DEFAULT; 97b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_cmt_use_dac) = SCTPCTL_CMT_USE_DAC_DEFAULT; 98b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst) = SCTPCTL_CWND_MAXBURST_DEFAULT; 99b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_nat_friendly) = SCTPCTL_NAT_FRIENDLY_DEFAULT; 100b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_L2_abc_variable) = SCTPCTL_ABC_L_VAR_DEFAULT; 101b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count) = SCTPCTL_MAX_CHAINED_MBUFS_DEFAULT; 102b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_do_drain) = SCTPCTL_DO_SCTP_DRAIN_DEFAULT; 103b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_hb_maxburst) = SCTPCTL_HB_MAX_BURST_DEFAULT; 104b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit) = SCTPCTL_ABORT_AT_LIMIT_DEFAULT; 105b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_min_residual) = SCTPCTL_MIN_RESIDUAL_DEFAULT; 106b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_max_retran_chunk) = SCTPCTL_MAX_RETRAN_CHUNK_DEFAULT; 107b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_logging_level) = SCTPCTL_LOGGING_LEVEL_DEFAULT; 108b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_default_cc_module) = SCTPCTL_DEFAULT_CC_MODULE_DEFAULT; 109f7a77f6fSMichael Tuexen SCTP_BASE_SYSCTL(sctp_default_ss_module) = SCTPCTL_DEFAULT_SS_MODULE_DEFAULT; 110b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_default_frag_interleave) = SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DEFAULT; 111b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_mobility_base) = SCTPCTL_MOBILITY_BASE_DEFAULT; 112b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff) = SCTPCTL_MOBILITY_FASTHANDOFF_DEFAULT; 113a16ccdceSRandall Stewart SCTP_BASE_SYSCTL(sctp_vtag_time_wait) = SCTPCTL_TIME_WAIT_DEFAULT; 11425a2a187SMichael Tuexen SCTP_BASE_SYSCTL(sctp_buffer_splitting) = SCTPCTL_BUFFER_SPLITTING_DEFAULT; 115dcfc0625SMichael Tuexen SCTP_BASE_SYSCTL(sctp_initial_cwnd) = SCTPCTL_INITIAL_CWND_DEFAULT; 116299108c5SRandall Stewart SCTP_BASE_SYSCTL(sctp_rttvar_bw) = SCTPCTL_RTTVAR_BW_DEFAULT; 117299108c5SRandall Stewart SCTP_BASE_SYSCTL(sctp_rttvar_rtt) = SCTPCTL_RTTVAR_RTT_DEFAULT; 118299108c5SRandall Stewart SCTP_BASE_SYSCTL(sctp_rttvar_eqret) = SCTPCTL_RTTVAR_EQRET_DEFAULT; 119f79aab18SRandall Stewart SCTP_BASE_SYSCTL(sctp_steady_step) = SCTPCTL_RTTVAR_STEADYS_DEFAULT; 120f79aab18SRandall Stewart SCTP_BASE_SYSCTL(sctp_use_dccc_ecn) = SCTPCTL_RTTVAR_DCCCECN_DEFAULT; 121c58e60beSMichael Tuexen SCTP_BASE_SYSCTL(sctp_blackhole) = SCTPCTL_BLACKHOLE_DEFAULT; 122ae7cc6c9SMichael Tuexen SCTP_BASE_SYSCTL(sctp_sendall_limit) = SCTPCTL_SENDALL_LIMIT_DEFAULT; 123ff1ffd74SMichael Tuexen SCTP_BASE_SYSCTL(sctp_diag_info_code) = SCTPCTL_DIAG_INFO_CODE_DEFAULT; 124b27a6b7dSRandall Stewart #if defined(SCTP_LOCAL_TRACE_BUF) 125b3f1ea41SRandall Stewart memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log)); 126b27a6b7dSRandall Stewart #endif 127b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = SCTPCTL_UDP_TUNNELING_PORT_DEFAULT; 128b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_enable_sack_immediately) = SCTPCTL_SACK_IMMEDIATELY_ENABLE_DEFAULT; 129bf3d5177SMichael Tuexen SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly) = SCTPCTL_NAT_FRIENDLY_INITS_DEFAULT; 130b3f1ea41SRandall Stewart #if defined(SCTP_DEBUG) 131b3f1ea41SRandall Stewart SCTP_BASE_SYSCTL(sctp_debug_on) = SCTPCTL_DEBUG_DEFAULT; 13242551e99SRandall Stewart #endif 133b3f1ea41SRandall Stewart } 134d61a0ae0SRandall Stewart 135d61a0ae0SRandall Stewart /* It returns an upper limit. No filtering is done here */ 136d61a0ae0SRandall Stewart static unsigned int 137f47f328dSMichael Tuexen sctp_sysctl_number_of_addresses(struct sctp_inpcb *inp) 138d61a0ae0SRandall Stewart { 1397215cc1bSMichael Tuexen unsigned int cnt; 140d61a0ae0SRandall Stewart struct sctp_vrf *vrf; 141d61a0ae0SRandall Stewart struct sctp_ifn *sctp_ifn; 142d61a0ae0SRandall Stewart struct sctp_ifa *sctp_ifa; 143d61a0ae0SRandall Stewart struct sctp_laddr *laddr; 144d61a0ae0SRandall Stewart 145d61a0ae0SRandall Stewart cnt = 0; 146e7e65008SMichael Tuexen /* neither Mac OS X nor FreeBSD support multiple routing functions */ 147d61a0ae0SRandall Stewart if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) { 148d61a0ae0SRandall Stewart return (0); 149d61a0ae0SRandall Stewart } 150d61a0ae0SRandall Stewart if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { 151d61a0ae0SRandall Stewart LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) { 152d61a0ae0SRandall Stewart LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) { 153e6194c2eSMichael Tuexen switch (sctp_ifa->address.sa.sa_family) { 154e6194c2eSMichael Tuexen #ifdef INET 155e6194c2eSMichael Tuexen case AF_INET: 156e6194c2eSMichael Tuexen #endif 157e6194c2eSMichael Tuexen #ifdef INET6 158e6194c2eSMichael Tuexen case AF_INET6: 159e6194c2eSMichael Tuexen #endif 160d61a0ae0SRandall Stewart cnt++; 161e6194c2eSMichael Tuexen break; 162e6194c2eSMichael Tuexen default: 163e6194c2eSMichael Tuexen break; 164d61a0ae0SRandall Stewart } 165d61a0ae0SRandall Stewart } 166d61a0ae0SRandall Stewart } 167d61a0ae0SRandall Stewart } else { 168d61a0ae0SRandall Stewart LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) { 169e6194c2eSMichael Tuexen switch (laddr->ifa->address.sa.sa_family) { 170e6194c2eSMichael Tuexen #ifdef INET 171e6194c2eSMichael Tuexen case AF_INET: 172e6194c2eSMichael Tuexen #endif 173e6194c2eSMichael Tuexen #ifdef INET6 174e6194c2eSMichael Tuexen case AF_INET6: 175e6194c2eSMichael Tuexen #endif 176d61a0ae0SRandall Stewart cnt++; 177e6194c2eSMichael Tuexen break; 178e6194c2eSMichael Tuexen default: 179e6194c2eSMichael Tuexen break; 180d61a0ae0SRandall Stewart } 181d61a0ae0SRandall Stewart } 182d61a0ae0SRandall Stewart } 183d61a0ae0SRandall Stewart return (cnt); 184d61a0ae0SRandall Stewart } 185d61a0ae0SRandall Stewart 186d61a0ae0SRandall Stewart static int 187f47f328dSMichael Tuexen sctp_sysctl_copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sysctl_req *req) 188d61a0ae0SRandall Stewart { 189d61a0ae0SRandall Stewart struct sctp_ifn *sctp_ifn; 190d61a0ae0SRandall Stewart struct sctp_ifa *sctp_ifa; 19129a84317SJohn Baldwin int loopback_scope; 19229a84317SJohn Baldwin #ifdef INET 19329a84317SJohn Baldwin int ipv4_local_scope; 19429a84317SJohn Baldwin int ipv4_addr_legal; 19529a84317SJohn Baldwin #endif 19629a84317SJohn Baldwin #ifdef INET6 19729a84317SJohn Baldwin int local_scope, site_scope; 19829a84317SJohn Baldwin int ipv6_addr_legal; 19929a84317SJohn Baldwin #endif 200d61a0ae0SRandall Stewart struct sctp_vrf *vrf; 201d61a0ae0SRandall Stewart struct xsctp_laddr xladdr; 202d61a0ae0SRandall Stewart struct sctp_laddr *laddr; 203d61a0ae0SRandall Stewart int error; 204d61a0ae0SRandall Stewart 205d61a0ae0SRandall Stewart /* Turn on all the appropriate scope */ 206*2486a7c0SMichael Tuexen if (stcb != NULL) { 207d61a0ae0SRandall Stewart /* use association specific values */ 208a1cb341bSMichael Tuexen loopback_scope = stcb->asoc.scope.loopback_scope; 20929a84317SJohn Baldwin #ifdef INET 210a1cb341bSMichael Tuexen ipv4_local_scope = stcb->asoc.scope.ipv4_local_scope; 21129a84317SJohn Baldwin ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal; 21229a84317SJohn Baldwin #endif 21329a84317SJohn Baldwin #ifdef INET6 214a1cb341bSMichael Tuexen local_scope = stcb->asoc.scope.local_scope; 215a1cb341bSMichael Tuexen site_scope = stcb->asoc.scope.site_scope; 216a1cb341bSMichael Tuexen ipv6_addr_legal = stcb->asoc.scope.ipv6_addr_legal; 21729a84317SJohn Baldwin #endif 218d61a0ae0SRandall Stewart } else { 219a1cb341bSMichael Tuexen /* Use generic values for endpoints. */ 220d61a0ae0SRandall Stewart loopback_scope = 1; 22129a84317SJohn Baldwin #ifdef INET 222d61a0ae0SRandall Stewart ipv4_local_scope = 1; 22329a84317SJohn Baldwin #endif 22429a84317SJohn Baldwin #ifdef INET6 225d61a0ae0SRandall Stewart local_scope = 1; 226d61a0ae0SRandall Stewart site_scope = 1; 227*2486a7c0SMichael Tuexen #endif 228*2486a7c0SMichael Tuexen if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { 229*2486a7c0SMichael Tuexen #ifdef INET6 230d61a0ae0SRandall Stewart ipv6_addr_legal = 1; 231*2486a7c0SMichael Tuexen #endif 232*2486a7c0SMichael Tuexen #ifdef INET 233*2486a7c0SMichael Tuexen if (SCTP_IPV6_V6ONLY(inp)) { 234*2486a7c0SMichael Tuexen ipv4_addr_legal = 0; 235*2486a7c0SMichael Tuexen } else { 236*2486a7c0SMichael Tuexen ipv4_addr_legal = 1; 237*2486a7c0SMichael Tuexen } 238*2486a7c0SMichael Tuexen #endif 239*2486a7c0SMichael Tuexen } else { 240*2486a7c0SMichael Tuexen #ifdef INET6 241d61a0ae0SRandall Stewart ipv6_addr_legal = 0; 24229a84317SJohn Baldwin #endif 243*2486a7c0SMichael Tuexen #ifdef INET 244*2486a7c0SMichael Tuexen ipv4_addr_legal = 1; 245*2486a7c0SMichael Tuexen #endif 246*2486a7c0SMichael Tuexen } 247d61a0ae0SRandall Stewart } 248d61a0ae0SRandall Stewart 249*2486a7c0SMichael Tuexen /* Neither Mac OS X nor FreeBSD support multiple routing functions. */ 250d61a0ae0SRandall Stewart if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) { 2515f26a41dSRandall Stewart SCTP_INP_RUNLOCK(inp); 2525f26a41dSRandall Stewart SCTP_INP_INFO_RUNLOCK(); 253*2486a7c0SMichael Tuexen return (ENOENT); 254d61a0ae0SRandall Stewart } 255d61a0ae0SRandall Stewart if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { 256d61a0ae0SRandall Stewart LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) { 257*2486a7c0SMichael Tuexen if ((loopback_scope == 0) && SCTP_IFN_IS_IFT_LOOP(sctp_ifn)) { 258*2486a7c0SMichael Tuexen /* Skip loopback if loopback_scope not set. */ 259d61a0ae0SRandall Stewart continue; 260*2486a7c0SMichael Tuexen } 261d61a0ae0SRandall Stewart LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) { 262*2486a7c0SMichael Tuexen if (stcb != NULL) { 263d61a0ae0SRandall Stewart /* 264*2486a7c0SMichael Tuexen * Ignore if blacklisted at 265*2486a7c0SMichael Tuexen * association level. 266d61a0ae0SRandall Stewart */ 267*2486a7c0SMichael Tuexen if (sctp_is_addr_restricted(stcb, sctp_ifa)) { 268d61a0ae0SRandall Stewart continue; 269d61a0ae0SRandall Stewart } 270*2486a7c0SMichael Tuexen } 2715e2c2d87SRandall Stewart switch (sctp_ifa->address.sa.sa_family) { 272e6194c2eSMichael Tuexen #ifdef INET 2735e2c2d87SRandall Stewart case AF_INET: 2745e2c2d87SRandall Stewart if (ipv4_addr_legal) { 275d61a0ae0SRandall Stewart struct sockaddr_in *sin; 276d61a0ae0SRandall Stewart 27724aaac8dSMichael Tuexen sin = &sctp_ifa->address.sin; 278*2486a7c0SMichael Tuexen if (sin->sin_addr.s_addr == 0) { 279d61a0ae0SRandall Stewart continue; 280*2486a7c0SMichael Tuexen } 2816ba22f19SMichael Tuexen if (prison_check_ip4(inp->ip_inp.inp.inp_cred, 2826ba22f19SMichael Tuexen &sin->sin_addr) != 0) { 2836ba22f19SMichael Tuexen continue; 2846ba22f19SMichael Tuexen } 285*2486a7c0SMichael Tuexen if ((ipv4_local_scope == 0) && (IN4_ISPRIVATE_ADDRESS(&sin->sin_addr))) { 286d61a0ae0SRandall Stewart continue; 287*2486a7c0SMichael Tuexen } 2885e2c2d87SRandall Stewart } else { 2895e2c2d87SRandall Stewart continue; 2905e2c2d87SRandall Stewart } 2915e2c2d87SRandall Stewart break; 292e6194c2eSMichael Tuexen #endif 2935e2c2d87SRandall Stewart #ifdef INET6 2945e2c2d87SRandall Stewart case AF_INET6: 2955e2c2d87SRandall Stewart if (ipv6_addr_legal) { 296d61a0ae0SRandall Stewart struct sockaddr_in6 *sin6; 297d61a0ae0SRandall Stewart 29824aaac8dSMichael Tuexen sin6 = &sctp_ifa->address.sin6; 299*2486a7c0SMichael Tuexen if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { 300d61a0ae0SRandall Stewart continue; 301*2486a7c0SMichael Tuexen } 3026ba22f19SMichael Tuexen if (prison_check_ip6(inp->ip_inp.inp.inp_cred, 3036ba22f19SMichael Tuexen &sin6->sin6_addr) != 0) { 3046ba22f19SMichael Tuexen continue; 3056ba22f19SMichael Tuexen } 306d61a0ae0SRandall Stewart if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { 307*2486a7c0SMichael Tuexen if (local_scope == 0) { 308d61a0ae0SRandall Stewart continue; 309d61a0ae0SRandall Stewart } 310*2486a7c0SMichael Tuexen } 311*2486a7c0SMichael Tuexen if ((site_scope == 0) && (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr))) { 312d61a0ae0SRandall Stewart continue; 313*2486a7c0SMichael Tuexen } 3145e2c2d87SRandall Stewart } else { 315d61a0ae0SRandall Stewart continue; 3165e2c2d87SRandall Stewart } 3175e2c2d87SRandall Stewart break; 3185e2c2d87SRandall Stewart #endif 3195e2c2d87SRandall Stewart default: 3205e2c2d87SRandall Stewart continue; 3215e2c2d87SRandall Stewart } 322851b7298SRandall Stewart memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr)); 323d61a0ae0SRandall Stewart memcpy((void *)&xladdr.address, (const void *)&sctp_ifa->address, sizeof(union sctp_sockstore)); 324d61a0ae0SRandall Stewart SCTP_INP_RUNLOCK(inp); 325d61a0ae0SRandall Stewart SCTP_INP_INFO_RUNLOCK(); 326d61a0ae0SRandall Stewart error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr)); 327*2486a7c0SMichael Tuexen if (error != 0) { 328d61a0ae0SRandall Stewart return (error); 329851b7298SRandall Stewart } else { 330d61a0ae0SRandall Stewart SCTP_INP_INFO_RLOCK(); 331d61a0ae0SRandall Stewart SCTP_INP_RLOCK(inp); 332d61a0ae0SRandall Stewart } 333d61a0ae0SRandall Stewart } 334d61a0ae0SRandall Stewart } 335d61a0ae0SRandall Stewart } else { 336d61a0ae0SRandall Stewart LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) { 337d61a0ae0SRandall Stewart /* ignore if blacklisted at association level */ 338*2486a7c0SMichael Tuexen if (stcb != NULL && sctp_is_addr_restricted(stcb, laddr->ifa)) 339d61a0ae0SRandall Stewart continue; 340851b7298SRandall Stewart memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr)); 341d61a0ae0SRandall Stewart memcpy((void *)&xladdr.address, (const void *)&laddr->ifa->address, sizeof(union sctp_sockstore)); 342851b7298SRandall Stewart xladdr.start_time.tv_sec = (uint32_t)laddr->start_time.tv_sec; 343851b7298SRandall Stewart xladdr.start_time.tv_usec = (uint32_t)laddr->start_time.tv_usec; 344d61a0ae0SRandall Stewart SCTP_INP_RUNLOCK(inp); 345d61a0ae0SRandall Stewart SCTP_INP_INFO_RUNLOCK(); 346d61a0ae0SRandall Stewart error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr)); 347*2486a7c0SMichael Tuexen if (error != 0) { 348d61a0ae0SRandall Stewart return (error); 349851b7298SRandall Stewart } else { 350d61a0ae0SRandall Stewart SCTP_INP_INFO_RLOCK(); 351d61a0ae0SRandall Stewart SCTP_INP_RLOCK(inp); 352d61a0ae0SRandall Stewart } 353d61a0ae0SRandall Stewart } 354d61a0ae0SRandall Stewart } 355851b7298SRandall Stewart memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr)); 356d61a0ae0SRandall Stewart xladdr.last = 1; 3575f26a41dSRandall Stewart SCTP_INP_RUNLOCK(inp); 3585f26a41dSRandall Stewart SCTP_INP_INFO_RUNLOCK(); 359d61a0ae0SRandall Stewart error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr)); 3605f26a41dSRandall Stewart 361*2486a7c0SMichael Tuexen if (error != 0) { 362d61a0ae0SRandall Stewart return (error); 363851b7298SRandall Stewart } else { 3645f26a41dSRandall Stewart SCTP_INP_INFO_RLOCK(); 3655f26a41dSRandall Stewart SCTP_INP_RLOCK(inp); 366d61a0ae0SRandall Stewart return (0); 367d61a0ae0SRandall Stewart } 3685f26a41dSRandall Stewart } 369d61a0ae0SRandall Stewart 37042551e99SRandall Stewart /* 37142551e99SRandall Stewart * sysctl functions 37242551e99SRandall Stewart */ 37342551e99SRandall Stewart static int 374f47f328dSMichael Tuexen sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS) 37542551e99SRandall Stewart { 37642551e99SRandall Stewart unsigned int number_of_endpoints; 37742551e99SRandall Stewart unsigned int number_of_local_addresses; 37842551e99SRandall Stewart unsigned int number_of_associations; 37942551e99SRandall Stewart unsigned int number_of_remote_addresses; 38042551e99SRandall Stewart unsigned int n; 38142551e99SRandall Stewart int error; 38242551e99SRandall Stewart struct sctp_inpcb *inp; 38342551e99SRandall Stewart struct sctp_tcb *stcb; 38442551e99SRandall Stewart struct sctp_nets *net; 38542551e99SRandall Stewart struct xsctp_inpcb xinpcb; 38642551e99SRandall Stewart struct xsctp_tcb xstcb; 38742551e99SRandall Stewart struct xsctp_raddr xraddr; 3888ce4a9a2SRandall Stewart struct socket *so; 38942551e99SRandall Stewart 39042551e99SRandall Stewart number_of_endpoints = 0; 39142551e99SRandall Stewart number_of_local_addresses = 0; 39242551e99SRandall Stewart number_of_associations = 0; 39342551e99SRandall Stewart number_of_remote_addresses = 0; 39442551e99SRandall Stewart 39542551e99SRandall Stewart SCTP_INP_INFO_RLOCK(); 396f47f328dSMichael Tuexen if (req->oldptr == NULL) { 397b3f1ea41SRandall Stewart LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) { 39842551e99SRandall Stewart SCTP_INP_RLOCK(inp); 39942551e99SRandall Stewart number_of_endpoints++; 400f47f328dSMichael Tuexen number_of_local_addresses += sctp_sysctl_number_of_addresses(inp); 40142551e99SRandall Stewart LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) { 40242551e99SRandall Stewart number_of_associations++; 403f47f328dSMichael Tuexen number_of_local_addresses += sctp_sysctl_number_of_addresses(inp); 40442551e99SRandall Stewart TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { 40542551e99SRandall Stewart number_of_remote_addresses++; 40642551e99SRandall Stewart } 40742551e99SRandall Stewart } 40842551e99SRandall Stewart SCTP_INP_RUNLOCK(inp); 40942551e99SRandall Stewart } 41042551e99SRandall Stewart SCTP_INP_INFO_RUNLOCK(); 41142551e99SRandall Stewart n = (number_of_endpoints + 1) * sizeof(struct xsctp_inpcb) + 412d61a0ae0SRandall Stewart (number_of_local_addresses + number_of_endpoints + number_of_associations) * sizeof(struct xsctp_laddr) + 413d61a0ae0SRandall Stewart (number_of_associations + number_of_endpoints) * sizeof(struct xsctp_tcb) + 414d61a0ae0SRandall Stewart (number_of_remote_addresses + number_of_associations) * sizeof(struct xsctp_raddr); 415d61a0ae0SRandall Stewart 41642551e99SRandall Stewart /* request some more memory than needed */ 41742551e99SRandall Stewart req->oldidx = (n + n / 8); 41860990c0cSMichael Tuexen return (0); 41942551e99SRandall Stewart } 420f47f328dSMichael Tuexen if (req->newptr != NULL) { 42142551e99SRandall Stewart SCTP_INP_INFO_RUNLOCK(); 422c4739e2fSRandall Stewart SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_SYSCTL, EPERM); 42360990c0cSMichael Tuexen return (EPERM); 42442551e99SRandall Stewart } 42579db6fe7SMark Johnston memset(&xinpcb, 0, sizeof(xinpcb)); 42679db6fe7SMark Johnston memset(&xstcb, 0, sizeof(xstcb)); 42779db6fe7SMark Johnston memset(&xraddr, 0, sizeof(xraddr)); 428b3f1ea41SRandall Stewart LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) { 42942551e99SRandall Stewart SCTP_INP_RLOCK(inp); 4308ce4a9a2SRandall Stewart if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) { 4318ce4a9a2SRandall Stewart /* if its allgone it is being freed - skip it */ 4328ce4a9a2SRandall Stewart goto skip; 4338ce4a9a2SRandall Stewart } 43442551e99SRandall Stewart xinpcb.last = 0; 43542551e99SRandall Stewart xinpcb.local_port = ntohs(inp->sctp_lport); 43642551e99SRandall Stewart xinpcb.flags = inp->sctp_flags; 4376be15a24SMichael Tuexen xinpcb.features = inp->sctp_features; 43842551e99SRandall Stewart xinpcb.total_sends = inp->total_sends; 43942551e99SRandall Stewart xinpcb.total_recvs = inp->total_recvs; 44042551e99SRandall Stewart xinpcb.total_nospaces = inp->total_nospaces; 44117205eccSRandall Stewart xinpcb.fragmentation_point = inp->sctp_frag_point; 4423a20f06aSBrooks Davis xinpcb.socket = (uintptr_t)inp->sctp_socket; 4438ce4a9a2SRandall Stewart so = inp->sctp_socket; 4448ce4a9a2SRandall Stewart if ((so == NULL) || 4455d08768aSMichael Tuexen (!SCTP_IS_LISTENING(inp)) || 446851b7298SRandall Stewart (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) { 447851b7298SRandall Stewart xinpcb.qlen = 0; 448851b7298SRandall Stewart xinpcb.maxqlen = 0; 449851b7298SRandall Stewart } else { 450779f106aSGleb Smirnoff xinpcb.qlen = so->sol_qlen; 451779f106aSGleb Smirnoff xinpcb.qlen_old = so->sol_qlen > USHRT_MAX ? 452779f106aSGleb Smirnoff USHRT_MAX : (uint16_t)so->sol_qlen; 453779f106aSGleb Smirnoff xinpcb.maxqlen = so->sol_qlimit; 454779f106aSGleb Smirnoff xinpcb.maxqlen_old = so->sol_qlimit > USHRT_MAX ? 455779f106aSGleb Smirnoff USHRT_MAX : (uint16_t)so->sol_qlimit; 456851b7298SRandall Stewart } 45742551e99SRandall Stewart SCTP_INP_INCR_REF(inp); 45842551e99SRandall Stewart SCTP_INP_RUNLOCK(inp); 45942551e99SRandall Stewart SCTP_INP_INFO_RUNLOCK(); 46042551e99SRandall Stewart error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb)); 46142551e99SRandall Stewart if (error) { 462d61a0ae0SRandall Stewart SCTP_INP_DECR_REF(inp); 46360990c0cSMichael Tuexen return (error); 46442551e99SRandall Stewart } 46542551e99SRandall Stewart SCTP_INP_INFO_RLOCK(); 46642551e99SRandall Stewart SCTP_INP_RLOCK(inp); 467f47f328dSMichael Tuexen error = sctp_sysctl_copy_out_local_addresses(inp, NULL, req); 468d61a0ae0SRandall Stewart if (error) { 469d61a0ae0SRandall Stewart SCTP_INP_DECR_REF(inp); 47060990c0cSMichael Tuexen return (error); 471d61a0ae0SRandall Stewart } 47242551e99SRandall Stewart LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) { 47342551e99SRandall Stewart SCTP_TCB_LOCK(stcb); 47442551e99SRandall Stewart atomic_add_int(&stcb->asoc.refcnt, 1); 47542551e99SRandall Stewart SCTP_TCB_UNLOCK(stcb); 476d61a0ae0SRandall Stewart xstcb.last = 0; 477d61a0ae0SRandall Stewart xstcb.local_port = ntohs(inp->sctp_lport); 478d61a0ae0SRandall Stewart xstcb.remote_port = ntohs(stcb->rport); 47942551e99SRandall Stewart if (stcb->asoc.primary_destination != NULL) 480d61a0ae0SRandall Stewart xstcb.primary_addr = stcb->asoc.primary_destination->ro._l_addr; 481d61a0ae0SRandall Stewart xstcb.heartbeat_interval = stcb->asoc.heart_beat_delay; 482e92c2a8dSMichael Tuexen xstcb.state = (uint32_t)sctp_map_assoc_state(stcb->asoc.state); 483a99b6783SRandall Stewart xstcb.assoc_id = sctp_get_associd(stcb); 4844f6b4933SRandall Stewart xstcb.peers_rwnd = stcb->asoc.peers_rwnd; 485d61a0ae0SRandall Stewart xstcb.in_streams = stcb->asoc.streamincnt; 486d61a0ae0SRandall Stewart xstcb.out_streams = stcb->asoc.streamoutcnt; 487d61a0ae0SRandall Stewart xstcb.max_nr_retrans = stcb->asoc.overall_error_count; 488d61a0ae0SRandall Stewart xstcb.primary_process = 0; /* not really supported 489d61a0ae0SRandall Stewart * yet */ 490d61a0ae0SRandall Stewart xstcb.T1_expireries = stcb->asoc.timoinit + stcb->asoc.timocookie; 491d61a0ae0SRandall Stewart xstcb.T2_expireries = stcb->asoc.timoshutdown + stcb->asoc.timoshutdownack; 492d61a0ae0SRandall Stewart xstcb.retransmitted_tsns = stcb->asoc.marked_retrans; 493851b7298SRandall Stewart xstcb.start_time.tv_sec = (uint32_t)stcb->asoc.start_time.tv_sec; 494851b7298SRandall Stewart xstcb.start_time.tv_usec = (uint32_t)stcb->asoc.start_time.tv_usec; 495851b7298SRandall Stewart xstcb.discontinuity_time.tv_sec = (uint32_t)stcb->asoc.discontinuity_time.tv_sec; 496851b7298SRandall Stewart xstcb.discontinuity_time.tv_usec = (uint32_t)stcb->asoc.discontinuity_time.tv_usec; 49742551e99SRandall Stewart xstcb.total_sends = stcb->total_sends; 49842551e99SRandall Stewart xstcb.total_recvs = stcb->total_recvs; 49942551e99SRandall Stewart xstcb.local_tag = stcb->asoc.my_vtag; 50042551e99SRandall Stewart xstcb.remote_tag = stcb->asoc.peer_vtag; 50142551e99SRandall Stewart xstcb.initial_tsn = stcb->asoc.init_seq_number; 50242551e99SRandall Stewart xstcb.highest_tsn = stcb->asoc.sending_seq - 1; 50342551e99SRandall Stewart xstcb.cumulative_tsn = stcb->asoc.last_acked_seq; 50442551e99SRandall Stewart xstcb.cumulative_tsn_ack = stcb->asoc.cumulative_tsn; 50517205eccSRandall Stewart xstcb.mtu = stcb->asoc.smallest_mtu; 506207304d4SRandall Stewart xstcb.refcnt = stcb->asoc.refcnt; 50742551e99SRandall Stewart SCTP_INP_RUNLOCK(inp); 50842551e99SRandall Stewart SCTP_INP_INFO_RUNLOCK(); 50942551e99SRandall Stewart error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb)); 51042551e99SRandall Stewart if (error) { 511d61a0ae0SRandall Stewart SCTP_INP_DECR_REF(inp); 512851b7298SRandall Stewart atomic_subtract_int(&stcb->asoc.refcnt, 1); 51360990c0cSMichael Tuexen return (error); 514d61a0ae0SRandall Stewart } 515d61a0ae0SRandall Stewart SCTP_INP_INFO_RLOCK(); 516d61a0ae0SRandall Stewart SCTP_INP_RLOCK(inp); 517f47f328dSMichael Tuexen error = sctp_sysctl_copy_out_local_addresses(inp, stcb, req); 518d61a0ae0SRandall Stewart if (error) { 519d61a0ae0SRandall Stewart SCTP_INP_DECR_REF(inp); 520851b7298SRandall Stewart atomic_subtract_int(&stcb->asoc.refcnt, 1); 52160990c0cSMichael Tuexen return (error); 52242551e99SRandall Stewart } 52342551e99SRandall Stewart TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { 524d61a0ae0SRandall Stewart xraddr.last = 0; 525d61a0ae0SRandall Stewart xraddr.address = net->ro._l_addr; 526d61a0ae0SRandall Stewart xraddr.active = ((net->dest_state & SCTP_ADDR_REACHABLE) == SCTP_ADDR_REACHABLE); 527d61a0ae0SRandall Stewart xraddr.confirmed = ((net->dest_state & SCTP_ADDR_UNCONFIRMED) == 0); 528d61a0ae0SRandall Stewart xraddr.heartbeat_enabled = ((net->dest_state & SCTP_ADDR_NOHB) == 0); 529ca85e948SMichael Tuexen xraddr.potentially_failed = ((net->dest_state & SCTP_ADDR_PF) == SCTP_ADDR_PF); 530d61a0ae0SRandall Stewart xraddr.rto = net->RTO; 531d61a0ae0SRandall Stewart xraddr.max_path_rtx = net->failure_threshold; 532d61a0ae0SRandall Stewart xraddr.rtx = net->marked_retrans; 533d61a0ae0SRandall Stewart xraddr.error_counter = net->error_count; 534d61a0ae0SRandall Stewart xraddr.cwnd = net->cwnd; 535d61a0ae0SRandall Stewart xraddr.flight_size = net->flight_size; 536d61a0ae0SRandall Stewart xraddr.mtu = net->mtu; 537be1d9176SMichael Tuexen xraddr.rtt = net->rtt / 1000; 538ca85e948SMichael Tuexen xraddr.heartbeat_interval = net->heart_beat_delay; 53929b9533bSMichael Tuexen xraddr.ssthresh = net->ssthresh; 540292efb1bSMichael Tuexen xraddr.encaps_port = net->port; 541292efb1bSMichael Tuexen if (net->dest_state & SCTP_ADDR_UNCONFIRMED) { 542292efb1bSMichael Tuexen xraddr.state = SCTP_UNCONFIRMED; 543292efb1bSMichael Tuexen } else if (net->dest_state & SCTP_ADDR_REACHABLE) { 544292efb1bSMichael Tuexen xraddr.state = SCTP_ACTIVE; 545292efb1bSMichael Tuexen } else { 546292efb1bSMichael Tuexen xraddr.state = SCTP_INACTIVE; 547292efb1bSMichael Tuexen } 548851b7298SRandall Stewart xraddr.start_time.tv_sec = (uint32_t)net->start_time.tv_sec; 549851b7298SRandall Stewart xraddr.start_time.tv_usec = (uint32_t)net->start_time.tv_usec; 550d61a0ae0SRandall Stewart SCTP_INP_RUNLOCK(inp); 551d61a0ae0SRandall Stewart SCTP_INP_INFO_RUNLOCK(); 55242551e99SRandall Stewart error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr)); 55342551e99SRandall Stewart if (error) { 554d61a0ae0SRandall Stewart SCTP_INP_DECR_REF(inp); 555851b7298SRandall Stewart atomic_subtract_int(&stcb->asoc.refcnt, 1); 55660990c0cSMichael Tuexen return (error); 55742551e99SRandall Stewart } 55842551e99SRandall Stewart SCTP_INP_INFO_RLOCK(); 55942551e99SRandall Stewart SCTP_INP_RLOCK(inp); 56042551e99SRandall Stewart } 561851b7298SRandall Stewart atomic_subtract_int(&stcb->asoc.refcnt, 1); 562d61a0ae0SRandall Stewart memset((void *)&xraddr, 0, sizeof(struct xsctp_raddr)); 563d61a0ae0SRandall Stewart xraddr.last = 1; 56442551e99SRandall Stewart SCTP_INP_RUNLOCK(inp); 565d61a0ae0SRandall Stewart SCTP_INP_INFO_RUNLOCK(); 566d61a0ae0SRandall Stewart error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr)); 567d61a0ae0SRandall Stewart if (error) { 568d61a0ae0SRandall Stewart SCTP_INP_DECR_REF(inp); 56960990c0cSMichael Tuexen return (error); 570d61a0ae0SRandall Stewart } 571d61a0ae0SRandall Stewart SCTP_INP_INFO_RLOCK(); 572d61a0ae0SRandall Stewart SCTP_INP_RLOCK(inp); 573d61a0ae0SRandall Stewart } 574851b7298SRandall Stewart SCTP_INP_DECR_REF(inp); 575d61a0ae0SRandall Stewart SCTP_INP_RUNLOCK(inp); 576d61a0ae0SRandall Stewart SCTP_INP_INFO_RUNLOCK(); 577d61a0ae0SRandall Stewart memset((void *)&xstcb, 0, sizeof(struct xsctp_tcb)); 578d61a0ae0SRandall Stewart xstcb.last = 1; 579d61a0ae0SRandall Stewart error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb)); 580d61a0ae0SRandall Stewart if (error) { 58160990c0cSMichael Tuexen return (error); 582d61a0ae0SRandall Stewart } 5838ce4a9a2SRandall Stewart skip: 584d61a0ae0SRandall Stewart SCTP_INP_INFO_RLOCK(); 58542551e99SRandall Stewart } 58642551e99SRandall Stewart SCTP_INP_INFO_RUNLOCK(); 58742551e99SRandall Stewart 588d61a0ae0SRandall Stewart memset((void *)&xinpcb, 0, sizeof(struct xsctp_inpcb)); 58942551e99SRandall Stewart xinpcb.last = 1; 59042551e99SRandall Stewart error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb)); 59160990c0cSMichael Tuexen return (error); 59242551e99SRandall Stewart } 59342551e99SRandall Stewart 594851b7298SRandall Stewart static int 595f47f328dSMichael Tuexen sctp_sysctl_handle_udp_tunneling(SYSCTL_HANDLER_ARGS) 596c54a18d2SRandall Stewart { 597c54a18d2SRandall Stewart int error; 598f47f328dSMichael Tuexen uint32_t old, new; 599c54a18d2SRandall Stewart 600be27fdd0SRandall Stewart SCTP_INP_INFO_RLOCK(); 601f47f328dSMichael Tuexen old = SCTP_BASE_SYSCTL(sctp_udp_tunneling_port); 602be27fdd0SRandall Stewart SCTP_INP_INFO_RUNLOCK(); 603f47f328dSMichael Tuexen new = old; 604f47f328dSMichael Tuexen error = sysctl_handle_int(oidp, &new, 0, req); 605f47f328dSMichael Tuexen if ((error == 0) && 606f47f328dSMichael Tuexen (req->newptr != NULL)) { 607bcbf8c21SMichael Tuexen #if (SCTPCTL_UDP_TUNNELING_PORT_MIN == 0) 608bcbf8c21SMichael Tuexen if (new > SCTPCTL_UDP_TUNNELING_PORT_MAX) { 609bcbf8c21SMichael Tuexen #else 610f47f328dSMichael Tuexen if ((new < SCTPCTL_UDP_TUNNELING_PORT_MIN) || 611f47f328dSMichael Tuexen (new > SCTPCTL_UDP_TUNNELING_PORT_MAX)) { 612bcbf8c21SMichael Tuexen #endif 613f47f328dSMichael Tuexen error = EINVAL; 614f47f328dSMichael Tuexen } else { 615be27fdd0SRandall Stewart SCTP_INP_INFO_WLOCK(); 616f47f328dSMichael Tuexen SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = new; 617f47f328dSMichael Tuexen if (old != 0) { 618c54a18d2SRandall Stewart sctp_over_udp_stop(); 619c54a18d2SRandall Stewart } 620f47f328dSMichael Tuexen if (new != 0) { 621f47f328dSMichael Tuexen error = sctp_over_udp_start(); 622c54a18d2SRandall Stewart } 623be27fdd0SRandall Stewart SCTP_INP_INFO_WUNLOCK(); 624c54a18d2SRandall Stewart } 625f47f328dSMichael Tuexen } 626c54a18d2SRandall Stewart return (error); 627c54a18d2SRandall Stewart } 628c54a18d2SRandall Stewart 629c54a18d2SRandall Stewart static int 630f47f328dSMichael Tuexen sctp_sysctl_handle_auth(SYSCTL_HANDLER_ARGS) 631f47f328dSMichael Tuexen { 632f47f328dSMichael Tuexen int error; 633f47f328dSMichael Tuexen uint32_t new; 634f47f328dSMichael Tuexen 635f47f328dSMichael Tuexen new = SCTP_BASE_SYSCTL(sctp_auth_enable); 636f47f328dSMichael Tuexen error = sysctl_handle_int(oidp, &new, 0, req); 637f47f328dSMichael Tuexen if ((error == 0) && 638f47f328dSMichael Tuexen (req->newptr != NULL)) { 639bcbf8c21SMichael Tuexen #if (SCTPCTL_AUTH_ENABLE_MIN == 0) 640bcbf8c21SMichael Tuexen if ((new > SCTPCTL_AUTH_ENABLE_MAX) || 641bcbf8c21SMichael Tuexen ((new == 0) && (SCTP_BASE_SYSCTL(sctp_asconf_enable) == 1))) { 642bcbf8c21SMichael Tuexen #else 643f47f328dSMichael Tuexen if ((new < SCTPCTL_AUTH_ENABLE_MIN) || 644f47f328dSMichael Tuexen (new > SCTPCTL_AUTH_ENABLE_MAX) || 645f47f328dSMichael Tuexen ((new == 0) && (SCTP_BASE_SYSCTL(sctp_asconf_enable) == 1))) { 646bcbf8c21SMichael Tuexen #endif 647f47f328dSMichael Tuexen error = EINVAL; 648f47f328dSMichael Tuexen } else { 649f47f328dSMichael Tuexen SCTP_BASE_SYSCTL(sctp_auth_enable) = new; 650f47f328dSMichael Tuexen } 651f47f328dSMichael Tuexen } 652f47f328dSMichael Tuexen return (error); 653f47f328dSMichael Tuexen } 654f47f328dSMichael Tuexen 655f47f328dSMichael Tuexen static int 656f47f328dSMichael Tuexen sctp_sysctl_handle_asconf(SYSCTL_HANDLER_ARGS) 657f47f328dSMichael Tuexen { 658f47f328dSMichael Tuexen int error; 659f47f328dSMichael Tuexen uint32_t new; 660f47f328dSMichael Tuexen 661f47f328dSMichael Tuexen new = SCTP_BASE_SYSCTL(sctp_asconf_enable); 662f47f328dSMichael Tuexen error = sysctl_handle_int(oidp, &new, 0, req); 663f47f328dSMichael Tuexen if ((error == 0) && 664f47f328dSMichael Tuexen (req->newptr != NULL)) { 665bcbf8c21SMichael Tuexen #if (SCTPCTL_ASCONF_ENABLE_MIN == 0) 666bcbf8c21SMichael Tuexen if ((new > SCTPCTL_ASCONF_ENABLE_MAX) || 667bcbf8c21SMichael Tuexen ((new == 1) && (SCTP_BASE_SYSCTL(sctp_auth_enable) == 0))) { 668bcbf8c21SMichael Tuexen #else 669f47f328dSMichael Tuexen if ((new < SCTPCTL_ASCONF_ENABLE_MIN) || 670f47f328dSMichael Tuexen (new > SCTPCTL_ASCONF_ENABLE_MAX) || 671f47f328dSMichael Tuexen ((new == 1) && (SCTP_BASE_SYSCTL(sctp_auth_enable) == 0))) { 672bcbf8c21SMichael Tuexen #endif 673f47f328dSMichael Tuexen error = EINVAL; 674f47f328dSMichael Tuexen } else { 675f47f328dSMichael Tuexen SCTP_BASE_SYSCTL(sctp_asconf_enable) = new; 676f47f328dSMichael Tuexen } 677f47f328dSMichael Tuexen } 678f47f328dSMichael Tuexen return (error); 679f47f328dSMichael Tuexen } 680f47f328dSMichael Tuexen 681f47f328dSMichael Tuexen static int 682f47f328dSMichael Tuexen sctp_sysctl_handle_stats(SYSCTL_HANDLER_ARGS) 683851b7298SRandall Stewart { 684851b7298SRandall Stewart int error; 685f47f328dSMichael Tuexen #if defined(SMP) && defined(SCTP_USE_PERCPU_STAT) 6860e1152fcSHans Petter Selasky struct sctpstat *sarry; 6870e1152fcSHans Petter Selasky struct sctpstat sb; 688f47f328dSMichael Tuexen int cpu; 689b3f1ea41SRandall Stewart #endif 690f885296dSMichael Tuexen struct sctpstat sb_temp; 69142551e99SRandall Stewart 692f47f328dSMichael Tuexen if ((req->newptr != NULL) && 693f47f328dSMichael Tuexen (req->newlen != sizeof(struct sctpstat))) { 694ae26e0a4SRandall Stewart return (EINVAL); 695ae26e0a4SRandall Stewart } 696f885296dSMichael Tuexen memset(&sb_temp, 0, sizeof(struct sctpstat)); 6970e1152fcSHans Petter Selasky 6980e1152fcSHans Petter Selasky if (req->newptr != NULL) { 699f885296dSMichael Tuexen error = SYSCTL_IN(req, &sb_temp, sizeof(struct sctpstat)); 700f885296dSMichael Tuexen if (error != 0) { 7010e1152fcSHans Petter Selasky return (error); 7020e1152fcSHans Petter Selasky } 703f885296dSMichael Tuexen } 704f885296dSMichael Tuexen #if defined(SMP) && defined(SCTP_USE_PERCPU_STAT) 705f885296dSMichael Tuexen memset(&sb, 0, sizeof(sb)); 706dec0177dSRandall Stewart for (cpu = 0; cpu < mp_maxid; cpu++) { 707ff014514SRandall Stewart sarry = &SCTP_BASE_STATS[cpu]; 708ff014514SRandall Stewart if (sarry->sctps_discontinuitytime.tv_sec > sb.sctps_discontinuitytime.tv_sec) { 709ff014514SRandall Stewart sb.sctps_discontinuitytime.tv_sec = sarry->sctps_discontinuitytime.tv_sec; 710ff014514SRandall Stewart sb.sctps_discontinuitytime.tv_usec = sarry->sctps_discontinuitytime.tv_usec; 711ff014514SRandall Stewart } 712ff014514SRandall Stewart sb.sctps_currestab += sarry->sctps_currestab; 713ff014514SRandall Stewart sb.sctps_activeestab += sarry->sctps_activeestab; 714ff014514SRandall Stewart sb.sctps_restartestab += sarry->sctps_restartestab; 715ff014514SRandall Stewart sb.sctps_collisionestab += sarry->sctps_collisionestab; 716ff014514SRandall Stewart sb.sctps_passiveestab += sarry->sctps_passiveestab; 717ff014514SRandall Stewart sb.sctps_aborted += sarry->sctps_aborted; 718ff014514SRandall Stewart sb.sctps_shutdown += sarry->sctps_shutdown; 719ff014514SRandall Stewart sb.sctps_outoftheblue += sarry->sctps_outoftheblue; 720ff014514SRandall Stewart sb.sctps_checksumerrors += sarry->sctps_checksumerrors; 721ff014514SRandall Stewart sb.sctps_outcontrolchunks += sarry->sctps_outcontrolchunks; 722ff014514SRandall Stewart sb.sctps_outorderchunks += sarry->sctps_outorderchunks; 723ff014514SRandall Stewart sb.sctps_outunorderchunks += sarry->sctps_outunorderchunks; 724ff014514SRandall Stewart sb.sctps_incontrolchunks += sarry->sctps_incontrolchunks; 725ff014514SRandall Stewart sb.sctps_inorderchunks += sarry->sctps_inorderchunks; 726ff014514SRandall Stewart sb.sctps_inunorderchunks += sarry->sctps_inunorderchunks; 727ff014514SRandall Stewart sb.sctps_fragusrmsgs += sarry->sctps_fragusrmsgs; 728ff014514SRandall Stewart sb.sctps_reasmusrmsgs += sarry->sctps_reasmusrmsgs; 729ff014514SRandall Stewart sb.sctps_outpackets += sarry->sctps_outpackets; 730ff014514SRandall Stewart sb.sctps_inpackets += sarry->sctps_inpackets; 731ff014514SRandall Stewart sb.sctps_recvpackets += sarry->sctps_recvpackets; 732ff014514SRandall Stewart sb.sctps_recvdatagrams += sarry->sctps_recvdatagrams; 733ff014514SRandall Stewart sb.sctps_recvpktwithdata += sarry->sctps_recvpktwithdata; 734ff014514SRandall Stewart sb.sctps_recvsacks += sarry->sctps_recvsacks; 735ff014514SRandall Stewart sb.sctps_recvdata += sarry->sctps_recvdata; 736ff014514SRandall Stewart sb.sctps_recvdupdata += sarry->sctps_recvdupdata; 737ff014514SRandall Stewart sb.sctps_recvheartbeat += sarry->sctps_recvheartbeat; 738ff014514SRandall Stewart sb.sctps_recvheartbeatack += sarry->sctps_recvheartbeatack; 739ff014514SRandall Stewart sb.sctps_recvecne += sarry->sctps_recvecne; 740ff014514SRandall Stewart sb.sctps_recvauth += sarry->sctps_recvauth; 741ff014514SRandall Stewart sb.sctps_recvauthmissing += sarry->sctps_recvauthmissing; 742ff014514SRandall Stewart sb.sctps_recvivalhmacid += sarry->sctps_recvivalhmacid; 743ff014514SRandall Stewart sb.sctps_recvivalkeyid += sarry->sctps_recvivalkeyid; 744ff014514SRandall Stewart sb.sctps_recvauthfailed += sarry->sctps_recvauthfailed; 745ff014514SRandall Stewart sb.sctps_recvexpress += sarry->sctps_recvexpress; 746ff014514SRandall Stewart sb.sctps_recvexpressm += sarry->sctps_recvexpressm; 747ff014514SRandall Stewart sb.sctps_recvswcrc += sarry->sctps_recvswcrc; 748ff014514SRandall Stewart sb.sctps_recvhwcrc += sarry->sctps_recvhwcrc; 749ff014514SRandall Stewart sb.sctps_sendpackets += sarry->sctps_sendpackets; 750ff014514SRandall Stewart sb.sctps_sendsacks += sarry->sctps_sendsacks; 751ff014514SRandall Stewart sb.sctps_senddata += sarry->sctps_senddata; 752ff014514SRandall Stewart sb.sctps_sendretransdata += sarry->sctps_sendretransdata; 753ff014514SRandall Stewart sb.sctps_sendfastretrans += sarry->sctps_sendfastretrans; 754ff014514SRandall Stewart sb.sctps_sendmultfastretrans += sarry->sctps_sendmultfastretrans; 755ff014514SRandall Stewart sb.sctps_sendheartbeat += sarry->sctps_sendheartbeat; 756ff014514SRandall Stewart sb.sctps_sendecne += sarry->sctps_sendecne; 757ff014514SRandall Stewart sb.sctps_sendauth += sarry->sctps_sendauth; 758ff014514SRandall Stewart sb.sctps_senderrors += sarry->sctps_senderrors; 759ff014514SRandall Stewart sb.sctps_sendswcrc += sarry->sctps_sendswcrc; 760ff014514SRandall Stewart sb.sctps_sendhwcrc += sarry->sctps_sendhwcrc; 761ff014514SRandall Stewart sb.sctps_pdrpfmbox += sarry->sctps_pdrpfmbox; 762ff014514SRandall Stewart sb.sctps_pdrpfehos += sarry->sctps_pdrpfehos; 763ff014514SRandall Stewart sb.sctps_pdrpmbda += sarry->sctps_pdrpmbda; 764ff014514SRandall Stewart sb.sctps_pdrpmbct += sarry->sctps_pdrpmbct; 765ff014514SRandall Stewart sb.sctps_pdrpbwrpt += sarry->sctps_pdrpbwrpt; 766ff014514SRandall Stewart sb.sctps_pdrpcrupt += sarry->sctps_pdrpcrupt; 767ff014514SRandall Stewart sb.sctps_pdrpnedat += sarry->sctps_pdrpnedat; 768ff014514SRandall Stewart sb.sctps_pdrppdbrk += sarry->sctps_pdrppdbrk; 769ff014514SRandall Stewart sb.sctps_pdrptsnnf += sarry->sctps_pdrptsnnf; 770ff014514SRandall Stewart sb.sctps_pdrpdnfnd += sarry->sctps_pdrpdnfnd; 771ff014514SRandall Stewart sb.sctps_pdrpdiwnp += sarry->sctps_pdrpdiwnp; 772ff014514SRandall Stewart sb.sctps_pdrpdizrw += sarry->sctps_pdrpdizrw; 773ff014514SRandall Stewart sb.sctps_pdrpbadd += sarry->sctps_pdrpbadd; 774ff014514SRandall Stewart sb.sctps_pdrpmark += sarry->sctps_pdrpmark; 775ff014514SRandall Stewart sb.sctps_timoiterator += sarry->sctps_timoiterator; 776ff014514SRandall Stewart sb.sctps_timodata += sarry->sctps_timodata; 777ff014514SRandall Stewart sb.sctps_timowindowprobe += sarry->sctps_timowindowprobe; 778ff014514SRandall Stewart sb.sctps_timoinit += sarry->sctps_timoinit; 779ff014514SRandall Stewart sb.sctps_timosack += sarry->sctps_timosack; 780ff014514SRandall Stewart sb.sctps_timoshutdown += sarry->sctps_timoshutdown; 781ff014514SRandall Stewart sb.sctps_timoheartbeat += sarry->sctps_timoheartbeat; 782ff014514SRandall Stewart sb.sctps_timocookie += sarry->sctps_timocookie; 783ff014514SRandall Stewart sb.sctps_timosecret += sarry->sctps_timosecret; 784ff014514SRandall Stewart sb.sctps_timopathmtu += sarry->sctps_timopathmtu; 785ff014514SRandall Stewart sb.sctps_timoshutdownack += sarry->sctps_timoshutdownack; 786ff014514SRandall Stewart sb.sctps_timoshutdownguard += sarry->sctps_timoshutdownguard; 787ff014514SRandall Stewart sb.sctps_timostrmrst += sarry->sctps_timostrmrst; 788ff014514SRandall Stewart sb.sctps_timoearlyfr += sarry->sctps_timoearlyfr; 789ff014514SRandall Stewart sb.sctps_timoasconf += sarry->sctps_timoasconf; 790ff014514SRandall Stewart sb.sctps_timodelprim += sarry->sctps_timodelprim; 791ff014514SRandall Stewart sb.sctps_timoautoclose += sarry->sctps_timoautoclose; 792ff014514SRandall Stewart sb.sctps_timoassockill += sarry->sctps_timoassockill; 793ff014514SRandall Stewart sb.sctps_timoinpkill += sarry->sctps_timoinpkill; 794ff014514SRandall Stewart sb.sctps_hdrops += sarry->sctps_hdrops; 795ff014514SRandall Stewart sb.sctps_badsum += sarry->sctps_badsum; 796ff014514SRandall Stewart sb.sctps_noport += sarry->sctps_noport; 797ff014514SRandall Stewart sb.sctps_badvtag += sarry->sctps_badvtag; 798ff014514SRandall Stewart sb.sctps_badsid += sarry->sctps_badsid; 799ff014514SRandall Stewart sb.sctps_nomem += sarry->sctps_nomem; 800ff014514SRandall Stewart sb.sctps_fastretransinrtt += sarry->sctps_fastretransinrtt; 801ff014514SRandall Stewart sb.sctps_markedretrans += sarry->sctps_markedretrans; 802ff014514SRandall Stewart sb.sctps_naglesent += sarry->sctps_naglesent; 803ff014514SRandall Stewart sb.sctps_naglequeued += sarry->sctps_naglequeued; 804ff014514SRandall Stewart sb.sctps_maxburstqueued += sarry->sctps_maxburstqueued; 805ff014514SRandall Stewart sb.sctps_ifnomemqueued += sarry->sctps_ifnomemqueued; 806ff014514SRandall Stewart sb.sctps_windowprobed += sarry->sctps_windowprobed; 807ff014514SRandall Stewart sb.sctps_lowlevelerr += sarry->sctps_lowlevelerr; 808ff014514SRandall Stewart sb.sctps_lowlevelerrusr += sarry->sctps_lowlevelerrusr; 809ff014514SRandall Stewart sb.sctps_datadropchklmt += sarry->sctps_datadropchklmt; 810ff014514SRandall Stewart sb.sctps_datadroprwnd += sarry->sctps_datadroprwnd; 811ff014514SRandall Stewart sb.sctps_ecnereducedcwnd += sarry->sctps_ecnereducedcwnd; 812ff014514SRandall Stewart sb.sctps_vtagexpress += sarry->sctps_vtagexpress; 813ff014514SRandall Stewart sb.sctps_vtagbogus += sarry->sctps_vtagbogus; 814ff014514SRandall Stewart sb.sctps_primary_randry += sarry->sctps_primary_randry; 815ff014514SRandall Stewart sb.sctps_cmt_randry += sarry->sctps_cmt_randry; 816ff014514SRandall Stewart sb.sctps_slowpath_sack += sarry->sctps_slowpath_sack; 817ff014514SRandall Stewart sb.sctps_wu_sacks_sent += sarry->sctps_wu_sacks_sent; 818ff014514SRandall Stewart sb.sctps_sends_with_flags += sarry->sctps_sends_with_flags; 819ff014514SRandall Stewart sb.sctps_sends_with_unord += sarry->sctps_sends_with_unord; 820ff014514SRandall Stewart sb.sctps_sends_with_eof += sarry->sctps_sends_with_eof; 821ff014514SRandall Stewart sb.sctps_sends_with_abort += sarry->sctps_sends_with_abort; 822ff014514SRandall Stewart sb.sctps_protocol_drain_calls += sarry->sctps_protocol_drain_calls; 823ff014514SRandall Stewart sb.sctps_protocol_drains_done += sarry->sctps_protocol_drains_done; 824ff014514SRandall Stewart sb.sctps_read_peeks += sarry->sctps_read_peeks; 825ff014514SRandall Stewart sb.sctps_cached_chk += sarry->sctps_cached_chk; 826ff014514SRandall Stewart sb.sctps_cached_strmoq += sarry->sctps_cached_strmoq; 827ff014514SRandall Stewart sb.sctps_left_abandon += sarry->sctps_left_abandon; 828ff014514SRandall Stewart sb.sctps_send_burst_avoid += sarry->sctps_send_burst_avoid; 829ff014514SRandall Stewart sb.sctps_send_cwnd_avoid += sarry->sctps_send_cwnd_avoid; 830ff014514SRandall Stewart sb.sctps_fwdtsn_map_over += sarry->sctps_fwdtsn_map_over; 831f885296dSMichael Tuexen if (req->newptr != NULL) { 8320e1152fcSHans Petter Selasky memcpy(sarry, &sb_temp, sizeof(struct sctpstat)); 833ff014514SRandall Stewart } 834f885296dSMichael Tuexen } 835f47f328dSMichael Tuexen error = SYSCTL_OUT(req, &sb, sizeof(struct sctpstat)); 836f47f328dSMichael Tuexen #else 837f47f328dSMichael Tuexen error = SYSCTL_OUT(req, &SCTP_BASE_STATS, sizeof(struct sctpstat)); 838f885296dSMichael Tuexen if (error != 0) { 839f885296dSMichael Tuexen return (error); 840f885296dSMichael Tuexen } 841f885296dSMichael Tuexen if (req->newptr != NULL) { 842f885296dSMichael Tuexen memcpy(&SCTP_BASE_STATS, &sb_temp, sizeof(struct sctpstat)); 843f885296dSMichael Tuexen } 844f47f328dSMichael Tuexen #endif 845ff014514SRandall Stewart return (error); 846ff014514SRandall Stewart } 847ff014514SRandall Stewart 848b3f1ea41SRandall Stewart #if defined(SCTP_LOCAL_TRACE_BUF) 849b3f1ea41SRandall Stewart static int 850f47f328dSMichael Tuexen sctp_sysctl_handle_trace_log(SYSCTL_HANDLER_ARGS) 851f47f328dSMichael Tuexen { 852f47f328dSMichael Tuexen int error; 853f47f328dSMichael Tuexen 854f47f328dSMichael Tuexen error = SYSCTL_OUT(req, &SCTP_BASE_SYSCTL(sctp_log), sizeof(struct sctp_log)); 855f47f328dSMichael Tuexen return (error); 856f47f328dSMichael Tuexen } 857f47f328dSMichael Tuexen 858f47f328dSMichael Tuexen static int 859f47f328dSMichael Tuexen sctp_sysctl_handle_trace_log_clear(SYSCTL_HANDLER_ARGS) 860b3f1ea41SRandall Stewart { 861a99b6783SRandall Stewart int error = 0; 862a99b6783SRandall Stewart 863b3f1ea41SRandall Stewart memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log)); 864a99b6783SRandall Stewart return (error); 865b3f1ea41SRandall Stewart } 866b3f1ea41SRandall Stewart #endif 867b3f1ea41SRandall Stewart 868f47f328dSMichael Tuexen #define SCTP_UINT_SYSCTL(mib_name, var_name, prefix) \ 869f47f328dSMichael Tuexen static int \ 870f47f328dSMichael Tuexen sctp_sysctl_handle_##mib_name(SYSCTL_HANDLER_ARGS) \ 871f47f328dSMichael Tuexen { \ 872f47f328dSMichael Tuexen int error; \ 873f47f328dSMichael Tuexen uint32_t new; \ 874f47f328dSMichael Tuexen \ 875f47f328dSMichael Tuexen new = SCTP_BASE_SYSCTL(var_name); \ 876f47f328dSMichael Tuexen error = sysctl_handle_int(oidp, &new, 0, req); \ 877f47f328dSMichael Tuexen if ((error == 0) && (req->newptr != NULL)) { \ 878f47f328dSMichael Tuexen if ((new < prefix##_MIN) || \ 879f47f328dSMichael Tuexen (new > prefix##_MAX)) { \ 880f47f328dSMichael Tuexen error = EINVAL; \ 881f47f328dSMichael Tuexen } else { \ 882f47f328dSMichael Tuexen SCTP_BASE_SYSCTL(var_name) = new; \ 883f47f328dSMichael Tuexen } \ 884f47f328dSMichael Tuexen } \ 885f47f328dSMichael Tuexen return (error); \ 886f47f328dSMichael Tuexen } \ 88795e55080SMichael Tuexen SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mib_name, \ 8885ac91821SMichael Tuexen CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW, NULL, 0, \ 8895ac91821SMichael Tuexen sctp_sysctl_handle_##mib_name, "UI", prefix##_DESC); 890b3f1ea41SRandall Stewart 89142551e99SRandall Stewart /* 89242551e99SRandall Stewart * sysctl definitions 89342551e99SRandall Stewart */ 89442551e99SRandall Stewart 895f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(sendspace, sctp_sendspace, SCTPCTL_MAXDGRAM) 896f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(recvspace, sctp_recvspace, SCTPCTL_RECVSPACE) 897f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(auto_asconf, sctp_auto_asconf, SCTPCTL_AUTOASCONF) 898f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(ecn_enable, sctp_ecn_enable, SCTPCTL_ECN_ENABLE) 899f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(pr_enable, sctp_pr_enable, SCTPCTL_PR_ENABLE) 9005ac91821SMichael Tuexen SYSCTL_PROC(_net_inet_sctp, OID_AUTO, auth_enable, CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW, 9015ac91821SMichael Tuexen NULL, 0, sctp_sysctl_handle_auth, "IU", SCTPCTL_AUTH_ENABLE_DESC); 9025ac91821SMichael Tuexen SYSCTL_PROC(_net_inet_sctp, OID_AUTO, asconf_enable, CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW, 9035ac91821SMichael Tuexen NULL, 0, sctp_sysctl_handle_asconf, "IU", SCTPCTL_ASCONF_ENABLE_DESC); 904f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(reconfig_enable, sctp_reconfig_enable, SCTPCTL_RECONFIG_ENABLE) 905f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(nrsack_enable, sctp_nrsack_enable, SCTPCTL_NRSACK_ENABLE) 906f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(pktdrop_enable, sctp_pktdrop_enable, SCTPCTL_PKTDROP_ENABLE) 907f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(peer_chkoh, sctp_peer_chunk_oh, SCTPCTL_PEER_CHKOH) 908f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(maxburst, sctp_max_burst_default, SCTPCTL_MAXBURST) 909f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(fr_maxburst, sctp_fr_max_burst_default, SCTPCTL_FRMAXBURST) 910f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(maxchunks, sctp_max_chunks_on_queue, SCTPCTL_MAXCHUNKS) 911f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(tcbhashsize, sctp_hashtblsize, SCTPCTL_TCBHASHSIZE) 912f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(pcbhashsize, sctp_pcbtblsize, SCTPCTL_PCBHASHSIZE) 913f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(min_split_point, sctp_min_split_point, SCTPCTL_MIN_SPLIT_POINT) 914f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(chunkscale, sctp_chunkscale, SCTPCTL_CHUNKSCALE) 915f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(delayed_sack_time, sctp_delayed_sack_time_default, SCTPCTL_DELAYED_SACK_TIME) 916f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(sack_freq, sctp_sack_freq_default, SCTPCTL_SACK_FREQ) 917f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(sys_resource, sctp_system_free_resc_limit, SCTPCTL_SYS_RESOURCE) 918f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(asoc_resource, sctp_asoc_free_resc_limit, SCTPCTL_ASOC_RESOURCE) 919f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(heartbeat_interval, sctp_heartbeat_interval_default, SCTPCTL_HEARTBEAT_INTERVAL) 920f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(pmtu_raise_time, sctp_pmtu_raise_time_default, SCTPCTL_PMTU_RAISE_TIME) 921f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(shutdown_guard_time, sctp_shutdown_guard_time_default, SCTPCTL_SHUTDOWN_GUARD_TIME) 922f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(secret_lifetime, sctp_secret_lifetime_default, SCTPCTL_SECRET_LIFETIME) 923f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(rto_max, sctp_rto_max_default, SCTPCTL_RTO_MAX) 924f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(rto_min, sctp_rto_min_default, SCTPCTL_RTO_MIN) 925f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(rto_initial, sctp_rto_initial_default, SCTPCTL_RTO_INITIAL) 926f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(init_rto_max, sctp_init_rto_max_default, SCTPCTL_INIT_RTO_MAX) 927f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(valid_cookie_life, sctp_valid_cookie_life_default, SCTPCTL_VALID_COOKIE_LIFE) 928f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(init_rtx_max, sctp_init_rtx_max_default, SCTPCTL_INIT_RTX_MAX) 929f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(assoc_rtx_max, sctp_assoc_rtx_max_default, SCTPCTL_ASSOC_RTX_MAX) 930f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(path_rtx_max, sctp_path_rtx_max_default, SCTPCTL_PATH_RTX_MAX) 931f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(path_pf_threshold, sctp_path_pf_threshold, SCTPCTL_PATH_PF_THRESHOLD) 932f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(add_more_on_output, sctp_add_more_threshold, SCTPCTL_ADD_MORE_ON_OUTPUT) 933f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(incoming_streams, sctp_nr_incoming_streams_default, SCTPCTL_INCOMING_STREAMS) 934f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(outgoing_streams, sctp_nr_outgoing_streams_default, SCTPCTL_OUTGOING_STREAMS) 935f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(cmt_on_off, sctp_cmt_on_off, SCTPCTL_CMT_ON_OFF) 936f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(cmt_use_dac, sctp_cmt_use_dac, SCTPCTL_CMT_USE_DAC) 937f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(cwnd_maxburst, sctp_use_cwnd_based_maxburst, SCTPCTL_CWND_MAXBURST) 938f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(nat_friendly, sctp_nat_friendly, SCTPCTL_NAT_FRIENDLY) 939f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(abc_l_var, sctp_L2_abc_variable, SCTPCTL_ABC_L_VAR) 940f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(max_chained_mbufs, sctp_mbuf_threshold_count, SCTPCTL_MAX_CHAINED_MBUFS) 941f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(do_sctp_drain, sctp_do_drain, SCTPCTL_DO_SCTP_DRAIN) 942f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(hb_max_burst, sctp_hb_maxburst, SCTPCTL_HB_MAX_BURST) 943f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(abort_at_limit, sctp_abort_if_one_2_one_hits_limit, SCTPCTL_ABORT_AT_LIMIT) 944f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(min_residual, sctp_min_residual, SCTPCTL_MIN_RESIDUAL) 945f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(max_retran_chunk, sctp_max_retran_chunk, SCTPCTL_MAX_RETRAN_CHUNK) 946f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(log_level, sctp_logging_level, SCTPCTL_LOGGING_LEVEL) 947f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(default_cc_module, sctp_default_cc_module, SCTPCTL_DEFAULT_CC_MODULE) 948f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(default_ss_module, sctp_default_ss_module, SCTPCTL_DEFAULT_SS_MODULE) 949f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(default_frag_interleave, sctp_default_frag_interleave, SCTPCTL_DEFAULT_FRAG_INTERLEAVE) 950f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(mobility_base, sctp_mobility_base, SCTPCTL_MOBILITY_BASE) 951f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(mobility_fasthandoff, sctp_mobility_fasthandoff, SCTPCTL_MOBILITY_FASTHANDOFF) 952b27a6b7dSRandall Stewart #if defined(SCTP_LOCAL_TRACE_BUF) 9535ac91821SMichael Tuexen SYSCTL_PROC(_net_inet_sctp, OID_AUTO, log, CTLFLAG_VNET | CTLTYPE_STRUCT | CTLFLAG_RD, 9545ac91821SMichael Tuexen NULL, 0, sctp_sysctl_handle_trace_log, "S,sctplog", "SCTP logging (struct sctp_log)"); 9555ac91821SMichael Tuexen SYSCTL_PROC(_net_inet_sctp, OID_AUTO, clear_trace, CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW, 9565ac91821SMichael Tuexen NULL, 0, sctp_sysctl_handle_trace_log_clear, "IU", "Clear SCTP Logging buffer"); 957b27a6b7dSRandall Stewart #endif 9585ac91821SMichael Tuexen SYSCTL_PROC(_net_inet_sctp, OID_AUTO, udp_tunneling_port, CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW, 9595ac91821SMichael Tuexen NULL, 0, sctp_sysctl_handle_udp_tunneling, "IU", SCTPCTL_UDP_TUNNELING_PORT_DESC); 960f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(enable_sack_immediately, sctp_enable_sack_immediately, SCTPCTL_SACK_IMMEDIATELY_ENABLE) 961f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(nat_friendly_init, sctp_inits_include_nat_friendly, SCTPCTL_NAT_FRIENDLY_INITS) 962f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(vtag_time_wait, sctp_vtag_time_wait, SCTPCTL_TIME_WAIT) 963f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(buffer_splitting, sctp_buffer_splitting, SCTPCTL_BUFFER_SPLITTING) 964f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(initial_cwnd, sctp_initial_cwnd, SCTPCTL_INITIAL_CWND) 965f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(rttvar_bw, sctp_rttvar_bw, SCTPCTL_RTTVAR_BW) 966f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(rttvar_rtt, sctp_rttvar_rtt, SCTPCTL_RTTVAR_RTT) 967f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(rttvar_eqret, sctp_rttvar_eqret, SCTPCTL_RTTVAR_EQRET) 968f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(rttvar_steady_step, sctp_steady_step, SCTPCTL_RTTVAR_STEADYS) 969f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(use_dcccecn, sctp_use_dccc_ecn, SCTPCTL_RTTVAR_DCCCECN) 970f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(blackhole, sctp_blackhole, SCTPCTL_BLACKHOLE) 971ae7cc6c9SMichael Tuexen SCTP_UINT_SYSCTL(sendall_limit, sctp_sendall_limit, SCTPCTL_SENDALL_LIMIT) 972f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(diag_info_code, sctp_diag_info_code, SCTPCTL_DIAG_INFO_CODE) 973851b7298SRandall Stewart #ifdef SCTP_DEBUG 974f47f328dSMichael Tuexen SCTP_UINT_SYSCTL(debug, sctp_debug_on, SCTPCTL_DEBUG) 975f0878bdcSMichael Tuexen #endif 9765ac91821SMichael Tuexen SYSCTL_PROC(_net_inet_sctp, OID_AUTO, stats, CTLFLAG_VNET | CTLTYPE_STRUCT | CTLFLAG_RW, 9775ac91821SMichael Tuexen NULL, 0, sctp_sysctl_handle_stats, "S,sctpstat", "SCTP statistics (struct sctp_stat)"); 9785ac91821SMichael Tuexen SYSCTL_PROC(_net_inet_sctp, OID_AUTO, assoclist, CTLFLAG_VNET | CTLTYPE_OPAQUE | CTLFLAG_RD, 9795ac91821SMichael Tuexen NULL, 0, sctp_sysctl_handle_assoclist, "S,xassoc", "List of active SCTP associations"); 980