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