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