From nobody Fri Jul 14 09:57:33 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 4R2RjT6jcFz4myyR; Fri, 14 Jul 2023 09:57:33 +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 4R2RjT6Gshz4J82; Fri, 14 Jul 2023 09:57:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689328653; 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=WIhNpKiDgGM0zhm0xSSw9xIqHHyICX/vvm9HggNhedI=; b=dDfx/s3ux7O7Z1Ozr1tqRzXUioD5xwJli/NNU6HLXgb9FCMdSDifVPnqWqg1H1/4Qmepvo kSTls+xL0L86kp+jwNHTh3Xycm9by2U2ds6yFNDg9YOWMT0931Vs9JFnQRy4pm63nDRgPw y1xsLC6xKYIv8BS5fPUavmJJyoTXYrcCRBUTTThbqWpP8mh/xO+ZCIdmu3tUimdaEZKMUH Ooc3nJsiolXS0xuKb83tT8GVvUx9kKjK6EM1WtbR6N63JYRK0vbDH0uzfNz/aj5tOP3vRu 8Mt74Rs2GL2laKHi6aSgcQ/DDKHMkfCVrk0UokVWFAd8ZxIQgGr/cq1DGCmNmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689328653; 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=WIhNpKiDgGM0zhm0xSSw9xIqHHyICX/vvm9HggNhedI=; b=m1gH24MTmm+NT5/W1ExuWPka69c/IkZl3PrD+A7h2oSrH7FZDwGfuhyZnJDc1mTcGNqVvr NwBcRhu1cgAO96HPGBs0CMQNyMo304V0+5qR2P3hOxsXgA093Fk4m8PWfn5P5jRLfNZ2yT 58vGjoTyX38K4C8L9LYg/4z28c8jJV/0qUvAIPkm76ZfSmeZift0UjJa0Bdha+A3pVUfXR eB0SmiNwZUchUrADm5aUGcCe7zPos9+FWeBBPokxmfxxxDrn3y1PSBKeTUxornLUEfXC0u Gl0d3mg0ADOEGHc4NidX8oGCBqaD4OKjTbMdlur3La/5WBn27zUsUssq5VkFIQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1689328653; a=rsa-sha256; cv=none; b=iCE84pjop5kq7OcTgF4iJgJiBosM1B9E7SnhB+IMQK2a+Z/4m11SveDfAGmtAD/mqopuOF w1jtJKW9wXYYcYFn3DtfU5l7mqkP0jzHwpU4IO4sNoBPR6tFDkmejmTvTvMXtD7layYbTS +jcPGtUyMWWcMhmTZDwIviJQ/2GbWGKwSS/WT1GkMkXZ3NgtBAI7j+sqUQrvTP5tBbZQHd TAV3XZtsL0HHZ6PNbayYnMHwSdl99TBQoSVxr22Pxc1dqE2T4kJHRxJCX8DzJxSGq28Oy8 G8IYYzCfg1/U35OI1O2WdimwIeHwXnBDotP/ERd9xr+PXdb5iRw2fJh/05n90g== 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 4R2RjT5KV6z1SWl; Fri, 14 Jul 2023 09:57:33 +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 36E9vXu0047195; Fri, 14 Jul 2023 09:57:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36E9vXtE047194; Fri, 14 Jul 2023 09:57:33 GMT (envelope-from git) Date: Fri, 14 Jul 2023 09:57:33 GMT Message-Id: <202307140957.36E9vXtE047194@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Doug Rabson Subject: git: 09267cc15284 - main - /etc/rc.subr: add support for kld sysctl variables 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: dfr X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 09267cc15284795fef958fb9ed786bb2382d6763 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dfr: URL: https://cgit.FreeBSD.org/src/commit/?id=09267cc15284795fef958fb9ed786bb2382d6763 commit 09267cc15284795fef958fb9ed786bb2382d6763 Author: Doug Rabson AuthorDate: 2023-06-21 12:26:17 +0000 Commit: Doug Rabson CommitDate: 2023-07-14 09:49:47 +0000 /etc/rc.subr: add support for kld sysctl variables For kernel modules loaded by scripts in /etc/rc.d and /usr/local/etc/rc.d, if there is a file in /etc/sysctl.conf.d named .conf, then this will be loaded using the sysctl(8) utility. For instance, sysctl variable changes for the pf kernel module would be placed in the file /etc/sysctl.conf.d/pf.conf. PR: 272129 Reviewed by: imp freebsd_igalic.co MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D40886 --- etc/mtree/BSD.root.dist | 2 ++ libexec/rc/rc.subr | 3 +++ share/man/man5/sysctl.conf.5 | 10 ++++++++++ 3 files changed, 15 insertions(+) diff --git a/etc/mtree/BSD.root.dist b/etc/mtree/BSD.root.dist index 3a3a3a78d995..2ec079b0abd1 100644 --- a/etc/mtree/BSD.root.dist +++ b/etc/mtree/BSD.root.dist @@ -96,6 +96,8 @@ .. ssl .. + sysctl.conf.d + .. syslog.d .. zfs diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr index 6a7f070f7f5b..ef3da46b3206 100644 --- a/libexec/rc/rc.subr +++ b/libexec/rc/rc.subr @@ -1970,6 +1970,9 @@ load_kld() return 1 else info "$1 kernel module loaded." + if [ -f "/etc/sysctl.conf.d/$1.conf" ]; then + sysctl -f "/etc/sysctl.conf.d/$1.conf" + fi fi else debug "load_kld: $1 kernel module already loaded." diff --git a/share/man/man5/sysctl.conf.5 b/share/man/man5/sysctl.conf.5 index 5df168661d85..26ecf763ca12 100644 --- a/share/man/man5/sysctl.conf.5 +++ b/share/man/man5/sysctl.conf.5 @@ -51,6 +51,13 @@ Comments can also exist at the end of a line, as seen in the .Sx EXAMPLES section, below. +.Pp +For kernel modules loaded via +.Xr rc.subr 8 +system , +additional module-specific settings can be applied +by adding a file in the same format named +.Pf /etc/sysctl.d/.conf . .Sh FILES .Bl -tag -width /etc/rc.d/sysctl_lastload -compact .It Pa /etc/rc.d/sysctl @@ -69,6 +76,9 @@ Initial settings for .It Pa /etc/sysctl.conf.local Machine-specific settings for sites with a common .Pa /etc/sysctl.conf . +.It Pa /etc/sysctl.conf.d +Module specific settings for kernel modules loaded via +.Xr rc.subr 8 . .El .Sh EXAMPLES To turn off logging of programs that exit due to fatal signals you may use