1 /*- 2 * Copyright (c) 2007, by Cisco Systems, Inc. All rights reserved. 3 * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 4 * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are met: 8 * 9 * a) Redistributions of source code must retain the above copyright notice, 10 * this list of conditions and the following disclaimer. 11 * 12 * b) Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in 14 * the documentation and/or other materials provided with the distribution. 15 * 16 * c) Neither the name of Cisco Systems, Inc. nor the names of its 17 * contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #ifdef __FreeBSD__ 34 #include <sys/cdefs.h> 35 __FBSDID("$FreeBSD: head/sys/netinet/sctp_sysctl.c 271221 2014-09-07 09:06:26Z tuexen $"); 36 #endif 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 #ifdef __FreeBSD__ 46 #include <sys/smp.h> 47 #include <sys/sysctl.h> 48 #endif 49 #if defined(__APPLE__) 50 #include <netinet/sctp_bsd_addr.h> 51 #endif 52 53 #ifdef __FreeBSD__ 54 FEATURE(sctp, "Stream Control Transmission Protocol"); 55 #endif 56 57 /* 58 * sysctl tunable variables 59 */ 60 61 void 62 sctp_init_sysctls() 63 { 64 SCTP_BASE_SYSCTL(sctp_sendspace) = SCTPCTL_MAXDGRAM_DEFAULT; 65 SCTP_BASE_SYSCTL(sctp_recvspace) = SCTPCTL_RECVSPACE_DEFAULT; 66 SCTP_BASE_SYSCTL(sctp_auto_asconf) = SCTPCTL_AUTOASCONF_DEFAULT; 67 SCTP_BASE_SYSCTL(sctp_multiple_asconfs) = SCTPCTL_MULTIPLEASCONFS_DEFAULT; 68 SCTP_BASE_SYSCTL(sctp_ecn_enable) = SCTPCTL_ECN_ENABLE_DEFAULT; 69 SCTP_BASE_SYSCTL(sctp_pr_enable) = SCTPCTL_PR_ENABLE_DEFAULT; 70 SCTP_BASE_SYSCTL(sctp_auth_enable) = SCTPCTL_AUTH_ENABLE_DEFAULT; 71 SCTP_BASE_SYSCTL(sctp_asconf_enable) = SCTPCTL_ASCONF_ENABLE_DEFAULT; 72 SCTP_BASE_SYSCTL(sctp_reconfig_enable) = SCTPCTL_RECONFIG_ENABLE_DEFAULT; 73 SCTP_BASE_SYSCTL(sctp_nrsack_enable) = SCTPCTL_NRSACK_ENABLE_DEFAULT; 74 SCTP_BASE_SYSCTL(sctp_pktdrop_enable) = SCTPCTL_PKTDROP_ENABLE_DEFAULT; 75 SCTP_BASE_SYSCTL(sctp_strict_sacks) = SCTPCTL_STRICT_SACKS_DEFAULT; 76 #if !(defined(__FreeBSD__) && __FreeBSD_version >= 800000) 77 #if !defined(SCTP_WITH_NO_CSUM) 78 SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback) = SCTPCTL_LOOPBACK_NOCSUM_DEFAULT; 79 #endif 80 #endif 81 SCTP_BASE_SYSCTL(sctp_peer_chunk_oh) = SCTPCTL_PEER_CHKOH_DEFAULT; 82 SCTP_BASE_SYSCTL(sctp_max_burst_default) = SCTPCTL_MAXBURST_DEFAULT; 83 SCTP_BASE_SYSCTL(sctp_fr_max_burst_default) = SCTPCTL_FRMAXBURST_DEFAULT; 84 SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue) = SCTPCTL_MAXCHUNKS_DEFAULT; 85 SCTP_BASE_SYSCTL(sctp_hashtblsize) = SCTPCTL_TCBHASHSIZE_DEFAULT; 86 SCTP_BASE_SYSCTL(sctp_pcbtblsize) = SCTPCTL_PCBHASHSIZE_DEFAULT; 87 SCTP_BASE_SYSCTL(sctp_min_split_point) = SCTPCTL_MIN_SPLIT_POINT_DEFAULT; 88 SCTP_BASE_SYSCTL(sctp_chunkscale) = SCTPCTL_CHUNKSCALE_DEFAULT; 89 SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default) = SCTPCTL_DELAYED_SACK_TIME_DEFAULT; 90 SCTP_BASE_SYSCTL(sctp_sack_freq_default) = SCTPCTL_SACK_FREQ_DEFAULT; 91 SCTP_BASE_SYSCTL(sctp_system_free_resc_limit) = SCTPCTL_SYS_RESOURCE_DEFAULT; 92 SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit) = SCTPCTL_ASOC_RESOURCE_DEFAULT; 93 SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default) = SCTPCTL_HEARTBEAT_INTERVAL_DEFAULT; 94 SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default) = SCTPCTL_PMTU_RAISE_TIME_DEFAULT; 95 SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default) = SCTPCTL_SHUTDOWN_GUARD_TIME_DEFAULT; 96 SCTP_BASE_SYSCTL(sctp_secret_lifetime_default) = SCTPCTL_SECRET_LIFETIME_DEFAULT; 97 SCTP_BASE_SYSCTL(sctp_rto_max_default) = SCTPCTL_RTO_MAX_DEFAULT; 98 SCTP_BASE_SYSCTL(sctp_rto_min_default) = SCTPCTL_RTO_MIN_DEFAULT; 99 SCTP_BASE_SYSCTL(sctp_rto_initial_default) = SCTPCTL_RTO_INITIAL_DEFAULT; 100 SCTP_BASE_SYSCTL(sctp_init_rto_max_default) = SCTPCTL_INIT_RTO_MAX_DEFAULT; 101 SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default) = SCTPCTL_VALID_COOKIE_LIFE_DEFAULT; 102 SCTP_BASE_SYSCTL(sctp_init_rtx_max_default) = SCTPCTL_INIT_RTX_MAX_DEFAULT; 103 SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default) = SCTPCTL_ASSOC_RTX_MAX_DEFAULT; 104 SCTP_BASE_SYSCTL(sctp_path_rtx_max_default) = SCTPCTL_PATH_RTX_MAX_DEFAULT; 105 SCTP_BASE_SYSCTL(sctp_path_pf_threshold) = SCTPCTL_PATH_PF_THRESHOLD_DEFAULT; 106 SCTP_BASE_SYSCTL(sctp_add_more_threshold) = SCTPCTL_ADD_MORE_ON_OUTPUT_DEFAULT; 107 SCTP_BASE_SYSCTL(sctp_nr_incoming_streams_default) = SCTPCTL_INCOMING_STREAMS_DEFAULT; 108 SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default) = SCTPCTL_OUTGOING_STREAMS_DEFAULT; 109 SCTP_BASE_SYSCTL(sctp_cmt_on_off) = SCTPCTL_CMT_ON_OFF_DEFAULT; 110 SCTP_BASE_SYSCTL(sctp_cmt_use_dac) = SCTPCTL_CMT_USE_DAC_DEFAULT; 111 SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst) = SCTPCTL_CWND_MAXBURST_DEFAULT; 112 SCTP_BASE_SYSCTL(sctp_nat_friendly) = SCTPCTL_NAT_FRIENDLY_DEFAULT; 113 SCTP_BASE_SYSCTL(sctp_L2_abc_variable) = SCTPCTL_ABC_L_VAR_DEFAULT; 114 SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count) = SCTPCTL_MAX_CHAINED_MBUFS_DEFAULT; 115 SCTP_BASE_SYSCTL(sctp_do_drain) = SCTPCTL_DO_SCTP_DRAIN_DEFAULT; 116 SCTP_BASE_SYSCTL(sctp_hb_maxburst) = SCTPCTL_HB_MAX_BURST_DEFAULT; 117 SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit) = SCTPCTL_ABORT_AT_LIMIT_DEFAULT; 118 SCTP_BASE_SYSCTL(sctp_strict_data_order) = SCTPCTL_STRICT_DATA_ORDER_DEFAULT; 119 SCTP_BASE_SYSCTL(sctp_min_residual) = SCTPCTL_MIN_RESIDUAL_DEFAULT; 120 SCTP_BASE_SYSCTL(sctp_max_retran_chunk) = SCTPCTL_MAX_RETRAN_CHUNK_DEFAULT; 121 SCTP_BASE_SYSCTL(sctp_logging_level) = SCTPCTL_LOGGING_LEVEL_DEFAULT; 122 SCTP_BASE_SYSCTL(sctp_default_cc_module) = SCTPCTL_DEFAULT_CC_MODULE_DEFAULT; 123 SCTP_BASE_SYSCTL(sctp_default_ss_module) = SCTPCTL_DEFAULT_SS_MODULE_DEFAULT; 124 SCTP_BASE_SYSCTL(sctp_default_frag_interleave) = SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DEFAULT; 125 SCTP_BASE_SYSCTL(sctp_mobility_base) = SCTPCTL_MOBILITY_BASE_DEFAULT; 126 SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff) = SCTPCTL_MOBILITY_FASTHANDOFF_DEFAULT; 127 SCTP_BASE_SYSCTL(sctp_vtag_time_wait) = SCTPCTL_TIME_WAIT_DEFAULT; 128 SCTP_BASE_SYSCTL(sctp_buffer_splitting) = SCTPCTL_BUFFER_SPLITTING_DEFAULT; 129 SCTP_BASE_SYSCTL(sctp_initial_cwnd) = SCTPCTL_INITIAL_CWND_DEFAULT; 130 SCTP_BASE_SYSCTL(sctp_rttvar_bw) = SCTPCTL_RTTVAR_BW_DEFAULT; 131 SCTP_BASE_SYSCTL(sctp_rttvar_rtt) = SCTPCTL_RTTVAR_RTT_DEFAULT; 132 SCTP_BASE_SYSCTL(sctp_rttvar_eqret) = SCTPCTL_RTTVAR_EQRET_DEFAULT; 133 SCTP_BASE_SYSCTL(sctp_steady_step) = SCTPCTL_RTTVAR_STEADYS_DEFAULT; 134 SCTP_BASE_SYSCTL(sctp_use_dccc_ecn) = SCTPCTL_RTTVAR_DCCCECN_DEFAULT; 135 SCTP_BASE_SYSCTL(sctp_blackhole) = SCTPCTL_BLACKHOLE_DEFAULT; 136 SCTP_BASE_SYSCTL(sctp_diag_info_code) = SCTPCTL_DIAG_INFO_CODE_DEFAULT; 137 #if defined(SCTP_LOCAL_TRACE_BUF) 138 #if defined(__Windows__) 139 /* On Windows, the resource for global variables is limited. */ 140 MALLOC(SCTP_BASE_SYSCTL(sctp_log), struct sctp_log *, sizeof(struct sctp_log), M_SYSCTL, M_ZERO); 141 #else 142 memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log)); 143 #endif 144 #endif 145 SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = SCTPCTL_UDP_TUNNELING_PORT_DEFAULT; 146 SCTP_BASE_SYSCTL(sctp_enable_sack_immediately) = SCTPCTL_SACK_IMMEDIATELY_ENABLE_DEFAULT; 147 SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly) = SCTPCTL_NAT_FRIENDLY_INITS_DEFAULT; 148 #if defined(SCTP_DEBUG) 149 SCTP_BASE_SYSCTL(sctp_debug_on) = SCTPCTL_DEBUG_DEFAULT; 150 #endif 151 #if defined(__APPLE__) 152 SCTP_BASE_SYSCTL(sctp_ignore_vmware_interfaces) = SCTPCTL_IGNORE_VMWARE_INTERFACES_DEFAULT; 153 SCTP_BASE_SYSCTL(sctp_main_timer) = SCTPCTL_MAIN_TIMER_DEFAULT; 154 SCTP_BASE_SYSCTL(sctp_addr_watchdog_limit) = SCTPCTL_ADDR_WATCHDOG_LIMIT_DEFAULT; 155 SCTP_BASE_SYSCTL(sctp_vtag_watchdog_limit) = SCTPCTL_VTAG_WATCHDOG_LIMIT_DEFAULT; 156 #endif 157 #if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) 158 SCTP_BASE_SYSCTL(sctp_output_unlocked) = SCTPCTL_OUTPUT_UNLOCKED_DEFAULT; 159 #endif 160 } 161 162 #if defined(__Windows__) 163 void 164 sctp_finish_sysctls() 165 { 166 #if defined(SCTP_LOCAL_TRACE_BUF) 167 if (SCTP_BASE_SYSCTL(sctp_log) != NULL) { 168 FREE(SCTP_BASE_SYSCTL(sctp_log), M_SYSCTL); 169 SCTP_BASE_SYSCTL(sctp_log) = NULL; 170 } 171 #endif 172 } 173 #endif 174 175 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__Windows__) 176 /* It returns an upper limit. No filtering is done here */ 177 static unsigned int 178 sctp_sysctl_number_of_addresses(struct sctp_inpcb *inp) 179 { 180 unsigned int cnt; 181 struct sctp_vrf *vrf; 182 struct sctp_ifn *sctp_ifn; 183 struct sctp_ifa *sctp_ifa; 184 struct sctp_laddr *laddr; 185 186 cnt = 0; 187 /* neither Mac OS X nor FreeBSD support mulitple routing functions */ 188 if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) { 189 return (0); 190 } 191 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { 192 LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) { 193 LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) { 194 switch (sctp_ifa->address.sa.sa_family) { 195 #ifdef INET 196 case AF_INET: 197 #endif 198 #ifdef INET6 199 case AF_INET6: 200 #endif 201 cnt++; 202 break; 203 default: 204 break; 205 } 206 } 207 } 208 } else { 209 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) { 210 switch (laddr->ifa->address.sa.sa_family) { 211 #ifdef INET 212 case AF_INET: 213 #endif 214 #ifdef INET6 215 case AF_INET6: 216 #endif 217 cnt++; 218 break; 219 default: 220 break; 221 } 222 } 223 } 224 return (cnt); 225 } 226 227 static int 228 sctp_sysctl_copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sysctl_req *req) 229 { 230 struct sctp_ifn *sctp_ifn; 231 struct sctp_ifa *sctp_ifa; 232 int loopback_scope, ipv4_local_scope, local_scope, site_scope; 233 int ipv4_addr_legal, ipv6_addr_legal; 234 #if defined(__Userspace__) 235 int conn_addr_legal; 236 #endif 237 struct sctp_vrf *vrf; 238 struct xsctp_laddr xladdr; 239 struct sctp_laddr *laddr; 240 int error; 241 242 /* Turn on all the appropriate scope */ 243 if (stcb) { 244 /* use association specific values */ 245 loopback_scope = stcb->asoc.scope.loopback_scope; 246 ipv4_local_scope = stcb->asoc.scope.ipv4_local_scope; 247 local_scope = stcb->asoc.scope.local_scope; 248 site_scope = stcb->asoc.scope.site_scope; 249 ipv4_addr_legal = stcb->asoc.scope.ipv4_addr_legal; 250 ipv6_addr_legal = stcb->asoc.scope.ipv6_addr_legal; 251 #if defined(__Userspace__) 252 conn_addr_legal = stcb->asoc.scope.conn_addr_legal; 253 #endif 254 } else { 255 /* Use generic values for endpoints. */ 256 loopback_scope = 1; 257 ipv4_local_scope = 1; 258 local_scope = 1; 259 site_scope = 1; 260 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) { 261 ipv6_addr_legal = 1; 262 if (SCTP_IPV6_V6ONLY(inp)) { 263 ipv4_addr_legal = 0; 264 } else { 265 ipv4_addr_legal = 1; 266 } 267 #if defined(__Userspace__) 268 conn_addr_legal = 0; 269 #endif 270 } else { 271 ipv6_addr_legal = 0; 272 #if defined(__Userspace__) 273 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_CONN) { 274 conn_addr_legal = 1; 275 ipv4_addr_legal = 0; 276 } else { 277 conn_addr_legal = 0; 278 ipv4_addr_legal = 1; 279 } 280 #else 281 ipv4_addr_legal = 1; 282 #endif 283 } 284 } 285 286 /* neither Mac OS X nor FreeBSD support mulitple routing functions */ 287 if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) { 288 SCTP_INP_RUNLOCK(inp); 289 SCTP_INP_INFO_RUNLOCK(); 290 return (-1); 291 } 292 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) { 293 LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) { 294 if ((loopback_scope == 0) && SCTP_IFN_IS_IFT_LOOP(sctp_ifn)) 295 /* Skip loopback if loopback_scope not set */ 296 continue; 297 LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) { 298 if (stcb) { 299 /* 300 * ignore if blacklisted at 301 * association level 302 */ 303 if (sctp_is_addr_restricted(stcb, sctp_ifa)) 304 continue; 305 } 306 switch (sctp_ifa->address.sa.sa_family) { 307 #ifdef INET 308 case AF_INET: 309 if (ipv4_addr_legal) { 310 struct sockaddr_in *sin; 311 312 sin = &sctp_ifa->address.sin; 313 if (sin->sin_addr.s_addr == 0) 314 continue; 315 #if defined(__FreeBSD__) 316 if (prison_check_ip4(inp->ip_inp.inp.inp_cred, 317 &sin->sin_addr) != 0) { 318 continue; 319 } 320 #endif 321 if ((ipv4_local_scope == 0) && (IN4_ISPRIVATE_ADDRESS(&sin->sin_addr))) 322 continue; 323 } else { 324 continue; 325 } 326 break; 327 #endif 328 #ifdef INET6 329 case AF_INET6: 330 if (ipv6_addr_legal) { 331 struct sockaddr_in6 *sin6; 332 333 #if defined(SCTP_EMBEDDED_V6_SCOPE) && !defined(SCTP_KAME) 334 struct sockaddr_in6 lsa6; 335 #endif 336 sin6 = &sctp_ifa->address.sin6; 337 if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) 338 continue; 339 #if defined(__FreeBSD__) 340 if (prison_check_ip6(inp->ip_inp.inp.inp_cred, 341 &sin6->sin6_addr) != 0) { 342 continue; 343 } 344 #endif 345 if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { 346 if (local_scope == 0) 347 continue; 348 #if defined(SCTP_EMBEDDED_V6_SCOPE) 349 if (sin6->sin6_scope_id == 0) { 350 #ifdef SCTP_KAME 351 /* bad link local address */ 352 if (sa6_recoverscope(sin6) != 0) 353 continue; 354 #else 355 lsa6 = *sin6; 356 /* bad link local address */ 357 if (in6_recoverscope(&lsa6, &lsa6.sin6_addr, NULL)) 358 continue; 359 sin6 = &lsa6; 360 #endif /* SCTP_KAME */ 361 } 362 #endif /* SCTP_EMBEDDED_V6_SCOPE */ 363 } 364 if ((site_scope == 0) && (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr))) 365 continue; 366 } else { 367 continue; 368 } 369 break; 370 #endif 371 #if defined(__Userspace__) 372 case AF_CONN: 373 if (!conn_addr_legal) { 374 continue; 375 } 376 break; 377 #endif 378 default: 379 continue; 380 } 381 memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr)); 382 memcpy((void *)&xladdr.address, (const void *)&sctp_ifa->address, sizeof(union sctp_sockstore)); 383 SCTP_INP_RUNLOCK(inp); 384 SCTP_INP_INFO_RUNLOCK(); 385 error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr)); 386 if (error) { 387 return (error); 388 } else { 389 SCTP_INP_INFO_RLOCK(); 390 SCTP_INP_RLOCK(inp); 391 } 392 } 393 } 394 } else { 395 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) { 396 /* ignore if blacklisted at association level */ 397 if (stcb && sctp_is_addr_restricted(stcb, laddr->ifa)) 398 continue; 399 memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr)); 400 memcpy((void *)&xladdr.address, (const void *)&laddr->ifa->address, sizeof(union sctp_sockstore)); 401 xladdr.start_time.tv_sec = (uint32_t)laddr->start_time.tv_sec; 402 xladdr.start_time.tv_usec = (uint32_t)laddr->start_time.tv_usec; 403 SCTP_INP_RUNLOCK(inp); 404 SCTP_INP_INFO_RUNLOCK(); 405 error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr)); 406 if (error) { 407 return (error); 408 } else { 409 SCTP_INP_INFO_RLOCK(); 410 SCTP_INP_RLOCK(inp); 411 } 412 } 413 } 414 memset((void *)&xladdr, 0, sizeof(struct xsctp_laddr)); 415 xladdr.last = 1; 416 SCTP_INP_RUNLOCK(inp); 417 SCTP_INP_INFO_RUNLOCK(); 418 error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr)); 419 420 if (error) { 421 return (error); 422 } else { 423 SCTP_INP_INFO_RLOCK(); 424 SCTP_INP_RLOCK(inp); 425 return (0); 426 } 427 } 428 429 /* 430 * sysctl functions 431 */ 432 #if defined(__APPLE__) 433 static int 434 sctp_sysctl_handle_assoclist SYSCTL_HANDLER_ARGS 435 { 436 #pragma unused(oidp, arg1, arg2) 437 #else 438 static int 439 sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS) 440 { 441 #endif 442 unsigned int number_of_endpoints; 443 unsigned int number_of_local_addresses; 444 unsigned int number_of_associations; 445 unsigned int number_of_remote_addresses; 446 unsigned int n; 447 int error; 448 struct sctp_inpcb *inp; 449 struct sctp_tcb *stcb; 450 struct sctp_nets *net; 451 struct xsctp_inpcb xinpcb; 452 struct xsctp_tcb xstcb; 453 struct xsctp_raddr xraddr; 454 struct socket *so; 455 456 number_of_endpoints = 0; 457 number_of_local_addresses = 0; 458 number_of_associations = 0; 459 number_of_remote_addresses = 0; 460 461 SCTP_INP_INFO_RLOCK(); 462 #if defined(__APPLE__) 463 if (req->oldptr == USER_ADDR_NULL) { 464 #else 465 if (req->oldptr == NULL) { 466 #endif 467 LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) { 468 SCTP_INP_RLOCK(inp); 469 number_of_endpoints++; 470 number_of_local_addresses += sctp_sysctl_number_of_addresses(inp); 471 LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) { 472 number_of_associations++; 473 number_of_local_addresses += sctp_sysctl_number_of_addresses(inp); 474 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { 475 number_of_remote_addresses++; 476 } 477 } 478 SCTP_INP_RUNLOCK(inp); 479 } 480 SCTP_INP_INFO_RUNLOCK(); 481 n = (number_of_endpoints + 1) * sizeof(struct xsctp_inpcb) + 482 (number_of_local_addresses + number_of_endpoints + number_of_associations) * sizeof(struct xsctp_laddr) + 483 (number_of_associations + number_of_endpoints) * sizeof(struct xsctp_tcb) + 484 (number_of_remote_addresses + number_of_associations) * sizeof(struct xsctp_raddr); 485 486 /* request some more memory than needed */ 487 #if !defined(__Windows__) 488 req->oldidx = (n + n / 8); 489 #else 490 req->dataidx = (n + n / 8); 491 #endif 492 return (0); 493 } 494 #if defined(__APPLE__) 495 if (req->newptr != USER_ADDR_NULL) { 496 #else 497 if (req->newptr != NULL) { 498 #endif 499 SCTP_INP_INFO_RUNLOCK(); 500 SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_SYSCTL, EPERM); 501 return (EPERM); 502 } 503 LIST_FOREACH(inp, &SCTP_BASE_INFO(listhead), sctp_list) { 504 SCTP_INP_RLOCK(inp); 505 if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) { 506 /* if its allgone it is being freed - skip it */ 507 goto skip; 508 } 509 xinpcb.last = 0; 510 xinpcb.local_port = ntohs(inp->sctp_lport); 511 xinpcb.flags = inp->sctp_flags; 512 #if defined(__FreeBSD__) && __FreeBSD_version < 1000048 513 xinpcb.features = (uint32_t)inp->sctp_features; 514 #else 515 xinpcb.features = inp->sctp_features; 516 #endif 517 xinpcb.total_sends = inp->total_sends; 518 xinpcb.total_recvs = inp->total_recvs; 519 xinpcb.total_nospaces = inp->total_nospaces; 520 xinpcb.fragmentation_point = inp->sctp_frag_point; 521 so = inp->sctp_socket; 522 if ((so == NULL) || 523 (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) { 524 xinpcb.qlen = 0; 525 xinpcb.maxqlen = 0; 526 } else { 527 xinpcb.qlen = so->so_qlen; 528 xinpcb.maxqlen = so->so_qlimit; 529 } 530 SCTP_INP_INCR_REF(inp); 531 SCTP_INP_RUNLOCK(inp); 532 SCTP_INP_INFO_RUNLOCK(); 533 error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb)); 534 if (error) { 535 SCTP_INP_DECR_REF(inp); 536 return (error); 537 } 538 SCTP_INP_INFO_RLOCK(); 539 SCTP_INP_RLOCK(inp); 540 error = sctp_sysctl_copy_out_local_addresses(inp, NULL, req); 541 if (error) { 542 SCTP_INP_DECR_REF(inp); 543 return (error); 544 } 545 LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) { 546 SCTP_TCB_LOCK(stcb); 547 atomic_add_int(&stcb->asoc.refcnt, 1); 548 SCTP_TCB_UNLOCK(stcb); 549 xstcb.last = 0; 550 xstcb.local_port = ntohs(inp->sctp_lport); 551 xstcb.remote_port = ntohs(stcb->rport); 552 if (stcb->asoc.primary_destination != NULL) 553 xstcb.primary_addr = stcb->asoc.primary_destination->ro._l_addr; 554 xstcb.heartbeat_interval = stcb->asoc.heart_beat_delay; 555 xstcb.state = SCTP_GET_STATE(&stcb->asoc); /* FIXME */ 556 #if defined(__FreeBSD__) 557 #if __FreeBSD_version >= 800000 558 /* 7.0 does not support these */ 559 xstcb.assoc_id = sctp_get_associd(stcb); 560 xstcb.peers_rwnd = stcb->asoc.peers_rwnd; 561 #endif 562 #else 563 xstcb.assoc_id = sctp_get_associd(stcb); 564 xstcb.peers_rwnd = stcb->asoc.peers_rwnd; 565 #endif 566 xstcb.in_streams = stcb->asoc.streamincnt; 567 xstcb.out_streams = stcb->asoc.streamoutcnt; 568 xstcb.max_nr_retrans = stcb->asoc.overall_error_count; 569 xstcb.primary_process = 0; /* not really supported yet */ 570 xstcb.T1_expireries = stcb->asoc.timoinit + stcb->asoc.timocookie; 571 xstcb.T2_expireries = stcb->asoc.timoshutdown + stcb->asoc.timoshutdownack; 572 xstcb.retransmitted_tsns = stcb->asoc.marked_retrans; 573 xstcb.start_time.tv_sec = (uint32_t)stcb->asoc.start_time.tv_sec; 574 xstcb.start_time.tv_usec = (uint32_t)stcb->asoc.start_time.tv_usec; 575 xstcb.discontinuity_time.tv_sec = (uint32_t)stcb->asoc.discontinuity_time.tv_sec; 576 xstcb.discontinuity_time.tv_usec = (uint32_t)stcb->asoc.discontinuity_time.tv_usec; 577 xstcb.total_sends = stcb->total_sends; 578 xstcb.total_recvs = stcb->total_recvs; 579 xstcb.local_tag = stcb->asoc.my_vtag; 580 xstcb.remote_tag = stcb->asoc.peer_vtag; 581 xstcb.initial_tsn = stcb->asoc.init_seq_number; 582 xstcb.highest_tsn = stcb->asoc.sending_seq - 1; 583 xstcb.cumulative_tsn = stcb->asoc.last_acked_seq; 584 xstcb.cumulative_tsn_ack = stcb->asoc.cumulative_tsn; 585 xstcb.mtu = stcb->asoc.smallest_mtu; 586 xstcb.refcnt = stcb->asoc.refcnt; 587 SCTP_INP_RUNLOCK(inp); 588 SCTP_INP_INFO_RUNLOCK(); 589 error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb)); 590 if (error) { 591 SCTP_INP_DECR_REF(inp); 592 atomic_subtract_int(&stcb->asoc.refcnt, 1); 593 return (error); 594 } 595 SCTP_INP_INFO_RLOCK(); 596 SCTP_INP_RLOCK(inp); 597 error = sctp_sysctl_copy_out_local_addresses(inp, stcb, req); 598 if (error) { 599 SCTP_INP_DECR_REF(inp); 600 atomic_subtract_int(&stcb->asoc.refcnt, 1); 601 return (error); 602 } 603 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { 604 xraddr.last = 0; 605 xraddr.address = net->ro._l_addr; 606 xraddr.active = ((net->dest_state & SCTP_ADDR_REACHABLE) == SCTP_ADDR_REACHABLE); 607 xraddr.confirmed = ((net->dest_state & SCTP_ADDR_UNCONFIRMED) == 0); 608 xraddr.heartbeat_enabled = ((net->dest_state & SCTP_ADDR_NOHB) == 0); 609 xraddr.potentially_failed = ((net->dest_state & SCTP_ADDR_PF) == SCTP_ADDR_PF); 610 xraddr.rto = net->RTO; 611 xraddr.max_path_rtx = net->failure_threshold; 612 xraddr.rtx = net->marked_retrans; 613 xraddr.error_counter = net->error_count; 614 xraddr.cwnd = net->cwnd; 615 xraddr.flight_size = net->flight_size; 616 xraddr.mtu = net->mtu; 617 #if defined(__FreeBSD__) 618 #if __FreeBSD_version >= 800000 619 xraddr.rtt = net->rtt / 1000; 620 xraddr.heartbeat_interval = net->heart_beat_delay; 621 #endif 622 #else 623 xraddr.rtt = net->rtt / 1000; 624 xraddr.heartbeat_interval = net->heart_beat_delay; 625 #endif 626 xraddr.start_time.tv_sec = (uint32_t)net->start_time.tv_sec; 627 xraddr.start_time.tv_usec = (uint32_t)net->start_time.tv_usec; 628 SCTP_INP_RUNLOCK(inp); 629 SCTP_INP_INFO_RUNLOCK(); 630 error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr)); 631 if (error) { 632 SCTP_INP_DECR_REF(inp); 633 atomic_subtract_int(&stcb->asoc.refcnt, 1); 634 return (error); 635 } 636 SCTP_INP_INFO_RLOCK(); 637 SCTP_INP_RLOCK(inp); 638 } 639 atomic_subtract_int(&stcb->asoc.refcnt, 1); 640 memset((void *)&xraddr, 0, sizeof(struct xsctp_raddr)); 641 xraddr.last = 1; 642 SCTP_INP_RUNLOCK(inp); 643 SCTP_INP_INFO_RUNLOCK(); 644 error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr)); 645 if (error) { 646 SCTP_INP_DECR_REF(inp); 647 return (error); 648 } 649 SCTP_INP_INFO_RLOCK(); 650 SCTP_INP_RLOCK(inp); 651 } 652 SCTP_INP_DECR_REF(inp); 653 SCTP_INP_RUNLOCK(inp); 654 SCTP_INP_INFO_RUNLOCK(); 655 memset((void *)&xstcb, 0, sizeof(struct xsctp_tcb)); 656 xstcb.last = 1; 657 error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb)); 658 if (error) { 659 return (error); 660 } 661 skip: 662 SCTP_INP_INFO_RLOCK(); 663 } 664 SCTP_INP_INFO_RUNLOCK(); 665 666 memset((void *)&xinpcb, 0, sizeof(struct xsctp_inpcb)); 667 xinpcb.last = 1; 668 error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb)); 669 return (error); 670 } 671 672 #if defined(__APPLE__) 673 static int 674 sctp_sysctl_handle_udp_tunneling SYSCTL_HANDLER_ARGS 675 { 676 #pragma unused(arg1, arg2) 677 #else 678 static int 679 sctp_sysctl_handle_udp_tunneling(SYSCTL_HANDLER_ARGS) 680 { 681 #endif 682 int error; 683 uint32_t old, new; 684 685 SCTP_INP_INFO_RLOCK(); 686 old = SCTP_BASE_SYSCTL(sctp_udp_tunneling_port); 687 SCTP_INP_INFO_RUNLOCK(); 688 new = old; 689 #if defined(__FreeBSD__) && __FreeBSD_version >= 800056 && __FreeBSD_version < 1000100 690 #ifdef VIMAGE 691 error = vnet_sysctl_handle_int(oidp, &new, 0, req); 692 #else 693 error = sysctl_handle_int(oidp, &new, 0, req); 694 #endif 695 #else 696 error = sysctl_handle_int(oidp, &new, 0, req); 697 #endif 698 if ((error == 0) && 699 #if defined (__APPLE__) 700 (req->newptr != USER_ADDR_NULL)) { 701 #else 702 (req->newptr != NULL)) { 703 #endif 704 #if defined(__Windows__) 705 SCTP_INP_INFO_WLOCK(); 706 sctp_over_udp_restart(); 707 SCTP_INP_INFO_WUNLOCK(); 708 #else 709 if ((new < SCTPCTL_UDP_TUNNELING_PORT_MIN) || 710 (new > SCTPCTL_UDP_TUNNELING_PORT_MAX)) { 711 error = EINVAL; 712 } else { 713 SCTP_INP_INFO_WLOCK(); 714 SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = new; 715 if (old != 0) { 716 sctp_over_udp_stop(); 717 } 718 if (new != 0) { 719 error = sctp_over_udp_start(); 720 } 721 SCTP_INP_INFO_WUNLOCK(); 722 } 723 #endif 724 } 725 return (error); 726 } 727 728 #if defined(__APPLE__) 729 int sctp_is_vmware_interface(struct ifnet *); 730 731 static int 732 sctp_sysctl_handle_vmware_interfaces SYSCTL_HANDLER_ARGS 733 { 734 #pragma unused(arg1, arg2) 735 int error; 736 uint32_t old, new; 737 738 old = SCTP_BASE_SYSCTL(sctp_ignore_vmware_interfaces); 739 new = old; 740 error = sysctl_handle_int(oidp, &new, 0, req); 741 if ((error == 0) && (req->newptr != USER_ADDR_NULL)) { 742 if ((new < SCTPCTL_IGNORE_VMWARE_INTERFACES_MIN) || 743 (new > SCTPCTL_IGNORE_VMWARE_INTERFACES_MAX)) { 744 error = EINVAL; 745 } else { 746 if ((old == 1) && (new == 0)) { 747 sctp_add_or_del_interfaces(sctp_is_vmware_interface, 1); 748 } 749 if ((old == 0) && (new == 1)) { 750 sctp_add_or_del_interfaces(sctp_is_vmware_interface, 0); 751 } 752 if (old != new) { 753 SCTP_BASE_SYSCTL(sctp_ignore_vmware_interfaces) = new; 754 } 755 } 756 } 757 return (error); 758 } 759 #endif 760 761 #if defined(__APPLE__) 762 static int 763 sctp_sysctl_handle_auth SYSCTL_HANDLER_ARGS 764 { 765 #pragma unused(arg1, arg2) 766 #else 767 static int 768 sctp_sysctl_handle_auth(SYSCTL_HANDLER_ARGS) 769 { 770 #endif 771 int error; 772 uint32_t new; 773 774 new = SCTP_BASE_SYSCTL(sctp_auth_enable); 775 #if defined(__FreeBSD__) && __FreeBSD_version >= 800056 && __FreeBSD_version < 1000100 776 #ifdef VIMAGE 777 error = vnet_sysctl_handle_int(oidp, &new, 0, req); 778 #else 779 error = sysctl_handle_int(oidp, &new, 0, req); 780 #endif 781 #else 782 error = sysctl_handle_int(oidp, &new, 0, req); 783 #endif 784 if ((error == 0) && 785 #if defined (__APPLE__) 786 (req->newptr != USER_ADDR_NULL)) { 787 #else 788 (req->newptr != NULL)) { 789 #endif 790 if ((new < SCTPCTL_AUTH_ENABLE_MIN) || 791 (new > SCTPCTL_AUTH_ENABLE_MAX) || 792 ((new == 0) && (SCTP_BASE_SYSCTL(sctp_asconf_enable) == 1))) { 793 error = EINVAL; 794 } else { 795 SCTP_BASE_SYSCTL(sctp_auth_enable) = new; 796 } 797 } 798 return (error); 799 } 800 801 #if defined(__APPLE__) 802 static int 803 sctp_sysctl_handle_asconf SYSCTL_HANDLER_ARGS 804 { 805 #pragma unused(arg1, arg2) 806 #else 807 static int 808 sctp_sysctl_handle_asconf(SYSCTL_HANDLER_ARGS) 809 { 810 #endif 811 int error; 812 uint32_t new; 813 814 new = SCTP_BASE_SYSCTL(sctp_asconf_enable); 815 #if defined(__FreeBSD__) && __FreeBSD_version >= 800056 && __FreeBSD_version < 1000100 816 #ifdef VIMAGE 817 error = vnet_sysctl_handle_int(oidp, &new, 0, req); 818 #else 819 error = sysctl_handle_int(oidp, &new, 0, req); 820 #endif 821 #else 822 error = sysctl_handle_int(oidp, &new, 0, req); 823 #endif 824 if ((error == 0) && 825 #if defined (__APPLE__) 826 (req->newptr != USER_ADDR_NULL)) { 827 #else 828 (req->newptr != NULL)) { 829 #endif 830 if ((new < SCTPCTL_ASCONF_ENABLE_MIN) || 831 (new > SCTPCTL_ASCONF_ENABLE_MAX) || 832 ((new == 1) && (SCTP_BASE_SYSCTL(sctp_auth_enable) == 0))) { 833 error = EINVAL; 834 } else { 835 SCTP_BASE_SYSCTL(sctp_asconf_enable) = new; 836 } 837 } 838 return (error); 839 } 840 841 #if defined(__APPLE__) 842 static int 843 sctp_sysctl_handle_stats SYSCTL_HANDLER_ARGS 844 { 845 #pragma unused(oidp, arg1, arg2) 846 #else 847 static int 848 sctp_sysctl_handle_stats(SYSCTL_HANDLER_ARGS) 849 { 850 #endif 851 int error; 852 #if defined(__FreeBSD__) 853 #if defined(SMP) && defined(SCTP_USE_PERCPU_STAT) 854 int cpu; 855 struct sctpstat sb, *sarry; 856 #endif 857 #endif 858 859 #if defined (__APPLE__) 860 if ((req->newptr != USER_ADDR_NULL) && 861 #else 862 if ((req->newptr != NULL) && 863 #endif 864 (req->newlen != sizeof(struct sctpstat))) { 865 return (EINVAL); 866 } 867 #if defined(__FreeBSD__) 868 #if defined(SMP) && defined(SCTP_USE_PERCPU_STAT) 869 memset(&sb, 0, sizeof(struct sctpstat)); 870 for (cpu = 0; cpu < mp_maxid; cpu++) { 871 sarry = &SCTP_BASE_STATS[cpu]; 872 if (sarry->sctps_discontinuitytime.tv_sec > sb.sctps_discontinuitytime.tv_sec) { 873 sb.sctps_discontinuitytime.tv_sec = sarry->sctps_discontinuitytime.tv_sec; 874 sb.sctps_discontinuitytime.tv_usec = sarry->sctps_discontinuitytime.tv_usec; 875 } 876 sb.sctps_currestab += sarry->sctps_currestab; 877 sb.sctps_activeestab += sarry->sctps_activeestab; 878 sb.sctps_restartestab += sarry->sctps_restartestab; 879 sb.sctps_collisionestab += sarry->sctps_collisionestab; 880 sb.sctps_passiveestab += sarry->sctps_passiveestab; 881 sb.sctps_aborted += sarry->sctps_aborted; 882 sb.sctps_shutdown += sarry->sctps_shutdown; 883 sb.sctps_outoftheblue += sarry->sctps_outoftheblue; 884 sb.sctps_checksumerrors += sarry->sctps_checksumerrors; 885 sb.sctps_outcontrolchunks += sarry->sctps_outcontrolchunks; 886 sb.sctps_outorderchunks += sarry->sctps_outorderchunks; 887 sb.sctps_outunorderchunks += sarry->sctps_outunorderchunks; 888 sb.sctps_incontrolchunks += sarry->sctps_incontrolchunks; 889 sb.sctps_inorderchunks += sarry->sctps_inorderchunks; 890 sb.sctps_inunorderchunks += sarry->sctps_inunorderchunks; 891 sb.sctps_fragusrmsgs += sarry->sctps_fragusrmsgs; 892 sb.sctps_reasmusrmsgs += sarry->sctps_reasmusrmsgs; 893 sb.sctps_outpackets += sarry->sctps_outpackets; 894 sb.sctps_inpackets += sarry->sctps_inpackets; 895 sb.sctps_recvpackets += sarry->sctps_recvpackets; 896 sb.sctps_recvdatagrams += sarry->sctps_recvdatagrams; 897 sb.sctps_recvpktwithdata += sarry->sctps_recvpktwithdata; 898 sb.sctps_recvsacks += sarry->sctps_recvsacks; 899 sb.sctps_recvdata += sarry->sctps_recvdata; 900 sb.sctps_recvdupdata += sarry->sctps_recvdupdata; 901 sb.sctps_recvheartbeat += sarry->sctps_recvheartbeat; 902 sb.sctps_recvheartbeatack += sarry->sctps_recvheartbeatack; 903 sb.sctps_recvecne += sarry->sctps_recvecne; 904 sb.sctps_recvauth += sarry->sctps_recvauth; 905 sb.sctps_recvauthmissing += sarry->sctps_recvauthmissing; 906 sb.sctps_recvivalhmacid += sarry->sctps_recvivalhmacid; 907 sb.sctps_recvivalkeyid += sarry->sctps_recvivalkeyid; 908 sb.sctps_recvauthfailed += sarry->sctps_recvauthfailed; 909 sb.sctps_recvexpress += sarry->sctps_recvexpress; 910 sb.sctps_recvexpressm += sarry->sctps_recvexpressm; 911 sb.sctps_recvnocrc += sarry->sctps_recvnocrc; 912 sb.sctps_recvswcrc += sarry->sctps_recvswcrc; 913 sb.sctps_recvhwcrc += sarry->sctps_recvhwcrc; 914 sb.sctps_sendpackets += sarry->sctps_sendpackets; 915 sb.sctps_sendsacks += sarry->sctps_sendsacks; 916 sb.sctps_senddata += sarry->sctps_senddata; 917 sb.sctps_sendretransdata += sarry->sctps_sendretransdata; 918 sb.sctps_sendfastretrans += sarry->sctps_sendfastretrans; 919 sb.sctps_sendmultfastretrans += sarry->sctps_sendmultfastretrans; 920 sb.sctps_sendheartbeat += sarry->sctps_sendheartbeat; 921 sb.sctps_sendecne += sarry->sctps_sendecne; 922 sb.sctps_sendauth += sarry->sctps_sendauth; 923 sb.sctps_senderrors += sarry->sctps_senderrors; 924 sb.sctps_sendnocrc += sarry->sctps_sendnocrc; 925 sb.sctps_sendswcrc += sarry->sctps_sendswcrc; 926 sb.sctps_sendhwcrc += sarry->sctps_sendhwcrc; 927 sb.sctps_pdrpfmbox += sarry->sctps_pdrpfmbox; 928 sb.sctps_pdrpfehos += sarry->sctps_pdrpfehos; 929 sb.sctps_pdrpmbda += sarry->sctps_pdrpmbda; 930 sb.sctps_pdrpmbct += sarry->sctps_pdrpmbct; 931 sb.sctps_pdrpbwrpt += sarry->sctps_pdrpbwrpt; 932 sb.sctps_pdrpcrupt += sarry->sctps_pdrpcrupt; 933 sb.sctps_pdrpnedat += sarry->sctps_pdrpnedat; 934 sb.sctps_pdrppdbrk += sarry->sctps_pdrppdbrk; 935 sb.sctps_pdrptsnnf += sarry->sctps_pdrptsnnf; 936 sb.sctps_pdrpdnfnd += sarry->sctps_pdrpdnfnd; 937 sb.sctps_pdrpdiwnp += sarry->sctps_pdrpdiwnp; 938 sb.sctps_pdrpdizrw += sarry->sctps_pdrpdizrw; 939 sb.sctps_pdrpbadd += sarry->sctps_pdrpbadd; 940 sb.sctps_pdrpmark += sarry->sctps_pdrpmark; 941 sb.sctps_timoiterator += sarry->sctps_timoiterator; 942 sb.sctps_timodata += sarry->sctps_timodata; 943 sb.sctps_timowindowprobe += sarry->sctps_timowindowprobe; 944 sb.sctps_timoinit += sarry->sctps_timoinit; 945 sb.sctps_timosack += sarry->sctps_timosack; 946 sb.sctps_timoshutdown += sarry->sctps_timoshutdown; 947 sb.sctps_timoheartbeat += sarry->sctps_timoheartbeat; 948 sb.sctps_timocookie += sarry->sctps_timocookie; 949 sb.sctps_timosecret += sarry->sctps_timosecret; 950 sb.sctps_timopathmtu += sarry->sctps_timopathmtu; 951 sb.sctps_timoshutdownack += sarry->sctps_timoshutdownack; 952 sb.sctps_timoshutdownguard += sarry->sctps_timoshutdownguard; 953 sb.sctps_timostrmrst += sarry->sctps_timostrmrst; 954 sb.sctps_timoearlyfr += sarry->sctps_timoearlyfr; 955 sb.sctps_timoasconf += sarry->sctps_timoasconf; 956 sb.sctps_timodelprim += sarry->sctps_timodelprim; 957 sb.sctps_timoautoclose += sarry->sctps_timoautoclose; 958 sb.sctps_timoassockill += sarry->sctps_timoassockill; 959 sb.sctps_timoinpkill += sarry->sctps_timoinpkill; 960 sb.sctps_hdrops += sarry->sctps_hdrops; 961 sb.sctps_badsum += sarry->sctps_badsum; 962 sb.sctps_noport += sarry->sctps_noport; 963 sb.sctps_badvtag += sarry->sctps_badvtag; 964 sb.sctps_badsid += sarry->sctps_badsid; 965 sb.sctps_nomem += sarry->sctps_nomem; 966 sb.sctps_fastretransinrtt += sarry->sctps_fastretransinrtt; 967 sb.sctps_markedretrans += sarry->sctps_markedretrans; 968 sb.sctps_naglesent += sarry->sctps_naglesent; 969 sb.sctps_naglequeued += sarry->sctps_naglequeued; 970 sb.sctps_maxburstqueued += sarry->sctps_maxburstqueued; 971 sb.sctps_ifnomemqueued += sarry->sctps_ifnomemqueued; 972 sb.sctps_windowprobed += sarry->sctps_windowprobed; 973 sb.sctps_lowlevelerr += sarry->sctps_lowlevelerr; 974 sb.sctps_lowlevelerrusr += sarry->sctps_lowlevelerrusr; 975 sb.sctps_datadropchklmt += sarry->sctps_datadropchklmt; 976 sb.sctps_datadroprwnd += sarry->sctps_datadroprwnd; 977 sb.sctps_ecnereducedcwnd += sarry->sctps_ecnereducedcwnd; 978 sb.sctps_vtagexpress += sarry->sctps_vtagexpress; 979 sb.sctps_vtagbogus += sarry->sctps_vtagbogus; 980 sb.sctps_primary_randry += sarry->sctps_primary_randry; 981 sb.sctps_cmt_randry += sarry->sctps_cmt_randry; 982 sb.sctps_slowpath_sack += sarry->sctps_slowpath_sack; 983 sb.sctps_wu_sacks_sent += sarry->sctps_wu_sacks_sent; 984 sb.sctps_sends_with_flags += sarry->sctps_sends_with_flags; 985 sb.sctps_sends_with_unord += sarry->sctps_sends_with_unord; 986 sb.sctps_sends_with_eof += sarry->sctps_sends_with_eof; 987 sb.sctps_sends_with_abort += sarry->sctps_sends_with_abort; 988 sb.sctps_protocol_drain_calls += sarry->sctps_protocol_drain_calls; 989 sb.sctps_protocol_drains_done += sarry->sctps_protocol_drains_done; 990 sb.sctps_read_peeks += sarry->sctps_read_peeks; 991 sb.sctps_cached_chk += sarry->sctps_cached_chk; 992 sb.sctps_cached_strmoq += sarry->sctps_cached_strmoq; 993 sb.sctps_left_abandon += sarry->sctps_left_abandon; 994 sb.sctps_send_burst_avoid += sarry->sctps_send_burst_avoid; 995 sb.sctps_send_cwnd_avoid += sarry->sctps_send_cwnd_avoid; 996 sb.sctps_fwdtsn_map_over += sarry->sctps_fwdtsn_map_over; 997 if (req->newptr != NULL) { 998 memcpy(sarry, req->newptr, sizeof(struct sctpstat)); 999 } 1000 } 1001 error = SYSCTL_OUT(req, &sb, sizeof(struct sctpstat)); 1002 #else 1003 error = SYSCTL_OUT(req, &SCTP_BASE_STATS, sizeof(struct sctpstat)); 1004 #endif 1005 #else 1006 error = SYSCTL_OUT(req, &SCTP_BASE_STATS, sizeof(struct sctpstat)); 1007 #endif 1008 return (error); 1009 } 1010 1011 #if defined(SCTP_LOCAL_TRACE_BUF) 1012 #if defined(__APPLE__) 1013 static int 1014 sctp_sysctl_handle_trace_log SYSCTL_HANDLER_ARGS 1015 { 1016 #pragma unused(arg1, arg2, oidp) 1017 #else 1018 static int 1019 sctp_sysctl_handle_trace_log(SYSCTL_HANDLER_ARGS) 1020 { 1021 #endif 1022 int error; 1023 1024 #if defined(__Windows__) 1025 error = SYSCTL_OUT(req, SCTP_BASE_SYSCTL(sctp_log), sizeof(struct sctp_log)); 1026 #else 1027 error = SYSCTL_OUT(req, &SCTP_BASE_SYSCTL(sctp_log), sizeof(struct sctp_log)); 1028 #endif 1029 return (error); 1030 } 1031 1032 #if defined(__APPLE__) 1033 static int 1034 sctp_sysctl_handle_trace_log_clear SYSCTL_HANDLER_ARGS 1035 { 1036 #pragma unused(arg1, arg2, req, oidp) 1037 #else 1038 static int 1039 sctp_sysctl_handle_trace_log_clear(SYSCTL_HANDLER_ARGS) 1040 { 1041 #endif 1042 int error = 0; 1043 #if defined(__Windows__) 1044 int value = 0; 1045 1046 if (req->new_data == NULL) { 1047 return (error); 1048 } 1049 error = SYSCTL_IN(req, &value, sizeof(int)); 1050 if (error == 0 && value != 0 && SCTP_BASE_SYSCTL(sctp_log) != NULL) { 1051 memset(SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log)); 1052 } 1053 #else 1054 1055 memset(&SCTP_BASE_SYSCTL(sctp_log), 0, sizeof(struct sctp_log)); 1056 #endif 1057 return (error); 1058 } 1059 #endif 1060 1061 #if defined(__APPLE__) || defined(__FreeBSD__) 1062 #if defined(__FreeBSD__) 1063 #if __FreeBSD_version >= 800056 && __FreeBSD_version < 1000100 1064 #ifdef VIMAGE 1065 #define SCTP_UINT_SYSCTL(name, var_name, prefix) \ 1066 static int \ 1067 sctp_sysctl_handle_##mib_name(SYSCTL_HANDLER_ARGS) \ 1068 { \ 1069 int error; \ 1070 uint32_t new; \ 1071 \ 1072 new = SCTP_BASE_SYSCTL(var_name); \ 1073 error = vnet_sysctl_handle_int(oidp, &new, 0, req); \ 1074 if ((error == 0) && (req->newptr != NULL)) { \ 1075 if ((new < prefix##_MIN) || \ 1076 (new > prefix##_MAX)) { \ 1077 error = EINVAL; \ 1078 } else { \ 1079 SCTP_BASE_SYSCTL(var_name) = new; \ 1080 } \ 1081 } \ 1082 return (error); \ 1083 } \ 1084 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mib_name, \ 1085 CTLTYPE_UINT|CTLFLAG_RW, NULL, 0, \ 1086 sctp_sysctl_handle_##mib_name, "UI", prefix##_DESC); 1087 #else 1088 #define SCTP_UINT_SYSCTL(mib_name, var_name, prefix) \ 1089 static int \ 1090 sctp_sysctl_handle_##mib_name(SYSCTL_HANDLER_ARGS) \ 1091 { \ 1092 int error; \ 1093 uint32_t new; \ 1094 \ 1095 new = SCTP_BASE_SYSCTL(var_name); \ 1096 error = sysctl_handle_int(oidp, &new, 0, req); \ 1097 if ((error == 0) && (req->newptr != NULL)) { \ 1098 if ((new < prefix##_MIN) || \ 1099 (new > prefix##_MAX)) { \ 1100 error = EINVAL; \ 1101 } else { \ 1102 SCTP_BASE_SYSCTL(var_name) = new; \ 1103 } \ 1104 } \ 1105 return (error); \ 1106 } \ 1107 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mib_name, \ 1108 CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW, NULL, 0, \ 1109 sctp_sysctl_handle_##mib_name, "UI", prefix##_DESC); 1110 #endif 1111 #else 1112 #define SCTP_UINT_SYSCTL(mib_name, var_name, prefix) \ 1113 static int \ 1114 sctp_sysctl_handle_##mib_name(SYSCTL_HANDLER_ARGS) \ 1115 { \ 1116 int error; \ 1117 uint32_t new; \ 1118 \ 1119 new = SCTP_BASE_SYSCTL(var_name); \ 1120 error = sysctl_handle_int(oidp, &new, 0, req); \ 1121 if ((error == 0) && (req->newptr != NULL)) { \ 1122 if ((new < prefix##_MIN) || \ 1123 (new > prefix##_MAX)) { \ 1124 error = EINVAL; \ 1125 } else { \ 1126 SCTP_BASE_SYSCTL(var_name) = new; \ 1127 } \ 1128 } \ 1129 return (error); \ 1130 } \ 1131 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mib_name, \ 1132 CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW, NULL, 0, \ 1133 sctp_sysctl_handle_##mib_name, "UI", prefix##_DESC); 1134 #endif 1135 #else 1136 #define SCTP_UINT_SYSCTL(mib_name, var_name, prefix) \ 1137 static int \ 1138 sctp_sysctl_handle_##mib_name(struct sysctl_oid *oidp, \ 1139 void *arg1 __attribute__((unused)), \ 1140 int arg2 __attribute__((unused)), \ 1141 struct sysctl_req *req) \ 1142 { \ 1143 int error; \ 1144 uint32_t new; \ 1145 \ 1146 new = SCTP_BASE_SYSCTL(var_name); \ 1147 error = sysctl_handle_int(oidp, &new, 0, req); \ 1148 if ((error == 0) && (req->newptr != USER_ADDR_NULL)) { \ 1149 if ((new < prefix##_MIN) || \ 1150 (new > prefix##_MAX)) { \ 1151 error = EINVAL; \ 1152 } else { \ 1153 SCTP_BASE_SYSCTL(var_name) = new; \ 1154 } \ 1155 } \ 1156 return (error); \ 1157 } \ 1158 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mib_name, \ 1159 CTLTYPE_INT | CTLFLAG_RW, NULL, 0, \ 1160 sctp_sysctl_handle_##mib_name, "I", prefix##_DESC); 1161 #define CTLTYPE_UINT CTLTYPE_INT 1162 #define CTLFLAG_VNET 0 1163 #endif 1164 1165 /* 1166 * sysctl definitions 1167 */ 1168 1169 SCTP_UINT_SYSCTL(sendspace, sctp_sendspace, SCTPCTL_MAXDGRAM) 1170 SCTP_UINT_SYSCTL(recvspace, sctp_recvspace, SCTPCTL_RECVSPACE) 1171 SCTP_UINT_SYSCTL(auto_asconf, sctp_auto_asconf, SCTPCTL_AUTOASCONF) 1172 SCTP_UINT_SYSCTL(ecn_enable, sctp_ecn_enable, SCTPCTL_ECN_ENABLE) 1173 SCTP_UINT_SYSCTL(pr_enable, sctp_pr_enable, SCTPCTL_PR_ENABLE) 1174 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, auth_enable, CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW, 1175 NULL, 0, sctp_sysctl_handle_auth, "IU", SCTPCTL_AUTH_ENABLE_DESC); 1176 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, asconf_enable, CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW, 1177 NULL, 0, sctp_sysctl_handle_asconf, "IU", SCTPCTL_ASCONF_ENABLE_DESC); 1178 SCTP_UINT_SYSCTL(reconfig_enable, sctp_reconfig_enable, SCTPCTL_RECONFIG_ENABLE) 1179 SCTP_UINT_SYSCTL(nrsack_enable, sctp_nrsack_enable, SCTPCTL_NRSACK_ENABLE) 1180 SCTP_UINT_SYSCTL(pktdrop_enable, sctp_pktdrop_enable, SCTPCTL_PKTDROP_ENABLE) 1181 SCTP_UINT_SYSCTL(strict_sacks, sctp_strict_sacks, SCTPCTL_STRICT_SACKS) 1182 #if defined(__APPLE__) 1183 #if !defined(SCTP_WITH_NO_CSUM) 1184 SCTP_UINT_SYSCTL(loopback_nocsum, sctp_no_csum_on_loopback, SCTPCTL_LOOPBACK_NOCSUM) 1185 #endif 1186 #endif 1187 SCTP_UINT_SYSCTL(peer_chkoh, sctp_peer_chunk_oh, SCTPCTL_PEER_CHKOH) 1188 SCTP_UINT_SYSCTL(maxburst, sctp_max_burst_default, SCTPCTL_MAXBURST) 1189 SCTP_UINT_SYSCTL(fr_maxburst, sctp_fr_max_burst_default, SCTPCTL_FRMAXBURST) 1190 SCTP_UINT_SYSCTL(maxchunks, sctp_max_chunks_on_queue, SCTPCTL_MAXCHUNKS) 1191 SCTP_UINT_SYSCTL(tcbhashsize, sctp_hashtblsize, SCTPCTL_TCBHASHSIZE) 1192 SCTP_UINT_SYSCTL(pcbhashsize, sctp_pcbtblsize, SCTPCTL_PCBHASHSIZE) 1193 SCTP_UINT_SYSCTL(min_split_point, sctp_min_split_point, SCTPCTL_MIN_SPLIT_POINT) 1194 SCTP_UINT_SYSCTL(chunkscale, sctp_chunkscale, SCTPCTL_CHUNKSCALE) 1195 SCTP_UINT_SYSCTL(delayed_sack_time, sctp_delayed_sack_time_default, SCTPCTL_DELAYED_SACK_TIME) 1196 SCTP_UINT_SYSCTL(sack_freq, sctp_sack_freq_default, SCTPCTL_SACK_FREQ) 1197 SCTP_UINT_SYSCTL(sys_resource, sctp_system_free_resc_limit, SCTPCTL_SYS_RESOURCE) 1198 SCTP_UINT_SYSCTL(asoc_resource, sctp_asoc_free_resc_limit, SCTPCTL_ASOC_RESOURCE) 1199 SCTP_UINT_SYSCTL(heartbeat_interval, sctp_heartbeat_interval_default, SCTPCTL_HEARTBEAT_INTERVAL) 1200 SCTP_UINT_SYSCTL(pmtu_raise_time, sctp_pmtu_raise_time_default, SCTPCTL_PMTU_RAISE_TIME) 1201 SCTP_UINT_SYSCTL(shutdown_guard_time, sctp_shutdown_guard_time_default, SCTPCTL_SHUTDOWN_GUARD_TIME) 1202 SCTP_UINT_SYSCTL(secret_lifetime, sctp_secret_lifetime_default, SCTPCTL_SECRET_LIFETIME) 1203 SCTP_UINT_SYSCTL(rto_max, sctp_rto_max_default, SCTPCTL_RTO_MAX) 1204 SCTP_UINT_SYSCTL(rto_min, sctp_rto_min_default, SCTPCTL_RTO_MIN) 1205 SCTP_UINT_SYSCTL(rto_initial, sctp_rto_initial_default, SCTPCTL_RTO_INITIAL) 1206 SCTP_UINT_SYSCTL(init_rto_max, sctp_init_rto_max_default, SCTPCTL_INIT_RTO_MAX) 1207 SCTP_UINT_SYSCTL(valid_cookie_life, sctp_valid_cookie_life_default, SCTPCTL_VALID_COOKIE_LIFE) 1208 SCTP_UINT_SYSCTL(init_rtx_max, sctp_init_rtx_max_default, SCTPCTL_INIT_RTX_MAX) 1209 SCTP_UINT_SYSCTL(assoc_rtx_max, sctp_assoc_rtx_max_default, SCTPCTL_ASSOC_RTX_MAX) 1210 SCTP_UINT_SYSCTL(path_rtx_max, sctp_path_rtx_max_default, SCTPCTL_PATH_RTX_MAX) 1211 SCTP_UINT_SYSCTL(path_pf_threshold, sctp_path_pf_threshold, SCTPCTL_PATH_PF_THRESHOLD) 1212 SCTP_UINT_SYSCTL(add_more_on_output, sctp_add_more_threshold, SCTPCTL_ADD_MORE_ON_OUTPUT) 1213 SCTP_UINT_SYSCTL(incoming_streams, sctp_nr_incoming_streams_default, SCTPCTL_INCOMING_STREAMS) 1214 SCTP_UINT_SYSCTL(outgoing_streams, sctp_nr_outgoing_streams_default, SCTPCTL_OUTGOING_STREAMS) 1215 SCTP_UINT_SYSCTL(cmt_on_off, sctp_cmt_on_off, SCTPCTL_CMT_ON_OFF) 1216 SCTP_UINT_SYSCTL(cmt_use_dac, sctp_cmt_use_dac, SCTPCTL_CMT_USE_DAC) 1217 SCTP_UINT_SYSCTL(cwnd_maxburst, sctp_use_cwnd_based_maxburst, SCTPCTL_CWND_MAXBURST) 1218 SCTP_UINT_SYSCTL(nat_friendly, sctp_nat_friendly, SCTPCTL_NAT_FRIENDLY) 1219 SCTP_UINT_SYSCTL(abc_l_var, sctp_L2_abc_variable, SCTPCTL_ABC_L_VAR) 1220 SCTP_UINT_SYSCTL(max_chained_mbufs, sctp_mbuf_threshold_count, SCTPCTL_MAX_CHAINED_MBUFS) 1221 SCTP_UINT_SYSCTL(do_sctp_drain, sctp_do_drain, SCTPCTL_DO_SCTP_DRAIN) 1222 SCTP_UINT_SYSCTL(hb_max_burst, sctp_hb_maxburst, SCTPCTL_HB_MAX_BURST) 1223 SCTP_UINT_SYSCTL(abort_at_limit, sctp_abort_if_one_2_one_hits_limit, SCTPCTL_ABORT_AT_LIMIT) 1224 SCTP_UINT_SYSCTL(strict_data_order, sctp_strict_data_order, SCTPCTL_STRICT_DATA_ORDER) 1225 SCTP_UINT_SYSCTL(min_residual, sctp_min_residual, SCTPCTL_MIN_RESIDUAL) 1226 SCTP_UINT_SYSCTL(max_retran_chunk, sctp_max_retran_chunk, SCTPCTL_MAX_RETRAN_CHUNK) 1227 SCTP_UINT_SYSCTL(log_level, sctp_logging_level, SCTPCTL_LOGGING_LEVEL) 1228 SCTP_UINT_SYSCTL(default_cc_module, sctp_default_cc_module, SCTPCTL_DEFAULT_CC_MODULE) 1229 SCTP_UINT_SYSCTL(default_ss_module, sctp_default_ss_module, SCTPCTL_DEFAULT_SS_MODULE) 1230 SCTP_UINT_SYSCTL(default_frag_interleave, sctp_default_frag_interleave, SCTPCTL_DEFAULT_FRAG_INTERLEAVE) 1231 SCTP_UINT_SYSCTL(mobility_base, sctp_mobility_base, SCTPCTL_MOBILITY_BASE) 1232 SCTP_UINT_SYSCTL(mobility_fasthandoff, sctp_mobility_fasthandoff, SCTPCTL_MOBILITY_FASTHANDOFF) 1233 #if defined(SCTP_LOCAL_TRACE_BUF) 1234 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, log, CTLFLAG_VNET|CTLTYPE_STRUCT|CTLFLAG_RD, 1235 NULL, 0, sctp_sysctl_handle_trace_log, "S,sctplog", "SCTP logging (struct sctp_log)"); 1236 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, clear_trace, CTLFLAG_VNET|CTLTYPE_UINT | CTLFLAG_RW, 1237 NULL, 0, sctp_sysctl_handle_trace_log_clear, "IU", "Clear SCTP Logging buffer"); 1238 #endif 1239 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, udp_tunneling_port, CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW, 1240 NULL, 0, sctp_sysctl_handle_udp_tunneling, "IU", SCTPCTL_UDP_TUNNELING_PORT_DESC); 1241 SCTP_UINT_SYSCTL(enable_sack_immediately, sctp_enable_sack_immediately, SCTPCTL_SACK_IMMEDIATELY_ENABLE) 1242 SCTP_UINT_SYSCTL(nat_friendly_init, sctp_inits_include_nat_friendly, SCTPCTL_NAT_FRIENDLY_INITS) 1243 SCTP_UINT_SYSCTL(vtag_time_wait, sctp_vtag_time_wait, SCTPCTL_TIME_WAIT) 1244 SCTP_UINT_SYSCTL(buffer_splitting, sctp_buffer_splitting, SCTPCTL_BUFFER_SPLITTING) 1245 SCTP_UINT_SYSCTL(initial_cwnd, sctp_initial_cwnd, SCTPCTL_INITIAL_CWND) 1246 SCTP_UINT_SYSCTL(rttvar_bw, sctp_rttvar_bw, SCTPCTL_RTTVAR_BW) 1247 SCTP_UINT_SYSCTL(rttvar_rtt, sctp_rttvar_rtt, SCTPCTL_RTTVAR_RTT) 1248 SCTP_UINT_SYSCTL(rttvar_eqret, sctp_rttvar_eqret, SCTPCTL_RTTVAR_EQRET) 1249 SCTP_UINT_SYSCTL(rttvar_steady_step, sctp_steady_step, SCTPCTL_RTTVAR_STEADYS) 1250 SCTP_UINT_SYSCTL(use_dcccecn, sctp_use_dccc_ecn, SCTPCTL_RTTVAR_DCCCECN) 1251 SCTP_UINT_SYSCTL(blackhole, sctp_blackhole, SCTPCTL_BLACKHOLE) 1252 SCTP_UINT_SYSCTL(diag_info_code, sctp_diag_info_code, SCTPCTL_DIAG_INFO_CODE) 1253 #ifdef SCTP_DEBUG 1254 SCTP_UINT_SYSCTL(debug, sctp_debug_on, SCTPCTL_DEBUG) 1255 #endif 1256 #if defined(__APPLE__) 1257 SCTP_UINT_SYSCTL(main_timer, sctp_main_timer, SCTPCTL_MAIN_TIMER) 1258 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, ignore_vmware_interfaces, CTLTYPE_UINT|CTLFLAG_RW, 1259 NULL, 0, sctp_sysctl_handle_vmware_interfaces, "IU", SCTPCTL_IGNORE_VMWARE_INTERFACES_DESC); 1260 SCTP_UINT_SYSCTL(addr_watchdog_limit, sctp_addr_watchdog_limit, SCTPCTL_ADDR_WATCHDOG_LIMIT) 1261 SCTP_UINT_SYSCTL(vtag_watchdog_limit, sctp_vtag_watchdog_limit, SCTPCTL_VTAG_WATCHDOG_LIMIT) 1262 #endif 1263 #if defined(__APPLE__) || defined(SCTP_SO_LOCK_TESTING) 1264 SCTP_UINT_SYSCTL(output_unlocked, sctp_output_unlocked, SCTPCTL_OUTPUT_UNLOCKED) 1265 #endif 1266 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, stats, CTLFLAG_VNET|CTLTYPE_STRUCT|CTLFLAG_RW, 1267 NULL, 0, sctp_sysctl_handle_stats, "S,sctpstat", "SCTP statistics (struct sctp_stat)"); 1268 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, assoclist, CTLFLAG_VNET|CTLTYPE_OPAQUE|CTLFLAG_RD, 1269 NULL, 0, sctp_sysctl_handle_assoclist, "S,xassoc", "List of active SCTP associations"); 1270 1271 #elif defined(__Windows__) 1272 1273 #define RANGECHK(var, min, max) \ 1274 if ((var) < (min)) { (var) = (min); } \ 1275 else if ((var) > (max)) { (var) = (max); } 1276 1277 static int 1278 sctp_sysctl_handle_int(SYSCTL_HANDLER_ARGS) 1279 { 1280 int error; 1281 1282 error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req); 1283 if (error == 0) { 1284 RANGECHK(SCTP_BASE_SYSCTL(sctp_sendspace), SCTPCTL_MAXDGRAM_MIN, SCTPCTL_MAXDGRAM_MAX); 1285 RANGECHK(SCTP_BASE_SYSCTL(sctp_recvspace), SCTPCTL_RECVSPACE_MIN, SCTPCTL_RECVSPACE_MAX); 1286 RANGECHK(SCTP_BASE_SYSCTL(sctp_auto_asconf), SCTPCTL_AUTOASCONF_MIN, SCTPCTL_AUTOASCONF_MAX); 1287 RANGECHK(SCTP_BASE_SYSCTL(sctp_auto_asconf), SCTPCTL_AUTOASCONF_MIN, SCTPCTL_AUTOASCONF_MAX); 1288 RANGECHK(SCTP_BASE_SYSCTL(sctp_ecn_enable), SCTPCTL_ECN_ENABLE_MIN, SCTPCTL_ECN_ENABLE_MAX); 1289 RANGECHK(SCTP_BASE_SYSCTL(sctp_pr_enable), SCTPCTL_PR_ENABLE_MIN, SCTPCTL_PR_ENABLE_MAX); 1290 RANGECHK(SCTP_BASE_SYSCTL(sctp_reconfig_enable), SCTPCTL_RECONFIG_ENABLE_MIN, SCTPCTL_RECONFIG_ENABLE_MAX); 1291 RANGECHK(SCTP_BASE_SYSCTL(sctp_nrsack_enable), SCTPCTL_NRSACK_ENABLE_MIN, SCTPCTL_NRSACK_ENABLE_MAX); 1292 RANGECHK(SCTP_BASE_SYSCTL(sctp_pktdrop_enable), SCTPCTL_PKTDROP_ENABLE_MIN, SCTPCTL_PKTDROP_ENABLE_MAX); 1293 RANGECHK(SCTP_BASE_SYSCTL(sctp_strict_sacks), SCTPCTL_STRICT_SACKS_MIN, SCTPCTL_STRICT_SACKS_MAX); 1294 #if !defined(SCTP_WITH_NO_CSUM) 1295 RANGECHK(SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback), SCTPCTL_LOOPBACK_NOCSUM_MIN, SCTPCTL_LOOPBACK_NOCSUM_MAX); 1296 #endif 1297 RANGECHK(SCTP_BASE_SYSCTL(sctp_peer_chunk_oh), SCTPCTL_PEER_CHKOH_MIN, SCTPCTL_PEER_CHKOH_MAX); 1298 RANGECHK(SCTP_BASE_SYSCTL(sctp_max_burst_default), SCTPCTL_MAXBURST_MIN, SCTPCTL_MAXBURST_MAX); 1299 RANGECHK(SCTP_BASE_SYSCTL(sctp_fr_max_burst_default), SCTPCTL_FRMAXBURST_MIN, SCTPCTL_FRMAXBURST_MAX); 1300 RANGECHK(SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue), SCTPCTL_MAXCHUNKS_MIN, SCTPCTL_MAXCHUNKS_MAX); 1301 RANGECHK(SCTP_BASE_SYSCTL(sctp_hashtblsize), SCTPCTL_TCBHASHSIZE_MIN, SCTPCTL_TCBHASHSIZE_MAX); 1302 RANGECHK(SCTP_BASE_SYSCTL(sctp_pcbtblsize), SCTPCTL_PCBHASHSIZE_MIN, SCTPCTL_PCBHASHSIZE_MAX); 1303 RANGECHK(SCTP_BASE_SYSCTL(sctp_min_split_point), SCTPCTL_MIN_SPLIT_POINT_MIN, SCTPCTL_MIN_SPLIT_POINT_MAX); 1304 RANGECHK(SCTP_BASE_SYSCTL(sctp_chunkscale), SCTPCTL_CHUNKSCALE_MIN, SCTPCTL_CHUNKSCALE_MAX); 1305 RANGECHK(SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default), SCTPCTL_DELAYED_SACK_TIME_MIN, SCTPCTL_DELAYED_SACK_TIME_MAX); 1306 RANGECHK(SCTP_BASE_SYSCTL(sctp_sack_freq_default), SCTPCTL_SACK_FREQ_MIN, SCTPCTL_SACK_FREQ_MAX); 1307 RANGECHK(SCTP_BASE_SYSCTL(sctp_system_free_resc_limit), SCTPCTL_SYS_RESOURCE_MIN, SCTPCTL_SYS_RESOURCE_MAX); 1308 RANGECHK(SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit), SCTPCTL_ASOC_RESOURCE_MIN, SCTPCTL_ASOC_RESOURCE_MAX); 1309 RANGECHK(SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default), SCTPCTL_HEARTBEAT_INTERVAL_MIN, SCTPCTL_HEARTBEAT_INTERVAL_MAX); 1310 RANGECHK(SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default), SCTPCTL_PMTU_RAISE_TIME_MIN, SCTPCTL_PMTU_RAISE_TIME_MAX); 1311 RANGECHK(SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default), SCTPCTL_SHUTDOWN_GUARD_TIME_MIN, SCTPCTL_SHUTDOWN_GUARD_TIME_MAX); 1312 RANGECHK(SCTP_BASE_SYSCTL(sctp_secret_lifetime_default), SCTPCTL_SECRET_LIFETIME_MIN, SCTPCTL_SECRET_LIFETIME_MAX); 1313 RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_max_default), SCTPCTL_RTO_MAX_MIN, SCTPCTL_RTO_MAX_MAX); 1314 RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_min_default), SCTPCTL_RTO_MIN_MIN, SCTPCTL_RTO_MIN_MAX); 1315 RANGECHK(SCTP_BASE_SYSCTL(sctp_rto_initial_default), SCTPCTL_RTO_INITIAL_MIN, SCTPCTL_RTO_INITIAL_MAX); 1316 RANGECHK(SCTP_BASE_SYSCTL(sctp_init_rto_max_default), SCTPCTL_INIT_RTO_MAX_MIN, SCTPCTL_INIT_RTO_MAX_MAX); 1317 RANGECHK(SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default), SCTPCTL_VALID_COOKIE_LIFE_MIN, SCTPCTL_VALID_COOKIE_LIFE_MAX); 1318 RANGECHK(SCTP_BASE_SYSCTL(sctp_init_rtx_max_default), SCTPCTL_INIT_RTX_MAX_MIN, SCTPCTL_INIT_RTX_MAX_MAX); 1319 RANGECHK(SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default), SCTPCTL_ASSOC_RTX_MAX_MIN, SCTPCTL_ASSOC_RTX_MAX_MAX); 1320 RANGECHK(SCTP_BASE_SYSCTL(sctp_path_rtx_max_default), SCTPCTL_PATH_RTX_MAX_MIN, SCTPCTL_PATH_RTX_MAX_MAX); 1321 RANGECHK(SCTP_BASE_SYSCTL(sctp_path_pf_threshold), SCTPCTL_PATH_PF_THRESHOLD_MIN, SCTPCTL_PATH_PF_THRESHOLD_MAX); 1322 RANGECHK(SCTP_BASE_SYSCTL(sctp_add_more_threshold), SCTPCTL_ADD_MORE_ON_OUTPUT_MIN, SCTPCTL_ADD_MORE_ON_OUTPUT_MAX); 1323 RANGECHK(SCTP_BASE_SYSCTL(sctp_nr_incoming_streams_default), SCTPCTL_INCOMING_STREAMS_MIN, SCTPCTL_INCOMING_STREAMS_MAX); 1324 RANGECHK(SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default), SCTPCTL_OUTGOING_STREAMS_MIN, SCTPCTL_OUTGOING_STREAMS_MAX); 1325 RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_on_off), SCTPCTL_CMT_ON_OFF_MIN, SCTPCTL_CMT_ON_OFF_MAX); 1326 RANGECHK(SCTP_BASE_SYSCTL(sctp_cmt_use_dac), SCTPCTL_CMT_USE_DAC_MIN, SCTPCTL_CMT_USE_DAC_MAX); 1327 RANGECHK(SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst), SCTPCTL_CWND_MAXBURST_MIN, SCTPCTL_CWND_MAXBURST_MAX); 1328 RANGECHK(SCTP_BASE_SYSCTL(sctp_nat_friendly), SCTPCTL_NAT_FRIENDLY_MIN, SCTPCTL_NAT_FRIENDLY_MAX); 1329 RANGECHK(SCTP_BASE_SYSCTL(sctp_L2_abc_variable), SCTPCTL_ABC_L_VAR_MIN, SCTPCTL_ABC_L_VAR_MAX); 1330 RANGECHK(SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count), SCTPCTL_MAX_CHAINED_MBUFS_MIN, SCTPCTL_MAX_CHAINED_MBUFS_MAX); 1331 RANGECHK(SCTP_BASE_SYSCTL(sctp_do_drain), SCTPCTL_DO_SCTP_DRAIN_MIN, SCTPCTL_DO_SCTP_DRAIN_MAX); 1332 RANGECHK(SCTP_BASE_SYSCTL(sctp_hb_maxburst), SCTPCTL_HB_MAX_BURST_MIN, SCTPCTL_HB_MAX_BURST_MAX); 1333 RANGECHK(SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit), SCTPCTL_ABORT_AT_LIMIT_MIN, SCTPCTL_ABORT_AT_LIMIT_MAX); 1334 RANGECHK(SCTP_BASE_SYSCTL(sctp_strict_data_order), SCTPCTL_STRICT_DATA_ORDER_MIN, SCTPCTL_STRICT_DATA_ORDER_MAX); 1335 RANGECHK(SCTP_BASE_SYSCTL(sctp_min_residual), SCTPCTL_MIN_RESIDUAL_MIN, SCTPCTL_MIN_RESIDUAL_MAX); 1336 RANGECHK(SCTP_BASE_SYSCTL(sctp_max_retran_chunk), SCTPCTL_MAX_RETRAN_CHUNK_MIN, SCTPCTL_MAX_RETRAN_CHUNK_MAX); 1337 RANGECHK(SCTP_BASE_SYSCTL(sctp_logging_level), SCTPCTL_LOGGING_LEVEL_MIN, SCTPCTL_LOGGING_LEVEL_MAX); 1338 RANGECHK(SCTP_BASE_SYSCTL(sctp_default_cc_module), SCTPCTL_DEFAULT_CC_MODULE_MIN, SCTPCTL_DEFAULT_CC_MODULE_MAX); 1339 RANGECHK(SCTP_BASE_SYSCTL(sctp_default_ss_module), SCTPCTL_DEFAULT_SS_MODULE_MIN, SCTPCTL_DEFAULT_SS_MODULE_MAX); 1340 RANGECHK(SCTP_BASE_SYSCTL(sctp_default_frag_interleave), SCTPCTL_DEFAULT_FRAG_INTERLEAVE_MIN, SCTPCTL_DEFAULT_FRAG_INTERLEAVE_MAX); 1341 RANGECHK(SCTP_BASE_SYSCTL(sctp_vtag_time_wait), SCTPCTL_TIME_WAIT_MIN, SCTPCTL_TIME_WAIT_MAX); 1342 RANGECHK(SCTP_BASE_SYSCTL(sctp_buffer_splitting), SCTPCTL_BUFFER_SPLITTING_MIN, SCTPCTL_BUFFER_SPLITTING_MAX); 1343 RANGECHK(SCTP_BASE_SYSCTL(sctp_initial_cwnd), SCTPCTL_INITIAL_CWND_MIN, SCTPCTL_INITIAL_CWND_MAX); 1344 RANGECHK(SCTP_BASE_SYSCTL(sctp_rttvar_bw), SCTPCTL_RTTVAR_BW_MIN, SCTPCTL_RTTVAR_BW_MAX); 1345 RANGECHK(SCTP_BASE_SYSCTL(sctp_rttvar_rtt), SCTPCTL_RTTVAR_RTT_MIN, SCTPCTL_RTTVAR_RTT_MAX); 1346 RANGECHK(SCTP_BASE_SYSCTL(sctp_rttvar_eqret), SCTPCTL_RTTVAR_EQRET_MIN, SCTPCTL_RTTVAR_EQRET_MAX); 1347 RANGECHK(SCTP_BASE_SYSCTL(sctp_steady_step), SCTPCTL_RTTVAR_STEADYS_MIN, SCTPCTL_RTTVAR_STEADYS_MAX); 1348 RANGECHK(SCTP_BASE_SYSCTL(sctp_use_dccc_ecn), SCTPCTL_RTTVAR_DCCCECN_MIN, SCTPCTL_RTTVAR_DCCCECN_MAX); 1349 RANGECHK(SCTP_BASE_SYSCTL(sctp_mobility_base), SCTPCTL_MOBILITY_BASE_MIN, SCTPCTL_MOBILITY_BASE_MAX); 1350 RANGECHK(SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff), SCTPCTL_MOBILITY_FASTHANDOFF_MIN, SCTPCTL_MOBILITY_FASTHANDOFF_MAX); 1351 RANGECHK(SCTP_BASE_SYSCTL(sctp_enable_sack_immediately), SCTPCTL_SACK_IMMEDIATELY_ENABLE_MIN, SCTPCTL_SACK_IMMEDIATELY_ENABLE_MAX); 1352 RANGECHK(SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly), SCTPCTL_NAT_FRIENDLY_INITS_MIN, SCTPCTL_NAT_FRIENDLY_INITS_MAX); 1353 RANGECHK(SCTP_BASE_SYSCTL(sctp_blackhole), SCTPCTL_BLACKHOLE_MIN, SCTPCTL_BLACKHOLE_MAX); 1354 RANGECHK(SCTP_BASE_SYSCTL(sctp_diag_info_code), SCTPCTL_DIAG_INFO_CODE_MIN, SCTPCTL_DIAG_INFO_CODE_MAX); 1355 #ifdef SCTP_DEBUG 1356 RANGECHK(SCTP_BASE_SYSCTL(sctp_debug_on), SCTPCTL_DEBUG_MIN, SCTPCTL_DEBUG_MAX); 1357 #endif 1358 } 1359 return (error); 1360 } 1361 1362 void 1363 sysctl_setup_sctp(void) 1364 { 1365 sysctl_add_oid(&sysctl_oid_top, "sendspace", CTLTYPE_INT|CTLFLAG_RW, 1366 &SCTP_BASE_SYSCTL(sctp_sendspace), 0, sctp_sysctl_handle_int, 1367 SCTPCTL_MAXDGRAM_DESC); 1368 1369 sysctl_add_oid(&sysctl_oid_top, "recvspace", CTLTYPE_INT|CTLFLAG_RW, 1370 &SCTP_BASE_SYSCTL(sctp_recvspace), 0, sctp_sysctl_handle_int, 1371 SCTPCTL_RECVSPACE_DESC); 1372 1373 sysctl_add_oid(&sysctl_oid_top, "auto_asconf", CTLTYPE_INT|CTLFLAG_RW, 1374 &SCTP_BASE_SYSCTL(sctp_auto_asconf), 0, sctp_sysctl_handle_int, 1375 SCTPCTL_AUTOASCONF_DESC); 1376 1377 sysctl_add_oid(&sysctl_oid_top, "ecn_enable", CTLTYPE_INT|CTLFLAG_RW, 1378 &SCTP_BASE_SYSCTL(sctp_ecn_enable), 0, sctp_sysctl_handle_int, 1379 SCTPCTL_ECN_ENABLE_DESC); 1380 1381 sysctl_add_oid(&sysctl_oid_top, "pr_enable", CTLTYPE_INT|CTLFLAG_RW, 1382 &SCTP_BASE_SYSCTL(sctp_pr_enable), 0, sctp_sysctl_handle_int, 1383 SCTPCTL_PR_ENABLE_DESC); 1384 1385 sysctl_add_oid(&sysctl_oid_top, "auth_enable", CTLTYPE_INT|CTLFLAG_RW, 1386 &SCTP_BASE_SYSCTL(sctp_auth_enable), 0, sctp_sysctl_handle_auth, 1387 SCTPCTL_AUTH_ENABLE_DESC); 1388 1389 sysctl_add_oid(&sysctl_oid_top, "asconf_enable", CTLTYPE_INT|CTLFLAG_RW, 1390 &SCTP_BASE_SYSCTL(sctp_asconf_enable), 0, sctp_sysctl_handle_asconf, 1391 SCTPCTL_ASCONF_ENABLE_DESC); 1392 1393 sysctl_add_oid(&sysctl_oid_top, "reconfig_enable", CTLTYPE_INT|CTLFLAG_RW, 1394 &SCTP_BASE_SYSCTL(sctp_reconfig_enable), 0, sctp_sysctl_handle_int, 1395 SCTPCTL_RECONFIG_ENABLE_DESC); 1396 1397 sysctl_add_oid(&sysctl_oid_top, "nrsack_enable", CTLTYPE_INT|CTLFLAG_RW, 1398 &SCTP_BASE_SYSCTL(sctp_nrsack_enable), 0, sctp_sysctl_handle_int, 1399 SCTPCTL_NRSACK_ENABLE_DESC); 1400 1401 sysctl_add_oid(&sysctl_oid_top, "pktdrop_enable", CTLTYPE_INT|CTLFLAG_RW, 1402 &SCTP_BASE_SYSCTL(sctp_pktdrop_enable), 0, sctp_sysctl_handle_int, 1403 SCTPCTL_PKTDROP_ENABLE_DESC); 1404 1405 sysctl_add_oid(&sysctl_oid_top, "strict_sacks", CTLTYPE_INT|CTLFLAG_RW, 1406 &SCTP_BASE_SYSCTL(sctp_strict_sacks), 0, sctp_sysctl_handle_int, 1407 SCTPCTL_STRICT_SACKS_DESC); 1408 1409 #if !defined(SCTP_WITH_NO_CSUM) 1410 sysctl_add_oid(&sysctl_oid_top, "loopback_nocsum", CTLTYPE_INT|CTLFLAG_RW, 1411 &SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback), 0, sctp_sysctl_handle_int, 1412 SCTPCTL_LOOPBACK_NOCSUM_DESC); 1413 #endif 1414 1415 sysctl_add_oid(&sysctl_oid_top, "peer_chkoh", CTLTYPE_INT|CTLFLAG_RW, 1416 &SCTP_BASE_SYSCTL(sctp_peer_chunk_oh), 0, sctp_sysctl_handle_int, 1417 SCTPCTL_PEER_CHKOH_DESC); 1418 1419 sysctl_add_oid(&sysctl_oid_top, "maxburst", CTLTYPE_INT|CTLFLAG_RW, 1420 &SCTP_BASE_SYSCTL(sctp_max_burst_default), 0, sctp_sysctl_handle_int, 1421 SCTPCTL_MAXBURST_DESC); 1422 1423 sysctl_add_oid(&sysctl_oid_top, "fr_maxburst", CTLTYPE_INT|CTLFLAG_RW, 1424 &SCTP_BASE_SYSCTL(sctp_fr_max_burst_default), 0, sctp_sysctl_handle_int, 1425 SCTPCTL_FRMAXBURST_DESC); 1426 1427 sysctl_add_oid(&sysctl_oid_top, "maxchunks", CTLTYPE_INT|CTLFLAG_RW, 1428 &SCTP_BASE_SYSCTL(sctp_max_chunks_on_queue), 0, sctp_sysctl_handle_int, 1429 SCTPCTL_MAXCHUNKS_DESC); 1430 1431 sysctl_add_oid(&sysctl_oid_top, "tcbhashsize", CTLTYPE_INT|CTLFLAG_RW, 1432 &SCTP_BASE_SYSCTL(sctp_hashtblsize), 0, sctp_sysctl_handle_int, 1433 SCTPCTL_TCBHASHSIZE_DESC); 1434 1435 sysctl_add_oid(&sysctl_oid_top, "pcbhashsize", CTLTYPE_INT|CTLFLAG_RW, 1436 &SCTP_BASE_SYSCTL(sctp_pcbtblsize), 0, sctp_sysctl_handle_int, 1437 SCTPCTL_PCBHASHSIZE_DESC); 1438 1439 sysctl_add_oid(&sysctl_oid_top, "min_split_point", CTLTYPE_INT|CTLFLAG_RW, 1440 &SCTP_BASE_SYSCTL(sctp_min_split_point), 0, sctp_sysctl_handle_int, 1441 SCTPCTL_MIN_SPLIT_POINT_DESC); 1442 1443 sysctl_add_oid(&sysctl_oid_top, "chunkscale", CTLTYPE_INT|CTLFLAG_RW, 1444 &SCTP_BASE_SYSCTL(sctp_chunkscale), 0, sctp_sysctl_handle_int, 1445 SCTPCTL_CHUNKSCALE_DESC); 1446 1447 sysctl_add_oid(&sysctl_oid_top, "delayed_sack_time", CTLTYPE_INT|CTLFLAG_RW, 1448 &SCTP_BASE_SYSCTL(sctp_delayed_sack_time_default), 0, sctp_sysctl_handle_int, 1449 SCTPCTL_DELAYED_SACK_TIME_DESC); 1450 1451 sysctl_add_oid(&sysctl_oid_top, "sack_freq", CTLTYPE_INT|CTLFLAG_RW, 1452 &SCTP_BASE_SYSCTL(sctp_sack_freq_default), 0, sctp_sysctl_handle_int, 1453 SCTPCTL_SACK_FREQ_DESC); 1454 1455 sysctl_add_oid(&sysctl_oid_top, "sys_resource", CTLTYPE_INT|CTLFLAG_RW, 1456 &SCTP_BASE_SYSCTL(sctp_system_free_resc_limit), 0, sctp_sysctl_handle_int, 1457 SCTPCTL_SYS_RESOURCE_DESC); 1458 1459 sysctl_add_oid(&sysctl_oid_top, "asoc_resource", CTLTYPE_INT|CTLFLAG_RW, 1460 &SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit), 0, sctp_sysctl_handle_int, 1461 SCTPCTL_ASOC_RESOURCE_DESC); 1462 1463 sysctl_add_oid(&sysctl_oid_top, "heartbeat_interval", CTLTYPE_INT|CTLFLAG_RW, 1464 &SCTP_BASE_SYSCTL(sctp_heartbeat_interval_default), 0, sctp_sysctl_handle_int, 1465 SCTPCTL_HEARTBEAT_INTERVAL_DESC); 1466 1467 sysctl_add_oid(&sysctl_oid_top, "pmtu_raise_time", CTLTYPE_INT|CTLFLAG_RW, 1468 &SCTP_BASE_SYSCTL(sctp_pmtu_raise_time_default), 0, sctp_sysctl_handle_int, 1469 SCTPCTL_PMTU_RAISE_TIME_DESC); 1470 1471 sysctl_add_oid(&sysctl_oid_top, "shutdown_guard_time", CTLTYPE_INT|CTLFLAG_RW, 1472 &SCTP_BASE_SYSCTL(sctp_shutdown_guard_time_default), 0, sctp_sysctl_handle_int, 1473 SCTPCTL_SHUTDOWN_GUARD_TIME_DESC); 1474 1475 sysctl_add_oid(&sysctl_oid_top, "secret_lifetime", CTLTYPE_INT|CTLFLAG_RW, 1476 &SCTP_BASE_SYSCTL(sctp_secret_lifetime_default), 0, sctp_sysctl_handle_int, 1477 SCTPCTL_SECRET_LIFETIME_DESC); 1478 1479 sysctl_add_oid(&sysctl_oid_top, "rto_max", CTLTYPE_INT|CTLFLAG_RW, 1480 &SCTP_BASE_SYSCTL(sctp_rto_max_default), 0, sctp_sysctl_handle_int, 1481 SCTPCTL_RTO_MAX_DESC); 1482 1483 sysctl_add_oid(&sysctl_oid_top, "rto_min", CTLTYPE_INT|CTLFLAG_RW, 1484 &SCTP_BASE_SYSCTL(sctp_rto_min_default), 0, sctp_sysctl_handle_int, 1485 SCTPCTL_RTO_MIN_DESC); 1486 1487 sysctl_add_oid(&sysctl_oid_top, "rto_initial", CTLTYPE_INT|CTLFLAG_RW, 1488 &SCTP_BASE_SYSCTL(sctp_rto_initial_default), 0, sctp_sysctl_handle_int, 1489 SCTPCTL_RTO_INITIAL_DESC); 1490 1491 sysctl_add_oid(&sysctl_oid_top, "init_rto_max", CTLTYPE_INT|CTLFLAG_RW, 1492 &SCTP_BASE_SYSCTL(sctp_init_rto_max_default), 0, sctp_sysctl_handle_int, 1493 SCTPCTL_INIT_RTO_MAX_DESC); 1494 1495 sysctl_add_oid(&sysctl_oid_top, "valid_cookie_life", CTLTYPE_INT|CTLFLAG_RW, 1496 &SCTP_BASE_SYSCTL(sctp_valid_cookie_life_default), 0, sctp_sysctl_handle_int, 1497 SCTPCTL_VALID_COOKIE_LIFE_DESC); 1498 1499 sysctl_add_oid(&sysctl_oid_top, "init_rtx_max", CTLTYPE_INT|CTLFLAG_RW, 1500 &SCTP_BASE_SYSCTL(sctp_init_rtx_max_default), 0, sctp_sysctl_handle_int, 1501 SCTPCTL_INIT_RTX_MAX_DESC); 1502 1503 sysctl_add_oid(&sysctl_oid_top, "assoc_rtx_max", CTLTYPE_INT|CTLFLAG_RW, 1504 &SCTP_BASE_SYSCTL(sctp_assoc_rtx_max_default), 0, sctp_sysctl_handle_int, 1505 SCTPCTL_ASSOC_RTX_MAX_DESC); 1506 1507 sysctl_add_oid(&sysctl_oid_top, "path_rtx_max", CTLTYPE_INT|CTLFLAG_RW, 1508 &SCTP_BASE_SYSCTL(sctp_path_rtx_max_default), 0, sctp_sysctl_handle_int, 1509 SCTPCTL_PATH_RTX_MAX_DESC); 1510 1511 sysctl_add_oid(&sysctl_oid_top, "path_pf_threshold", CTLTYPE_INT|CTLFLAG_RW, 1512 &SCTP_BASE_SYSCTL(sctp_path_pf_threshold), 0, sctp_sysctl_handle_int, 1513 SCTPCTL_PATH_PF_THRESHOLD_DESC); 1514 1515 sysctl_add_oid(&sysctl_oid_top, "add_more_on_output", CTLTYPE_INT|CTLFLAG_RW, 1516 &SCTP_BASE_SYSCTL(sctp_add_more_threshold), 0, sctp_sysctl_handle_int, 1517 SCTPCTL_ADD_MORE_ON_OUTPUT_DESC); 1518 1519 sysctl_add_oid(&sysctl_oid_top, "incoming_streams", CTLTYPE_INT|CTLFLAG_RW, 1520 &SCTP_BASE_SYSCTL(sctp_nr_incoming_streams_default), 0, sctp_sysctl_handle_int, 1521 SCTPCTL_INCOMING_STREAMS_DESC); 1522 1523 sysctl_add_oid(&sysctl_oid_top, "outgoing_streams", CTLTYPE_INT|CTLFLAG_RW, 1524 &SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default), 0, sctp_sysctl_handle_int, 1525 SCTPCTL_OUTGOING_STREAMS_DESC); 1526 1527 sysctl_add_oid(&sysctl_oid_top, "cmt_on_off", CTLTYPE_INT|CTLFLAG_RW, 1528 &SCTP_BASE_SYSCTL(sctp_cmt_on_off), 0, sctp_sysctl_handle_int, 1529 SCTPCTL_CMT_ON_OFF_DESC); 1530 1531 sysctl_add_oid(&sysctl_oid_top, "cmt_use_dac", CTLTYPE_INT|CTLFLAG_RW, 1532 &SCTP_BASE_SYSCTL(sctp_cmt_use_dac), 0, sctp_sysctl_handle_int, 1533 SCTPCTL_CMT_USE_DAC_DESC); 1534 1535 sysctl_add_oid(&sysctl_oid_top, "cwnd_maxburst", CTLTYPE_INT|CTLFLAG_RW, 1536 &SCTP_BASE_SYSCTL(sctp_use_cwnd_based_maxburst), 0, sctp_sysctl_handle_int, 1537 SCTPCTL_CWND_MAXBURST_DESC); 1538 1539 sysctl_add_oid(&sysctl_oid_top, "nat_friendly", CTLTYPE_INT|CTLFLAG_RW, 1540 &SCTP_BASE_SYSCTL(sctp_nat_friendly), 0, sctp_sysctl_handle_int, 1541 SCTPCTL_NAT_FRIENDLY_DESC); 1542 1543 sysctl_add_oid(&sysctl_oid_top, "abc_l_var", CTLTYPE_INT|CTLFLAG_RW, 1544 &SCTP_BASE_SYSCTL(sctp_L2_abc_variable), 0, sctp_sysctl_handle_int, 1545 SCTPCTL_ABC_L_VAR_DESC); 1546 1547 sysctl_add_oid(&sysctl_oid_top, "max_chained_mbufs", CTLTYPE_INT|CTLFLAG_RW, 1548 &SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count), 0, sctp_sysctl_handle_int, 1549 SCTPCTL_MAX_CHAINED_MBUFS_DESC); 1550 1551 sysctl_add_oid(&sysctl_oid_top, "do_sctp_drain", CTLTYPE_INT|CTLFLAG_RW, 1552 &SCTP_BASE_SYSCTL(sctp_do_drain), 0, sctp_sysctl_handle_int, 1553 SCTPCTL_DO_SCTP_DRAIN_DESC); 1554 1555 sysctl_add_oid(&sysctl_oid_top, "hb_max_burst", CTLTYPE_INT|CTLFLAG_RW, 1556 &SCTP_BASE_SYSCTL(sctp_hb_maxburst), 0, sctp_sysctl_handle_int, 1557 SCTPCTL_HB_MAX_BURST_DESC); 1558 1559 sysctl_add_oid(&sysctl_oid_top, "abort_at_limit", CTLTYPE_INT|CTLFLAG_RW, 1560 &SCTP_BASE_SYSCTL(sctp_abort_if_one_2_one_hits_limit), 0, sctp_sysctl_handle_int, 1561 SCTPCTL_ABORT_AT_LIMIT_DESC); 1562 1563 sysctl_add_oid(&sysctl_oid_top, "strict_data_order", CTLTYPE_INT|CTLFLAG_RW, 1564 &SCTP_BASE_SYSCTL(sctp_strict_data_order), 0, sctp_sysctl_handle_int, 1565 SCTPCTL_STRICT_DATA_ORDER_DESC); 1566 1567 sysctl_add_oid(&sysctl_oid_top, "min_residual", CTLTYPE_INT|CTLFLAG_RW, 1568 &SCTP_BASE_SYSCTL(sctp_min_residual), 0, sctp_sysctl_handle_int, 1569 SCTPCTL_MIN_RESIDUAL_DESC); 1570 1571 sysctl_add_oid(&sysctl_oid_top, "max_retran_chunk", CTLTYPE_INT|CTLFLAG_RW, 1572 &SCTP_BASE_SYSCTL(sctp_max_retran_chunk), 0, sctp_sysctl_handle_int, 1573 SCTPCTL_MAX_RETRAN_CHUNK_DESC); 1574 1575 sysctl_add_oid(&sysctl_oid_top, "log_level", CTLTYPE_INT|CTLFLAG_RW, 1576 &SCTP_BASE_SYSCTL(sctp_logging_level), 0, sctp_sysctl_handle_int, 1577 SCTPCTL_LOGGING_LEVEL_DESC); 1578 1579 sysctl_add_oid(&sysctl_oid_top, "default_cc_module", CTLTYPE_INT|CTLFLAG_RW, 1580 &SCTP_BASE_SYSCTL(sctp_default_cc_module), 0, sctp_sysctl_handle_int, 1581 SCTPCTL_DEFAULT_CC_MODULE_DESC); 1582 1583 sysctl_add_oid(&sysctl_oid_top, "default_ss_module", CTLTYPE_INT|CTLFLAG_RW, 1584 &SCTP_BASE_SYSCTL(sctp_default_ss_module), 0, sctp_sysctl_handle_int, 1585 SCTPCTL_DEFAULT_SS_MODULE_DESC); 1586 1587 sysctl_add_oid(&sysctl_oid_top, "default_frag_interleave", CTLTYPE_INT|CTLFLAG_RW, 1588 &SCTP_BASE_SYSCTL(sctp_default_frag_interleave), 0, sctp_sysctl_handle_int, 1589 SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DESC); 1590 1591 sysctl_add_oid(&sysctl_oid_top, "mobility_base", CTLTYPE_INT|CTLFLAG_RW, 1592 &SCTP_BASE_SYSCTL(sctp_mobility_base), 0, sctp_sysctl_handle_int, 1593 SCTPCTL_MOBILITY_BASE_DESC); 1594 1595 sysctl_add_oid(&sysctl_oid_top, "mobility_fasthandoff", CTLTYPE_INT|CTLFLAG_RW, 1596 &SCTP_BASE_SYSCTL(sctp_mobility_fasthandoff), 0, sctp_sysctl_handle_int, 1597 SCTPCTL_MOBILITY_FASTHANDOFF_DESC); 1598 1599 #if defined(SCTP_LOCAL_TRACE_BUF) 1600 sysctl_add_oid(&sysctl_oid_top, "sctp_log", CTLTYPE_STRUCT|CTLFLAG_RD, 1601 SCTP_BASE_SYSCTL(sctp_log), sizeof(struct sctp_log), NULL, 1602 "SCTP logging (struct sctp_log)"); 1603 1604 sysctl_add_oid(&sysctl_oid_top, "clear_trace", CTLTYPE_INT|CTLFLAG_WR, 1605 NULL, 0, sctp_sysctl_handle_trace_log_clear, 1606 "Clear SCTP Logging buffer"); 1607 #endif 1608 1609 sysctl_add_oid(&sysctl_oid_top, "udp_tunneling_port", CTLTYPE_INT|CTLFLAG_RW, 1610 &SCTP_BASE_SYSCTL(sctp_udp_tunneling_port), 0, sctp_sysctl_handle_udp_tunneling, 1611 SCTPCTL_UDP_TUNNELING_PORT_DESC); 1612 1613 sysctl_add_oid(&sysctl_oid_top, "enable_sack_immediately", CTLTYPE_INT|CTLFLAG_RW, 1614 &SCTP_BASE_SYSCTL(sctp_enable_sack_immediately), 0, sctp_sysctl_handle_int, 1615 SCTPCTL_SACK_IMMEDIATELY_ENABLE_DESC); 1616 1617 sysctl_add_oid(&sysctl_oid_top, "nat_friendly_init", CTLTYPE_INT|CTLFLAG_RW, 1618 &SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly), 0, sctp_sysctl_handle_int, 1619 SCTPCTL_NAT_FRIENDLY_DESC); 1620 1621 sysctl_add_oid(&sysctl_oid_top, "vtag_time_wait", CTLTYPE_INT|CTLFLAG_RW, 1622 &SCTP_BASE_SYSCTL(sctp_vtag_time_wait), 0, sctp_sysctl_handle_int, 1623 SCTPCTL_TIME_WAIT_DESC); 1624 1625 sysctl_add_oid(&sysctl_oid_top, "buffer_splitting", CTLTYPE_INT|CTLFLAG_RW, 1626 &SCTP_BASE_SYSCTL(sctp_buffer_splitting), 0, sctp_sysctl_handle_int, 1627 SCTPCTL_BUFFER_SPLITTING_DESC); 1628 1629 sysctl_add_oid(&sysctl_oid_top, "initial_cwnd", CTLTYPE_INT|CTLFLAG_RW, 1630 &SCTP_BASE_SYSCTL(sctp_initial_cwnd), 0, sctp_sysctl_handle_int, 1631 SCTPCTL_INITIAL_CWND_DESC); 1632 1633 sysctl_add_oid(&sysctl_oid_top, "rttvar_bw", CTLTYPE_INT|CTLFLAG_RW, 1634 &SCTP_BASE_SYSCTL(sctp_rttvar_bw), 0, sctp_sysctl_handle_int, 1635 SCTPCTL_RTTVAR_BW_DESC); 1636 1637 sysctl_add_oid(&sysctl_oid_top, "rttvar_rtt", CTLTYPE_INT|CTLFLAG_RW, 1638 &SCTP_BASE_SYSCTL(sctp_rttvar_rtt), 0, sctp_sysctl_handle_int, 1639 SCTPCTL_RTTVAR_RTT_DESC); 1640 1641 sysctl_add_oid(&sysctl_oid_top, "rttvar_eqret", CTLTYPE_INT|CTLFLAG_RW, 1642 &SCTP_BASE_SYSCTL(sctp_rttvar_eqret), 0, sctp_sysctl_handle_int, 1643 SCTPCTL_RTTVAR_EQRET_DESC); 1644 1645 sysctl_add_oid(&sysctl_oid_top, "rttvar_steady_step", CTLTYPE_INT|CTLFLAG_RW, 1646 &SCTP_BASE_SYSCTL(sctp_steady_step), 0, sctp_sysctl_handle_int, 1647 SCTPCTL_RTTVAR_STEADYS_DESC); 1648 1649 sysctl_add_oid(&sysctl_oid_top, "use_dcccecn", CTLTYPE_INT|CTLFLAG_RW, 1650 &SCTP_BASE_SYSCTL(sctp_use_dccc_ecn), 0, sctp_sysctl_handle_int, 1651 SCTPCTL_RTTVAR_DCCCECN_DESC); 1652 1653 sysctl_add_oid(&sysctl_oid_top, "blackhole", CTLTYPE_INT|CTLFLAG_RW, 1654 &SCTP_BASE_SYSCTL(sctp_blackhole), 0, sctp_sysctl_handle_int, 1655 SCTPCTL_BLACKHOLE_DESC); 1656 1657 sysctl_add_oid(&sysctl_oid_top, "diag_info_code", CTLTYPE_INT|CTLFLAG_RW, 1658 &SCTP_BASE_SYSCTL(sctp_diag_info_code), 0, sctp_sysctl_handle_int, 1659 SCTPCTL_DIAG_INFO_CODE_DESC); 1660 1661 #ifdef SCTP_DEBUG 1662 sysctl_add_oid(&sysctl_oid_top, "debug", CTLTYPE_INT|CTLFLAG_RW, 1663 &SCTP_BASE_SYSCTL(sctp_debug_on), 0, sctp_sysctl_handle_int, 1664 SCTPCTL_DEBUG_DESC); 1665 #endif 1666 1667 sysctl_add_oid(&sysctl_oid_top, "stats", CTLTYPE_STRUCT|CTLFLAG_RW, 1668 &SCTP_BASE_STATS, sizeof(SCTP_BASE_STATS), NULL, 1669 "SCTP statistics (struct sctp_stat)"); 1670 1671 sysctl_add_oid(&sysctl_oid_top, "assoclist", CTLTYPE_STRUCT|CTLFLAG_RD, 1672 NULL, 0, sctp_assoclist, 1673 "List of active SCTP associations"); 1674 } 1675 #endif 1676 #endif 1677