git: 53379a40395d - stable/12 - sctp: Various fixes for loader tunables
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 16 Oct 2023 15:51:18 UTC
The branch stable/12 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=53379a40395dc4e66540c1c539dd1b70d8592852 commit 53379a40395dc4e66540c1c539dd1b70d8592852 Author: Zhenlei Huang <zlei@FreeBSD.org> AuthorDate: 2023-10-09 04:36:48 +0000 Commit: Zhenlei Huang <zlei@FreeBSD.org> CommitDate: 2023-10-16 15:49:59 +0000 sctp: Various fixes for loader tunables The following sysctl variables are actually loader tunables. Add sysctl flag CTLFLAG_TUN to them so that `sysctl -T` will report them correctly. 1. net.inet.sctp.tcbhashsize 2. net.inet.sctp.pcbhashsize 3. net.inet.sctp.chunkscale The loader tunable 'net.inet.sctp.tcbhashsize' and 'net.inet.sctp.chunkscale' are only used during vnet initializing, thus it make no senses to make them writable tunable. Validate the values of loader tunables on vnet initialize, reset them to theirs defaults if invalid to prevent potential kernel panics. Reviewed by: tuexen, #transport, #network MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D42007 (cherry picked from commit dac91eb7660324677d8a2f71bd6f192422355ba1) (cherry picked from commit fd9de12a71109d1e3bb4b20e7d040fc9a1784dc2) (cherry picked from commit 69e05e06c60d1f068fafcc4a26ef5efdb8771c71) --- sys/netinet/sctp_pcb.c | 8 ++++++++ sys/netinet/sctp_sysctl.c | 24 ++++++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c index a1e6ebb8589b..4761fb69c05f 100644 --- a/sys/netinet/sctp_pcb.c +++ b/sys/netinet/sctp_pcb.c @@ -5743,6 +5743,11 @@ sctp_startup_mcore_threads(void) } #endif +#define VALIDATE_LOADER_TUNABLE(var_name, prefix) \ + if (SCTP_BASE_SYSCTL(var_name) < prefix##_MIN || \ + SCTP_BASE_SYSCTL(var_name) > prefix##_MAX) \ + SCTP_BASE_SYSCTL(var_name) = prefix##_DEFAULT + void sctp_pcb_init(void) { @@ -5785,6 +5790,9 @@ sctp_pcb_init(void) TUNABLE_INT_FETCH("net.inet.sctp.tcbhashsize", &SCTP_BASE_SYSCTL(sctp_hashtblsize)); TUNABLE_INT_FETCH("net.inet.sctp.pcbhashsize", &SCTP_BASE_SYSCTL(sctp_pcbtblsize)); TUNABLE_INT_FETCH("net.inet.sctp.chunkscale", &SCTP_BASE_SYSCTL(sctp_chunkscale)); + VALIDATE_LOADER_TUNABLE(sctp_hashtblsize, SCTPCTL_TCBHASHSIZE); + VALIDATE_LOADER_TUNABLE(sctp_pcbtblsize, SCTPCTL_PCBHASHSIZE); + VALIDATE_LOADER_TUNABLE(sctp_chunkscale, SCTPCTL_CHUNKSCALE); SCTP_BASE_INFO(sctp_asochash) = SCTP_HASH_INIT((SCTP_BASE_SYSCTL(sctp_hashtblsize) * 31), &SCTP_BASE_INFO(hashasocmark)); SCTP_BASE_INFO(sctp_ephash) = SCTP_HASH_INIT(SCTP_BASE_SYSCTL(sctp_hashtblsize), diff --git a/sys/netinet/sctp_sysctl.c b/sys/netinet/sctp_sysctl.c index 6e3b1d4ac3d5..2d5e573c0f8e 100644 --- a/sys/netinet/sctp_sysctl.c +++ b/sys/netinet/sctp_sysctl.c @@ -838,6 +838,14 @@ sctp_sysctl_handle_trace_log_clear(SYSCTL_HANDLER_ARGS) #endif #define SCTP_UINT_SYSCTL(mib_name, var_name, prefix) \ + SCTP_UINT_SYSCTL_FLAG(mib_name, var_name, prefix, \ + CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW); + +#define SCTP_UINT_SYSCTL_TUN(mib_name, var_name, prefix) \ + SCTP_UINT_SYSCTL_FLAG(mib_name, var_name, prefix, \ + CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RWTUN|CTLFLAG_NOFETCH); + +#define SCTP_UINT_SYSCTL_FLAG(mib_name, var_name, prefix, flags) \ static int \ sctp_sysctl_handle_##mib_name(SYSCTL_HANDLER_ARGS) \ { \ @@ -856,9 +864,13 @@ sctp_sysctl_handle_trace_log_clear(SYSCTL_HANDLER_ARGS) } \ return (error); \ } \ - SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mib_name, \ - CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW, NULL, 0, \ - sctp_sysctl_handle_##mib_name, "UI", prefix##_DESC); + SYSCTL_PROC(_net_inet_sctp, OID_AUTO, mib_name, flags, \ + NULL, 0, sctp_sysctl_handle_##mib_name, "UI", prefix##_DESC) + +#define SCTP_UINT_SYSCTL_RDTUN(mib_name, var_name, prefix) \ + SYSCTL_UINT(_net_inet_sctp, OID_AUTO, mib_name, \ + CTLFLAG_VNET|CTLFLAG_RDTUN|CTLFLAG_NOFETCH, \ + &VNET_NAME(system_base_info.sctpsysctl.var_name), 0, prefix##_DESC); /* * sysctl definitions @@ -880,10 +892,10 @@ SCTP_UINT_SYSCTL(peer_chkoh, sctp_peer_chunk_oh, SCTPCTL_PEER_CHKOH) SCTP_UINT_SYSCTL(maxburst, sctp_max_burst_default, SCTPCTL_MAXBURST) SCTP_UINT_SYSCTL(fr_maxburst, sctp_fr_max_burst_default, SCTPCTL_FRMAXBURST) SCTP_UINT_SYSCTL(maxchunks, sctp_max_chunks_on_queue, SCTPCTL_MAXCHUNKS) -SCTP_UINT_SYSCTL(tcbhashsize, sctp_hashtblsize, SCTPCTL_TCBHASHSIZE) -SCTP_UINT_SYSCTL(pcbhashsize, sctp_pcbtblsize, SCTPCTL_PCBHASHSIZE) +SCTP_UINT_SYSCTL_RDTUN(tcbhashsize, sctp_hashtblsize, SCTPCTL_TCBHASHSIZE) +SCTP_UINT_SYSCTL_TUN(pcbhashsize, sctp_pcbtblsize, SCTPCTL_PCBHASHSIZE) SCTP_UINT_SYSCTL(min_split_point, sctp_min_split_point, SCTPCTL_MIN_SPLIT_POINT) -SCTP_UINT_SYSCTL(chunkscale, sctp_chunkscale, SCTPCTL_CHUNKSCALE) +SCTP_UINT_SYSCTL_RDTUN(chunkscale, sctp_chunkscale, SCTPCTL_CHUNKSCALE) SCTP_UINT_SYSCTL(delayed_sack_time, sctp_delayed_sack_time_default, SCTPCTL_DELAYED_SACK_TIME) SCTP_UINT_SYSCTL(sack_freq, sctp_sack_freq_default, SCTPCTL_SACK_FREQ) SCTP_UINT_SYSCTL(sys_resource, sctp_system_free_resc_limit, SCTPCTL_SYS_RESOURCE)