From nobody Mon Oct 16 15:18:14 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4S8LN64Nbxz4xTdp; Mon, 16 Oct 2023 15:18:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4S8LN63TRhz4X8r; Mon, 16 Oct 2023 15:18:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697469494; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/Vzm8AcJ4zTo17IpsIuMYcrd0PSQy5d2wFyD0q8wVoQ=; b=iMcShzEYg0ka3Ad8D6PVMota8gwpZA6bAgpbQJkM4J9EDHUMUehOqiupvHXdoJGSwUyCu1 v82zdgRaBtjJQKzDTcInwqMW468XqVH6J6c7rJkeW2y7fedvdMvcKSZT6xCrI9GOLKspuv +O/34mPABbnACVzUPjywqbuodPcbHJJnN6l6jvvM93iQuWQF/AzWJ/j5SIQNBeyNJ1JGXF g36jpLk/tkbPPwLM9OP7yXKm2ta+dM7Aks6df0WNGN0ifMVqflFUHp1jFU08T9yxJQCICl cAdSPaGEu+ufKDAMshncoTG2OEgDiVfVJzdYmf1+30tZVZfGTHCGXwRrIxVFEA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697469494; a=rsa-sha256; cv=none; b=raeUtvadawTvbzOv8BIpcgly246yIJ78MFBEXC4I/6Aj2EUXhO1O0VwJkF0EAUr6dk/u4Y kHkIgowOQpLnEiZMur56mLoTB+WjfOqkFLDS8ks9QeI3HoCgmLm9eYuvaHcJu2dko9e2oI FLVutBe6CqcfGYw0uPhE2glMsmUWZs3rzFUnlVD6hjYrauvOzdpdTG4hSwQ/drF2hnCkrH HA8+yqGSSqDLlG2GiinGmw8TeuEgHyiBQLYggXy5RI12V/2vJ6UwmV7tdeScMdOSwAnqrp Fkad2WWBvNH5EtqRsm2ehlbVghCFmwRjyWExaW51LNf3tbYiAPFlavglrOobGQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697469494; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/Vzm8AcJ4zTo17IpsIuMYcrd0PSQy5d2wFyD0q8wVoQ=; b=kWJMaMqH2TuwNuonsNAYLjM5VRO9ALVCFpyrVQFH1W0PKEQDerrVyYRZEoCYGp2G20PA3L sUWJvEDATYNnpyOYOWuParEFKEJ5nIiNUnItEVr4KtDt6eOY4LNyEZ6eHkRyW44VG8gs5u q4FS99CFME5XdVZ/BHGDsW1q8QlcAMt995KQHfCqJrcwzXw81q/j55FmkGlPSa30fLdx/I qpbmQO5aFHMhyySyNRgaYynlWia1SsnyaCyD/l868ystv5FJs5NVBJRrbP0YhfBWHWdKJi UncSGVCV5uIGVTh/8itXt2ONC7WZbDuvFl4ObZDtHq7q26QkVGH9Is9XMgunzQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4S8LN62T2Kzlfp; Mon, 16 Oct 2023 15:18:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 39GFIEvX054341; Mon, 16 Oct 2023 15:18:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39GFIEBg054337; Mon, 16 Oct 2023 15:18:14 GMT (envelope-from git) Date: Mon, 16 Oct 2023 15:18:14 GMT Message-Id: <202310161518.39GFIEBg054337@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Zhenlei Huang Subject: git: fd9de12a7110 - stable/14 - sctp: Various fixes for loader tunables List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zlei X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: fd9de12a71109d1e3bb4b20e7d040fc9a1784dc2 Auto-Submitted: auto-generated The branch stable/14 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=fd9de12a71109d1e3bb4b20e7d040fc9a1784dc2 commit fd9de12a71109d1e3bb4b20e7d040fc9a1784dc2 Author: Zhenlei Huang AuthorDate: 2023-10-09 04:36:48 +0000 Commit: Zhenlei Huang CommitDate: 2023-10-16 15:15:37 +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) --- 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 16cde18c4c1d..a1742b2fffca 100644 --- a/sys/netinet/sctp_pcb.c +++ b/sys/netinet/sctp_pcb.c @@ -5676,6 +5676,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) { @@ -5717,6 +5722,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 851ed408092b..2c2cc58ee086 100644 --- a/sys/netinet/sctp_sysctl.c +++ b/sys/netinet/sctp_sysctl.c @@ -867,6 +867,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) \ { \ @@ -885,9 +893,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 @@ -909,10 +921,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)