/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 <kld
name>.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
This commit is contained in:
Doug Rabson 2023-06-21 13:26:17 +01:00
parent f53b28c6df
commit 09267cc152
3 changed files with 15 additions and 0 deletions

View File

@ -96,6 +96,8 @@
..
ssl
..
sysctl.conf.d
..
syslog.d
..
zfs

View File

@ -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."

View File

@ -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/<module name>.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