1 /*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 2007, by Cisco Systems, Inc. All rights reserved. 5 * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 6 * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions are met: 10 * 11 * a) Redistributions of source code must retain the above copyright notice, 12 * this list of conditions and the following disclaimer. 13 * 14 * b) Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in 16 * the documentation and/or other materials provided with the distribution. 17 * 18 * c) Neither the name of Cisco Systems, Inc. nor the names of its 19 * contributors may be used to endorse or promote products derived 20 * from this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32 * THE POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35 #include <sys/cdefs.h> 36 __FBSDID("$FreeBSD$"); 37 38 #include <netinet/sctp_os.h> 39 #include <netinet/sctp.h> 40 #include <netinet/sctp_constants.h> 41 #include <netinet/sctp_sysctl.h> 42 #include <netinet/sctp_pcb.h> 43 #include <netinet/sctputil.h> 44 #include <netinet/sctp_output.h> 45 #include <sys/smp.h> 46 #include <sys/sysctl.h> 47 48 FEATURE(sctp, "Stream Control Transmission Protocol"); 49 50 /* 51 * sysctl tunable variables 52 */ 53 54 void 55 sctp_init_sysctls() 56 { 57 SCTP_BASE_SYSCTL(sctp_sendspace) = SCTPCTL_MAXDGRAM_DEFAULT; 58 SCTP_BASE_SYSCTL(sctp_recvspace) = SCTPCTL_RECVSPACE_DEFAULT; 59 SCTP_BASE_SYSCTL(sctp_auto_asconf) = SCTPCTL_AUTOASCONF_DEFAULT; 60 SCTP_BASE_SYSCTL(sctp_multiple_asconfs) = SCTPCTL_MULTIPLEASCONFS_DEFAULT; 61 SCTP_BASE_SYSCTL(sctp_ecn_enable) = SCTPCTL_ECN_ENABLE_DEFAULT; 62 SCTP_BASE_SYSCTL(sctp_pr_enable) = SCTPCTL_PR_ENABLE_DEFAULT; 63 SCTP_BASE_SYSCTL(sctp_auth_enable) = SCTPCTL_AUTH_ENABLE_DEFAULT; 64 SCTP_BASE_SYSCTL(sctp_asconf_enable) = SCTPCTL_ASCONF_ENABLE_DEFAULT; 65 SCTP_BASE_SYSCTL(sctp_reconfig_enable) = SCTPCTL_RECONFIG_ENABLE_DEFAULT; 66 SCTP_BASE_SYSCTL(sctp_nrsack_enable) = SCTPCTL_NRSACK_ENABLE_DEFAULT; 67 SCTP_BASE_SYSCTL(sctp_pktdrop_enable) = SCTPCTL_PKTDROP_ENABLE_DEFAULT; 68 SCTP_BASE_SYSCTL(sctp_peer_chunk_oh) = SCTPCTL_PEER_CHKOH_DEFAULT; 69 SCTP_BASE_SYSCTL(sctp_max_burst_default) = SCTPCTL_MAXBURST_DEFAULT; 70 SCTP_BASE_SYSCTL(sctp_fr_max_burst_default) = SCTPCTL_FRMAXBURST_DEFAULT; 71 SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue) = SCTPCTL_MAXCHUNKS_DEFAULT; 72 SCTP_BASE_SYSCTL(sctp_hashtblsize) = SCTPCTL_TCBHASHSIZE_DEFAULT; 73 SCTP_BASE_SYSCTL(sctp_pcbtblsize) = SCTPCTL_PCBHASHSIZE_DEFAULT; 74 SCTP_BASE_SYSCTL(sctp_min_split_point) = SCTPCTL_MIN_SPLIT_POINT_DEFAULT; 75 SCTP_BASE_SYSCTL(sctp_chunkscale) = SCTPCTL_CHUNKSCALE_DEFAULT; 76 SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default) = SCTPCTL_DELAYED_SACK_TIME_DEFAULT; 77 SCTP_BASE_SYSCTL(sctp_sack_freq_default) = SCTPCTL_SACK_FREQ_DEFAULT; 78 SCTP_BASE_SYSCTL(sctp_system_free_resc_limit) = SCTPCTL_SYS_RESOURCE_DEFAULT; 79 SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit) = SCTPCTL_ASOC_RESOURCE_DEFAULT; 80 SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default) = SCTPCTL_HEARTBEAT_INTERVAL_DEFAULT; 81 SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default) = SCTPCTL_PMTU_RAISE_TIME_DEFAULT; 82 SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default) = SCTPCTL_SHUTDOWN_GUARD_TIME_DEFAULT; 83 SCTP_BASE_SYSCTL(sctp_secret_lifetime_default) = SCTPCTL_SECRET_LIFETIME_DEFAULT; 84 SCTP_BASE_SYSCTL(sctp_rto_max_default) = SCTPCTL_RTO_MAX_DEFAULT; 85 SCTP_BASE_SYSCTL(sctp_rto_min_default) = SCTPCTL_RTO_MIN_DEFAULT; 86 SCTP_BASE_SYSCTL(sctp_rto_initial_default) = SCTPCTL_RTO_INITIAL_DEFAULT; 87 SCTP_BASE_SYSCTL(sctp_init_rto_max_default) = SCTPCTL_INIT_RTO_MAX_DEFAULT; 88 SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default) = SCTPCTL_VALID_COOKIE_LIFE_DEFAULT; 89 SCTP_BASE_SYSCTL(sctp_init_rtx_max_default) = SCTPCTL_INIT_RTX_MAX_DEFAULT; 90 SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default) = SCTPCTL_ASSOC_RTX_MAX_DEFAULT; 91 SCTP_BASE_SYSCTL(sctp_path_rtx_max_default) = SCTPCTL_PATH_RTX_MAX_DEFAULT; 92 SCTP_BASE_SYSCTL(sctp_path_pf_threshold) = SCTPCTL_PATH_PF_THRESHOLD_DEFAULT; 93 SCTP_BASE_SYSCTL(sctp_add_more_threshold) = SCTPCTL_ADD_MORE_ON_OUTPUT_DEFAULT; 94 SCTP_BASE_SYSCTL(sctp_nr_incoming_streams_default) = SCTPCTL_INCOMING_STREAMS_DEFAULT; 95 SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default) = SCTPCTL_OUTGOING_STREAMS_DEFAULT; 96 SCTP_BASE_SYSCTL(sctp_cmt_on_off) = SCTPCTL_CMT_ON_OFF_DEFAULT; 97 SCTP_BASE_SYSCTL(sctp_cmt_use_dac) = SCTPCTL_CMT_USE_DAC_DEFAULT; 98 SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst) = SCTPCTL_CWND_MAXBURST_DEFAULT; 99 SCTP_BASE_SYSCTL(sctp_nat_friendly) = SCTPCTL_NAT_FRIENDLY_DEFAULT; 100 SCTP_BASE_SYSCTL(sctp_L2_abc_variable) = SCTPCTL_ABC_L_VAR_DEFAULT; 101 SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count) = SCTPCTL_MAX_CHAINED_MBUFS_DEFAULT; 102 SCTP_BASE_SYSCTL(sctp_do_drain) = SCTPCTL_DO_SCTP_DRAIN_DEFAULT; 103 SCTP_BASE_SYSCTL(sctp_hb_maxburst) = SCTPCTL_HB_MAX_BURST_DEFAULT; 104 SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit) = SCTPCTL_ABORT_AT_LIMIT_DEFAULT; 105 SCTP_BASE_SYSCTL(sctp_min_residual) = SCTPCTL_MIN_RESIDUAL_DEFAULT; 106 SCTP_BASE_SYSCTL(sctp_max_retran_chunk) = SCTPCTL_MAX_RETRAN_CHUNK_DEFAULT; 107 SCTP_BASE_SYSCTL(sctp_logging_level) = SCTPCTL_LOGGING_LEVEL_DEFAULT; 108 SCTP_BASE_SYSCTL(sctp_default_cc_module) = SCTPCTL_DEFAULT_CC_MODULE_DEFAULT; 109 SCTP_BASE_SYSCTL(sctp_default_ss_module) = SCTPCTL_DEFAULT_SS_MODULE_DEFAULT; 110 SCTP_BASE_SYSCTL(sctp_default_frag_interleave) = SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DEFAULT; 111 SCTP_BASE_SYSCTL(sctp_mobility_base) = SCTPCTL_MOBILITY_BASE_DEFAULT; 112 SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff) = SCTPCTL_MOBILITY_FASTHANDOFF_DEFAULT; 113 SCTP_BASE_SYSCTL(sctp_vtag_time_wait) = SCTPCTL_TIME_WAIT_DEFAULT; 114 SCTP_BASE_SYSCTL(sctp_buffer_splitting) = SCTPCTL_BUFFER_SPLITTING_DEFAULT; 115 SCTP_BASE_SYSCTL(sctp_initial_cwnd) = SCTPCTL_INITIAL_CWND_DEFAULT; 116 SCTP_BASE_SYSCTL(sctp_rttvar_bw) = SCTPCTL_RTTVAR_BW_DEFAULT; 117 SCTP_BASE_SYSCTL(sctp_rttvar_rtt) = SCTPCTL_RTTVAR_RTT_DEFAULT; 118 SCTP_BASE_SYSCTL(sctp_rttvar_eqret) = SCTPCTL_RTTVAR_EQRET_DEFAULT; 119 SCTP_BASE_SYSCTL(sctp_steady_step) = SCTPCTL_RTTVAR_STEADYS_DEFAULT; 120 SCTP_BASE_SYSCTL(sctp_use_dccc_ecn) = SCTPCTL_RTTVAR_DCCCECN_DEFAULT; 121 SCTP_BASE_SYSCTL(sctp_blackhole) = SCTPCTL_BLACKHOLE_DEFAULT; 122 SCTP_BASE_SYSCTL(sctp_sendall_limit) = SCTPCTL_SENDALL_LIMIT_DEFAULT; 123 SCTP_BASE_SYSCTL(sctp_diag_info_code) = SCTPCTL_DIAG_INFO_CODE_DEFAULT; 124 #if defined(SCTP_LOCAL_TRACE_BUF) 125 memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log)); 126 #endif 127 SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = SCTPCTL_UDP_TUNNELING_PORT_DEFAULT; 128 SCTP_BASE_SYSCTL(sctp_enable_sack_immediately) = SCTPCTL_SACK_IMMEDIATELY_ENABLE_DEFAULT; 129 SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly) = SCTPCTL_NAT_FRIENDLY_INITS_DEFAULT; 130 #if defined(SCTP_DEBUG) 131 SCTP_BASE_SYSCTL(sctp_debug_on) = SCTPCTL_DEBUG_DEFAULT; 132 #endif 133 #if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) 134 SCTP_BASE_SYSCTL(sctp_output_unlocked) = SCTPCTL_OUTPUT_UNLOCKED_DEFAULT; 135 #endif 136 } 137 138 139 /* It returns an upper limit. No filtering is done here */ 140 static unsigned int 141 sctp_sysctl_number_of_addresses(struct sctp_inpcb *inp) 142 { 143 unsigned int cnt; 144 struct sctp_vrf *vrf; 145 struct sctp_ifn *sctp_ifn; 146 struct sctp_ifa *sctp_ifa; 147 struct sctp_laddr *laddr; 148 149 cnt = 0; 150 /* neither Mac OS X nor FreeBSD support mulitple routing functions */ 151 if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) { 152 return (0); 153 } 154 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { 155 LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) { 156 LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) { 157 switch (sctp_ifa->address.sa.sa_family) { 158 #ifdef INET 159 case AF_INET: 160 #endif 161 #ifdef INET6 162 case AF_INET6: 163 #endif 164 cnt++; 165 break; 166 default: 167 break; 168 } 169 } 170 } 171 } else { 172 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) { 173 switch (laddr->ifa->address.sa.sa_family) { 174 #ifdef INET 175 case AF_INET: 176 #endif 177 #ifdef INET6 178 case AF_INET6: 179 #endif 180 cnt++; 181 break; 182 default: 183 break; 184 } 185 } 186 } 187 return (cnt); 188 } 189 190 static int 191 sctp_sysctl_copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sysctl_req *req) 192 { 193 struct sctp_ifn *sctp_ifn; 194 struct sctp_ifa *sctp_ifa; 195 int loopback_scope, ipv4_local_scope, local_scope, site_scope; 196 int ipv4_addr_legal, ipv6_addr_legal; 197 struct sctp_vrf *vrf; 198 struct xsctp_laddr xladdr; 199 struct sctp_laddr *laddr; 200 int error; 201 202 /* Turn on all the appropriate scope */ 203 if (stcb) { 204 /* use association specific values */ 205 loopback_scope = stcb->asoc.scope.loopback_scope; 206 ipv4_local_scope = stcb->asoc.scope.ipv4_local_scope; 207 local_scope = stcb->asoc.scope.local_scope; 208 site_scope = stcb->asoc.scope.site_scope; 209 ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal; 210 ipv6_addr_legal = stcb->asoc.scope.ipv6_addr_legal; 211 } else { 212 /* Use generic values for endpoints. */ 213 loopback_scope = 1; 214 ipv4_local_scope = 1; 215 local_scope = 1; 216 site_scope = 1; 217 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { 218 ipv6_addr_legal = 1; 219 if (SCTP_IPV6_V6ONLY(inp)) { 220 ipv4_addr_legal = 0; 221 } else { 222 ipv4_addr_legal = 1; 223 } 224 } else { 225 ipv6_addr_legal = 0; 226 ipv4_addr_legal = 1; 227 } 228 } 229 230 /* neither Mac OS X nor FreeBSD support mulitple routing functions */ 231 if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) { 232 SCTP_INP_RUNLOCK(inp); 233 SCTP_INP_INFO_RUNLOCK(); 234 return (-1); 235 } 236 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { 237 LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) { 238 if ((loopback_scope == 0) && SCTP_IFN_IS_IFT_LOOP(sctp_ifn)) 239 /* Skip loopback if loopback_scope not set */ 240 continue; 241 LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) { 242 if (stcb) { 243 /* 244 * ignore if blacklisted at 245 * association level 246 */ 247 if (sctp_is_addr_restricted(stcb, sctp_ifa)) 248 continue; 249 } 250 switch (sctp_ifa->address.sa.sa_family) { 251 #ifdef INET 252 case AF_INET: 253 if (ipv4_addr_legal) { 254 struct sockaddr_in *sin; 255 256 sin = &sctp_ifa->address.sin; 257 if (sin->sin_addr.s_addr == 0) 258 continue; 259 if (prison_check_ip4(inp->ip_inp.inp.inp_cred, 260 &sin->sin_addr) != 0) { 261 continue; 262 } 263 if ((ipv4_local_scope == 0) && (IN4_ISPRIVATE_ADDRESS(&sin->sin_addr))) 264 continue; 265 } else { 266 continue; 267 } 268 break; 269 #endif 270 #ifdef INET6 271 case AF_INET6: 272 if (ipv6_addr_legal) { 273 struct sockaddr_in6 *sin6; 274 275 sin6 = &sctp_ifa->address.sin6; 276 if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) 277 continue; 278 if (prison_check_ip6(inp->ip_inp.inp.inp_cred, 279 &sin6->sin6_addr) != 0) { 280 continue; 281 } 282 if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { 283 if (local_scope == 0) 284 continue; 285 } 286 if ((site_scope == 0) && (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr))) 287 continue; 288 } else { 289 continue; 290 } 291 break; 292 #endif 293 default: 294 continue; 295 } 296 memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr)); 297 memcpy((void *)&xladdr.address, (const void *)&sctp_ifa->address, sizeof(union sctp_sockstore)); 298 SCTP_INP_RUNLOCK(inp); 299 SCTP_INP_INFO_RUNLOCK(); 300 error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr)); 301 if (error) { 302 return (error); 303 } else { 304 SCTP_INP_INFO_RLOCK(); 305 SCTP_INP_RLOCK(inp); 306 } 307 } 308 } 309 } else { 310 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) { 311 /* ignore if blacklisted at association level */ 312 if (stcb && sctp_is_addr_restricted(stcb, laddr->ifa)) 313 continue; 314 memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr)); 315 memcpy((void *)&xladdr.address, (const void *)&laddr->ifa->address, sizeof(union sctp_sockstore)); 316 xladdr.start_time.tv_sec = (uint32_t)laddr->start_time.tv_sec; 317 xladdr.start_time.tv_usec = (uint32_t)laddr->start_time.tv_usec; 318 SCTP_INP_RUNLOCK(inp); 319 SCTP_INP_INFO_RUNLOCK(); 320 error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr)); 321 if (error) { 322 return (error); 323 } else { 324 SCTP_INP_INFO_RLOCK(); 325 SCTP_INP_RLOCK(inp); 326 } 327 } 328 } 329 memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr)); 330 xladdr.last = 1; 331 SCTP_INP_RUNLOCK(inp); 332 SCTP_INP_INFO_RUNLOCK(); 333 error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr)); 334 335 if (error) { 336 return (error); 337 } else { 338 SCTP_INP_INFO_RLOCK(); 339 SCTP_INP_RLOCK(inp); 340 return (0); 341 } 342 } 343 344 /* 345 * sysctl functions 346 */ 347 static int 348 sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS) 349 { 350 unsigned int number_of_endpoints; 351 unsigned int number_of_local_addresses; 352 unsigned int number_of_associations; 353 unsigned int number_of_remote_addresses; 354 unsigned int n; 355 int error; 356 struct sctp_inpcb *inp; 357 struct sctp_tcb *stcb; 358 struct sctp_nets *net; 359 struct xsctp_inpcb xinpcb; 360 struct xsctp_tcb xstcb; 361 struct xsctp_raddr xraddr; 362 struct socket *so; 363 364 number_of_endpoints = 0; 365 number_of_local_addresses = 0; 366 number_of_associations = 0; 367 number_of_remote_addresses = 0; 368 369 SCTP_INP_INFO_RLOCK(); 370 if (req->oldptr == NULL) { 371 LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) { 372 SCTP_INP_RLOCK(inp); 373 number_of_endpoints++; 374 number_of_local_addresses += sctp_sysctl_number_of_addresses(inp); 375 LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) { 376 number_of_associations++; 377 number_of_local_addresses += sctp_sysctl_number_of_addresses(inp); 378 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { 379 number_of_remote_addresses++; 380 } 381 } 382 SCTP_INP_RUNLOCK(inp); 383 } 384 SCTP_INP_INFO_RUNLOCK(); 385 n = (number_of_endpoints + 1) * sizeof(struct xsctp_inpcb) + 386 (number_of_local_addresses + number_of_endpoints + number_of_associations) * sizeof(struct xsctp_laddr) + 387 (number_of_associations + number_of_endpoints) * sizeof(struct xsctp_tcb) + 388 (number_of_remote_addresses + number_of_associations) * sizeof(struct xsctp_raddr); 389 390 /* request some more memory than needed */ 391 req->oldidx = (n + n / 8); 392 return (0); 393 } 394 if (req->newptr != NULL) { 395 SCTP_INP_INFO_RUNLOCK(); 396 SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_SYSCTL, EPERM); 397 return (EPERM); 398 } 399 memset(&xinpcb, 0, sizeof(xinpcb)); 400 memset(&xstcb, 0, sizeof(xstcb)); 401 memset(&xraddr, 0, sizeof(xraddr)); 402 LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) { 403 SCTP_INP_RLOCK(inp); 404 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) { 405 /* if its allgone it is being freed - skip it */ 406 goto skip; 407 } 408 xinpcb.last = 0; 409 xinpcb.local_port = ntohs(inp->sctp_lport); 410 xinpcb.flags = inp->sctp_flags; 411 xinpcb.features = inp->sctp_features; 412 xinpcb.total_sends = inp->total_sends; 413 xinpcb.total_recvs = inp->total_recvs; 414 xinpcb.total_nospaces = inp->total_nospaces; 415 xinpcb.fragmentation_point = inp->sctp_frag_point; 416 xinpcb.socket = (uintptr_t)inp->sctp_socket; 417 so = inp->sctp_socket; 418 if ((so == NULL) || 419 (!SCTP_IS_LISTENING(inp)) || 420 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) { 421 xinpcb.qlen = 0; 422 xinpcb.maxqlen = 0; 423 } else { 424 xinpcb.qlen = so->sol_qlen; 425 xinpcb.qlen_old = so->sol_qlen > USHRT_MAX ? 426 USHRT_MAX : (uint16_t)so->sol_qlen; 427 xinpcb.maxqlen = so->sol_qlimit; 428 xinpcb.maxqlen_old = so->sol_qlimit > USHRT_MAX ? 429 USHRT_MAX : (uint16_t)so->sol_qlimit; 430 } 431 SCTP_INP_INCR_REF(inp); 432 SCTP_INP_RUNLOCK(inp); 433 SCTP_INP_INFO_RUNLOCK(); 434 error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb)); 435 if (error) { 436 SCTP_INP_DECR_REF(inp); 437 return (error); 438 } 439 SCTP_INP_INFO_RLOCK(); 440 SCTP_INP_RLOCK(inp); 441 error = sctp_sysctl_copy_out_local_addresses(inp, NULL, req); 442 if (error) { 443 SCTP_INP_DECR_REF(inp); 444 return (error); 445 } 446 LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) { 447 SCTP_TCB_LOCK(stcb); 448 atomic_add_int(&stcb->asoc.refcnt, 1); 449 SCTP_TCB_UNLOCK(stcb); 450 xstcb.last = 0; 451 xstcb.local_port = ntohs(inp->sctp_lport); 452 xstcb.remote_port = ntohs(stcb->rport); 453 if (stcb->asoc.primary_destination != NULL) 454 xstcb.primary_addr = stcb->asoc.primary_destination->ro._l_addr; 455 xstcb.heartbeat_interval = stcb->asoc.heart_beat_delay; 456 xstcb.state = (uint32_t)sctp_map_assoc_state(stcb->asoc.state); 457 /* 7.0 does not support these */ 458 xstcb.assoc_id = sctp_get_associd(stcb); 459 xstcb.peers_rwnd = stcb->asoc.peers_rwnd; 460 xstcb.in_streams = stcb->asoc.streamincnt; 461 xstcb.out_streams = stcb->asoc.streamoutcnt; 462 xstcb.max_nr_retrans = stcb->asoc.overall_error_count; 463 xstcb.primary_process = 0; /* not really supported 464 * yet */ 465 xstcb.T1_expireries = stcb->asoc.timoinit + stcb->asoc.timocookie; 466 xstcb.T2_expireries = stcb->asoc.timoshutdown + stcb->asoc.timoshutdownack; 467 xstcb.retransmitted_tsns = stcb->asoc.marked_retrans; 468 xstcb.start_time.tv_sec = (uint32_t)stcb->asoc.start_time.tv_sec; 469 xstcb.start_time.tv_usec = (uint32_t)stcb->asoc.start_time.tv_usec; 470 xstcb.discontinuity_time.tv_sec = (uint32_t)stcb->asoc.discontinuity_time.tv_sec; 471 xstcb.discontinuity_time.tv_usec = (uint32_t)stcb->asoc.discontinuity_time.tv_usec; 472 xstcb.total_sends = stcb->total_sends; 473 xstcb.total_recvs = stcb->total_recvs; 474 xstcb.local_tag = stcb->asoc.my_vtag; 475 xstcb.remote_tag = stcb->asoc.peer_vtag; 476 xstcb.initial_tsn = stcb->asoc.init_seq_number; 477 xstcb.highest_tsn = stcb->asoc.sending_seq - 1; 478 xstcb.cumulative_tsn = stcb->asoc.last_acked_seq; 479 xstcb.cumulative_tsn_ack = stcb->asoc.cumulative_tsn; 480 xstcb.mtu = stcb->asoc.smallest_mtu; 481 xstcb.refcnt = stcb->asoc.refcnt; 482 SCTP_INP_RUNLOCK(inp); 483 SCTP_INP_INFO_RUNLOCK(); 484 error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb)); 485 if (error) { 486 SCTP_INP_DECR_REF(inp); 487 atomic_subtract_int(&stcb->asoc.refcnt, 1); 488 return (error); 489 } 490 SCTP_INP_INFO_RLOCK(); 491 SCTP_INP_RLOCK(inp); 492 error = sctp_sysctl_copy_out_local_addresses(inp, stcb, req); 493 if (error) { 494 SCTP_INP_DECR_REF(inp); 495 atomic_subtract_int(&stcb->asoc.refcnt, 1); 496 return (error); 497 } 498 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { 499 xraddr.last = 0; 500 xraddr.address = net->ro._l_addr; 501 xraddr.active = ((net->dest_state & SCTP_ADDR_REACHABLE) == SCTP_ADDR_REACHABLE); 502 xraddr.confirmed = ((net->dest_state & SCTP_ADDR_UNCONFIRMED) == 0); 503 xraddr.heartbeat_enabled = ((net->dest_state & SCTP_ADDR_NOHB) == 0); 504 xraddr.potentially_failed = ((net->dest_state & SCTP_ADDR_PF) == SCTP_ADDR_PF); 505 xraddr.rto = net->RTO; 506 xraddr.max_path_rtx = net->failure_threshold; 507 xraddr.rtx = net->marked_retrans; 508 xraddr.error_counter = net->error_count; 509 xraddr.cwnd = net->cwnd; 510 xraddr.flight_size = net->flight_size; 511 xraddr.mtu = net->mtu; 512 xraddr.rtt = net->rtt / 1000; 513 xraddr.heartbeat_interval = net->heart_beat_delay; 514 xraddr.ssthresh = net->ssthresh; 515 xraddr.encaps_port = net->port; 516 if (net->dest_state & SCTP_ADDR_UNCONFIRMED) { 517 xraddr.state = SCTP_UNCONFIRMED; 518 } else if (net->dest_state & SCTP_ADDR_REACHABLE) { 519 xraddr.state = SCTP_ACTIVE; 520 } else { 521 xraddr.state = SCTP_INACTIVE; 522 } 523 xraddr.start_time.tv_sec = (uint32_t)net->start_time.tv_sec; 524 xraddr.start_time.tv_usec = (uint32_t)net->start_time.tv_usec; 525 SCTP_INP_RUNLOCK(inp); 526 SCTP_INP_INFO_RUNLOCK(); 527 error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr)); 528 if (error) { 529 SCTP_INP_DECR_REF(inp); 530 atomic_subtract_int(&stcb->asoc.refcnt, 1); 531 return (error); 532 } 533 SCTP_INP_INFO_RLOCK(); 534 SCTP_INP_RLOCK(inp); 535 } 536 atomic_subtract_int(&stcb->asoc.refcnt, 1); 537 memset((void *)&xraddr, 0, sizeof(struct xsctp_raddr)); 538 xraddr.last = 1; 539 SCTP_INP_RUNLOCK(inp); 540 SCTP_INP_INFO_RUNLOCK(); 541 error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr)); 542 if (error) { 543 SCTP_INP_DECR_REF(inp); 544 return (error); 545 } 546 SCTP_INP_INFO_RLOCK(); 547 SCTP_INP_RLOCK(inp); 548 } 549 SCTP_INP_DECR_REF(inp); 550 SCTP_INP_RUNLOCK(inp); 551 SCTP_INP_INFO_RUNLOCK(); 552 memset((void *)&xstcb, 0, sizeof(struct xsctp_tcb)); 553 xstcb.last = 1; 554 error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb)); 555 if (error) { 556 return (error); 557 } 558 skip: 559 SCTP_INP_INFO_RLOCK(); 560 } 561 SCTP_INP_INFO_RUNLOCK(); 562 563 memset((void *)&xinpcb, 0, sizeof(struct xsctp_inpcb)); 564 xinpcb.last = 1; 565 error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb)); 566 return (error); 567 } 568 569 static int 570 sctp_sysctl_handle_udp_tunneling(SYSCTL_HANDLER_ARGS) 571 { 572 int error; 573 uint32_t old, new; 574 575 SCTP_INP_INFO_RLOCK(); 576 old = SCTP_BASE_SYSCTL(sctp_udp_tunneling_port); 577 SCTP_INP_INFO_RUNLOCK(); 578 new = old; 579 error = sysctl_handle_int(oidp, &new, 0, req); 580 if ((error == 0) && 581 (req->newptr != NULL)) { 582 #if (SCTPCTL_UDP_TUNNELING_PORT_MIN == 0) 583 if (new > SCTPCTL_UDP_TUNNELING_PORT_MAX) { 584 #else 585 if ((new < SCTPCTL_UDP_TUNNELING_PORT_MIN) || 586 (new > SCTPCTL_UDP_TUNNELING_PORT_MAX)) { 587 #endif 588 error = EINVAL; 589 } else { 590 SCTP_INP_INFO_WLOCK(); 591 SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = new; 592 if (old != 0) { 593 sctp_over_udp_stop(); 594 } 595 if (new != 0) { 596 error = sctp_over_udp_start(); 597 } 598 SCTP_INP_INFO_WUNLOCK(); 599 } 600 } 601 return (error); 602 } 603 604 605 static int 606 sctp_sysctl_handle_auth(SYSCTL_HANDLER_ARGS) 607 { 608 int error; 609 uint32_t new; 610 611 new = SCTP_BASE_SYSCTL(sctp_auth_enable); 612 error = sysctl_handle_int(oidp, &new, 0, req); 613 if ((error == 0) && 614 (req->newptr != NULL)) { 615 #if (SCTPCTL_AUTH_ENABLE_MIN == 0) 616 if ((new > SCTPCTL_AUTH_ENABLE_MAX) || 617 ((new == 0) && (SCTP_BASE_SYSCTL(sctp_asconf_enable) == 1))) { 618 #else 619 if ((new < SCTPCTL_AUTH_ENABLE_MIN) || 620 (new > SCTPCTL_AUTH_ENABLE_MAX) || 621 ((new == 0) && (SCTP_BASE_SYSCTL(sctp_asconf_enable) == 1))) { 622 #endif 623 error = EINVAL; 624 } else { 625 SCTP_BASE_SYSCTL(sctp_auth_enable) = new; 626 } 627 } 628 return (error); 629 } 630 631 static int 632 sctp_sysctl_handle_asconf(SYSCTL_HANDLER_ARGS) 633 { 634 int error; 635 uint32_t new; 636 637 new = SCTP_BASE_SYSCTL(sctp_asconf_enable); 638 error = sysctl_handle_int(oidp, &new, 0, req); 639 if ((error == 0) && 640 (req->newptr != NULL)) { 641 #if (SCTPCTL_ASCONF_ENABLE_MIN == 0) 642 if ((new > SCTPCTL_ASCONF_ENABLE_MAX) || 643 ((new == 1) && (SCTP_BASE_SYSCTL(sctp_auth_enable) == 0))) { 644 #else 645 if ((new < SCTPCTL_ASCONF_ENABLE_MIN) || 646 (new > SCTPCTL_ASCONF_ENABLE_MAX) || 647 ((new == 1) && (SCTP_BASE_SYSCTL(sctp_auth_enable) == 0))) { 648 #endif 649 error = EINVAL; 650 } else { 651 SCTP_BASE_SYSCTL(sctp_asconf_enable) = new; 652 } 653 } 654 return (error); 655 } 656 657 static int 658 sctp_sysctl_handle_stats(SYSCTL_HANDLER_ARGS) 659 { 660 int error; 661 #if defined(SMP) && defined(SCTP_USE_PERCPU_STAT) 662 struct sctpstat *sarry; 663 struct sctpstat sb; 664 int cpu; 665 #endif 666 struct sctpstat sb_temp; 667 668 if ((req->newptr != NULL) && 669 (req->newlen != sizeof(struct sctpstat))) { 670 return (EINVAL); 671 } 672 memset(&sb_temp, 0, sizeof(struct sctpstat)); 673 674 if (req->newptr != NULL) { 675 error = SYSCTL_IN(req, &sb_temp, sizeof(struct sctpstat)); 676 if (error != 0) { 677 return (error); 678 } 679 } 680 #if defined(SMP) && defined(SCTP_USE_PERCPU_STAT) 681 memset(&sb, 0, sizeof(sb)); 682 for (cpu = 0; cpu < mp_maxid; cpu++) { 683 sarry = &SCTP_BASE_STATS[cpu]; 684 if (sarry->sctps_discontinuitytime.tv_sec > sb.sctps_discontinuitytime.tv_sec) { 685 sb.sctps_discontinuitytime.tv_sec = sarry->sctps_discontinuitytime.tv_sec; 686 sb.sctps_discontinuitytime.tv_usec = sarry->sctps_discontinuitytime.tv_usec; 687 } 688 sb.sctps_currestab += sarry->sctps_currestab; 689 sb.sctps_activeestab += sarry->sctps_activeestab; 690 sb.sctps_restartestab += sarry->sctps_restartestab; 691 sb.sctps_collisionestab += sarry->sctps_collisionestab; 692 sb.sctps_passiveestab += sarry->sctps_passiveestab; 693 sb.sctps_aborted += sarry->sctps_aborted; 694 sb.sctps_shutdown += sarry->sctps_shutdown; 695 sb.sctps_outoftheblue += sarry->sctps_outoftheblue; 696 sb.sctps_checksumerrors += sarry->sctps_checksumerrors; 697 sb.sctps_outcontrolchunks += sarry->sctps_outcontrolchunks; 698 sb.sctps_outorderchunks += sarry->sctps_outorderchunks; 699 sb.sctps_outunorderchunks += sarry->sctps_outunorderchunks; 700 sb.sctps_incontrolchunks += sarry->sctps_incontrolchunks; 701 sb.sctps_inorderchunks += sarry->sctps_inorderchunks; 702 sb.sctps_inunorderchunks += sarry->sctps_inunorderchunks; 703 sb.sctps_fragusrmsgs += sarry->sctps_fragusrmsgs; 704 sb.sctps_reasmusrmsgs += sarry->sctps_reasmusrmsgs; 705 sb.sctps_outpackets += sarry->sctps_outpackets; 706 sb.sctps_inpackets += sarry->sctps_inpackets; 707 sb.sctps_recvpackets += sarry->sctps_recvpackets; 708 sb.sctps_recvdatagrams += sarry->sctps_recvdatagrams; 709 sb.sctps_recvpktwithdata += sarry->sctps_recvpktwithdata; 710 sb.sctps_recvsacks += sarry->sctps_recvsacks; 711 sb.sctps_recvdata += sarry->sctps_recvdata; 712 sb.sctps_recvdupdata += sarry->sctps_recvdupdata; 713 sb.sctps_recvheartbeat += sarry->sctps_recvheartbeat; 714 sb.sctps_recvheartbeatack += sarry->sctps_recvheartbeatack; 715 sb.sctps_recvecne += sarry->sctps_recvecne; 716 sb.sctps_recvauth += sarry->sctps_recvauth; 717 sb.sctps_recvauthmissing += sarry->sctps_recvauthmissing; 718 sb.sctps_recvivalhmacid += sarry->sctps_recvivalhmacid; 719 sb.sctps_recvivalkeyid += sarry->sctps_recvivalkeyid; 720 sb.sctps_recvauthfailed += sarry->sctps_recvauthfailed; 721 sb.sctps_recvexpress += sarry->sctps_recvexpress; 722 sb.sctps_recvexpressm += sarry->sctps_recvexpressm; 723 sb.sctps_recvswcrc += sarry->sctps_recvswcrc; 724 sb.sctps_recvhwcrc += sarry->sctps_recvhwcrc; 725 sb.sctps_sendpackets += sarry->sctps_sendpackets; 726 sb.sctps_sendsacks += sarry->sctps_sendsacks; 727 sb.sctps_senddata += sarry->sctps_senddata; 728 sb.sctps_sendretransdata += sarry->sctps_sendretransdata; 729 sb.sctps_sendfastretrans += sarry->sctps_sendfastretrans; 730 sb.sctps_sendmultfastretrans += sarry->sctps_sendmultfastretrans; 731 sb.sctps_sendheartbeat += sarry->sctps_sendheartbeat; 732 sb.sctps_sendecne += sarry->sctps_sendecne; 733 sb.sctps_sendauth += sarry->sctps_sendauth; 734 sb.sctps_senderrors += sarry->sctps_senderrors; 735 sb.sctps_sendswcrc += sarry->sctps_sendswcrc; 736 sb.sctps_sendhwcrc += sarry->sctps_sendhwcrc; 737 sb.sctps_pdrpfmbox += sarry->sctps_pdrpfmbox; 738 sb.sctps_pdrpfehos += sarry->sctps_pdrpfehos; 739 sb.sctps_pdrpmbda += sarry->sctps_pdrpmbda; 740 sb.sctps_pdrpmbct += sarry->sctps_pdrpmbct; 741 sb.sctps_pdrpbwrpt += sarry->sctps_pdrpbwrpt; 742 sb.sctps_pdrpcrupt += sarry->sctps_pdrpcrupt; 743 sb.sctps_pdrpnedat += sarry->sctps_pdrpnedat; 744 sb.sctps_pdrppdbrk += sarry->sctps_pdrppdbrk; 745 sb.sctps_pdrptsnnf += sarry->sctps_pdrptsnnf; 746 sb.sctps_pdrpdnfnd += sarry->sctps_pdrpdnfnd; 747 sb.sctps_pdrpdiwnp += sarry->sctps_pdrpdiwnp; 748 sb.sctps_pdrpdizrw += sarry->sctps_pdrpdizrw; 749 sb.sctps_pdrpbadd += sarry->sctps_pdrpbadd; 750 sb.sctps_pdrpmark += sarry->sctps_pdrpmark; 751 sb.sctps_timoiterator += sarry->sctps_timoiterator; 752 sb.sctps_timodata += sarry->sctps_timodata; 753 sb.sctps_timowindowprobe += sarry->sctps_timowindowprobe; 754 sb.sctps_timoinit += sarry->sctps_timoinit; 755 sb.sctps_timosack += sarry->sctps_timosack; 756 sb.sctps_timoshutdown += sarry->sctps_timoshutdown; 757 sb.sctps_timoheartbeat += sarry->sctps_timoheartbeat; 758 sb.sctps_timocookie += sarry->sctps_timocookie; 759 sb.sctps_timosecret += sarry->sctps_timosecret; 760 sb.sctps_timopathmtu += sarry->sctps_timopathmtu; 761 sb.sctps_timoshutdownack += sarry->sctps_timoshutdownack; 762 sb.sctps_timoshutdownguard += sarry->sctps_timoshutdownguard; 763 sb.sctps_timostrmrst += sarry->sctps_timostrmrst; 764 sb.sctps_timoearlyfr += sarry->sctps_timoearlyfr; 765 sb.sctps_timoasconf += sarry->sctps_timoasconf; 766 sb.sctps_timodelprim += sarry->sctps_timodelprim; 767 sb.sctps_timoautoclose += sarry->sctps_timoautoclose; 768 sb.sctps_timoassockill += sarry->sctps_timoassockill; 769 sb.sctps_timoinpkill += sarry->sctps_timoinpkill; 770 sb.sctps_hdrops += sarry->sctps_hdrops; 771 sb.sctps_badsum += sarry->sctps_badsum; 772 sb.sctps_noport += sarry->sctps_noport; 773 sb.sctps_badvtag += sarry->sctps_badvtag; 774 sb.sctps_badsid += sarry->sctps_badsid; 775 sb.sctps_nomem += sarry->sctps_nomem; 776 sb.sctps_fastretransinrtt += sarry->sctps_fastretransinrtt; 777 sb.sctps_markedretrans += sarry->sctps_markedretrans; 778 sb.sctps_naglesent += sarry->sctps_naglesent; 779 sb.sctps_naglequeued += sarry->sctps_naglequeued; 780 sb.sctps_maxburstqueued += sarry->sctps_maxburstqueued; 781 sb.sctps_ifnomemqueued += sarry->sctps_ifnomemqueued; 782 sb.sctps_windowprobed += sarry->sctps_windowprobed; 783 sb.sctps_lowlevelerr += sarry->sctps_lowlevelerr; 784 sb.sctps_lowlevelerrusr += sarry->sctps_lowlevelerrusr; 785 sb.sctps_datadropchklmt += sarry->sctps_datadropchklmt; 786 sb.sctps_datadroprwnd += sarry->sctps_datadroprwnd; 787 sb.sctps_ecnereducedcwnd += sarry->sctps_ecnereducedcwnd; 788 sb.sctps_vtagexpress += sarry->sctps_vtagexpress; 789 sb.sctps_vtagbogus += sarry->sctps_vtagbogus; 790 sb.sctps_primary_randry += sarry->sctps_primary_randry; 791 sb.sctps_cmt_randry += sarry->sctps_cmt_randry; 792 sb.sctps_slowpath_sack += sarry->sctps_slowpath_sack; 793 sb.sctps_wu_sacks_sent += sarry->sctps_wu_sacks_sent; 794 sb.sctps_sends_with_flags += sarry->sctps_sends_with_flags; 795 sb.sctps_sends_with_unord += sarry->sctps_sends_with_unord; 796 sb.sctps_sends_with_eof += sarry->sctps_sends_with_eof; 797 sb.sctps_sends_with_abort += sarry->sctps_sends_with_abort; 798 sb.sctps_protocol_drain_calls += sarry->sctps_protocol_drain_calls; 799 sb.sctps_protocol_drains_done += sarry->sctps_protocol_drains_done; 800 sb.sctps_read_peeks += sarry->sctps_read_peeks; 801 sb.sctps_cached_chk += sarry->sctps_cached_chk; 802 sb.sctps_cached_strmoq += sarry->sctps_cached_strmoq; 803 sb.sctps_left_abandon += sarry->sctps_left_abandon; 804 sb.sctps_send_burst_avoid += sarry->sctps_send_burst_avoid; 805 sb.sctps_send_cwnd_avoid += sarry->sctps_send_cwnd_avoid; 806 sb.sctps_fwdtsn_map_over += sarry->sctps_fwdtsn_map_over; 807 if (req->newptr != NULL) { 808 memcpy(sarry, &sb_temp, sizeof(struct sctpstat)); 809 } 810 } 811 error = SYSCTL_OUT(req, &sb, sizeof(struct sctpstat)); 812 #else 813 error = SYSCTL_OUT(req, &SCTP_BASE_STATS, sizeof(struct sctpstat)); 814 if (error != 0) { 815 return (error); 816 } 817 if (req->newptr != NULL) { 818 memcpy(&SCTP_BASE_STATS, &sb_temp, sizeof(struct sctpstat)); 819 } 820 #endif 821 return (error); 822 } 823 824 #if defined(SCTP_LOCAL_TRACE_BUF) 825 static int 826 sctp_sysctl_handle_trace_log(SYSCTL_HANDLER_ARGS) 827 { 828 int error; 829 830 error = SYSCTL_OUT(req, &SCTP_BASE_SYSCTL(sctp_log), sizeof(struct sctp_log)); 831 return (error); 832 } 833 834 static int 835 sctp_sysctl_handle_trace_log_clear(SYSCTL_HANDLER_ARGS) 836 { 837 int error = 0; 838 839 memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log)); 840 return (error); 841 } 842 #endif 843 844 #define SCTP_UINT_SYSCTL(mib_name, var_name, prefix) \ 845 static int \ 846 sctp_sysctl_handle_##mib_name(SYSCTL_HANDLER_ARGS) \ 847 { \ 848 int error; \ 849 uint32_t new; \ 850 \ 851 new = SCTP_BASE_SYSCTL(var_name); \ 852 error = sysctl_handle_int(oidp, &new, 0, req); \ 853 if ((error == 0) && (req->newptr != NULL)) { \ 854 if ((new < prefix##_MIN) || \ 855 (new > prefix##_MAX)) { \ 856 error = EINVAL; \ 857 } else { \ 858 SCTP_BASE_SYSCTL(var_name) = new; \ 859 } \ 860 } \ 861 return (error); \ 862 } \ 863 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mib_name, \ 864 CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW, NULL, 0, \ 865 sctp_sysctl_handle_##mib_name, "UI", prefix##_DESC); 866 867 /* 868 * sysctl definitions 869 */ 870 871 SCTP_UINT_SYSCTL(sendspace, sctp_sendspace, SCTPCTL_MAXDGRAM) 872 SCTP_UINT_SYSCTL(recvspace, sctp_recvspace, SCTPCTL_RECVSPACE) 873 SCTP_UINT_SYSCTL(auto_asconf, sctp_auto_asconf, SCTPCTL_AUTOASCONF) 874 SCTP_UINT_SYSCTL(ecn_enable, sctp_ecn_enable, SCTPCTL_ECN_ENABLE) 875 SCTP_UINT_SYSCTL(pr_enable, sctp_pr_enable, SCTPCTL_PR_ENABLE) 876 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, auth_enable, CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW, 877 NULL, 0, sctp_sysctl_handle_auth, "IU", SCTPCTL_AUTH_ENABLE_DESC); 878 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, asconf_enable, CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW, 879 NULL, 0, sctp_sysctl_handle_asconf, "IU", SCTPCTL_ASCONF_ENABLE_DESC); 880 SCTP_UINT_SYSCTL(reconfig_enable, sctp_reconfig_enable, SCTPCTL_RECONFIG_ENABLE) 881 SCTP_UINT_SYSCTL(nrsack_enable, sctp_nrsack_enable, SCTPCTL_NRSACK_ENABLE) 882 SCTP_UINT_SYSCTL(pktdrop_enable, sctp_pktdrop_enable, SCTPCTL_PKTDROP_ENABLE) 883 SCTP_UINT_SYSCTL(peer_chkoh, sctp_peer_chunk_oh, SCTPCTL_PEER_CHKOH) 884 SCTP_UINT_SYSCTL(maxburst, sctp_max_burst_default, SCTPCTL_MAXBURST) 885 SCTP_UINT_SYSCTL(fr_maxburst, sctp_fr_max_burst_default, SCTPCTL_FRMAXBURST) 886 SCTP_UINT_SYSCTL(maxchunks, sctp_max_chunks_on_queue, SCTPCTL_MAXCHUNKS) 887 SCTP_UINT_SYSCTL(tcbhashsize, sctp_hashtblsize, SCTPCTL_TCBHASHSIZE) 888 SCTP_UINT_SYSCTL(pcbhashsize, sctp_pcbtblsize, SCTPCTL_PCBHASHSIZE) 889 SCTP_UINT_SYSCTL(min_split_point, sctp_min_split_point, SCTPCTL_MIN_SPLIT_POINT) 890 SCTP_UINT_SYSCTL(chunkscale, sctp_chunkscale, SCTPCTL_CHUNKSCALE) 891 SCTP_UINT_SYSCTL(delayed_sack_time, sctp_delayed_sack_time_default, SCTPCTL_DELAYED_SACK_TIME) 892 SCTP_UINT_SYSCTL(sack_freq, sctp_sack_freq_default, SCTPCTL_SACK_FREQ) 893 SCTP_UINT_SYSCTL(sys_resource, sctp_system_free_resc_limit, SCTPCTL_SYS_RESOURCE) 894 SCTP_UINT_SYSCTL(asoc_resource, sctp_asoc_free_resc_limit, SCTPCTL_ASOC_RESOURCE) 895 SCTP_UINT_SYSCTL(heartbeat_interval, sctp_heartbeat_interval_default, SCTPCTL_HEARTBEAT_INTERVAL) 896 SCTP_UINT_SYSCTL(pmtu_raise_time, sctp_pmtu_raise_time_default, SCTPCTL_PMTU_RAISE_TIME) 897 SCTP_UINT_SYSCTL(shutdown_guard_time, sctp_shutdown_guard_time_default, SCTPCTL_SHUTDOWN_GUARD_TIME) 898 SCTP_UINT_SYSCTL(secret_lifetime, sctp_secret_lifetime_default, SCTPCTL_SECRET_LIFETIME) 899 SCTP_UINT_SYSCTL(rto_max, sctp_rto_max_default, SCTPCTL_RTO_MAX) 900 SCTP_UINT_SYSCTL(rto_min, sctp_rto_min_default, SCTPCTL_RTO_MIN) 901 SCTP_UINT_SYSCTL(rto_initial, sctp_rto_initial_default, SCTPCTL_RTO_INITIAL) 902 SCTP_UINT_SYSCTL(init_rto_max, sctp_init_rto_max_default, SCTPCTL_INIT_RTO_MAX) 903 SCTP_UINT_SYSCTL(valid_cookie_life, sctp_valid_cookie_life_default, SCTPCTL_VALID_COOKIE_LIFE) 904 SCTP_UINT_SYSCTL(init_rtx_max, sctp_init_rtx_max_default, SCTPCTL_INIT_RTX_MAX) 905 SCTP_UINT_SYSCTL(assoc_rtx_max, sctp_assoc_rtx_max_default, SCTPCTL_ASSOC_RTX_MAX) 906 SCTP_UINT_SYSCTL(path_rtx_max, sctp_path_rtx_max_default, SCTPCTL_PATH_RTX_MAX) 907 SCTP_UINT_SYSCTL(path_pf_threshold, sctp_path_pf_threshold, SCTPCTL_PATH_PF_THRESHOLD) 908 SCTP_UINT_SYSCTL(add_more_on_output, sctp_add_more_threshold, SCTPCTL_ADD_MORE_ON_OUTPUT) 909 SCTP_UINT_SYSCTL(incoming_streams, sctp_nr_incoming_streams_default, SCTPCTL_INCOMING_STREAMS) 910 SCTP_UINT_SYSCTL(outgoing_streams, sctp_nr_outgoing_streams_default, SCTPCTL_OUTGOING_STREAMS) 911 SCTP_UINT_SYSCTL(cmt_on_off, sctp_cmt_on_off, SCTPCTL_CMT_ON_OFF) 912 SCTP_UINT_SYSCTL(cmt_use_dac, sctp_cmt_use_dac, SCTPCTL_CMT_USE_DAC) 913 SCTP_UINT_SYSCTL(cwnd_maxburst, sctp_use_cwnd_based_maxburst, SCTPCTL_CWND_MAXBURST) 914 SCTP_UINT_SYSCTL(nat_friendly, sctp_nat_friendly, SCTPCTL_NAT_FRIENDLY) 915 SCTP_UINT_SYSCTL(abc_l_var, sctp_L2_abc_variable, SCTPCTL_ABC_L_VAR) 916 SCTP_UINT_SYSCTL(max_chained_mbufs, sctp_mbuf_threshold_count, SCTPCTL_MAX_CHAINED_MBUFS) 917 SCTP_UINT_SYSCTL(do_sctp_drain, sctp_do_drain, SCTPCTL_DO_SCTP_DRAIN) 918 SCTP_UINT_SYSCTL(hb_max_burst, sctp_hb_maxburst, SCTPCTL_HB_MAX_BURST) 919 SCTP_UINT_SYSCTL(abort_at_limit, sctp_abort_if_one_2_one_hits_limit, SCTPCTL_ABORT_AT_LIMIT) 920 SCTP_UINT_SYSCTL(min_residual, sctp_min_residual, SCTPCTL_MIN_RESIDUAL) 921 SCTP_UINT_SYSCTL(max_retran_chunk, sctp_max_retran_chunk, SCTPCTL_MAX_RETRAN_CHUNK) 922 SCTP_UINT_SYSCTL(log_level, sctp_logging_level, SCTPCTL_LOGGING_LEVEL) 923 SCTP_UINT_SYSCTL(default_cc_module, sctp_default_cc_module, SCTPCTL_DEFAULT_CC_MODULE) 924 SCTP_UINT_SYSCTL(default_ss_module, sctp_default_ss_module, SCTPCTL_DEFAULT_SS_MODULE) 925 SCTP_UINT_SYSCTL(default_frag_interleave, sctp_default_frag_interleave, SCTPCTL_DEFAULT_FRAG_INTERLEAVE) 926 SCTP_UINT_SYSCTL(mobility_base, sctp_mobility_base, SCTPCTL_MOBILITY_BASE) 927 SCTP_UINT_SYSCTL(mobility_fasthandoff, sctp_mobility_fasthandoff, SCTPCTL_MOBILITY_FASTHANDOFF) 928 #if defined(SCTP_LOCAL_TRACE_BUF) 929 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, log, CTLFLAG_VNET | CTLTYPE_STRUCT | CTLFLAG_RD, 930 NULL, 0, sctp_sysctl_handle_trace_log, "S,sctplog", "SCTP logging (struct sctp_log)"); 931 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, clear_trace, CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW, 932 NULL, 0, sctp_sysctl_handle_trace_log_clear, "IU", "Clear SCTP Logging buffer"); 933 #endif 934 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, udp_tunneling_port, CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW, 935 NULL, 0, sctp_sysctl_handle_udp_tunneling, "IU", SCTPCTL_UDP_TUNNELING_PORT_DESC); 936 SCTP_UINT_SYSCTL(enable_sack_immediately, sctp_enable_sack_immediately, SCTPCTL_SACK_IMMEDIATELY_ENABLE) 937 SCTP_UINT_SYSCTL(nat_friendly_init, sctp_inits_include_nat_friendly, SCTPCTL_NAT_FRIENDLY_INITS) 938 SCTP_UINT_SYSCTL(vtag_time_wait, sctp_vtag_time_wait, SCTPCTL_TIME_WAIT) 939 SCTP_UINT_SYSCTL(buffer_splitting, sctp_buffer_splitting, SCTPCTL_BUFFER_SPLITTING) 940 SCTP_UINT_SYSCTL(initial_cwnd, sctp_initial_cwnd, SCTPCTL_INITIAL_CWND) 941 SCTP_UINT_SYSCTL(rttvar_bw, sctp_rttvar_bw, SCTPCTL_RTTVAR_BW) 942 SCTP_UINT_SYSCTL(rttvar_rtt, sctp_rttvar_rtt, SCTPCTL_RTTVAR_RTT) 943 SCTP_UINT_SYSCTL(rttvar_eqret, sctp_rttvar_eqret, SCTPCTL_RTTVAR_EQRET) 944 SCTP_UINT_SYSCTL(rttvar_steady_step, sctp_steady_step, SCTPCTL_RTTVAR_STEADYS) 945 SCTP_UINT_SYSCTL(use_dcccecn, sctp_use_dccc_ecn, SCTPCTL_RTTVAR_DCCCECN) 946 SCTP_UINT_SYSCTL(blackhole, sctp_blackhole, SCTPCTL_BLACKHOLE) 947 SCTP_UINT_SYSCTL(sendall_limit, sctp_sendall_limit, SCTPCTL_SENDALL_LIMIT) 948 SCTP_UINT_SYSCTL(diag_info_code, sctp_diag_info_code, SCTPCTL_DIAG_INFO_CODE) 949 #ifdef SCTP_DEBUG 950 SCTP_UINT_SYSCTL(debug, sctp_debug_on, SCTPCTL_DEBUG) 951 #endif 952 #if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) 953 SCTP_UINT_SYSCTL(output_unlocked, sctp_output_unlocked, SCTPCTL_OUTPUT_UNLOCKED) 954 #endif 955 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, stats, CTLFLAG_VNET | CTLTYPE_STRUCT | CTLFLAG_RW, 956 NULL, 0, sctp_sysctl_handle_stats, "S,sctpstat", "SCTP statistics (struct sctp_stat)"); 957 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, assoclist, CTLFLAG_VNET | CTLTYPE_OPAQUE | CTLFLAG_RD, 958 NULL, 0, sctp_sysctl_handle_assoclist, "S,xassoc", "List of active SCTP associations"); 959