aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.inc19
-rw-r--r--RELNOTES7
-rw-r--r--contrib/blocklist/Makefile2
-rw-r--r--contrib/blocklist/Makefile.inc7
-rw-r--r--contrib/blocklist/README52
-rw-r--r--contrib/blocklist/TODO49
-rw-r--r--contrib/blocklist/bin/Makefile12
-rw-r--r--contrib/blocklist/bin/blacklistctl.862
-rw-r--r--contrib/blocklist/bin/blacklistctl.c11
-rw-r--r--contrib/blocklist/bin/blacklistd.854
-rw-r--r--contrib/blocklist/bin/blacklistd.c34
-rw-r--r--contrib/blocklist/bin/blacklistd.conf.571
-rw-r--r--contrib/blocklist/bin/blocklistctl.8131
-rw-r--r--contrib/blocklist/bin/blocklistctl.c170
-rw-r--r--contrib/blocklist/bin/blocklistd.8303
-rw-r--r--contrib/blocklist/bin/blocklistd.c592
-rw-r--r--contrib/blocklist/bin/blocklistd.conf.5237
-rw-r--r--contrib/blocklist/bin/conf.c200
-rw-r--r--contrib/blocklist/bin/conf.h3
-rw-r--r--contrib/blocklist/bin/internal.c8
-rw-r--r--contrib/blocklist/bin/internal.h8
-rw-r--r--contrib/blocklist/bin/old_internal.c50
-rw-r--r--contrib/blocklist/bin/old_internal.h58
-rw-r--r--contrib/blocklist/bin/run.c9
-rw-r--r--contrib/blocklist/bin/run.h2
-rw-r--r--contrib/blocklist/bin/state.c6
-rw-r--r--contrib/blocklist/bin/state.h2
-rw-r--r--contrib/blocklist/bin/support.c11
-rw-r--r--contrib/blocklist/bin/support.h7
-rw-r--r--contrib/blocklist/diff/ftpd.diff12
-rw-r--r--contrib/blocklist/diff/named.diff12
-rw-r--r--contrib/blocklist/diff/postfix.diff98
-rw-r--r--contrib/blocklist/diff/proftpd.diff20
-rw-r--r--contrib/blocklist/diff/ssh.diff14
-rw-r--r--contrib/blocklist/etc/Makefile10
-rw-r--r--contrib/blocklist/etc/blocklistd.conf (renamed from contrib/blocklist/etc/blacklistd.conf)7
-rw-r--r--contrib/blocklist/etc/ipf.conf45
-rw-r--r--contrib/blocklist/etc/npf.conf4
-rw-r--r--contrib/blocklist/etc/rc.d/Makefile4
-rw-r--r--contrib/blocklist/etc/rc.d/blocklistd (renamed from contrib/blocklist/etc/rc.d/blacklistd)20
-rw-r--r--contrib/blocklist/include/Makefile4
-rw-r--r--contrib/blocklist/include/bl.h11
-rw-r--r--contrib/blocklist/include/blacklist.h16
-rw-r--r--contrib/blocklist/include/blocklist.h65
-rw-r--r--contrib/blocklist/include/old_bl.h80
-rw-r--r--contrib/blocklist/lib/Makefile20
-rw-r--r--contrib/blocklist/lib/bl.c112
-rw-r--r--contrib/blocklist/lib/blacklist.c17
-rw-r--r--contrib/blocklist/lib/blocklist.c117
-rw-r--r--contrib/blocklist/lib/libblacklist.337
-rw-r--r--contrib/blocklist/lib/libblocklist.3183
-rw-r--r--contrib/blocklist/lib/old_bl.c554
-rw-r--r--contrib/blocklist/lib/shlib_version2
-rw-r--r--contrib/blocklist/libexec/Makefile4
-rw-r--r--contrib/blocklist/libexec/blacklistd-helper134
-rwxr-xr-xcontrib/blocklist/libexec/blocklistd-helper272
-rw-r--r--contrib/blocklist/port/Makefile.am42
-rw-r--r--contrib/blocklist/port/_strtoi.h2
-rw-r--r--contrib/blocklist/port/configure.ac12
-rw-r--r--contrib/blocklist/port/fgetln.c2
-rw-r--r--contrib/blocklist/port/fparseln.c6
-rw-r--r--contrib/blocklist/port/pidfile.c6
-rw-r--r--contrib/blocklist/port/popenve.c6
-rw-r--r--contrib/blocklist/port/port.h32
-rw-r--r--contrib/blocklist/port/sockaddr_snprintf.c6
-rw-r--r--contrib/blocklist/port/strlcat.c7
-rw-r--r--contrib/blocklist/port/strlcpy.c7
-rw-r--r--contrib/blocklist/port/strtoi.c6
-rw-r--r--contrib/blocklist/port/vsyslog_r.c13
-rw-r--r--contrib/blocklist/test/Makefile2
-rw-r--r--contrib/blocklist/test/cltest.c6
-rw-r--r--contrib/blocklist/test/srvtest.c42
-rw-r--r--contrib/bsddialog/.gitignore1
-rw-r--r--contrib/bsddialog/CHANGELOG50
-rw-r--r--contrib/bsddialog/LICENSE2
-rw-r--r--contrib/bsddialog/Makefile13
-rw-r--r--contrib/bsddialog/README.md5
-rwxr-xr-xcontrib/bsddialog/examples_library/compile8
-rw-r--r--contrib/bsddialog/examples_library/textbox.c38
-rw-r--r--contrib/bsddialog/lib/GNUmakefile19
-rw-r--r--contrib/bsddialog/lib/Makefile21
-rw-r--r--contrib/bsddialog/lib/barbox.c37
-rw-r--r--contrib/bsddialog/lib/bsddialog.316
-rw-r--r--contrib/bsddialog/lib/bsddialog.h5
-rw-r--r--contrib/bsddialog/lib/bsddialog_theme.h2
-rw-r--r--contrib/bsddialog/lib/datebox.c28
-rw-r--r--contrib/bsddialog/lib/formbox.c48
-rw-r--r--contrib/bsddialog/lib/lib_util.c3
-rw-r--r--contrib/bsddialog/lib/lib_util.h4
-rw-r--r--contrib/bsddialog/lib/libbsddialog.c14
-rw-r--r--contrib/bsddialog/lib/menubox.c18
-rw-r--r--contrib/bsddialog/lib/messagebox.c16
-rw-r--r--contrib/bsddialog/lib/textbox.c16
-rw-r--r--contrib/bsddialog/lib/theme.c6
-rw-r--r--contrib/bsddialog/lib/timebox.c16
-rw-r--r--contrib/bsddialog/utility/GNUmakefile11
-rw-r--r--contrib/bsddialog/utility/Makefile11
-rw-r--r--contrib/bsddialog/utility/bsddialog.121
-rw-r--r--contrib/bsddialog/utility/bsddialog.c2
-rw-r--r--contrib/bsddialog/utility/util.h2
-rw-r--r--contrib/bsddialog/utility/util_builders.c66
-rw-r--r--contrib/bsddialog/utility/util_cli.c2
-rw-r--r--contrib/bsddialog/utility/util_theme.c4
-rw-r--r--contrib/kyua/drivers/run_tests.cpp2
-rw-r--r--contrib/sendmail/src/newaliases.12
-rw-r--r--crypto/krb5/src/build-tools/mit-krb5.pc.in2
-rw-r--r--crypto/openssh/auth-pam.c4
-rw-r--r--crypto/openssh/auth.c8
-rw-r--r--crypto/openssh/blocklist.c (renamed from crypto/openssh/blacklist.c)16
-rw-r--r--crypto/openssh/blocklist_client.h (renamed from crypto/openssh/blacklist_client.h)30
-rw-r--r--crypto/openssh/monitor.c8
-rw-r--r--crypto/openssh/servconf.c18
-rw-r--r--crypto/openssh/servconf.h2
-rw-r--r--crypto/openssh/sshd-session.c10
-rw-r--r--crypto/openssh/sshd_config2
-rw-r--r--crypto/openssh/sshd_config.514
-rw-r--r--etc/mtree/BSD.include.dist4
-rw-r--r--etc/mtree/BSD.usr.dist14
-rw-r--r--etc/mtree/BSD.var.dist2
-rw-r--r--lib/Makefile1
-rw-r--r--lib/libblacklist/Makefile7
-rw-r--r--lib/libblocklist/Makefile30
-rw-r--r--lib/libblocklist/Makefile.depend16
-rw-r--r--lib/libbluetooth/Makefile2
-rw-r--r--lib/libbz2/Makefile13
-rw-r--r--lib/libbz2/bzip2.pc.in11
-rw-r--r--lib/libcasper/services/cap_fileargs/cap_fileargs.h2
-rw-r--r--lib/libsys/getgroups.225
-rw-r--r--lib/libsysdecode/Makefile.depend2
-rw-r--r--lib/msun/src/e_remainder.c4
-rw-r--r--lib/virtual_oss/Makefile.inc2
-rw-r--r--libexec/Makefile6
-rw-r--r--libexec/blacklistd-helper/Makefile7
-rw-r--r--libexec/blocklistd-helper/Makefile10
-rw-r--r--libexec/blocklistd-helper/Makefile.depend (renamed from libexec/blacklistd-helper/Makefile.depend)0
-rw-r--r--libexec/blocklistd-helper/blacklistd-helper293
-rw-r--r--libexec/fingerd/Makefile8
-rw-r--r--libexec/fingerd/Makefile.depend.options2
-rw-r--r--libexec/fingerd/fingerd.c16
-rw-r--r--libexec/rc/rc.conf6
-rw-r--r--libexec/rc/rc.d/Makefile5
-rwxr-xr-xlibexec/rc/rc.d/blacklistd10
-rw-r--r--libexec/rc/rc.d/blocklistd46
-rw-r--r--libexec/rc/rc.d/virtual_oss4
-rw-r--r--release/Makefile.mirrors1
-rw-r--r--release/packages/ucl/acpi-all.ucl2
-rw-r--r--release/packages/ucl/audit-all.ucl2
-rw-r--r--release/packages/ucl/blocklist-all.ucl8
-rw-r--r--release/packages/ucl/libbegemot-all.ucl4
-rw-r--r--release/packages/ucl/libbsdstat-all.ucl2
-rw-r--r--release/packages/ucl/mandoc-all.ucl2
-rw-r--r--release/packages/ucl/yp-all.ucl2
-rw-r--r--release/tools/ec2-base.conf4
-rw-r--r--release/tools/ec2-builder.conf3
-rw-r--r--release/tools/ec2-small.conf3
-rw-r--r--release/tools/oci-image-notoolchain.conf54
-rw-r--r--release/tools/vmimage.subr22
-rw-r--r--sbin/mount_nullfs/mount_nullfs.828
-rw-r--r--secure/libexec/sshd-auth/Makefile10
-rw-r--r--secure/libexec/sshd-session/Makefile10
-rw-r--r--secure/usr.sbin/sshd/Makefile.depend.options2
-rw-r--r--share/man/man4/umass.456
-rw-r--r--share/man/man5/periodic.conf.52
-rw-r--r--share/man/man5/src.conf.543
-rw-r--r--share/mk/bsd.libnames.mk1
-rw-r--r--share/mk/local.dirdeps-options.mk1
-rw-r--r--share/mk/src.libnames.mk10
-rw-r--r--share/mk/src.opts.mk10
-rw-r--r--stand/lua/cli.lua.818
-rw-r--r--sys/amd64/include/vmm.h99
-rw-r--r--sys/amd64/vmm/vmm.c47
-rw-r--r--sys/amd64/vmm/vmm_dev_machdep.c1
-rw-r--r--sys/arm64/include/vmm.h32
-rw-r--r--sys/arm64/vmm/arm64.h31
-rw-r--r--sys/arm64/vmm/vmm.c37
-rw-r--r--sys/conf/dtb.build.mk4
-rw-r--r--sys/conf/kern.opts.mk10
-rw-r--r--sys/contrib/openzfs/module/os/freebsd/zfs/sysctl_os.c244
-rw-r--r--sys/contrib/openzfs/module/zfs/arc.c32
-rw-r--r--sys/contrib/openzfs/module/zfs/dmu_zfetch.c10
-rw-r--r--sys/contrib/openzfs/module/zfs/vdev.c2
-rw-r--r--sys/contrib/openzfs/module/zfs/vdev_queue.c2
-rw-r--r--sys/contrib/openzfs/module/zfs/vdev_removal.c4
-rw-r--r--sys/contrib/openzfs/tests/zfs-tests/include/tunables.cfg4
-rw-r--r--sys/dev/ice/ice_common.c9
-rw-r--r--sys/dev/ice/ice_devids.h18
-rw-r--r--sys/dev/ice/ice_drv_info.h39
-rw-r--r--sys/dev/ixgbe/if_ix.c521
-rw-r--r--sys/dev/ixgbe/ixgbe.h52
-rw-r--r--sys/dev/ixgbe/ixgbe_features.h1
-rw-r--r--sys/dev/nvme/nvme.h6
-rw-r--r--sys/dev/vmm/vmm_mem.c31
-rw-r--r--sys/dev/vmm/vmm_mem.h6
-rw-r--r--sys/fs/nullfs/null.h15
-rw-r--r--sys/fs/nullfs/null_subr.c4
-rw-r--r--sys/fs/nullfs/null_vfsops.c20
-rw-r--r--sys/fs/nullfs/null_vnops.c10
-rw-r--r--sys/modules/aic7xxx/ahc/Makefile2
-rw-r--r--sys/modules/cxgb/Makefile3
-rw-r--r--sys/modules/dpdk_lpm4/Makefile3
-rw-r--r--sys/modules/dpdk_lpm6/Makefile3
-rw-r--r--sys/modules/fib_dxr/Makefile3
-rw-r--r--sys/modules/if_enc/Makefile2
-rw-r--r--sys/modules/if_gif/Makefile2
-rw-r--r--sys/modules/if_gre/Makefile1
-rw-r--r--sys/modules/iser/Makefile2
-rw-r--r--sys/modules/ktest/Makefile3
-rw-r--r--sys/modules/ktest/ktest/Makefile6
-rw-r--r--sys/modules/ktest/ktest_example/Makefile5
-rw-r--r--sys/modules/ktest/ktest_netlink_message_writer/Makefile2
-rw-r--r--sys/modules/miiproxy/Makefile2
-rw-r--r--sys/modules/netgraph/Makefile2
-rw-r--r--sys/modules/netgraph/checksum/Makefile3
-rw-r--r--sys/modules/netmap/Makefile3
-rw-r--r--sys/modules/opensolaris/Makefile2
-rw-r--r--sys/modules/ow/Makefile3
-rw-r--r--sys/modules/qlnx/Makefile3
-rw-r--r--sys/modules/rtwn/Makefile4
-rw-r--r--sys/modules/rtwn_pci/Makefile4
-rw-r--r--sys/modules/rtwn_usb/Makefile4
-rw-r--r--sys/modules/sound/driver/Makefile3
-rw-r--r--sys/modules/sound/sound/Makefile1
-rw-r--r--sys/modules/tests/fib_lookup/Makefile3
-rw-r--r--sys/modules/vnic/Makefile3
-rw-r--r--sys/modules/vnic/mrmlbus/Makefile3
-rw-r--r--sys/modules/vnic/thunder_bgx/Makefile3
-rw-r--r--sys/modules/vnic/thunder_mdio/Makefile3
-rw-r--r--sys/modules/vnic/vnicpf/Makefile3
-rw-r--r--sys/modules/vnic/vnicvf/Makefile3
-rw-r--r--sys/netpfil/ipfw/ip_dn_io.c6
-rw-r--r--sys/riscv/include/vmm.h24
-rw-r--r--sys/riscv/vmm/riscv.h23
-rw-r--r--sys/riscv/vmm/vmm.c35
-rw-r--r--sys/sys/user.h3
-rw-r--r--sys/vm/vm_object.c12
-rw-r--r--targets/pseudo/userland/Makefile.depend6
-rw-r--r--targets/pseudo/userland/lib/Makefile.depend4
-rw-r--r--targets/pseudo/userland/libexec/Makefile.depend4
-rw-r--r--tests/sys/netpfil/pf/ether.sh3
-rw-r--r--tests/sys/netpfil/pf/nat.sh7
-rw-r--r--tests/sys/netpfil/pf/rules_counter.sh1
-rw-r--r--tests/sys/netpfil/pf/syncookie.sh3
-rw-r--r--tools/build/mk/OptionalObsoleteFiles.inc21
-rw-r--r--tools/build/options/WITHOUT_BLACKLIST6
-rw-r--r--tools/build/options/WITHOUT_BLACKLIST_SUPPORT8
-rw-r--r--tools/build/options/WITHOUT_BLOCKLIST4
-rw-r--r--tools/build/options/WITHOUT_BLOCKLIST_SUPPORT6
-rw-r--r--usr.bin/sockstat/main.c26
-rw-r--r--usr.bin/sockstat/sockstat.13
-rw-r--r--usr.bin/sockstat/tests/Makefile3
-rw-r--r--usr.bin/vmstat/vmstat.c4
-rw-r--r--usr.sbin/Makefile2
-rw-r--r--usr.sbin/acpi/acpidump/acpi.c9
-rw-r--r--usr.sbin/blacklistctl/Makefile7
-rw-r--r--usr.sbin/blacklistd/Makefile9
-rw-r--r--usr.sbin/blacklistd/blacklistd.conf10
-rw-r--r--usr.sbin/blocklistctl/Makefile22
-rw-r--r--usr.sbin/blocklistctl/Makefile.depend18
-rw-r--r--usr.sbin/blocklistd/Makefile23
-rw-r--r--usr.sbin/blocklistd/Makefile.depend18
-rw-r--r--usr.sbin/blocklistd/blocklistd.conf16
-rwxr-xr-xusr.sbin/bsdinstall/scripts/auto4
-rwxr-xr-xusr.sbin/bsdinstall/scripts/jail4
-rw-r--r--usr.sbin/ctld/ctld.cc5
-rw-r--r--usr.sbin/ctld/ctld.hh1
-rw-r--r--usr.sbin/ctld/nvmf.cc77
-rw-r--r--usr.sbin/ctld/nvmf.hh16
-rw-r--r--usr.sbin/nfsuserd/nfsuserd.c1
-rwxr-xr-xusr.sbin/periodic/etc/security/520.pfdenied2
-rw-r--r--usr.sbin/rpc.tlsservd/rpc.tlsservd.c7
270 files changed, 6262 insertions, 1293 deletions
diff --git a/Makefile.inc1 b/Makefile.inc1
index 9dc4f2db4a6c..74c4598dd092 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -2240,7 +2240,7 @@ _default_flavor= -default
_debug=-dbg
. endif
-create-dtb-package:
+create-dtb-package: .PHONY
@if [ -f ${KSTAGEDIR}/${DISTDIR}/dtb.plist ]; then \
${SRCDIR}/release/packages/generate-ucl.lua \
PKGNAME "dtb" \
@@ -2265,9 +2265,12 @@ create-dtb-package:
-o ${REPODIR}/${PKG_ABI}/${PKG_OUTPUT_DIR} ; \
fi
-create-kernel-packages: .PHONY
+create-kernel-packages: .PHONY create-kernel-flavored-packages create-dtb-package
+create-kernel-flavored-packages: .PHONY
+.ORDER: create-kernel-flavored-packages create-dtb-package
+
. for flavor in "" ${_debug}
-create-kernel-packages: create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},} create-dtb-package
+create-kernel-flavored-packages: create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}
create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap .PHONY
@cd ${KSTAGEDIR}/${DISTDIR} ; \
${METALOG_SORT_CMD} ${KSTAGEDIR}/kernel.meta | \
diff --git a/RELNOTES b/RELNOTES
index 9960fdcaf00f..174ce12e4148 100644
--- a/RELNOTES
+++ b/RELNOTES
@@ -10,6 +10,13 @@ newline. Entries should be separated by a newline.
Changes to this file should not be MFCed.
+5000d023a446, 03da141d59ae:
+ Add a "-f" option to "kadmin -l dump" with can be used to
+ dump the Heimdal KDC database in a format that can be loaded
+ into the MIT KDC.
+ See https://wiki.freebsd.org/Kerberos/Heimdal2MIT_KDC_Migration
+ for how to use "-f" to transfer/convert the KDC database.
+
9cab9fde5eda:
virtual_oss is imported to base. The audio/virtual_oss port will stop
being built from FreeBSD 15.0 onwards.
diff --git a/contrib/blocklist/Makefile b/contrib/blocklist/Makefile
index da4411d0ca75..899746d01431 100644
--- a/contrib/blocklist/Makefile
+++ b/contrib/blocklist/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.2 2015/01/22 17:49:41 christos Exp $
+# $NetBSD: Makefile,v 1.1.1.1 2020/06/15 01:52:52 christos Exp $
SUBDIR = lib .WAIT include bin etc libexec
diff --git a/contrib/blocklist/Makefile.inc b/contrib/blocklist/Makefile.inc
index 85c82783cd35..b22d4a801240 100644
--- a/contrib/blocklist/Makefile.inc
+++ b/contrib/blocklist/Makefile.inc
@@ -1,10 +1,11 @@
-# $NetBSD: Makefile.inc,v 1.3 2015/01/23 03:57:22 christos Exp $
+# $NetBSD: Makefile.inc,v 1.3 2025/02/11 17:48:30 christos Exp $
WARNS=6
.if !defined(LIB)
-LDADD+= -lblacklist
-DPADD+= ${LIBBLACKLIST}
+LDADD+= -lblocklist
+DPADD+= ${LIBBLOCKLIST}
.endif
CPPFLAGS+= -I${.CURDIR}/../include
CPPFLAGS+=-DHAVE_STRUCT_SOCKADDR_SA_LEN -DHAVE_UTIL_H -DHAVE_DB_H
+CPPFLAGS+=-DHAVE_SYS_CDEFS_H
diff --git a/contrib/blocklist/README b/contrib/blocklist/README
index 7da3317a77fe..4b34138e01ec 100644
--- a/contrib/blocklist/README
+++ b/contrib/blocklist/README
@@ -1,21 +1,21 @@
-# $NetBSD: README,v 1.8 2017/04/13 17:59:34 christos Exp $
+# $NetBSD: README,v 1.3 2024/02/09 00:53:30 wiz Exp $
This package contains library that can be used by network daemons to
communicate with a packet filter via a daemon to enforce opening and
closing ports dynamically based on policy.
-The interface to the packet filter is in libexec/blacklistd-helper
+The interface to the packet filter is in libexec/blocklistd-helper
(this is currently designed for npf) and the configuration file
-(inspired from inetd.conf) is in etc/blacklistd.conf.
+(inspired from inetd.conf) is in etc/blocklistd.conf.
-On NetBSD you can find an example npf.conf and blacklistd.conf in
-/usr/share/examples/blacklistd; you need to adjust the interface
+On NetBSD you can find an example npf.conf and blocklistd.conf in
+/usr/share/examples/blocklistd; you need to adjust the interface
in npf.conf and copy both files to /etc; then you just enable
-blacklistd=YES in /etc/rc.conf, start it up, and you are all set.
+blocklistd=YES in /etc/rc.conf, start it up, and you are all set.
-There is also a startup file in etc/rc.d/blacklistd
+There is also a startup file in etc/rc.d/blocklistd
-Patches to various daemons to add blacklisting capabilitiers are in the
+Patches to various daemons to add blocklisting capabilities are in the
"diff" directory:
- OpenSSH: diff/ssh.diff [tcp socket example]
- Bind: diff/named.diff [both tcp and udp]
@@ -23,21 +23,21 @@ Patches to various daemons to add blacklisting capabilitiers are in the
These patches have been applied to NetBSD-current.
-The network daemon (for example sshd) communicates to blacklistd, via
-a unix socket like syslog. The library calls are simple and everything
+The network daemon (for example sshd) communicates to blocklistd, via
+a Unix socket like syslog. The library calls are simple and everything
is handled by the library. In the simplest form the only thing the
daemon needs to do is to call:
- blacklist(action, acceptedfd, message);
+ blocklist(action, acceptedfd, message);
Where:
- action = 0 -> successful login clear blacklist state
+ action = 0 -> successful login clear blocklist state
1 -> failed login, add to the failed count
acceptedfd -> the file descriptor where the server is
connected to the remote client. It is used
to determine the listening socket, and the
remote address. This allows any program to
- contact the blacklist daemon, since the verification
+ contact the blocklist daemon, since the verification
if the program has access to the listening
socket is done by virtue that the port
number is retrieved from the kernel.
@@ -46,13 +46,13 @@ Where:
Unfortunately there is no way to get information about the "peer"
from a udp socket, because there is no connection and that information
is kept with the server. In that case the daemon can provide the
-peer information to blacklistd via:
+peer information to blocklistd via:
- blacklist_sa(action, acceptedfd, sockaddr, sockaddr_len, message);
+ blocklist_sa(action, acceptedfd, sockaddr, sockaddr_len, message);
The configuration file contains entries of the form:
-# Blacklist rule
+# Blocklist rule
# host/Port type protocol owner name nfail disable
192.168.1.1:ssh stream tcp * -int 10 1m
8.8.8.8:ssh stream tcp * -ext 6 60m
@@ -60,18 +60,18 @@ ssh stream tcp6 * * 6 60m
http stream tcp * * 6 60m
Here note that owner is * because the connection is done from the
-child ssh socket which runs with user privs. We treat ipv4 connections
+child ssh socket which runs with user privs. We treat IPv4 connections
differently by maintaining two different rules one for the external
interface and one from the internal We also register for both tcp
and tcp6 since those are different listening sockets and addresses;
-we don't bother with ipv6 and separate rules. We use nfail = 6,
+we don't bother with IPv6 and separate rules. We use nfail = 6,
because ssh allows 3 password attempts per connection, and this
will let us have 2 connections before blocking. Finally we block
for an hour; we could block forever too by specifying * in the
duration column.
-blacklistd and the library use syslog(3) to report errors. The
-blacklist filter state is persisted automatically in /var/db/blacklistd.db
+blocklistd and the library use syslog(3) to report errors. The
+blocklist filter state is persisted automatically in /var/db/blocklistd.db
so that if the daemon is restarted, it remembers what connections
is currently handling. To start from a fresh state (if you restart
npf too for example), you can use -f. To watch the daemon at work,
@@ -80,27 +80,27 @@ you can use -d.
The current control file is designed for npf, and it uses the
dynamic rule feature. You need to create a dynamic rule in your
/etc/npf.conf on the group referring to the interface you want to block
-called blacklistd as follows:
+called blocklistd as follows:
ext_if=bge0
int_if=sk0
group "external" on $ext_if {
...
- ruleset "blacklistd-ext"
- ruleset "blacklistd"
+ ruleset "blocklistd-ext"
+ ruleset "blocklistd"
...
}
group "internal" on $int_if {
...
- ruleset "blacklistd-int"
+ ruleset "blocklistd-int"
...
}
-You can use 'blacklistctl dump -a' to list all the current entries
+You can use 'blocklistctl dump -a' to list all the current entries
in the database; the ones that have nfail <c>/<t> where <c>urrent
->= <t>otal, should have an id assosiated with them; this means that
+>= <t>otal, should have an id associated with them; this means that
there is a packet filter rule added for that entry. For npf, you
can examine the packet filter dynamic rule entries using 'npfctl
rule <rulename> list'. The number of current entries can exceed
diff --git a/contrib/blocklist/TODO b/contrib/blocklist/TODO
index 9925020d54bb..d67111bd5139 100644
--- a/contrib/blocklist/TODO
+++ b/contrib/blocklist/TODO
@@ -1,4 +1,4 @@
-# $NetBSD: TODO,v 1.7 2015/01/23 21:34:01 christos Exp $
+# $NetBSD: TODO,v 1.3 2025/02/05 20:22:26 christos Exp $
- don't poll periodically, find the next timeout
- use the socket also for commands? Or separate socket?
@@ -17,5 +17,48 @@
-n
block
unblock
-- do we need an api in blacklistctl to perform maintenance
-- fix the blacklistctl output to be more user friendly
+- do we need an api in blocklistctl to perform maintenance
+- fix the blocklistctl output to be more user friendly
+
+- figure out some way to do distributed operation securely (perhaps with
+ a helper daemon that authenticates local sockets and then communicates
+ local DB changes to the central server over a secure channel --
+ perhaps blocklistd-helper can have a back-end that can send updates to
+ a central server)
+
+- add "blocklistd -l" to enable filter logging on all rules by default
+
+- add some new options in the config file
+
+ "/all" - block both TCP and UDP (on the proto field?)
+
+ "/log" - enable filter logging (if not the default) (on the name field?)
+ "/nolog"- disable filter logging (if not the default) (on the name field?)
+
+ The latter two probably require a new parameter for blocklistd-helper.
+
+- "blocklistd -f" should (also?) be a blocklistctl function!?!?!
+
+- if blocklistd was started with '-r' then a SIGHUP should also do a
+ "control flush $rulename" and then re-add all the filter rules?
+
+- should/could /etc/rc.conf.d/ipfilter be created with the following?
+
+ reload_postcmd=blocklistd_reload
+ start_postcmd=blocklistd_start
+ stop_precmd=blocklistd_stop
+ blocklistd_reload ()
+ {
+ /etc/rc.d/blocklistd reload # IFF SIGHUP does flush/re-add
+ # /etc/rc.d/blocklistd restart
+ }
+ blocklistd_stop ()
+ {
+ /etc/rc.d/blocklistd stop
+ }
+ blocklistd_start ()
+ {
+ /etc/rc.d/blocklistd start
+ }
+
+ or is there a better way?
diff --git a/contrib/blocklist/bin/Makefile b/contrib/blocklist/bin/Makefile
index 280c72fd3af1..1856e2524f3c 100644
--- a/contrib/blocklist/bin/Makefile
+++ b/contrib/blocklist/bin/Makefile
@@ -1,12 +1,12 @@
-# $NetBSD: Makefile,v 1.11 2015/01/27 19:40:36 christos Exp $
+# $NetBSD: Makefile,v 1.1.1.1 2020/06/15 01:52:52 christos Exp $
BINDIR=/sbin
-PROGS=blacklistd blacklistctl
-MAN.blacklistd=blacklistd.8 blacklistd.conf.5
-MAN.blacklistctl=blacklistctl.8
-SRCS.blacklistd = blacklistd.c conf.c run.c state.c support.c internal.c
-SRCS.blacklistctl = blacklistctl.c conf.c state.c support.c internal.c
+PROGS=blocklistd blocklistctl
+MAN.blocklistd=blocklistd.8 blocklistd.conf.5
+MAN.blocklistctl=blocklistctl.8
+SRCS.blocklistd = blocklistd.c conf.c run.c state.c support.c internal.c
+SRCS.blocklistctl = blocklistctl.c conf.c state.c support.c internal.c
DBG=-g
LDADD+=-lutil
diff --git a/contrib/blocklist/bin/blacklistctl.8 b/contrib/blocklist/bin/blacklistctl.8
index 7c6521117745..4d557c0c979d 100644
--- a/contrib/blocklist/bin/blacklistctl.8
+++ b/contrib/blocklist/bin/blacklistctl.8
@@ -1,4 +1,4 @@
-.\" $NetBSD: blacklistctl.8,v 1.9 2016/06/08 12:48:37 wiz Exp $
+.\" $NetBSD: blocklistctl.8,v 1.4 2025/02/07 01:35:38 kre Exp $
.\"
.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,27 +27,43 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd June 7, 2016
+.Dd January 27, 2025
.Dt BLACKLISTCTL 8
.Os
.Sh NAME
.Nm blacklistctl
-.Nd display and change the state of blacklistd
+.Nd display and change the state of the blacklistd database
.Sh SYNOPSIS
.Nm
.Cm dump
.Op Fl abdnrw
+.Op Fl D Ar dbname
.Sh DESCRIPTION
.Nm
-is a program used to display the state of
+is a program used to display and change the state of the
.Xr blacklistd 8
+database.
+The following sub-commands are supported:
+.Ss dump
.Pp
-The following options are available:
+The following options are available for the
+.Cm dump
+sub-command:
.Bl -tag -width indent
.It Fl a
-Show all database entries, by default it shows only the embryonic ones.
+Show all database entries, by default it shows only the active ones.
+Inactive entries will be shown with a last-access (or, with
+.Fl r ,
+the remaining) time of
+.Ql never .
.It Fl b
Show only the blocked entries.
+.It Fl D Ar dbname
+Specify the location of the
+.Ic blacklistd
+database file to use.
+The default is
+.Pa /var/db/blocklistd.db .
.It Fl d
Increase debugging level.
.It Fl n
@@ -59,9 +75,43 @@ Normally the width of addresses is good for IPv4, the
.Fl w
flag, makes the display wide enough for IPv6 addresses.
.El
+.Pp
+The output of the
+.Cm dump
+sub-command consists of a header (unless
+.Fl n
+was given) and one line for each record in the database, where each line
+has the following columns:
+.Bl -tag -width indent
+.It Ql address/ma:port
+The remote address, mask, and local port number of the client connection
+associated with the database entry.
+.It Ql id
+column will show the identifier for the packet filter rule associated
+with the database entry, though this may only be the word
+.Ql OK
+for packet filters which do not creat a unique identifier for each rule.
+.It Ql nfail
+The number of
+.Em failures
+reported for the client on the noted port, as well as the number of
+failures allowed before blocking (or, with
+.Fl a ,
+an asterisk
+.Aq * )
+.It So last access Sc | So remaining time Sc
+The last time a the client was reported as attempting access, or, with
+.Fl r ,
+the time remaining before the rule blocking the client will be removed.
+.El
.Sh SEE ALSO
.Xr blacklistd 8
.Sh NOTES
+The
+.Nm
+program has been renamed to
+.Xr blocklistctl 8 .
+.Pp
Sometimes the reported number of failed attempts can exceed the number
of attempts that
.Xr blacklistd 8
diff --git a/contrib/blocklist/bin/blacklistctl.c b/contrib/blocklist/bin/blacklistctl.c
index 89b72921caf5..6298a08b10b4 100644
--- a/contrib/blocklist/bin/blacklistctl.c
+++ b/contrib/blocklist/bin/blacklistctl.c
@@ -1,4 +1,4 @@
-/* $NetBSD: blacklistctl.c,v 1.23 2018/05/24 19:21:01 christos Exp $ */
+/* $NetBSD: blocklistctl.c,v 1.4 2025/02/11 17:48:30 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -32,8 +32,10 @@
#include "config.h"
#endif
+#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
-__RCSID("$NetBSD: blacklistctl.c,v 1.23 2018/05/24 19:21:01 christos Exp $");
+#endif
+__RCSID("$NetBSD: blocklistctl.c,v 1.4 2025/02/11 17:48:30 christos Exp $");
#include <stdio.h>
#include <time.h>
@@ -53,7 +55,7 @@ __RCSID("$NetBSD: blacklistctl.c,v 1.23 2018/05/24 19:21:01 christos Exp $");
#include "conf.h"
#include "state.h"
-#include "internal.h"
+#include "old_internal.h"
#include "support.h"
static __dead void
@@ -63,7 +65,8 @@ usage(int c)
warnx("Missing/unknown command");
else if (c != '?')
warnx("Unknown option `%c'", (char)c);
- fprintf(stderr, "Usage: %s dump [-abdnrw]\n", getprogname());
+ fprintf(stderr,
+ "Usage: %s dump [-abdnrw] [-D dbname]\n", getprogname());
exit(EXIT_FAILURE);
}
diff --git a/contrib/blocklist/bin/blacklistd.8 b/contrib/blocklist/bin/blacklistd.8
index 82e1f15f61c9..9ca886e9c4d3 100644
--- a/contrib/blocklist/bin/blacklistd.8
+++ b/contrib/blocklist/bin/blacklistd.8
@@ -1,4 +1,4 @@
-.\" $NetBSD: blacklistd.8,v 1.23 2020/04/21 13:57:12 christos Exp $
+.\" $NetBSD: blocklistd.8,v 1.8 2025/02/25 22:13:34 christos Exp $
.\"
.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd April 21, 2020
+.Dd February 25, 2025
.Dt BLACKLISTD 8
.Os
.Sh NAME
@@ -53,18 +53,31 @@ for notifications from other daemons about successful or failed connection
attempts.
If no such file is specified, then it only listens to the socket path
specified by
-.Ar sockspath
+.Ar sockpath
or if that is not specified to
-.Pa /var/run/blacklistd.sock .
+.Pa /var/run/blocklistd.sock .
Each notification contains an (action, port, protocol, address, owner) tuple
that identifies the remote connection and the action.
-This tuple is consulted against entries in
-.Ar configfile
-with syntax specified in
+This tuple is consulted against entries from the
+.Ar configfile ,
+with the syntax specified in
.Xr blacklistd.conf 5 .
If an entry is matched, a state entry is created for that tuple.
Each entry contains a number of tries limit and a duration.
.Pp
+If
+.Ar configfile
+is a directory, or a directory exists with the same name as
+.Ar configfile
+with
+.Qq .d
+appended to it, each file in the directory will be read as configuration file.
+If
+.Ar configfile
+exists as a file it will be processed before the contents of the
+.Ar configfile Ns .d
+directory if that also exists.
+.Pp
The way
.Nm
does configuration entry matching is by having the client side pass the
@@ -152,7 +165,7 @@ The following options are available:
.It Fl C Ar controlprog
Use
.Ar controlprog
-to communicate with the packet filter, usually
+to communicate with the packet filter, instead of the default, which is
.Pa /usr/libexec/blacklistd-helper .
The following arguments are passed to the control program:
.Bl -tag -width protocol
@@ -161,7 +174,7 @@ The action to perform:
.Dv add ,
.Dv rem ,
or
-.Dv flush
+.Dv flush ;
to add, remove or flush a firewall rule.
.It name
The rule name.
@@ -183,13 +196,17 @@ identifier of the rule to be removed.
The add command is expected to return the rule identifier string to stdout.
.El
.It Fl c Ar configuration
-The name of the configuration file to read, usually
+The name of the configuration file to read.
+The default when
+.Fl c
+is not given is
.Pa /etc/blacklistd.conf .
.It Fl D Ar dbfile
The Berkeley DB file where
.Nm
-stores its state, usually
-.Pa /var/db/blacklistd.db .
+stores its state.
+It defaults to
+.Pa /var/db/blocklistd.db .
.It Fl d
Normally,
.Nm
@@ -203,7 +220,7 @@ are deleted by invoking the control script as:
.Bd -literal -offset indent
control flush <rulename>
.Ed
-.It Fl P Ar sockspathsfile
+.It Fl P Ar sockpathsfile
A file containing a list of pathnames, one per line that
.Nm
will create sockets to listen to.
@@ -261,16 +278,23 @@ to decrease the internal debugging level by 1.
Shell script invoked to interface with the packet filter.
.It Pa /etc/blacklistd.conf
Configuration file.
-.It Pa /var/db/blacklistd.db
+.It Pa /var/db/blocklistd.db
Database of current connection entries.
-.It Pa /var/run/blacklistd.sock
+.It Pa /var/run/blocklistd.sock
Socket to receive connection notifications.
.El
.Sh SEE ALSO
.Xr blacklistd.conf 5 ,
.Xr blacklistctl 8 ,
+.Xr ipf 8 ,
+.Xr ipfw 8 ,
.Xr pfctl 8 ,
.Xr syslogd 8
+.Sh NOTES
+The
+.Nm
+daemon has been renamed to
+.Xr blocklistd 8 .
.Sh HISTORY
.Nm
first appeared in
diff --git a/contrib/blocklist/bin/blacklistd.c b/contrib/blocklist/bin/blacklistd.c
index 714abcbcaf0e..ded3075ed707 100644
--- a/contrib/blocklist/bin/blacklistd.c
+++ b/contrib/blocklist/bin/blacklistd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: blacklistd.c,v 1.38 2019/02/27 02:20:18 christos Exp $ */
+/* $NetBSD: blocklistd.c,v 1.10 2025/03/26 17:09:35 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -31,8 +31,11 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+
+#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
-__RCSID("$NetBSD: blacklistd.c,v 1.38 2019/02/27 02:20:18 christos Exp $");
+#endif
+__RCSID("$NetBSD: blocklistd.c,v 1.10 2025/03/26 17:09:35 christos Exp $");
#include <sys/types.h>
#include <sys/socket.h>
@@ -64,8 +67,8 @@ __RCSID("$NetBSD: blacklistd.c,v 1.38 2019/02/27 02:20:18 christos Exp $");
#include <ifaddrs.h>
#include <netinet/in.h>
-#include "bl.h"
-#include "internal.h"
+#include "old_bl.h"
+#include "old_internal.h"
#include "conf.h"
#include "run.h"
#include "state.h"
@@ -175,6 +178,8 @@ process(bl_t bl)
struct dbinfo dbi;
struct timespec ts;
+ memset(&dbi, 0, sizeof(dbi));
+ memset(&c, 0, sizeof(c));
if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
(*lfun)(LOG_ERR, "clock_gettime failed (%m)");
return;
@@ -188,10 +193,11 @@ process(bl_t bl)
if (getremoteaddress(bi, &rss, &rsl) == -1)
goto out;
- if (debug) {
+ if (debug || bi->bi_msg[0]) {
sockaddr_snprintf(rbuf, sizeof(rbuf), "%a:%p", (void *)&rss);
- (*lfun)(LOG_DEBUG, "processing type=%d fd=%d remote=%s msg=%s"
- " uid=%lu gid=%lu", bi->bi_type, bi->bi_fd, rbuf,
+ (*lfun)(bi->bi_msg[0] ? LOG_INFO : LOG_DEBUG,
+ "processing type=%d fd=%d remote=%s msg=%s uid=%lu gid=%lu",
+ bi->bi_type, bi->bi_fd, rbuf,
bi->bi_msg, (unsigned long)bi->bi_uid,
(unsigned long)bi->bi_gid);
}
@@ -334,7 +340,7 @@ static void
addfd(struct pollfd **pfdp, bl_t **blp, size_t *nfd, size_t *maxfd,
const char *path)
{
- bl_t bl = bl_create(true, path, vflag ? vdlog : vsyslog);
+ bl_t bl = bl_create(true, path, vflag ? vdlog : vsyslog_r);
if (bl == NULL || !bl_isconnected(bl))
exit(EXIT_FAILURE);
if (*nfd >= *maxfd) {
@@ -395,15 +401,25 @@ rules_flush(void)
static void
rules_restore(void)
{
+ DB *db;
struct conf c;
struct dbinfo dbi;
unsigned int f;
- for (f = 1; state_iterate(state, &c, &dbi, f) == 1; f = 0) {
+ db = state_open(dbfile, O_RDONLY, 0);
+ if (db == NULL) {
+ (*lfun)(LOG_ERR, "Can't open `%s' to restore state (%m)",
+ dbfile);
+ return;
+ }
+ for (f = 1; state_iterate(db, &c, &dbi, f) == 1; f = 0) {
if (dbi.id[0] == '\0')
continue;
(void)run_change("add", &c, dbi.id, sizeof(dbi.id));
+ state_put(state, &c, &dbi);
}
+ state_close(db);
+ state_sync(state);
}
int
diff --git a/contrib/blocklist/bin/blacklistd.conf.5 b/contrib/blocklist/bin/blacklistd.conf.5
index 70036441eb4b..e775d30e7e8e 100644
--- a/contrib/blocklist/bin/blacklistd.conf.5
+++ b/contrib/blocklist/bin/blacklistd.conf.5
@@ -1,6 +1,6 @@
-.\" $NetBSD: blacklistd.conf.5,v 1.9 2019/11/06 20:33:30 para Exp $
+.\" $NetBSD: blocklistd.conf.5,v 1.7 2025/02/11 17:47:05 christos Exp $
.\"
-.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
+.\" Copyright (c) 2015, 2025 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd May 18, 2020
+.Dd February 5, 2025
.Dt BLACKLISTD.CONF 5
.Os
.Sh NAME
@@ -48,34 +48,34 @@ Comments are denoted by a
at the beginning of a line.
.Pp
There are two kinds of configuration lines,
-.Va local
+.Va [local]
and
-.Va remote .
+.Va [remote] .
By default, configuration lines are
-.Va local ,
+.Va [local] ,
i.e. the address specified refers to the addresses on the local machine.
To switch to between
-.Va local
+.Va [local]
and
-.Va remote
+.Va [remote]
configuration lines you can specify the stanzas:
.Dq [local]
and
.Dq [remote] .
.Pp
On
-.Va local
+.Va [local]
and
-.Va remote
+.Va [remote]
lines
.Dq *
means use the default, or wildcard match.
In addition, for
-.Va remote
+.Va [remote]
lines
.Dq =
means use the values from the matched
-.Va local
+.Va [local]
configuration line.
.Pp
The first four fields,
@@ -85,9 +85,9 @@ The first four fields,
and
.Va owner
are used to match the
-.Va local
+.Va [local]
or
-.Va remote
+.Va [remote]
addresses, whereas the last 3 fields
.Va name ,
.Va nfail ,
@@ -110,8 +110,8 @@ The
can be an IPv4 address in numeric format, an IPv6 address
in numeric format and enclosed by square brackets, or an interface name.
Mask modifiers are not allowed on interfaces because interfaces
-can have multiple addresses in different protocols where the mask has a different
-size.
+can have multiple addresses in different protocols where the mask has a
+different size.
.Pp
The
.Dv mask
@@ -143,8 +143,8 @@ The
field, is the name of the packet filter rule to be used.
If the
.Va name
-starts with a
-.Dq - ,
+starts with a hyphen
+.Pq Dq - ,
then the default rulename is prepended to the given name.
If the
.Dv name
@@ -160,13 +160,13 @@ field contains the number of failed attempts before access is blocked,
defaulting to
.Dq *
meaning never, and the last field
-.Va disable
+.Va duration
specifies the amount of time since the last access that the blocking
rule should be active, defaulting to
.Dq *
meaning forever.
The default unit for
-.Va disable
+.Va duration
is seconds, but one can specify suffixes for different units, such as
.Dq m
for minutes
@@ -176,25 +176,31 @@ for hours and
for days.
.Pp
Matching is done first by checking the
-.Va local
+.Va [local]
rules individually, in the order of the most specific to the least specific.
-If a match is found, then the
-.Va remote
+If a match is found, then the matching
+.Va [remote]
rules are applied.
The
.Va name ,
.Va nfail ,
and
-.Va disable
+.Va duration
fields can be altered by the
-.Va remote
+.Va [remote]
rule that matched.
.Pp
The
-.Va remote
+.Va [remote]
rules can be used for allowing specific addresses, changing the mask
-size, the rule that the packet filter uses, the number of failed attempts,
-or the block duration.
+size (via
+.Va name ) ,
+the rule that the packet filter uses (also via
+.Va name ) ,
+the number of failed attempts (via
+.Va nfail ) ,
+or the duration to block (via
+.Va duration ) .
.Sh FILES
.Bl -tag -width /etc/blacklistd.conf -compact
.It Pa /etc/blacklistd.conf
@@ -209,13 +215,20 @@ bnx0:ssh * * * * 3 6h
[remote]
# Never block 1.2.3.4
1.2.3.4:ssh * * * * * *
-# For addresses coming from 8.8.0.0/16 block whole /24 networks instead of
+# Never block the example IPv6 subnet either
+[2001:db8::]/32:ssh * * * * * *
+# For addresses coming from 8.8.0.0/16 block whole /24 networks instead
# individual hosts, but keep the rest of the blocking parameters the same.
8.8.0.0/16:ssh * * * /24 = =
.Ed
.Sh SEE ALSO
.Xr blacklistctl 8 ,
.Xr blacklistd 8
+.Sh NOTES
+The
+.Nm
+file has been renamed to
+.Xr blocklistd.conf 8 .
.Sh HISTORY
.Nm
first appeared in
diff --git a/contrib/blocklist/bin/blocklistctl.8 b/contrib/blocklist/bin/blocklistctl.8
new file mode 100644
index 000000000000..a98c16374f19
--- /dev/null
+++ b/contrib/blocklist/bin/blocklistctl.8
@@ -0,0 +1,131 @@
+.\" $NetBSD: blocklistctl.8,v 1.4 2025/02/07 01:35:38 kre Exp $
+.\"
+.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Christos Zoulas.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd January 27, 2025
+.Dt BLOCKLISTCTL 8
+.Os
+.Sh NAME
+.Nm blocklistctl
+.Nd display and change the state of the blocklistd database
+.Sh SYNOPSIS
+.Nm
+.Cm dump
+.Op Fl abdnrw
+.Op Fl D Ar dbname
+.Sh DESCRIPTION
+.Nm
+is a program used to display and change the state of the
+.Xr blocklistd 8
+database.
+The following sub-commands are supported:
+.Ss dump
+.Pp
+The following options are available for the
+.Cm dump
+sub-command:
+.Bl -tag -width indent
+.It Fl a
+Show all database entries, by default it shows only the active ones.
+Inactive entries will be shown with a last-access (or, with
+.Fl r ,
+the remaining) time of
+.Ql never .
+.It Fl b
+Show only the blocked entries.
+.It Fl D Ar dbname
+Specify the location of the
+.Ic blocklistd
+database file to use.
+The default is
+.Pa /var/db/blocklistd.db .
+.It Fl d
+Increase debugging level.
+.It Fl n
+Don't display a header.
+.It Fl r
+Show the remaining blocked time instead of the last activity time.
+.It Fl w
+Normally the width of addresses is good for IPv4, the
+.Fl w
+flag, makes the display wide enough for IPv6 addresses.
+.El
+.Pp
+The output of the
+.Cm dump
+sub-command consists of a header (unless
+.Fl n
+was given) and one line for each record in the database, where each line
+has the following columns:
+.Bl -tag -width indent
+.It Ql address/ma:port
+The remote address, mask, and local port number of the client connection
+associated with the database entry.
+.It Ql id
+column will show the identifier for the packet filter rule associated
+with the database entry, though this may only be the word
+.Ql OK
+for packet filters which do not creat a unique identifier for each rule.
+.It Ql nfail
+The number of
+.Em failures
+reported for the client on the noted port, as well as the number of
+failures allowed before blocking (or, with
+.Fl a ,
+an asterisk
+.Aq * )
+.It So last access Sc | So remaining time Sc
+The last time a the client was reported as attempting access, or, with
+.Fl r ,
+the time remaining before the rule blocking the client will be removed.
+.El
+.Sh SEE ALSO
+.Xr blocklistd 8
+.Sh NOTES
+Sometimes the reported number of failed attempts can exceed the number
+of attempts that
+.Xr blocklistd 8
+is configured to block.
+This can happen either because the rule has been removed manually, or
+because there were more attempts in flight while the rule block was being
+added.
+This condition is normal; in that case
+.Xr blocklistd 8
+will first attempt to remove the existing rule, and then it will re-add
+it to make sure that there is only one rule active.
+.Sh HISTORY
+.Nm
+first appeared in
+.Nx 7 .
+.Fx
+support for
+.Nm
+was implemented in
+.Fx 11 .
+.Sh AUTHORS
+.An Christos Zoulas
diff --git a/contrib/blocklist/bin/blocklistctl.c b/contrib/blocklist/bin/blocklistctl.c
new file mode 100644
index 000000000000..8c75e0430c61
--- /dev/null
+++ b/contrib/blocklist/bin/blocklistctl.c
@@ -0,0 +1,170 @@
+/* $NetBSD: blocklistctl.c,v 1.4 2025/02/11 17:48:30 christos Exp $ */
+
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+__RCSID("$NetBSD: blocklistctl.c,v 1.4 2025/02/11 17:48:30 christos Exp $");
+
+#include <stdio.h>
+#include <time.h>
+#ifdef HAVE_LIBUTIL_H
+#include <libutil.h>
+#endif
+#ifdef HAVE_UTIL_H
+#include <util.h>
+#endif
+#include <fcntl.h>
+#include <string.h>
+#include <syslog.h>
+#include <err.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/socket.h>
+
+#include "conf.h"
+#include "state.h"
+#include "internal.h"
+#include "support.h"
+
+static __dead void
+usage(int c)
+{
+ if (c == 0)
+ warnx("Missing/unknown command");
+ else if (c != '?')
+ warnx("Unknown option `%c'", (char)c);
+ fprintf(stderr,
+ "Usage: %s dump [-abdnrw] [-D dbname]\n", getprogname());
+ exit(EXIT_FAILURE);
+}
+
+static const char *
+star(char *buf, size_t len, int val)
+{
+ if (val == -1)
+ return "*";
+ snprintf(buf, len, "%d", val);
+ return buf;
+}
+
+int
+main(int argc, char *argv[])
+{
+ const char *dbname = _PATH_BLSTATE;
+ DB *db;
+ struct conf c;
+ struct dbinfo dbi;
+ unsigned int i;
+ struct timespec ts;
+ int all, blocked, remain, wide, noheader;
+ int o;
+
+ noheader = wide = blocked = all = remain = 0;
+ lfun = dlog;
+
+ if (argc == 1 || strcmp(argv[1], "dump") != 0)
+ usage(0);
+
+ argc--;
+ argv++;
+
+ while ((o = getopt(argc, argv, "abD:dnrw")) != -1)
+ switch (o) {
+ case 'a':
+ all = 1;
+ blocked = 0;
+ break;
+ case 'b':
+ blocked = 1;
+ break;
+ case 'D':
+ dbname = optarg;
+ break;
+ case 'd':
+ debug++;
+ break;
+ case 'n':
+ noheader = 1;
+ break;
+ case 'r':
+ remain = 1;
+ break;
+ case 'w':
+ wide = 1;
+ break;
+ default:
+ usage(o);
+ }
+
+ db = state_open(dbname, O_RDONLY, 0);
+ if (db == NULL)
+ err(EXIT_FAILURE, "Can't open `%s'", dbname);
+
+ clock_gettime(CLOCK_REALTIME, &ts);
+ wide = wide ? 8 * 4 + 7 : 4 * 3 + 3;
+ if (!noheader)
+ printf("%*.*s/ma:port\tid\tnfail\t%s\n", wide, wide,
+ "address", remain ? "remaining time" : "last access");
+ for (i = 1; state_iterate(db, &c, &dbi, i) != 0; i = 0) {
+ char buf[BUFSIZ];
+ char mbuf[64], pbuf[64];
+ if (!all) {
+ if (blocked) {
+ if (c.c_nfail == -1 || dbi.count < c.c_nfail)
+ continue;
+ } else {
+ if (dbi.count >= c.c_nfail)
+ continue;
+ }
+ }
+ sockaddr_snprintf(buf, sizeof(buf), "%a", (void *)&c.c_ss);
+ printf("%*.*s/%s:%s\t", wide, wide, buf,
+ star(mbuf, sizeof(mbuf), c.c_lmask),
+ star(pbuf, sizeof(pbuf), c.c_port));
+ if (c.c_duration == -1) {
+ strlcpy(buf, "never", sizeof(buf));
+ } else {
+ if (remain)
+ fmtydhms(buf, sizeof(buf),
+ c.c_duration - (ts.tv_sec - dbi.last));
+ else
+ fmttime(buf, sizeof(buf), dbi.last);
+ }
+ printf("%s\t%d/%s\t%-s\n", dbi.id, dbi.count,
+ star(mbuf, sizeof(mbuf), c.c_nfail), buf);
+ }
+ state_close(db);
+ return EXIT_SUCCESS;
+}
diff --git a/contrib/blocklist/bin/blocklistd.8 b/contrib/blocklist/bin/blocklistd.8
new file mode 100644
index 000000000000..e0b9fb482cbd
--- /dev/null
+++ b/contrib/blocklist/bin/blocklistd.8
@@ -0,0 +1,303 @@
+.\" $NetBSD: blocklistd.8,v 1.8 2025/02/25 22:13:34 christos Exp $
+.\"
+.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Christos Zoulas.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd February 25, 2025
+.Dt BLOCKLISTD 8
+.Os
+.Sh NAME
+.Nm blocklistd
+.Nd block and release ports on demand to avoid DoS abuse
+.Sh SYNOPSIS
+.Nm
+.Op Fl dfrv
+.Op Fl C Ar controlprog
+.Op Fl c Ar configfile
+.Op Fl D Ar dbfile
+.Op Fl P Ar sockpathsfile
+.Op Fl R Ar rulename
+.Op Fl s Ar sockpath
+.Op Fl t Ar timeout
+.Sh DESCRIPTION
+.Nm
+is a daemon similar to
+.Xr syslogd 8
+that listens to sockets at paths specified in the
+.Ar sockpathsfile
+for notifications from other daemons about successful or failed connection
+attempts.
+If no such file is specified, then it only listens to the socket path
+specified by
+.Ar sockpath
+or if that is not specified to
+.Pa /var/run/blocklistd.sock .
+Each notification contains an (action, port, protocol, address, owner) tuple
+that identifies the remote connection and the action.
+This tuple is consulted against entries from the
+.Ar configfile ,
+with the syntax specified in
+.Xr blocklistd.conf 5 .
+If an entry is matched, a state entry is created for that tuple.
+Each entry contains a number of tries limit and a duration.
+.Pp
+If
+.Ar configfile
+is a directory, or a directory exists with the same name as
+.Ar configfile
+with
+.Qq .d
+appended to it, each file in the directory will be read as configuration file.
+If
+.Ar configfile
+exists as a file it will be processed before the contents of the
+.Ar configfile Ns .d
+directory if that also exists.
+.Pp
+The way
+.Nm
+does configuration entry matching is by having the client side pass the
+file descriptor associated with the connection the client wants to blocklist
+as well as passing socket credentials.
+.Pp
+The file descriptor is used to retrieve information (address and port)
+about the remote side with
+.Xr getpeername 2
+and the local side with
+.Xr getsockname 2 .
+.Pp
+By examining the port of the local side,
+.Nm
+can determine if the client program
+.Dq owns
+the port.
+By examining the optional address portion on the local side, it can match
+interfaces.
+By examining the remote address, it can match specific allow or deny rules.
+.Pp
+Finally
+.Nm
+can examine the socket credentials to match the user in the configuration file.
+.Pp
+While this works well for TCP sockets, it cannot be relied on for unbound
+UDP sockets.
+It is also less meaningful when it comes to connections using non-privileged
+ports.
+On the other hand, if we receive a request that has a local endpoint indicating
+a UDP privileged port, we can presume that the client was privileged to be
+able to acquire that port.
+.Pp
+Once an entry is matched
+.Nm
+can perform various actions.
+If the action is
+.Dq add
+and the number of tries limit is reached, then a
+control script
+.Ar controlprog
+is invoked with arguments:
+.Bd -literal -offset indent
+control add <rulename> <proto> <address> <mask> <port>
+.Ed
+.Pp
+and should invoke a packet filter command to block the connection
+specified by the arguments.
+The
+.Ar rulename
+argument can be set from the command line (default
+.Dv blocklistd ) .
+The script could print a numerical id to stdout as a handle for
+the rule that can be used later to remove that connection, but
+that is not required as all information to remove the rule is
+kept.
+.Pp
+If the action is
+.Dq rem
+Then the same control script is invoked as:
+.Bd -literal -offset indent
+control rem <rulename> <proto> <address> <mask> <port> <id>
+.Ed
+.Pp
+where
+.Ar id
+is the number returned from the
+.Dq add
+action.
+.Pp
+.Nm
+maintains a database of known connections in
+.Ar dbfile .
+On startup it reads entries from that file, and updates its internal state.
+.Pp
+.Nm
+checks the list of active entries every
+.Ar timeout
+seconds (default
+.Dv 15 )
+and removes entries and block rules using the control program as necessary.
+.Pp
+The following options are available:
+.Bl -tag -width indent
+.It Fl C Ar controlprog
+Use
+.Ar controlprog
+to communicate with the packet filter, instead of the default, which is
+.Pa /usr/libexec/blocklistd-helper .
+The following arguments are passed to the control program:
+.Bl -tag -width protocol
+.It action
+The action to perform:
+.Dv add ,
+.Dv rem ,
+or
+.Dv flush ;
+to add, remove or flush a firewall rule.
+.It name
+The rule name.
+.It protocol
+The optional protocol name (can be empty):
+.Dv tcp ,
+.Dv tcp6 ,
+.Dv udp ,
+.Dv udp6 .
+.It address
+The IPv4 or IPv6 numeric address to be blocked or released.
+.It mask
+The numeric mask to be applied to the blocked or released address
+.It port
+The optional numeric port to be blocked (can be empty).
+.It id
+For packet filters that support removal of rules by rule identifier, the
+identifier of the rule to be removed.
+The add command is expected to return the rule identifier string to stdout.
+.El
+.It Fl c Ar configuration
+The name of the configuration file to read.
+The default when
+.Fl c
+is not given is
+.Pa /etc/blocklistd.conf .
+.It Fl D Ar dbfile
+The Berkeley DB file where
+.Nm
+stores its state.
+It defaults to
+.Pa /var/db/blocklistd.db .
+.It Fl d
+Normally,
+.Nm
+disassociates itself from the terminal unless the
+.Fl d
+flag is specified, in which case it stays in the foreground.
+.It Fl f
+Truncate the state database and flush all the rules named
+.Ar rulename
+are deleted by invoking the control script as:
+.Bd -literal -offset indent
+control flush <rulename>
+.Ed
+.It Fl P Ar sockpathsfile
+A file containing a list of pathnames, one per line that
+.Nm
+will create sockets to listen to.
+This is useful for chrooted environments.
+.It Fl R Ar rulename
+Specify the default rule name for the packet filter rules, usually
+.Dv blocklistd .
+.It Fl r
+Re-read the firewall rules from the internal database, then
+remove and re-add them.
+This helps for packet filters that do not retain state across reboots.
+.It Fl s Ar sockpath
+Add
+.Ar sockpath
+to the list of Unix sockets
+.Nm
+listens to.
+.It Fl t Ar timeout
+The interval in seconds
+.Nm
+polls the state file to update the rules.
+.It Fl v
+Cause
+.Nm
+to print
+diagnostic messages to
+.Dv stdout
+instead of
+.Xr syslogd 8 .
+.El
+.Sh SIGNAL HANDLING
+.Nm
+deals with the following signals:
+.Bl -tag -width "USR2"
+.It Dv HUP
+Receipt of this signal causes
+.Nm
+to re-read the configuration file.
+.It Dv INT , Dv TERM & Dv QUIT
+These signals tell
+.Nm
+to exit in an orderly fashion.
+.It Dv USR1
+This signal tells
+.Nm
+to increase the internal debugging level by 1.
+.It Dv USR2
+This signal tells
+.Nm
+to decrease the internal debugging level by 1.
+.El
+.Sh FILES
+.Bl -tag -width /usr/libexec/blocklistd-helper -compact
+.It Pa /usr/libexec/blocklistd-helper
+Shell script invoked to interface with the packet filter.
+.It Pa /etc/blocklistd.conf
+Configuration file.
+.It Pa /var/db/blocklistd.db
+Database of current connection entries.
+.It Pa /var/run/blocklistd.sock
+Socket to receive connection notifications.
+.El
+.Sh SEE ALSO
+.Xr blocklistd.conf 5 ,
+.Xr blocklistctl 8 ,
+.Xr ipf 8 ,
+.Xr ipfw 8 ,
+.Xr pfctl 8 ,
+.Xr syslogd 8
+.Sh HISTORY
+.Nm
+first appeared in
+.Nx 7 .
+.Fx
+support for
+.Nm
+was implemented in
+.Fx 11 .
+.Sh AUTHORS
+.An Christos Zoulas
diff --git a/contrib/blocklist/bin/blocklistd.c b/contrib/blocklist/bin/blocklistd.c
new file mode 100644
index 000000000000..03a1dbbf056c
--- /dev/null
+++ b/contrib/blocklist/bin/blocklistd.c
@@ -0,0 +1,592 @@
+/* $NetBSD: blocklistd.c,v 1.10 2025/03/26 17:09:35 christos Exp $ */
+
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+__RCSID("$NetBSD: blocklistd.c,v 1.10 2025/03/26 17:09:35 christos Exp $");
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/queue.h>
+
+#ifdef HAVE_LIBUTIL_H
+#include <libutil.h>
+#endif
+#ifdef HAVE_UTIL_H
+#include <util.h>
+#endif
+#include <string.h>
+#include <signal.h>
+#include <netdb.h>
+#include <stdio.h>
+#include <stdbool.h>
+#include <string.h>
+#include <inttypes.h>
+#include <syslog.h>
+#include <ctype.h>
+#include <limits.h>
+#include <errno.h>
+#include <poll.h>
+#include <fcntl.h>
+#include <err.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
+#include <ifaddrs.h>
+#include <netinet/in.h>
+
+#include "bl.h"
+#include "internal.h"
+#include "conf.h"
+#include "run.h"
+#include "state.h"
+#include "support.h"
+
+static const char *configfile = _PATH_BLCONF;
+static DB *state;
+static const char *dbfile = _PATH_BLSTATE;
+static sig_atomic_t readconf;
+static sig_atomic_t done;
+static int vflag;
+
+static void
+sigusr1(int n __unused)
+{
+ debug++;
+}
+
+static void
+sigusr2(int n __unused)
+{
+ debug--;
+}
+
+static void
+sighup(int n __unused)
+{
+ readconf++;
+}
+
+static void
+sigdone(int n __unused)
+{
+ done++;
+}
+
+static __dead void
+usage(int c)
+{
+ if (c != '?')
+ warnx("Unknown option `%c'", (char)c);
+ fprintf(stderr, "Usage: %s [-vdfr] [-c <config>] [-R <rulename>] "
+ "[-P <sockpathsfile>] [-C <controlprog>] [-D <dbfile>] "
+ "[-s <sockpath>] [-t <timeout>]\n", getprogname());
+ exit(EXIT_FAILURE);
+}
+
+static int
+getremoteaddress(bl_info_t *bi, struct sockaddr_storage *rss, socklen_t *rsl)
+{
+ *rsl = sizeof(*rss);
+ memset(rss, 0, *rsl);
+
+ if (getpeername(bi->bi_fd, (void *)rss, rsl) != -1)
+ return 0;
+
+ if (errno != ENOTCONN) {
+ (*lfun)(LOG_ERR, "getpeername failed (%m)");
+ return -1;
+ }
+
+ if (bi->bi_slen == 0) {
+ (*lfun)(LOG_ERR, "unconnected socket with no peer in message");
+ return -1;
+ }
+
+ switch (bi->bi_ss.ss_family) {
+ case AF_INET:
+ *rsl = sizeof(struct sockaddr_in);
+ break;
+ case AF_INET6:
+ *rsl = sizeof(struct sockaddr_in6);
+ break;
+ default:
+ (*lfun)(LOG_ERR, "bad client passed socket family %u",
+ (unsigned)bi->bi_ss.ss_family);
+ return -1;
+ }
+
+ if (*rsl != bi->bi_slen) {
+ (*lfun)(LOG_ERR, "bad client passed socket length %u != %u",
+ (unsigned)*rsl, (unsigned)bi->bi_slen);
+ return -1;
+ }
+
+ memcpy(rss, &bi->bi_ss, *rsl);
+
+#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
+ if (*rsl != rss->ss_len) {
+ (*lfun)(LOG_ERR,
+ "bad client passed socket internal length %u != %u",
+ (unsigned)*rsl, (unsigned)rss->ss_len);
+ return -1;
+ }
+#endif
+ return 0;
+}
+
+static void
+process(bl_t bl)
+{
+ struct sockaddr_storage rss;
+ socklen_t rsl;
+ char rbuf[BUFSIZ];
+ bl_info_t *bi;
+ struct conf c;
+ struct dbinfo dbi;
+ struct timespec ts;
+
+ memset(&dbi, 0, sizeof(dbi));
+ memset(&c, 0, sizeof(c));
+ if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
+ (*lfun)(LOG_ERR, "clock_gettime failed (%m)");
+ return;
+ }
+
+ if ((bi = bl_recv(bl)) == NULL) {
+ (*lfun)(LOG_ERR, "no message (%m)");
+ return;
+ }
+
+ if (getremoteaddress(bi, &rss, &rsl) == -1)
+ goto out;
+
+ if (debug || bi->bi_msg[0]) {
+ sockaddr_snprintf(rbuf, sizeof(rbuf), "%a:%p", (void *)&rss);
+ (*lfun)(bi->bi_msg[0] ? LOG_INFO : LOG_DEBUG,
+ "processing type=%d fd=%d remote=%s msg=%s uid=%lu gid=%lu",
+ bi->bi_type, bi->bi_fd, rbuf,
+ bi->bi_msg, (unsigned long)bi->bi_uid,
+ (unsigned long)bi->bi_gid);
+ }
+
+ if (conf_find(bi->bi_fd, bi->bi_uid, &rss, &c) == NULL) {
+ (*lfun)(LOG_DEBUG, "no rule matched");
+ goto out;
+ }
+
+
+ if (state_get(state, &c, &dbi) == -1)
+ goto out;
+
+ if (debug) {
+ char b1[128], b2[128];
+ (*lfun)(LOG_DEBUG, "%s: initial db state for %s: count=%d/%d "
+ "last=%s now=%s", __func__, rbuf, dbi.count, c.c_nfail,
+ fmttime(b1, sizeof(b1), dbi.last),
+ fmttime(b2, sizeof(b2), ts.tv_sec));
+ }
+
+ switch (bi->bi_type) {
+ case BL_ABUSE:
+ /*
+ * If the application has signaled abusive behavior,
+ * set the number of fails to be one less than the
+ * configured limit. Fallthrough to the normal BL_ADD
+ * processing, which will increment the failure count
+ * to the threshhold, and block the abusive address.
+ */
+ if (c.c_nfail != -1)
+ dbi.count = c.c_nfail - 1;
+ /*FALLTHROUGH*/
+ case BL_ADD:
+ dbi.count++;
+ dbi.last = ts.tv_sec;
+ if (c.c_nfail != -1 && dbi.count >= c.c_nfail) {
+ /*
+ * No point in re-adding the rule.
+ * It might exist already due to latency in processing
+ * and removing the rule is the wrong thing to do as
+ * it allows a window to attack again.
+ */
+ if (dbi.id[0] == '\0') {
+ int res = run_change("add", &c,
+ dbi.id, sizeof(dbi.id));
+ if (res == -1)
+ goto out;
+ }
+ sockaddr_snprintf(rbuf, sizeof(rbuf), "%a",
+ (void *)&rss);
+ (*lfun)(LOG_INFO,
+ "blocked %s/%d:%d for %d seconds",
+ rbuf, c.c_lmask, c.c_port, c.c_duration);
+ }
+ break;
+ case BL_DELETE:
+ if (dbi.last == 0)
+ goto out;
+ dbi.count = 0;
+ dbi.last = 0;
+ break;
+ case BL_BADUSER:
+ /* ignore for now */
+ break;
+ default:
+ (*lfun)(LOG_ERR, "unknown message %d", bi->bi_type);
+ }
+ state_put(state, &c, &dbi);
+
+out:
+ close(bi->bi_fd);
+
+ if (debug) {
+ char b1[128], b2[128];
+ (*lfun)(LOG_DEBUG, "%s: final db state for %s: count=%d/%d "
+ "last=%s now=%s", __func__, rbuf, dbi.count, c.c_nfail,
+ fmttime(b1, sizeof(b1), dbi.last),
+ fmttime(b2, sizeof(b2), ts.tv_sec));
+ }
+}
+
+static void
+update_interfaces(void)
+{
+ struct ifaddrs *oifas, *nifas;
+
+ if (getifaddrs(&nifas) == -1)
+ return;
+
+ oifas = ifas;
+ ifas = nifas;
+
+ if (oifas)
+ freeifaddrs(oifas);
+}
+
+static void
+update(void)
+{
+ struct timespec ts;
+ struct conf c;
+ struct dbinfo dbi;
+ unsigned int f, n;
+ char buf[128];
+ void *ss = &c.c_ss;
+
+ if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
+ (*lfun)(LOG_ERR, "clock_gettime failed (%m)");
+ return;
+ }
+
+again:
+ for (n = 0, f = 1; state_iterate(state, &c, &dbi, f) == 1;
+ f = 0, n++)
+ {
+ time_t when = c.c_duration + dbi.last;
+ if (debug > 1) {
+ char b1[64], b2[64];
+ sockaddr_snprintf(buf, sizeof(buf), "%a:%p", ss);
+ (*lfun)(LOG_DEBUG, "%s:[%u] %s count=%d duration=%d "
+ "last=%s " "now=%s", __func__, n, buf, dbi.count,
+ c.c_duration, fmttime(b1, sizeof(b1), dbi.last),
+ fmttime(b2, sizeof(b2), ts.tv_sec));
+ }
+ if (c.c_duration == -1 || when >= ts.tv_sec)
+ continue;
+ if (dbi.id[0]) {
+ run_change("rem", &c, dbi.id, 0);
+ sockaddr_snprintf(buf, sizeof(buf), "%a", ss);
+ (*lfun)(LOG_INFO, "released %s/%d:%d after %d seconds",
+ buf, c.c_lmask, c.c_port, c.c_duration);
+ }
+ state_del(state, &c);
+ goto again;
+ }
+}
+
+static void
+addfd(struct pollfd **pfdp, bl_t **blp, size_t *nfd, size_t *maxfd,
+ const char *path)
+{
+ bl_t bl = bl_create(true, path, vflag ? vdlog : vsyslog_r);
+ if (bl == NULL || !bl_isconnected(bl))
+ exit(EXIT_FAILURE);
+ if (*nfd >= *maxfd) {
+ *maxfd += 10;
+ *blp = realloc(*blp, sizeof(**blp) * *maxfd);
+ if (*blp == NULL)
+ err(EXIT_FAILURE, "malloc");
+ *pfdp = realloc(*pfdp, sizeof(**pfdp) * *maxfd);
+ if (*pfdp == NULL)
+ err(EXIT_FAILURE, "malloc");
+ }
+
+ (*pfdp)[*nfd].fd = bl_getfd(bl);
+ (*pfdp)[*nfd].events = POLLIN;
+ (*blp)[*nfd] = bl;
+ *nfd += 1;
+}
+
+static void
+uniqueadd(struct conf ***listp, size_t *nlist, size_t *mlist, struct conf *c)
+{
+ struct conf **list = *listp;
+
+ if (c->c_name[0] == '\0')
+ return;
+ for (size_t i = 0; i < *nlist; i++) {
+ if (strcmp(list[i]->c_name, c->c_name) == 0)
+ return;
+ }
+ if (*nlist == *mlist) {
+ *mlist += 10;
+ void *p = realloc(*listp, *mlist * sizeof(*list));
+ if (p == NULL)
+ err(EXIT_FAILURE, "Can't allocate for rule list");
+ list = *listp = p;
+ }
+ list[(*nlist)++] = c;
+}
+
+static void
+rules_flush(void)
+{
+ struct conf **list;
+ size_t nlist, mlist;
+
+ list = NULL;
+ mlist = nlist = 0;
+ for (size_t i = 0; i < rconf.cs_n; i++)
+ uniqueadd(&list, &nlist, &mlist, &rconf.cs_c[i]);
+ for (size_t i = 0; i < lconf.cs_n; i++)
+ uniqueadd(&list, &nlist, &mlist, &lconf.cs_c[i]);
+
+ for (size_t i = 0; i < nlist; i++)
+ run_flush(list[i]);
+ free(list);
+}
+
+static void
+rules_restore(void)
+{
+ DB *db;
+ struct conf c;
+ struct dbinfo dbi;
+ unsigned int f;
+
+ db = state_open(dbfile, O_RDONLY, 0);
+ if (db == NULL) {
+ (*lfun)(LOG_ERR, "Can't open `%s' to restore state (%m)",
+ dbfile);
+ return;
+ }
+ for (f = 1; state_iterate(db, &c, &dbi, f) == 1; f = 0) {
+ if (dbi.id[0] == '\0')
+ continue;
+ (void)run_change("add", &c, dbi.id, sizeof(dbi.id));
+ state_put(state, &c, &dbi);
+ }
+ state_close(db);
+ state_sync(state);
+}
+
+int
+main(int argc, char *argv[])
+{
+ int c, tout, flags, flush, restore, ret;
+ const char *spath, **blsock;
+ size_t nblsock, maxblsock;
+
+ setprogname(argv[0]);
+
+ spath = NULL;
+ blsock = NULL;
+ maxblsock = nblsock = 0;
+ flush = 0;
+ restore = 0;
+ tout = 0;
+ flags = O_RDWR|O_EXCL|O_CLOEXEC;
+ while ((c = getopt(argc, argv, "C:c:D:dfP:rR:s:t:v")) != -1) {
+ switch (c) {
+ case 'C':
+ controlprog = optarg;
+ break;
+ case 'c':
+ configfile = optarg;
+ break;
+ case 'D':
+ dbfile = optarg;
+ break;
+ case 'd':
+ debug++;
+ break;
+ case 'f':
+ flush++;
+ break;
+ case 'P':
+ spath = optarg;
+ break;
+ case 'R':
+ rulename = optarg;
+ break;
+ case 'r':
+ restore++;
+ break;
+ case 's':
+ if (nblsock >= maxblsock) {
+ maxblsock += 10;
+ void *p = realloc(blsock,
+ sizeof(*blsock) * maxblsock);
+ if (p == NULL)
+ err(EXIT_FAILURE,
+ "Can't allocate memory for %zu sockets",
+ maxblsock);
+ blsock = p;
+ }
+ blsock[nblsock++] = optarg;
+ break;
+ case 't':
+ tout = atoi(optarg) * 1000;
+ break;
+ case 'v':
+ vflag++;
+ break;
+ default:
+ usage(c);
+ }
+ }
+
+ argc -= optind;
+ if (argc)
+ usage('?');
+
+ signal(SIGHUP, sighup);
+ signal(SIGINT, sigdone);
+ signal(SIGQUIT, sigdone);
+ signal(SIGTERM, sigdone);
+ signal(SIGUSR1, sigusr1);
+ signal(SIGUSR2, sigusr2);
+
+ openlog(getprogname(), LOG_PID, LOG_DAEMON);
+
+ if (debug) {
+ lfun = dlog;
+ if (tout == 0)
+ tout = 5000;
+ } else {
+ if (tout == 0)
+ tout = 15000;
+ }
+
+ update_interfaces();
+ conf_parse(configfile);
+ if (flush) {
+ rules_flush();
+ if (!restore)
+ flags |= O_TRUNC;
+ }
+
+ struct pollfd *pfd = NULL;
+ bl_t *bl = NULL;
+ size_t nfd = 0;
+ size_t maxfd = 0;
+
+ for (size_t i = 0; i < nblsock; i++)
+ addfd(&pfd, &bl, &nfd, &maxfd, blsock[i]);
+ free(blsock);
+
+ if (spath) {
+ FILE *fp = fopen(spath, "r");
+ char *line;
+ if (fp == NULL)
+ err(EXIT_FAILURE, "Can't open `%s'", spath);
+ for (; (line = fparseln(fp, NULL, NULL, NULL, 0)) != NULL;
+ free(line))
+ addfd(&pfd, &bl, &nfd, &maxfd, line);
+ fclose(fp);
+ }
+ if (nfd == 0)
+ addfd(&pfd, &bl, &nfd, &maxfd, _PATH_BLSOCK);
+
+ state = state_open(dbfile, flags, 0600);
+ if (state == NULL)
+ state = state_open(dbfile, flags | O_CREAT, 0600);
+ if (state == NULL)
+ return EXIT_FAILURE;
+
+ if (restore) {
+ if (!flush)
+ rules_flush();
+ rules_restore();
+ }
+
+ if (!debug) {
+ if (daemon(0, 0) == -1)
+ err(EXIT_FAILURE, "daemon failed");
+ if (pidfile(NULL) == -1)
+ err(EXIT_FAILURE, "Can't create pidfile");
+ }
+
+ for (size_t t = 0; !done; t++) {
+ if (readconf) {
+ readconf = 0;
+ conf_parse(configfile);
+ }
+ ret = poll(pfd, (nfds_t)nfd, tout);
+ if (debug)
+ (*lfun)(LOG_DEBUG, "received %d from poll()", ret);
+ switch (ret) {
+ case -1:
+ if (errno == EINTR)
+ continue;
+ (*lfun)(LOG_ERR, "poll (%m)");
+ return EXIT_FAILURE;
+ case 0:
+ state_sync(state);
+ break;
+ default:
+ for (size_t i = 0; i < nfd; i++)
+ if (pfd[i].revents & POLLIN)
+ process(bl[i]);
+ }
+ if (t % 100 == 0)
+ state_sync(state);
+ if (t % 10000 == 0)
+ update_interfaces();
+ update();
+ }
+ state_close(state);
+ return 0;
+}
diff --git a/contrib/blocklist/bin/blocklistd.conf.5 b/contrib/blocklist/bin/blocklistd.conf.5
new file mode 100644
index 000000000000..3a7dbfc07f58
--- /dev/null
+++ b/contrib/blocklist/bin/blocklistd.conf.5
@@ -0,0 +1,237 @@
+.\" $NetBSD: blocklistd.conf.5,v 1.7 2025/02/11 17:47:05 christos Exp $
+.\"
+.\" Copyright (c) 2015, 2025 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Christos Zoulas.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd February 5, 2025
+.Dt BLOCKLISTD.CONF 5
+.Os
+.Sh NAME
+.Nm blocklistd.conf
+.Nd configuration file format for blocklistd
+.Sh DESCRIPTION
+The
+.Nm
+file contains configuration entries for
+.Xr blocklistd 8
+in a fashion similar to
+.Xr inetd.conf 5 .
+Only one entry per line is permitted.
+Every entry must have all fields populated.
+Each field can be separated by a tab or a space.
+Comments are denoted by a
+.Dq #
+at the beginning of a line.
+.Pp
+There are two kinds of configuration lines,
+.Va [local]
+and
+.Va [remote] .
+By default, configuration lines are
+.Va [local] ,
+i.e. the address specified refers to the addresses on the local machine.
+To switch to between
+.Va [local]
+and
+.Va [remote]
+configuration lines you can specify the stanzas:
+.Dq [local]
+and
+.Dq [remote] .
+.Pp
+On
+.Va [local]
+and
+.Va [remote]
+lines
+.Dq *
+means use the default, or wildcard match.
+In addition, for
+.Va [remote]
+lines
+.Dq =
+means use the values from the matched
+.Va [local]
+configuration line.
+.Pp
+The first four fields,
+.Va location ,
+.Va type ,
+.Va proto ,
+and
+.Va owner
+are used to match the
+.Va [local]
+or
+.Va [remote]
+addresses, whereas the last 3 fields
+.Va name ,
+.Va nfail ,
+and
+.Va disable
+are used to modify the filtering action.
+.Pp
+The first field denotes the
+.Va location
+as an address, mask, and port.
+The syntax for the
+.Va location
+is:
+.Bd -literal -offset indent
+ [<address>|<interface>][/<mask>][:<port>]
+.Ed
+.Pp
+The
+.Dv address
+can be an IPv4 address in numeric format, an IPv6 address
+in numeric format and enclosed by square brackets, or an interface name.
+Mask modifiers are not allowed on interfaces because interfaces
+can have multiple addresses in different protocols where the mask has a
+different size.
+.Pp
+The
+.Dv mask
+is always numeric, but the
+.Dv port
+can be either numeric or symbolic.
+.Pp
+The second field is the socket
+.Va type :
+.Dv stream ,
+.Dv dgram ,
+or numeric.
+The third field is the
+.Va protocol :
+.Dv tcp ,
+.Dv udp ,
+.Dv tcp6 ,
+.Dv udp6 ,
+or numeric.
+The fourth field is the effective user
+.Va ( owner )
+of the daemon process reporting the event,
+either as a username or a userid.
+.Pp
+The rest of the fields control the behavior of the filter.
+.Pp
+The
+.Va name
+field, is the name of the packet filter rule to be used.
+If the
+.Va name
+starts with a hyphen
+.Pq Dq - ,
+then the default rulename is prepended to the given name.
+If the
+.Dv name
+contains a
+.Dq / ,
+the remaining portion of the name is interpreted as the mask to be
+applied to the address specified in the rule, causing a single rule violation to
+block the entire subnet for the configured prefix.
+.Pp
+The
+.Va nfail
+field contains the number of failed attempts before access is blocked,
+defaulting to
+.Dq *
+meaning never, and the last field
+.Va duration
+specifies the amount of time since the last access that the blocking
+rule should be active, defaulting to
+.Dq *
+meaning forever.
+The default unit for
+.Va duration
+is seconds, but one can specify suffixes for different units, such as
+.Dq m
+for minutes
+.Dq h
+for hours and
+.Dq d
+for days.
+.Pp
+Matching is done first by checking the
+.Va [local]
+rules individually, in the order of the most specific to the least specific.
+If a match is found, then the matching
+.Va [remote]
+rules are applied.
+The
+.Va name ,
+.Va nfail ,
+and
+.Va duration
+fields can be altered by the
+.Va [remote]
+rule that matched.
+.Pp
+The
+.Va [remote]
+rules can be used for allowing specific addresses, changing the mask
+size (via
+.Va name ) ,
+the rule that the packet filter uses (also via
+.Va name ) ,
+the number of failed attempts (via
+.Va nfail ) ,
+or the duration to block (via
+.Va duration ) .
+.Sh FILES
+.Bl -tag -width /etc/blocklistd.conf -compact
+.It Pa /etc/blocklistd.conf
+Configuration file.
+.El
+.Sh EXAMPLES
+.Bd -literal -offset 8n
+# Block ssh, after 3 attempts for 6 hours on the bnx0 interface
+[local]
+# location type proto owner name nfail duration
+bnx0:ssh * * * * 3 6h
+[remote]
+# Never block 1.2.3.4
+1.2.3.4:ssh * * * * * *
+# Never block the example IPv6 subnet either
+[2001:db8::]/32:ssh * * * * * *
+# For addresses coming from 8.8.0.0/16 block whole /24 networks instead
+# individual hosts, but keep the rest of the blocking parameters the same.
+8.8.0.0/16:ssh * * * /24 = =
+.Ed
+.Sh SEE ALSO
+.Xr blocklistctl 8 ,
+.Xr blocklistd 8
+.Sh HISTORY
+.Nm
+first appeared in
+.Nx 7 .
+.Fx
+support for
+.Nm
+was implemented in
+.Fx 11 .
+.Sh AUTHORS
+.An Christos Zoulas
diff --git a/contrib/blocklist/bin/conf.c b/contrib/blocklist/bin/conf.c
index 8f7e75a56be1..f469e28235cd 100644
--- a/contrib/blocklist/bin/conf.c
+++ b/contrib/blocklist/bin/conf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: conf.c,v 1.24 2016/04/04 15:52:56 christos Exp $ */
+/* $NetBSD: conf.c,v 1.10 2025/02/11 17:48:30 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -32,8 +32,10 @@
#include "config.h"
#endif
+#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
-__RCSID("$NetBSD: conf.c,v 1.24 2016/04/04 15:52:56 christos Exp $");
+#endif
+__RCSID("$NetBSD: conf.c,v 1.10 2025/02/11 17:48:30 christos Exp $");
#include <stdio.h>
#ifdef HAVE_LIBUTIL_H
@@ -58,6 +60,7 @@ __RCSID("$NetBSD: conf.c,v 1.24 2016/04/04 15:52:56 christos Exp $");
#include <net/if.h>
#include <net/route.h>
#include <sys/socket.h>
+#include <dirent.h>
#include "bl.h"
#include "internal.h"
@@ -261,7 +264,7 @@ conf_gethostport(const char *f, size_t l, bool local, struct conf *c,
if (debug)
(*lfun)(LOG_DEBUG, "%s: host6 %s", __func__, p);
if (strcmp(p, "*") != 0) {
- if (inet_pton(AF_INET6, p, &sin6->sin6_addr) == -1)
+ if (inet_pton(AF_INET6, p, &sin6->sin6_addr) != 1)
goto out;
sin6->sin6_family = AF_INET6;
#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
@@ -269,6 +272,8 @@ conf_gethostport(const char *f, size_t l, bool local, struct conf *c,
#endif
port = &sin6->sin6_port;
}
+ if (!*pstr)
+ pstr = "*";
} else if (pstr != p || strchr(p, '.') || conf_is_interface(p)) {
if (pstr == p)
pstr = "*";
@@ -311,7 +316,7 @@ conf_gethostport(const char *f, size_t l, bool local, struct conf *c,
*port = htons((in_port_t)c->c_port);
return 0;
out:
- (*lfun)(LOG_ERR, "%s: %s, %zu: Bad address [%s]", __func__, f, l, pstr);
+ (*lfun)(LOG_ERR, "%s: %s, %zu: Bad address [%s]", __func__, f, l, p);
return -1;
out1:
(*lfun)(LOG_ERR, "%s: %s, %zu: Can't specify mask %d with "
@@ -407,6 +412,8 @@ conf_parseline(const char *f, size_t l, char *p, struct conf *c, bool local)
{
int e;
+ c->c_lineno = l;
+
while (*p && isspace((unsigned char)*p))
p++;
@@ -471,7 +478,6 @@ conf_amask_eq(const void *v1, const void *v2, size_t len, int mask)
uint32_t m;
int omask = mask;
- len >>= 2;
switch (mask) {
case FSTAR:
if (memcmp(v1, v2, len) == 0)
@@ -485,7 +491,7 @@ conf_amask_eq(const void *v1, const void *v2, size_t len, int mask)
break;
}
- for (size_t i = 0; i < len; i++) {
+ for (size_t i = 0; i < (len >> 2); i++) {
if (mask > 32) {
m = htonl((uint32_t)~0);
mask -= 32;
@@ -501,7 +507,6 @@ conf_amask_eq(const void *v1, const void *v2, size_t len, int mask)
out:
if (debug > 1) {
char b1[256], b2[256];
- len <<= 2;
blhexdump(b1, sizeof(b1), "a1", v1, len);
blhexdump(b2, sizeof(b2), "a2", v2, len);
(*lfun)(LOG_DEBUG, "%s: %s != %s [0x%x]", __func__,
@@ -691,6 +696,25 @@ conf_addr_eq(const struct sockaddr_storage *s1,
static int
conf_eq(const struct conf *c1, const struct conf *c2)
{
+ if (!conf_addr_eq(&c1->c_ss, &c2->c_ss, FSTAR))
+ return 0;
+
+#define CMP(a, b, f) \
+ if ((a)->f != (b)->f) \
+ return 0;
+
+ CMP(c1, c2, c_port);
+ CMP(c1, c2, c_proto);
+ CMP(c1, c2, c_family);
+ CMP(c1, c2, c_uid);
+#undef CMP
+
+ return 1;
+}
+
+static int
+conf_match(const struct conf *c1, const struct conf *c2)
+{
if (!conf_addr_eq(&c1->c_ss, &c2->c_ss, c2->c_lmask))
return 0;
@@ -953,13 +977,54 @@ confset_free(struct confset *cs)
}
static void
-confset_replace(struct confset *dc, struct confset *sc)
+confset_merge(struct confset *dc, struct confset *sc)
{
- struct confset tc;
- tc = *dc;
- *dc = *sc;
- confset_init(sc);
- confset_free(&tc);
+ size_t i, j;
+ char buf[BUFSIZ];
+
+ /* Check each rule of the src confset (sc) */
+ for (i = 0; i < sc->cs_n; i++) {
+ /* Compare to each rule in the dest confset (dc) */
+ for (j = 0; j < dc->cs_n; j++) {
+ if (conf_eq(&dc->cs_c[j], &sc->cs_c[i])) {
+ break;
+ }
+ }
+
+ if (j == dc->cs_n) {
+ /* This is a new rule to add to the dest confset. */
+ if (confset_full(dc) && confset_grow(dc) == -1)
+ return;
+
+ *confset_get(dc) = sc->cs_c[i];
+ confset_add(dc);
+ continue;
+ }
+
+ /* We had a match above. */
+ /*
+ * Check whether the rule from the src confset is more
+ * restrictive than the existing one. Adjust the
+ * existing rule if necessary.
+ */
+ if (sc->cs_c[i].c_nfail == dc->cs_c[j].c_nfail &&
+ sc->cs_c[i].c_duration && dc->cs_c[j].c_duration) {
+ (*lfun)(LOG_DEBUG, "skipping existing rule: %s",
+ conf_print(buf, sizeof (buf), "", "\t", &sc->cs_c[i]));
+ continue;
+ }
+
+ if (sc->cs_c[i].c_nfail < dc->cs_c[j].c_nfail)
+ dc->cs_c[j].c_nfail = sc->cs_c[i].c_nfail;
+
+ if (sc->cs_c[i].c_duration > dc->cs_c[j].c_duration)
+ dc->cs_c[j].c_duration = sc->cs_c[i].c_duration;
+
+ (*lfun)(LOG_DEBUG, "adjusted existing rule: %s",
+ conf_print(buf, sizeof (buf), "", "\t", &dc->cs_c[j]));
+ }
+
+ confset_free(sc);
}
static void
@@ -990,7 +1055,7 @@ confset_match(const struct confset *cs, struct conf *c,
if (debug)
(*lfun)(LOG_DEBUG, "%s", conf_print(buf, sizeof(buf),
"check:\t", "", &cs->cs_c[i]));
- if (conf_eq(c, &cs->cs_c[i])) {
+ if (conf_match(c, &cs->cs_c[i])) {
if (debug)
(*lfun)(LOG_DEBUG, "%s",
conf_print(buf, sizeof(buf),
@@ -1160,21 +1225,14 @@ conf_find(int fd, uid_t uid, const struct sockaddr_storage *rss,
return cr;
}
-
-void
-conf_parse(const char *f)
+static void
+conf_parsefile(FILE *fp, const char *config_file)
{
- FILE *fp;
char *line;
size_t lineno, len;
struct confset lc, rc, *cs;
- if ((fp = fopen(f, "r")) == NULL) {
- (*lfun)(LOG_ERR, "%s: Cannot open `%s' (%m)", __func__, f);
- return;
- }
-
- lineno = 1;
+ lineno = 0;
confset_init(&rc);
confset_init(&lc);
@@ -1197,23 +1255,103 @@ conf_parse(const char *f)
if (confset_grow(cs) == -1) {
confset_free(&lc);
confset_free(&rc);
- fclose(fp);
free(line);
return;
}
}
- if (conf_parseline(f, lineno, line, confset_get(cs),
+ if (conf_parseline(config_file, lineno, line, confset_get(cs),
cs == &lc) == -1)
continue;
confset_add(cs);
}
- fclose(fp);
- confset_sort(&lc);
- confset_sort(&rc);
+ confset_merge(&rconf, &rc);
+ confset_merge(&lconf, &lc);
+}
+
+
+static void
+conf_parsedir(DIR *dir, const char *config_path)
+{
+ long path_max;
+ struct dirent *dent;
+ char *path;
+ FILE *fp;
+
+ if ((path_max = pathconf(config_path, _PC_PATH_MAX)) == -1)
+ path_max = 2048;
+
+ if ((path = malloc((size_t)path_max)) == NULL) {
+ (*lfun)(LOG_ERR, "%s: Failed to allocate memory for path (%m)",
+ __func__);
+ return;
+ }
+
+ while ((dent = readdir(dir)) != NULL) {
+ if (strcmp(dent->d_name, ".") == 0 ||
+ strcmp(dent->d_name, "..") == 0)
+ continue;
+
+ (void) snprintf(path, (size_t)path_max, "%s/%s", config_path,
+ dent->d_name);
+ if ((fp = fopen(path, "r")) == NULL) {
+ (*lfun)(LOG_ERR, "%s: Cannot open `%s' (%m)", __func__,
+ path);
+ continue;
+ }
+ conf_parsefile(fp, path);
+ fclose(fp);
+ }
+
+ free(path);
+}
+
+void
+conf_parse(const char *config_path)
+{
+ char *path;
+ DIR *dir;
+ FILE *fp;
+
+ if ((dir = opendir(config_path)) != NULL) {
+ /*
+ * If config_path is a directory, parse the configuration files
+ * in the directory. Then we're done here.
+ */
+ conf_parsedir(dir, config_path);
+ closedir(dir);
+ goto out;
+ } else if ((fp = fopen(config_path, "r")) != NULL) {
+ /* If config_path is a file, parse it. */
+ conf_parsefile(fp, config_path);
+ fclose(fp);
+ }
+
+ /*
+ * Append ".d" to config_path, and if that is a directory, parse the
+ * configuration files in the directory.
+ */
+ if (asprintf(&path, "%s.d", config_path) < 0) {
+ (*lfun)(LOG_ERR, "%s: Failed to allocate memory for path (%m)",
+ __func__);
+ goto out;
+ }
+
+ if ((dir = opendir(path)) != NULL) {
+ conf_parsedir(dir, path);
+ closedir(dir);
+ }
+ free(path);
+
+out:
+ if (dir == NULL && fp == NULL) {
+ (*lfun)(LOG_ERR, "%s: Cannot open `%s' (%m)", __func__,
+ config_path);
+ return;
+ }
- confset_replace(&rconf, &rc);
- confset_replace(&lconf, &lc);
+ confset_sort(&lconf);
+ confset_sort(&rconf);
if (debug) {
confset_list(&lconf, "local", "target");
diff --git a/contrib/blocklist/bin/conf.h b/contrib/blocklist/bin/conf.h
index 03f1942e3e32..8e4cd3a41fae 100644
--- a/contrib/blocklist/bin/conf.h
+++ b/contrib/blocklist/bin/conf.h
@@ -1,4 +1,4 @@
-/* $NetBSD: conf.h,v 1.6 2015/01/27 19:40:36 christos Exp $ */
+/* $NetBSD: conf.h,v 1.2 2025/02/05 20:09:33 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -34,6 +34,7 @@
#include <sys/socket.h>
struct conf {
+ size_t c_lineno;
struct sockaddr_storage c_ss;
int c_lmask;
int c_port;
diff --git a/contrib/blocklist/bin/internal.c b/contrib/blocklist/bin/internal.c
index 5c039e4dc5d2..625de55928d8 100644
--- a/contrib/blocklist/bin/internal.c
+++ b/contrib/blocklist/bin/internal.c
@@ -1,4 +1,4 @@
-/* $NetBSD: internal.c,v 1.5 2015/01/27 19:40:37 christos Exp $ */
+/* $NetBSD: internal.c,v 1.2 2025/02/11 17:48:30 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -32,8 +32,10 @@
#include "config.h"
#endif
+#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
-__RCSID("$NetBSD: internal.c,v 1.5 2015/01/27 19:40:37 christos Exp $");
+#endif
+__RCSID("$NetBSD: internal.c,v 1.2 2025/02/11 17:48:30 christos Exp $");
#include <stdio.h>
#include <syslog.h>
@@ -41,7 +43,7 @@ __RCSID("$NetBSD: internal.c,v 1.5 2015/01/27 19:40:37 christos Exp $");
#include "internal.h"
int debug;
-const char *rulename = "blacklistd";
+const char *rulename = "blocklistd";
const char *controlprog = _PATH_BLCONTROL;
struct confset lconf, rconf;
struct ifaddrs *ifas;
diff --git a/contrib/blocklist/bin/internal.h b/contrib/blocklist/bin/internal.h
index 5a40e49fbbd5..553320e7afd5 100644
--- a/contrib/blocklist/bin/internal.h
+++ b/contrib/blocklist/bin/internal.h
@@ -1,4 +1,4 @@
-/* $NetBSD: internal.h,v 1.14 2016/04/04 15:52:56 christos Exp $ */
+/* $NetBSD: internal.h,v 1.1.1.1 2020/06/15 01:52:53 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -32,13 +32,13 @@
#define _INTERNAL_H
#ifndef _PATH_BLCONF
-#define _PATH_BLCONF "/etc/blacklistd.conf"
+#define _PATH_BLCONF "/etc/blocklistd.conf"
#endif
#ifndef _PATH_BLCONTROL
-#define _PATH_BLCONTROL "/libexec/blacklistd-helper"
+#define _PATH_BLCONTROL "/usr/libexec/blocklistd-helper"
#endif
#ifndef _PATH_BLSTATE
-#define _PATH_BLSTATE "/var/db/blacklistd.db"
+#define _PATH_BLSTATE "/var/db/blocklistd.db"
#endif
extern struct confset rconf, lconf;
diff --git a/contrib/blocklist/bin/old_internal.c b/contrib/blocklist/bin/old_internal.c
new file mode 100644
index 000000000000..79093cc8b8ab
--- /dev/null
+++ b/contrib/blocklist/bin/old_internal.c
@@ -0,0 +1,50 @@
+/* $NetBSD: internal.c,v 1.2 2025/02/11 17:48:30 christos Exp $ */
+
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+__RCSID("$NetBSD: internal.c,v 1.2 2025/02/11 17:48:30 christos Exp $");
+
+#include <stdio.h>
+#include <syslog.h>
+#include "conf.h"
+#include "old_internal.h"
+
+int debug;
+const char *rulename = "blacklistd";
+const char *controlprog = _PATH_BLCONTROL;
+struct confset lconf, rconf;
+struct ifaddrs *ifas;
+void (*lfun)(int, const char *, ...) = syslog;
diff --git a/contrib/blocklist/bin/old_internal.h b/contrib/blocklist/bin/old_internal.h
new file mode 100644
index 000000000000..becee563e81d
--- /dev/null
+++ b/contrib/blocklist/bin/old_internal.h
@@ -0,0 +1,58 @@
+/* $NetBSD: internal.h,v 1.1.1.1 2020/06/15 01:52:53 christos Exp $ */
+
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _OLD_INTERNAL_H
+#define _OLD_INTERNAL_H
+
+#ifndef _PATH_BLCONF
+#define _PATH_BLCONF "/etc/blacklistd.conf"
+#endif
+#ifndef _PATH_BLCONTROL
+#define _PATH_BLCONTROL "/usr/libexec/blacklistd-helper"
+#endif
+#ifndef _PATH_BLSTATE
+/* We want the new name, the old one would be incompatible after 24932b6 */
+#define _PATH_BLSTATE "/var/db/blocklistd.db"
+#endif
+
+extern struct confset rconf, lconf;
+extern int debug;
+extern const char *rulename;
+extern const char *controlprog;
+extern struct ifaddrs *ifas;
+
+#if !defined(__syslog_attribute__) && !defined(__syslog__)
+#define __syslog__ __printf__
+#endif
+
+extern void (*lfun)(int, const char *, ...)
+ __attribute__((__format__(__syslog__, 2, 3)));
+
+#endif /* _OLD_INTERNAL_H */
diff --git a/contrib/blocklist/bin/run.c b/contrib/blocklist/bin/run.c
index 5588f0198c04..adcc407e65c6 100644
--- a/contrib/blocklist/bin/run.c
+++ b/contrib/blocklist/bin/run.c
@@ -1,4 +1,4 @@
-/* $NetBSD: run.c,v 1.14 2016/04/04 15:52:56 christos Exp $ */
+/* $NetBSD: run.c,v 1.3 2025/02/11 17:48:30 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -32,8 +32,10 @@
#include "config.h"
#endif
+#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
-__RCSID("$NetBSD: run.c,v 1.14 2016/04/04 15:52:56 christos Exp $");
+#endif
+__RCSID("$NetBSD: run.c,v 1.3 2025/02/11 17:48:30 christos Exp $");
#include <stdio.h>
#ifdef HAVE_LIBUTIL_H
@@ -131,7 +133,8 @@ run_change(const char *how, const struct conf *c, char *id, size_t len)
prname = "udp";
break;
default:
- (*lfun)(LOG_ERR, "%s: bad protocol %d", __func__, c->c_proto);
+ (*lfun)(LOG_ERR, "%s: bad protocol %d (line %zu)", __func__,
+ c->c_proto, c->c_lineno);
return -1;
}
diff --git a/contrib/blocklist/bin/run.h b/contrib/blocklist/bin/run.h
index bafc3e554690..da21906e0db6 100644
--- a/contrib/blocklist/bin/run.h
+++ b/contrib/blocklist/bin/run.h
@@ -1,4 +1,4 @@
-/* $NetBSD: run.h,v 1.5 2015/01/27 19:40:37 christos Exp $ */
+/* $NetBSD: run.h,v 1.1.1.1 2020/06/15 01:52:53 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
diff --git a/contrib/blocklist/bin/state.c b/contrib/blocklist/bin/state.c
index f2622c82c251..08e2622e223f 100644
--- a/contrib/blocklist/bin/state.c
+++ b/contrib/blocklist/bin/state.c
@@ -1,4 +1,4 @@
-/* $NetBSD: state.c,v 1.19 2016/09/26 19:43:43 christos Exp $ */
+/* $NetBSD: state.c,v 1.2 2025/02/11 17:48:30 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -32,8 +32,10 @@
#include "config.h"
#endif
+#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
-__RCSID("$NetBSD: state.c,v 1.19 2016/09/26 19:43:43 christos Exp $");
+#endif
+__RCSID("$NetBSD: state.c,v 1.2 2025/02/11 17:48:30 christos Exp $");
#include <sys/types.h>
#include <sys/socket.h>
diff --git a/contrib/blocklist/bin/state.h b/contrib/blocklist/bin/state.h
index 2e9257006e80..48f63a41ef33 100644
--- a/contrib/blocklist/bin/state.h
+++ b/contrib/blocklist/bin/state.h
@@ -1,4 +1,4 @@
-/* $NetBSD: state.h,v 1.5 2015/01/27 19:40:37 christos Exp $ */
+/* $NetBSD: state.h,v 1.1.1.1 2020/06/15 01:52:53 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
diff --git a/contrib/blocklist/bin/support.c b/contrib/blocklist/bin/support.c
index d560d2303223..91e40812611e 100644
--- a/contrib/blocklist/bin/support.c
+++ b/contrib/blocklist/bin/support.c
@@ -1,4 +1,4 @@
-/* $NetBSD: support.c,v 1.9 2018/09/18 22:12:19 christos Exp $ */
+/* $NetBSD: support.c,v 1.3 2025/02/11 17:48:30 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -32,8 +32,10 @@
#include "config.h"
#endif
+#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
-__RCSID("$NetBSD: support.c,v 1.9 2018/09/18 22:12:19 christos Exp $");
+#endif
+__RCSID("$NetBSD: support.c,v 1.3 2025/02/11 17:48:30 christos Exp $");
#include <time.h>
#include <string.h>
@@ -66,7 +68,8 @@ expandm(char *buf, size_t len, const char *fmt)
}
void
-vdlog(int level __unused, const char *fmt, va_list ap)
+vdlog(int level __unused, struct syslog_data *sd __unused,
+ const char *fmt, va_list ap)
{
char buf[BUFSIZ];
@@ -81,7 +84,7 @@ dlog(int level, const char *fmt, ...)
va_list ap;
va_start(ap, fmt);
- vdlog(level, fmt, ap);
+ vdlog(level, NULL, fmt, ap);
va_end(ap);
}
diff --git a/contrib/blocklist/bin/support.h b/contrib/blocklist/bin/support.h
index 899649ce8319..bb865cb8fe68 100644
--- a/contrib/blocklist/bin/support.h
+++ b/contrib/blocklist/bin/support.h
@@ -1,4 +1,4 @@
-/* $NetBSD: support.h,v 1.7 2016/04/04 15:52:56 christos Exp $ */
+/* $NetBSD: support.h,v 1.2 2024/08/02 17:11:55 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -34,8 +34,9 @@
__BEGIN_DECLS
const char *fmttime(char *, size_t, time_t);
const char *fmtydhms(char *, size_t, time_t);
-void vdlog(int, const char *, va_list)
- __attribute__((__format__(__printf__, 2, 0)));
+struct syslog_data;
+void vdlog(int, struct syslog_data *, const char *, va_list)
+ __attribute__((__format__(__printf__, 3, 0)));
void dlog(int, const char *, ...)
__attribute__((__format__(__printf__, 2, 3)));
ssize_t blhexdump(char *, size_t, const char *, const void *, size_t);
diff --git a/contrib/blocklist/diff/ftpd.diff b/contrib/blocklist/diff/ftpd.diff
index d28577f3ef5f..37b43dae2295 100644
--- a/contrib/blocklist/diff/ftpd.diff
+++ b/contrib/blocklist/diff/ftpd.diff
@@ -2,17 +2,17 @@
+++ pfilter.c 2015-01-23 17:12:02.000000000 -0500
@@ -0,0 +1,24 @@
+#include <stdio.h>
-+#include <blacklist.h>
++#include <blocklist.h>
+
+#include "pfilter.h"
+
-+static struct blacklist *blstate;
++static struct blocklist *blstate;
+
+void
+pfilter_open(void)
+{
+ if (blstate == NULL)
-+ blstate = blacklist_open();
++ blstate = blocklist_open();
+}
+
+void
@@ -23,7 +23,7 @@
+ if (blstate == NULL)
+ return;
+
-+ blacklist_r(blstate, what, 0, msg);
++ blocklist_r(blstate, what, 0, msg);
+}
--- /dev/null 2015-01-23 17:30:40.000000000 -0500
+++ pfilter.h 2015-01-23 17:07:25.000000000 -0500
@@ -42,8 +42,8 @@ diff -u -p -u -r1.63 Makefile
MLINKS= ftpusers.5 ftpchroot.5
+SRCS+= pfilter.c
-+LDADD+= -lblacklist
-+DPADD+= ${LIBBLACKLIST}
++LDADD+= -lblocklist
++DPADD+= ${LIBBLOCKLIST}
+
.if defined(NO_INTERNAL_LS)
CPPFLAGS+=-DNO_INTERNAL_LS
diff --git a/contrib/blocklist/diff/named.diff b/contrib/blocklist/diff/named.diff
index fcd97ba7ec1f..a5069ff94df7 100644
--- a/contrib/blocklist/diff/named.diff
+++ b/contrib/blocklist/diff/named.diff
@@ -8,17 +8,17 @@
+#include <named/types.h>
+#include <named/client.h>
+
-+#include <blacklist.h>
++#include <blocklist.h>
+
+#include "pfilter.h"
+
-+static struct blacklist *blstate;
++static struct blocklist *blstate;
+
+void
+pfilter_open(void)
+{
+ if (blstate == NULL)
-+ blstate = blacklist_open();
++ blstate = blocklist_open();
+}
+
+#define TCP_CLIENT(c) (((c)->attributes & NS_CLIENTATTR_TCP) != 0)
@@ -39,7 +39,7 @@
+ }
+ if (socket == NULL)
+ return;
-+ blacklist_sa_r(blstate,
++ blocklist_sa_r(blstate,
+ res != ISC_R_SUCCESS, isc_socket_getfd(socket),
+ &client->peeraddr.type.sa, client->peeraddr.length, msg);
+}
@@ -63,8 +63,8 @@ diff -u -u -r1.8 Makefile
+ pfilter.c tkeyconf.c tsigconf.c \
update.c xfrout.c zoneconf.c ${SRCS_UNIX}
-+LDADD+=-lblacklist
-+DPADD+=${LIBBLACKLIST}
++LDADD+=-lblocklist
++DPADD+=${LIBBLOCKLIST}
.include <bsd.prog.mk>
Index: dist/bin/named/client.c
===================================================================
diff --git a/contrib/blocklist/diff/postfix.diff b/contrib/blocklist/diff/postfix.diff
new file mode 100644
index 000000000000..6f14389515cf
--- /dev/null
+++ b/contrib/blocklist/diff/postfix.diff
@@ -0,0 +1,98 @@
+Index: dist/src/smtpd/pfilter.c
+===================================================================
+RCS file: dist/src/smtpd/pfilter.c
+diff -N dist/src/smtpd/pfilter.c
+--- /dev/null 1 Jan 1970 00:00:00 -0000
++++ dist/src/smtpd/pfilter.c 1 Feb 2018 03:29:09 -0000
+@@ -0,0 +1,19 @@
++#include "pfilter.h"
++#include <stdio.h> /* for NULL */
++#include <blocklist.h>
++
++static struct blocklist *blstate;
++
++void
++pfilter_notify(int a, int fd)
++{
++ if (blstate == NULL)
++ blstate = blocklist_open();
++ if (blstate == NULL)
++ return;
++ (void)blocklist_r(blstate, a, fd, "smtpd");
++ if (a == 0) {
++ blocklist_close(blstate);
++ blstate = NULL;
++ }
++}
+Index: dist/src/smtpd/pfilter.h
+===================================================================
+RCS file: dist/src/smtpd/pfilter.h
+diff -N dist/src/smtpd/pfilter.h
+--- /dev/null 1 Jan 1970 00:00:00 -0000
++++ dist/src/smtpd/pfilter.h 1 Feb 2018 03:29:09 -0000
+@@ -0,0 +1,2 @@
++
++void pfilter_notify(int, int);
+Index: dist/src/smtpd/smtpd.c
+===================================================================
+RCS file: /cvsroot/src/external/ibm-public/postfix/dist/src/smtpd/smtpd.c,v
+retrieving revision 1.14
+diff -u -r1.14 smtpd.c
+--- dist/src/smtpd/smtpd.c 14 Feb 2017 01:16:48 -0000 1.14
++++ dist/src/smtpd/smtpd.c 1 Feb 2018 03:29:09 -0000
+@@ -1197,6 +1197,8 @@
+ #include <smtpd_milter.h>
+ #include <smtpd_expand.h>
+
++#include "pfilter.h"
++
+ /*
+ * Tunable parameters. Make sure that there is some bound on the length of
+ * an SMTP command, so that the mail system stays in control even when a
+@@ -5048,6 +5050,7 @@
+ if (state->error_count >= var_smtpd_hard_erlim) {
+ state->reason = REASON_ERROR_LIMIT;
+ state->error_mask |= MAIL_ERROR_PROTOCOL;
++ pfilter_notify(1, vstream_fileno(state->client));
+ smtpd_chat_reply(state, "421 4.7.0 %s Error: too many errors",
+ var_myhostname);
+ break;
+Index: libexec/smtpd/Makefile
+===================================================================
+RCS file: /cvsroot/src/external/ibm-public/postfix/libexec/smtpd/Makefile,v
+retrieving revision 1.6
+diff -u -r1.6 Makefile
+--- libexec/smtpd/Makefile 21 May 2017 15:28:40 -0000 1.6
++++ libexec/smtpd/Makefile 1 Feb 2018 03:29:09 -0000
+@@ -13,11 +13,14 @@
+ SRCS= smtpd.c smtpd_token.c smtpd_check.c smtpd_chat.c smtpd_state.c \
+ smtpd_peer.c smtpd_sasl_proto.c smtpd_sasl_glue.c smtpd_proxy.c \
+ smtpd_xforward.c smtpd_dsn_fix.c smtpd_milter.c smtpd_resolve.c \
+- smtpd_expand.c smtpd_haproxy.c
++ smtpd_expand.c smtpd_haproxy.c pfilter.c
+
+ DPADD+= ${LIBPMASTER} ${LIBPMILTER} ${LIBPGLOBAL} ${LIBPDNS} ${LIBPXSASL}
+ LDADD+= ${LIBPMASTER} ${LIBPMILTER} ${LIBPGLOBAL} ${LIBPDNS} ${LIBPXSASL}
+
++DPADD+= ${LIBBLOCKLIST}
++LDADD+= -lblocklist
++
+ DPADD+= ${LIBPTLS} ${LIBSSL} ${LIBCRYPTO}
+ LDADD+= ${LIBPTLS} -lssl -lcrypto
+
+Index: dist/src/smtpd/smtpd.c
+===================================================================
+RCS file: /cvsroot/src/external/ibm-public/postfix/dist/src/smtpd/smtpd.c,v
+retrieving revision 1.17
+diff -u -u -r1.17 smtpd.c
+--- dist/src/smtpd/smtpd.c 18 Mar 2020 19:05:20 -0000 1.17
++++ dist/src/smtpd/smtpd.c 25 Sep 2020 12:51:52 -0000
+@@ -5795,6 +5795,8 @@
+ || strcmp(state->reason, REASON_LOST_CONNECTION)) {
+ msg_info("%s after %s from %s",
+ state->reason, state->where, state->namaddr);
++ if (strcmp(state->where, SMTPD_CMD_AUTH) == 0)
++ pfilter_notify(1, vstream_fileno(state->client));
+ }
+ }
+
diff --git a/contrib/blocklist/diff/proftpd.diff b/contrib/blocklist/diff/proftpd.diff
index 455b7cd60c64..e8d2cc5e9e07 100644
--- a/contrib/blocklist/diff/proftpd.diff
+++ b/contrib/blocklist/diff/proftpd.diff
@@ -1,12 +1,12 @@
--- Make.rules.in.orig 2015-05-27 20:25:54.000000000 -0400
+++ Make.rules.in 2016-01-25 21:48:47.000000000 -0500
@@ -110,3 +110,8 @@
-
+
FTPWHO_OBJS=ftpwho.o scoreboard.o misc.o
BUILD_FTPWHO_OBJS=utils/ftpwho.o utils/scoreboard.o utils/misc.o
+
-+CPPFLAGS+=-DHAVE_BLACKLIST
-+LIBS+=-lblacklist
++CPPFLAGS+=-DHAVE_BLOCKLIST
++LIBS+=-lblocklist
+OBJS+= pfilter.o
+BUILD_OBJS+= src/pfilter.o
--- /dev/null 2016-01-22 17:30:55.000000000 -0500
@@ -84,25 +84,25 @@
+#include "pfilter.h"
+#include "conf.h"
+#include "privs.h"
-+#ifdef HAVE_BLACKLIST
-+#include <blacklist.h>
++#ifdef HAVE_BLOCKLIST
++#include <blocklist.h>
+#endif
+
-+static struct blacklist *blstate;
++static struct blocklist *blstate;
+
+void
+pfilter_init(void)
+{
-+#ifdef HAVE_BLACKLIST
++#ifdef HAVE_BLOCKLIST
+ if (blstate == NULL)
-+ blstate = blacklist_open();
++ blstate = blocklist_open();
+#endif
+}
+
+void
+pfilter_notify(int a)
+{
-+#ifdef HAVE_BLACKLIST
++#ifdef HAVE_BLOCKLIST
+ conn_t *c = session.c;
+ int fd;
+
@@ -119,6 +119,6 @@
+ pfilter_init();
+ if (blstate == NULL)
+ return;
-+ (void)blacklist_r(blstate, a, fd, "proftpd");
++ (void)blocklist_r(blstate, a, fd, "proftpd");
+#endif
+}
diff --git a/contrib/blocklist/diff/ssh.diff b/contrib/blocklist/diff/ssh.diff
index 9427fc8ddb36..17300bb5dc8d 100644
--- a/contrib/blocklist/diff/ssh.diff
+++ b/contrib/blocklist/diff/ssh.diff
@@ -7,14 +7,14 @@
+#include "packet.h"
+#include "log.h"
+#include "pfilter.h"
-+#include <blacklist.h>
++#include <blocklist.h>
+
-+static struct blacklist *blstate;
++static struct blocklist *blstate;
+
+void
+pfilter_init(void)
+{
-+ blstate = blacklist_open();
++ blstate = blocklist_open();
+}
+
+void
@@ -27,9 +27,9 @@
+ return;
+ // XXX: 3?
+ fd = packet_connection_is_on_socket() ? packet_get_connection_in() : 3;
-+ (void)blacklist_r(blstate, a, fd, "ssh");
++ (void)blocklist_r(blstate, a, fd, "ssh");
+ if (a == 0) {
-+ blacklist_close(blstate);
++ blocklist_close(blstate);
+ blstate = NULL;
+ }
+}
@@ -60,8 +60,8 @@ diff -u -u -r1.10 Makefile
LDADD+= -lwrap
DPADD+= ${LIBWRAP}
+
-+LDADD+= -lblacklist
-+DPADD+= ${LIBBLACKLIST}
++LDADD+= -lblocklist
++DPADD+= ${LIBBLOCKLIST}
diff -ru openssh-7.7p1/auth-pam.c dist/auth-pam.c
--- openssh-7.7p1/auth-pam.c 2018-04-02 01:38:28.000000000 -0400
+++ dist/auth-pam.c 2018-05-23 11:56:22.206661484 -0400
diff --git a/contrib/blocklist/etc/Makefile b/contrib/blocklist/etc/Makefile
index 669528ddca89..f4f2dc79f857 100644
--- a/contrib/blocklist/etc/Makefile
+++ b/contrib/blocklist/etc/Makefile
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile,v 1.3 2015/01/26 00:18:40 christos Exp $
+# $NetBSD: Makefile,v 1.2 2025/02/05 20:24:26 christos Exp $
-SUBDIR=rc.d
+SUBDIR= rc.d
-FILESDIR= /usr/share/examples/blacklist
-FILESMODE= 644
-FILES= blacklistd.conf npf.conf
+FILESDIR= /usr/share/examples/blocklist
+FILESMODE= 644
+FILES= blocklistd.conf ipf.conf npf.conf
.include <bsd.files.mk>
.include <bsd.subdir.mk>
diff --git a/contrib/blocklist/etc/blacklistd.conf b/contrib/blocklist/etc/blocklistd.conf
index f061b004ad36..b52b994fe950 100644
--- a/contrib/blocklist/etc/blacklistd.conf
+++ b/contrib/blocklist/etc/blocklistd.conf
@@ -1,5 +1,5 @@
-# Blacklist rule
-# adr/mask:port type proto owner name nfail disable
+# Blocklist rule
+# adr/mask:port type proto owner name nfail duration
[local]
ssh stream * * * 3 6h
ftp stream * * * 3 6h
@@ -7,8 +7,9 @@ domain * * named * 3 12h
#6161 stream tcp6 christos * 2 10m
* * * * * 3 60
-# adr/mask:port type proto owner name nfail disable
+# adr/mask:port type proto owner name nfail duration
[remote]
#129.168.0.0/16 * * * = * *
+#[2001:db8::]/32:ssh * * * = * *
#6161 = = = =/24 = =
#* stream tcp * = = =
diff --git a/contrib/blocklist/etc/ipf.conf b/contrib/blocklist/etc/ipf.conf
new file mode 100644
index 000000000000..f6bec74238d6
--- /dev/null
+++ b/contrib/blocklist/etc/ipf.conf
@@ -0,0 +1,45 @@
+#========================================
+#
+# subsection for abuse blocking
+#
+#========================================
+#
+# This section should be included early in the main /etc/ipf.conf file, right
+# after any basic generic accounting ("count") rules, and any cleanup rules to
+# block invalid fragments, invalid options (e.g. "ssrr"), etc.
+#
+# Note these will not actually block anything since they don't include the
+# "quick" flag, and are thus part of a last-match group. They simply set up a
+# group such that any connection logging rule further below won't also match if
+# one of the rules in the group matches, no matter when or where the subsequent
+# matching rule is added. I.e. all rules in the group are checked for a match
+# (and a possible "first match" with "quick") before any subsequent rules
+# further below are used. Note group rules can be added at any time, including
+# at runtime after all other rules have been added -- they will still belong to
+# the group and once added will be checked as part of the group.
+#
+# head of "blocklistd" group:
+#
+# The "blocklistd" group will be used by blocklistd(8).
+#
+block in proto tcp/udp from any to any head blocklistd
+#
+# head of "attackers" group to block all attackers:
+#
+# The "attackers" group is intended to be used for manually maintained rules
+# e.g. as could be added like this:
+#
+# echo 'block return-rst in log quick proto tcp from 118.136.0.0/15 to any flags S/SAFR group attackers' >> /etc/ipf.conf
+# /etc/rc.d/ipfliter reload
+#
+# Note the choice in this example is to return RST packets for blocked SYN
+# packets to help the other end close. This is not necessary, but it better
+# mimics what the kernel does by default, thus perhaps hiding the fact a
+# firewall is present.
+#
+# XXX This example still allows UDP services, but we would need to duplicate
+# each rule with "proto udp" (and without "flags blah") due to IPF parsing
+# limitations....
+#
+block in proto tcp/udp from any to any head attackers
+#
diff --git a/contrib/blocklist/etc/npf.conf b/contrib/blocklist/etc/npf.conf
index 42d56044ad6e..b1c33f2738f0 100644
--- a/contrib/blocklist/etc/npf.conf
+++ b/contrib/blocklist/etc/npf.conf
@@ -1,4 +1,4 @@
-# Transparent firewall example for blacklistd
+# Transparent firewall example for blocklistd
$ext_if = "bnx0"
@@ -6,7 +6,7 @@ set bpf.jit on;
alg "icmp"
group "external" on $ext_if {
- ruleset "blacklistd"
+ ruleset "blocklistd"
pass final all
}
diff --git a/contrib/blocklist/etc/rc.d/Makefile b/contrib/blocklist/etc/rc.d/Makefile
index e863d0853a0f..9e214984f7c2 100644
--- a/contrib/blocklist/etc/rc.d/Makefile
+++ b/contrib/blocklist/etc/rc.d/Makefile
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.1 2015/01/22 17:49:41 christos Exp $
+# $NetBSD: Makefile,v 1.1.1.1 2020/06/15 01:52:53 christos Exp $
-SCRIPTS=blacklistd
+SCRIPTS=blocklistd
SCRIPTSDIR=/etc/rc.d
.include <bsd.prog.mk>
diff --git a/contrib/blocklist/etc/rc.d/blacklistd b/contrib/blocklist/etc/rc.d/blocklistd
index 278a6742e63c..89871ebda4a0 100644
--- a/contrib/blocklist/etc/rc.d/blacklistd
+++ b/contrib/blocklist/etc/rc.d/blocklistd
@@ -1,15 +1,15 @@
#!/bin/sh
#
-# $NetBSD: blacklistd,v 1.2 2016/10/17 22:47:16 christos Exp $
+# $NetBSD: blocklistd,v 1.2 2021/03/07 00:46:39 christos Exp $
#
-# PROVIDE: blacklistd
-# REQUIRE: npf
+# PROVIDE: blocklistd
+# REQUIRE: npf pf ipfilter
# BEFORE: SERVERS
$_rc_subr_loaded . /etc/rc.subr
-name="blacklistd"
+name="blocklistd"
rcvar=$name
command="/sbin/${name}"
pidfile="/var/run/${name}.pid"
@@ -18,17 +18,17 @@ start_precmd="${name}_precmd"
extra_commands="reload"
_sockfile="/var/run/${name}.sockets"
-_sockname="blacklistd.sock"
+_sockname="blocklistd.sock"
-blacklistd_precmd()
+blocklistd_precmd()
{
- # Create default list of blacklistd sockets to watch
+ # Create default list of blocklistd sockets to watch
#
( umask 022 ; > $_sockfile )
# Find /etc/rc.d scripts with "chrootdir" rcorder(8) keyword,
# and if $${app}_chrootdir is a directory, add appropriate
- # blacklistd socket to list of sockets to watch.
+ # blocklistd socket to list of sockets to watch.
#
for _lr in $(rcorder -k chrootdir /etc/rc.d/*); do
(
@@ -42,8 +42,8 @@ blacklistd_precmd()
done
# If other sockets have been provided, change run_rc_command()'s
- # internal copy of $blacklistd_flags to force use of specific
- # blacklistd sockets.
+ # internal copy of $blocklistd_flags to force use of specific
+ # blocklistd sockets.
#
if [ -s $_sockfile ]; then
echo "/var/run/${_sockname}" >> $_sockfile
diff --git a/contrib/blocklist/include/Makefile b/contrib/blocklist/include/Makefile
index 6854907be25e..b7ce1eca278c 100644
--- a/contrib/blocklist/include/Makefile
+++ b/contrib/blocklist/include/Makefile
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile,v 1.1 2015/01/21 16:16:00 christos Exp $
+# $NetBSD: Makefile,v 1.1.1.1 2020/06/15 01:52:53 christos Exp $
# Doing a make includes builds /usr/include
NOOBJ= # defined
-INCS= blacklist.h
+INCS= blocklist.h
INCSDIR= /usr/include
.include <bsd.prog.mk>
diff --git a/contrib/blocklist/include/bl.h b/contrib/blocklist/include/bl.h
index 8f366de912fe..c7ed517d7a6d 100644
--- a/contrib/blocklist/include/bl.h
+++ b/contrib/blocklist/include/bl.h
@@ -1,4 +1,4 @@
-/* $NetBSD: bl.h,v 1.13 2016/03/11 17:16:40 christos Exp $ */
+/* $NetBSD: bl.h,v 1.2 2024/08/02 17:11:55 christos Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include <stdarg.h>
#include <sys/param.h>
#include <sys/socket.h>
-#include "blacklist.h"
+#include "blocklist.h"
typedef enum {
BL_INVALID,
@@ -58,14 +58,15 @@ typedef struct {
#define bi_cred bi_u._bi_cred
#ifndef _PATH_BLSOCK
-#define _PATH_BLSOCK "/var/run/blacklistd.sock"
+#define _PATH_BLSOCK "/var/run/blocklistd.sock"
#endif
__BEGIN_DECLS
-typedef struct blacklist *bl_t;
+typedef struct blocklist *bl_t;
-bl_t bl_create(bool, const char *, void (*)(int, const char *, va_list));
+bl_t bl_create(bool, const char *,
+ void (*)(int, struct syslog_data *, const char *, va_list));
void bl_destroy(bl_t);
int bl_send(bl_t, bl_type_t, int, const struct sockaddr *, socklen_t,
const char *);
diff --git a/contrib/blocklist/include/blacklist.h b/contrib/blocklist/include/blacklist.h
index 2f5c8ba09864..f97cf34c4bcb 100644
--- a/contrib/blocklist/include/blacklist.h
+++ b/contrib/blocklist/include/blacklist.h
@@ -1,4 +1,4 @@
-/* $NetBSD: blacklist.h,v 1.3 2015/01/23 18:48:56 christos Exp $ */
+/* $NetBSD: blocklist.h,v 1.4 2025/02/11 17:42:17 christos Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -32,16 +32,26 @@
#define _BLACKLIST_H
#include <sys/socket.h>
+#include <syslog.h>
-__BEGIN_DECLS
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct syslog_data;
struct blacklist *blacklist_open(void);
+struct blacklist *blacklist_open2(
+ void (*)(int, struct syslog_data *, const char *, va_list));
void blacklist_close(struct blacklist *);
int blacklist(int, int, const char *);
int blacklist_r(struct blacklist *, int, int, const char *);
int blacklist_sa(int, int, const struct sockaddr *, socklen_t, const char *);
int blacklist_sa_r(struct blacklist *, int, int,
const struct sockaddr *, socklen_t, const char *);
-__END_DECLS
+
+#if defined(__cplusplus)
+}
+#endif
/* action values for user applications */
#define BLACKLIST_API_ENUM 1
diff --git a/contrib/blocklist/include/blocklist.h b/contrib/blocklist/include/blocklist.h
new file mode 100644
index 000000000000..f09e5139079b
--- /dev/null
+++ b/contrib/blocklist/include/blocklist.h
@@ -0,0 +1,65 @@
+/* $NetBSD: blocklist.h,v 1.4 2025/02/11 17:42:17 christos Exp $ */
+
+/*-
+ * Copyright (c) 2014 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _BLOCKLIST_H
+#define _BLOCKLIST_H
+
+#include <sys/socket.h>
+#include <syslog.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+struct syslog_data;
+struct blocklist *blocklist_open(void);
+struct blocklist *blocklist_open2(
+ void (*)(int, struct syslog_data *, const char *, va_list));
+void blocklist_close(struct blocklist *);
+int blocklist(int, int, const char *);
+int blocklist_r(struct blocklist *, int, int, const char *);
+int blocklist_sa(int, int, const struct sockaddr *, socklen_t, const char *);
+int blocklist_sa_r(struct blocklist *, int, int,
+ const struct sockaddr *, socklen_t, const char *);
+
+#if defined(__cplusplus)
+}
+#endif
+
+/* action values for user applications */
+#define BLOCKLIST_API_ENUM 1
+enum {
+ BLOCKLIST_AUTH_OK = 0,
+ BLOCKLIST_AUTH_FAIL,
+ BLOCKLIST_ABUSIVE_BEHAVIOR,
+ BLOCKLIST_BAD_USER
+};
+
+#endif /* _BLOCKLIST_H */
diff --git a/contrib/blocklist/include/old_bl.h b/contrib/blocklist/include/old_bl.h
new file mode 100644
index 000000000000..1ab64a4d9b69
--- /dev/null
+++ b/contrib/blocklist/include/old_bl.h
@@ -0,0 +1,80 @@
+/* $NetBSD: bl.h,v 1.2 2024/08/02 17:11:55 christos Exp $ */
+
+/*-
+ * Copyright (c) 2014 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _OLD_BL_H
+#define _OLD_BL_H
+
+#include <stdbool.h>
+#include <stdarg.h>
+#include <sys/param.h>
+#include <sys/socket.h>
+#include "blacklist.h"
+
+typedef enum {
+ BL_INVALID,
+ BL_ADD,
+ BL_DELETE,
+ BL_ABUSE,
+ BL_BADUSER
+} bl_type_t;
+
+typedef struct {
+ bl_type_t bi_type;
+ int bi_fd;
+ uid_t bi_uid;
+ gid_t bi_gid;
+ socklen_t bi_slen;
+ struct sockaddr_storage bi_ss;
+ char bi_msg[1024];
+} bl_info_t;
+
+#define bi_cred bi_u._bi_cred
+
+/* We want the new name */
+#ifndef _PATH_BLSOCK
+#define _PATH_BLSOCK "/var/run/blocklistd.sock"
+#endif
+
+__BEGIN_DECLS
+
+typedef struct blacklist *bl_t;
+
+bl_t bl_create(bool, const char *,
+ void (*)(int, struct syslog_data *, const char *, va_list));
+void bl_destroy(bl_t);
+int bl_send(bl_t, bl_type_t, int, const struct sockaddr *, socklen_t,
+ const char *);
+int bl_getfd(bl_t);
+bl_info_t *bl_recv(bl_t);
+bool bl_isconnected(bl_t);
+
+__END_DECLS
+
+#endif /* _OLD_BL_H */
diff --git a/contrib/blocklist/lib/Makefile b/contrib/blocklist/lib/Makefile
index 4f1ab7717a99..147f311c4782 100644
--- a/contrib/blocklist/lib/Makefile
+++ b/contrib/blocklist/lib/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.7 2019/03/08 20:40:05 christos Exp $
+# $NetBSD: Makefile,v 1.1.1.1 2020/06/15 01:52:53 christos Exp $
.include <bsd.own.mk>
@@ -6,14 +6,14 @@ USE_SHLIBDIR= yes
CPPFLAGS+=-D_REENTRANT
#LIBDPLIBS+=pthread ${NETBSDSRCDIR}/lib/libpthread
-LIB=blacklist
-SRCS=bl.c blacklist.c
-MAN=libblacklist.3
-MLINKS+=libblacklist.3 blacklist_open.3
-MLINKS+=libblacklist.3 blacklist_close.3
-MLINKS+=libblacklist.3 blacklist.3
-MLINKS+=libblacklist.3 blacklist_r.3
-MLINKS+=libblacklist.3 blacklist_sa.3
-MLINKS+=libblacklist.3 blacklist_sa_r.3
+LIB=blocklist
+SRCS=bl.c blocklist.c
+MAN=libblocklist.3
+MLINKS+=libblocklist.3 blocklist_open.3
+MLINKS+=libblocklist.3 blocklist_close.3
+MLINKS+=libblocklist.3 blocklist.3
+MLINKS+=libblocklist.3 blocklist_r.3
+MLINKS+=libblocklist.3 blocklist_sa.3
+MLINKS+=libblocklist.3 blocklist_sa_r.3
.include <bsd.lib.mk>
diff --git a/contrib/blocklist/lib/bl.c b/contrib/blocklist/lib/bl.c
index 409317bc3fc0..80396ed12b28 100644
--- a/contrib/blocklist/lib/bl.c
+++ b/contrib/blocklist/lib/bl.c
@@ -1,4 +1,4 @@
-/* $NetBSD: bl.c,v 1.28 2016/07/29 17:13:09 christos Exp $ */
+/* $NetBSD: bl.c,v 1.9 2025/03/30 01:53:59 christos Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -32,8 +32,10 @@
#include "config.h"
#endif
+#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
-__RCSID("$NetBSD: bl.c,v 1.28 2016/07/29 17:13:09 christos Exp $");
+#endif
+__RCSID("$NetBSD: bl.c,v 1.9 2025/03/30 01:53:59 christos Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -57,6 +59,10 @@ __RCSID("$NetBSD: bl.c,v 1.28 2016/07/29 17:13:09 christos Exp $");
#include <pthread.h>
#endif
+#if defined(SO_RECVUCRED)
+#include <ucred.h>
+#endif
+
#include "bl.h"
typedef struct {
@@ -68,7 +74,7 @@ typedef struct {
char bl_data[];
} bl_message_t;
-struct blacklist {
+struct blocklist {
#ifdef _REENTRANT
pthread_mutex_t b_mutex;
# define BL_INIT(b) pthread_mutex_init(&b->b_mutex, NULL)
@@ -82,7 +88,8 @@ struct blacklist {
int b_fd;
int b_connected;
struct sockaddr_un b_sun;
- void (*b_fun)(int, const char *, va_list);
+ struct syslog_data b_syslog_data;
+ void (*b_fun)(int, struct syslog_data *, const char *, va_list);
bl_info_t b_info;
};
@@ -115,14 +122,16 @@ bl_reset(bl_t b, bool locked)
}
static void
-bl_log(void (*fun)(int, const char *, va_list), int level,
- const char *fmt, ...)
+bl_log(bl_t b, int level, const char *fmt, ...)
{
va_list ap;
int serrno = errno;
+ if (b->b_fun == NULL)
+ return;
+
va_start(ap, fmt);
- (*fun)(level, fmt, ap);
+ (*b->b_fun)(level, &b->b_syslog_data, fmt, ap);
va_end(ap);
errno = serrno;
}
@@ -152,7 +161,7 @@ bl_init(bl_t b, bool srv)
b->b_fd = socket(PF_LOCAL,
SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK|SOCK_NOSIGPIPE, 0);
if (b->b_fd == -1) {
- bl_log(b->b_fun, LOG_ERR, "%s: socket failed (%s)",
+ bl_log(b, LOG_ERR, "%s: socket failed (%s)",
__func__, strerror(errno));
BL_UNLOCK(b);
return -1;
@@ -186,7 +195,7 @@ bl_init(bl_t b, bool srv)
rv = connect(b->b_fd, (const void *)sun, (socklen_t)sizeof(*sun));
if (rv == 0) {
if (srv) {
- bl_log(b->b_fun, LOG_ERR,
+ bl_log(b, LOG_ERR,
"%s: another daemon is handling `%s'",
__func__, sun->sun_path);
goto out;
@@ -199,7 +208,7 @@ bl_init(bl_t b, bool srv)
* and only log once.
*/
if (b->b_connected != 1) {
- bl_log(b->b_fun, LOG_DEBUG,
+ bl_log(b, LOG_DEBUG,
"%s: connect failed for `%s' (%s)",
__func__, sun->sun_path, strerror(errno));
b->b_connected = 1;
@@ -207,8 +216,7 @@ bl_init(bl_t b, bool srv)
BL_UNLOCK(b);
return -1;
}
- bl_log(b->b_fun, LOG_DEBUG, "Connected to blacklist server",
- __func__);
+ bl_log(b, LOG_DEBUG, "Connected to blocklist server", __func__);
}
if (srv) {
@@ -219,8 +227,7 @@ bl_init(bl_t b, bool srv)
(void)umask(om);
errno = serrno;
if (rv == -1) {
- bl_log(b->b_fun, LOG_ERR,
- "%s: bind failed for `%s' (%s)",
+ bl_log(b, LOG_ERR, "%s: bind failed for `%s' (%s)",
__func__, sun->sun_path, strerror(errno));
goto out;
}
@@ -231,8 +238,8 @@ bl_init(bl_t b, bool srv)
#if defined(LOCAL_CREDS)
#define CRED_LEVEL 0
#define CRED_NAME LOCAL_CREDS
-#define CRED_SC_UID sc_euid
-#define CRED_SC_GID sc_egid
+#define CRED_SC_UID(x) (x)->sc_euid
+#define CRED_SC_GID(x) (x)->sc_egid
#define CRED_MESSAGE SCM_CREDS
#define CRED_SIZE SOCKCREDSIZE(NGROUPS_MAX)
#define CRED_TYPE struct sockcred
@@ -240,12 +247,21 @@ bl_init(bl_t b, bool srv)
#elif defined(SO_PASSCRED)
#define CRED_LEVEL SOL_SOCKET
#define CRED_NAME SO_PASSCRED
-#define CRED_SC_UID uid
-#define CRED_SC_GID gid
+#define CRED_SC_UID(x) (x)->uid
+#define CRED_SC_GID(x) (x)->gid
#define CRED_MESSAGE SCM_CREDENTIALS
#define CRED_SIZE sizeof(struct ucred)
#define CRED_TYPE struct ucred
#define GOT_CRED 2
+#elif defined(SO_RECVUCRED)
+#define CRED_LEVEL SOL_SOCKET
+#define CRED_NAME SO_RECVUCRED
+#define CRED_SC_UID(x) ucred_geteuid(x)
+#define CRED_SC_GID(x) ucred_getegid(x)
+#define CRED_MESSAGE SCM_UCRED
+#define CRED_SIZE ucred_size()
+#define CRED_TYPE ucred_t
+#define GOT_CRED 2
#else
#define GOT_CRED 0
/*
@@ -259,7 +275,7 @@ bl_init(bl_t b, bool srv)
#ifdef CRED_LEVEL
if (setsockopt(b->b_fd, CRED_LEVEL, CRED_NAME,
&one, (socklen_t)sizeof(one)) == -1) {
- bl_log(b->b_fun, LOG_ERR, "%s: setsockopt %s "
+ bl_log(b, LOG_ERR, "%s: setsockopt %s "
"failed (%s)", __func__, __STRING(CRED_NAME),
strerror(errno));
goto out;
@@ -275,12 +291,15 @@ out:
}
bl_t
-bl_create(bool srv, const char *path, void (*fun)(int, const char *, va_list))
+bl_create(bool srv, const char *path,
+ void (*fun)(int, struct syslog_data *, const char *, va_list))
{
+ static struct syslog_data sd = SYSLOG_DATA_INIT;
bl_t b = calloc(1, sizeof(*b));
if (b == NULL)
- goto out;
- b->b_fun = fun == NULL ? vsyslog : fun;
+ return NULL;
+ b->b_fun = fun;
+ b->b_syslog_data = sd;
b->b_fd = -1;
b->b_connected = -1;
BL_INIT(b);
@@ -295,11 +314,6 @@ bl_create(bool srv, const char *path, void (*fun)(int, const char *, va_list))
bl_init(b, srv);
return b;
-out:
- free(b);
- bl_log(fun, LOG_ERR, "%s: malloc failed (%s)", __func__,
- strerror(errno));
- return NULL;
}
void
@@ -327,7 +341,7 @@ bl_getsock(bl_t b, struct sockaddr_storage *ss, const struct sockaddr *sa,
family = AF_INET6;
break;
default:
- bl_log(b->b_fun, LOG_ERR, "%s: invalid socket len %u (%s)",
+ bl_log(b, LOG_ERR, "%s: invalid socket len %u (%s)",
__func__, (unsigned)slen, ctx);
errno = EINVAL;
return -1;
@@ -336,7 +350,7 @@ bl_getsock(bl_t b, struct sockaddr_storage *ss, const struct sockaddr *sa,
memcpy(ss, sa, slen);
if (ss->ss_family != family) {
- bl_log(b->b_fun, LOG_INFO,
+ bl_log(b, LOG_INFO,
"%s: correcting socket family %d to %d (%s)",
__func__, ss->ss_family, family, ctx);
ss->ss_family = family;
@@ -344,7 +358,7 @@ bl_getsock(bl_t b, struct sockaddr_storage *ss, const struct sockaddr *sa,
#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
if (ss->ss_len != slen) {
- bl_log(b->b_fun, LOG_INFO,
+ bl_log(b, LOG_INFO,
"%s: correcting socket len %u to %u (%s)",
__func__, ss->ss_len, (unsigned)slen, ctx);
ss->ss_len = (uint8_t)slen;
@@ -424,10 +438,11 @@ bl_recv(bl_t b)
union {
char ctrl[CMSG_SPACE(sizeof(int)) + CMSG_SPACE(CRED_SIZE)];
uint32_t fd;
- CRED_TYPE sc;
} ua;
struct cmsghdr *cmsg;
+#if GOT_CRED != 0
CRED_TYPE *sc;
+#endif
union {
bl_message_t bl;
char buf[512];
@@ -450,18 +465,18 @@ bl_recv(bl_t b)
msg.msg_flags = 0;
msg.msg_control = ua.ctrl;
- msg.msg_controllen = sizeof(ua.ctrl) + 100;
+ msg.msg_controllen = sizeof(ua.ctrl);
rlen = recvmsg(b->b_fd, &msg, 0);
if (rlen == -1) {
- bl_log(b->b_fun, LOG_ERR, "%s: recvmsg failed (%s)", __func__,
+ bl_log(b, LOG_ERR, "%s: recvmsg failed (%s)", __func__,
strerror(errno));
return NULL;
}
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
if (cmsg->cmsg_level != SOL_SOCKET) {
- bl_log(b->b_fun, LOG_ERR,
+ bl_log(b, LOG_ERR,
"%s: unexpected cmsg_level %d",
__func__, cmsg->cmsg_level);
continue;
@@ -469,10 +484,15 @@ bl_recv(bl_t b)
switch (cmsg->cmsg_type) {
case SCM_RIGHTS:
if (cmsg->cmsg_len != CMSG_LEN(sizeof(int))) {
- bl_log(b->b_fun, LOG_ERR,
+ int *fd = (void *)CMSG_DATA(cmsg);
+ size_t len = cmsg->cmsg_len / sizeof(int);
+ bl_log(b, LOG_ERR,
"%s: unexpected cmsg_len %d != %zu",
__func__, cmsg->cmsg_len,
- CMSG_LEN(2 * sizeof(int)));
+ CMSG_LEN(sizeof(int)));
+
+ for (size_t i = 0; i < len; i++)
+ (void)close(fd[i]);
continue;
}
memcpy(&bi->bi_fd, CMSG_DATA(cmsg), sizeof(bi->bi_fd));
@@ -481,13 +501,13 @@ bl_recv(bl_t b)
#ifdef CRED_MESSAGE
case CRED_MESSAGE:
sc = (void *)CMSG_DATA(cmsg);
- bi->bi_uid = sc->CRED_SC_UID;
- bi->bi_gid = sc->CRED_SC_GID;
+ bi->bi_uid = CRED_SC_UID(sc);
+ bi->bi_gid = CRED_SC_GID(sc);
got |= GOT_CRED;
break;
#endif
default:
- bl_log(b->b_fun, LOG_ERR,
+ bl_log(b, LOG_ERR,
"%s: unexpected cmsg_type %d",
__func__, cmsg->cmsg_type);
continue;
@@ -496,7 +516,7 @@ bl_recv(bl_t b)
}
if (got != (GOT_CRED|GOT_FD)) {
- bl_log(b->b_fun, LOG_ERR, "message missing %s %s",
+ bl_log(b, LOG_ERR, "message missing %s %s",
#if GOT_CRED != 0
(got & GOT_CRED) == 0 ? "cred" :
#endif
@@ -506,13 +526,13 @@ bl_recv(bl_t b)
rem = (size_t)rlen;
if (rem < sizeof(ub.bl)) {
- bl_log(b->b_fun, LOG_ERR, "message too short %zd", rlen);
+ bl_log(b, LOG_ERR, "message too short %zd", rlen);
return NULL;
}
rem -= sizeof(ub.bl);
if (ub.bl.bl_version != BL_VERSION) {
- bl_log(b->b_fun, LOG_ERR, "bad version %d", ub.bl.bl_version);
+ bl_log(b, LOG_ERR, "bad version %d", ub.bl.bl_version);
return NULL;
}
@@ -523,10 +543,12 @@ bl_recv(bl_t b)
bi->bi_uid = -1;
bi->bi_gid = -1;
#endif
- rem = MIN(sizeof(bi->bi_msg), rem);
if (rem == 0)
bi->bi_msg[0] = '\0';
- else
- strlcpy(bi->bi_msg, ub.bl.bl_data, rem);
+ else {
+ rem = MIN(sizeof(bi->bi_msg) - 1, rem);
+ memcpy(bi->bi_msg, ub.bl.bl_data, rem);
+ bi->bi_msg[rem] = '\0';
+ }
return bi;
}
diff --git a/contrib/blocklist/lib/blacklist.c b/contrib/blocklist/lib/blacklist.c
index ba376c3daf0d..12e5f83e09af 100644
--- a/contrib/blocklist/lib/blacklist.c
+++ b/contrib/blocklist/lib/blacklist.c
@@ -1,4 +1,4 @@
-/* $NetBSD: blacklist.c,v 1.5 2015/01/22 16:19:53 christos Exp $ */
+/* $NetBSD: blocklist.c,v 1.4 2025/02/11 17:48:30 christos Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -32,11 +32,13 @@
#include "config.h"
#endif
+#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
-__RCSID("$NetBSD: blacklist.c,v 1.5 2015/01/22 16:19:53 christos Exp $");
+#endif
+__RCSID("$NetBSD: blocklist.c,v 1.4 2025/02/11 17:48:30 christos Exp $");
#include <stdio.h>
-#include <bl.h>
+#include <old_bl.h>
#include <stdarg.h>
#include <errno.h>
@@ -98,7 +100,14 @@ blacklist_r(struct blacklist *bl, int action, int rfd, const char *msg)
struct blacklist *
blacklist_open(void) {
- return bl_create(false, NULL, vsyslog);
+ return bl_create(false, NULL, vsyslog_r);
+}
+
+struct blacklist *
+blacklist_open2(
+ void (*logger)(int, struct syslog_data *, const char *, va_list))
+{
+ return bl_create(false, NULL, logger);
}
void
diff --git a/contrib/blocklist/lib/blocklist.c b/contrib/blocklist/lib/blocklist.c
new file mode 100644
index 000000000000..139fc4342626
--- /dev/null
+++ b/contrib/blocklist/lib/blocklist.c
@@ -0,0 +1,117 @@
+/* $NetBSD: blocklist.c,v 1.4 2025/02/11 17:48:30 christos Exp $ */
+
+/*-
+ * Copyright (c) 2014 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+__RCSID("$NetBSD: blocklist.c,v 1.4 2025/02/11 17:48:30 christos Exp $");
+
+#include <stdio.h>
+#include <bl.h>
+
+#include <stdarg.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <syslog.h>
+
+int
+blocklist_sa(int action, int rfd, const struct sockaddr *sa, socklen_t salen,
+ const char *msg)
+{
+ struct blocklist *bl;
+ int rv;
+ if ((bl = blocklist_open()) == NULL)
+ return -1;
+ rv = blocklist_sa_r(bl, action, rfd, sa, salen, msg);
+ blocklist_close(bl);
+ return rv;
+}
+
+int
+blocklist_sa_r(struct blocklist *bl, int action, int rfd,
+ const struct sockaddr *sa, socklen_t slen, const char *msg)
+{
+ bl_type_t internal_action;
+
+ /* internal values are not the same as user application values */
+ switch (action) {
+ case BLOCKLIST_AUTH_FAIL:
+ internal_action = BL_ADD;
+ break;
+ case BLOCKLIST_AUTH_OK:
+ internal_action = BL_DELETE;
+ break;
+ case BLOCKLIST_ABUSIVE_BEHAVIOR:
+ internal_action = BL_ABUSE;
+ break;
+ case BLOCKLIST_BAD_USER:
+ internal_action = BL_BADUSER;
+ break;
+ default:
+ internal_action = BL_INVALID;
+ break;
+ }
+ return bl_send(bl, internal_action, rfd, sa, slen, msg);
+}
+
+int
+blocklist(int action, int rfd, const char *msg)
+{
+ return blocklist_sa(action, rfd, NULL, 0, msg);
+}
+
+int
+blocklist_r(struct blocklist *bl, int action, int rfd, const char *msg)
+{
+ return blocklist_sa_r(bl, action, rfd, NULL, 0, msg);
+}
+
+struct blocklist *
+blocklist_open(void) {
+ return bl_create(false, NULL, vsyslog_r);
+}
+
+struct blocklist *
+blocklist_open2(
+ void (*logger)(int, struct syslog_data *, const char *, va_list))
+{
+ return bl_create(false, NULL, logger);
+}
+
+void
+blocklist_close(struct blocklist *bl)
+{
+ bl_destroy(bl);
+}
diff --git a/contrib/blocklist/lib/libblacklist.3 b/contrib/blocklist/lib/libblacklist.3
index 146915c8dc31..5bc093c38f79 100644
--- a/contrib/blocklist/lib/libblacklist.3
+++ b/contrib/blocklist/lib/libblacklist.3
@@ -1,4 +1,4 @@
-.\" $NetBSD: libblacklist.3,v 1.10 2020/03/30 15:47:15 christos Exp $
+.\" $NetBSD: libblocklist.3,v 1.7 2025/02/05 20:14:30 christos Exp $
.\"
.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,11 +27,12 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd March 30, 2020
+.Dd February 5, 2025
.Dt LIBBLACKLIST 3
.Os
.Sh NAME
.Nm blacklist_open ,
+.Nm blacklist_open2 ,
.Nm blacklist_close ,
.Nm blacklist_r ,
.Nm blacklist ,
@@ -44,6 +45,8 @@
.In blacklist.h
.Ft struct blacklist *
.Fn blacklist_open "void"
+.Ft struct blacklist *
+.Fn blacklist_open2 "void (*logger)(int, struct syslog_data *, va_list)"
.Ft void
.Fn blacklist_close "struct blacklist *cookie"
.Ft int
@@ -68,6 +71,19 @@ and returns a pointer to it, or
.Dv NULL
on failure.
.Pp
+The function
+.Fn blacklist_open2
+is similar to
+.Fn blacklist_open
+but allows a
+.Fa logger
+to be specified.
+If the
+.Fa logger
+is
+.Dv NULL ,
+then no logging is performed.
+.Pp
The
.Fn blacklist_close
function frees all memory and resources used.
@@ -89,17 +105,17 @@ argument.
The
.Ar action
parameter can take these values:
-.Bl -tag -width ".Va BLACKLIST_ABUSIVE_BEHAVIOR"
-.It Va BLACKLIST_AUTH_FAIL
+.Bl -tag -width ".Dv BLACKLIST_ABUSIVE_BEHAVIOR"
+.It Dv BLACKLIST_AUTH_FAIL
There was an unsuccessful authentication attempt.
-.It Va BLACKLIST_AUTH_OK
+.It Dv BLACKLIST_AUTH_OK
A user successfully authenticated.
-.It Va BLACKLIST_ABUSIVE_BEHAVIOR
+.It Dv BLACKLIST_ABUSIVE_BEHAVIOR
The sending daemon has detected abusive behavior
from the remote system.
The remote address should
be blocked as soon as possible.
-.It Va BLACKLIST_BAD_USER
+.It Dv BLACKLIST_BAD_USER
The sending daemon has determined the username
presented for authentication is invalid.
The
@@ -108,7 +124,7 @@ daemon compares the username to a configured list of forbidden
usernames and
blocks the address immediately if a forbidden username matches.
(The
-.Ar BLACKLIST_BAD_USER
+.Dv BLACKLIST_BAD_USER
support is not currently available.)
.El
.Pp
@@ -160,6 +176,11 @@ on success and
on failure setting
.Dv errno
to an appropriate value.
+.Sh NOTES
+The
+.Lb libblacklist
+has been renamed to
+.Xr libblocklist 3 .
.Sh SEE ALSO
.Xr blacklistd.conf 5 ,
.Xr blacklistd 8
diff --git a/contrib/blocklist/lib/libblocklist.3 b/contrib/blocklist/lib/libblocklist.3
new file mode 100644
index 000000000000..fd6eb93eb756
--- /dev/null
+++ b/contrib/blocklist/lib/libblocklist.3
@@ -0,0 +1,183 @@
+.\" $NetBSD: libblocklist.3,v 1.7 2025/02/05 20:14:30 christos Exp $
+.\"
+.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Christos Zoulas.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd February 5, 2025
+.Dt LIBBLOCKLIST 3
+.Os
+.Sh NAME
+.Nm blocklist_open ,
+.Nm blocklist_open2 ,
+.Nm blocklist_close ,
+.Nm blocklist_r ,
+.Nm blocklist ,
+.Nm blocklist_sa ,
+.Nm blocklist_sa_r
+.Nd Blocklistd notification library
+.Sh LIBRARY
+.Lb libblocklist
+.Sh SYNOPSIS
+.In blocklist.h
+.Ft struct blocklist *
+.Fn blocklist_open "void"
+.Ft struct blocklist *
+.Fn blocklist_open2 "void (*logger)(int, struct syslog_data *, va_list)"
+.Ft void
+.Fn blocklist_close "struct blocklist *cookie"
+.Ft int
+.Fn blocklist "int action" "int fd" "const char *msg"
+.Ft int
+.Fn blocklist_r "struct blocklist *cookie" "int action" "int fd" "const char *msg"
+.Ft int
+.Fn blocklist_sa "int action" "int fd" "const struct sockaddr *sa" "socklen_t salen" "const char *msg"
+.Ft int
+.Fn blocklist_sa_r "struct blocklist *cookie" "int action" "int fd" "const struct sockaddr *sa" "socklen_t salen" "const char *msg"
+.Sh DESCRIPTION
+These functions can be used by daemons to notify
+.Xr blocklistd 8
+about successful and failed remote connections so that blocklistd can
+block or release port access to prevent Denial of Service attacks.
+.Pp
+The function
+.Fn blocklist_open
+creates the necessary state to communicate with
+.Xr blocklistd 8
+and returns a pointer to it, or
+.Dv NULL
+on failure.
+.Pp
+The function
+.Fn blocklist_open2
+is similar to
+.Fn blocklist_open
+but allows a
+.Fa logger
+to be specified.
+If the
+.Fa logger
+is
+.Dv NULL ,
+then no logging is performed.
+.Pp
+The
+.Fn blocklist_close
+function frees all memory and resources used.
+.Pp
+The
+.Fn blocklist
+function sends a message to
+.Xr blocklistd 8 ,
+with an integer
+.Ar action
+argument specifying the type of notification,
+a file descriptor
+.Ar fd
+specifying the accepted file descriptor connected to the client,
+and an optional message in the
+.Ar msg
+argument.
+.Pp
+The
+.Ar action
+parameter can take these values:
+.Bl -tag -width ".Dv BLOCKLIST_ABUSIVE_BEHAVIOR"
+.It Dv BLOCKLIST_AUTH_FAIL
+There was an unsuccessful authentication attempt.
+.It Dv BLOCKLIST_AUTH_OK
+A user successfully authenticated.
+.It Dv BLOCKLIST_ABUSIVE_BEHAVIOR
+The sending daemon has detected abusive behavior
+from the remote system.
+The remote address should
+be blocked as soon as possible.
+.It Dv BLOCKLIST_BAD_USER
+The sending daemon has determined the username
+presented for authentication is invalid.
+The
+.Xr blocklistd 8
+daemon compares the username to a configured list of forbidden
+usernames and
+blocks the address immediately if a forbidden username matches.
+(The
+.Dv BLOCKLIST_BAD_USER
+support is not currently available.)
+.El
+.Pp
+The
+.Fn blocklist_r
+function is more efficient because it keeps the blocklist state around.
+.Pp
+The
+.Fn blocklist_sa
+and
+.Fn blocklist_sa_r
+functions can be used with unconnected sockets, where
+.Xr getpeername 2
+will not work, the server will pass the peer name in the message.
+.Pp
+In all cases the file descriptor passed in the
+.Fa fd
+argument must be pointing to a valid socket so that
+.Xr blocklistd 8
+can establish ownership of the local endpoint
+using
+.Xr getsockname 2 .
+.Pp
+By default,
+.Xr syslogd 8
+is used for message logging.
+The internal
+.Fn bl_create
+function can be used to create the required internal
+state and specify a custom logging function.
+.Sh RETURN VALUES
+The function
+.Fn blocklist_open
+returns a cookie on success and
+.Dv NULL
+on failure setting
+.Dv errno
+to an appropriate value.
+.Pp
+The functions
+.Fn blocklist ,
+.Fn blocklist_sa ,
+and
+.Fn blocklist_sa_r
+return
+.Dv 0
+on success and
+.Dv \-1
+on failure setting
+.Dv errno
+to an appropriate value.
+.Sh SEE ALSO
+.Xr blocklistd.conf 5 ,
+.Xr blocklistd 8
+.Sh AUTHORS
+.An Christos Zoulas
diff --git a/contrib/blocklist/lib/old_bl.c b/contrib/blocklist/lib/old_bl.c
new file mode 100644
index 000000000000..ffbbd3f620ac
--- /dev/null
+++ b/contrib/blocklist/lib/old_bl.c
@@ -0,0 +1,554 @@
+/* $NetBSD: bl.c,v 1.9 2025/03/30 01:53:59 christos Exp $ */
+
+/*-
+ * Copyright (c) 2014 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+__RCSID("$NetBSD: bl.c,v 1.9 2025/03/30 01:53:59 christos Exp $");
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/un.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <syslog.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <netinet/in.h>
+#ifdef _REENTRANT
+#include <pthread.h>
+#endif
+
+#if defined(SO_RECVUCRED)
+#include <ucred.h>
+#endif
+
+#include "old_bl.h"
+
+typedef struct {
+ uint32_t bl_len;
+ uint32_t bl_version;
+ uint32_t bl_type;
+ uint32_t bl_salen;
+ struct sockaddr_storage bl_ss;
+ char bl_data[];
+} bl_message_t;
+
+struct blacklist {
+#ifdef _REENTRANT
+ pthread_mutex_t b_mutex;
+# define BL_INIT(b) pthread_mutex_init(&b->b_mutex, NULL)
+# define BL_LOCK(b) pthread_mutex_lock(&b->b_mutex)
+# define BL_UNLOCK(b) pthread_mutex_unlock(&b->b_mutex)
+#else
+# define BL_INIT(b) do {} while(/*CONSTCOND*/0)
+# define BL_LOCK(b) BL_INIT(b)
+# define BL_UNLOCK(b) BL_INIT(b)
+#endif
+ int b_fd;
+ int b_connected;
+ struct sockaddr_un b_sun;
+ struct syslog_data b_syslog_data;
+ void (*b_fun)(int, struct syslog_data *, const char *, va_list);
+ bl_info_t b_info;
+};
+
+#define BL_VERSION 1
+
+bool
+bl_isconnected(bl_t b)
+{
+ return b->b_connected == 0;
+}
+
+int
+bl_getfd(bl_t b)
+{
+ return b->b_fd;
+}
+
+static void
+bl_reset(bl_t b, bool locked)
+{
+ int serrno = errno;
+ if (!locked)
+ BL_LOCK(b);
+ close(b->b_fd);
+ errno = serrno;
+ b->b_fd = -1;
+ b->b_connected = -1;
+ if (!locked)
+ BL_UNLOCK(b);
+}
+
+static void
+bl_log(bl_t b, int level, const char *fmt, ...)
+{
+ va_list ap;
+ int serrno = errno;
+
+ if (b->b_fun == NULL)
+ return;
+
+ va_start(ap, fmt);
+ (*b->b_fun)(level, &b->b_syslog_data, fmt, ap);
+ va_end(ap);
+ errno = serrno;
+}
+
+static int
+bl_init(bl_t b, bool srv)
+{
+ static int one = 1;
+ /* AF_UNIX address of local logger */
+ mode_t om;
+ int rv, serrno;
+ struct sockaddr_un *sun = &b->b_sun;
+
+#ifndef SOCK_NONBLOCK
+#define SOCK_NONBLOCK 0
+#endif
+#ifndef SOCK_CLOEXEC
+#define SOCK_CLOEXEC 0
+#endif
+#ifndef SOCK_NOSIGPIPE
+#define SOCK_NOSIGPIPE 0
+#endif
+
+ BL_LOCK(b);
+
+ if (b->b_fd == -1) {
+ b->b_fd = socket(PF_LOCAL,
+ SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK|SOCK_NOSIGPIPE, 0);
+ if (b->b_fd == -1) {
+ bl_log(b, LOG_ERR, "%s: socket failed (%s)",
+ __func__, strerror(errno));
+ BL_UNLOCK(b);
+ return -1;
+ }
+#if SOCK_CLOEXEC == 0
+ fcntl(b->b_fd, F_SETFD, FD_CLOEXEC);
+#endif
+#if SOCK_NONBLOCK == 0
+ fcntl(b->b_fd, F_SETFL, fcntl(b->b_fd, F_GETFL) | O_NONBLOCK);
+#endif
+#if SOCK_NOSIGPIPE == 0
+#ifdef SO_NOSIGPIPE
+ int o = 1;
+ setsockopt(b->b_fd, SOL_SOCKET, SO_NOSIGPIPE, &o, sizeof(o));
+#else
+ signal(SIGPIPE, SIG_IGN);
+#endif
+#endif
+ }
+
+ if (bl_isconnected(b)) {
+ BL_UNLOCK(b);
+ return 0;
+ }
+
+ /*
+ * We try to connect anyway even when we are a server to verify
+ * that no other server is listening to the socket. If we succeed
+ * to connect and we are a server, someone else owns it.
+ */
+ rv = connect(b->b_fd, (const void *)sun, (socklen_t)sizeof(*sun));
+ if (rv == 0) {
+ if (srv) {
+ bl_log(b, LOG_ERR,
+ "%s: another daemon is handling `%s'",
+ __func__, sun->sun_path);
+ goto out;
+ }
+ } else {
+ if (!srv) {
+ /*
+ * If the daemon is not running, we just try a
+ * connect, so leave the socket alone until it does
+ * and only log once.
+ */
+ if (b->b_connected != 1) {
+ bl_log(b, LOG_DEBUG,
+ "%s: connect failed for `%s' (%s)",
+ __func__, sun->sun_path, strerror(errno));
+ b->b_connected = 1;
+ }
+ BL_UNLOCK(b);
+ return -1;
+ }
+ bl_log(b, LOG_DEBUG, "Connected to blacklist server", __func__);
+ }
+
+ if (srv) {
+ (void)unlink(sun->sun_path);
+ om = umask(0);
+ rv = bind(b->b_fd, (const void *)sun, (socklen_t)sizeof(*sun));
+ serrno = errno;
+ (void)umask(om);
+ errno = serrno;
+ if (rv == -1) {
+ bl_log(b, LOG_ERR, "%s: bind failed for `%s' (%s)",
+ __func__, sun->sun_path, strerror(errno));
+ goto out;
+ }
+ }
+
+ b->b_connected = 0;
+#define GOT_FD 1
+#if defined(LOCAL_CREDS)
+#define CRED_LEVEL 0
+#define CRED_NAME LOCAL_CREDS
+#define CRED_SC_UID(x) (x)->sc_euid
+#define CRED_SC_GID(x) (x)->sc_egid
+#define CRED_MESSAGE SCM_CREDS
+#define CRED_SIZE SOCKCREDSIZE(NGROUPS_MAX)
+#define CRED_TYPE struct sockcred
+#define GOT_CRED 2
+#elif defined(SO_PASSCRED)
+#define CRED_LEVEL SOL_SOCKET
+#define CRED_NAME SO_PASSCRED
+#define CRED_SC_UID(x) (x)->uid
+#define CRED_SC_GID(x) (x)->gid
+#define CRED_MESSAGE SCM_CREDENTIALS
+#define CRED_SIZE sizeof(struct ucred)
+#define CRED_TYPE struct ucred
+#define GOT_CRED 2
+#elif defined(SO_RECVUCRED)
+#define CRED_LEVEL SOL_SOCKET
+#define CRED_NAME SO_RECVUCRED
+#define CRED_SC_UID(x) ucred_geteuid(x)
+#define CRED_SC_GID(x) ucred_getegid(x)
+#define CRED_MESSAGE SCM_UCRED
+#define CRED_SIZE ucred_size()
+#define CRED_TYPE ucred_t
+#define GOT_CRED 2
+#else
+#define GOT_CRED 0
+/*
+ * getpeereid() and LOCAL_PEERCRED don't help here
+ * because we are not a stream socket!
+ */
+#define CRED_SIZE 0
+#define CRED_TYPE void * __unused
+#endif
+
+#ifdef CRED_LEVEL
+ if (setsockopt(b->b_fd, CRED_LEVEL, CRED_NAME,
+ &one, (socklen_t)sizeof(one)) == -1) {
+ bl_log(b, LOG_ERR, "%s: setsockopt %s "
+ "failed (%s)", __func__, __STRING(CRED_NAME),
+ strerror(errno));
+ goto out;
+ }
+#endif
+
+ BL_UNLOCK(b);
+ return 0;
+out:
+ bl_reset(b, true);
+ BL_UNLOCK(b);
+ return -1;
+}
+
+bl_t
+bl_create(bool srv, const char *path,
+ void (*fun)(int, struct syslog_data *, const char *, va_list))
+{
+ static struct syslog_data sd = SYSLOG_DATA_INIT;
+ bl_t b = calloc(1, sizeof(*b));
+ if (b == NULL)
+ return NULL;
+ b->b_fun = fun;
+ b->b_syslog_data = sd;
+ b->b_fd = -1;
+ b->b_connected = -1;
+ BL_INIT(b);
+
+ memset(&b->b_sun, 0, sizeof(b->b_sun));
+ b->b_sun.sun_family = AF_LOCAL;
+#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
+ b->b_sun.sun_len = sizeof(b->b_sun);
+#endif
+ strlcpy(b->b_sun.sun_path,
+ path ? path : _PATH_BLSOCK, sizeof(b->b_sun.sun_path));
+
+ bl_init(b, srv);
+ return b;
+}
+
+void
+bl_destroy(bl_t b)
+{
+ bl_reset(b, false);
+ free(b);
+}
+
+static int
+bl_getsock(bl_t b, struct sockaddr_storage *ss, const struct sockaddr *sa,
+ socklen_t slen, const char *ctx)
+{
+ uint8_t family;
+
+ memset(ss, 0, sizeof(*ss));
+
+ switch (slen) {
+ case 0:
+ return 0;
+ case sizeof(struct sockaddr_in):
+ family = AF_INET;
+ break;
+ case sizeof(struct sockaddr_in6):
+ family = AF_INET6;
+ break;
+ default:
+ bl_log(b, LOG_ERR, "%s: invalid socket len %u (%s)",
+ __func__, (unsigned)slen, ctx);
+ errno = EINVAL;
+ return -1;
+ }
+
+ memcpy(ss, sa, slen);
+
+ if (ss->ss_family != family) {
+ bl_log(b, LOG_INFO,
+ "%s: correcting socket family %d to %d (%s)",
+ __func__, ss->ss_family, family, ctx);
+ ss->ss_family = family;
+ }
+
+#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
+ if (ss->ss_len != slen) {
+ bl_log(b, LOG_INFO,
+ "%s: correcting socket len %u to %u (%s)",
+ __func__, ss->ss_len, (unsigned)slen, ctx);
+ ss->ss_len = (uint8_t)slen;
+ }
+#endif
+ return 0;
+}
+
+int
+bl_send(bl_t b, bl_type_t e, int pfd, const struct sockaddr *sa,
+ socklen_t slen, const char *ctx)
+{
+ struct msghdr msg;
+ struct iovec iov;
+ union {
+ char ctrl[CMSG_SPACE(sizeof(int))];
+ uint32_t fd;
+ } ua;
+ struct cmsghdr *cmsg;
+ union {
+ bl_message_t bl;
+ char buf[512];
+ } ub;
+ size_t ctxlen, tried;
+#define NTRIES 5
+
+ ctxlen = strlen(ctx);
+ if (ctxlen > 128)
+ ctxlen = 128;
+
+ iov.iov_base = ub.buf;
+ iov.iov_len = sizeof(bl_message_t) + ctxlen;
+ ub.bl.bl_len = (uint32_t)iov.iov_len;
+ ub.bl.bl_version = BL_VERSION;
+ ub.bl.bl_type = (uint32_t)e;
+
+ if (bl_getsock(b, &ub.bl.bl_ss, sa, slen, ctx) == -1)
+ return -1;
+
+
+ ub.bl.bl_salen = slen;
+ memcpy(ub.bl.bl_data, ctx, ctxlen);
+
+ msg.msg_name = NULL;
+ msg.msg_namelen = 0;
+ msg.msg_iov = &iov;
+ msg.msg_iovlen = 1;
+ msg.msg_flags = 0;
+
+ msg.msg_control = ua.ctrl;
+ msg.msg_controllen = sizeof(ua.ctrl);
+
+ cmsg = CMSG_FIRSTHDR(&msg);
+ cmsg->cmsg_len = CMSG_LEN(sizeof(int));
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+
+ memcpy(CMSG_DATA(cmsg), &pfd, sizeof(pfd));
+
+ tried = 0;
+again:
+ if (bl_init(b, false) == -1)
+ return -1;
+
+ if ((sendmsg(b->b_fd, &msg, 0) == -1) && tried++ < NTRIES) {
+ bl_reset(b, false);
+ goto again;
+ }
+ return tried >= NTRIES ? -1 : 0;
+}
+
+bl_info_t *
+bl_recv(bl_t b)
+{
+ struct msghdr msg;
+ struct iovec iov;
+ union {
+ char ctrl[CMSG_SPACE(sizeof(int)) + CMSG_SPACE(CRED_SIZE)];
+ uint32_t fd;
+ } ua;
+ struct cmsghdr *cmsg;
+#if GOT_CRED != 0
+ CRED_TYPE *sc;
+#endif
+ union {
+ bl_message_t bl;
+ char buf[512];
+ } ub;
+ int got;
+ ssize_t rlen;
+ size_t rem;
+ bl_info_t *bi = &b->b_info;
+
+ got = 0;
+ memset(bi, 0, sizeof(*bi));
+
+ iov.iov_base = ub.buf;
+ iov.iov_len = sizeof(ub);
+
+ msg.msg_name = NULL;
+ msg.msg_namelen = 0;
+ msg.msg_iov = &iov;
+ msg.msg_iovlen = 1;
+ msg.msg_flags = 0;
+
+ msg.msg_control = ua.ctrl;
+ msg.msg_controllen = sizeof(ua.ctrl);
+
+ rlen = recvmsg(b->b_fd, &msg, 0);
+ if (rlen == -1) {
+ bl_log(b, LOG_ERR, "%s: recvmsg failed (%s)", __func__,
+ strerror(errno));
+ return NULL;
+ }
+
+ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
+ if (cmsg->cmsg_level != SOL_SOCKET) {
+ bl_log(b, LOG_ERR,
+ "%s: unexpected cmsg_level %d",
+ __func__, cmsg->cmsg_level);
+ continue;
+ }
+ switch (cmsg->cmsg_type) {
+ case SCM_RIGHTS:
+ if (cmsg->cmsg_len != CMSG_LEN(sizeof(int))) {
+ int *fd = (void *)CMSG_DATA(cmsg);
+ size_t len = cmsg->cmsg_len / sizeof(int);
+ bl_log(b, LOG_ERR,
+ "%s: unexpected cmsg_len %d != %zu",
+ __func__, cmsg->cmsg_len,
+ CMSG_LEN(sizeof(int)));
+
+ for (size_t i = 0; i < len; i++)
+ (void)close(fd[i]);
+ continue;
+ }
+ memcpy(&bi->bi_fd, CMSG_DATA(cmsg), sizeof(bi->bi_fd));
+ got |= GOT_FD;
+ break;
+#ifdef CRED_MESSAGE
+ case CRED_MESSAGE:
+ sc = (void *)CMSG_DATA(cmsg);
+ bi->bi_uid = CRED_SC_UID(sc);
+ bi->bi_gid = CRED_SC_GID(sc);
+ got |= GOT_CRED;
+ break;
+#endif
+ default:
+ bl_log(b, LOG_ERR,
+ "%s: unexpected cmsg_type %d",
+ __func__, cmsg->cmsg_type);
+ continue;
+ }
+
+ }
+
+ if (got != (GOT_CRED|GOT_FD)) {
+ bl_log(b, LOG_ERR, "message missing %s %s",
+#if GOT_CRED != 0
+ (got & GOT_CRED) == 0 ? "cred" :
+#endif
+ "", (got & GOT_FD) == 0 ? "fd" : "");
+ return NULL;
+ }
+
+ rem = (size_t)rlen;
+ if (rem < sizeof(ub.bl)) {
+ bl_log(b, LOG_ERR, "message too short %zd", rlen);
+ return NULL;
+ }
+ rem -= sizeof(ub.bl);
+
+ if (ub.bl.bl_version != BL_VERSION) {
+ bl_log(b, LOG_ERR, "bad version %d", ub.bl.bl_version);
+ return NULL;
+ }
+
+ bi->bi_type = ub.bl.bl_type;
+ bi->bi_slen = ub.bl.bl_salen;
+ bi->bi_ss = ub.bl.bl_ss;
+#ifndef CRED_MESSAGE
+ bi->bi_uid = -1;
+ bi->bi_gid = -1;
+#endif
+ if (rem == 0)
+ bi->bi_msg[0] = '\0';
+ else {
+ rem = MIN(sizeof(bi->bi_msg) - 1, rem);
+ memcpy(bi->bi_msg, ub.bl.bl_data, rem);
+ bi->bi_msg[rem] = '\0';
+ }
+ return bi;
+}
diff --git a/contrib/blocklist/lib/shlib_version b/contrib/blocklist/lib/shlib_version
index 97c9f92d6b8f..3d7c908e43d6 100644
--- a/contrib/blocklist/lib/shlib_version
+++ b/contrib/blocklist/lib/shlib_version
@@ -1,2 +1,2 @@
major=0
-minor=0
+minor=1
diff --git a/contrib/blocklist/libexec/Makefile b/contrib/blocklist/libexec/Makefile
index 6537080bf465..619d962c23b2 100644
--- a/contrib/blocklist/libexec/Makefile
+++ b/contrib/blocklist/libexec/Makefile
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.1 2015/01/22 17:49:41 christos Exp $
+# $NetBSD: Makefile,v 1.1.1.1 2020/06/15 01:52:53 christos Exp $
-SCRIPTS= blacklistd-helper
+SCRIPTS= blocklistd-helper
SCRIPTSDIR= /libexec
.include <bsd.prog.mk>
diff --git a/contrib/blocklist/libexec/blacklistd-helper b/contrib/blocklist/libexec/blacklistd-helper
deleted file mode 100644
index f92eab8b29bd..000000000000
--- a/contrib/blocklist/libexec/blacklistd-helper
+++ /dev/null
@@ -1,134 +0,0 @@
-#!/bin/sh
-#echo "run $@" 1>&2
-#set -x
-# $1 command
-# $2 rulename
-# $3 protocol
-# $4 address
-# $5 mask
-# $6 port
-# $7 id
-
-pf=
-if [ -f "/etc/ipfw-blacklist.rc" ]; then
- pf="ipfw"
- . /etc/ipfw-blacklist.rc
- ipfw_offset=${ipfw_offset:-2000}
-fi
-
-if [ -z "$pf" ]; then
- for f in npf pf ipf; do
- if [ -f "/etc/$f.conf" ]; then
- pf="$f"
- break
- fi
- done
-fi
-
-if [ -z "$pf" ]; then
- echo "$0: Unsupported packet filter" 1>&2
- exit 1
-fi
-
-if [ -n "$3" ]; then
- proto="proto $3"
-fi
-
-if [ -n "$6" ]; then
- port="port $6"
-fi
-
-addr="$4"
-mask="$5"
-case "$4" in
-::ffff:*.*.*.*)
- if [ "$5" = 128 ]; then
- mask=32
- addr=${4#::ffff:}
- fi;;
-esac
-
-case "$1" in
-add)
- case "$pf" in
- ipf)
- /sbin/ipfstat -io | /sbin/ipf -I -f - >/dev/null 2>&1
- echo block in quick $proto from $addr/$mask to \
- any port=$6 head port$6 | \
- /sbin/ipf -I -f - -s >/dev/null 2>&1 && echo OK
- ;;
- ipfw)
- # use $ipfw_offset+$port for rule number
- rule=$(($ipfw_offset + $6))
- tname="port$6"
- /sbin/ipfw table $tname create type addr 2>/dev/null
- /sbin/ipfw -q table $tname add "$addr/$mask"
- # if rule number $rule does not already exist, create it
- /sbin/ipfw show $rule >/dev/null 2>&1 || \
- /sbin/ipfw add $rule drop $3 from \
- table"("$tname")" to any dst-port $6 >/dev/null && \
- echo OK
- ;;
- npf)
- /sbin/npfctl rule "$2" add block in final $proto from \
- "$addr/$mask" to any $port
- ;;
- pf)
- # if the filtering rule does not exist, create it
- /sbin/pfctl -a "$2/$6" -sr 2>/dev/null | \
- grep -q "<port$6>" || \
- echo "block in quick $proto from <port$6> to any $port" | \
- /sbin/pfctl -a "$2/$6" -f -
- # insert $ip/$mask into per-protocol/port anchored table
- /sbin/pfctl -qa "$2/$6" -t "port$6" -T add "$addr/$mask" && \
- /sbin/pfctl -qk "$addr" && echo OK
- ;;
- esac
- ;;
-rem)
- case "$pf" in
- ipf)
- /sbin/ipfstat -io | /sbin/ipf -I -f - >/dev/null 2>&1
- echo block in quick $proto from $addr/$mask to \
- any port=$6 head port$6 | \
- /sbin/ipf -I -r -f - -s >/dev/null 2>&1 && echo OK
- ;;
- ipfw)
- /sbin/ipfw table "port$6" delete "$addr/$mask" 2>/dev/null && \
- echo OK
- ;;
- npf)
- /sbin/npfctl rule "$2" rem-id "$7"
- ;;
- pf)
- /sbin/pfctl -qa "$2/$6" -t "port$6" -T delete "$addr/$mask" && \
- echo OK
- ;;
- esac
- ;;
-flush)
- case "$pf" in
- ipf)
- /sbin/ipf -Z -I -Fi -s > /dev/null && echo OK
- ;;
- ipfw)
- /sbin/ipfw table "port$6" flush 2>/dev/null && echo OK
- ;;
- npf)
- /sbin/npfctl rule "$2" flush
- ;;
- pf)
- # dynamically determine which anchors exist
- for anchor in $(/sbin/pfctl -a "$2" -s Anchors); do
- /sbin/pfctl -a $anchor -t "port${anchor##*/}" -T flush
- /sbin/pfctl -a $anchor -F rules
- done
- echo OK
- ;;
- esac
- ;;
-*)
- echo "$0: Unknown command '$1'" 1>&2
- exit 1
- ;;
-esac
diff --git a/contrib/blocklist/libexec/blocklistd-helper b/contrib/blocklist/libexec/blocklistd-helper
new file mode 100755
index 000000000000..14a192ee35ce
--- /dev/null
+++ b/contrib/blocklist/libexec/blocklistd-helper
@@ -0,0 +1,272 @@
+#!/bin/sh
+#echo "run $@" 1>&2
+#set -x
+# $1 command
+# $2 rulename
+# $3 protocol
+# $4 address
+# $5 mask
+# $6 port
+# $7 id
+
+pf=
+if [ -f "/etc/ipfw-blocklist.rc" ]; then
+ pf="ipfw"
+ . /etc/ipfw-blocklist.rc
+ ipfw_offset=${ipfw_offset:-2000}
+fi
+
+if [ -z "$pf" ]; then
+ for f in npf pf ipfilter ipfw; do
+ if [ -x /etc/rc.d/$f ]; then
+ if /etc/rc.d/$f status >/dev/null 2>&1; then
+ pf="$f"
+ break
+ fi
+ elif [ -f "/etc/$f.conf" ]; then
+ # xxx assume a config file means it can be enabled --
+ # and the first one wins!
+ pf="$f"
+ break
+ fi
+ done
+fi
+
+if [ -z "$pf" -a -x "/sbin/iptables" ]; then
+ pf="iptables"
+fi
+
+if [ -z "$pf" ]; then
+ echo "$0: Unsupported packet filter" 1>&2
+ exit 1
+fi
+
+flags=
+if [ -n "$3" ]; then
+ raw_proto="$3"
+ proto="proto $3"
+ if [ $3 = "tcp" ]; then
+ flags="flags S/SAFR"
+ fi
+fi
+
+if [ -n "$6" ]; then
+ raw_port="$6"
+ port="port $6"
+fi
+
+addr="$4"
+mask="$5"
+case "$4" in
+::ffff:*.*.*.*)
+ if [ "$5" = 128 ]; then
+ mask=32
+ addr=${4#::ffff:}
+ fi;;
+esac
+
+case "$1" in
+add)
+ case "$pf" in
+ ipfilter)
+ # N.B.: If you reload /etc/ipf.conf then you need to stop and
+ # restart blocklistd (and make sure blocklistd_flags="-r").
+ # This should normally already be implemented in
+ # /etc/rc.d/ipfilter, but if then not add the following lines to
+ # the end of the ipfilter_reload() function:
+ #
+ # if checkyesnox blocklistd; then
+ # /etc/rc.d/blocklistd restart
+ # fi
+ #
+ # XXX we assume the following rule is present in /etc/ipf.conf:
+ # (should we check? -- it probably cannot be added dynamically)
+ #
+ # block in proto tcp/udp from any to any head blocklistd
+ #
+ # where "blocklistd" is the default rulename (i.e. "$2")
+ #
+ # This rule can come before any rule that logs connections,
+ # etc., and should be followed by final rules such as:
+ #
+ # # log all as-yet unblocked incoming TCP connection
+ # # attempts
+ # log in proto tcp from any to any flags S/SAFR
+ # # last "pass" match wins for all non-blocked packets
+ # pass in all
+ # pass out all
+ #
+ # I.e. a "pass" rule which will be the final match and override
+ # the "block". This way the rules added by blocklistd will
+ # actually block packets, and prevent logging of them as
+ # connections, because they include the "quick" flag.
+ #
+ # N.b.: $port is not included/used in rules -- abusers are cut
+ # off completely from all services!
+ #
+ # Note RST packets are not returned for blocked SYN packets of
+ # active attacks, so the port will not appear to be closed.
+ # This will probably give away the fact that a firewall has been
+ # triggered to block connections, but it prevents generating
+ # extra outbound traffic, and it may also slow down the attacker
+ # somewhat.
+ #
+ # Note also that we don't block all packets, just new attempts
+ # to open connections (see $flags above). This allows us to do
+ # counterespionage against the attacker (or continue to make use
+ # of any other services that might be on the same subnet as the
+ # supposed attacker). However it does not kill any active
+ # connections -- we rely on the reporting daemon to do its own
+ # protection and cleanup.
+ #
+ # N.B.: The rule generated here must exactly match the
+ # corresponding rule generated for the "rem" command below!
+ #
+ echo block in log quick $proto \
+ from $addr/$mask to any $flags group $2 | \
+ /sbin/ipf -A -f - >/dev/null 2>&1 && echo OK
+ ;;
+
+ ipfw)
+ # use $ipfw_offset+$port for rule number
+ rule=$(($ipfw_offset + $6))
+ tname="port$6"
+ /sbin/ipfw table $tname create type addr 2>/dev/null
+ /sbin/ipfw -q table $tname add "$addr/$mask"
+ # if rule number $rule does not already exist, create it
+ /sbin/ipfw show $rule >/dev/null 2>&1 || \
+ /sbin/ipfw add $rule drop $3 from \
+ table"("$tname")" to any dst-port $6 >/dev/null && \
+ echo OK
+ ;;
+
+ iptables)
+ if ! /sbin/iptables --list "$2" >/dev/null 2>&1; then
+ /sbin/iptables --new-chain "$2"
+ fi
+ /sbin/iptables --append INPUT --proto "$raw_proto" \
+ --dport "$raw_port" --jump "$2"
+ /sbin/iptables --append "$2" --proto "$raw_proto" \
+ --source "$addr/$mask" --dport "$raw_port" --jump DROP
+ echo OK
+ ;;
+
+ npf)
+ /sbin/npfctl rule "$2" add block in final $proto from \
+ "$addr/$mask" to any $port
+ ;;
+
+ pf)
+ # if the filtering rule does not exist, create it
+ /sbin/pfctl -a "$2/$6" -sr 2>/dev/null | \
+ grep -q "<port$6>" || \
+ echo "block in quick $proto from <port$6> to any $port" | \
+ /sbin/pfctl -a "$2/$6" -f -
+ # insert $ip/$mask into per-protocol/port anchored table
+ /sbin/pfctl -qa "$2/$6" -t "port$6" -T add "$addr/$mask" && \
+ /sbin/pfctl -qk "$addr" && echo OK
+ ;;
+
+ esac
+ ;;
+rem)
+ case "$pf" in
+ ipfilter)
+ # N.B.: The rule generated here must exactly match the
+ # corresponding rule generated for the "add" command above!
+ #
+ echo block in log quick $proto \
+ from $addr/$mask to any $flags group $2 | \
+ /sbin/ipf -A -r -f - >/dev/null 2>&1 && echo OK
+ ;;
+
+ ipfw)
+ /sbin/ipfw table "port$6" delete "$addr/$mask" 2>/dev/null && \
+ echo OK
+ ;;
+
+ iptables)
+ if /sbin/iptables --list "$2" >/dev/null 2>&1; then
+ /sbin/iptables --delete "$2" --proto "$raw_proto" \
+ --source "$addr/$mask" --dport "$raw_port" \
+ --jump DROP
+ fi
+ echo OK
+ ;;
+
+ npf)
+ /sbin/npfctl rule "$2" rem-id "$7"
+ ;;
+
+ pf)
+ /sbin/pfctl -qa "$2/$6" -t "port$6" -T delete "$addr/$mask" && \
+ echo OK
+ ;;
+
+ esac
+ ;;
+flush)
+ case "$pf" in
+ ipfilter)
+ #
+ # N.B. WARNING: This is obviously not reentrant!
+ #
+ # First we flush all the rules from the inactive set, then we
+ # reload the ones that do not belong to the group "$2", and
+ # finally we swap the active and inactive rule sets.
+ #
+ /sbin/ipf -I -F a
+ #
+ # "ipf -I -F a" also flushes active accounting rules!
+ #
+ # Note that accounting rule groups are unique to accounting
+ # rules and have nothing to do with filter rules, though of
+ # course theoretically one could use the same group name for
+ # them too.
+ #
+ # In theory anyone using any such accounting rules should have a
+ # wrapper /etc/rc.conf.d/blocklistd script (and corresponding
+ # /etc/rc.conf.d/ipfilter script) that will record and
+ # consolidate the values accumulated by such accounting rules
+ # before they are flushed, since otherwise their counts will be
+ # lost forever.
+ #
+ /usr/sbin/ipfstat -io | fgrep -v "group $2" | \
+ /sbin/ipf -I -f - >/dev/null 2>&1
+ #
+ # This MUST be done last and separately as "-s" is executed
+ # _while_ the command arguments are being processed!
+ #
+ /sbin/ipf -s && echo OK
+ ;;
+
+ ipfw)
+ /sbin/ipfw table "port$6" flush 2>/dev/null && echo OK
+ ;;
+
+ iptables)
+ if /sbin/iptables --list "$2" >/dev/null 2>&1; then
+ /sbin/iptables --flush "$2"
+ fi
+ echo OK
+ ;;
+
+ npf)
+ /sbin/npfctl rule "$2" flush
+ ;;
+
+ pf)
+ # dynamically determine which anchors exist
+ for anchor in $(/sbin/pfctl -a "$2" -s Anchors 2> /dev/null); do
+ /sbin/pfctl -a "$anchor" -t "port${anchor##*/}" -T flush 2> /dev/null
+ /sbin/pfctl -a "$anchor" -F rules
+ done
+ echo OK
+ ;;
+ esac
+ ;;
+*)
+ echo "$0: Unknown command '$1'" 1>&2
+ exit 1
+ ;;
+esac
diff --git a/contrib/blocklist/port/Makefile.am b/contrib/blocklist/port/Makefile.am
index 43bf6c94b420..0e6085f9580f 100644
--- a/contrib/blocklist/port/Makefile.am
+++ b/contrib/blocklist/port/Makefile.am
@@ -1,25 +1,39 @@
#
ACLOCAL_AMFLAGS = -I m4
-lib_LTLIBRARIES = libblacklist.la
-include_HEADERS = ../include/blacklist.h
+lib_LTLIBRARIES = libblocklist.la
+include_HEADERS = $(srcdir)/../include/blocklist.h
-bin_PROGRAMS = blacklistd blacklistctl srvtest cltest
+exampledir = $(datarootdir)/examples
+example_DATA = $(srcdir)/../etc/blocklistd.conf $(srcdir)/../etc/npf.conf $(srcdir)/../etc/ipf.conf
-VPATH = ../bin:../lib:../test:../include
+sbin_PROGRAMS = blocklistd blocklistctl
+noinst_PROGRAMS = srvtest cltest
+libexec_SCRIPTS = $(srcdir)/../libexec/blocklistd-helper
-AM_CPPFLAGS = -I../include -DDOT="."
+man5_MANS = $(srcdir)/../bin/blocklistd.conf.5
+man8_MANS = $(srcdir)/../bin/blocklistd.8 $(srcdir)/../bin/blocklistctl.8
+
+VPATH = $(srcdir)/../port:$(srcdir)/../bin:$(srcdir)/../lib:$(srcdir)/../test:$(srcdir)/../include
+
+AM_CPPFLAGS = -I$(srcdir)/../include -DDOT="."
+AM_CPPFLAGS += -D_PATH_BLCONF=\"$(sysconfdir)/blocklistd.conf\"
+AM_CPPFLAGS += -D_PATH_BLCONTROL=\"$(libexecdir)/blocklistd-helper\"
+AM_CPPFLAGS += -D_PATH_BLSOCK=\"$(runstatedir)/blocklistd.sock\"
+AM_CPPFLAGS += -D_PATH_BLSTATE=\"$(localstatedir)/db/blocklistd.db\"
+AM_CPPFLAGS += -std=c99 -D_POSIX_C_SOURCE=200809L -D__EXTENSIONS__
+AM_CPPFLAGS += -D__BSD_VISIBLE=1
AM_CFLAGS = @WARNINGS@
-libblacklist_la_SOURCES = bl.c blacklist.c
-libblacklist_la_LDFLAGS = -no-undefined -version-info 0:0:0
-libblacklist_la_LIBADD = $(LTLIBOBJS)
+libblocklist_la_SOURCES = bl.c blocklist.c
+libblocklist_la_LDFLAGS = -no-undefined -version-info 0:0:0
+libblocklist_la_LIBADD = $(LTLIBOBJS)
SRCS = internal.c support.c run.c conf.c state.c
-blacklistd_SOURCES = blacklistd.c ${SRCS}
-blacklistd_LDADD = libblacklist.la
-blacklistctl_SOURCES = blacklistctl.c ${SRCS}
-blacklistctl_LDADD = libblacklist.la
+blocklistd_SOURCES = blocklistd.c ${SRCS}
+blocklistd_LDADD = libblocklist.la
+blocklistctl_SOURCES = blocklistctl.c ${SRCS}
+blocklistctl_LDADD = libblocklist.la
srvtest_SOURCES = srvtest.c ${SRCS}
-srvtest_LDADD = libblacklist.la
+srvtest_LDADD = libblocklist.la
cltest_SOURCES = cltest.c ${SRCS}
-cltest_LDADD = libblacklist.la
+cltest_LDADD = libblocklist.la
diff --git a/contrib/blocklist/port/_strtoi.h b/contrib/blocklist/port/_strtoi.h
index 4b2b4e80f0d8..f50eefd67ff1 100644
--- a/contrib/blocklist/port/_strtoi.h
+++ b/contrib/blocklist/port/_strtoi.h
@@ -1,4 +1,4 @@
-/* $NetBSD: _strtoi.h,v 1.1 2015/01/22 02:15:59 christos Exp $ */
+/* $NetBSD: _strtoi.h,v 1.1.1.1 2020/06/15 01:52:53 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
diff --git a/contrib/blocklist/port/configure.ac b/contrib/blocklist/port/configure.ac
index eef8065f060a..99ecf8732c93 100644
--- a/contrib/blocklist/port/configure.ac
+++ b/contrib/blocklist/port/configure.ac
@@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script.
-AC_INIT([blacklistd],[0.1],[christos@netbsd.com])
+AC_INIT([blocklistd],[0.1],[christos@netbsd.com])
AM_INIT_AUTOMAKE([subdir-objects foreign])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
@@ -7,9 +7,10 @@ AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AC_SUBST(WARNINGS)
+AC_SUBST(LINK_NTOA)
dnl Checks for programs.
-AC_PROG_CC_STDC
+AC_PROG_CC
AC_USE_SYSTEM_EXTENSIONS
AM_PROG_CC_C_O
AC_C_BIGENDIAN
@@ -18,18 +19,19 @@ AC_PROG_LN_S
LT_INIT([disable-static pic-only])
gl_VISIBILITY
dnl Checks for headers
-AC_HEADER_STDC
AC_HEADER_MAJOR
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(stdint.h fcntl.h stdint.h inttypes.h unistd.h)
AC_CHECK_HEADERS(sys/un.h sys/socket.h limits.h)
AC_CHECK_HEADERS(arpa/inet.h getopt.h err.h)
AC_CHECK_HEADERS(sys/types.h util.h sys/time.h time.h)
-AC_CHECK_HEADERS(netatalk/at.h net/if_dl.h db.h db_185.h)
+AC_CHECK_HEADERS(netatalk/at.h db.h db_185.h)
+AC_CHECK_HEADERS(sys/cdefs.h)
AC_CHECK_LIB(rt, clock_gettime)
AC_CHECK_LIB(db, __db185_open)
AC_CHECK_LIB(util, pidfile)
AC_CHECK_LIB(util, sockaddr_snprintf)
+AC_SEARCH_LIBS(__xnet_connect, socket)
AH_BOTTOM([
#ifndef __NetBSD__
@@ -82,7 +84,7 @@ dnl Checks for functions
AC_CHECK_FUNCS(strerror)
dnl Provide implementation of some required functions if necessary
-AC_REPLACE_FUNCS(strtoi sockaddr_snprintf popenve clock_gettime strlcpy strlcat getprogname fparseln fgetln pidfile)
+AC_REPLACE_FUNCS(strtoi sockaddr_snprintf popenve clock_gettime strlcpy strlcat getprogname fparseln fgetln pidfile vsyslog_r)
dnl See if we are cross-compiling
AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes)
diff --git a/contrib/blocklist/port/fgetln.c b/contrib/blocklist/port/fgetln.c
index a41a383a6653..006e19f5279f 100644
--- a/contrib/blocklist/port/fgetln.c
+++ b/contrib/blocklist/port/fgetln.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fgetln.c,v 1.1 2015/01/22 03:48:07 christos Exp $ */
+/* $NetBSD: fgetln.c,v 1.1.1.1 2020/06/15 01:52:54 christos Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
diff --git a/contrib/blocklist/port/fparseln.c b/contrib/blocklist/port/fparseln.c
index 5bfae54b9a9b..22850ea9e304 100644
--- a/contrib/blocklist/port/fparseln.c
+++ b/contrib/blocklist/port/fparseln.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fparseln.c,v 1.1 2015/01/22 03:48:07 christos Exp $ */
+/* $NetBSD: fparseln.c,v 1.2 2025/02/11 17:48:30 christos Exp $ */
/*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
@@ -27,9 +27,11 @@
#include "config.h"
#endif
+#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
+#endif
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: fparseln.c,v 1.1 2015/01/22 03:48:07 christos Exp $");
+__RCSID("$NetBSD: fparseln.c,v 1.2 2025/02/11 17:48:30 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
diff --git a/contrib/blocklist/port/pidfile.c b/contrib/blocklist/port/pidfile.c
index 4deb2349d20a..1dbbf510c4e3 100644
--- a/contrib/blocklist/port/pidfile.c
+++ b/contrib/blocklist/port/pidfile.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pidfile.c,v 1.2 2016/04/05 12:28:57 christos Exp $ */
+/* $NetBSD: pidfile.c,v 1.2 2025/02/11 17:48:30 christos Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -32,9 +32,11 @@
#include "config.h"
#endif
+#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
+#endif
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: pidfile.c,v 1.2 2016/04/05 12:28:57 christos Exp $");
+__RCSID("$NetBSD: pidfile.c,v 1.2 2025/02/11 17:48:30 christos Exp $");
#endif
#include <sys/param.h>
diff --git a/contrib/blocklist/port/popenve.c b/contrib/blocklist/port/popenve.c
index 20f6b5b86b68..bdff8cdc1de4 100644
--- a/contrib/blocklist/port/popenve.c
+++ b/contrib/blocklist/port/popenve.c
@@ -1,4 +1,4 @@
-/* $NetBSD: popenve.c,v 1.2 2015/01/22 03:10:50 christos Exp $ */
+/* $NetBSD: popenve.c,v 1.2 2025/02/11 17:48:30 christos Exp $ */
/*
* Copyright (c) 1988, 1993
@@ -36,12 +36,14 @@
#include "config.h"
#endif
+#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
+#endif
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 5/3/95";
#else
-__RCSID("$NetBSD: popenve.c,v 1.2 2015/01/22 03:10:50 christos Exp $");
+__RCSID("$NetBSD: popenve.c,v 1.2 2025/02/11 17:48:30 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
diff --git a/contrib/blocklist/port/port.h b/contrib/blocklist/port/port.h
index f82fb34b40f5..d1a9ac6bd6e5 100644
--- a/contrib/blocklist/port/port.h
+++ b/contrib/blocklist/port/port.h
@@ -1,6 +1,7 @@
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
+#include <sys/param.h>
#include <stdio.h>
#include <inttypes.h>
#include <time.h>
@@ -15,6 +16,22 @@
#define __dead __attribute__((__noreturn__))
#endif
+#ifndef __BEGIN_DECLS
+#define __BEGIN_DECLS
+#endif
+
+#ifndef __END_DECLS
+#define __END_DECLS
+#endif
+
+#ifndef MIN
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif
+
+#ifndef MAX
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
+
#ifndef __RCSID
#define __RCSID(a)
#endif
@@ -27,6 +44,10 @@
#define __arraycount(a) (sizeof(a) / sizeof(a[0]))
#endif
+#ifndef __STRING
+#define __STRING(x) #x
+#endif
+
#ifndef HAVE_STRLCPY
size_t strlcpy(char *, const char *, size_t);
#endif
@@ -78,9 +99,10 @@ int clock_gettime(int, struct timespec *);
#define CLOCK_REALTIME 0
#endif
-#if !defined(__FreeBSD__)
-#define _PATH_BLCONF "conf"
-#define _PATH_BLCONTROL "control"
-#define _PATH_BLSOCK "blacklistd.sock"
-#define _PATH_BLSTATE "blacklistd.db"
+#ifndef HAVE_VSYSLOG_R
+#define SYSLOG_DATA_INIT { 0 }
+struct syslog_data {
+ int dummy;
+};
+void vsyslog_r(int, struct syslog_data *, const char *, va_list);
#endif
diff --git a/contrib/blocklist/port/sockaddr_snprintf.c b/contrib/blocklist/port/sockaddr_snprintf.c
index 558755b6294b..a37eded14a88 100644
--- a/contrib/blocklist/port/sockaddr_snprintf.c
+++ b/contrib/blocklist/port/sockaddr_snprintf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sockaddr_snprintf.c,v 1.11 2016/06/01 22:57:51 christos Exp $ */
+/* $NetBSD: sockaddr_snprintf.c,v 1.2 2025/02/11 17:48:30 christos Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -32,9 +32,11 @@
#include "config.h"
#endif
+#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
+#endif
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: sockaddr_snprintf.c,v 1.11 2016/06/01 22:57:51 christos Exp $");
+__RCSID("$NetBSD: sockaddr_snprintf.c,v 1.2 2025/02/11 17:48:30 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
diff --git a/contrib/blocklist/port/strlcat.c b/contrib/blocklist/port/strlcat.c
index d3c69b5fab78..8cabd654e6b0 100644
--- a/contrib/blocklist/port/strlcat.c
+++ b/contrib/blocklist/port/strlcat.c
@@ -1,4 +1,4 @@
-/* $NetBSD: strlcat.c,v 1.2 2015/01/22 03:48:07 christos Exp $ */
+/* $NetBSD: strlcat.c,v 1.2 2025/02/11 17:48:30 christos Exp $ */
/* $OpenBSD: strlcat.c,v 1.10 2003/04/12 21:56:39 millert Exp $ */
/*
@@ -22,9 +22,12 @@
#include "config.h"
#endif
+#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
+#endif
+
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: strlcat.c,v 1.2 2015/01/22 03:48:07 christos Exp $");
+__RCSID("$NetBSD: strlcat.c,v 1.2 2025/02/11 17:48:30 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#ifdef _LIBC
diff --git a/contrib/blocklist/port/strlcpy.c b/contrib/blocklist/port/strlcpy.c
index 6646e1ce9696..3de72a640c59 100644
--- a/contrib/blocklist/port/strlcpy.c
+++ b/contrib/blocklist/port/strlcpy.c
@@ -1,4 +1,4 @@
-/* $NetBSD: strlcpy.c,v 1.2 2015/01/22 03:48:07 christos Exp $ */
+/* $NetBSD: strlcpy.c,v 1.2 2025/02/11 17:48:30 christos Exp $ */
/* $OpenBSD: strlcpy.c,v 1.7 2003/04/12 21:56:39 millert Exp $ */
/*
@@ -22,9 +22,12 @@
#include "config.h"
#endif
+#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
+#endif
+
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: strlcpy.c,v 1.2 2015/01/22 03:48:07 christos Exp $");
+__RCSID("$NetBSD: strlcpy.c,v 1.2 2025/02/11 17:48:30 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#ifdef _LIBC
diff --git a/contrib/blocklist/port/strtoi.c b/contrib/blocklist/port/strtoi.c
index 5514f1a00a32..b0bed7058cc3 100644
--- a/contrib/blocklist/port/strtoi.c
+++ b/contrib/blocklist/port/strtoi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: strtoi.c,v 1.3 2015/01/22 03:10:50 christos Exp $ */
+/* $NetBSD: strtoi.c,v 1.2 2025/02/11 17:48:31 christos Exp $ */
/*-
* Copyright (c) 2005 The DragonFly Project. All rights reserved.
@@ -33,8 +33,10 @@
#include "config.h"
#endif
+#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
-__RCSID("$NetBSD: strtoi.c,v 1.3 2015/01/22 03:10:50 christos Exp $");
+#endif
+__RCSID("$NetBSD: strtoi.c,v 1.2 2025/02/11 17:48:31 christos Exp $");
#if defined(_KERNEL)
#include <sys/param.h>
diff --git a/contrib/blocklist/port/vsyslog_r.c b/contrib/blocklist/port/vsyslog_r.c
new file mode 100644
index 000000000000..848f31b04453
--- /dev/null
+++ b/contrib/blocklist/port/vsyslog_r.c
@@ -0,0 +1,13 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <syslog.h>
+#include <stdarg.h>
+
+void
+vsyslog_r(int priority, struct syslog_data *sd __unused, const char *fmt, va_list ap)
+{
+ vsyslog(priority, fmt, ap);
+}
+
diff --git a/contrib/blocklist/test/Makefile b/contrib/blocklist/test/Makefile
index a451274def06..d127955acdb7 100644
--- a/contrib/blocklist/test/Makefile
+++ b/contrib/blocklist/test/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.3 2015/05/30 22:40:38 christos Exp $
+# $NetBSD: Makefile,v 1.1.1.1 2020/06/15 01:52:54 christos Exp $
MKMAN=no
diff --git a/contrib/blocklist/test/cltest.c b/contrib/blocklist/test/cltest.c
index 6671429fc3c4..dc77a522bad8 100644
--- a/contrib/blocklist/test/cltest.c
+++ b/contrib/blocklist/test/cltest.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cltest.c,v 1.6 2015/01/22 05:44:28 christos Exp $ */
+/* $NetBSD: cltest.c,v 1.2 2025/02/11 17:48:31 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -32,8 +32,10 @@
#include "config.h"
#endif
+#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
-__RCSID("$NetBSD: cltest.c,v 1.6 2015/01/22 05:44:28 christos Exp $");
+#endif
+__RCSID("$NetBSD: cltest.c,v 1.2 2025/02/11 17:48:31 christos Exp $");
#include <sys/types.h>
#include <sys/socket.h>
diff --git a/contrib/blocklist/test/srvtest.c b/contrib/blocklist/test/srvtest.c
index 03a762ab81f2..4eb9468ed5fd 100644
--- a/contrib/blocklist/test/srvtest.c
+++ b/contrib/blocklist/test/srvtest.c
@@ -1,4 +1,4 @@
-/* $NetBSD: srvtest.c,v 1.10 2015/05/30 22:40:38 christos Exp $ */
+/* $NetBSD: srvtest.c,v 1.2 2025/02/11 17:43:16 christos Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -32,8 +32,10 @@
#include "config.h"
#endif
+#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
-__RCSID("$NetBSD: srvtest.c,v 1.10 2015/05/30 22:40:38 christos Exp $");
+#endif
+__RCSID("$NetBSD: srvtest.c,v 1.2 2025/02/11 17:43:16 christos Exp $");
#include <sys/types.h>
#include <sys/socket.h>
@@ -48,7 +50,7 @@ __RCSID("$NetBSD: srvtest.c,v 1.10 2015/05/30 22:40:38 christos Exp $");
#include <poll.h>
#include <err.h>
-#include "blacklist.h"
+#include "blocklist.h"
#ifdef BLDEBUG
#include "bl.h"
static void *b;
@@ -71,9 +73,9 @@ process_tcp(int afd)
buffer[sizeof(buffer) - 1] = '\0';
printf("%s: sending %d %s\n", getprogname(), afd, buffer);
#ifdef BLDEBUG
- blacklist_r(b, 1, afd, buffer);
+ blocklist_r(b, 1, afd, buffer);
#else
- blacklist(1, afd, buffer);
+ blocklist(1, afd, buffer);
#endif
exit(0);
}
@@ -95,7 +97,7 @@ process_udp(int afd)
err(1, "recvfrom");
buffer[sizeof(buffer) - 1] = '\0';
printf("%s: sending %d %s\n", getprogname(), afd, buffer);
- blacklist_sa(1, afd, (void *)&ss, slen, buffer);
+ blocklist_sa(1, afd, (void *)&ss, slen, buffer);
exit(0);
}
static int
@@ -167,7 +169,11 @@ static __dead void
usage(int c)
{
warnx("Unknown option `%c'", (char)c);
- fprintf(stderr, "Usage: %s [-u] [-p <num>]\n", getprogname());
+ fprintf(stderr, "Usage: %s [-u] [-p <num>]"
+#ifdef BLDEBUG
+ " [-s <sockpath>]"
+#endif
+ "\n", getprogname());
exit(EXIT_FAILURE);
}
@@ -182,14 +188,16 @@ main(int argc, char *argv[])
struct pollfd pfd[NUMFD];
int type = SOCK_STREAM, c;
in_port_t port = 6161;
-
- signal(SIGCHLD, SIG_IGN);
-
#ifdef BLDEBUG
- b = bl_create(false, "blsock", vsyslog);
+ char *sockpath = "blsock";
+ const char *optstr = "up:s:";
+#else
+ const char *optstr = "up:";
#endif
- while ((c = getopt(argc, argv, "up:")) != -1)
+ signal(SIGCHLD, SIG_IGN);
+
+ while ((c = getopt(argc, argv, optstr)) != -1)
switch (c) {
case 'u':
type = SOCK_DGRAM;
@@ -197,10 +205,20 @@ main(int argc, char *argv[])
case 'p':
port = (in_port_t)atoi(optarg);
break;
+#ifdef BLDEBUG
+ case 's':
+ sockpath = (char *)optarg;
+ break;
+#endif
default:
usage(c);
}
+#ifdef BLDEBUG
+ b = bl_create(false, sockpath, vsyslog_r);
+#endif
+
+
pfd[0].fd = cr(AF_INET, type, port);
pfd[0].events = POLLIN;
#if NUMFD > 1
diff --git a/contrib/bsddialog/.gitignore b/contrib/bsddialog/.gitignore
index c8fc68ed8a0e..c9613d477f7f 100644
--- a/contrib/bsddialog/.gitignore
+++ b/contrib/bsddialog/.gitignore
@@ -21,6 +21,7 @@ examples_library/msgbox
examples_library/pause
examples_library/radiolist
examples_library/rangebox
+examples_library/textbox
examples_library/theme
examples_library/timebox
examples_library/yesno
diff --git a/contrib/bsddialog/CHANGELOG b/contrib/bsddialog/CHANGELOG
index a4cf4d01c077..7800098644d7 100644
--- a/contrib/bsddialog/CHANGELOG
+++ b/contrib/bsddialog/CHANGELOG
@@ -1,11 +1,57 @@
-2024-07-01 1.0.4
+2025-06-22 Version 1.0.5
+
+ Manual:
+ * fix: "User-friendly documentation for alternate screen"
+ https://bugs.freebsd.org/285459.
+ Improve bsddialog.1: --alternate-screen and --normal-screen.
+
+ NetBSD (tested on amd64) refactoring, no function changes:
+ * https://gitlab.com/alfix/bsddialog/-/merge_requests/4
+ lib: include <stdarg.h> in lib_util.c.
+ * https://gitlab.com/alfix/bsddialog/-/merge_requests/5
+ a call to curses' refresh() is performed, while a local
+ variable is also called refresh.
+ * Makefiles: add install and uninstall targets (both GND and BSD)
+ https://gitlab.com/alfix/bsddialog/-/merge_requests/3
+
+ MacOS (tested on amd64) refactoring, no function changes:
+ * https://gitlab.com/alfix/bsddialog/-/merge_requests/6
+ utility: replace u_int with unsigned int.
+
+ Library:
+ * fix: useless refreshes, https://gitlab.com/alfix/bsddialog/-/issues/8:
+ "It takes lot of time when running over a 115200 UART".
+ Not fixed for bsddialog_gauge() because it has to be rewritten.
+ * change: bsddialog_backtitle() does not update the screen so the
+ backtitle is not printed. To use if a dialog is built later.
+ Rationale: see "115200 UART" problem above.
+ * add: bsddialog_backtitle_rf() to print a top title refreshing the
+ screen like bsddialog_backtitle() was previously.
+ * change: forms, ENTER is also a navigation keys in forms fields.
+ Request: https://bugs.freebsd.org/287592
+ If conf.button.always_active is true the form is closes immediatly.
+
+ Library and implicitly utility:
+ * fix: textbox buttons returned values (was always OK).
+ Thanks to https://reviews.freebsd.org/D48668.
+ * change: TAB is a navigation keys in forms. Previously it directly
+ switched form-fields <-> buttons.
+ Request: https://bugs.freebsd.org/287592
+
+ Utility:
+ * change: forms, ENTER is a also navigation keys in forms fields.
+ Previously it directly closed the form except with --switch-buttons
+ Request: https://bugs.freebsd.org/287592
+
+
+2024-07-01 Version 1.0.4
Utility internal refactoring (no functional change):
* change: rename an internal constant to avoid a future conflict
because FreeBSD is changing headers files for _FORTIFY_SOURCE.
Reported and fixed by Kyle Evans.
-2024-05-27 1.0.3
+2024-05-27 Version 1.0.3
Utility:
change: --form and --mixedform do not print field value to output fd if
diff --git a/contrib/bsddialog/LICENSE b/contrib/bsddialog/LICENSE
index 7b36a8dce42e..9ea4a4a62f4b 100644
--- a/contrib/bsddialog/LICENSE
+++ b/contrib/bsddialog/LICENSE
@@ -1,6 +1,6 @@
BSD 2-Clause License
-Copyright (c) 2021-2024, Alfonso Sabato Siciliano
+Copyright (c) 2021-2025, Alfonso Sabato Siciliano
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
diff --git a/contrib/bsddialog/Makefile b/contrib/bsddialog/Makefile
index a6af8813a48e..335b693470e6 100644
--- a/contrib/bsddialog/Makefile
+++ b/contrib/bsddialog/Makefile
@@ -4,7 +4,7 @@
# Written in 2023 by Alfonso Sabato Siciliano
OUTPUT = bsddialog
-export VERSION=1.0.4
+export VERSION=1.0.5
.CURDIR ?= ${CURDIR}
LIBPATH = ${.CURDIR}/lib
LIBBSDDIALOG = ${LIBPATH}/libbsddialog.so
@@ -22,7 +22,15 @@ DEBUG ?=
export ENABLEDEBUG=${DEBUG}
###################
-all : ${OUTPUT}
+all: ${OUTPUT}
+
+install: all
+ ${MAKE} -C ${LIBPATH} install
+ ${MAKE} -C ${UTILITYPATH} install
+
+uninstall:
+ ${MAKE} -C ${UTILITYPATH} uninstall
+ ${MAKE} -C ${LIBPATH} uninstall
${OUTPUT}: ${LIBBSDDIALOG}
${MAKE} -C ${UTILITYPATH} LIBPATH=${LIBPATH}
@@ -36,3 +44,4 @@ clean:
${MAKE} -C ${UTILITYPATH} clean
${RM} ${OUTPUT} *.core
+.PHONY: all install uninstall clean
diff --git a/contrib/bsddialog/README.md b/contrib/bsddialog/README.md
index 7b9b6cf8e84d..5a25109775fe 100644
--- a/contrib/bsddialog/README.md
+++ b/contrib/bsddialog/README.md
@@ -1,4 +1,4 @@
-# BSDDialog 1.0.4
+# BSDDialog 1.0.5
This project provides **bsddialog** and **libbsddialog**, an utility
and a library to build scripts and tools with TUI dialogs and widgets.
@@ -129,7 +129,6 @@ in the _Public Domain_ to build new projects:
- implement global buttons handler.
- doc: external tutorial, theming guide.
- implement menutype.min\_on.
- - improve refresh at startup, avoid dialog refresh before drawing text.
- add debug API: bsddialog\_debug(y,x,refresh,"fmt",...).
- add mouse support.
- use alarm(2) for bsddialog\_pause.
@@ -139,4 +138,4 @@ in the _Public Domain_ to build new projects:
- fix --mixedform "" 0 0 0 Label 1 0 Init 1 12 0 0 2 (with 0 editable field).
- add *text* customization to --hmsg *help-message*
- check --passwordform *fieldlen* like --form and --mixedform.
-
+ - add manuals to Makefiles installe and uninstall targets.
diff --git a/contrib/bsddialog/examples_library/compile b/contrib/bsddialog/examples_library/compile
index 9025f35426d9..1a68313090f6 100755
--- a/contrib/bsddialog/examples_library/compile
+++ b/contrib/bsddialog/examples_library/compile
@@ -8,14 +8,16 @@
# worldwide. This software is distributed without any warranty, see:
# <http://creativecommons.org/publicdomain/zero/1.0/>.
+set -x
+
libpath=../lib
examples="menu checklist radiolist mixedlist theme infobox yesno msgbox \
- datebox form timebox rangebox pause calendar gauge mixedgauge"
+datebox form timebox rangebox pause calendar gauge mixedgauge textbox"
rm -f $examples
for e in $examples
do
- cc -g -Wall -Wextra -I$libpath ${e}.c -o $e -L$libpath -lbsddialog \
- -Wl,-rpath=$libpath
+ cc -g -Wall -Wextra -I$libpath ${e}.c -o $e \
+ -Wl,-rpath=$libpath -L$libpath -lbsddialog
done
diff --git a/contrib/bsddialog/examples_library/textbox.c b/contrib/bsddialog/examples_library/textbox.c
new file mode 100644
index 000000000000..2e76cbb97891
--- /dev/null
+++ b/contrib/bsddialog/examples_library/textbox.c
@@ -0,0 +1,38 @@
+/*-
+ * SPDX-License-Identifier: CC0-1.0
+ *
+ * Written in 2025 by Alfonso Sabato Siciliano.
+ * To the extent possible under law, the author has dedicated all copyright
+ * and related and neighboring rights to this software to the public domain
+ * worldwide. This software is distributed without any warranty, see:
+ * <http://creativecommons.org/publicdomain/zero/1.0/>.
+ */
+
+#include <bsddialog.h>
+#include <stdio.h>
+
+int main()
+{
+ int output;
+ struct bsddialog_conf conf;
+
+ if (bsddialog_init() == BSDDIALOG_ERROR) {
+ printf("Error: %s\n", bsddialog_geterror());
+ return (1);
+ }
+ bsddialog_initconf(&conf);
+ conf.title = "textbox";
+ output = bsddialog_textbox(&conf, "./textbox.c", 20, 80);
+ bsddialog_end();
+
+ switch (output) {
+ case BSDDIALOG_ERROR:
+ printf("Error %s\n", bsddialog_geterror());
+ return (1);
+ case BSDDIALOG_OK:
+ printf("[Exit]\n");
+ break;
+ }
+
+ return (0);
+}
diff --git a/contrib/bsddialog/lib/GNUmakefile b/contrib/bsddialog/lib/GNUmakefile
index 7c7a9bc25ee4..2cb060381a46 100644
--- a/contrib/bsddialog/lib/GNUmakefile
+++ b/contrib/bsddialog/lib/GNUmakefile
@@ -9,6 +9,7 @@ HEADERS = bsddialog.h bsddialog_theme.h bsddialog_progressview.h
SOURCES = barbox.c datebox.c formbox.c libbsddialog.c lib_util.c \
menubox.c messagebox.c textbox.c theme.c timebox.c
OBJECTS = $(SOURCES:.c=.o)
+PREFIX = /usr/local
ifneq ($(ENABLEDEBUG),)
CFLAGS += -g
@@ -21,7 +22,21 @@ LIBFLAG = -shared
RM = rm -f
LN = ln -s -f
-all : $(LIBRARY)
+all: $(LIBRARY)
+
+install: all
+ ${INSTALL} -m 0644 bsddialog.h ${DESTDIR}${PREFIX}/include/bsddialog.h
+ ${INSTALL} -m 0644 bsddialog_progressview.h ${DESTDIR}${PREFIX}/include/bsddialog_progressview.h
+ ${INSTALL} -m 0644 bsddialog_theme.h ${DESTDIR}${PREFIX}/include/bsddialog_theme.h
+ ${INSTALL} -m 0755 ${LIBRARY_SO}.${VERSION} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO}.${VERSION}
+ ${LN} ${LIBRARY_SO}.${VERSION} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO}
+
+uninstall:
+ ${RM} ${DESTDIR}${PREFIX}/include/bsddialog.h
+ ${RM} ${DESTDIR}${PREFIX}/include/bsddialog_progressview.h
+ ${RM} ${DESTDIR}${PREFIX}/include/bsddialog_theme.h
+ ${RM} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO}.${VERSION}
+ ${RM} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO}
$(LIBRARY): $(OBJECTS)
$(CC) $(LIBFLAG) $^ -o $(LIBRARY_SO).$(VERSION) $(LDFLAGS)
@@ -32,3 +47,5 @@ $(LIBRARY): $(OBJECTS)
clean:
$(RM) $(LIBRARY_SO)* *.o *~
+
+.PHONY: all install uninstall ${LIBRARY} clean
diff --git a/contrib/bsddialog/lib/Makefile b/contrib/bsddialog/lib/Makefile
index 252b33f79848..c728541a9f7a 100644
--- a/contrib/bsddialog/lib/Makefile
+++ b/contrib/bsddialog/lib/Makefile
@@ -10,6 +10,7 @@ HEADERS = bsddialog.h bsddialog_theme.h bsddialog_progressview.h
SOURCES = barbox.c datebox.c formbox.c libbsddialog.c lib_util.c \
menubox.c messagebox.c textbox.c theme.c timebox.c
OBJECTS = ${SOURCES:.c=.o}
+PREFIX = /usr/local
.if defined(DEBUG)
CFLAGS += -g
@@ -23,7 +24,23 @@ LDFLAGS += -fstack-protector-strong -shared -Wl,-x -Wl,--fatal-warnings \
LN = ln -s -f
RM = rm -f
-all : ${LIBRARY}
+all: ${LIBRARY}
+
+install: all
+ ${INSTALL} -m 0644 bsddialog.h ${DESTDIR}${PREFIX}/include/bsddialog.h
+ ${INSTALL} -m 0644 bsddialog_progressview.h ${DESTDIR}${PREFIX}/include/bsddialog_progressview.h
+ ${INSTALL} -m 0644 bsddialog_theme.h ${DESTDIR}${PREFIX}/include/bsddialog_theme.h
+ ${INSTALL} -m 0644 ${LIBRARY_A} ${DESTDIR}${PREFIX}/lib/${LIBRARY_A}
+ ${INSTALL} -m 0755 ${LIBRARY_SO}.${VERSION} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO}.${VERSION}
+ ${LN} ${LIBRARY_SO}.${VERSION} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO}
+
+uninstall:
+ ${RM} ${DESTDIR}${PREFIX}/include/bsddialog.h
+ ${RM} ${DESTDIR}${PREFIX}/include/bsddialog_progressview.h
+ ${RM} ${DESTDIR}${PREFIX}/include/bsddialog_theme.h
+ ${RM} ${DESTDIR}${PREFIX}/lib/${LIBRARY_A}
+ ${RM} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO}.${VERSION}
+ ${RM} ${DESTDIR}${PREFIX}/lib/${LIBRARY_SO}
${LIBRARY}: ${LIBRARY_SO} ${LIBRARY_A}
@@ -42,3 +59,5 @@ ${LIBRARY_A}: ${OBJECTS}
clean:
${RM} ${LIBRARY_SO}* *.o *~ *.gz ${LIBRARY_A}
+
+.PHONY: all install uninstall ${LIBRARY} clean
diff --git a/contrib/bsddialog/lib/barbox.c b/contrib/bsddialog/lib/barbox.c
index 4feea20c6441..51f81ecbca68 100644
--- a/contrib/bsddialog/lib/barbox.c
+++ b/contrib/bsddialog/lib/barbox.c
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2021-2024 Alfonso Sabato Siciliano
+ * Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -371,7 +371,7 @@ bsddialog_progressview (struct bsddialog_conf *conf, const char *text, int rows,
unsigned int i, mainperc, totaltodo;
float readforsec;
const char **minilabels;
- time_t tstart, told, tnew, refresh;
+ time_t tstart, told, tnew, trefresh;
if ((minilabels = calloc(nminibar, sizeof(char*))) == NULL)
RETURN_ERROR("Cannot allocate memory for minilabels");
@@ -385,7 +385,7 @@ bsddialog_progressview (struct bsddialog_conf *conf, const char *text, int rows,
minipercs[i] = minibar[i].status;
}
- refresh = pvconf->refresh == 0 ? 0 : pvconf->refresh - 1;
+ trefresh = pvconf->refresh == 0 ? 0 : pvconf->refresh - 1;
retval = BSDDIALOG_OK;
i = 0;
update = true;
@@ -398,7 +398,7 @@ bsddialog_progressview (struct bsddialog_conf *conf, const char *text, int rows,
mainperc = (bsddialog_total_progview * 100) / totaltodo;
time(&tnew);
- if (update || tnew > told + refresh) {
+ if (update || tnew > told + trefresh) {
retval = do_mixedgauge(conf, text, rows, cols, mainperc,
nminibar, minilabels, minipercs, true);
if (retval == BSDDIALOG_ERROR)
@@ -440,17 +440,18 @@ bsddialog_progressview (struct bsddialog_conf *conf, const char *text, int rows,
return (retval);
}
-static int rangebox_redraw(struct dialog *d, struct bar *b, int *bigchange)
+static int
+rangebox_redraw(struct dialog *d, bool redraw, struct bar *b, int *bigchange)
{
- if (d->built) {
+ if (redraw) {
hide_dialog(d);
refresh(); /* Important for decreasing screen */
}
if (dialog_size_position(d, HBOX, MIN_WBOX, NULL) != 0)
return (BSDDIALOG_ERROR);
- if (draw_dialog(d) != 0)
+ if (draw_dialog(d) != 0) /* doupdate() in main loop */
return (BSDDIALOG_ERROR);
- if (d->built)
+ if (redraw)
refresh(); /* Important to fix grey lines expanding screen */
TEXTPAD(d, HBOX + HBUTTONS);
@@ -490,7 +491,7 @@ bsddialog_rangebox(struct bsddialog_conf *conf, const char *text, int rows,
RETURN_ERROR("Cannot build WINDOW bar");
b.y = b.x = 1;
b.fmt = "%d";
- if (rangebox_redraw(&d, &b, &bigchange) != 0)
+ if (rangebox_redraw(&d, false, &b, &bigchange) != 0)
return (BSDDIALOG_ERROR);
loop = true;
@@ -568,12 +569,12 @@ bsddialog_rangebox(struct bsddialog_conf *conf, const char *text, int rows,
break;
if (f1help_dialog(conf) != 0)
return (BSDDIALOG_ERROR);
- if (rangebox_redraw(&d, &b, &bigchange) != 0)
+ if (rangebox_redraw(&d, true, &b, &bigchange) != 0)
return (BSDDIALOG_ERROR);
break;
case KEY_CTRL('l'):
case KEY_RESIZE:
- if (rangebox_redraw(&d, &b, &bigchange) != 0)
+ if (rangebox_redraw(&d, true, &b, &bigchange) != 0)
return (BSDDIALOG_ERROR);
break;
default:
@@ -594,17 +595,17 @@ bsddialog_rangebox(struct bsddialog_conf *conf, const char *text, int rows,
return (retval);
}
-static int pause_redraw(struct dialog *d, struct bar *b)
+static int pause_redraw(struct dialog *d, bool redraw, struct bar *b)
{
- if (d->built) {
+ if (redraw) {
hide_dialog(d);
refresh(); /* Important for decreasing screen */
}
if (dialog_size_position(d, HBOX, MIN_WBOX, NULL) != 0)
return (BSDDIALOG_ERROR);
- if (draw_dialog(d) != 0)
+ if (draw_dialog(d) != 0) /* doupdate() in main loop */
return (BSDDIALOG_ERROR);
- if (d->built)
+ if (redraw)
refresh(); /* Important to fix grey lines expanding screen */
TEXTPAD(d, HBOX + HBUTTONS);
@@ -633,7 +634,7 @@ bsddialog_pause(struct bsddialog_conf *conf, const char *text, int rows,
RETURN_ERROR("Cannot build WINDOW bar");
b.y = b.x = 1;
b.fmt = "%d";
- if (pause_redraw(&d, &b) != 0)
+ if (pause_redraw(&d, false, &b) != 0)
return (BSDDIALOG_ERROR);
tout = *seconds;
@@ -687,12 +688,12 @@ bsddialog_pause(struct bsddialog_conf *conf, const char *text, int rows,
break;
if (f1help_dialog(conf) != 0)
return (BSDDIALOG_ERROR);
- if (pause_redraw(&d, &b) != 0)
+ if (pause_redraw(&d, true, &b) != 0)
return (BSDDIALOG_ERROR);
break;
case KEY_CTRL('l'):
case KEY_RESIZE:
- if (pause_redraw(&d, &b) != 0)
+ if (pause_redraw(&d, true, &b) != 0)
return (BSDDIALOG_ERROR);
break;
default:
diff --git a/contrib/bsddialog/lib/bsddialog.3 b/contrib/bsddialog/lib/bsddialog.3
index cbf1653a2aca..bbd756661a78 100644
--- a/contrib/bsddialog/lib/bsddialog.3
+++ b/contrib/bsddialog/lib/bsddialog.3
@@ -1,5 +1,5 @@
.\"
-.\" Copyright (c) 2021-2024 Alfonso Sabato Siciliano
+.\" Copyright (c) 2021-2025 Alfonso Sabato Siciliano
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@@ -22,11 +22,12 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd March 16, 2024
+.Dd June 22, 2025
.Dt BSDDIALOG 3
.Os
.Sh NAME
.Nm bsddialog_backtitle ,
+.Nm bsddialog_backtitle_rf ,
.Nm bsddialog_calendar ,
.Nm bsddialog_clear ,
.Nm bsddialog_color ,
@@ -65,6 +66,8 @@
.Ft int
.Fn bsddialog_backtitle "struct bsddialog_conf *conf" "const char *backtitle"
.Ft int
+.Fn bsddialog_backtitle_rf "struct bsddialog_conf *conf" "const char *backtitle"
+.Ft int
.Fo bsddialog_calendar
.Fa "struct bsddialog_conf *conf"
.Fa "const char *text"
@@ -292,7 +295,7 @@ and before
.Dv false
otherwise.
.Pp
-.Fn bsddialog_backtitle
+.Fn bsddialog_backtitle_rf
prints
.Fa backtitle
on the top of the screen.
@@ -302,6 +305,11 @@ and
.Fa conf.no_lines
described later.
.Pp
+.Fn bsddialog_backtitle
+is like
+.Fn bsddialog_backtitle_rf
+but it does not update the screen, using if a dialog is built later.
+.Pp
.Fn bsddialog_error
returns a string to describe the last error.
The function should be called after a
@@ -902,7 +910,7 @@ provides a dialog for a
the labels on buttons are
.Dq Yes
and
-.Dq No .
+.Dq &No .
.Ss Keys
.Bl -tag -width Ds
.It Ctrl-l
diff --git a/contrib/bsddialog/lib/bsddialog.h b/contrib/bsddialog/lib/bsddialog.h
index fd0e2bc02580..fc59071c6fa0 100644
--- a/contrib/bsddialog/lib/bsddialog.h
+++ b/contrib/bsddialog/lib/bsddialog.h
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2021-2024 Alfonso Sabato Siciliano
+ * Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,7 +30,7 @@
#include <stdbool.h>
-#define LIBBSDDIALOG_VERSION "1.0.4"
+#define LIBBSDDIALOG_VERSION "1.0.5"
/* Return values */
#define BSDDIALOG_ERROR -1
@@ -179,6 +179,7 @@ int bsddialog_init_notheme(void);
bool bsddialog_inmode(void);
int bsddialog_end(void);
int bsddialog_backtitle(struct bsddialog_conf *conf, const char *backtitle);
+int bsddialog_backtitle_rf(struct bsddialog_conf *conf, const char *backtitle);
int bsddialog_initconf(struct bsddialog_conf *conf);
void bsddialog_clear(unsigned int y);
void bsddialog_refresh(void);
diff --git a/contrib/bsddialog/lib/bsddialog_theme.h b/contrib/bsddialog/lib/bsddialog_theme.h
index 2071896b61f0..77938c65b6ce 100644
--- a/contrib/bsddialog/lib/bsddialog_theme.h
+++ b/contrib/bsddialog/lib/bsddialog_theme.h
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2021-2023 Alfonso Sabato Siciliano
+ * Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/contrib/bsddialog/lib/datebox.c b/contrib/bsddialog/lib/datebox.c
index ee955471799e..66f36f5f4a99 100644
--- a/contrib/bsddialog/lib/datebox.c
+++ b/contrib/bsddialog/lib/datebox.c
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2022-2024 Alfonso Sabato Siciliano
+ * Copyright (c) 2022-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -296,20 +296,20 @@ print_calendar(struct bsddialog_conf *conf, WINDOW *win, int yy, int mm, int dd,
}
static int
-calendar_redraw(struct dialog *d, WINDOW *yy_win, WINDOW *mm_win,
+calendar_draw(struct dialog *d, bool redraw, WINDOW *yy_win, WINDOW *mm_win,
WINDOW *dd_win)
{
int ycal, xcal;
- if (d->built) {
+ if (redraw) {
hide_dialog(d);
refresh(); /* Important for decreasing screen */
}
if (dialog_size_position(d, MINHCAL, MINWCAL, NULL) != 0)
return (BSDDIALOG_ERROR);
- if (draw_dialog(d) != 0)
+ if (draw_dialog(d) != 0) /* doupdate in main loop */
return (BSDDIALOG_ERROR);
- if (d->built)
+ if (redraw)
refresh(); /* Important to fix grey lines expanding screen */
TEXTPAD(d, MINHCAL + HBUTTONS);
@@ -354,7 +354,7 @@ bsddialog_calendar(struct bsddialog_conf *conf, const char *text, int rows,
if ((dd_win = newwin(1, 1, 1, 1)) == NULL)
RETURN_ERROR("Cannot build WINDOW for dd");
wbkgd(dd_win, t.dialog.color);
- if (calendar_redraw(&d, yy_win, mm_win, dd_win) != 0)
+ if (calendar_draw(&d, false, yy_win, mm_win, dd_win) != 0)
return (BSDDIALOG_ERROR);
sel = -1;
@@ -503,12 +503,12 @@ bsddialog_calendar(struct bsddialog_conf *conf, const char *text, int rows,
break;
if (f1help_dialog(conf) != 0)
return (BSDDIALOG_ERROR);
- if (calendar_redraw(&d, yy_win, mm_win, dd_win) != 0)
+ if (calendar_draw(&d, true, yy_win, mm_win, dd_win) != 0)
return (BSDDIALOG_ERROR);
break;
case KEY_CTRL('l'):
case KEY_RESIZE:
- if (calendar_redraw(&d, yy_win, mm_win, dd_win) != 0)
+ if (calendar_draw(&d, true, yy_win, mm_win, dd_win) != 0)
return (BSDDIALOG_ERROR);
break;
default:
@@ -533,11 +533,11 @@ bsddialog_calendar(struct bsddialog_conf *conf, const char *text, int rows,
return (retval);
}
-static int datebox_redraw(struct dialog *d, struct dateitem *di)
+static int datebox_draw(struct dialog *d, bool redraw, struct dateitem *di)
{
int y, x;
- if (d->built) {
+ if (redraw) {
hide_dialog(d);
refresh(); /* Important for decreasing screen */
}
@@ -545,7 +545,7 @@ static int datebox_redraw(struct dialog *d, struct dateitem *di)
return (BSDDIALOG_ERROR);
if (draw_dialog(d) != 0)
return (BSDDIALOG_ERROR);
- if (d->built)
+ if (redraw)
refresh(); /* Important to fix grey lines expanding screen */
TEXTPAD(d, 3 /*windows*/ + HBUTTONS);
@@ -624,7 +624,7 @@ bsddialog_datebox(struct bsddialog_conf *conf, const char *text, int rows,
set_buttons(&d, true, OK_LABEL, CANCEL_LABEL);
if (build_dateitem(conf->date.format, &yy, &mm, &dd, di) != 0)
return (BSDDIALOG_ERROR);
- if (datebox_redraw(&d, di) != 0)
+ if (datebox_draw(&d, false, di) != 0)
return (BSDDIALOG_ERROR);
sel = -1;
@@ -716,12 +716,12 @@ bsddialog_datebox(struct bsddialog_conf *conf, const char *text, int rows,
break;
if (f1help_dialog(conf) != 0)
return (BSDDIALOG_ERROR);
- if (datebox_redraw(&d, di) != 0)
+ if (datebox_draw(&d, true, di) != 0)
return (BSDDIALOG_ERROR);
break;
case KEY_CTRL('l'):
case KEY_RESIZE:
- if (datebox_redraw(&d, di) != 0)
+ if (datebox_draw(&d, true, di) != 0)
return (BSDDIALOG_ERROR);
break;
default:
diff --git a/contrib/bsddialog/lib/formbox.c b/contrib/bsddialog/lib/formbox.c
index ca473356e350..a072461c43e1 100644
--- a/contrib/bsddialog/lib/formbox.c
+++ b/contrib/bsddialog/lib/formbox.c
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2021-2024 Alfonso Sabato Siciliano
+ * Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -601,11 +601,11 @@ static int form_size_position(struct dialog *d, struct privateform *f)
}
static int
-form_redraw(struct dialog *d, struct privateform *f, bool focusinform)
+form_draw(struct dialog *d, bool redraw, struct privateform *f, bool focusinform)
{
unsigned int i;
- if (d->built) {
+ if (redraw) {
hide_dialog(d);
refresh(); /* Important for decreasing screen */
}
@@ -613,9 +613,9 @@ form_redraw(struct dialog *d, struct privateform *f, bool focusinform)
f->w = f->wmin;
if (form_size_position(d, f) != 0)
return (BSDDIALOG_ERROR);
- if (draw_dialog(d) != 0)
+ if (draw_dialog(d) != 0) /* doupdate() in main loop */
return (BSDDIALOG_ERROR);
- if (d->built)
+ if (redraw)
refresh(); /* Important to fix grey lines expanding screen */
TEXTPAD(d, 2 /* box borders */ + f->viewrows + HBUTTONS);
@@ -707,7 +707,7 @@ bsddialog_form(struct bsddialog_conf *conf, const char *text, int rows,
}
form.formheight = formheight;
- if (form_redraw(&d, &form, focusinform) != 0)
+ if (form_draw(&d, false, &form, focusinform) != 0)
return (BSDDIALOG_ERROR);
changeitem = switchfocus = false;
@@ -719,10 +719,16 @@ bsddialog_form(struct bsddialog_conf *conf, const char *text, int rows,
switch(input) {
case KEY_ENTER:
case 10: /* Enter */
- if (focusinform && conf->button.always_active == false)
- break;
- retval = BUTTONVALUE(d.bs);
- loop = false;
+ if (focusinform && conf->button.always_active == false) {
+ next = nextitem(form.nitems, form.pritems, form.sel);
+ if (next > form.sel)
+ changeitem = true; /* needs next */
+ else
+ switchfocus = true;
+ } else {
+ retval = BUTTONVALUE(d.bs);
+ loop = false;
+ }
break;
case 27: /* Esc */
if (conf->key.enable_esc) {
@@ -732,7 +738,12 @@ bsddialog_form(struct bsddialog_conf *conf, const char *text, int rows,
break;
case '\t': /* TAB */
if (focusinform) {
- switchfocus = true;
+ next = nextitem(form.nitems, form.pritems,
+ form.sel);
+ if (next > form.sel)
+ changeitem = true; /* needs next */
+ else
+ switchfocus = true;
} else {
if (d.bs.curr + 1 < (int)d.bs.nbuttons) {
d.bs.curr++;
@@ -839,12 +850,12 @@ bsddialog_form(struct bsddialog_conf *conf, const char *text, int rows,
retval = BSDDIALOG_ERROR;
loop = false;
}
- if (form_redraw(&d, &form, focusinform) != 0)
+ if (form_draw(&d, true, &form, focusinform) != 0)
return (BSDDIALOG_ERROR);
break;
case KEY_CTRL('l'):
case KEY_RESIZE:
- if (form_redraw(&d, &form, focusinform) != 0)
+ if (form_draw(&d, true, &form, focusinform) != 0)
return (BSDDIALOG_ERROR);
break;
default:
@@ -884,11 +895,20 @@ bsddialog_form(struct bsddialog_conf *conf, const char *text, int rows,
conf->button.always_active || !focusinform,
!focusinform);
wnoutrefresh(d.widget);
- DRAWITEM_TRICK(&form, form.sel, focusinform);
+ if (focusinform == false)
+ DRAWITEM_TRICK(&form, form.sel, false);
+ else {
+ next = firstitem(form.nitems, form.pritems);
+ if (next == form.sel)
+ DRAWITEM_TRICK(&form, form.sel, true);
+ else
+ changeitem = true;
+ }
switchfocus = false;
}
if (changeitem) {
+ /* useless after if(switchfocus) */
DRAWITEM_TRICK(&form, form.sel, false);
form.sel = next;
item = &form.pritems[form.sel];
diff --git a/contrib/bsddialog/lib/lib_util.c b/contrib/bsddialog/lib/lib_util.c
index d673a1a74d72..f042a2832eb9 100644
--- a/contrib/bsddialog/lib/lib_util.c
+++ b/contrib/bsddialog/lib/lib_util.c
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2021-2023 Alfonso Sabato Siciliano
+ * Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -25,6 +25,7 @@
* SUCH DAMAGE.
*/
+#include <stdarg.h>
#include <curses.h>
#include <stdlib.h>
#include <string.h>
diff --git a/contrib/bsddialog/lib/lib_util.h b/contrib/bsddialog/lib/lib_util.h
index 526f65b4bfaa..1adc34f3b80a 100644
--- a/contrib/bsddialog/lib/lib_util.h
+++ b/contrib/bsddialog/lib/lib_util.h
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2021-2024 Alfonso Sabato Siciliano
+ * Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -62,7 +62,7 @@ extern bool hastermcolors;
RETURN_ERROR("*" #p " is NULL"); \
} while (0)
#define CHECK_ARRAY(nitem, a) do { \
- if (nitem > 0 && a == NULL) \
+ if (nitem > 0 && a == NULL) \
RETURN_FMTERROR(#nitem " is %d but *" #a " is NULL", nitem); \
} while (0)
/* widget utils */
diff --git a/contrib/bsddialog/lib/libbsddialog.c b/contrib/bsddialog/lib/libbsddialog.c
index 555d060ebcbd..cdb5e1e251dc 100644
--- a/contrib/bsddialog/lib/libbsddialog.c
+++ b/contrib/bsddialog/lib/libbsddialog.c
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2021-2023 Alfonso Sabato Siciliano
+ * Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -114,11 +114,21 @@ int bsddialog_backtitle(struct bsddialog_conf *conf, const char *backtitle)
mvhline_set(1, 1, WACS_HLINE, SCREENCOLS - 2);
}
- refresh();
+ wnoutrefresh(stdscr);
return (BSDDIALOG_OK);
}
+int bsddialog_backtitle_rf(struct bsddialog_conf *conf, const char *backtitle)
+{
+ int rv;
+
+ rv = bsddialog_backtitle(conf, backtitle);
+ doupdate();
+
+ return (rv);
+}
+
bool bsddialog_inmode(void)
{
return (in_bsddialog_mode);
diff --git a/contrib/bsddialog/lib/menubox.c b/contrib/bsddialog/lib/menubox.c
index 896306b2881d..e6e2e7e3e63e 100644
--- a/contrib/bsddialog/lib/menubox.c
+++ b/contrib/bsddialog/lib/menubox.c
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2021-2024 Alfonso Sabato Siciliano
+ * Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -391,7 +391,7 @@ drawitem(struct bsddialog_conf *conf, struct privatemenu *m, int y, bool focus)
attron(t.menu.bottomdesccolor);
addstr(pritem->bottomdesc);
attroff(t.menu.bottomdesccolor);
- refresh();
+ wnoutrefresh(stdscr);
}
}
}
@@ -454,18 +454,18 @@ static int menu_size_position(struct dialog *d, struct privatemenu *m)
return (0);
}
-static int mixedlist_redraw(struct dialog *d, struct privatemenu *m)
+static int mixedlist_draw(struct dialog *d, bool redraw, struct privatemenu *m)
{
- if (d->built) {
+ if (redraw) {
hide_dialog(d);
refresh(); /* Important for decreasing screen */
}
m->menurows = m->apimenurows;
if (menu_size_position(d, m) != 0)
return (BSDDIALOG_ERROR);
- if (draw_dialog(d) != 0)
+ if (draw_dialog(d) != 0) /* doupdate() in main loop */
return (BSDDIALOG_ERROR);
- if (d->built)
+ if (redraw)
refresh(); /* Important to fix grey lines expanding screen */
TEXTPAD(d, 2/*bmenu*/ + m->menurows + HBUTTONS);
@@ -532,7 +532,7 @@ do_mixedlist(struct bsddialog_conf *conf, const char *text, int rows, int cols,
drawitem(d.conf, &m, m.sel, true);
m.ypad = 0;
m.apimenurows = menurows;
- if (mixedlist_redraw(&d, &m) != 0)
+ if (mixedlist_draw(&d, false, &m) != 0)
return (BSDDIALOG_ERROR);
changeitem = false;
@@ -575,12 +575,12 @@ do_mixedlist(struct bsddialog_conf *conf, const char *text, int rows, int cols,
break;
if (f1help_dialog(conf) != 0)
return (BSDDIALOG_ERROR);
- if (mixedlist_redraw(&d, &m) != 0)
+ if (mixedlist_draw(&d, true, &m) != 0)
return (BSDDIALOG_ERROR);
break;
case KEY_CTRL('l'):
case KEY_RESIZE:
- if (mixedlist_redraw(&d, &m) != 0)
+ if (mixedlist_draw(&d, true, &m) != 0)
return (BSDDIALOG_ERROR);
break;
}
diff --git a/contrib/bsddialog/lib/messagebox.c b/contrib/bsddialog/lib/messagebox.c
index 5132b1b089b8..c3d4a20f5404 100644
--- a/contrib/bsddialog/lib/messagebox.c
+++ b/contrib/bsddialog/lib/messagebox.c
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2021-2024 Alfonso Sabato Siciliano
+ * Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -69,19 +69,19 @@ static int message_size_position(struct dialog *d, int *htext)
return (0);
}
-static int message_draw(struct dialog *d, struct scroll *s)
+static int message_draw(struct dialog *d, bool redraw, struct scroll *s)
{
int unused;
- if (d->built) {
+ if (redraw) { /* redraw: RESIZE or F1 */
hide_dialog(d);
refresh(); /* Important for decreasing screen */
}
if (message_size_position(d, &s->htext) != 0)
return (BSDDIALOG_ERROR);
- if (draw_dialog(d) != 0)
+ if (draw_dialog(d) != 0) /* doupdate() in main loop */
return (BSDDIALOG_ERROR);
- if (d->built)
+ if (redraw)
refresh(); /* Important to fix grey lines expanding screen */
s->printrows = d->h - BORDER - HBUTTONS - BORDER;
@@ -106,7 +106,7 @@ do_message(struct bsddialog_conf *conf, const char *text, int rows, int cols,
return (BSDDIALOG_ERROR);
set_buttons(&d, true, oklabel, cancellabel);
s.htext = -1;
- if (message_draw(&d, &s) != 0)
+ if (message_draw(&d, false, &s) != 0)
return (BSDDIALOG_ERROR);
loop = true;
@@ -170,12 +170,12 @@ do_message(struct bsddialog_conf *conf, const char *text, int rows, int cols,
break;
if (f1help_dialog(d.conf) != 0)
return (BSDDIALOG_ERROR);
- if (message_draw(&d, &s) != 0)
+ if (message_draw(&d, true, &s) != 0)
return (BSDDIALOG_ERROR);
break;
case KEY_CTRL('l'):
case KEY_RESIZE:
- if (message_draw(&d, &s) != 0)
+ if (message_draw(&d, true, &s) != 0)
return (BSDDIALOG_ERROR);
break;
default:
diff --git a/contrib/bsddialog/lib/textbox.c b/contrib/bsddialog/lib/textbox.c
index ca3eb69fff52..1f730e0d925b 100644
--- a/contrib/bsddialog/lib/textbox.c
+++ b/contrib/bsddialog/lib/textbox.c
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2021-2024 Alfonso Sabato Siciliano
+ * Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -101,17 +101,17 @@ static int textbox_size_position(struct dialog *d, struct scrolltext *st)
return (0);
}
-static int textbox_draw(struct dialog *d, struct scrolltext *st)
+static int textbox_draw(struct dialog *d, bool redraw, struct scrolltext *st)
{
- if (d->built) {
+ if (redraw) {
hide_dialog(d);
refresh(); /* Important for decreasing screen */
}
if (textbox_size_position(d, st) != 0)
return (BSDDIALOG_ERROR);
- if (draw_dialog(d) != 0)
+ if (draw_dialog(d) != 0) /* wrefresh() and prefresh() in main loop */
return (BSDDIALOG_ERROR);
- if (d->built)
+ if (redraw)
refresh(); /* Important to fix grey lines expanding screen */
st->ys = d->y + 1;
@@ -175,7 +175,7 @@ bsddialog_textbox(struct bsddialog_conf *conf, const char *file, int rows,
fclose(fp);
set_tabsize(defaulttablen); /* reset because it is curses global */
- if (textbox_draw(&d, &st) != 0)
+ if (textbox_draw(&d, false, &st) != 0)
return (BSDDIALOG_ERROR);
loop = true;
@@ -254,12 +254,12 @@ bsddialog_textbox(struct bsddialog_conf *conf, const char *file, int rows,
break;
if (f1help_dialog(conf) != 0)
return (BSDDIALOG_ERROR);
- if (textbox_draw(&d, &st) != 0)
+ if (textbox_draw(&d, true, &st) != 0)
return (BSDDIALOG_ERROR);
break;
case KEY_CTRL('l'):
case KEY_RESIZE:
- if (textbox_draw(&d, &st) != 0)
+ if (textbox_draw(&d, true, &st) != 0)
return (BSDDIALOG_ERROR);
break;
}
diff --git a/contrib/bsddialog/lib/theme.c b/contrib/bsddialog/lib/theme.c
index 04f85b2455fa..6c17d908324b 100644
--- a/contrib/bsddialog/lib/theme.c
+++ b/contrib/bsddialog/lib/theme.c
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2021-2023 Alfonso Sabato Siciliano
+ * Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -217,7 +217,7 @@ int bsddialog_set_theme(struct bsddialog_theme *theme)
{
CHECK_PTR(theme);
set_theme(&t, theme);
- refresh();
+ wnoutrefresh(stdscr);
return (BSDDIALOG_OK);
}
@@ -239,7 +239,7 @@ int bsddialog_set_default_theme(enum bsddialog_default_theme newtheme)
"to use enum bsddialog_default_theme",
newtheme);
}
- refresh();
+ wnoutrefresh(stdscr);
return (BSDDIALOG_OK);
}
diff --git a/contrib/bsddialog/lib/timebox.c b/contrib/bsddialog/lib/timebox.c
index 1421cd7d2b81..603d5fa5d7a3 100644
--- a/contrib/bsddialog/lib/timebox.c
+++ b/contrib/bsddialog/lib/timebox.c
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2021-2024 Alfonso Sabato Siciliano
+ * Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -62,19 +62,19 @@ drawsquare(struct bsddialog_conf *conf, WINDOW *win, unsigned int value,
wnoutrefresh(win);
}
-static int timebox_redraw(struct dialog *d, struct clock *c)
+static int timebox_draw(struct dialog *d, bool redraw, struct clock *c)
{
int y, x;
- if (d->built) {
+ if (redraw) {
hide_dialog(d);
refresh(); /* Important for decreasing screen */
}
if (dialog_size_position(d, HBOX, MINWTIME, NULL) != 0)
return (BSDDIALOG_ERROR);
- if (draw_dialog(d) != 0)
+ if (draw_dialog(d) != 0) /* doupdate() in mail loop */
return (BSDDIALOG_ERROR);
- if (d->built)
+ if (redraw)
refresh(); /* Important to fix grey lines expanding screen */
TEXTPAD(d, HBOX + HBUTTONS);
@@ -117,7 +117,7 @@ bsddialog_timebox(struct bsddialog_conf *conf, const char* text, int rows,
wbkgd(c[i].win, t.dialog.color);
c[i].value = MIN(c[i].value, c[i].max);
}
- if (timebox_redraw(&d, c) != 0)
+ if (timebox_draw(&d, false, c) != 0)
return (BSDDIALOG_ERROR);
sel = -1;
@@ -210,12 +210,12 @@ bsddialog_timebox(struct bsddialog_conf *conf, const char* text, int rows,
break;
if (f1help_dialog(conf) != 0)
return (BSDDIALOG_ERROR);
- if (timebox_redraw(&d, c) != 0)
+ if (timebox_draw(&d, true, c) != 0)
return (BSDDIALOG_ERROR);
break;
case KEY_CTRL('l'):
case KEY_RESIZE:
- if (timebox_redraw(&d, c) != 0)
+ if (timebox_draw(&d, true, c) != 0)
return (BSDDIALOG_ERROR);
break;
default:
diff --git a/contrib/bsddialog/utility/GNUmakefile b/contrib/bsddialog/utility/GNUmakefile
index 518ec0d912d6..600efc7aacf6 100644
--- a/contrib/bsddialog/utility/GNUmakefile
+++ b/contrib/bsddialog/utility/GNUmakefile
@@ -6,6 +6,7 @@
OUTPUT = bsddialog
SOURCES = bsddialog.c util_builders.c util_cli.c util_theme.c
OBJECTS = $(SOURCES:.c=.o)
+PREFIX = /usr/local
ifneq ($(ENABLEDEBUG),)
CFLAGS += -g
@@ -20,7 +21,13 @@ endif
RM = rm -f
-all : $(OUTPUT)
+all: $(OUTPUT)
+
+install: all
+ ${INSTALL} -m 0755 ${OUTPUT} ${DESTDIR}${PREFIX}/bin/${OUTPUT}
+
+uninstall:
+ ${RM} ${DESTDIR}${PREFIX}/bin/${OUTPUT}
$(OUTPUT): $(OBJECTS)
$(CC) $^ -o $@ $(LDFLAGS)
@@ -31,3 +38,5 @@ $(OUTPUT): $(OBJECTS)
clean:
$(RM) $(OUTPUT) *.o *~
+
+.PHONY: all install uninstall clean
diff --git a/contrib/bsddialog/utility/Makefile b/contrib/bsddialog/utility/Makefile
index ab51b46a25be..e6cd541fded4 100644
--- a/contrib/bsddialog/utility/Makefile
+++ b/contrib/bsddialog/utility/Makefile
@@ -6,6 +6,7 @@
OUTPUT = bsddialog
SOURCES = bsddialog.c util_builders.c util_cli.c util_theme.c
OBJECTS = ${SOURCES:.c=.o}
+PREFIX = /usr/local
.if defined(DEBUG)
CFLAGS += -g
@@ -21,7 +22,13 @@ LDFLAGS += -ltinfow -Wl,-rpath=${LIBPATH} -L${LIBPATH} -lbsddialog
INSTALL = install
RM = rm -f
-all : ${OUTPUT}
+all: ${OUTPUT}
+
+install: all
+ ${INSTALL} -m 0755 ${OUTPUT} ${DESTDIR}${PREFIX}/bin/${OUTPUT}
+
+uninstall:
+ ${RM} ${DESTDIR}${PREFIX}/bin/${OUTPUT}
${OUTPUT}: ${OBJECTS}
${CC} ${LDFLAGS} ${OBJECTS} -o ${.PREFIX}
@@ -31,3 +38,5 @@ ${OUTPUT}: ${OBJECTS}
clean:
${RM} ${OUTPUT} *.o *~ *.core *.gz
+
+.PHONY: all install uninstall clean
diff --git a/contrib/bsddialog/utility/bsddialog.1 b/contrib/bsddialog/utility/bsddialog.1
index 4586ba16020c..0ec2a96952bd 100644
--- a/contrib/bsddialog/utility/bsddialog.1
+++ b/contrib/bsddialog/utility/bsddialog.1
@@ -1,5 +1,5 @@
.\"
-.\" Copyright (c) 2021-2024 Alfonso Sabato Siciliano
+.\" Copyright (c) 2021-2025 Alfonso Sabato Siciliano
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd May 25, 2024
+.Dd June 22, 2025
.Dt BSDDIALOG 1
.Os
.Sh NAME
@@ -80,7 +80,14 @@ The following options can change the default behavior of the utility and are
common to some dialog.
.Bl -tag -width Ds
.It Fl Fl alternate-screen
-If available set alternate screen mode, see
+Set alternate screen mode if the terminal and
+.Xr curses 3
+provide it.
+If enabled bsddialog draws to the alternate screen and restores the main screen
+after exit.
+See
+.Dq smcup
+in
.Xr terminfo 5 .
.It Fl Fl ascii-lines
Ascii characters to draw lines.
@@ -291,7 +298,11 @@ Set an exit code value for the
.Dq Ok
button.
.It Fl Fl normal-screen
-If available set normal screen mode, see
+Set normal screen mode.
+bsddialog does not restore the previous screen after exit.
+See
+.Dq rmcup
+in
.Xr terminfo 5 .
.It Fl Fl output-fd Ar fd
Print input from user interface to the specified file descriptor.
@@ -737,7 +748,7 @@ Right1 generic button.
.It 10
Right2 generic button.
.It 11
-Right2 generic button.
+Right3 generic button.
.El
.Sh EXAMPLES
Backtitle, title and message:
diff --git a/contrib/bsddialog/utility/bsddialog.c b/contrib/bsddialog/utility/bsddialog.c
index 3ba21eadf7a3..bce1d0ab8452 100644
--- a/contrib/bsddialog/utility/bsddialog.c
+++ b/contrib/bsddialog/utility/bsddialog.c
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2021-2024 Alfonso Sabato Siciliano
+ * Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/contrib/bsddialog/utility/util.h b/contrib/bsddialog/utility/util.h
index 2750c2ee6951..d1f7793c9755 100644
--- a/contrib/bsddialog/utility/util.h
+++ b/contrib/bsddialog/utility/util.h
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2021-2023 Alfonso Sabato Siciliano
+ * Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/contrib/bsddialog/utility/util_builders.c b/contrib/bsddialog/utility/util_builders.c
index 2e69994a0ec0..0a968d4319f9 100644
--- a/contrib/bsddialog/utility/util_builders.c
+++ b/contrib/bsddialog/utility/util_builders.c
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2021-2024 Alfonso Sabato Siciliano
+ * Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -82,7 +82,7 @@ int gauge_builder(BUILDER_ARGS)
perc = 0;
if (argc == 1) {
- perc = (u_int)strtoul(argv[0], NULL, 10);
+ perc = (unsigned int)strtoul(argv[0], NULL, 10);
perc = perc > 100 ? 100 : perc;
} else if (argc > 1) {
error_args(opt->name, argc - 1, argv + 1);
@@ -106,7 +106,7 @@ int mixedgauge_builder(BUILDER_ARGS)
exit_error(true,
"bad %s pair number [<minilabel> <miniperc>]", opt->name);
- mainperc = (u_int)strtoul(argv[0], NULL, 10);
+ mainperc = (unsigned int)strtoul(argv[0], NULL, 10);
mainperc = mainperc > 100 ? 100 : mainperc;
argc--;
argv++;
@@ -138,7 +138,7 @@ int pause_builder(BUILDER_ARGS)
if (argc > 1)
error_args(opt->name, argc - 1, argv + 1);
- secs = (u_int)strtoul(argv[0], NULL, 10);
+ secs = (unsigned int)strtoul(argv[0], NULL, 10);
output = bsddialog_pause(conf, text, rows, cols, &secs);
return (output);
@@ -189,9 +189,9 @@ static int date(BUILDER_ARGS)
error_args(opt->name, argc - 3, argv + 3);
} else if (argc == 3) {
/* lib checks/sets max and min */
- dd = (u_int)strtoul(argv[0], NULL, 10);
- mm = (u_int)strtoul(argv[1], NULL, 10);
- yy = (u_int)strtoul(argv[2], NULL, 10);
+ dd = (unsigned int)strtoul(argv[0], NULL, 10);
+ mm = (unsigned int)strtoul(argv[1], NULL, 10);
+ yy = (unsigned int)strtoul(argv[2], NULL, 10);
}
if (strcmp(opt->name, "--datebox") == 0)
@@ -259,9 +259,9 @@ int timebox_builder(BUILDER_ARGS)
if (argc > 3) {
error_args("--timebox", argc - 3, argv + 3);
} else if (argc == 3) {
- hh = (u_int)strtoul(argv[0], NULL, 10);
- mm = (u_int)strtoul(argv[1], NULL, 10);
- ss = (u_int)strtoul(argv[2], NULL, 10);
+ hh = (unsigned int)strtoul(argv[0], NULL, 10);
+ mm = (unsigned int)strtoul(argv[1], NULL, 10);
+ ss = (unsigned int)strtoul(argv[2], NULL, 10);
}
output = bsddialog_timebox(conf, text, rows, cols, &hh, &mm, &ss);
@@ -315,7 +315,7 @@ get_menu_items(int argc, char **argv, bool setprefix, bool setdepth,
for (i = 0; i < *nitems; i++) {
(*items)[i].prefix = setprefix ? argv[j++] : "";
(*items)[i].depth = setdepth ?
- (u_int)strtoul(argv[j++], NULL, 0) : 0;
+ (unsigned int)strtoul(argv[j++], NULL, 0) : 0;
(*items)[i].name = setname ? argv[j++] : "";
(*items)[i].desc = setdesc ? argv[j++] : "";
if (setstatus) {
@@ -436,7 +436,7 @@ int checklist_builder(BUILDER_ARGS)
if (argc < 1)
exit_error(true, "--checklist missing <menurows>");
- menurows = (u_int)strtoul(argv[0], NULL, 10);
+ menurows = (unsigned int)strtoul(argv[0], NULL, 10);
get_menu_items(argc-1, argv+1, opt->item_prefix, opt->item_depth, true,
true, true, opt->item_bottomdesc, &nitems, &items, &focusitem, opt);
@@ -461,7 +461,7 @@ int menu_builder(BUILDER_ARGS)
if (argc < 1)
exit_error(true, "--menu missing <menurows>");
- menurows = (u_int)strtoul(argv[0], NULL, 10);
+ menurows = (unsigned int)strtoul(argv[0], NULL, 10);
get_menu_items(argc-1, argv+1, opt->item_prefix, opt->item_depth, true,
true, false, opt->item_bottomdesc, &nitems, &items, &focusitem,
@@ -487,7 +487,7 @@ int radiolist_builder(BUILDER_ARGS)
if (argc < 1)
exit_error(true, "--radiolist missing <menurows>");
- menurows = (u_int)strtoul(argv[0], NULL, 10);
+ menurows = (unsigned int)strtoul(argv[0], NULL, 10);
get_menu_items(argc-1, argv+1, opt->item_prefix, opt->item_depth, true,
true, true, opt->item_bottomdesc, &nitems, &items, &focusitem, opt);
@@ -512,7 +512,7 @@ int treeview_builder(BUILDER_ARGS)
if (argc < 1)
exit_error(true, "--treeview missing <menurows>");
- menurows = (u_int)strtoul(argv[0], NULL, 10);
+ menurows = (unsigned int)strtoul(argv[0], NULL, 10);
get_menu_items(argc-1, argv+1, opt->item_prefix, true, true, true, true,
opt->item_bottomdesc, &nitems, &items, &focusitem, opt);
@@ -595,7 +595,7 @@ int form_builder(BUILDER_ARGS)
if (argc < 1)
exit_error(true, "--form missing <formheight>");
- formheight = (u_int)strtoul(argv[0], NULL, 10);
+ formheight = (unsigned int)strtoul(argv[0], NULL, 10);
argc--;
argv++;
@@ -609,11 +609,11 @@ int form_builder(BUILDER_ARGS)
j = 0;
for (i = 0; i < nitems; i++) {
items[i].label = argv[j++];
- items[i].ylabel = (u_int)strtoul(argv[j++], NULL, 10);
- items[i].xlabel = (u_int)strtoul(argv[j++], NULL, 10);
+ items[i].ylabel = (unsigned int)strtoul(argv[j++], NULL, 10);
+ items[i].xlabel = (unsigned int)strtoul(argv[j++], NULL, 10);
items[i].init = argv[j++];
- items[i].yfield = (u_int)strtoul(argv[j++], NULL, 10);
- items[i].xfield = (u_int)strtoul(argv[j++], NULL, 10);
+ items[i].yfield = (unsigned int)strtoul(argv[j++], NULL, 10);
+ items[i].xfield = (unsigned int)strtoul(argv[j++], NULL, 10);
fieldlen = (int)strtol(argv[j++], NULL, 10);
if (fieldlen == 0)
@@ -621,7 +621,7 @@ int form_builder(BUILDER_ARGS)
else
items[i].fieldlen = abs(fieldlen);
- items[i].maxvaluelen = (u_int)strtoul(argv[j++], NULL, 10);
+ items[i].maxvaluelen = (unsigned int)strtoul(argv[j++], NULL, 10);
if (items[i].maxvaluelen == 0)
items[i].maxvaluelen = items[i].fieldlen;
@@ -678,7 +678,7 @@ int mixedform_builder(BUILDER_ARGS)
if (argc < 1)
exit_error(true, "--mixedform missing <formheight>");
- formheight = (u_int)strtoul(argv[0], NULL, 10);
+ formheight = (unsigned int)strtoul(argv[0], NULL, 10);
argc--;
argv++;
@@ -692,21 +692,21 @@ int mixedform_builder(BUILDER_ARGS)
j = 0;
for (i = 0; i < nitems; i++) {
items[i].label = argv[j++];
- items[i].ylabel = (u_int)strtoul(argv[j++], NULL, 10);
- items[i].xlabel = (u_int)strtoul(argv[j++], NULL, 10);
+ items[i].ylabel = (unsigned int)strtoul(argv[j++], NULL, 10);
+ items[i].xlabel = (unsigned int)strtoul(argv[j++], NULL, 10);
items[i].init = argv[j++];
- items[i].yfield = (u_int)strtoul(argv[j++], NULL, 10);
- items[i].xfield = (u_int)strtoul(argv[j++], NULL, 10);
+ items[i].yfield = (unsigned int)strtoul(argv[j++], NULL, 10);
+ items[i].xfield = (unsigned int)strtoul(argv[j++], NULL, 10);
fieldlen = (int)strtol(argv[j++], NULL, 10);
if (fieldlen == 0)
items[i].fieldlen = strcols(items[i].init);
else
items[i].fieldlen = abs(fieldlen);
- items[i].maxvaluelen = (u_int)strtoul(argv[j++], NULL, 10);
+ items[i].maxvaluelen = (unsigned int)strtoul(argv[j++], NULL, 10);
if (items[i].maxvaluelen == 0)
items[i].maxvaluelen = items[i].fieldlen;
- items[i].flags = (u_int)strtoul(argv[j++], NULL, 10);
+ items[i].flags = (unsigned int)strtoul(argv[j++], NULL, 10);
if (fieldlen <= 0)
items[i].flags |= BSDDIALOG_FIELDREADONLY;
@@ -765,7 +765,7 @@ int passwordform_builder(BUILDER_ARGS)
if (argc < 1)
exit_error(true, "--passwordform missing <formheight>");
- formheight = (u_int)strtoul(argv[0], NULL, 10);
+ formheight = (unsigned int)strtoul(argv[0], NULL, 10);
argc--;
argv++;
@@ -780,11 +780,11 @@ int passwordform_builder(BUILDER_ARGS)
j = 0;
for (i = 0; i < nitems; i++) {
items[i].label = argv[j++];
- items[i].ylabel = (u_int)strtoul(argv[j++], NULL, 10);
- items[i].xlabel = (u_int)strtoul(argv[j++], NULL, 10);
+ items[i].ylabel = (unsigned int)strtoul(argv[j++], NULL, 10);
+ items[i].xlabel = (unsigned int)strtoul(argv[j++], NULL, 10);
items[i].init = argv[j++];
- items[i].yfield = (u_int)strtoul(argv[j++], NULL, 10);
- items[i].xfield = (u_int)strtoul(argv[j++], NULL, 10);
+ items[i].yfield = (unsigned int)strtoul(argv[j++], NULL, 10);
+ items[i].xfield = (unsigned int)strtoul(argv[j++], NULL, 10);
fieldlen = (int)strtol(argv[j++], NULL, 10);
items[i].fieldlen = abs(fieldlen);
diff --git a/contrib/bsddialog/utility/util_cli.c b/contrib/bsddialog/utility/util_cli.c
index a70de36a699e..01b6fc31f065 100644
--- a/contrib/bsddialog/utility/util_cli.c
+++ b/contrib/bsddialog/utility/util_cli.c
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2021-2023 Alfonso Sabato Siciliano
+ * Copyright (c) 2021-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/contrib/bsddialog/utility/util_theme.c b/contrib/bsddialog/utility/util_theme.c
index a95cadacc1b0..cca79e83b97d 100644
--- a/contrib/bsddialog/utility/util_theme.c
+++ b/contrib/bsddialog/utility/util_theme.c
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2022-2024 Alfonso Sabato Siciliano
+ * Copyright (c) 2022-2025 Alfonso Sabato Siciliano
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -279,7 +279,7 @@ void loadtheme(const char *file, bool compatibility)
break;
case BOOL:
boolvalue = (strstr(value, "true") != NULL) ?
- true :false;
+ true : false;
*((bool*)p[i].value) = boolvalue;
break;
case COLOR:
diff --git a/contrib/kyua/drivers/run_tests.cpp b/contrib/kyua/drivers/run_tests.cpp
index d92940005242..3af9a1268815 100644
--- a/contrib/kyua/drivers/run_tests.cpp
+++ b/contrib/kyua/drivers/run_tests.cpp
@@ -209,7 +209,7 @@ finish_test(scheduler::result_handle_ptr result_handle,
hooks.got_result(
*test_result_handle->test_program(),
test_result_handle->test_case_name(),
- test_result_handle->test_result(),
+ test_result,
result_handle->end_time() - result_handle->start_time());
}
diff --git a/contrib/sendmail/src/newaliases.1 b/contrib/sendmail/src/newaliases.1
index 59dc0de20cf7..cdb6eef67416 100644
--- a/contrib/sendmail/src/newaliases.1
+++ b/contrib/sendmail/src/newaliases.1
@@ -14,7 +14,7 @@
.TH NEWALIASES 1 "$Date: 2013-11-22 20:51:56 $"
.SH NAME
newaliases
-\- rebuild the data base for the mail aliases file
+\- rebuild the data base for the sendmail aliases file
.SH SYNOPSIS
.B newaliases
.SH DESCRIPTION
diff --git a/crypto/krb5/src/build-tools/mit-krb5.pc.in b/crypto/krb5/src/build-tools/mit-krb5.pc.in
index fdc557785ad4..dca1654c8c9d 100644
--- a/crypto/krb5/src/build-tools/mit-krb5.pc.in
+++ b/crypto/krb5/src/build-tools/mit-krb5.pc.in
@@ -12,4 +12,4 @@ Description: An implementation of Kerberos network authentication
Version: @KRB5_VERSION@
Cflags: -I${includedir}
Libs: -L${libdir} -lkrb5 -lk5crypto @COM_ERR_LIB@
-Libs.private: -lkrb5support
+Libs.private: -lkrb5support -lkrb5profile
diff --git a/crypto/openssh/auth-pam.c b/crypto/openssh/auth-pam.c
index df08dbd99a9d..217fae531afa 100644
--- a/crypto/openssh/auth-pam.c
+++ b/crypto/openssh/auth-pam.c
@@ -101,7 +101,7 @@
#endif
#include "monitor_wrap.h"
#include "srclimit.h"
-#include "blacklist_client.h"
+#include "blocklist_client.h"
extern ServerOptions options;
extern struct sshbuf *loginmsg;
@@ -937,7 +937,7 @@ sshpam_query(void *ctx, char **name, char **info,
sshbuf_free(buffer);
return (0);
}
- BLACKLIST_NOTIFY(NULL, BLACKLIST_AUTH_FAIL,
+ BLOCKLIST_NOTIFY(NULL, BLOCKLIST_AUTH_FAIL,
"PAM illegal user");
error("PAM: %s for %s%.100s from %.100s", msg,
sshpam_authctxt->valid ? "" : "illegal user ",
diff --git a/crypto/openssh/auth.c b/crypto/openssh/auth.c
index 0a1c8f71b390..28ee390f4a15 100644
--- a/crypto/openssh/auth.c
+++ b/crypto/openssh/auth.c
@@ -75,7 +75,7 @@
#include "monitor_wrap.h"
#include "ssherr.h"
#include "channels.h"
-#include "blacklist_client.h"
+#include "blocklist_client.h"
/* import */
extern ServerOptions options;
@@ -289,7 +289,7 @@ auth_log(struct ssh *ssh, int authenticated, int partial,
else {
authmsg = authenticated ? "Accepted" : "Failed";
if (authenticated)
- BLACKLIST_NOTIFY(ssh, BLACKLIST_AUTH_OK,
+ BLOCKLIST_NOTIFY(ssh, BLOCKLIST_AUTH_OK,
"Authenticated");
}
@@ -339,7 +339,7 @@ auth_maxtries_exceeded(struct ssh *ssh)
{
Authctxt *authctxt = (Authctxt *)ssh->authctxt;
- BLACKLIST_NOTIFY(ssh, BLACKLIST_AUTH_FAIL, "Maximum attempts exceeded");
+ BLOCKLIST_NOTIFY(ssh, BLOCKLIST_AUTH_FAIL, "Maximum attempts exceeded");
error("maximum authentication attempts exceeded for "
"%s%.100s from %.200s port %d ssh2",
authctxt->valid ? "" : "invalid user ",
@@ -500,7 +500,7 @@ getpwnamallow(struct ssh *ssh, const char *user)
aix_restoreauthdb();
#endif
if (pw == NULL) {
- BLACKLIST_NOTIFY(ssh, BLACKLIST_AUTH_FAIL, "Invalid user");
+ BLOCKLIST_NOTIFY(ssh, BLOCKLIST_AUTH_FAIL, "Invalid user");
logit("Invalid user %.100s from %.100s port %d",
user, ssh_remote_ipaddr(ssh), ssh_remote_port(ssh));
#ifdef CUSTOM_FAILED_LOGIN
diff --git a/crypto/openssh/blacklist.c b/crypto/openssh/blocklist.c
index 33d02607dd98..f3c00016db66 100644
--- a/crypto/openssh/blacklist.c
+++ b/crypto/openssh/blocklist.c
@@ -46,16 +46,16 @@
#include "log.h"
#include "misc.h"
#include "servconf.h"
-#include <blacklist.h>
-#include "blacklist_client.h"
+#include <blocklist.h>
+#include "blocklist_client.h"
-static struct blacklist *blstate = NULL;
+static struct blocklist *blstate = NULL;
/* import */
extern ServerOptions options;
/* internal definition from bl.h */
-struct blacklist *bl_create(bool, char *, void (*)(int, const char *, va_list));
+struct blocklist *bl_create(bool, char *, void (*)(int, const char *, va_list));
/* impedence match vsyslog() to sshd's internal logging levels */
void
@@ -80,18 +80,18 @@ im_log(int priority, const char *message, va_list args)
}
void
-blacklist_init(void)
+blocklist_init(void)
{
- if (options.use_blacklist)
+ if (options.use_blocklist)
blstate = bl_create(false, NULL, im_log);
}
void
-blacklist_notify(struct ssh *ssh, int action, const char *msg)
+blocklist_notify(struct ssh *ssh, int action, const char *msg)
{
if (blstate != NULL && ssh_packet_connection_is_on_socket(ssh))
- (void)blacklist_r(blstate, action,
+ (void)blocklist_r(blstate, action,
ssh_packet_get_connection_in(ssh), msg);
}
diff --git a/crypto/openssh/blacklist_client.h b/crypto/openssh/blocklist_client.h
index 601a44461e20..be92245e4690 100644
--- a/crypto/openssh/blacklist_client.h
+++ b/crypto/openssh/blocklist_client.h
@@ -31,31 +31,31 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef BLACKLIST_CLIENT_H
-#define BLACKLIST_CLIENT_H
+#ifndef BLOCKLIST_CLIENT_H
+#define BLOCKLIST_CLIENT_H
-#ifndef BLACKLIST_API_ENUM
+#ifndef BLOCKLIST_API_ENUM
enum {
- BLACKLIST_AUTH_OK = 0,
- BLACKLIST_AUTH_FAIL,
- BLACKLIST_ABUSIVE_BEHAVIOR,
- BLACKLIST_BAD_USER
+ BLOCKLIST_AUTH_OK = 0,
+ BLOCKLIST_AUTH_FAIL,
+ BLOCKLIST_ABUSIVE_BEHAVIOR,
+ BLOCKLIST_BAD_USER
};
#endif
-#ifdef USE_BLACKLIST
-void blacklist_init(void);
-void blacklist_notify(struct ssh *, int, const char *);
+#ifdef USE_BLOCKLIST
+void blocklist_init(void);
+void blocklist_notify(struct ssh *, int, const char *);
-#define BLACKLIST_INIT() blacklist_init()
-#define BLACKLIST_NOTIFY(ssh,x,msg) blacklist_notify(ssh,x,msg)
+#define BLOCKLIST_INIT() blocklist_init()
+#define BLOCKLIST_NOTIFY(ssh,x,msg) blocklist_notify(ssh,x,msg)
#else
-#define BLACKLIST_INIT()
-#define BLACKLIST_NOTIFY(ssh,x,msg)
+#define BLOCKLIST_INIT()
+#define BLOCKLIST_NOTIFY(ssh,x,msg)
#endif
-#endif /* BLACKLIST_CLIENT_H */
+#endif /* BLOCKLIST_CLIENT_H */
diff --git a/crypto/openssh/monitor.c b/crypto/openssh/monitor.c
index b826ecdb9065..77dccf0d84f1 100644
--- a/crypto/openssh/monitor.c
+++ b/crypto/openssh/monitor.c
@@ -85,7 +85,7 @@
#include "misc.h"
#include "servconf.h"
#include "monitor.h"
-#include "blacklist_client.h"
+#include "blocklist_client.h"
#ifdef GSSAPI
#include "ssh-gss.h"
@@ -355,7 +355,7 @@ monitor_child_preauth(struct ssh *ssh, struct monitor *pmonitor)
}
}
if (authctxt->failures > options.max_authtries) {
- BLACKLIST_NOTIFY(ssh, BLACKLIST_AUTH_FAIL,
+ BLOCKLIST_NOTIFY(ssh, BLOCKLIST_AUTH_FAIL,
"Too many authentication attempts");
/* Shouldn't happen */
fatal_f("privsep child made too many authentication "
@@ -364,12 +364,12 @@ monitor_child_preauth(struct ssh *ssh, struct monitor *pmonitor)
}
if (!authctxt->valid) {
- BLACKLIST_NOTIFY(ssh, BLACKLIST_AUTH_FAIL,
+ BLOCKLIST_NOTIFY(ssh, BLOCKLIST_AUTH_FAIL,
"Authenticated invalid user");
fatal_f("authenticated invalid user");
}
if (strcmp(auth_method, "unknown") == 0) {
- BLACKLIST_NOTIFY(ssh, BLACKLIST_AUTH_FAIL,
+ BLOCKLIST_NOTIFY(ssh, BLOCKLIST_AUTH_FAIL,
"Authentication method name unknown");
fatal_f("authentication method name unknown");
}
diff --git a/crypto/openssh/servconf.c b/crypto/openssh/servconf.c
index 5ab34973bbcb..07d3bee2fcb9 100644
--- a/crypto/openssh/servconf.c
+++ b/crypto/openssh/servconf.c
@@ -217,7 +217,7 @@ initialize_server_options(ServerOptions *options)
options->sshd_session_path = NULL;
options->sshd_auth_path = NULL;
options->refuse_connection = -1;
- options->use_blacklist = -1;
+ options->use_blocklist = -1;
}
/* Returns 1 if a string option is unset or set to "none" or 0 otherwise. */
@@ -506,8 +506,8 @@ fill_default_server_options(ServerOptions *options)
options->sshd_auth_path = xstrdup(_PATH_SSHD_AUTH);
if (options->refuse_connection == -1)
options->refuse_connection = 0;
- if (options->use_blacklist == -1)
- options->use_blacklist = 0;
+ if (options->use_blocklist == -1)
+ options->use_blocklist = 0;
assemble_algorithms(options);
@@ -591,7 +591,7 @@ typedef enum {
sExposeAuthInfo, sRDomain, sPubkeyAuthOptions, sSecurityKeyProvider,
sRequiredRSASize, sChannelTimeout, sUnusedConnectionTimeout,
sSshdSessionPath, sSshdAuthPath, sRefuseConnection,
- sUseBlacklist,
+ sUseBlocklist,
sDeprecated, sIgnore, sUnsupported
} ServerOpCodes;
@@ -761,8 +761,8 @@ static struct {
{ "sshdsessionpath", sSshdSessionPath, SSHCFG_GLOBAL },
{ "sshdauthpath", sSshdAuthPath, SSHCFG_GLOBAL },
{ "refuseconnection", sRefuseConnection, SSHCFG_ALL },
- { "useblacklist", sUseBlacklist, SSHCFG_GLOBAL },
- { "useblocklist", sUseBlacklist, SSHCFG_GLOBAL }, /* alias */
+ { "useblocklist", sUseBlocklist, SSHCFG_GLOBAL },
+ { "useblacklist", sUseBlocklist, SSHCFG_GLOBAL }, /* alias */
{ NULL, sBadOption, 0 }
};
@@ -2742,8 +2742,8 @@ process_server_config_line_depth(ServerOptions *options, char *line,
multistate_ptr = multistate_flag;
goto parse_multistate;
- case sUseBlacklist:
- intptr = &options->use_blacklist;
+ case sUseBlocklist:
+ intptr = &options->use_blocklist;
goto parse_flag;
case sDeprecated:
@@ -3297,7 +3297,7 @@ dump_config(ServerOptions *o)
dump_cfg_fmtint(sFingerprintHash, o->fingerprint_hash);
dump_cfg_fmtint(sExposeAuthInfo, o->expose_userauth_info);
dump_cfg_fmtint(sRefuseConnection, o->refuse_connection);
- dump_cfg_fmtint(sUseBlacklist, o->use_blacklist);
+ dump_cfg_fmtint(sUseBlocklist, o->use_blocklist);
/* string arguments */
dump_cfg_string(sPidFile, o->pid_file);
diff --git a/crypto/openssh/servconf.h b/crypto/openssh/servconf.h
index ad3974322e83..38b2afeb15bd 100644
--- a/crypto/openssh/servconf.h
+++ b/crypto/openssh/servconf.h
@@ -253,7 +253,7 @@ typedef struct {
int refuse_connection;
- int use_blacklist;
+ int use_blocklist;
} ServerOptions;
/* Information about the incoming connection as used by Match */
diff --git a/crypto/openssh/sshd-session.c b/crypto/openssh/sshd-session.c
index 62c76cc1c8aa..e8299c254567 100644
--- a/crypto/openssh/sshd-session.c
+++ b/crypto/openssh/sshd-session.c
@@ -108,7 +108,7 @@
#include "sk-api.h"
#include "srclimit.h"
#include "dh.h"
-#include "blacklist_client.h"
+#include "blocklist_client.h"
/* Re-exec fds */
#define REEXEC_DEVCRYPTO_RESERVED_FD (STDERR_FILENO + 1)
@@ -217,7 +217,7 @@ mm_is_monitor(void)
static void
grace_alarm_handler(int sig)
{
- BLACKLIST_NOTIFY(the_active_state, BLACKLIST_AUTH_FAIL,
+ BLOCKLIST_NOTIFY(the_active_state, BLOCKLIST_AUTH_FAIL,
"Grace period expired");
/*
* Try to kill any processes that we have spawned, E.g. authorized
@@ -1203,7 +1203,7 @@ main(int ac, char **av)
ssh_signal(SIGCHLD, SIG_DFL);
ssh_signal(SIGINT, SIG_DFL);
- BLACKLIST_INIT();
+ BLOCKLIST_INIT();
/*
* Register our connection. This turns encryption off because we do
@@ -1282,7 +1282,7 @@ main(int ac, char **av)
if ((r = kex_exchange_identification(ssh, -1,
options.version_addendum)) != 0) {
- BLACKLIST_NOTIFY(ssh, BLACKLIST_AUTH_FAIL, "Banner exchange");
+ BLOCKLIST_NOTIFY(ssh, BLOCKLIST_AUTH_FAIL, "Banner exchange");
sshpkt_fatal(ssh, r, "banner exchange");
}
@@ -1430,7 +1430,7 @@ cleanup_exit(int i)
#endif
/* Override default fatal exit value when auth was attempted */
if (i == 255 && auth_attempted) {
- BLACKLIST_NOTIFY(the_active_state, BLACKLIST_AUTH_FAIL,
+ BLOCKLIST_NOTIFY(the_active_state, BLOCKLIST_AUTH_FAIL,
"Fatal exit");
_exit(EXIT_AUTH_ATTEMPTED);
}
diff --git a/crypto/openssh/sshd_config b/crypto/openssh/sshd_config
index 50a3d228fa58..708be7fe2870 100644
--- a/crypto/openssh/sshd_config
+++ b/crypto/openssh/sshd_config
@@ -107,7 +107,7 @@ AuthorizedKeysFile .ssh/authorized_keys
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
-#UseBlacklist no
+#UseBlocklist no
#VersionAddendum FreeBSD-20250801
# no default banner path
diff --git a/crypto/openssh/sshd_config.5 b/crypto/openssh/sshd_config.5
index ff1be7ba6ccf..c637d68f90c6 100644
--- a/crypto/openssh/sshd_config.5
+++ b/crypto/openssh/sshd_config.5
@@ -2020,20 +2020,20 @@ The default
is to never expire connections for having no open channels.
This option may be useful in conjunction with
.Cm ChannelTimeout .
-.It Cm UseBlacklist
+.It Cm UseBlocklist
Specifies whether
.Xr sshd 8
attempts to send authentication success and failure messages
to the
-.Xr blacklistd 8
+.Xr blocklistd 8
daemon.
The default is
.Cm no .
-For forward compatibility with an upcoming
-.Xr blacklistd
-rename, the
-.Cm UseBlocklist
-alias can be used instead.
+For backward compatibility with
+.Xr blacklistd 8 ,
+the
+.Cm UseBlacklist
+alias can still be used.
.It Cm UseDNS
Specifies whether
.Xr sshd 8
diff --git a/etc/mtree/BSD.include.dist b/etc/mtree/BSD.include.dist
index 28c4d91ac1c0..454657183c58 100644
--- a/etc/mtree/BSD.include.dist
+++ b/etc/mtree/BSD.include.dist
@@ -276,9 +276,7 @@
..
kadm5
..
- kdb5
- ..
- krb5
+ krb5 tags=package=kerberos-dev
..
lib80211
..
diff --git a/etc/mtree/BSD.usr.dist b/etc/mtree/BSD.usr.dist
index d7d839b94b96..6a8c155e5e73 100644
--- a/etc/mtree/BSD.usr.dist
+++ b/etc/mtree/BSD.usr.dist
@@ -85,15 +85,15 @@
..
i18n
..
- krb5
- kdb
+ krb5 tags=package=kerberos-kdc
+ kdb tags=package=kerberos-kdc
..
- plugins
- kdb
+ plugins tags=package=kerberos-kdc
+ kdb tags=package=kerberos-kdc
..
- preauth
+ preauth tags=package=kerberos-kdc
..
- tls
+ tls tags=package=kerberos-kdc
..
..
..
@@ -269,7 +269,7 @@
..
dtrace
..
- et
+ et tags=package=kerberos-dev
..
examples
BSD_daemon
diff --git a/etc/mtree/BSD.var.dist b/etc/mtree/BSD.var.dist
index d8593e61c49e..b3372196f5f9 100644
--- a/etc/mtree/BSD.var.dist
+++ b/etc/mtree/BSD.var.dist
@@ -45,7 +45,7 @@
..
ipf mode=0700 tags=package=ipf
..
- krb5kdc mode=0700
+ krb5kdc mode=0700 tags=package=kerberos-kdc
..
mtree
..
diff --git a/lib/Makefile b/lib/Makefile
index d43e4d395f56..75a2355aa452 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -163,6 +163,7 @@ SUBDIR_DEPEND_virtual_oss= libsamplerate
SUBDIR.${MK_BEARSSL}+= libbearssl libsecureboot
SUBDIR.${MK_BLACKLIST}+=libblacklist
+SUBDIR.${MK_BLOCKLIST}+=libblocklist
SUBDIR.${MK_BLUETOOTH}+=libbluetooth libsdp
SUBDIR.${MK_BSNMP}+= libbsnmp
diff --git a/lib/libblacklist/Makefile b/lib/libblacklist/Makefile
index bfd9edb9614c..cac023d69bb7 100644
--- a/lib/libblacklist/Makefile
+++ b/lib/libblacklist/Makefile
@@ -1,6 +1,6 @@
BLOCKLIST_DIR=${SRCTOP}/contrib/blocklist
-.PATH: ${BLOCKLIST_DIR}/lib ${BLOCKLIST_DIR}/include
+.PATH: ${BLOCKLIST_DIR}/lib ${BLOCKLIST_DIR}/include ${BLOCKLIST_DIR}/port
PACKAGE= blocklist
LIB= blacklist
@@ -13,9 +13,10 @@ CFLAGS.clang+=-Wno-thread-safety-analysis
CFLAGS+=-I${BLOCKLIST_DIR}/include -I${BLOCKLIST_DIR}/port \
-D_REENTRANT -DHAVE_CONFIG_H -DHAVE_DB_H -DHAVE_LIBUTIL_H \
-DHAVE_CLOCK_GETTIME -DHAVE_FGETLN -DHAVE_GETPROGNAME \
- -DHAVE_STRLCAT -DHAVE_STRLCPY -DHAVE_STRUCT_SOCKADDR_SA_LEN
+ -DHAVE_STRLCAT -DHAVE_STRLCPY -DHAVE_STRUCT_SOCKADDR_SA_LEN \
+ -DHAVE_SYS_CDEFS_H
-SRCS= bl.c blacklist.c
+SRCS= old_bl.c blacklist.c vsyslog_r.c
INCS= blacklist.h
MAN= libblacklist.3
diff --git a/lib/libblocklist/Makefile b/lib/libblocklist/Makefile
new file mode 100644
index 000000000000..127abb23f43e
--- /dev/null
+++ b/lib/libblocklist/Makefile
@@ -0,0 +1,30 @@
+BLOCKLIST_DIR=${SRCTOP}/contrib/blocklist
+
+.PATH: ${BLOCKLIST_DIR}/lib ${BLOCKLIST_DIR}/include ${BLOCKLIST_DIR}/port
+
+PACKAGE= blocklist
+LIB= blocklist
+SHLIB_MAJOR= 0
+
+LIBADD+= pthread
+
+CFLAGS.clang+=-Wno-thread-safety-analysis
+
+CFLAGS+=-I${BLOCKLIST_DIR}/include -I${BLOCKLIST_DIR}/port \
+ -D_REENTRANT -DHAVE_CONFIG_H -DHAVE_DB_H -DHAVE_LIBUTIL_H \
+ -DHAVE_CLOCK_GETTIME -DHAVE_FGETLN -DHAVE_GETPROGNAME \
+ -DHAVE_STRLCAT -DHAVE_STRLCPY -DHAVE_STRUCT_SOCKADDR_SA_LEN \
+ -DHAVE_SYS_CDEFS_H
+
+SRCS= bl.c blocklist.c vsyslog_r.c
+INCS= blocklist.h
+MAN= libblocklist.3
+
+MLINKS= libblocklist.3 blocklist_open.3 \
+ libblocklist.3 blocklist_close.3 \
+ libblocklist.3 blocklist.3 \
+ libblocklist.3 blocklist_r.3 \
+ libblocklist.3 blocklist_sa.3 \
+ libblocklist.3 blocklist_sa_r.3
+
+.include <bsd.lib.mk>
diff --git a/lib/libblocklist/Makefile.depend b/lib/libblocklist/Makefile.depend
new file mode 100644
index 000000000000..577dc5747f1e
--- /dev/null
+++ b/lib/libblocklist/Makefile.depend
@@ -0,0 +1,16 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libthr \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/libbluetooth/Makefile b/lib/libbluetooth/Makefile
index a6ac291a0bf8..b935bdf3fc78 100644
--- a/lib/libbluetooth/Makefile
+++ b/lib/libbluetooth/Makefile
@@ -1,6 +1,8 @@
# $Id: Makefile,v 1.5 2003/07/22 18:38:04 max Exp $
PACKAGE= bluetooth
+LIB_PACKAGE=
+
CONFS= hosts protocols
CONFSDIR= /etc/bluetooth
CONFSMODE_protocols= 444
diff --git a/lib/libbz2/Makefile b/lib/libbz2/Makefile
index d773f202dd67..2aedbaed4328 100644
--- a/lib/libbz2/Makefile
+++ b/lib/libbz2/Makefile
@@ -13,4 +13,17 @@ CFLAGS+= -I${BZ2DIR}
WARNS?= 3
+BZIP2_VERSION!= sed -n '/bzip2\/libbzip2 version /{s/.*version //;s/ of.*//p;q;}' ${BZ2DIR}/bzlib.h
+
+bzip2.pc: bzip2.pc.in
+ sed -e 's,@prefix@,/usr,g ; \
+ s,@exec_prefix@,$${prefix},g ; \
+ s,@libdir@,${LIBDIR},g ; \
+ s,@sharedlibdir@,${SHLIBDIR},g ; \
+ s,@includedir@,${INCLUDEDIR},g ; \
+ s,@VERSION@,${BZIP2_VERSION},g ;' \
+ ${.ALLSRC} > ${.TARGET}
+
+PCFILES= bzip2.pc
+
.include <bsd.lib.mk>
diff --git a/lib/libbz2/bzip2.pc.in b/lib/libbz2/bzip2.pc.in
new file mode 100644
index 000000000000..d91c9931a58a
--- /dev/null
+++ b/lib/libbz2/bzip2.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+sharedlibdir=@sharedlibdir@
+includedir=@includedir@
+
+Name: bzip2
+Description: bzip2 compression library
+Version: @VERSION@
+Libs: -L${libdir} -lbz2
+Cflags: -I${includedir}
diff --git a/lib/libcasper/services/cap_fileargs/cap_fileargs.h b/lib/libcasper/services/cap_fileargs/cap_fileargs.h
index 8207671d9753..d3a0150044d7 100644
--- a/lib/libcasper/services/cap_fileargs/cap_fileargs.h
+++ b/lib/libcasper/services/cap_fileargs/cap_fileargs.h
@@ -75,7 +75,7 @@ fileargs_init(int argc __unused, char *argv[] __unused, int flags, mode_t mode,
cap_rights_t *rightsp __unused, int operations __unused) {
fileargs_t *fa;
- fa = malloc(sizeof(*fa));
+ fa = (fileargs_t *)malloc(sizeof(*fa));
if (fa != NULL) {
fa->fa_flags = flags;
fa->fa_mode = mode;
diff --git a/lib/libsys/getgroups.2 b/lib/libsys/getgroups.2
index 4881a65d532e..4e94b32d4e7b 100644
--- a/lib/libsys/getgroups.2
+++ b/lib/libsys/getgroups.2
@@ -33,7 +33,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd September 17, 2025
+.Dd October 10, 2025
.Dt GETGROUPS 2
.Os
.Sh NAME
@@ -107,10 +107,8 @@ array.
The
.Fn getgroups
system call conforms to
-.St -p1003.1-2008
-with the additional properties that supplementary groups are reported in
-strictly ascending order and the returned size coincides with the cardinal of
-the set.
+.St -p1003.1-2008 ,
+not reporting the effective group ID.
.Sh HISTORY
The
.Fn getgroups
@@ -121,8 +119,8 @@ Since
.Fx 14.3 ,
the
.Fn getgroups
-system call has treated the supplementary groups as a set, reporting them in
-strictly ascending order and returning the cardinal of the set.
+system call has been reporting the supplementary groups in strictly ascending
+order.
.Pp
Before
.Fx 15.0 ,
@@ -138,15 +136,14 @@ system call gets the supplementary groups set in the
array.
In particular, as evoked in
.Sx HISTORY ,
-it does not anymore retrieve the effective GID in the first slot of
+it does not anymore retrieve the effective group ID in the first slot of
.Fa gidset .
-Programs should not make any assumption about which group is placed in the first
-slot of
-.Fa gidset
-other than it being the supplementary group with smallest GID.
+Programs that process this slot in a specific way must be modified to obtain the
+effective group ID through other means, such as a call to
+.Xr getegid 2 .
.Pp
-The effective GID is present in the supplementary groups set if and only if it
-was explicitly set as a supplementary group.
+The effective group ID is present in the supplementary groups set if and only if
+it was explicitly set as a supplementary group.
The function
.Fn initgroups
enforces that, while the
diff --git a/lib/libsysdecode/Makefile.depend b/lib/libsysdecode/Makefile.depend
index 1c40e21d361d..a9ccf3aa0870 100644
--- a/lib/libsysdecode/Makefile.depend
+++ b/lib/libsysdecode/Makefile.depend
@@ -38,7 +38,7 @@ DIRDEPS = \
lib/libarchive \
lib/libbe \
lib/libbegemot \
- lib/libblacklist \
+ lib/libblocklist \
lib/libblocksruntime \
lib/libbluetooth \
lib/libbsddialog \
diff --git a/lib/msun/src/e_remainder.c b/lib/msun/src/e_remainder.c
index a5fb7141d01a..cc6cd320073e 100644
--- a/lib/msun/src/e_remainder.c
+++ b/lib/msun/src/e_remainder.c
@@ -64,8 +64,8 @@ remainder(double x, double p)
if(x>=p_half) x -= p;
}
}
- GET_HIGH_WORD(hx,x);
- if ((hx&0x7fffffff)==0) hx = 0;
+ EXTRACT_WORDS(hx, lx, x);
+ if (((hx&0x7fffffff)|lx) == 0) hx = 0;
SET_HIGH_WORD(x,hx^sx);
return x;
}
diff --git a/lib/virtual_oss/Makefile.inc b/lib/virtual_oss/Makefile.inc
index 45c8e0b1fdfc..877465a5c548 100644
--- a/lib/virtual_oss/Makefile.inc
+++ b/lib/virtual_oss/Makefile.inc
@@ -1,3 +1,5 @@
+PACKAGE= sound
+
.include "../Makefile.inc"
LDFLAGS+= -L${.OBJDIR:H:H}/libsamplerate
diff --git a/libexec/Makefile b/libexec/Makefile
index e87b48b153a8..180dd10b5d29 100644
--- a/libexec/Makefile
+++ b/libexec/Makefile
@@ -4,7 +4,7 @@
SUBDIR= ${_atf} \
${_atrun} \
- ${_blacklistd-helper} \
+ ${_blocklistd-helper} \
${_comsat} \
${_dma} \
flua \
@@ -37,8 +37,8 @@ SUBDIR= ${_atf} \
_atrun= atrun
.endif
-.if ${MK_BLACKLIST} != "no"
-_blacklistd-helper+= blacklistd-helper
+.if ${MK_BLOCKLIST} != "no"
+_blocklistd-helper+= blocklistd-helper
.endif
.if ${MK_BOOTPD} != "no"
diff --git a/libexec/blacklistd-helper/Makefile b/libexec/blacklistd-helper/Makefile
deleted file mode 100644
index d32b69c278a8..000000000000
--- a/libexec/blacklistd-helper/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-BLOCKLIST_DIR=${SRCTOP}/contrib/blocklist
-
-PACKAGE= blocklist
-
-SCRIPTS= ${BLOCKLIST_DIR}/libexec/blacklistd-helper
-
-.include <bsd.prog.mk>
diff --git a/libexec/blocklistd-helper/Makefile b/libexec/blocklistd-helper/Makefile
new file mode 100644
index 000000000000..5c72b5155662
--- /dev/null
+++ b/libexec/blocklistd-helper/Makefile
@@ -0,0 +1,10 @@
+BLOCKLIST_DIR=${SRCTOP}/contrib/blocklist
+
+PACKAGE= blocklist
+
+SCRIPTS= ${BLOCKLIST_DIR}/libexec/blocklistd-helper
+
+# blacklist
+SCRIPTS+= blacklistd-helper
+
+.include <bsd.prog.mk>
diff --git a/libexec/blacklistd-helper/Makefile.depend b/libexec/blocklistd-helper/Makefile.depend
index 11aba52f82cf..11aba52f82cf 100644
--- a/libexec/blacklistd-helper/Makefile.depend
+++ b/libexec/blocklistd-helper/Makefile.depend
diff --git a/libexec/blocklistd-helper/blacklistd-helper b/libexec/blocklistd-helper/blacklistd-helper
new file mode 100644
index 000000000000..92f768e86cdf
--- /dev/null
+++ b/libexec/blocklistd-helper/blacklistd-helper
@@ -0,0 +1,293 @@
+#!/bin/sh
+#echo "run $@" 1>&2
+#set -x
+# $1 command
+# $2 rulename
+# $3 protocol
+# $4 address
+# $5 mask
+# $6 port
+# $7 id
+
+pf=
+if [ -f "/etc/ipfw-blacklist.rc" ]; then
+ echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" >&2
+ echo "@ WARNING: rename /etc/ipfw-blacklist.rc to @" >&2
+ echo "@ /etc/ipfw-blocklist.rc @" >&2
+ echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" >&2
+
+ pf="ipfw"
+ . /etc/ipfw-blacklist.rc
+ ipfw_offset=${ipfw_offset:-2000}
+fi
+
+if [ -z "$pf" ]; then
+ for f in npf pf ipfilter ipfw; do
+ if [ -x /etc/rc.d/$f ]; then
+ if /etc/rc.d/$f status >/dev/null 2>&1; then
+ pf="$f"
+ break
+ fi
+ elif [ -f "/etc/$f.conf" ]; then
+ # xxx assume a config file means it can be enabled --
+ # and the first one wins!
+ pf="$f"
+ break
+ fi
+ done
+fi
+
+if [ -z "$pf" -a -x "/sbin/iptables" ]; then
+ pf="iptables"
+fi
+
+if [ -z "$pf" ]; then
+ echo "$0: Unsupported packet filter" 1>&2
+ exit 1
+fi
+
+flags=
+if [ -n "$3" ]; then
+ raw_proto="$3"
+ proto="proto $3"
+ if [ $3 = "tcp" ]; then
+ flags="flags S/SAFR"
+ fi
+fi
+
+if [ -n "$6" ]; then
+ raw_port="$6"
+ port="port $6"
+fi
+
+addr="$4"
+mask="$5"
+case "$4" in
+::ffff:*.*.*.*)
+ if [ "$5" = 128 ]; then
+ mask=32
+ addr=${4#::ffff:}
+ fi;;
+esac
+
+if [ "$pf" = "pf" ]; then
+ for anchor in $(/sbin/pfctl -s Anchors 2> /dev/null); do
+ if [ "$anchor" = "blacklistd" ]; then
+ echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" >&2
+ echo "@ WARNING: rename the blacklist anchor to blocklist @" >&2
+ echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" >&2
+ fi
+ done
+fi
+
+if [ "$pf" = "ipfilter" ]; then
+ echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" >&2
+ echo "@ WARNING: blacklist has been renamed to blocklist @" >&2
+ echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" >&2
+fi
+
+case "$1" in
+add)
+ case "$pf" in
+ ipfilter)
+ # N.B.: If you reload /etc/ipf.conf then you need to stop and
+ # restart blacklistd (and make sure blacklistd_flags="-r").
+ # This should normally already be implemented in
+ # /etc/rc.d/ipfilter, but if then not add the following lines to
+ # the end of the ipfilter_reload() function:
+ #
+ # if checkyesnox blacklistd; then
+ # /etc/rc.d/blacklistd restart
+ # fi
+ #
+ # XXX we assume the following rule is present in /etc/ipf.conf:
+ # (should we check? -- it probably cannot be added dynamically)
+ #
+ # block in proto tcp/udp from any to any head blacklistd
+ #
+ # where "blacklistd" is the default rulename (i.e. "$2")
+ #
+ # This rule can come before any rule that logs connections,
+ # etc., and should be followed by final rules such as:
+ #
+ # # log all as-yet unblocked incoming TCP connection
+ # # attempts
+ # log in proto tcp from any to any flags S/SAFR
+ # # last "pass" match wins for all non-blocked packets
+ # pass in all
+ # pass out all
+ #
+ # I.e. a "pass" rule which will be the final match and override
+ # the "block". This way the rules added by blacklistd will
+ # actually block packets, and prevent logging of them as
+ # connections, because they include the "quick" flag.
+ #
+ # N.b.: $port is not included/used in rules -- abusers are cut
+ # off completely from all services!
+ #
+ # Note RST packets are not returned for blocked SYN packets of
+ # active attacks, so the port will not appear to be closed.
+ # This will probably give away the fact that a firewall has been
+ # triggered to block connections, but it prevents generating
+ # extra outbound traffic, and it may also slow down the attacker
+ # somewhat.
+ #
+ # Note also that we don't block all packets, just new attempts
+ # to open connections (see $flags above). This allows us to do
+ # counterespionage against the attacker (or continue to make use
+ # of any other services that might be on the same subnet as the
+ # supposed attacker). However it does not kill any active
+ # connections -- we rely on the reporting daemon to do its own
+ # protection and cleanup.
+ #
+ # N.B.: The rule generated here must exactly match the
+ # corresponding rule generated for the "rem" command below!
+ #
+ echo block in log quick $proto \
+ from $addr/$mask to any $flags group $2 | \
+ /sbin/ipf -A -f - >/dev/null 2>&1 && echo OK
+ ;;
+
+ ipfw)
+ # use $ipfw_offset+$port for rule number
+ rule=$(($ipfw_offset + $6))
+ tname="port$6"
+ /sbin/ipfw table $tname create type addr 2>/dev/null
+ /sbin/ipfw -q table $tname add "$addr/$mask"
+ # if rule number $rule does not already exist, create it
+ /sbin/ipfw show $rule >/dev/null 2>&1 || \
+ /sbin/ipfw add $rule drop $3 from \
+ table"("$tname")" to any dst-port $6 >/dev/null && \
+ echo OK
+ ;;
+
+ iptables)
+ if ! /sbin/iptables --list "$2" >/dev/null 2>&1; then
+ /sbin/iptables --new-chain "$2"
+ fi
+ /sbin/iptables --append INPUT --proto "$raw_proto" \
+ --dport "$raw_port" --jump "$2"
+ /sbin/iptables --append "$2" --proto "$raw_proto" \
+ --source "$addr/$mask" --dport "$raw_port" --jump DROP
+ echo OK
+ ;;
+
+ npf)
+ /sbin/npfctl rule "$2" add block in final $proto from \
+ "$addr/$mask" to any $port
+ ;;
+
+ pf)
+ # if the filtering rule does not exist, create it
+ /sbin/pfctl -a "$2/$6" -sr 2>/dev/null | \
+ grep -q "<port$6>" || \
+ echo "block in quick $proto from <port$6> to any $port" | \
+ /sbin/pfctl -a "$2/$6" -f -
+ # insert $ip/$mask into per-protocol/port anchored table
+ /sbin/pfctl -qa "$2/$6" -t "port$6" -T add "$addr/$mask" && \
+ /sbin/pfctl -qk "$addr" && echo OK
+ ;;
+
+ esac
+ ;;
+rem)
+ case "$pf" in
+ ipfilter)
+ # N.B.: The rule generated here must exactly match the
+ # corresponding rule generated for the "add" command above!
+ #
+ echo block in log quick $proto \
+ from $addr/$mask to any $flags group $2 | \
+ /sbin/ipf -A -r -f - >/dev/null 2>&1 && echo OK
+ ;;
+
+ ipfw)
+ /sbin/ipfw table "port$6" delete "$addr/$mask" 2>/dev/null && \
+ echo OK
+ ;;
+
+ iptables)
+ if /sbin/iptables --list "$2" >/dev/null 2>&1; then
+ /sbin/iptables --delete "$2" --proto "$raw_proto" \
+ --source "$addr/$mask" --dport "$raw_port" \
+ --jump DROP
+ fi
+ echo OK
+ ;;
+
+ npf)
+ /sbin/npfctl rule "$2" rem-id "$7"
+ ;;
+
+ pf)
+ /sbin/pfctl -qa "$2/$6" -t "port$6" -T delete "$addr/$mask" && \
+ echo OK
+ ;;
+
+ esac
+ ;;
+flush)
+ case "$pf" in
+ ipfilter)
+ #
+ # N.B. WARNING: This is obviously not reentrant!
+ #
+ # First we flush all the rules from the inactive set, then we
+ # reload the ones that do not belong to the group "$2", and
+ # finally we swap the active and inactive rule sets.
+ #
+ /sbin/ipf -I -F a
+ #
+ # "ipf -I -F a" also flushes active accounting rules!
+ #
+ # Note that accounting rule groups are unique to accounting
+ # rules and have nothing to do with filter rules, though of
+ # course theoretically one could use the same group name for
+ # them too.
+ #
+ # In theory anyone using any such accounting rules should have a
+ # wrapper /etc/rc.conf.d/blacklistd script (and corresponding
+ # /etc/rc.conf.d/ipfilter script) that will record and
+ # consolidate the values accumulated by such accounting rules
+ # before they are flushed, since otherwise their counts will be
+ # lost forever.
+ #
+ /usr/sbin/ipfstat -io | fgrep -v "group $2" | \
+ /sbin/ipf -I -f - >/dev/null 2>&1
+ #
+ # This MUST be done last and separately as "-s" is executed
+ # _while_ the command arguments are being processed!
+ #
+ /sbin/ipf -s && echo OK
+ ;;
+
+ ipfw)
+ /sbin/ipfw table "port$6" flush 2>/dev/null && echo OK
+ ;;
+
+ iptables)
+ if /sbin/iptables --list "$2" >/dev/null 2>&1; then
+ /sbin/iptables --flush "$2"
+ fi
+ echo OK
+ ;;
+
+ npf)
+ /sbin/npfctl rule "$2" flush
+ ;;
+
+ pf)
+ # dynamically determine which anchors exist
+ for anchor in $(/sbin/pfctl -a "$2" -s Anchors 2> /dev/null); do
+ /sbin/pfctl -a "$anchor" -t "port${anchor##*/}" -T flush 2> /dev/null
+ /sbin/pfctl -a "$anchor" -F rules
+ done
+ echo OK
+ ;;
+ esac
+ ;;
+*)
+ echo "$0: Unknown command '$1'" 1>&2
+ exit 1
+ ;;
+esac
diff --git a/libexec/fingerd/Makefile b/libexec/fingerd/Makefile
index 296cb504bab1..e2fe412df8bc 100644
--- a/libexec/fingerd/Makefile
+++ b/libexec/fingerd/Makefile
@@ -7,10 +7,10 @@ MAN= fingerd.8
WARNS?= 2
WFORMAT=0
-.if ${MK_BLACKLIST_SUPPORT} != "no"
-CFLAGS+= -DUSE_BLACKLIST -I${SRCTOP}/contrib/blocklist/include
-LIBADD+= blacklist
-LDFLAGS+=-L${LIBBLACKLISTDIR}
+.if ${MK_BLOCKLIST_SUPPORT} != "no"
+CFLAGS+= -DUSE_BLOCKLIST -I${SRCTOP}/contrib/blocklist/include
+LIBADD+= blocklist
+LDFLAGS+=-L${LIBBLOCKLISTDIR}
.endif
.include <bsd.prog.mk>
diff --git a/libexec/fingerd/Makefile.depend.options b/libexec/fingerd/Makefile.depend.options
index 5a94eff626dc..f68343adae89 100644
--- a/libexec/fingerd/Makefile.depend.options
+++ b/libexec/fingerd/Makefile.depend.options
@@ -1,5 +1,5 @@
# This file is not autogenerated - take care!
-DIRDEPS_OPTIONS= BLACKLIST_SUPPORT
+DIRDEPS_OPTIONS= BLOCKLIST_SUPPORT
.include <dirdeps-options.mk>
diff --git a/libexec/fingerd/fingerd.c b/libexec/fingerd/fingerd.c
index c30d5e5e0ef5..8b63aa338b0c 100644
--- a/libexec/fingerd/fingerd.c
+++ b/libexec/fingerd/fingerd.c
@@ -45,8 +45,8 @@
#include <stdlib.h>
#include <string.h>
#include "pathnames.h"
-#ifdef USE_BLACKLIST
-#include <blacklist.h>
+#ifdef USE_BLOCKLIST
+#include <blocklist.h>
#endif
void logerr(const char *, ...) __printflike(1, 2) __dead2;
@@ -144,8 +144,8 @@ main(int argc, char *argv[])
*ap = strtok(lp, " \t\r\n");
if (!*ap) {
if (secure && ap == &av[4]) {
-#ifdef USE_BLACKLIST
- blacklist(1, STDIN_FILENO, "nousername");
+#ifdef USE_BLOCKLIST
+ blocklist(1, STDIN_FILENO, "nousername");
#endif
puts("must provide username\r\n");
exit(1);
@@ -153,8 +153,8 @@ main(int argc, char *argv[])
break;
}
if (secure && strchr(*ap, '@')) {
-#ifdef USE_BLACKLIST
- blacklist(1, STDIN_FILENO, "noforwarding");
+#ifdef USE_BLOCKLIST
+ blocklist(1, STDIN_FILENO, "noforwarding");
#endif
puts("forwarding service denied\r\n");
exit(1);
@@ -194,8 +194,8 @@ main(int argc, char *argv[])
}
dup2(STDOUT_FILENO, STDERR_FILENO);
-#ifdef USE_BLACKLIST
- blacklist(0, STDIN_FILENO, "success");
+#ifdef USE_BLOCKLIST
+ blocklist(0, STDIN_FILENO, "success");
#endif
execv(prog, comp);
write(STDERR_FILENO, prog, strlen(prog));
diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf
index c776a815003c..b7cce777c4f6 100644
--- a/libexec/rc/rc.conf
+++ b/libexec/rc/rc.conf
@@ -319,8 +319,10 @@ ctld_enable="NO" # CAM Target Layer / iSCSI target daemon.
local_unbound_enable="NO" # Local caching DNS resolver
local_unbound_oomprotect="YES" # Don't kill local_unbound when swap space is exhausted.
local_unbound_tls="NO" # Use DNS over TLS
-blacklistd_enable="NO" # Run blacklistd daemon (YES/NO).
-blacklistd_flags="" # Optional flags for blacklistd(8).
+blacklistd_enable="NO" # Renamed to blocklistd_enable.
+blacklistd_flags="" # Renamed to blocklistd_flags.
+blocklistd_enable="NO" # Run blocklistd daemon (YES/NO).
+blocklistd_flags="" # Optional flags for blocklistd(8).
resolv_enable="YES" # Enable resolv / resolvconf
#
diff --git a/libexec/rc/rc.d/Makefile b/libexec/rc/rc.d/Makefile
index f6d1a34ceb9e..093da31ed787 100644
--- a/libexec/rc/rc.d/Makefile
+++ b/libexec/rc/rc.d/Makefile
@@ -111,9 +111,10 @@ AUTOFS= automount \
automountd \
autounmountd
-CONFGROUPS.${MK_BLACKLIST}+= BLOCKLIST
+CONFGROUPS.${MK_BLOCKLIST}+= BLOCKLIST
BLOCKLISTPACKAGE= blocklist
-BLOCKLIST= blacklistd
+BLOCKLIST= blacklistd \
+ blocklistd
CONFGROUPS.${MK_BLUETOOTH}+= BLUETOOTH
BLUETOOTHPACKAGE= bluetooth
diff --git a/libexec/rc/rc.d/blacklistd b/libexec/rc/rc.d/blacklistd
index 5248b0ea3580..9157e258f43f 100755
--- a/libexec/rc/rc.d/blacklistd
+++ b/libexec/rc/rc.d/blacklistd
@@ -34,13 +34,21 @@
. /etc/rc.subr
name="blacklistd"
-desc="System blacklist daemon"
+desc="The blacklist daemon has been renamed to blocklist"
rcvar="blacklistd_enable"
command="/usr/sbin/${name}"
required_files="/etc/blacklistd.conf"
+start_precmd="blacklistd_prestart"
# no svcj options needed
: ${blacklistd_svcj_options:=""}
+blacklistd_prestart()
+{
+ echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
+ echo "@ WARNING: blacklistd has been renamed to blocklistd @"
+ echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
+}
+
load_rc_config $name
run_rc_command "$1"
diff --git a/libexec/rc/rc.d/blocklistd b/libexec/rc/rc.d/blocklistd
new file mode 100644
index 000000000000..24cbae77fd40
--- /dev/null
+++ b/libexec/rc/rc.d/blocklistd
@@ -0,0 +1,46 @@
+#!/bin/sh
+#
+# Copyright (c) 2016 The FreeBSD Foundation
+#
+# This software was developed by Kurt Lidl under sponsorship from the
+# FreeBSD Foundation.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+#
+
+# PROVIDE: blocklistd
+# REQUIRE: netif pf
+
+. /etc/rc.subr
+
+name="blocklistd"
+desc="System blocklist daemon"
+rcvar="blocklistd_enable"
+command="/usr/sbin/${name}"
+required_files="/etc/blocklistd.conf"
+
+# no svcj options needed
+: ${blocklistd_svcj_options:=""}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/libexec/rc/rc.d/virtual_oss b/libexec/rc/rc.d/virtual_oss
index 4f5c34ce03f3..b9c830617385 100644
--- a/libexec/rc/rc.d/virtual_oss
+++ b/libexec/rc/rc.d/virtual_oss
@@ -1,8 +1,8 @@
#!/bin/sh
# PROVIDE: virtual_oss
-# REQUIRE: kld ldconfig
-# BEFORE: LOGIN sndiod
+# REQUIRE: NETWORKING kld ldconfig
+# BEFORE: LOGIN
# KEYWORD: shutdown
. /etc/rc.subr
diff --git a/release/Makefile.mirrors b/release/Makefile.mirrors
index ed9420e926ce..924d289d1c44 100644
--- a/release/Makefile.mirrors
+++ b/release/Makefile.mirrors
@@ -407,7 +407,6 @@ pkgbase-repo-stage:
mv pkgbase-repo.tar ${OSRELEASE}-pkgbase-repo.tar
cp -p ${RELEASEDIR}/pkgbase/${OSRELEASE}-pkgbase-repo.tar \
${PKGBASE_DIR}/Latest/${OSRELEASE}-pkgbase-repo.tar
-. endfor
. for CHECKSUM in ${CHECKSUM_FILES}
cd ${RELEASEDIR}/pkgbase && \
${CHECKSUM:tl} ${OSRELEASE}-pkgbase-repo.tar > CHECKSUM.${CHECKSUM}
diff --git a/release/packages/ucl/acpi-all.ucl b/release/packages/ucl/acpi-all.ucl
index 9e75822a8a04..9b63b825bd60 100644
--- a/release/packages/ucl/acpi-all.ucl
+++ b/release/packages/ucl/acpi-all.ucl
@@ -23,7 +23,7 @@ ACPI is a hardware standard allowing the operating system to monitor various
hardware devices and system state. For example, ACPI can report whether the
system is on AC or battery power.
-This packages provides several utilities that can be used to interact with the
+This package provides several utilities that can be used to interact with the
ACPI implementation in the kernel:
* The /etc/rc.d/power_profile service can be used to change system performance
diff --git a/release/packages/ucl/audit-all.ucl b/release/packages/ucl/audit-all.ucl
index 3324795d8d9c..0ff79f7c6b73 100644
--- a/release/packages/ucl/audit-all.ucl
+++ b/release/packages/ucl/audit-all.ucl
@@ -39,7 +39,7 @@ The audit facility implements the de facto industry standard BSM API, file
formats, and command line interface, first found in the Solaris operating
system.
-This packages provides the auditing daemon auditd(8) and various utilities
+This package provides the auditing daemon auditd(8) and various utilities
used to manage the auditing system and work with audit data.
EOD
diff --git a/release/packages/ucl/blocklist-all.ucl b/release/packages/ucl/blocklist-all.ucl
index 92f304ac9151..273df85fc22b 100644
--- a/release/packages/ucl/blocklist-all.ucl
+++ b/release/packages/ucl/blocklist-all.ucl
@@ -19,12 +19,14 @@
comment = "Network blocklist daemon"
desc = <<EOD
-The blacklistd(8) daemon monitors failed access attempts from remote network
+The blocklistd(8) daemon monitors failed access attempts from remote network
locations and automatically blocks the originating network address using the
system packet filter.
-blacklistd(8) relies on each network daemon to report access attempts, so
-only daemons which have had blacklist support added will work.
+blocklistd(8) relies on each network daemon to report access attempts, so
+only daemons which have had blocklist support added will work.
+
+The blocklistd(8) daemon was previously named blacklistd(8).
EOD
annotations {
diff --git a/release/packages/ucl/libbegemot-all.ucl b/release/packages/ucl/libbegemot-all.ucl
index 812e94f72eaf..5bead26f69f8 100644
--- a/release/packages/ucl/libbegemot-all.ucl
+++ b/release/packages/ucl/libbegemot-all.ucl
@@ -41,8 +41,8 @@ calls are however clumsy to use and the usage of one of these calls is
probably not portable to other systems - not all systems support both calls.
The rpoll(3) family of functions is designed to overcome these restrictions.
-They support the well known and understood technique of event driven programing
-and, in addition to select(2) and poll(2) also support timers.
+They support the well known and understood technique of event driven
+programming and, in addition to select(2) and poll(2) also support timers.
EOD
annotations {
diff --git a/release/packages/ucl/libbsdstat-all.ucl b/release/packages/ucl/libbsdstat-all.ucl
index 144d4200fed9..56efee79a334 100644
--- a/release/packages/ucl/libbsdstat-all.ucl
+++ b/release/packages/ucl/libbsdstat-all.ucl
@@ -19,7 +19,7 @@
comment = "Periodic statistics library"
desc = <<EOD
-libbsdstat is a library for managing and display periodically collected
+libbsdstat is a library for managing and displaying periodically collected
statistics.
EOD
diff --git a/release/packages/ucl/mandoc-all.ucl b/release/packages/ucl/mandoc-all.ucl
index 3948c4ce261e..ebd6a9da59e0 100644
--- a/release/packages/ucl/mandoc-all.ucl
+++ b/release/packages/ucl/mandoc-all.ucl
@@ -19,7 +19,7 @@
comment = "Online manual page reader"
desc = <<EOD
-This packages provides man(1), a utility which can format and display system
+This package provides man(1), a utility which can format and display system
manual pages, along with the related utilities apropos(1) and makewhatis(8),
and the mandoc(1) rendering backend.
EOD
diff --git a/release/packages/ucl/yp-all.ucl b/release/packages/ucl/yp-all.ucl
index f361f319b730..fb337394fc4c 100644
--- a/release/packages/ucl/yp-all.ucl
+++ b/release/packages/ucl/yp-all.ucl
@@ -20,7 +20,7 @@ comment = "Yellow Pages (YP) / Network Information Service (NIS)"
desc = <<EOD
YP, also called NIS, is a network protocol for sharing name service
-information across machines on a network. This packages contain the YP
+information across machines on a network. This package contains the YP
server, YP management utilities, the YP-LDAP gateway (ypldap), YP client
utilities and a sample Makefile for building the YP database.
EOD
diff --git a/release/tools/ec2-base.conf b/release/tools/ec2-base.conf
index b6354db3d9d1..ffe2646240a5 100644
--- a/release/tools/ec2-base.conf
+++ b/release/tools/ec2-base.conf
@@ -36,5 +36,9 @@ vm_extra_pre_umount() {
# Standard FreeBSD network configuration
ec2_base_networking
+ # Add files from packages which weren't recorded in metalog
+ metalog_add_data ./usr/local/etc/dhclient.conf
+ metalog_add_data ./usr/local/etc/ssl/cert.pem
+
return 0
}
diff --git a/release/tools/ec2-builder.conf b/release/tools/ec2-builder.conf
index a55485fec0cd..3b0344f9eb9a 100644
--- a/release/tools/ec2-builder.conf
+++ b/release/tools/ec2-builder.conf
@@ -66,5 +66,8 @@ vm_extra_pre_umount() {
EOF
metalog_add_data ./boot/loader.conf
+ # Add files from packages which weren't recorded in metalog
+ metalog_add_data ./usr/local/etc/dhclient.conf
+
return 0
}
diff --git a/release/tools/ec2-small.conf b/release/tools/ec2-small.conf
index acaffbbc0c42..6564a59c2cf6 100644
--- a/release/tools/ec2-small.conf
+++ b/release/tools/ec2-small.conf
@@ -49,5 +49,8 @@ vm_extra_pre_umount() {
# Standard FreeBSD network configuration
ec2_base_networking
+ # Add files from packages which weren't recorded in metalog
+ metalog_add_data ./usr/local/etc/dhclient.conf
+
return 0
}
diff --git a/release/tools/oci-image-notoolchain.conf b/release/tools/oci-image-notoolchain.conf
index a769b53f9ff6..72a62657fa76 100644
--- a/release/tools/oci-image-notoolchain.conf
+++ b/release/tools/oci-image-notoolchain.conf
@@ -1,67 +1,25 @@
#! /bin/sh
-# Build OCI container image with almost all packages suitable for jails, excluding compiler
+# Build OCI container image with almost all packages suitable for jails,
+# excluding toolchain.
OCI_BASE_IMAGE=runtime
oci_image_build() {
set_cmd ${workdir} /bin/sh
install_packages ${abi} ${workdir} \
- FreeBSD-acct \
- FreeBSD-at \
- FreeBSD-audit \
- FreeBSD-autofs \
- FreeBSD-blocklist \
- FreeBSD-bsnmp \
- FreeBSD-caroot \
- FreeBSD-certctl \
- FreeBSD-clibs \
- FreeBSD-console-tools \
- FreeBSD-cron \
- FreeBSD-csh \
+ FreeBSD-bmake \
FreeBSD-dma \
- FreeBSD-ee \
- FreeBSD-fd \
- FreeBSD-fetch \
- FreeBSD-ftp \
FreeBSD-inetd \
FreeBSD-ipf \
FreeBSD-ipfw \
- FreeBSD-iscsi \
- FreeBSD-jail \
- FreeBSD-kerberos \
- FreeBSD-kerberos-lib \
- FreeBSD-libarchive \
- FreeBSD-libcompiler_rt-dev \
- FreeBSD-libexecinfo \
- FreeBSD-libucl \
- FreeBSD-locales \
- FreeBSD-lp \
- FreeBSD-mtree \
FreeBSD-natd \
FreeBSD-netmap \
- FreeBSD-newsyslog \
- FreeBSD-nfs \
- FreeBSD-nuageinit \
- FreeBSD-openssl \
- FreeBSD-periodic \
FreeBSD-pf \
- FreeBSD-pkg-bootstrap \
- FreeBSD-quotacheck \
- FreeBSD-rc \
- FreeBSD-rcmds \
- FreeBSD-rescue \
- FreeBSD-resolvconf \
- FreeBSD-runtime \
FreeBSD-ssh \
- FreeBSD-syslogd \
- FreeBSD-tcpd \
FreeBSD-telnet \
- FreeBSD-ufs \
- FreeBSD-unbound \
- FreeBSD-utilities \
- FreeBSD-vi \
- FreeBSD-yp \
+ FreeBSD-xz \
FreeBSD-zfs \
- FreeBSD-zoneinfo
+ FreeBSD-set-minimal-jail
}
+
diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr
index 131ebe37db6c..c3c917dcd642 100644
--- a/release/tools/vmimage.subr
+++ b/release/tools/vmimage.subr
@@ -74,10 +74,15 @@ vm_base_packages_list() {
# Output a list of package sets equivalent to what we get from
# "installworld installkernel distribution", aka. the full base
# system.
- for S in base lib32 kernels; do
+ for S in base kernels; do
echo FreeBSD-set-$S
echo FreeBSD-set-$S-dbg
done
+ case ${TARGET_ARCH} in
+ amd64 | aarch64 | powerpc64)
+ echo FreeBSD-set-lib32
+ echo FreeBSD-set-lib32-dbg
+ esac
echo FreeBSD-set-tests
}
@@ -208,6 +213,16 @@ vm_extra_install_packages() {
install -y -r ${PKG_REPO_NAME} $pkg
done
metalog_add_data ./var/db/pkg/local.sqlite
+
+ # Add some database files which are created by pkg triggers;
+ # at some point in the future the tools which create these
+ # files should probably learn how to record them in METALOG
+ # (which would simplify no-root installworld as well).
+ metalog_add_data ./etc/login.conf.db
+ metalog_add_data ./etc/passwd
+ metalog_add_data ./etc/pwd.db
+ metalog_add_data ./etc/spwd.db 600
+ metalog_add_data ./var/db/services.db
else
if [ -n "${WITHOUT_QEMU}" ]; then
return 0
@@ -275,6 +290,11 @@ buildfs() {
cat ${DESTDIR}/METALOG.pkg >> ${DESTDIR}/METALOG
fi
+ # Sort METALOG file; makefs produces directories with 000 permissions
+ # if their contents are seen before the directories themselves.
+ env -i LC_COLLATE=C sort -u ${DESTDIR}/METALOG > ${DESTDIR}/METALOG.sorted
+ mv ${DESTDIR}/METALOG.sorted ${DESTDIR}/METALOG
+
case "${VMFS}" in
ufs)
cd ${DESTDIR} && ${MAKEFS} ${MAKEFSARGS} -o label=rootfs -o version=2 -o softupdates=1 \
diff --git a/sbin/mount_nullfs/mount_nullfs.8 b/sbin/mount_nullfs/mount_nullfs.8
index 17b1f45f5e42..b3cf57fd9dea 100644
--- a/sbin/mount_nullfs/mount_nullfs.8
+++ b/sbin/mount_nullfs/mount_nullfs.8
@@ -90,7 +90,7 @@ See the
.Xr mount 8
man page for possible options and their meanings.
Additionally the following option is supported:
-.Bl -tag -width nocache
+.Bl -tag -width nounixbypass
.It Cm nocache
Disable metadata caching in the null layer.
Some lower-layer file systems may force this option.
@@ -98,6 +98,32 @@ Depending on the access pattern,
this may result in increased lock contention.
.It Cm cache
Force enable metadata caching.
+.It Cm nounixbypass
+Disable bypassing
+.Xr unix 4
+socket files used for
+.Xr bind 2
+and
+.Xr connect 2 ,
+to the lower (mounted-from) filesystem layer.
+.Pp
+The effect is that lower and upper (bypassed) unix sockets
+are separate.
+.It Cm unixbypass
+Enable the bypass of unix socket file to lower filesystem layer.
+This is default.
+.Pp
+The effect is that
+.Xr bind 2
+and
+.Xr connect 2
+operations on a unix socket done from either the upper (nullfs) or lower
+layer path are performed on same unix socket.
+For instance, if a server
+.Xr bind 2
+is done on a socket in the lower layer, then
+.Xr connect 2
+on the socket file accessed via the nullfs mount, connects to the server.
.El
.El
.Pp
diff --git a/secure/libexec/sshd-auth/Makefile b/secure/libexec/sshd-auth/Makefile
index a127b50b407a..0ee49585a023 100644
--- a/secure/libexec/sshd-auth/Makefile
+++ b/secure/libexec/sshd-auth/Makefile
@@ -31,11 +31,11 @@ CFLAGS+= -DUSE_BSM_AUDIT=1 -DHAVE_GETAUDIT_ADDR=1
LIBADD+= bsm
.endif
-.if ${MK_BLACKLIST_SUPPORT} != "no"
-CFLAGS+= -DUSE_BLACKLIST=1 -I${SRCTOP}/contrib/blocklist/include
-SRCS+= blacklist.c
-LIBADD+= blacklist
-LDFLAGS+=-L${LIBBLACKLISTDIR}
+.if ${MK_BLOCKLIST_SUPPORT} != "no"
+CFLAGS+= -DUSE_BLOCKLIST=1 -I${SRCTOP}/contrib/blocklist/include
+SRCS+= blocklist.c
+LIBADD+= blocklist
+LDFLAGS+=-L${LIBBLOCKLISTDIR}
.endif
.if ${MK_KERBEROS_SUPPORT} != "no"
diff --git a/secure/libexec/sshd-session/Makefile b/secure/libexec/sshd-session/Makefile
index 9e95c94000ff..a7849f2a35f8 100644
--- a/secure/libexec/sshd-session/Makefile
+++ b/secure/libexec/sshd-session/Makefile
@@ -29,11 +29,11 @@ CFLAGS+= -DUSE_BSM_AUDIT=1 -DHAVE_GETAUDIT_ADDR=1
LIBADD+= bsm
.endif
-.if ${MK_BLACKLIST_SUPPORT} != "no"
-CFLAGS+= -DUSE_BLACKLIST=1 -I${SRCTOP}/contrib/blocklist/include
-SRCS+= blacklist.c
-LIBADD+= blacklist
-LDFLAGS+=-L${LIBBLACKLISTDIR}
+.if ${MK_BLOCKLIST_SUPPORT} != "no"
+CFLAGS+= -DUSE_BLOCKLIST=1 -I${SRCTOP}/contrib/blocklist/include
+SRCS+= blocklist.c
+LIBADD+= blocklist
+LDFLAGS+=-L${LIBBLOCKLISTDIR}
.endif
.if ${MK_KERBEROS_SUPPORT} != "no"
diff --git a/secure/usr.sbin/sshd/Makefile.depend.options b/secure/usr.sbin/sshd/Makefile.depend.options
index 69af5a2e8d79..c8816eb881fb 100644
--- a/secure/usr.sbin/sshd/Makefile.depend.options
+++ b/secure/usr.sbin/sshd/Makefile.depend.options
@@ -1,5 +1,5 @@
# This file is not autogenerated - take care!
-DIRDEPS_OPTIONS= AUDIT BLACKLIST_SUPPORT GSSAPI KERBEROS_SUPPORT TCP_WRAPPERS
+DIRDEPS_OPTIONS= AUDIT BLOCKLIST_SUPPORT GSSAPI KERBEROS_SUPPORT TCP_WRAPPERS
.include <dirdeps-options.mk>
diff --git a/share/man/man4/umass.4 b/share/man/man4/umass.4
index db4e6f0890f2..8c6b03a3afea 100644
--- a/share/man/man4/umass.4
+++ b/share/man/man4/umass.4
@@ -25,44 +25,44 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd October 2, 2025
+.Dd October 9, 2025
.Dt UMASS 4
.Os
.Sh NAME
.Nm umass
.Nd USB Mass Storage Devices driver
.Sh SYNOPSIS
-To compile this driver into the kernel,
-place the following line in your
-kernel configuration file:
-.Bd -ragged -offset indent
+.Cd "device da"
.Cd "device scbus"
+.Cd "device pass"
.Cd "device usb"
.Cd "device umass"
-.Ed
.Pp
-Alternatively, to load the driver as a
-module at boot time, place the following line in
+In
.Xr loader.conf 5 :
-.Bd -literal -offset indent
-umass_load="YES"
-.Ed
+.Cd umass_load
.Sh DESCRIPTION
The
.Nm
driver provides support for Mass Storage devices that attach to the USB
-port.
+interface.
.Pp
-To use the
-.Nm
-driver,
+If the appropriate hardware is detected,
+the driver will be loaded automatically by
+.Xr devmatch 8 .
+To load the driver manually at boot time, use the
+.Cm umass_load
+command at the
+.Xr loader 8
+prompt, or add it to
+.Xr loader.conf 5 .
+.Pp
+To use the driver in a custom kernel,
.Xr usb 4
-and one of
-.Xr uhci 4
-or
-.Xr ohci 4
-or
-.Xr ehci 4
+and at least one of
+.Xr uhci 4 ,
+.Xr ohci 4 ,
+.Xr ehci 4 ,
or
.Xr xhci 4
must be configured in the kernel.
@@ -88,16 +88,8 @@ USB hard disk drives
USB floppy drives
.El
.Sh EXAMPLES
-.Bd -literal -offset indent
-device umass
-device scbus
-device da
-device pass
-.Ed
-.Pp
-Add the
-.Nm
-driver to the kernel.
+Rescan all slots on a multi-slot flash reader,
+where the slots map to separate LUNs on a single SCSI ID:
.Bd -literal -offset indent
camcontrol rescan 0:0:0
camcontrol rescan 0:0:1
@@ -105,8 +97,6 @@ camcontrol rescan 0:0:2
camcontrol rescan 0:0:3
.Ed
.Pp
-Rescan all slots on a multi-slot flash reader, where the slots map to separate
-LUNs on a single SCSI ID.
Typically only the first slot will be enabled at boot time.
This assumes that
the flash reader is the first SCSI bus in the system and has 4 slots.
diff --git a/share/man/man5/periodic.conf.5 b/share/man/man5/periodic.conf.5
index a2ed2b09d772..8910895d9b89 100644
--- a/share/man/man5/periodic.conf.5
+++ b/share/man/man5/periodic.conf.5
@@ -981,7 +981,7 @@ since yesterday's check.
Space-separated list of additional anchors whose denied packets log entries to
show.
The main ruleset (i.e., the empty-string anchor) and any
-.Xr blacklistd 8
+.Xr blocklistd 8
anchors, if present, are always shown.
.It Va security_status_pfdenied_period
.Pq Vt str
diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5
index 5c8ae5b83e5f..1bb609336532 100644
--- a/share/man/man5/src.conf.5
+++ b/share/man/man5/src.conf.5
@@ -1,5 +1,5 @@
.\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman.
-.Dd September 25, 2025
+.Dd October 1, 2025
.Dt SRC.CONF 5
.Os
.Sh NAME
@@ -226,10 +226,15 @@ options provide "full" Relocation Read-Only (RELRO) support.
With full RELRO the entire GOT is made read-only after performing relocation at
startup, avoiding GOT overwrite attacks.
.It Va WITHOUT_BLACKLIST
-Set this if you do not want to build
-.Xr blacklistd 8
-and
-.Xr blacklistctl 8 .
+This option has been renamed to
+.Va WITHOUT_BLOCKLIST .
+When set, it enforces these options:
+.Pp
+.Bl -item -compact
+.It
+.Va WITHOUT_BLOCKLIST
+.El
+.Pp
When set, these options are also in effect:
.Pp
.Bl -inset -compact
@@ -237,10 +242,36 @@ When set, these options are also in effect:
(unless
.Va WITH_BLACKLIST_SUPPORT
is set explicitly)
+.It Va WITHOUT_BLOCKLIST_SUPPORT
+(unless
+.Va WITH_BLOCKLIST_SUPPORT
+is set explicitly)
.El
.It Va WITHOUT_BLACKLIST_SUPPORT
+This option has been renamed to
+.Va WITHOUT_BLOCKLIST_SUPPORT .
+When set, it enforces these options:
+.Pp
+.Bl -item -compact
+.It
+.Va WITHOUT_BLOCKLIST_SUPPORT
+.El
+.It Va WITHOUT_BLOCKLIST
+Set this if you do not want to build
+.Xr blocklistd 8
+and
+.Xr blocklistctl 8 .
+When set, these options are also in effect:
+.Pp
+.Bl -inset -compact
+.It Va WITHOUT_BLOCKLIST_SUPPORT
+(unless
+.Va WITH_BLOCKLIST_SUPPORT
+is set explicitly)
+.El
+.It Va WITHOUT_BLOCKLIST_SUPPORT
Build some programs without
-.Xr libblacklist 3
+.Xr libblocklist 3
support, like
.Xr fingerd 8
and
diff --git a/share/mk/bsd.libnames.mk b/share/mk/bsd.libnames.mk
index 3ff4c4e90a1b..2f099e0579b2 100644
--- a/share/mk/bsd.libnames.mk
+++ b/share/mk/bsd.libnames.mk
@@ -27,6 +27,7 @@ LIBAVL?= ${LIBDESTDIR}${LIBDIR_BASE}/libavl.a
LIBBE?= ${LIBDESTDIR}${LIBDIR_BASE}/libbe.a
LIBBEGEMOT?= ${LIBDESTDIR}${LIBDIR_BASE}/libbegemot.a
LIBBLACKLIST?= ${LIBDESTDIR}${LIBDIR_BASE}/libblacklist.a
+LIBBLOCKLIST?= ${LIBDESTDIR}${LIBDIR_BASE}/libblocklist.a
LIBBLOCKSRUNTIME?= ${LIBDESTDIR}${LIBDIR_BASE}/libBlocksRuntime.a
LIBBLUETOOTH?= ${LIBDESTDIR}${LIBDIR_BASE}/libbluetooth.a
LIBBSDXML?= ${LIBDESTDIR}${LIBDIR_BASE}/libbsdxml.a
diff --git a/share/mk/local.dirdeps-options.mk b/share/mk/local.dirdeps-options.mk
index 4eef5311375e..5773c4979e56 100644
--- a/share/mk/local.dirdeps-options.mk
+++ b/share/mk/local.dirdeps-options.mk
@@ -2,6 +2,7 @@
# avoid duplication
DIRDEPS.AUDIT.yes= lib/libbsm
DIRDEPS.BLACKLIST_SUPPORT.yes+= lib/libblacklist
+DIRDEPS.BLOCKLIST_SUPPORT.yes+= lib/libblocklist
DIRDEPS.CASPER.yes+= lib/libcasper/libcasper
DIRDEPS.GSSAPI.yes+= lib/libgssapi
DIRDEPS.JAIL.yes+= lib/libjail
diff --git a/share/mk/src.libnames.mk b/share/mk/src.libnames.mk
index 3e108591251a..b2ed63759c19 100644
--- a/share/mk/src.libnames.mk
+++ b/share/mk/src.libnames.mk
@@ -264,8 +264,12 @@ _LIBRARIES+= \
.if ${MK_BLACKLIST} != "no"
_LIBRARIES+= \
- blacklist \
+ blacklist
+.endif
+.if ${MK_BLOCKLIST} != "no"
+_LIBRARIES+= \
+ blocklist
.endif
.if ${MK_OFED} != "no"
@@ -319,6 +323,9 @@ _DP_zstd= pthread
.if ${MK_BLACKLIST} != "no"
_DP_blacklist+= pthread
.endif
+.if ${MK_BLOCKLIST} != "no"
+_DP_blocklist+= pthread
+.endif
_DP_crypto= pthread
# See comment by _DP_archive above
.if ${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING)
@@ -865,6 +872,7 @@ LIBGTESTDIR= ${_LIB_OBJTOP}/lib/googletest/gtest
LIBGTEST_MAINDIR= ${_LIB_OBJTOP}/lib/googletest/gtest_main
LIBALIASDIR= ${_LIB_OBJTOP}/lib/libalias/libalias
LIBBLACKLISTDIR= ${_LIB_OBJTOP}/lib/libblacklist
+LIBBLOCKLISTDIR= ${_LIB_OBJTOP}/lib/libblocklist
LIBBLOCKSRUNTIMEDIR= ${_LIB_OBJTOP}/lib/libblocksruntime
LIBBSNMPDIR= ${_LIB_OBJTOP}/lib/libbsnmp/libbsnmp
LIBCASPERDIR= ${_LIB_OBJTOP}/lib/libcasper/libcasper
diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk
index 9bd4e6a1842f..446f78a2acf3 100644
--- a/share/mk/src.opts.mk
+++ b/share/mk/src.opts.mk
@@ -66,6 +66,7 @@ __DEFAULT_YES_OPTIONS = \
AUTOFS \
BHYVE \
BLACKLIST \
+ BLOCKLIST \
BLUETOOTH \
BOOT \
BOOTPARAMD \
@@ -242,6 +243,7 @@ __LIBC_MALLOC_DEFAULT= jemalloc
#
.for var in \
BLACKLIST \
+ BLOCKLIST \
BZIP2 \
INET \
INET6 \
@@ -391,6 +393,14 @@ MK_SOURCELESS_HOST:= no
MK_SOURCELESS_UCODE:= no
.endif
+.if ${MK_BLACKLIST} == "no"
+MK_BLOCKLIST:= no
+.endif
+
+.if ${MK_BLACKLIST_SUPPORT} == "no"
+MK_BLOCKLIST_SUPPORT:= no
+.endif
+
.if ${MK_CDDL} == "no"
MK_CTF:= no
MK_DTRACE:= no
diff --git a/stand/lua/cli.lua.8 b/stand/lua/cli.lua.8
index aee1d3d53579..e47ecd3d23db 100644
--- a/stand/lua/cli.lua.8
+++ b/stand/lua/cli.lua.8
@@ -52,10 +52,11 @@ For instance:
local cli = require("cli")
cli.foo = function(...)
- -- Expand args to command name and the rest of argv. These arguments
- -- are pushed directly to the stack by loader, then handed off to
- -- cli_execute. cli_execute then passes them on to the invoked
- -- function, where they appear as varargs that must be peeled apart into
+ -- Expand args to command name and the rest of argv.
+ -- These arguments are pushed directly to the stack by
+ -- loader, then handed off to cli_execute. cli_execute
+ -- then passes them on to the invoked function, where
+ -- they appear as varargs that must be peeled apart into
-- their respective components.
local _, argv = cli.arguments(...)
@@ -63,10 +64,11 @@ cli.foo = function(...)
for k, v in ipairs(argv) do
print("arg #" .. tostring(k) .. ": '" .. v .. "'")
end
- -- Perform a loader command directly. This will not get dispatched back
- -- to Lua, so it is acceptable to have a function of the exact same name
- -- in loader. Lua will have the first chance to handle any commands
- -- executed at the loader prompt.
+ -- Perform a loader command directly. This will not get
+ -- dispatched back to Lua, so it is acceptable to have a
+ -- function of the exact same name in loader. Lua will
+ -- have the first chance to handle any commands executed
+ -- at the loader prompt.
loader.perform("foo")
end
.Ed
diff --git a/sys/amd64/include/vmm.h b/sys/amd64/include/vmm.h
index e35119af8572..66d8991d36e8 100644
--- a/sys/amd64/include/vmm.h
+++ b/sys/amd64/include/vmm.h
@@ -170,55 +170,63 @@ struct vm_eventinfo {
int *iptr; /* reqidle cookie */
};
-typedef int (*vmm_init_func_t)(int ipinum);
-typedef int (*vmm_cleanup_func_t)(void);
-typedef void (*vmm_suspend_func_t)(void);
-typedef void (*vmm_resume_func_t)(void);
-typedef void * (*vmi_init_func_t)(struct vm *vm, struct pmap *pmap);
-typedef int (*vmi_run_func_t)(void *vcpui, register_t rip,
- struct pmap *pmap, struct vm_eventinfo *info);
-typedef void (*vmi_cleanup_func_t)(void *vmi);
-typedef void * (*vmi_vcpu_init_func_t)(void *vmi, struct vcpu *vcpu,
- int vcpu_id);
-typedef void (*vmi_vcpu_cleanup_func_t)(void *vcpui);
-typedef int (*vmi_get_register_t)(void *vcpui, int num, uint64_t *retval);
-typedef int (*vmi_set_register_t)(void *vcpui, int num, uint64_t val);
-typedef int (*vmi_get_desc_t)(void *vcpui, int num, struct seg_desc *desc);
-typedef int (*vmi_set_desc_t)(void *vcpui, int num, struct seg_desc *desc);
-typedef int (*vmi_get_cap_t)(void *vcpui, int num, int *retval);
-typedef int (*vmi_set_cap_t)(void *vcpui, int num, int val);
-typedef struct vmspace * (*vmi_vmspace_alloc)(vm_offset_t min, vm_offset_t max);
-typedef void (*vmi_vmspace_free)(struct vmspace *vmspace);
-typedef struct vlapic * (*vmi_vlapic_init)(void *vcpui);
-typedef void (*vmi_vlapic_cleanup)(struct vlapic *vlapic);
-typedef int (*vmi_snapshot_vcpu_t)(void *vcpui, struct vm_snapshot_meta *meta);
-typedef int (*vmi_restore_tsc_t)(void *vcpui, uint64_t now);
+#define DECLARE_VMMOPS_FUNC(ret_type, opname, args) \
+ typedef ret_type (*vmmops_##opname##_t) args; \
+ ret_type vmmops_##opname args
+
+DECLARE_VMMOPS_FUNC(int, modinit, (int ipinum));
+DECLARE_VMMOPS_FUNC(int, modcleanup, (void));
+DECLARE_VMMOPS_FUNC(void, modresume, (void));
+DECLARE_VMMOPS_FUNC(void, modsuspend, (void));
+DECLARE_VMMOPS_FUNC(void *, init, (struct vm *vm, struct pmap *pmap));
+DECLARE_VMMOPS_FUNC(int, run, (void *vcpui, register_t pc,
+ struct pmap *pmap, struct vm_eventinfo *info));
+DECLARE_VMMOPS_FUNC(void, cleanup, (void *vmi));
+DECLARE_VMMOPS_FUNC(void *, vcpu_init, (void *vmi, struct vcpu *vcpu,
+ int vcpu_id));
+DECLARE_VMMOPS_FUNC(void, vcpu_cleanup, (void *vcpui));
+DECLARE_VMMOPS_FUNC(int, getreg, (void *vcpui, int num, uint64_t *retval));
+DECLARE_VMMOPS_FUNC(int, setreg, (void *vcpui, int num, uint64_t val));
+DECLARE_VMMOPS_FUNC(int, getdesc, (void *vcpui, int num,
+ struct seg_desc *desc));
+DECLARE_VMMOPS_FUNC(int, setdesc, (void *vcpui, int num,
+ struct seg_desc *desc));
+DECLARE_VMMOPS_FUNC(int, getcap, (void *vcpui, int num, int *retval));
+DECLARE_VMMOPS_FUNC(int, setcap, (void *vcpui, int num, int val));
+DECLARE_VMMOPS_FUNC(struct vmspace *, vmspace_alloc,
+ (vm_offset_t min, vm_offset_t max));
+DECLARE_VMMOPS_FUNC(void, vmspace_free, (struct vmspace *vmspace));
+DECLARE_VMMOPS_FUNC(struct vlapic *, vlapic_init, (void *vcpui));
+DECLARE_VMMOPS_FUNC(void, vlapic_cleanup, (struct vlapic *vlapic));
+DECLARE_VMMOPS_FUNC(int, vcpu_snapshot, (void *vcpui,
+ struct vm_snapshot_meta *meta));
+DECLARE_VMMOPS_FUNC(int, restore_tsc, (void *vcpui, uint64_t now));
struct vmm_ops {
- vmm_init_func_t modinit; /* module wide initialization */
- vmm_cleanup_func_t modcleanup;
- vmm_resume_func_t modsuspend;
- vmm_resume_func_t modresume;
-
- vmi_init_func_t init; /* vm-specific initialization */
- vmi_run_func_t run;
- vmi_cleanup_func_t cleanup;
- vmi_vcpu_init_func_t vcpu_init;
- vmi_vcpu_cleanup_func_t vcpu_cleanup;
- vmi_get_register_t getreg;
- vmi_set_register_t setreg;
- vmi_get_desc_t getdesc;
- vmi_set_desc_t setdesc;
- vmi_get_cap_t getcap;
- vmi_set_cap_t setcap;
- vmi_vmspace_alloc vmspace_alloc;
- vmi_vmspace_free vmspace_free;
- vmi_vlapic_init vlapic_init;
- vmi_vlapic_cleanup vlapic_cleanup;
+ vmmops_modinit_t modinit; /* module wide initialization */
+ vmmops_modcleanup_t modcleanup;
+ vmmops_modresume_t modsuspend;
+ vmmops_modresume_t modresume;
+
+ vmmops_init_t init; /* vm-specific initialization */
+ vmmops_run_t run;
+ vmmops_cleanup_t cleanup;
+ vmmops_vcpu_init_t vcpu_init;
+ vmmops_vcpu_cleanup_t vcpu_cleanup;
+ vmmops_getreg_t getreg;
+ vmmops_setreg_t setreg;
+ vmmops_getdesc_t getdesc;
+ vmmops_setdesc_t setdesc;
+ vmmops_getcap_t getcap;
+ vmmops_setcap_t setcap;
+ vmmops_vmspace_alloc_t vmspace_alloc;
+ vmmops_vmspace_free_t vmspace_free;
+ vmmops_vlapic_init_t vlapic_init;
+ vmmops_vlapic_cleanup_t vlapic_cleanup;
/* checkpoint operations */
- vmi_snapshot_vcpu_t vcpu_snapshot;
- vmi_restore_tsc_t restore_tsc;
+ vmmops_vcpu_snapshot_t vcpu_snapshot;
+ vmmops_restore_tsc_t restore_tsc;
};
extern const struct vmm_ops vmm_ops_intel;
@@ -375,7 +383,6 @@ vcpu_should_yield(struct vcpu *vcpu)
void *vcpu_stats(struct vcpu *vcpu);
void vcpu_notify_event(struct vcpu *vcpu, bool lapic_intr);
-struct vmspace *vm_vmspace(struct vm *vm);
struct vm_mem *vm_mem(struct vm *vm);
struct vatpic *vm_atpic(struct vm *vm);
struct vatpit *vm_atpit(struct vm *vm);
diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c
index c42da02d0bf6..2ac076551165 100644
--- a/sys/amd64/vmm/vmm.c
+++ b/sys/amd64/vmm/vmm.c
@@ -163,7 +163,6 @@ struct vm {
void *rendezvous_arg; /* (x) [r] rendezvous func/arg */
vm_rendezvous_func_t rendezvous_func;
struct mtx rendezvous_mtx; /* (o) rendezvous lock */
- struct vmspace *vmspace; /* (o) guest's address space */
struct vm_mem mem; /* (i) [m+v] guest memory */
char name[VM_MAX_NAMELEN+1]; /* (o) virtual machine name */
struct vcpu **vcpu; /* (o) guest vcpus */
@@ -201,7 +200,7 @@ vmmops_panic(void)
}
#define DEFINE_VMMOPS_IFUNC(ret_type, opname, args) \
- DEFINE_IFUNC(static, ret_type, vmmops_##opname, args) \
+ DEFINE_IFUNC(, ret_type, vmmops_##opname, args) \
{ \
if (vmm_is_intel()) \
return (vmm_ops_intel.opname); \
@@ -499,7 +498,7 @@ MODULE_VERSION(vmm, 1);
static void
vm_init(struct vm *vm, bool create)
{
- vm->cookie = vmmops_init(vm, vmspace_pmap(vm->vmspace));
+ vm->cookie = vmmops_init(vm, vmspace_pmap(vm_vmspace(vm)));
vm->iommu = NULL;
vm->vioapic = vioapic_init(vm);
vm->vhpet = vhpet_init(vm);
@@ -584,7 +583,7 @@ int
vm_create(const char *name, struct vm **retvm)
{
struct vm *vm;
- struct vmspace *vmspace;
+ int error;
/*
* If vmm.ko could not be successfully initialized then don't attempt
@@ -597,14 +596,13 @@ vm_create(const char *name, struct vm **retvm)
VM_MAX_NAMELEN + 1)
return (EINVAL);
- vmspace = vmmops_vmspace_alloc(0, VM_MAXUSER_ADDRESS_LA48);
- if (vmspace == NULL)
- return (ENOMEM);
-
vm = malloc(sizeof(struct vm), M_VM, M_WAITOK | M_ZERO);
+ error = vm_mem_init(&vm->mem, 0, VM_MAXUSER_ADDRESS_LA48);
+ if (error != 0) {
+ free(vm, M_VM);
+ return (error);
+ }
strcpy(vm->name, name);
- vm->vmspace = vmspace;
- vm_mem_init(&vm->mem);
mtx_init(&vm->rendezvous_mtx, "vm rendezvous lock", 0, MTX_DEF);
sx_init(&vm->vcpus_init_lock, "vm vcpus");
vm->vcpu = malloc(sizeof(*vm->vcpu) * vm_maxcpu, M_VM, M_WAITOK |
@@ -685,9 +683,6 @@ vm_cleanup(struct vm *vm, bool destroy)
if (destroy) {
vm_mem_destroy(vm);
- vmmops_vmspace_free(vm->vmspace);
- vm->vmspace = NULL;
-
free(vm->vcpu, M_VM);
sx_destroy(&vm->vcpus_init_lock);
mtx_destroy(&vm->rendezvous_mtx);
@@ -731,7 +726,7 @@ vm_map_mmio(struct vm *vm, vm_paddr_t gpa, size_t len, vm_paddr_t hpa)
{
vm_object_t obj;
- if ((obj = vmm_mmio_alloc(vm->vmspace, gpa, len, hpa)) == NULL)
+ if ((obj = vmm_mmio_alloc(vm_vmspace(vm), gpa, len, hpa)) == NULL)
return (ENOMEM);
else
return (0);
@@ -741,19 +736,21 @@ int
vm_unmap_mmio(struct vm *vm, vm_paddr_t gpa, size_t len)
{
- vmm_mmio_free(vm->vmspace, gpa, len);
+ vmm_mmio_free(vm_vmspace(vm), gpa, len);
return (0);
}
static int
vm_iommu_map(struct vm *vm)
{
+ pmap_t pmap;
vm_paddr_t gpa, hpa;
struct vm_mem_map *mm;
int error, i;
sx_assert(&vm->mem.mem_segs_lock, SX_LOCKED);
+ pmap = vmspace_pmap(vm_vmspace(vm));
for (i = 0; i < VM_MAX_MEMMAPS; i++) {
if (!vm_memseg_sysmem(vm, i))
continue;
@@ -767,7 +764,7 @@ vm_iommu_map(struct vm *vm)
mm->flags |= VM_MEMMAP_F_IOMMU;
for (gpa = mm->gpa; gpa < mm->gpa + mm->len; gpa += PAGE_SIZE) {
- hpa = pmap_extract(vmspace_pmap(vm->vmspace), gpa);
+ hpa = pmap_extract(pmap, gpa);
/*
* All mappings in the vmm vmspace must be
@@ -816,7 +813,7 @@ vm_iommu_unmap(struct vm *vm)
for (gpa = mm->gpa; gpa < mm->gpa + mm->len; gpa += PAGE_SIZE) {
KASSERT(vm_page_wired(PHYS_TO_VM_PAGE(pmap_extract(
- vmspace_pmap(vm->vmspace), gpa))),
+ vmspace_pmap(vm_vmspace(vm)), gpa))),
("vm_iommu_unmap: vm %p gpa %jx not wired",
vm, (uintmax_t)gpa));
iommu_remove_mapping(vm->iommu, gpa, PAGE_SIZE);
@@ -1249,7 +1246,7 @@ vm_handle_paging(struct vcpu *vcpu, bool *retu)
("vm_handle_paging: invalid fault_type %d", ftype));
if (ftype == VM_PROT_READ || ftype == VM_PROT_WRITE) {
- rv = pmap_emulate_accessed_dirty(vmspace_pmap(vm->vmspace),
+ rv = pmap_emulate_accessed_dirty(vmspace_pmap(vm_vmspace(vm)),
vme->u.paging.gpa, ftype);
if (rv == 0) {
VMM_CTR2(vcpu, "%s bit emulation for gpa %#lx",
@@ -1259,7 +1256,7 @@ vm_handle_paging(struct vcpu *vcpu, bool *retu)
}
}
- map = &vm->vmspace->vm_map;
+ map = &vm_vmspace(vm)->vm_map;
rv = vm_fault(map, vme->u.paging.gpa, ftype, VM_FAULT_NORMAL, NULL);
VMM_CTR3(vcpu, "vm_handle_paging rv = %d, gpa = %#lx, "
@@ -1560,7 +1557,7 @@ vm_run(struct vcpu *vcpu)
if (CPU_ISSET(vcpuid, &vm->suspended_cpus))
return (EINVAL);
- pmap = vmspace_pmap(vm->vmspace);
+ pmap = vmspace_pmap(vm_vmspace(vm));
vme = &vcpu->exitinfo;
evinfo.rptr = &vm->rendezvous_req_cpus;
evinfo.sptr = &vm->suspend;
@@ -2302,12 +2299,6 @@ vcpu_notify_event(struct vcpu *vcpu, bool lapic_intr)
vcpu_unlock(vcpu);
}
-struct vmspace *
-vm_vmspace(struct vm *vm)
-{
- return (vm->vmspace);
-}
-
struct vm_mem *
vm_mem(struct vm *vm)
{
@@ -2519,7 +2510,7 @@ vm_get_rescnt(struct vcpu *vcpu, struct vmm_stat_type *stat)
if (vcpu->vcpuid == 0) {
vmm_stat_set(vcpu, VMM_MEM_RESIDENT, PAGE_SIZE *
- vmspace_resident_count(vcpu->vm->vmspace));
+ vmspace_resident_count(vm_vmspace(vcpu->vm)));
}
}
@@ -2529,7 +2520,7 @@ vm_get_wiredcnt(struct vcpu *vcpu, struct vmm_stat_type *stat)
if (vcpu->vcpuid == 0) {
vmm_stat_set(vcpu, VMM_MEM_WIRED, PAGE_SIZE *
- pmap_wired_count(vmspace_pmap(vcpu->vm->vmspace)));
+ pmap_wired_count(vmspace_pmap(vm_vmspace(vcpu->vm))));
}
}
diff --git a/sys/amd64/vmm/vmm_dev_machdep.c b/sys/amd64/vmm/vmm_dev_machdep.c
index d8d2b460404c..dfebc9dcadbf 100644
--- a/sys/amd64/vmm/vmm_dev_machdep.c
+++ b/sys/amd64/vmm/vmm_dev_machdep.c
@@ -48,6 +48,7 @@
#include <x86/apicreg.h>
#include <dev/vmm/vmm_dev.h>
+#include <dev/vmm/vmm_mem.h>
#include <dev/vmm/vmm_stat.h>
#include "vmm_lapic.h"
diff --git a/sys/arm64/include/vmm.h b/sys/arm64/include/vmm.h
index e839b5dd92c9..84b286a60b38 100644
--- a/sys/arm64/include/vmm.h
+++ b/sys/arm64/include/vmm.h
@@ -143,6 +143,37 @@ struct vm_eventinfo {
int *iptr; /* reqidle cookie */
};
+#define DECLARE_VMMOPS_FUNC(ret_type, opname, args) \
+ ret_type vmmops_##opname args
+
+DECLARE_VMMOPS_FUNC(int, modinit, (int ipinum));
+DECLARE_VMMOPS_FUNC(int, modcleanup, (void));
+DECLARE_VMMOPS_FUNC(void *, init, (struct vm *vm, struct pmap *pmap));
+DECLARE_VMMOPS_FUNC(int, gla2gpa, (void *vcpui, struct vm_guest_paging *paging,
+ uint64_t gla, int prot, uint64_t *gpa, int *is_fault));
+DECLARE_VMMOPS_FUNC(int, run, (void *vcpui, register_t pc, struct pmap *pmap,
+ struct vm_eventinfo *info));
+DECLARE_VMMOPS_FUNC(void, cleanup, (void *vmi));
+DECLARE_VMMOPS_FUNC(void *, vcpu_init, (void *vmi, struct vcpu *vcpu,
+ int vcpu_id));
+DECLARE_VMMOPS_FUNC(void, vcpu_cleanup, (void *vcpui));
+DECLARE_VMMOPS_FUNC(int, exception, (void *vcpui, uint64_t esr, uint64_t far));
+DECLARE_VMMOPS_FUNC(int, getreg, (void *vcpui, int num, uint64_t *retval));
+DECLARE_VMMOPS_FUNC(int, setreg, (void *vcpui, int num, uint64_t val));
+DECLARE_VMMOPS_FUNC(int, getcap, (void *vcpui, int num, int *retval));
+DECLARE_VMMOPS_FUNC(int, setcap, (void *vcpui, int num, int val));
+DECLARE_VMMOPS_FUNC(struct vmspace *, vmspace_alloc, (vm_offset_t min,
+ vm_offset_t max));
+DECLARE_VMMOPS_FUNC(void, vmspace_free, (struct vmspace *vmspace));
+#ifdef notyet
+#ifdef BHYVE_SNAPSHOT
+DECLARE_VMMOPS_FUNC(int, snapshot, (void *vmi, struct vm_snapshot_meta *meta));
+DECLARE_VMMOPS_FUNC(int, vcpu_snapshot, (void *vcpui,
+ struct vm_snapshot_meta *meta));
+DECLARE_VMMOPS_FUNC(int, restore_tsc, (void *vcpui, uint64_t now));
+#endif
+#endif
+
int vm_create(const char *name, struct vm **retvm);
struct vcpu *vm_alloc_vcpu(struct vm *vm, int vcpuid);
void vm_disable_vcpu_creation(struct vm *vm);
@@ -232,7 +263,6 @@ vcpu_should_yield(struct vcpu *vcpu)
void *vcpu_stats(struct vcpu *vcpu);
void vcpu_notify_event(struct vcpu *vcpu);
-struct vmspace *vm_vmspace(struct vm *vm);
struct vm_mem *vm_mem(struct vm *vm);
enum vm_reg_name vm_segment_name(int seg_encoding);
diff --git a/sys/arm64/vmm/arm64.h b/sys/arm64/vmm/arm64.h
index f9b74aef7188..f530dab05331 100644
--- a/sys/arm64/vmm/arm64.h
+++ b/sys/arm64/vmm/arm64.h
@@ -136,37 +136,6 @@ struct hyp {
struct hypctx *ctx[];
};
-#define DEFINE_VMMOPS_IFUNC(ret_type, opname, args) \
- ret_type vmmops_##opname args;
-
-DEFINE_VMMOPS_IFUNC(int, modinit, (int ipinum))
-DEFINE_VMMOPS_IFUNC(int, modcleanup, (void))
-DEFINE_VMMOPS_IFUNC(void *, init, (struct vm *vm, struct pmap *pmap))
-DEFINE_VMMOPS_IFUNC(int, gla2gpa, (void *vcpui, struct vm_guest_paging *paging,
- uint64_t gla, int prot, uint64_t *gpa, int *is_fault))
-DEFINE_VMMOPS_IFUNC(int, run, (void *vcpui, register_t pc, struct pmap *pmap,
- struct vm_eventinfo *info))
-DEFINE_VMMOPS_IFUNC(void, cleanup, (void *vmi))
-DEFINE_VMMOPS_IFUNC(void *, vcpu_init, (void *vmi, struct vcpu *vcpu,
- int vcpu_id))
-DEFINE_VMMOPS_IFUNC(void, vcpu_cleanup, (void *vcpui))
-DEFINE_VMMOPS_IFUNC(int, exception, (void *vcpui, uint64_t esr, uint64_t far))
-DEFINE_VMMOPS_IFUNC(int, getreg, (void *vcpui, int num, uint64_t *retval))
-DEFINE_VMMOPS_IFUNC(int, setreg, (void *vcpui, int num, uint64_t val))
-DEFINE_VMMOPS_IFUNC(int, getcap, (void *vcpui, int num, int *retval))
-DEFINE_VMMOPS_IFUNC(int, setcap, (void *vcpui, int num, int val))
-DEFINE_VMMOPS_IFUNC(struct vmspace *, vmspace_alloc, (vm_offset_t min,
- vm_offset_t max))
-DEFINE_VMMOPS_IFUNC(void, vmspace_free, (struct vmspace *vmspace))
-#ifdef notyet
-#ifdef BHYVE_SNAPSHOT
-DEFINE_VMMOPS_IFUNC(int, snapshot, (void *vmi, struct vm_snapshot_meta *meta))
-DEFINE_VMMOPS_IFUNC(int, vcpu_snapshot, (void *vcpui,
- struct vm_snapshot_meta *meta))
-DEFINE_VMMOPS_IFUNC(int, restore_tsc, (void *vcpui, uint64_t now))
-#endif
-#endif
-
uint64_t vmm_call_hyp(uint64_t, ...);
#if 0
diff --git a/sys/arm64/vmm/vmm.c b/sys/arm64/vmm/vmm.c
index a551a2807183..aeda689f3b1a 100644
--- a/sys/arm64/vmm/vmm.c
+++ b/sys/arm64/vmm/vmm.c
@@ -88,7 +88,6 @@ struct vcpu {
struct vfpstate *guestfpu; /* (a,i) guest fpu state */
};
-#define vcpu_lock_initialized(v) mtx_initialized(&((v)->mtx))
#define vcpu_lock_init(v) mtx_init(&((v)->mtx), "vcpu lock", 0, MTX_SPIN)
#define vcpu_lock_destroy(v) mtx_destroy(&((v)->mtx))
#define vcpu_lock(v) mtx_lock_spin(&((v)->mtx))
@@ -126,7 +125,6 @@ struct vm {
bool dying; /* (o) is dying */
volatile cpuset_t suspended_cpus; /* (i) suspended vcpus */
volatile cpuset_t halted_cpus; /* (x) cpus in a hard halt */
- struct vmspace *vmspace; /* (o) guest's address space */
struct vm_mem mem; /* (i) guest memory */
char name[VM_MAX_NAMELEN]; /* (o) virtual machine name */
struct vcpu **vcpu; /* (i) guest vcpus */
@@ -274,6 +272,7 @@ vcpu_cleanup(struct vcpu *vcpu, bool destroy)
vmm_stat_free(vcpu->stats);
fpu_save_area_free(vcpu->guestfpu);
vcpu_lock_destroy(vcpu);
+ free(vcpu, M_VMM);
}
}
@@ -407,7 +406,7 @@ vm_init(struct vm *vm, bool create)
{
int i;
- vm->cookie = vmmops_init(vm, vmspace_pmap(vm->vmspace));
+ vm->cookie = vmmops_init(vm, vmspace_pmap(vm_vmspace(vm)));
MPASS(vm->cookie != NULL);
CPU_ZERO(&vm->active_cpus);
@@ -485,7 +484,7 @@ int
vm_create(const char *name, struct vm **retvm)
{
struct vm *vm;
- struct vmspace *vmspace;
+ int error;
/*
* If vmm.ko could not be successfully initialized then don't attempt
@@ -497,14 +496,13 @@ vm_create(const char *name, struct vm **retvm)
if (name == NULL || strlen(name) >= VM_MAX_NAMELEN)
return (EINVAL);
- vmspace = vmmops_vmspace_alloc(0, 1ul << 39);
- if (vmspace == NULL)
- return (ENOMEM);
-
vm = malloc(sizeof(struct vm), M_VMM, M_WAITOK | M_ZERO);
+ error = vm_mem_init(&vm->mem, 0, 1ul << 39);
+ if (error != 0) {
+ free(vm, M_VMM);
+ return (error);
+ }
strcpy(vm->name, name);
- vm->vmspace = vmspace;
- vm_mem_init(&vm->mem);
sx_init(&vm->vcpus_init_lock, "vm vcpus");
vm->sockets = 1;
@@ -558,7 +556,7 @@ vm_cleanup(struct vm *vm, bool destroy)
if (destroy) {
vm_xlock_memsegs(vm);
- pmap = vmspace_pmap(vm->vmspace);
+ pmap = vmspace_pmap(vm_vmspace(vm));
sched_pin();
PCPU_SET(curvmpmap, NULL);
sched_unpin();
@@ -582,11 +580,6 @@ vm_cleanup(struct vm *vm, bool destroy)
if (destroy) {
vm_mem_destroy(vm);
- vmmops_vmspace_free(vm->vmspace);
- vm->vmspace = NULL;
-
- for (i = 0; i < vm->maxcpus; i++)
- free(vm->vcpu[i], M_VMM);
free(vm->vcpu, M_VMM);
sx_destroy(&vm->vcpus_init_lock);
}
@@ -1090,12 +1083,6 @@ vcpu_notify_event(struct vcpu *vcpu)
vcpu_unlock(vcpu);
}
-struct vmspace *
-vm_vmspace(struct vm *vm)
-{
- return (vm->vmspace);
-}
-
struct vm_mem *
vm_mem(struct vm *vm)
{
@@ -1416,7 +1403,7 @@ vm_handle_paging(struct vcpu *vcpu, bool *retu)
vme = &vcpu->exitinfo;
- pmap = vmspace_pmap(vcpu->vm->vmspace);
+ pmap = vmspace_pmap(vm_vmspace(vcpu->vm));
addr = vme->u.paging.gpa;
esr = vme->u.paging.esr;
@@ -1433,7 +1420,7 @@ vm_handle_paging(struct vcpu *vcpu, bool *retu)
panic("%s: Invalid exception (esr = %lx)", __func__, esr);
}
- map = &vm->vmspace->vm_map;
+ map = &vm_vmspace(vm)->vm_map;
rv = vm_fault(map, vme->u.paging.gpa, ftype, VM_FAULT_NORMAL, NULL);
if (rv != KERN_SUCCESS)
return (EFAULT);
@@ -1507,7 +1494,7 @@ vm_run(struct vcpu *vcpu)
if (CPU_ISSET(vcpuid, &vm->suspended_cpus))
return (EINVAL);
- pmap = vmspace_pmap(vm->vmspace);
+ pmap = vmspace_pmap(vm_vmspace(vm));
vme = &vcpu->exitinfo;
evinfo.rptr = NULL;
evinfo.sptr = &vm->suspend;
diff --git a/sys/conf/dtb.build.mk b/sys/conf/dtb.build.mk
index 327d69106244..7eb0db5e8b80 100644
--- a/sys/conf/dtb.build.mk
+++ b/sys/conf/dtb.build.mk
@@ -1,7 +1,3 @@
-
-.include <bsd.init.mk>
-# Grab all the options for a kernel build. For backwards compat, we need to
-# do this after bsd.own.mk.
.include "kern.opts.mk"
DTC?= dtc
diff --git a/sys/conf/kern.opts.mk b/sys/conf/kern.opts.mk
index 045e55d1b19a..cef4dd11ba58 100644
--- a/sys/conf/kern.opts.mk
+++ b/sys/conf/kern.opts.mk
@@ -4,6 +4,7 @@
# parts to omit (eg CDDL or SOURCELESS_HOST). Some of these will cause
# config.mk to define symbols in various opt_*.h files.
+
#
# Define MK_* variables (which are either "yes" or "no") for users
# to set via WITH_*/WITHOUT_* in /etc/src.conf and override in the
@@ -13,17 +14,12 @@
# that haven't been converted over.
#
-# Note: bsd.own.mk must be included before the rest of kern.opts.mk to make
-# building on 10.x and earlier work. This should be removed when that's no
-# longer supported since it confounds the defaults (since it uses the host's
-# notion of defaults rather than what's default in current when building
-# within sys/modules).
-.include <bsd.own.mk>
-
# These options are used by the kernel build process (kern.mk and kmod.mk)
# They have to be listed here so we can build modules outside of the
# src tree.
+.include <bsd.init.mk>
+
KLDXREF_CMD?= kldxref
__DEFAULT_YES_OPTIONS = \
diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/sysctl_os.c b/sys/contrib/openzfs/module/os/freebsd/zfs/sysctl_os.c
index 393bfaa65ff5..ace2360c032d 100644
--- a/sys/contrib/openzfs/module/os/freebsd/zfs/sysctl_os.c
+++ b/sys/contrib/openzfs/module/os/freebsd/zfs/sysctl_os.c
@@ -188,6 +188,11 @@ param_set_arc_max(SYSCTL_HANDLER_ARGS)
return (0);
}
+SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_max,
+ CTLTYPE_ULONG | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
+ NULL, 0, param_set_arc_max, "LU",
+ "Maximum ARC size in bytes (LEGACY)");
+
int
param_set_arc_min(SYSCTL_HANDLER_ARGS)
{
@@ -212,6 +217,11 @@ param_set_arc_min(SYSCTL_HANDLER_ARGS)
return (0);
}
+SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_min,
+ CTLTYPE_ULONG | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
+ NULL, 0, param_set_arc_min, "LU",
+ "Minimum ARC size in bytes (LEGACY)");
+
extern uint_t zfs_arc_free_target;
int
@@ -235,6 +245,16 @@ param_set_arc_free_target(SYSCTL_HANDLER_ARGS)
return (0);
}
+/*
+ * NOTE: This sysctl is CTLFLAG_RW not CTLFLAG_RWTUN due to its dependency on
+ * pagedaemon initialization.
+ */
+SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_free_target,
+ CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE,
+ NULL, 0, param_set_arc_free_target, "IU",
+ "Desired number of free pages below which ARC triggers reclaim"
+ " (LEGACY)");
+
int
param_set_arc_no_grow_shift(SYSCTL_HANDLER_ARGS)
{
@@ -253,6 +273,187 @@ param_set_arc_no_grow_shift(SYSCTL_HANDLER_ARGS)
return (0);
}
+SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_no_grow_shift,
+ CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
+ NULL, 0, param_set_arc_no_grow_shift, "I",
+ "log2(fraction of ARC which must be free to allow growing) (LEGACY)");
+
+extern uint64_t l2arc_write_max;
+
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_max,
+ CTLFLAG_RWTUN, &l2arc_write_max, 0,
+ "Max write bytes per interval (LEGACY)");
+
+extern uint64_t l2arc_write_boost;
+
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_boost,
+ CTLFLAG_RWTUN, &l2arc_write_boost, 0,
+ "Extra write bytes during device warmup (LEGACY)");
+
+extern uint64_t l2arc_headroom;
+
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_headroom,
+ CTLFLAG_RWTUN, &l2arc_headroom, 0,
+ "Number of max device writes to precache (LEGACY)");
+
+extern uint64_t l2arc_headroom_boost;
+
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_headroom_boost,
+ CTLFLAG_RWTUN, &l2arc_headroom_boost, 0,
+ "Compressed l2arc_headroom multiplier (LEGACY)");
+
+extern uint64_t l2arc_feed_secs;
+
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_secs,
+ CTLFLAG_RWTUN, &l2arc_feed_secs, 0,
+ "Seconds between L2ARC writing (LEGACY)");
+
+extern uint64_t l2arc_feed_min_ms;
+
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_min_ms,
+ CTLFLAG_RWTUN, &l2arc_feed_min_ms, 0,
+ "Min feed interval in milliseconds (LEGACY)");
+
+extern int l2arc_noprefetch;
+
+SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_noprefetch,
+ CTLFLAG_RWTUN, &l2arc_noprefetch, 0,
+ "Skip caching prefetched buffers (LEGACY)");
+
+extern int l2arc_feed_again;
+
+SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_feed_again,
+ CTLFLAG_RWTUN, &l2arc_feed_again, 0,
+ "Turbo L2ARC warmup (LEGACY)");
+
+extern int l2arc_norw;
+
+SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_norw,
+ CTLFLAG_RWTUN, &l2arc_norw, 0,
+ "No reads during writes (LEGACY)");
+
+static int
+param_get_arc_state_size(SYSCTL_HANDLER_ARGS)
+{
+ arc_state_t *state = (arc_state_t *)arg1;
+ int64_t val;
+
+ val = zfs_refcount_count(&state->arcs_size[ARC_BUFC_DATA]) +
+ zfs_refcount_count(&state->arcs_size[ARC_BUFC_METADATA]);
+ return (sysctl_handle_64(oidp, &val, 0, req));
+}
+
+extern arc_state_t ARC_anon;
+
+SYSCTL_PROC(_vfs_zfs, OID_AUTO, anon_size,
+ CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE,
+ &ARC_anon, 0, param_get_arc_state_size, "Q",
+ "size of anonymous state");
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_metadata_esize, CTLFLAG_RD,
+ &ARC_anon.arcs_esize[ARC_BUFC_METADATA].rc_count, 0,
+ "size of evictable metadata in anonymous state");
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_data_esize, CTLFLAG_RD,
+ &ARC_anon.arcs_esize[ARC_BUFC_DATA].rc_count, 0,
+ "size of evictable data in anonymous state");
+
+extern arc_state_t ARC_mru;
+
+SYSCTL_PROC(_vfs_zfs, OID_AUTO, mru_size,
+ CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE,
+ &ARC_mru, 0, param_get_arc_state_size, "Q",
+ "size of mru state");
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_metadata_esize, CTLFLAG_RD,
+ &ARC_mru.arcs_esize[ARC_BUFC_METADATA].rc_count, 0,
+ "size of evictable metadata in mru state");
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_data_esize, CTLFLAG_RD,
+ &ARC_mru.arcs_esize[ARC_BUFC_DATA].rc_count, 0,
+ "size of evictable data in mru state");
+
+extern arc_state_t ARC_mru_ghost;
+
+SYSCTL_PROC(_vfs_zfs, OID_AUTO, mru_ghost_size,
+ CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE,
+ &ARC_mru_ghost, 0, param_get_arc_state_size, "Q",
+ "size of mru ghost state");
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_metadata_esize, CTLFLAG_RD,
+ &ARC_mru_ghost.arcs_esize[ARC_BUFC_METADATA].rc_count, 0,
+ "size of evictable metadata in mru ghost state");
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_data_esize, CTLFLAG_RD,
+ &ARC_mru_ghost.arcs_esize[ARC_BUFC_DATA].rc_count, 0,
+ "size of evictable data in mru ghost state");
+
+extern arc_state_t ARC_mfu;
+
+SYSCTL_PROC(_vfs_zfs, OID_AUTO, mfu_size,
+ CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE,
+ &ARC_mfu, 0, param_get_arc_state_size, "Q",
+ "size of mfu state");
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_metadata_esize, CTLFLAG_RD,
+ &ARC_mfu.arcs_esize[ARC_BUFC_METADATA].rc_count, 0,
+ "size of evictable metadata in mfu state");
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_data_esize, CTLFLAG_RD,
+ &ARC_mfu.arcs_esize[ARC_BUFC_DATA].rc_count, 0,
+ "size of evictable data in mfu state");
+
+extern arc_state_t ARC_mfu_ghost;
+
+SYSCTL_PROC(_vfs_zfs, OID_AUTO, mfu_ghost_size,
+ CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE,
+ &ARC_mfu_ghost, 0, param_get_arc_state_size, "Q",
+ "size of mfu ghost state");
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_ghost_metadata_esize, CTLFLAG_RD,
+ &ARC_mfu_ghost.arcs_esize[ARC_BUFC_METADATA].rc_count, 0,
+ "size of evictable metadata in mfu ghost state");
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_ghost_data_esize, CTLFLAG_RD,
+ &ARC_mfu_ghost.arcs_esize[ARC_BUFC_DATA].rc_count, 0,
+ "size of evictable data in mfu ghost state");
+
+extern arc_state_t ARC_uncached;
+
+SYSCTL_PROC(_vfs_zfs, OID_AUTO, uncached_size,
+ CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE,
+ &ARC_uncached, 0, param_get_arc_state_size, "Q",
+ "size of uncached state");
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, uncached_metadata_esize, CTLFLAG_RD,
+ &ARC_uncached.arcs_esize[ARC_BUFC_METADATA].rc_count, 0,
+ "size of evictable metadata in uncached state");
+SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, uncached_data_esize, CTLFLAG_RD,
+ &ARC_uncached.arcs_esize[ARC_BUFC_DATA].rc_count, 0,
+ "size of evictable data in uncached state");
+
+extern arc_state_t ARC_l2c_only;
+
+SYSCTL_PROC(_vfs_zfs, OID_AUTO, l2c_only_size,
+ CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE,
+ &ARC_l2c_only, 0, param_get_arc_state_size, "Q",
+ "size of l2c_only state");
+
+/* dbuf.c */
+
+/* dmu.c */
+
+/* dmu_zfetch.c */
+
+SYSCTL_NODE(_vfs_zfs, OID_AUTO, zfetch, CTLFLAG_RW, 0, "ZFS ZFETCH (LEGACY)");
+
+extern uint32_t zfetch_max_distance;
+
+SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, max_distance,
+ CTLFLAG_RWTUN, &zfetch_max_distance, 0,
+ "Max bytes to prefetch per stream (LEGACY)");
+
+extern uint32_t zfetch_max_idistance;
+
+SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, max_idistance,
+ CTLFLAG_RWTUN, &zfetch_max_idistance, 0,
+ "Max bytes to prefetch indirects for per stream (LEGACY)");
+
+/* dsl_pool.c */
+
+/* dnode.c */
+
+/* dsl_scan.c */
+
/* metaslab.c */
int
@@ -313,6 +514,19 @@ SYSCTL_UINT(_vfs_zfs, OID_AUTO, condense_pct,
"Condense on-disk spacemap when it is more than this many percents"
" of in-memory counterpart");
+extern uint_t zfs_remove_max_segment;
+
+SYSCTL_UINT(_vfs_zfs, OID_AUTO, remove_max_segment,
+ CTLFLAG_RWTUN, &zfs_remove_max_segment, 0,
+ "Largest contiguous segment ZFS will attempt to allocate when removing"
+ " a device");
+
+extern int zfs_removal_suspend_progress;
+
+SYSCTL_INT(_vfs_zfs, OID_AUTO, removal_suspend_progress,
+ CTLFLAG_RWTUN, &zfs_removal_suspend_progress, 0,
+ "Ensures certain actions can happen while in the middle of a removal");
+
/*
* Minimum size which forces the dynamic allocator to change
* it's allocation strategy. Once the space map cannot satisfy
@@ -535,6 +749,12 @@ param_set_min_auto_ashift(SYSCTL_HANDLER_ARGS)
return (0);
}
+SYSCTL_PROC(_vfs_zfs, OID_AUTO, min_auto_ashift,
+ CTLTYPE_UINT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
+ &zfs_vdev_min_auto_ashift, sizeof (zfs_vdev_min_auto_ashift),
+ param_set_min_auto_ashift, "IU",
+ "Min ashift used when creating new top-level vdev. (LEGACY)");
+
int
param_set_max_auto_ashift(SYSCTL_HANDLER_ARGS)
{
@@ -554,6 +774,13 @@ param_set_max_auto_ashift(SYSCTL_HANDLER_ARGS)
return (0);
}
+SYSCTL_PROC(_vfs_zfs, OID_AUTO, max_auto_ashift,
+ CTLTYPE_UINT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
+ &zfs_vdev_max_auto_ashift, sizeof (zfs_vdev_max_auto_ashift),
+ param_set_max_auto_ashift, "IU",
+ "Max ashift used when optimizing for logical -> physical sector size on"
+ " new top-level vdevs. (LEGACY)");
+
/*
* Since the DTL space map of a vdev is not expected to have a lot of
* entries, we default its block size to 4K.
@@ -575,6 +802,23 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, standard_sm_blksz,
CTLFLAG_RDTUN, &zfs_vdev_standard_sm_blksz, 0,
"Block size for standard space map. Power of 2 greater than 4096.");
+extern int vdev_validate_skip;
+
+SYSCTL_INT(_vfs_zfs, OID_AUTO, validate_skip,
+ CTLFLAG_RDTUN, &vdev_validate_skip, 0,
+ "Enable to bypass vdev_validate().");
+
+/* vdev_mirror.c */
+
+/* vdev_queue.c */
+
+extern uint_t zfs_vdev_max_active;
+
+SYSCTL_UINT(_vfs_zfs, OID_AUTO, top_maxinflight,
+ CTLFLAG_RWTUN, &zfs_vdev_max_active, 0,
+ "The maximum number of I/Os of all types active for each device."
+ " (LEGACY)");
+
/* zio.c */
SYSCTL_INT(_vfs_zfs_zio, OID_AUTO, exclude_metadata,
diff --git a/sys/contrib/openzfs/module/zfs/arc.c b/sys/contrib/openzfs/module/zfs/arc.c
index 591e2dade59e..b677f90280d7 100644
--- a/sys/contrib/openzfs/module/zfs/arc.c
+++ b/sys/contrib/openzfs/module/zfs/arc.c
@@ -486,13 +486,13 @@ static taskq_t *arc_flush_taskq;
static uint_t zfs_arc_evict_threads = 0;
/* The 7 states: */
-static arc_state_t ARC_anon;
-/* */ arc_state_t ARC_mru;
-static arc_state_t ARC_mru_ghost;
-/* */ arc_state_t ARC_mfu;
-static arc_state_t ARC_mfu_ghost;
-static arc_state_t ARC_l2c_only;
-static arc_state_t ARC_uncached;
+arc_state_t ARC_anon;
+arc_state_t ARC_mru;
+arc_state_t ARC_mru_ghost;
+arc_state_t ARC_mfu;
+arc_state_t ARC_mfu_ghost;
+arc_state_t ARC_l2c_only;
+arc_state_t ARC_uncached;
arc_stats_t arc_stats = {
{ "hits", KSTAT_DATA_UINT64 },
@@ -832,15 +832,15 @@ typedef struct arc_async_flush {
#define L2ARC_FEED_TYPES 4
/* L2ARC Performance Tunables */
-static uint64_t l2arc_write_max = L2ARC_WRITE_SIZE; /* def max write size */
-static uint64_t l2arc_write_boost = L2ARC_WRITE_SIZE; /* extra warmup write */
-static uint64_t l2arc_headroom = L2ARC_HEADROOM; /* # of dev writes */
-static uint64_t l2arc_headroom_boost = L2ARC_HEADROOM_BOOST;
-static uint64_t l2arc_feed_secs = L2ARC_FEED_SECS; /* interval seconds */
-static uint64_t l2arc_feed_min_ms = L2ARC_FEED_MIN_MS; /* min interval msecs */
-static int l2arc_noprefetch = B_TRUE; /* don't cache prefetch bufs */
-static int l2arc_feed_again = B_TRUE; /* turbo warmup */
-static int l2arc_norw = B_FALSE; /* no reads during writes */
+uint64_t l2arc_write_max = L2ARC_WRITE_SIZE; /* def max write size */
+uint64_t l2arc_write_boost = L2ARC_WRITE_SIZE; /* extra warmup write */
+uint64_t l2arc_headroom = L2ARC_HEADROOM; /* # of dev writes */
+uint64_t l2arc_headroom_boost = L2ARC_HEADROOM_BOOST;
+uint64_t l2arc_feed_secs = L2ARC_FEED_SECS; /* interval seconds */
+uint64_t l2arc_feed_min_ms = L2ARC_FEED_MIN_MS; /* min interval msecs */
+int l2arc_noprefetch = B_TRUE; /* don't cache prefetch bufs */
+int l2arc_feed_again = B_TRUE; /* turbo warmup */
+int l2arc_norw = B_FALSE; /* no reads during writes */
static uint_t l2arc_meta_percent = 33; /* limit on headers size */
/*
diff --git a/sys/contrib/openzfs/module/zfs/dmu_zfetch.c b/sys/contrib/openzfs/module/zfs/dmu_zfetch.c
index 3d3a9c713568..51165d0bf723 100644
--- a/sys/contrib/openzfs/module/zfs/dmu_zfetch.c
+++ b/sys/contrib/openzfs/module/zfs/dmu_zfetch.c
@@ -57,19 +57,19 @@ static unsigned int zfetch_max_sec_reap = 2;
/* min bytes to prefetch per stream (default 2MB) */
static unsigned int zfetch_min_distance = 2 * 1024 * 1024;
/* max bytes to prefetch per stream (default 8MB) */
-static unsigned int zfetch_max_distance = 8 * 1024 * 1024;
+unsigned int zfetch_max_distance = 8 * 1024 * 1024;
#else
/* min bytes to prefetch per stream (default 4MB) */
static unsigned int zfetch_min_distance = 4 * 1024 * 1024;
/* max bytes to prefetch per stream (default 64MB) */
-static unsigned int zfetch_max_distance = 64 * 1024 * 1024;
+unsigned int zfetch_max_distance = 64 * 1024 * 1024;
#endif
/* max bytes to prefetch indirects for per stream (default 128MB) */
-static unsigned int zfetch_max_idistance = 128 * 1024 * 1024;
+unsigned int zfetch_max_idistance = 128 * 1024 * 1024;
/* max request reorder distance within a stream (default 16MB) */
-static unsigned int zfetch_max_reorder = 16 * 1024 * 1024;
+unsigned int zfetch_max_reorder = 16 * 1024 * 1024;
/* Max log2 fraction of holes in a stream */
-static unsigned int zfetch_hole_shift = 2;
+unsigned int zfetch_hole_shift = 2;
typedef struct zfetch_stats {
kstat_named_t zfetchstat_hits;
diff --git a/sys/contrib/openzfs/module/zfs/vdev.c b/sys/contrib/openzfs/module/zfs/vdev.c
index 654e034de9e1..c8d7280387a2 100644
--- a/sys/contrib/openzfs/module/zfs/vdev.c
+++ b/sys/contrib/openzfs/module/zfs/vdev.c
@@ -100,7 +100,7 @@ static uint_t zfs_vdev_default_ms_shift = 29;
/* upper limit for metaslab size (16G) */
static uint_t zfs_vdev_max_ms_shift = 34;
-static int vdev_validate_skip = B_FALSE;
+int vdev_validate_skip = B_FALSE;
/*
* Since the DTL space map of a vdev is not expected to have a lot of
diff --git a/sys/contrib/openzfs/module/zfs/vdev_queue.c b/sys/contrib/openzfs/module/zfs/vdev_queue.c
index e69e5598939e..c12713b107bf 100644
--- a/sys/contrib/openzfs/module/zfs/vdev_queue.c
+++ b/sys/contrib/openzfs/module/zfs/vdev_queue.c
@@ -122,7 +122,7 @@
* The maximum number of i/os active to each device. Ideally, this will be >=
* the sum of each queue's max_active.
*/
-static uint_t zfs_vdev_max_active = 1000;
+uint_t zfs_vdev_max_active = 1000;
/*
* Per-queue limits on the number of i/os active to each device. If the
diff --git a/sys/contrib/openzfs/module/zfs/vdev_removal.c b/sys/contrib/openzfs/module/zfs/vdev_removal.c
index 2ce0121324ad..2f7a739da241 100644
--- a/sys/contrib/openzfs/module/zfs/vdev_removal.c
+++ b/sys/contrib/openzfs/module/zfs/vdev_removal.c
@@ -105,7 +105,7 @@ static const uint_t zfs_remove_max_copy_bytes = 64 * 1024 * 1024;
*
* See also the accessor function spa_remove_max_segment().
*/
-static uint_t zfs_remove_max_segment = SPA_MAXBLOCKSIZE;
+uint_t zfs_remove_max_segment = SPA_MAXBLOCKSIZE;
/*
* Ignore hard IO errors during device removal. When set if a device
@@ -137,7 +137,7 @@ uint_t vdev_removal_max_span = 32 * 1024;
* This is used by the test suite so that it can ensure that certain
* actions happen while in the middle of a removal.
*/
-static int zfs_removal_suspend_progress = 0;
+int zfs_removal_suspend_progress = 0;
#define VDEV_REMOVAL_ZAP_OBJS "lzap"
diff --git a/sys/contrib/openzfs/tests/zfs-tests/include/tunables.cfg b/sys/contrib/openzfs/tests/zfs-tests/include/tunables.cfg
index 54b50c9dba77..127ea188f17f 100644
--- a/sys/contrib/openzfs/tests/zfs-tests/include/tunables.cfg
+++ b/sys/contrib/openzfs/tests/zfs-tests/include/tunables.cfg
@@ -76,8 +76,8 @@ READ_SIT_OUT_SECS vdev.read_sit_out_secs vdev_read_sit_out_secs
SIT_OUT_CHECK_INTERVAL vdev.raidz_outlier_check_interval_ms vdev_raidz_outlier_check_interval_ms
SIT_OUT_INSENSITIVITY vdev.raidz_outlier_insensitivity vdev_raidz_outlier_insensitivity
REBUILD_SCRUB_ENABLED rebuild_scrub_enabled zfs_rebuild_scrub_enabled
-REMOVAL_SUSPEND_PROGRESS vdev.removal_suspend_progress zfs_removal_suspend_progress
-REMOVE_MAX_SEGMENT vdev.remove_max_segment zfs_remove_max_segment
+REMOVAL_SUSPEND_PROGRESS removal_suspend_progress zfs_removal_suspend_progress
+REMOVE_MAX_SEGMENT remove_max_segment zfs_remove_max_segment
RESILVER_MIN_TIME_MS resilver_min_time_ms zfs_resilver_min_time_ms
RESILVER_DEFER_PERCENT resilver_defer_percent zfs_resilver_defer_percent
SCAN_LEGACY scan_legacy zfs_scan_legacy
diff --git a/sys/dev/ice/ice_common.c b/sys/dev/ice/ice_common.c
index ad4ea4c8e7a1..b895f661bc46 100644
--- a/sys/dev/ice/ice_common.c
+++ b/sys/dev/ice/ice_common.c
@@ -213,6 +213,15 @@ int ice_set_mac_type(struct ice_hw *hw)
case ICE_DEV_ID_E830_L_QSFP:
case ICE_DEV_ID_E830C_SFP:
case ICE_DEV_ID_E830_L_SFP:
+ case ICE_DEV_ID_E835CC_BACKPLANE:
+ case ICE_DEV_ID_E835CC_QSFP56:
+ case ICE_DEV_ID_E835CC_SFP:
+ case ICE_DEV_ID_E835C_BACKPLANE:
+ case ICE_DEV_ID_E835C_QSFP:
+ case ICE_DEV_ID_E835C_SFP:
+ case ICE_DEV_ID_E835_L_BACKPLANE:
+ case ICE_DEV_ID_E835_L_QSFP:
+ case ICE_DEV_ID_E835_L_SFP:
hw->mac_type = ICE_MAC_E830;
break;
default:
diff --git a/sys/dev/ice/ice_devids.h b/sys/dev/ice/ice_devids.h
index 3f91e9dfbcaf..74712c61ae8e 100644
--- a/sys/dev/ice/ice_devids.h
+++ b/sys/dev/ice/ice_devids.h
@@ -62,6 +62,24 @@
#define ICE_DEV_ID_E830C_SFP 0x12DA
/* Intel(R) Ethernet Controller E830-L for SFP */
#define ICE_DEV_ID_E830_L_SFP 0x12DE
+/* Intel(R) Ethernet Controller E835-CC for backplane */
+#define ICE_DEV_ID_E835CC_BACKPLANE 0x1248
+/* Intel(R) Ethernet Controller E835-CC for QSFP */
+#define ICE_DEV_ID_E835CC_QSFP56 0x1249
+/* Intel(R) Ethernet Controller E835-CC for SFP */
+#define ICE_DEV_ID_E835CC_SFP 0x124A
+/* Intel(R) Ethernet Controller E835-C for backplane */
+#define ICE_DEV_ID_E835C_BACKPLANE 0x1261
+/* Intel(R) Ethernet Controller E835-C for QSFP */
+#define ICE_DEV_ID_E835C_QSFP 0x1262
+/* Intel(R) Ethernet Controller E835-C for SFP */
+#define ICE_DEV_ID_E835C_SFP 0x1263
+/* Intel(R) Ethernet Controller E835-L for backplane */
+#define ICE_DEV_ID_E835_L_BACKPLANE 0x1265
+/* Intel(R) Ethernet Controller E835-L for QSFP */
+#define ICE_DEV_ID_E835_L_QSFP 0x1266
+/* Intel(R) Ethernet Controller E835-L for SFP */
+#define ICE_DEV_ID_E835_L_SFP 0x1267
/* Intel(R) Ethernet Controller E810-C for backplane */
#define ICE_DEV_ID_E810C_BACKPLANE 0x1591
/* Intel(R) Ethernet Controller E810-C for QSFP */
diff --git a/sys/dev/ice/ice_drv_info.h b/sys/dev/ice/ice_drv_info.h
index 2a51a7394424..46965f4124bc 100644
--- a/sys/dev/ice/ice_drv_info.h
+++ b/sys/dev/ice/ice_drv_info.h
@@ -218,6 +218,45 @@ static const pci_vendor_info_t ice_vendor_info_array[] = {
"Intel(R) Ethernet Network Adapter E830-XXV-2"),
PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E830_L_SFP,
"Intel(R) Ethernet Connection E830-L for SFP"),
+ PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_BACKPLANE,
+ "Intel(R) Ethernet Connection E835-CC for backplane"),
+ PVIDV_OEM(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_QSFP56,
+ ICE_INTEL_VENDOR_ID, 0x0001, 0,
+ "Intel(R) Ethernet Network Adapter E835-C-Q2"),
+ PVIDV_OEM(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_QSFP56,
+ ICE_INTEL_VENDOR_ID, 0x0002, 0,
+ "Intel(R) Ethernet Network Adapter E835-C-Q2 for OCP 3.0"),
+ PVIDV_OEM(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_QSFP56,
+ ICE_INTEL_VENDOR_ID, 0x0003, 0,
+ "Intel(R) Ethernet Network Adapter E835-CC-Q1"),
+ PVIDV_OEM(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_QSFP56,
+ ICE_INTEL_VENDOR_ID, 0x0004, 0,
+ "Intel(R) Ethernet Network Adapter E835-CC-Q1 for OCP 3.0"),
+ PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_QSFP56,
+ "Intel(R) Ethernet Connection E835-CC for QSFP56"),
+ PVIDV_OEM(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_SFP,
+ ICE_INTEL_VENDOR_ID, 0x0001, 0,
+ "Intel(R) Ethernet Network Adapter E835-XXV-2 for OCP 3.0"),
+ PVIDV_OEM(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_SFP,
+ ICE_INTEL_VENDOR_ID, 0x0003, 0,
+ "Intel(R) Ethernet Network Adapter E835-XXV-2"),
+ PVIDV_OEM(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_SFP,
+ ICE_INTEL_VENDOR_ID, 0x0004, 0,
+ "Intel(R) Ethernet Network Adapter E835-XXV-4 for OCP 3.0"),
+ PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835CC_SFP,
+ "Intel(R) Ethernet Connection E835-CC for SFP"),
+ PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835C_BACKPLANE,
+ "Intel(R) Ethernet Connection E835-C for backplane"),
+ PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835C_QSFP,
+ "Intel(R) Ethernet Connection E835-C for QSFP"),
+ PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835C_SFP,
+ "Intel(R) Ethernet Connection E835-C for SFP"),
+ PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835_L_BACKPLANE,
+ "Intel(R) Ethernet Connection E835-L for backplane"),
+ PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835_L_QSFP,
+ "Intel(R) Ethernet Connection E835-L for QSFP"),
+ PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E835_L_SFP,
+ "Intel(R) Ethernet Connection E835-L for SFP"),
PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E825C_BACKPLANE,
"Intel(R) Ethernet Connection E825-C for backplane"),
PVIDV(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E825C_QSFP,
diff --git a/sys/dev/ixgbe/if_ix.c b/sys/dev/ixgbe/if_ix.c
index 6d08bd49bc04..1d36fd11f368 100644
--- a/sys/dev/ixgbe/if_ix.c
+++ b/sys/dev/ixgbe/if_ix.c
@@ -192,6 +192,8 @@ static int ixgbe_if_i2c_req(if_ctx_t, struct ifi2creq *);
static bool ixgbe_if_needs_restart(if_ctx_t, enum iflib_restart_event);
int ixgbe_intr(void *);
+static int ixgbe_if_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data);
+
/************************************************************************
* Function prototypes
************************************************************************/
@@ -239,6 +241,13 @@ static void ixgbe_setup_vlan_hw_support(if_ctx_t);
static void ixgbe_config_gpie(struct ixgbe_softc *);
static void ixgbe_config_delay_values(struct ixgbe_softc *);
+static void ixgbe_add_debug_sysctls(struct ixgbe_softc *sc);
+static void ixgbe_add_debug_dump_sysctls(struct ixgbe_softc *sc);
+static int ixgbe_debug_dump_ioctl(struct ixgbe_softc *sc, struct ifdrv *ifd);
+static u8 ixgbe_debug_dump_print_cluster(struct ixgbe_softc *sc,
+ struct sbuf *sbuf, u8 cluster_id);
+static int ixgbe_nvm_access_ioctl(struct ixgbe_softc *sc, struct ifdrv *ifd);
+
/* Sysctl handlers */
static int ixgbe_sysctl_flowcntl(SYSCTL_HANDLER_ARGS);
static int ixgbe_sysctl_advertise(SYSCTL_HANDLER_ARGS);
@@ -260,6 +269,9 @@ static int ixgbe_sysctl_wol_enable(SYSCTL_HANDLER_ARGS);
static int ixgbe_sysctl_wufc(SYSCTL_HANDLER_ARGS);
static int ixgbe_sysctl_tso_tcp_flags_mask(SYSCTL_HANDLER_ARGS);
+static int ixgbe_sysctl_debug_dump_set_clusters(SYSCTL_HANDLER_ARGS);
+static int ixgbe_sysctl_dump_debug_dump(SYSCTL_HANDLER_ARGS);
+
/* Deferred interrupt tasklets */
static void ixgbe_handle_msf(void *);
static void ixgbe_handle_mod(void *);
@@ -330,6 +342,7 @@ static device_method_t ixgbe_if_methods[] = {
DEVMETHOD(ifdi_get_counter, ixgbe_if_get_counter),
DEVMETHOD(ifdi_i2c_req, ixgbe_if_i2c_req),
DEVMETHOD(ifdi_needs_restart, ixgbe_if_needs_restart),
+ DEVMETHOD(ifdi_priv_ioctl, ixgbe_if_priv_ioctl),
#ifdef PCI_IOV
DEVMETHOD(ifdi_iov_init, ixgbe_if_iov_init),
DEVMETHOD(ifdi_iov_uninit, ixgbe_if_iov_uninit),
@@ -1015,6 +1028,8 @@ ixgbe_if_attach_pre(if_ctx_t ctx)
if (hw->mac.type == ixgbe_mac_E610)
ixgbe_init_aci(hw);
+ sc->do_debug_dump = false;
+
if (hw->mac.ops.fw_recovery_mode &&
hw->mac.ops.fw_recovery_mode(hw)) {
device_printf(dev,
@@ -1395,6 +1410,248 @@ ixgbe_if_needs_restart(if_ctx_t ctx __unused, enum iflib_restart_event event)
}
/************************************************************************
+ * ixgbe_if_priv_ioctl - Ioctl handler for driver
+ *
+ * Handler for custom driver specific ioctls
+ *
+ * return 0 on success, positive on failure
+ ************************************************************************/
+static int
+ixgbe_if_priv_ioctl(if_ctx_t ctx, u_long command, caddr_t data)
+{
+ struct ixgbe_softc *sc = iflib_get_softc(ctx);
+ struct ifdrv *ifd;
+ device_t dev = sc->dev;
+
+ /* Make sure the command type is valid */
+ switch (command) {
+ case SIOCSDRVSPEC:
+ case SIOCGDRVSPEC:
+ /* Accepted commands */
+ break;
+ case SIOCGPRIVATE_0:
+ /*
+ * Although we do not support this ioctl command, it's expected
+ * that iflib will forward it to the IFDI_PRIV_IOCTL handler.
+ * Do not print a message in this case.
+ */
+ return (ENOTSUP);
+ default:
+ /*
+ * If we get a different command for this function, it's
+ * definitely unexpected, so log a message indicating what
+ * command we got for debugging purposes.
+ */
+ device_printf(dev,
+ "%s: unexpected ioctl command %08lx\n",
+ __func__, command);
+ return (EINVAL);
+ }
+
+ ifd = (struct ifdrv *)data;
+
+ switch (ifd->ifd_cmd) {
+ case IXGBE_NVM_ACCESS:
+ IOCTL_DEBUGOUT("ioctl: NVM ACCESS");
+ return (ixgbe_nvm_access_ioctl(sc, ifd));
+ case IXGBE_DEBUG_DUMP:
+ IOCTL_DEBUGOUT("ioctl: DEBUG DUMP");
+ return (ixgbe_debug_dump_ioctl(sc, ifd));
+ default:
+ IOCTL_DEBUGOUT1(
+ "ioctl: UNKNOWN SIOC(S|G)DRVSPEC (0x%X) command\n",
+ (int)ifd->ifd_cmd);
+ return (EINVAL);
+ }
+
+ return (0);
+}
+
+/************************************************************************
+ * ixgbe_nvm_access_ioctl
+ *
+ * Handles an NVM access ioctl request
+ ************************************************************************/
+static int
+ixgbe_nvm_access_ioctl(struct ixgbe_softc *sc, struct ifdrv *ifd)
+{
+ struct ixgbe_nvm_access_data *data;
+ struct ixgbe_nvm_access_cmd *cmd;
+ struct ixgbe_hw *hw = &sc->hw;
+ size_t ifd_len = ifd->ifd_len;
+ size_t malloc_len;
+ device_t dev = sc->dev;
+ u8 *nvm_buffer;
+ s32 error = 0;
+
+ /*
+ * ifioctl forwards SIOCxDRVSPEC to iflib without conducting
+ * a privilege check. Subsequently, iflib passes the ioctl to the driver
+ * without verifying privileges. To prevent non-privileged threads from
+ * accessing this interface, perform a privilege check at this point.
+ */
+ error = priv_check(curthread, PRIV_DRIVER);
+ if (error)
+ return (error);
+
+ if (ifd_len < sizeof(*cmd)) {
+ device_printf(dev,
+ "%s: ifdrv length is too small. Got %zu, "
+ "but expected %zu\n",
+ __func__, ifd_len, sizeof(*cmd));
+ return (EINVAL);
+ }
+
+ if (ifd->ifd_data == NULL) {
+ device_printf(dev, "%s: No ifd data buffer.\n",
+ __func__);
+ return (EINVAL);
+ }
+
+ malloc_len = max(ifd_len, sizeof(*data) + sizeof(*cmd));
+
+ nvm_buffer = (u8 *)malloc(malloc_len, M_IXGBE, M_ZERO | M_NOWAIT);
+ if (!nvm_buffer)
+ return (ENOMEM);
+
+ /* Copy the NVM access command and data in from user space */
+ error = copyin(ifd->ifd_data, nvm_buffer, ifd_len);
+ if (error) {
+ device_printf(dev, "%s: Failed to copy data in, error: %d\n",
+ __func__, error);
+ goto cleanup_free_nvm_buffer;
+ }
+
+ /*
+ * The NVM command structure is immediately followed by data which
+ * varies in size based on the command.
+ */
+ cmd = (struct ixgbe_nvm_access_cmd *)nvm_buffer;
+ data = (struct ixgbe_nvm_access_data *)
+ (nvm_buffer + sizeof(struct ixgbe_nvm_access_cmd));
+
+ /* Handle the NVM access request */
+ error = ixgbe_handle_nvm_access(hw, cmd, data);
+ if (error) {
+ device_printf(dev, "%s: NVM access request failed, error %d\n",
+ __func__, error);
+ }
+
+ /* Copy the possibly modified contents of the handled request out */
+ error = copyout(nvm_buffer, ifd->ifd_data, ifd_len);
+ if (error) {
+ device_printf(dev, "%s: Copying response back to "
+ "user space failed, error %d\n",
+ __func__, error);
+ goto cleanup_free_nvm_buffer;
+ }
+
+cleanup_free_nvm_buffer:
+ free(nvm_buffer, M_IXGBE);
+ return (error);
+}
+
+/************************************************************************
+ * ixgbe_debug_dump_ioctl
+ *
+ * Makes debug dump of internal FW/HW data.
+ ************************************************************************/
+static int
+ixgbe_debug_dump_ioctl(struct ixgbe_softc *sc, struct ifdrv *ifd)
+{
+ struct ixgbe_debug_dump_cmd *dd_cmd;
+ struct ixgbe_hw *hw = &sc->hw;
+ size_t ifd_len = ifd->ifd_len;
+ device_t dev = sc->dev;
+ s32 error = 0;
+
+ if (!(sc->feat_en & IXGBE_FEATURE_DBG_DUMP))
+ return (ENODEV);
+
+ /* Data returned from ACI command */
+ u16 ret_buf_size = 0;
+ u16 ret_next_cluster = 0;
+ u16 ret_next_table = 0;
+ u32 ret_next_index = 0;
+
+ /*
+ * ifioctl forwards SIOCxDRVSPEC to iflib without conducting
+ * a privilege check. Subsequently, iflib passes the ioctl to the driver
+ * without verifying privileges. To prevent non-privileged threads from
+ * accessing this interface, perform a privilege check at this point.
+ */
+ error = priv_check(curthread, PRIV_DRIVER);
+ if (error)
+ return (error);
+
+ if (ifd_len < sizeof(*dd_cmd)) {
+ device_printf(dev,
+ "%s: ifdrv length is too small. Got %zu, "
+ "but expected %zu\n",
+ __func__, ifd_len, sizeof(*dd_cmd));
+ return (EINVAL);
+ }
+
+ if (ifd->ifd_data == NULL) {
+ device_printf(dev, "%s: No ifd data buffer.\n",
+ __func__);
+ return (EINVAL);
+ }
+
+ dd_cmd = (struct ixgbe_debug_dump_cmd *)malloc(ifd_len, M_IXGBE,
+ M_NOWAIT | M_ZERO);
+ if (!dd_cmd) {
+ error = -ENOMEM;
+ goto out;
+ }
+ /* copy data from userspace */
+ error = copyin(ifd->ifd_data, dd_cmd, ifd_len);
+ if (error) {
+ device_printf(dev, "%s: Failed to copy data in, error: %d\n",
+ __func__, error);
+ goto out;
+ }
+
+ /* ACI command requires buf_size arg to be grater than 0 */
+ if (dd_cmd->data_size == 0) {
+ device_printf(dev, "%s: data_size must be greater than 0\n",
+ __func__);
+ error = EINVAL;
+ goto out;
+ }
+
+ /* Zero the data buffer memory space */
+ memset(dd_cmd->data, 0, ifd_len - sizeof(*dd_cmd));
+
+ error = ixgbe_aci_get_internal_data(hw, dd_cmd->cluster_id,
+ dd_cmd->table_id, dd_cmd->offset, dd_cmd->data, dd_cmd->data_size,
+ &ret_buf_size, &ret_next_cluster, &ret_next_table, &ret_next_index);
+ if (error) {
+ device_printf(dev,
+ "%s: Failed to get internal FW/HW data, error: %d\n",
+ __func__, error);
+ goto out;
+ }
+
+ dd_cmd->cluster_id = ret_next_cluster;
+ dd_cmd->table_id = ret_next_table;
+ dd_cmd->offset = ret_next_index;
+ dd_cmd->data_size = ret_buf_size;
+
+ error = copyout(dd_cmd, ifd->ifd_data, ifd->ifd_len);
+ if (error) {
+ device_printf(dev,
+ "%s: Failed to copy data out, error: %d\n",
+ __func__, error);
+ }
+
+out:
+ free(dd_cmd, M_IXGBE);
+
+ return (error);
+}
+
+/************************************************************************
* ixgbe_add_media_types
************************************************************************/
static void
@@ -2883,6 +3140,264 @@ ixgbe_sysctl_interrupt_rate_handler(SYSCTL_HANDLER_ARGS)
} /* ixgbe_sysctl_interrupt_rate_handler */
/************************************************************************
+ * ixgbe_debug_dump_print_cluster
+ ************************************************************************/
+static u8
+ixgbe_debug_dump_print_cluster(struct ixgbe_softc *sc, struct sbuf *sbuf,
+ u8 cluster_id)
+{
+ u16 data_buf_size = IXGBE_ACI_MAX_BUFFER_SIZE;
+ device_t dev = sc->dev;
+ struct ixgbe_hw *hw = &sc->hw;
+ const u8 reserved_buf[8] = {};
+ int max_aci_calls = 1000;
+ int error, counter = 0;
+ u8 *data_buf;
+
+ /* Input parameters / loop variables */
+ u16 table_id = 0;
+ u32 offset = 0;
+
+ /* Data returned from ACI command */
+ u16 ret_buf_size = 0;
+ u16 ret_next_cluster = 0;
+ u16 ret_next_table = 0;
+ u32 ret_next_index = 0;
+
+ data_buf = (u8 *)malloc(data_buf_size, M_IXGBE, M_NOWAIT | M_ZERO);
+ if (!data_buf)
+ return (0);
+
+ DEBUGOUT2("%s: dumping cluster id (relative) %d\n",
+ __func__, cluster_id);
+
+ do {
+ DEBUGOUT3("table_id 0x%04x offset 0x%08x buf_size %d\n",
+ table_id, offset, data_buf_size);
+
+ error = ixgbe_aci_get_internal_data(hw, cluster_id, table_id,
+ offset, data_buf, data_buf_size, &ret_buf_size,
+ &ret_next_cluster, &ret_next_table, &ret_next_index);
+ if (error) {
+ device_printf(dev,
+ "%s: Failed to get internal FW/HW data, error: %d, "
+ "last aci status: %d\n",
+ __func__, error, hw->aci.last_status);
+ break;
+ }
+
+ DEBUGOUT3("ret_table_id 0x%04x ret_offset 0x%08x "
+ "ret_buf_size %d\n",
+ ret_next_table, ret_next_index, ret_buf_size);
+
+ /* Print cluster id */
+ u32 print_cluster_id = (u32)cluster_id;
+ sbuf_bcat(sbuf, &print_cluster_id, sizeof(print_cluster_id));
+ /* Print table id */
+ u32 print_table_id = (u32)table_id;
+ sbuf_bcat(sbuf, &print_table_id, sizeof(print_table_id));
+ /* Print table length */
+ u32 print_table_length = (u32)ret_buf_size;
+ sbuf_bcat(sbuf, &print_table_length,
+ sizeof(print_table_length));
+ /* Print current offset */
+ u32 print_curr_offset = offset;
+ sbuf_bcat(sbuf, &print_curr_offset, sizeof(print_curr_offset));
+ /* Print reserved bytes */
+ sbuf_bcat(sbuf, reserved_buf, sizeof(reserved_buf));
+ /* Print data */
+ sbuf_bcat(sbuf, data_buf, ret_buf_size);
+
+ /* Prepare for the next loop spin */
+ memset(data_buf, 0, data_buf_size);
+
+ bool last_index = (ret_next_index == 0xffffffff);
+ bool last_table = ((ret_next_table == 0xff ||
+ ret_next_table == 0xffff) &&
+ last_index);
+
+ if (last_table) {
+ /* End of the cluster */
+ DEBUGOUT1("End of the cluster ID %d\n", cluster_id);
+ break;
+ } else if (last_index) {
+ /* End of the table */
+ table_id = ret_next_table;
+ offset = 0;
+ } else {
+ /* More data left in the table */
+ offset = ret_next_index;
+ }
+ } while (++counter < max_aci_calls);
+
+ if (counter >= max_aci_calls)
+ device_printf(dev, "Exceeded nr of ACI calls for cluster %d\n",
+ cluster_id);
+
+ free(data_buf, M_IXGBE);
+
+ return (++cluster_id);
+} /* ixgbe_print_debug_dump_cluster */
+
+/************************************************************************
+ * ixgbe_sysctl_debug_dump_set_clusters
+ *
+ * Sets the cluster to dump from FW when Debug Dump requested.
+ ************************************************************************/
+static int
+ixgbe_sysctl_debug_dump_set_clusters(SYSCTL_HANDLER_ARGS)
+{
+ struct ixgbe_softc *sc = (struct ixgbe_softc *)arg1;
+ u32 clusters = sc->debug_dump_cluster_mask;
+ device_t dev = sc->dev;
+ int error;
+
+ error = sysctl_handle_32(oidp, &clusters, 0, req);
+ if ((error) || !req->newptr)
+ return (error);
+
+ if (clusters & ~(IXGBE_DBG_DUMP_VALID_CLUSTERS_MASK)) {
+ device_printf(dev,
+ "%s: Unrecognized parameter: %u\n",
+ __func__, clusters);
+ sc->debug_dump_cluster_mask =
+ IXGBE_ACI_DBG_DUMP_CLUSTER_ID_INVALID;
+ return (EINVAL);
+ }
+
+ sc->debug_dump_cluster_mask = clusters;
+
+ return (0);
+} /* ixgbe_sysctl_debug_dump_set_clusters */
+
+/************************************************************************
+ * ixgbe_sysctl_dump_debug_dump
+ ************************************************************************/
+static int
+ixgbe_sysctl_dump_debug_dump(SYSCTL_HANDLER_ARGS)
+{
+ struct ixgbe_softc *sc = (struct ixgbe_softc *)arg1;
+ device_t dev = sc->dev;
+ struct sbuf *sbuf;
+ int error = 0;
+
+ UNREFERENCED_PARAMETER(arg2);
+
+ if (!sc->do_debug_dump) {
+ if (req->oldptr == NULL && req->newptr == NULL) {
+ error = SYSCTL_OUT(req, 0, 0);
+ return (error);
+ }
+
+ char input_buf[2] = "";
+ error = sysctl_handle_string(oidp, input_buf,
+ sizeof(input_buf), req);
+ if ((error) || (req->newptr == NULL))
+ return (error);
+
+ if (input_buf[0] == '1') {
+ if (sc->debug_dump_cluster_mask ==
+ IXGBE_ACI_DBG_DUMP_CLUSTER_ID_INVALID) {
+ device_printf(dev,
+ "Debug Dump failed because an invalid "
+ "cluster was specified.\n");
+ return (EINVAL);
+ }
+
+ sc->do_debug_dump = true;
+ return (0);
+ }
+
+ return (EINVAL);
+ }
+
+ /* Caller just wants the upper bound for size */
+ if (req->oldptr == NULL && req->newptr == NULL) {
+ size_t est_output_len = IXGBE_DBG_DUMP_BASE_SIZE;
+ if (sc->debug_dump_cluster_mask & 0x2)
+ est_output_len += IXGBE_DBG_DUMP_BASE_SIZE;
+ error = SYSCTL_OUT(req, 0, est_output_len);
+ return (error);
+ }
+
+ sbuf = sbuf_new_for_sysctl(NULL, NULL, 128, req);
+ sbuf_clear_flags(sbuf, SBUF_INCLUDENUL);
+
+ DEBUGOUT("FW Debug Dump running...\n");
+
+ if (sc->debug_dump_cluster_mask) {
+ for (u8 id = 0; id <= IXGBE_ACI_DBG_DUMP_CLUSTER_ID_MAX; id++) {
+ if (sc->debug_dump_cluster_mask & BIT(id)) {
+ DEBUGOUT1("Dumping cluster ID %u...\n", id);
+ ixgbe_debug_dump_print_cluster(sc, sbuf, id);
+ }
+ }
+ } else {
+ u8 next_cluster_id = 0;
+ do {
+ DEBUGOUT1("Dumping cluster ID %u...\n",
+ next_cluster_id);
+ next_cluster_id = ixgbe_debug_dump_print_cluster(sc,
+ sbuf, next_cluster_id);
+ } while (next_cluster_id != 0 &&
+ next_cluster_id <= IXGBE_ACI_DBG_DUMP_CLUSTER_ID_MAX);
+ }
+
+ sbuf_finish(sbuf);
+ sbuf_delete(sbuf);
+
+ sc->do_debug_dump = false;
+
+ return (error);
+} /* ixgbe_sysctl_dump_debug_dump */
+
+/************************************************************************
+ * ixgbe_add_debug_dump_sysctls
+ ************************************************************************/
+static void
+ixgbe_add_debug_dump_sysctls(struct ixgbe_softc *sc)
+{
+ struct sysctl_oid_list *debug_list, *dump_list;
+ struct sysctl_oid *dump_node;
+ struct sysctl_ctx_list *ctx;
+ device_t dev = sc->dev;
+
+ ctx = device_get_sysctl_ctx(dev);
+ debug_list = SYSCTL_CHILDREN(sc->debug_sysctls);
+
+ dump_node = SYSCTL_ADD_NODE(ctx, debug_list, OID_AUTO, "dump",
+ CTLFLAG_RD, NULL, "Internal FW/HW Dump");
+ dump_list = SYSCTL_CHILDREN(dump_node);
+
+ SYSCTL_ADD_PROC(ctx, dump_list, OID_AUTO, "clusters",
+ CTLTYPE_U32 | CTLFLAG_RW, sc, 0,
+ ixgbe_sysctl_debug_dump_set_clusters, "SU",
+ IXGBE_SYSCTL_DESC_DEBUG_DUMP_SET_CLUSTER);
+
+ SYSCTL_ADD_PROC(ctx, dump_list, OID_AUTO, "dump",
+ CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_MPSAFE, sc, 0,
+ ixgbe_sysctl_dump_debug_dump, "",
+ IXGBE_SYSCTL_DESC_DUMP_DEBUG_DUMP);
+} /* ixgbe_add_debug_dump_sysctls */
+
+static void
+ixgbe_add_debug_sysctls(struct ixgbe_softc *sc)
+{
+ struct sysctl_oid_list *ctx_list;
+ struct sysctl_ctx_list *ctx;
+ device_t dev = sc->dev;
+
+ ctx = device_get_sysctl_ctx(dev);
+ ctx_list = SYSCTL_CHILDREN(device_get_sysctl_tree(dev));
+
+ sc->debug_sysctls = SYSCTL_ADD_NODE(ctx, ctx_list, OID_AUTO, "debug",
+ CTLFLAG_RD, NULL, "Debug Sysctls");
+
+ if (sc->feat_en & IXGBE_FEATURE_DBG_DUMP)
+ ixgbe_add_debug_dump_sysctls(sc);
+} /* ixgbe_add_debug_sysctls */
+
+/************************************************************************
* ixgbe_add_device_sysctls
************************************************************************/
static void
@@ -2992,6 +3507,8 @@ ixgbe_add_device_sysctls(if_ctx_t ctx)
CTLTYPE_INT | CTLFLAG_RW, sc, 0,
ixgbe_sysctl_eee_state, "I", "EEE Power Save State");
}
+
+ ixgbe_add_debug_sysctls(sc);
} /* ixgbe_add_device_sysctls */
/************************************************************************
@@ -5182,6 +5699,7 @@ ixgbe_init_device_features(struct ixgbe_softc *sc)
break;
case ixgbe_mac_E610:
sc->feat_cap |= IXGBE_FEATURE_RECOVERY_MODE;
+ sc->feat_cap |= IXGBE_FEATURE_DBG_DUMP;
break;
default:
break;
@@ -5203,6 +5721,9 @@ ixgbe_init_device_features(struct ixgbe_softc *sc)
/* Recovery mode */
if (sc->feat_cap & IXGBE_FEATURE_RECOVERY_MODE)
sc->feat_en |= IXGBE_FEATURE_RECOVERY_MODE;
+ /* FW Debug Dump */
+ if (sc->feat_cap & IXGBE_FEATURE_DBG_DUMP)
+ sc->feat_en |= IXGBE_FEATURE_DBG_DUMP;
/* Enabled via global sysctl... */
/* Flow Director */
diff --git a/sys/dev/ixgbe/ixgbe.h b/sys/dev/ixgbe/ixgbe.h
index 844064bf8543..624b71acabea 100644
--- a/sys/dev/ixgbe/ixgbe.h
+++ b/sys/dev/ixgbe/ixgbe.h
@@ -46,6 +46,7 @@
#include <sys/module.h>
#include <sys/sockio.h>
#include <sys/eventhandler.h>
+#include <sys/priv.h>
#include <net/if.h>
#include <net/if_var.h>
@@ -475,6 +476,20 @@ struct ixgbe_softc {
u32 feat_cap;
u32 feat_en;
u16 lse_mask;
+
+ struct sysctl_oid *debug_sysctls;
+ u32 debug_dump_cluster_mask;
+ bool do_debug_dump;
+};
+
+struct ixgbe_debug_dump_cmd {
+ u32 offset; /* offset to read/write from table, in bytes */
+ u8 cluster_id; /* also used to get next cluster id */
+ u16 table_id;
+ u16 data_size; /* size of data field, in bytes */
+ u16 reserved1;
+ u32 reserved2;
+ u8 data[];
};
/* Precision Time Sync (IEEE 1588) defines */
@@ -499,6 +514,43 @@ struct ixgbe_softc {
#define IXGBE_PHY_CURRENT_TEMP 0xC820
#define IXGBE_PHY_OVERTEMP_STATUS 0xC830
+/**
+ * The ioctl command number used by NVM update for accessing the driver for
+ * NVM access commands.
+ */
+#define IXGBE_NVM_ACCESS \
+ (((((((('E' << 4) + '1') << 4) + 'K') << 4) + 'G') << 4) | 5)
+
+/*
+ * The ioctl command number used by a userspace tool for accessing the driver
+ * for getting debug dump data from the firmware.
+ */
+#define IXGBE_DEBUG_DUMP \
+ (((((((('E' << 4) + '1') << 4) + 'K') << 4) + 'G') << 4) | 6)
+
+/* Debug Dump related definitions */
+#define IXGBE_ACI_DBG_DUMP_CLUSTER_ID_INVALID 0xFFFFFF
+#define IXGBE_ACI_DBG_DUMP_CLUSTER_ID_BASE 50
+#define IXGBE_ACI_DBG_DUMP_CLUSTER_ID_MAX 1
+
+#define IXGBE_DBG_DUMP_VALID_CLUSTERS_MASK 0x3
+#define IXGBE_DBG_DUMP_BASE_SIZE (2 * 1024 * 1024)
+
+#define IXGBE_SYSCTL_DESC_DEBUG_DUMP_SET_CLUSTER \
+"\nSelect clusters to dump with \"dump\" sysctl" \
+"\nFlags:" \
+"\n\t 0x1 - Link" \
+"\n\t 0x2 - Full CSR Space, excluding RCW registers" \
+"\n\t" \
+"\nUse \"sysctl -x\" to view flags properly."
+
+#define IXGBE_SYSCTL_DESC_DUMP_DEBUG_DUMP \
+"\nWrite 1 to output a FW debug dump containing the clusters " \
+"specified by the \"clusters\" sysctl" \
+"\nThe \"-b\" flag must be used in order to dump this data " \
+"as binary data because" \
+"\nthis data is opaque and not a string."
+
/* Sysctl help messages; displayed with sysctl -d */
#define IXGBE_SYSCTL_DESC_ADV_SPEED \
"\nControl advertised link speed using these flags:\n" \
diff --git a/sys/dev/ixgbe/ixgbe_features.h b/sys/dev/ixgbe/ixgbe_features.h
index 0cef334a185f..bee9040319d8 100644
--- a/sys/dev/ixgbe/ixgbe_features.h
+++ b/sys/dev/ixgbe/ixgbe_features.h
@@ -57,6 +57,7 @@
#define IXGBE_FEATURE_LEGACY_IRQ (u32)(1 << 12)
#define IXGBE_FEATURE_NEEDS_CTXD (u32)(1 << 13)
#define IXGBE_FEATURE_RECOVERY_MODE (u32)(1 << 15)
+#define IXGBE_FEATURE_DBG_DUMP (u32)(1 << 16)
/* Check for OS support. Undefine features if not included in the OS */
#ifndef PCI_IOV
diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h
index 17c5cdb4db87..57cb37907e65 100644
--- a/sys/dev/nvme/nvme.h
+++ b/sys/dev/nvme/nvme.h
@@ -1507,9 +1507,7 @@ struct nvme_namespace_data {
uint8_t eui64[8];
/** lba format support */
- uint32_t lbaf[16];
-
- uint8_t reserved7[192];
+ uint32_t lbaf[64];
uint8_t vendor_specific[3712];
} __packed __aligned(4);
@@ -2175,7 +2173,7 @@ void nvme_namespace_data_swapbytes(struct nvme_namespace_data *s __unused)
s->anagrpid = le32toh(s->anagrpid);
s->nvmsetid = le16toh(s->nvmsetid);
s->endgid = le16toh(s->endgid);
- for (i = 0; i < 16; i++)
+ for (i = 0; i < 64; i++)
s->lbaf[i] = le32toh(s->lbaf[i]);
#endif
}
diff --git a/sys/dev/vmm/vmm_mem.c b/sys/dev/vmm/vmm_mem.c
index be59e37de33d..9df31c9ba133 100644
--- a/sys/dev/vmm/vmm_mem.c
+++ b/sys/dev/vmm/vmm_mem.c
@@ -26,10 +26,14 @@
static void vm_free_memmap(struct vm *vm, int ident);
-void
-vm_mem_init(struct vm_mem *mem)
+int
+vm_mem_init(struct vm_mem *mem, vm_offset_t lo, vm_offset_t hi)
{
+ mem->mem_vmspace = vmmops_vmspace_alloc(lo, hi);
+ if (mem->mem_vmspace == NULL)
+ return (ENOMEM);
sx_init(&mem->mem_segs_lock, "vm_mem_segs");
+ return (0);
}
static bool
@@ -93,10 +97,21 @@ vm_mem_destroy(struct vm *vm)
for (int i = 0; i < VM_MAX_MEMSEGS; i++)
vm_free_memseg(vm, i);
+ vmmops_vmspace_free(mem->mem_vmspace);
+
sx_xunlock(&mem->mem_segs_lock);
sx_destroy(&mem->mem_segs_lock);
}
+struct vmspace *
+vm_vmspace(struct vm *vm)
+{
+ struct vm_mem *mem;
+
+ mem = vm_mem(vm);
+ return (mem->mem_vmspace);
+}
+
void
vm_slock_memsegs(struct vm *vm)
{
@@ -246,7 +261,7 @@ vm_mmap_memseg(struct vm *vm, vm_paddr_t gpa, int segid, vm_ooffset_t first,
struct vm_mem *mem;
struct vm_mem_seg *seg;
struct vm_mem_map *m, *map;
- struct vmspace *vmspace;
+ struct vm_map *vmmap;
vm_ooffset_t last;
int i, error;
@@ -282,19 +297,19 @@ vm_mmap_memseg(struct vm *vm, vm_paddr_t gpa, int segid, vm_ooffset_t first,
if (map == NULL)
return (ENOSPC);
- vmspace = vm_vmspace(vm);
- error = vm_map_find(&vmspace->vm_map, seg->object, first, &gpa,
- len, 0, VMFS_NO_SPACE, prot, prot, 0);
+ vmmap = &mem->mem_vmspace->vm_map;
+ error = vm_map_find(vmmap, seg->object, first, &gpa, len, 0,
+ VMFS_NO_SPACE, prot, prot, 0);
if (error != KERN_SUCCESS)
return (EFAULT);
vm_object_reference(seg->object);
if (flags & VM_MEMMAP_F_WIRED) {
- error = vm_map_wire(&vmspace->vm_map, gpa, gpa + len,
+ error = vm_map_wire(vmmap, gpa, gpa + len,
VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
if (error != KERN_SUCCESS) {
- vm_map_remove(&vmspace->vm_map, gpa, gpa + len);
+ vm_map_remove(vmmap, gpa, gpa + len);
return (error == KERN_RESOURCE_SHORTAGE ? ENOMEM :
EFAULT);
}
diff --git a/sys/dev/vmm/vmm_mem.h b/sys/dev/vmm/vmm_mem.h
index 856470cf2590..f3d22058c7b8 100644
--- a/sys/dev/vmm/vmm_mem.h
+++ b/sys/dev/vmm/vmm_mem.h
@@ -36,6 +36,7 @@ enum {
struct vm;
struct vm_object;
+struct vmspace;
struct vm_mem_seg {
size_t len;
@@ -56,12 +57,15 @@ struct vm_mem {
struct vm_mem_map mem_maps[VM_MAX_MEMMAPS];
struct vm_mem_seg mem_segs[VM_MAX_MEMSEGS];
struct sx mem_segs_lock;
+ struct vmspace *mem_vmspace;
};
-void vm_mem_init(struct vm_mem *mem);
+int vm_mem_init(struct vm_mem *mem, vm_offset_t lo, vm_offset_t hi);
void vm_mem_cleanup(struct vm *vm);
void vm_mem_destroy(struct vm *vm);
+struct vmspace *vm_vmspace(struct vm *vm);
+
/*
* APIs that modify the guest memory map require all vcpus to be frozen.
*/
diff --git a/sys/fs/nullfs/null.h b/sys/fs/nullfs/null.h
index ad3f7779e108..7bfdc20a3f67 100644
--- a/sys/fs/nullfs/null.h
+++ b/sys/fs/nullfs/null.h
@@ -35,11 +35,12 @@
#ifndef FS_NULL_H
#define FS_NULL_H
-#define NULLM_CACHE 0x0001
-
#include <sys/ck.h>
#include <vm/uma.h>
+#define NULLM_CACHE 0x0001
+#define NULLM_NOUNPBYPASS 0x0002
+
struct null_mount {
struct mount *nullm_vfs;
struct vnode *nullm_lowerrootvp; /* Ref to lower root vnode */
@@ -82,6 +83,16 @@ struct vnode *null_checkvp(struct vnode *vp, char *fil, int lno);
#endif
extern struct vop_vector null_vnodeops;
+extern struct vop_vector null_vnodeops_no_unp_bypass;
+
+static inline bool
+null_is_nullfs_vnode(struct vnode *vp)
+{
+ const struct vop_vector *op;
+
+ op = vp->v_op;
+ return (op == &null_vnodeops || op == &null_vnodeops_no_unp_bypass);
+}
extern uma_zone_t null_node_zone;
diff --git a/sys/fs/nullfs/null_subr.c b/sys/fs/nullfs/null_subr.c
index d7f847d449d0..a843ae44f121 100644
--- a/sys/fs/nullfs/null_subr.c
+++ b/sys/fs/nullfs/null_subr.c
@@ -240,7 +240,9 @@ null_nodeget(struct mount *mp, struct vnode *lowervp, struct vnode **vpp)
*/
xp = uma_zalloc_smr(null_node_zone, M_WAITOK);
- error = getnewvnode("nullfs", mp, &null_vnodeops, &vp);
+ error = getnewvnode("nullfs", mp, (MOUNTTONULLMOUNT(mp)->nullm_flags &
+ NULLM_NOUNPBYPASS) != 0 ? &null_vnodeops_no_unp_bypass :
+ &null_vnodeops, &vp);
if (error) {
vput(lowervp);
uma_zfree_smr(null_node_zone, xp);
diff --git a/sys/fs/nullfs/null_vfsops.c b/sys/fs/nullfs/null_vfsops.c
index 4cddf24a5745..170a3dd51cd8 100644
--- a/sys/fs/nullfs/null_vfsops.c
+++ b/sys/fs/nullfs/null_vfsops.c
@@ -85,6 +85,10 @@ nullfs_mount(struct mount *mp)
char *target;
int error, len;
bool isvnunlocked;
+ static const char cache_opt_name[] = "cache";
+ static const char nocache_opt_name[] = "nocache";
+ static const char unixbypass_opt_name[] = "unixbypass";
+ static const char nounixbypass_opt_name[] = "nounixbypass";
NULLFSDEBUG("nullfs_mount(mp = %p)\n", (void *)mp);
@@ -116,7 +120,7 @@ nullfs_mount(struct mount *mp)
/*
* Unlock lower node to avoid possible deadlock.
*/
- if (mp->mnt_vnodecovered->v_op == &null_vnodeops &&
+ if (null_is_nullfs_vnode(mp->mnt_vnodecovered) &&
VOP_ISLOCKED(mp->mnt_vnodecovered) == LK_EXCLUSIVE) {
VOP_UNLOCK(mp->mnt_vnodecovered);
isvnunlocked = true;
@@ -150,7 +154,7 @@ nullfs_mount(struct mount *mp)
/*
* Check multi null mount to avoid `lock against myself' panic.
*/
- if (mp->mnt_vnodecovered->v_op == &null_vnodeops) {
+ if (null_is_nullfs_vnode(mp->mnt_vnodecovered)) {
nn = VTONULL(mp->mnt_vnodecovered);
if (nn == NULL || lowerrootvp == nn->null_lowervp) {
NULLFSDEBUG("nullfs_mount: multi null mount?\n");
@@ -205,9 +209,10 @@ nullfs_mount(struct mount *mp)
MNT_IUNLOCK(mp);
}
- if (vfs_getopt(mp->mnt_optnew, "cache", NULL, NULL) == 0) {
+ if (vfs_getopt(mp->mnt_optnew, cache_opt_name, NULL, NULL) == 0) {
xmp->nullm_flags |= NULLM_CACHE;
- } else if (vfs_getopt(mp->mnt_optnew, "nocache", NULL, NULL) == 0) {
+ } else if (vfs_getopt(mp->mnt_optnew, nocache_opt_name, NULL,
+ NULL) == 0) {
;
} else if (null_cache_vnodes &&
(xmp->nullm_vfs->mnt_kern_flag & MNTK_NULL_NOCACHE) == 0) {
@@ -219,6 +224,13 @@ nullfs_mount(struct mount *mp)
&xmp->notify_node);
}
+ if (vfs_getopt(mp->mnt_optnew, unixbypass_opt_name, NULL, NULL) == 0) {
+ ;
+ } else if (vfs_getopt(mp->mnt_optnew, nounixbypass_opt_name, NULL,
+ NULL) == 0) {
+ xmp->nullm_flags |= NULLM_NOUNPBYPASS;
+ }
+
if (lowerrootvp == mp->mnt_vnodecovered) {
vn_lock(lowerrootvp, LK_EXCLUSIVE | LK_RETRY | LK_CANRECURSE);
lowerrootvp->v_vflag |= VV_CROSSLOCK;
diff --git a/sys/fs/nullfs/null_vnops.c b/sys/fs/nullfs/null_vnops.c
index ec8a6b10b13f..d4baabeb40ab 100644
--- a/sys/fs/nullfs/null_vnops.c
+++ b/sys/fs/nullfs/null_vnops.c
@@ -278,7 +278,7 @@ null_bypass(struct vop_generic_args *ap)
* that aren't. (We must always map first vp or vclean fails.)
*/
if (i != 0 && (*this_vp_p == NULL ||
- (*this_vp_p)->v_op != &null_vnodeops)) {
+ !null_is_nullfs_vnode(*this_vp_p))) {
old_vps[i] = NULL;
} else {
old_vps[i] = *this_vp_p;
@@ -1256,3 +1256,11 @@ struct vop_vector null_vnodeops = {
.vop_copy_file_range = VOP_PANIC,
};
VFS_VOP_VECTOR_REGISTER(null_vnodeops);
+
+struct vop_vector null_vnodeops_no_unp_bypass = {
+ .vop_default = &null_vnodeops,
+ .vop_unp_bind = vop_stdunp_bind,
+ .vop_unp_connect = vop_stdunp_connect,
+ .vop_unp_detach = vop_stdunp_detach,
+};
+VFS_VOP_VECTOR_REGISTER(null_vnodeops_no_unp_bypass);
diff --git a/sys/modules/aic7xxx/ahc/Makefile b/sys/modules/aic7xxx/ahc/Makefile
index 3741d4fb666f..6f9bdcb1d8bd 100644
--- a/sys/modules/aic7xxx/ahc/Makefile
+++ b/sys/modules/aic7xxx/ahc/Makefile
@@ -1,6 +1,4 @@
SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
-
.PATH: ${SYSDIR}/dev/aic7xxx
KMOD= ahc
SUBDIR+= ahc_isa ahc_pci
diff --git a/sys/modules/cxgb/Makefile b/sys/modules/cxgb/Makefile
index 2989ad580b97..7ebdc1d51945 100644
--- a/sys/modules/cxgb/Makefile
+++ b/sys/modules/cxgb/Makefile
@@ -1,6 +1,3 @@
-SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
-
SUBDIR= cxgb
SUBDIR+= cxgb_t3fw
diff --git a/sys/modules/dpdk_lpm4/Makefile b/sys/modules/dpdk_lpm4/Makefile
index ff68fac78915..9bc2693aeffb 100644
--- a/sys/modules/dpdk_lpm4/Makefile
+++ b/sys/modules/dpdk_lpm4/Makefile
@@ -1,6 +1,3 @@
-SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
-
.PATH: ${SYSDIR}/contrib/dpdk_rte_lpm
KMOD= dpdk_lpm4
diff --git a/sys/modules/dpdk_lpm6/Makefile b/sys/modules/dpdk_lpm6/Makefile
index f2248e5d1c1c..9de2c6650422 100644
--- a/sys/modules/dpdk_lpm6/Makefile
+++ b/sys/modules/dpdk_lpm6/Makefile
@@ -1,6 +1,3 @@
-SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
-
.PATH: ${SYSDIR}/contrib/dpdk_rte_lpm
KMOD= dpdk_lpm6
diff --git a/sys/modules/fib_dxr/Makefile b/sys/modules/fib_dxr/Makefile
index 7d1996ba510f..f8a28abe957a 100644
--- a/sys/modules/fib_dxr/Makefile
+++ b/sys/modules/fib_dxr/Makefile
@@ -1,6 +1,3 @@
-SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
-
.PATH: ${SYSDIR}/netinet
KMOD= fib_dxr
diff --git a/sys/modules/if_enc/Makefile b/sys/modules/if_enc/Makefile
index 449d869d6a21..bd865a0216a4 100644
--- a/sys/modules/if_enc/Makefile
+++ b/sys/modules/if_enc/Makefile
@@ -1,6 +1,4 @@
SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
-
.PATH: ${SYSDIR}/net
KMOD= if_enc
diff --git a/sys/modules/if_gif/Makefile b/sys/modules/if_gif/Makefile
index efcd6952a8ac..5e3fda3a51c6 100644
--- a/sys/modules/if_gif/Makefile
+++ b/sys/modules/if_gif/Makefile
@@ -1,6 +1,4 @@
SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
-
.PATH: ${SYSDIR}/net ${SYSDIR}/netinet ${SYSDIR}/netinet6
KMOD= if_gif
diff --git a/sys/modules/if_gre/Makefile b/sys/modules/if_gre/Makefile
index 9f50708a14d7..58bd03c23785 100644
--- a/sys/modules/if_gre/Makefile
+++ b/sys/modules/if_gre/Makefile
@@ -1,6 +1,5 @@
SYSDIR?=${SRCTOP}/sys
.PATH: ${SYSDIR}/net ${SYSDIR}/netinet ${SYSDIR}/netinet6
-.include "${SYSDIR}/conf/kern.opts.mk"
KMOD= if_gre
SRCS= if_gre.c opt_inet.h opt_inet6.h opt_rss.h
diff --git a/sys/modules/iser/Makefile b/sys/modules/iser/Makefile
index 615199ec97a3..ff08ae6f346a 100644
--- a/sys/modules/iser/Makefile
+++ b/sys/modules/iser/Makefile
@@ -1,6 +1,4 @@
SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
-
.PATH: ${SYSDIR}/dev/iser/
KMOD= iser
diff --git a/sys/modules/ktest/Makefile b/sys/modules/ktest/Makefile
index 151db53417df..a3052efa9ed9 100644
--- a/sys/modules/ktest/Makefile
+++ b/sys/modules/ktest/Makefile
@@ -1,6 +1,3 @@
-SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
-
SUBDIR= ktest \
ktest_example \
ktest_netlink_message_writer
diff --git a/sys/modules/ktest/ktest/Makefile b/sys/modules/ktest/ktest/Makefile
index 3d4f1a8c2cc0..9741662ef709 100644
--- a/sys/modules/ktest/ktest/Makefile
+++ b/sys/modules/ktest/ktest/Makefile
@@ -1,9 +1,5 @@
PACKAGE= tests
-
-SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
-
-.PATH: ${SYSDIR}/tests
+.PATH: ${SRCTOP}/sys/tests
KMOD= ktest
SRCS= ktest.c
diff --git a/sys/modules/ktest/ktest_example/Makefile b/sys/modules/ktest/ktest_example/Makefile
index 2b572d867aa5..aacc8f0e4ca5 100644
--- a/sys/modules/ktest/ktest_example/Makefile
+++ b/sys/modules/ktest/ktest_example/Makefile
@@ -1,9 +1,8 @@
PACKAGE= tests
-SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
+.include "${SRCTOP}/sys/conf/kern.opts.mk"
-.PATH: ${SYSDIR}/tests
+.PATH: ${SRCTOP}/sys/tests
KMOD= ktest_example
SRCS= ktest_example.c
diff --git a/sys/modules/ktest/ktest_netlink_message_writer/Makefile b/sys/modules/ktest/ktest_netlink_message_writer/Makefile
index a91c45755d0d..3f05f9b26785 100644
--- a/sys/modules/ktest/ktest_netlink_message_writer/Makefile
+++ b/sys/modules/ktest/ktest_netlink_message_writer/Makefile
@@ -1,8 +1,6 @@
PACKAGE= tests
SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
-
.PATH: ${SYSDIR}/netlink
KMOD= ktest_netlink_message_writer
diff --git a/sys/modules/miiproxy/Makefile b/sys/modules/miiproxy/Makefile
index 730bef4220cd..ab92ebe71b43 100644
--- a/sys/modules/miiproxy/Makefile
+++ b/sys/modules/miiproxy/Makefile
@@ -3,7 +3,7 @@
KMOD = miiproxy
SRCS= miiproxy.c
-SRCS+= bus_if.h mdio_if.h miibus_if.h opt_platform.h
+SRCS+= bus_if.h device_if.h mdio_if.h miibus_if.h opt_platform.h
CFLAGS+= -I${SRCTOP}/sys/dev/etherswitch
.include <bsd.kmod.mk>
diff --git a/sys/modules/netgraph/Makefile b/sys/modules/netgraph/Makefile
index 94560d5c51d7..b2d65af16e7f 100644
--- a/sys/modules/netgraph/Makefile
+++ b/sys/modules/netgraph/Makefile
@@ -1,5 +1,3 @@
-# $Whistle: Makefile,v 1.5 1999/01/24 06:48:37 archie Exp $
-
SYSDIR?=${SRCTOP}/sys
.include "${SYSDIR}/conf/kern.opts.mk"
diff --git a/sys/modules/netgraph/checksum/Makefile b/sys/modules/netgraph/checksum/Makefile
index 4e2b1f547a40..bbbc7363d045 100644
--- a/sys/modules/netgraph/checksum/Makefile
+++ b/sys/modules/netgraph/checksum/Makefile
@@ -1,6 +1,3 @@
-SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
-
KMOD= ng_checksum
SRCS= ng_checksum.c opt_inet.h opt_inet6.h
diff --git a/sys/modules/netmap/Makefile b/sys/modules/netmap/Makefile
index 17b52aec1893..8c114ac51538 100644
--- a/sys/modules/netmap/Makefile
+++ b/sys/modules/netmap/Makefile
@@ -2,9 +2,6 @@
# Compile netmap as a module, useful if you want a netmap bridge
# or loadable drivers.
-.include <bsd.own.mk> # FreeBSD 10 and earlier
-# .include "${SYSDIR}/conf/kern.opts.mk"
-
.PATH: ${.CURDIR}/../../dev/netmap
.PATH.h: ${.CURDIR}/../../net
CFLAGS += -I${.CURDIR}/../../ -D INET -D VIMAGE
diff --git a/sys/modules/opensolaris/Makefile b/sys/modules/opensolaris/Makefile
index 98f52057e45e..7e2d5f9101ad 100644
--- a/sys/modules/opensolaris/Makefile
+++ b/sys/modules/opensolaris/Makefile
@@ -1,4 +1,4 @@
-SYSDIR?= ${SRCTOP}/sys
+SYSDIR?=${SRCTOP}/sys
.PATH: ${SYSDIR}/cddl/compat/opensolaris/kern
.PATH: ${SYSDIR}/contrib/openzfs/module/os/freebsd/spl
diff --git a/sys/modules/ow/Makefile b/sys/modules/ow/Makefile
index 76fefe3e63be..7aa9d2de8183 100644
--- a/sys/modules/ow/Makefile
+++ b/sys/modules/ow/Makefile
@@ -1,6 +1,3 @@
-SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
-
SUBDIR = ow owc ow_temp
.include <bsd.subdir.mk>
diff --git a/sys/modules/qlnx/Makefile b/sys/modules/qlnx/Makefile
index 2121f9d586a6..291b681c809e 100644
--- a/sys/modules/qlnx/Makefile
+++ b/sys/modules/qlnx/Makefile
@@ -31,9 +31,6 @@
#
#
-SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
-
SUBDIR=qlnxe
SUBDIR+=qlnxev
SUBDIR+=qlnxr
diff --git a/sys/modules/rtwn/Makefile b/sys/modules/rtwn/Makefile
index 9afdd2084ecb..f15cbbe8236b 100644
--- a/sys/modules/rtwn/Makefile
+++ b/sys/modules/rtwn/Makefile
@@ -1,7 +1,5 @@
.PATH: ${SRCTOP}/sys/dev/rtwn
-
-SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
+.include "${SRCTOP}/sys/conf/kern.opts.mk"
KMOD = rtwn
SRCS = if_rtwn.c if_rtwn_tx.c if_rtwn_rx.c if_rtwn_beacon.c \
diff --git a/sys/modules/rtwn_pci/Makefile b/sys/modules/rtwn_pci/Makefile
index ce2144121e88..3fea80d7d256 100644
--- a/sys/modules/rtwn_pci/Makefile
+++ b/sys/modules/rtwn_pci/Makefile
@@ -1,7 +1,5 @@
.PATH: ${SRCTOP}/sys/dev/rtwn/pci
-
-SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
+.include "${SRCTOP}/sys/conf/kern.opts.mk"
KMOD = if_rtwn_pci
SRCS = rtwn_pci_attach.c rtwn_pci_reg.c rtwn_pci_rx.c rtwn_pci_tx.c \
diff --git a/sys/modules/rtwn_usb/Makefile b/sys/modules/rtwn_usb/Makefile
index 16899b8a8c49..6a73276d088c 100644
--- a/sys/modules/rtwn_usb/Makefile
+++ b/sys/modules/rtwn_usb/Makefile
@@ -1,7 +1,5 @@
.PATH: ${SRCTOP}/sys/dev/rtwn/usb
-
-SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
+.include "${SRCTOP}/sys/conf/kern.opts.mk"
KMOD = if_rtwn_usb
SRCS = rtwn_usb_attach.c rtwn_usb_ep.c rtwn_usb_reg.c rtwn_usb_rx.c \
diff --git a/sys/modules/sound/driver/Makefile b/sys/modules/sound/driver/Makefile
index ff9499fdf841..02703d4b591a 100644
--- a/sys/modules/sound/driver/Makefile
+++ b/sys/modules/sound/driver/Makefile
@@ -1,5 +1,4 @@
-SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
+.include "${SRCTOP}/sys/conf/kern.opts.mk"
# Modules that include binary-only blobs of microcode should be selectable by
# MK_SOURCELESS_UCODE option (see below).
diff --git a/sys/modules/sound/sound/Makefile b/sys/modules/sound/sound/Makefile
index f3978e9bd9cc..169b1a2730ec 100644
--- a/sys/modules/sound/sound/Makefile
+++ b/sys/modules/sound/sound/Makefile
@@ -1,5 +1,4 @@
SYSDIR?=${SRCTOP}/sys
-
.PATH: ${SYSDIR}/dev/sound
.PATH: ${SYSDIR}/dev/sound/pcm
.PATH: ${SYSDIR}/dev/sound/midi
diff --git a/sys/modules/tests/fib_lookup/Makefile b/sys/modules/tests/fib_lookup/Makefile
index 7d6198396911..b78d4309f145 100644
--- a/sys/modules/tests/fib_lookup/Makefile
+++ b/sys/modules/tests/fib_lookup/Makefile
@@ -1,6 +1,3 @@
-SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
-
.PATH: ${SYSDIR}/tests/fib_lookup
KMOD= test_lookup
diff --git a/sys/modules/vnic/Makefile b/sys/modules/vnic/Makefile
index 7b975bfebe81..53e208328159 100644
--- a/sys/modules/vnic/Makefile
+++ b/sys/modules/vnic/Makefile
@@ -1,6 +1,3 @@
-SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
-
CFLAGS+= -DFDT
SUBDIR = mrmlbus thunder_mdio thunder_bgx vnicpf vnicvf
diff --git a/sys/modules/vnic/mrmlbus/Makefile b/sys/modules/vnic/mrmlbus/Makefile
index a3581b7a79a5..a8fe9e5474e1 100644
--- a/sys/modules/vnic/mrmlbus/Makefile
+++ b/sys/modules/vnic/mrmlbus/Makefile
@@ -1,6 +1,3 @@
-SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
-
S= ${SRCTOP}/sys
.PATH: $S/dev/vnic
diff --git a/sys/modules/vnic/thunder_bgx/Makefile b/sys/modules/vnic/thunder_bgx/Makefile
index 90df4b25df90..bf46c3194493 100644
--- a/sys/modules/vnic/thunder_bgx/Makefile
+++ b/sys/modules/vnic/thunder_bgx/Makefile
@@ -1,6 +1,3 @@
-SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
-
S= ${SRCTOP}/sys
.PATH: $S/dev/vnic
diff --git a/sys/modules/vnic/thunder_mdio/Makefile b/sys/modules/vnic/thunder_mdio/Makefile
index 37032516f3ca..07cc583bfaf8 100644
--- a/sys/modules/vnic/thunder_mdio/Makefile
+++ b/sys/modules/vnic/thunder_mdio/Makefile
@@ -1,6 +1,3 @@
-SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
-
S= ${SRCTOP}/sys
.PATH: $S/dev/vnic
diff --git a/sys/modules/vnic/vnicpf/Makefile b/sys/modules/vnic/vnicpf/Makefile
index 37cd29e6fdd8..3cd64d08a788 100644
--- a/sys/modules/vnic/vnicpf/Makefile
+++ b/sys/modules/vnic/vnicpf/Makefile
@@ -1,6 +1,3 @@
-SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
-
S= ${SRCTOP}/sys
.PATH: $S/dev/vnic
diff --git a/sys/modules/vnic/vnicvf/Makefile b/sys/modules/vnic/vnicvf/Makefile
index c6ffaaa2c302..da938b7fd073 100644
--- a/sys/modules/vnic/vnicvf/Makefile
+++ b/sys/modules/vnic/vnicvf/Makefile
@@ -1,6 +1,3 @@
-SYSDIR?=${SRCTOP}/sys
-.include "${SYSDIR}/conf/kern.opts.mk"
-
S= ${SRCTOP}/sys
.PATH: $S/dev/vnic
diff --git a/sys/netpfil/ipfw/ip_dn_io.c b/sys/netpfil/ipfw/ip_dn_io.c
index 03116cb0641c..3a8de2b2bfee 100644
--- a/sys/netpfil/ipfw/ip_dn_io.c
+++ b/sys/netpfil/ipfw/ip_dn_io.c
@@ -43,6 +43,7 @@
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/rwlock.h>
+#include <sys/sdt.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/sysctl.h>
@@ -70,6 +71,9 @@
#endif
#include <netpfil/ipfw/dn_sched.h>
+SDT_PROVIDER_DEFINE(dummynet);
+SDT_PROBE_DEFINE2(dummynet, , , drop, "struct mbuf *", "struct dn_queue *");
+
/*
* We keep a private variable for the simulation time, but we could
* probably use an existing one ("softticks" in sys/kern/kern_timeout.c)
@@ -545,6 +549,7 @@ dn_enqueue(struct dn_queue *q, struct mbuf* m, int drop)
drop:
V_dn_cfg.io_pkt_drop++;
+ SDT_PROBE2(dummynet, , , drop, m, q);
q->ni.drops++;
ni->drops++;
FREE_PKT(m);
@@ -1001,6 +1006,7 @@ done:
dropit:
V_dn_cfg.io_pkt_drop++;
+ SDT_PROBE2(dummynet, , , drop, m, q);
DN_BH_WUNLOCK();
if (m)
FREE_PKT(m);
diff --git a/sys/riscv/include/vmm.h b/sys/riscv/include/vmm.h
index de7119dd534a..bc00474ed0fd 100644
--- a/sys/riscv/include/vmm.h
+++ b/sys/riscv/include/vmm.h
@@ -123,6 +123,29 @@ struct vm_eventinfo {
int *iptr; /* reqidle cookie */
};
+#define DECLARE_VMMOPS_FUNC(ret_type, opname, args) \
+ ret_type vmmops_##opname args
+
+DECLARE_VMMOPS_FUNC(int, modinit, (void));
+DECLARE_VMMOPS_FUNC(int, modcleanup, (void));
+DECLARE_VMMOPS_FUNC(void *, init, (struct vm *vm, struct pmap *pmap));
+DECLARE_VMMOPS_FUNC(int, gla2gpa, (void *vcpui, struct vm_guest_paging *paging,
+ uint64_t gla, int prot, uint64_t *gpa, int *is_fault));
+DECLARE_VMMOPS_FUNC(int, run, (void *vcpui, register_t pc, struct pmap *pmap,
+ struct vm_eventinfo *info));
+DECLARE_VMMOPS_FUNC(void, cleanup, (void *vmi));
+DECLARE_VMMOPS_FUNC(void *, vcpu_init, (void *vmi, struct vcpu *vcpu,
+ int vcpu_id));
+DECLARE_VMMOPS_FUNC(void, vcpu_cleanup, (void *vcpui));
+DECLARE_VMMOPS_FUNC(int, exception, (void *vcpui, uint64_t scause));
+DECLARE_VMMOPS_FUNC(int, getreg, (void *vcpui, int num, uint64_t *retval));
+DECLARE_VMMOPS_FUNC(int, setreg, (void *vcpui, int num, uint64_t val));
+DECLARE_VMMOPS_FUNC(int, getcap, (void *vcpui, int num, int *retval));
+DECLARE_VMMOPS_FUNC(int, setcap, (void *vcpui, int num, int val));
+DECLARE_VMMOPS_FUNC(struct vmspace *, vmspace_alloc, (vm_offset_t min,
+ vm_offset_t max));
+DECLARE_VMMOPS_FUNC(void, vmspace_free, (struct vmspace *vmspace));
+
int vm_create(const char *name, struct vm **retvm);
struct vcpu *vm_alloc_vcpu(struct vm *vm, int vcpuid);
void vm_disable_vcpu_creation(struct vm *vm);
@@ -212,7 +235,6 @@ vcpu_should_yield(struct vcpu *vcpu)
void *vcpu_stats(struct vcpu *vcpu);
void vcpu_notify_event(struct vcpu *vcpu);
-struct vmspace *vm_vmspace(struct vm *vm);
struct vm_mem *vm_mem(struct vm *vm);
enum vm_reg_name vm_segment_name(int seg_encoding);
diff --git a/sys/riscv/vmm/riscv.h b/sys/riscv/vmm/riscv.h
index 870d0d6c5cd1..917a333520ed 100644
--- a/sys/riscv/vmm/riscv.h
+++ b/sys/riscv/vmm/riscv.h
@@ -122,29 +122,6 @@ struct hyptrap {
uint64_t htinst;
};
-#define DEFINE_VMMOPS_IFUNC(ret_type, opname, args) \
- ret_type vmmops_##opname args;
-
-DEFINE_VMMOPS_IFUNC(int, modinit, (void))
-DEFINE_VMMOPS_IFUNC(int, modcleanup, (void))
-DEFINE_VMMOPS_IFUNC(void *, init, (struct vm *vm, struct pmap *pmap))
-DEFINE_VMMOPS_IFUNC(int, gla2gpa, (void *vcpui, struct vm_guest_paging *paging,
- uint64_t gla, int prot, uint64_t *gpa, int *is_fault))
-DEFINE_VMMOPS_IFUNC(int, run, (void *vcpui, register_t pc, struct pmap *pmap,
- struct vm_eventinfo *info))
-DEFINE_VMMOPS_IFUNC(void, cleanup, (void *vmi))
-DEFINE_VMMOPS_IFUNC(void *, vcpu_init, (void *vmi, struct vcpu *vcpu,
- int vcpu_id))
-DEFINE_VMMOPS_IFUNC(void, vcpu_cleanup, (void *vcpui))
-DEFINE_VMMOPS_IFUNC(int, exception, (void *vcpui, uint64_t scause))
-DEFINE_VMMOPS_IFUNC(int, getreg, (void *vcpui, int num, uint64_t *retval))
-DEFINE_VMMOPS_IFUNC(int, setreg, (void *vcpui, int num, uint64_t val))
-DEFINE_VMMOPS_IFUNC(int, getcap, (void *vcpui, int num, int *retval))
-DEFINE_VMMOPS_IFUNC(int, setcap, (void *vcpui, int num, int val))
-DEFINE_VMMOPS_IFUNC(struct vmspace *, vmspace_alloc, (vm_offset_t min,
- vm_offset_t max))
-DEFINE_VMMOPS_IFUNC(void, vmspace_free, (struct vmspace *vmspace))
-
#define dprintf(fmt, ...)
struct hypctx *riscv_get_active_vcpu(void);
diff --git a/sys/riscv/vmm/vmm.c b/sys/riscv/vmm/vmm.c
index ec4514f70fa6..790dcc576507 100644
--- a/sys/riscv/vmm/vmm.c
+++ b/sys/riscv/vmm/vmm.c
@@ -92,7 +92,6 @@ struct vcpu {
struct fpreg *guestfpu; /* (a,i) guest fpu state */
};
-#define vcpu_lock_initialized(v) mtx_initialized(&((v)->mtx))
#define vcpu_lock_init(v) mtx_init(&((v)->mtx), "vcpu lock", 0, MTX_SPIN)
#define vcpu_lock_destroy(v) mtx_destroy(&((v)->mtx))
#define vcpu_lock(v) mtx_lock_spin(&((v)->mtx))
@@ -121,7 +120,6 @@ struct vm {
bool dying; /* (o) is dying */
volatile cpuset_t suspended_cpus; /* (i) suspended vcpus */
volatile cpuset_t halted_cpus; /* (x) cpus in a hard halt */
- struct vmspace *vmspace; /* (o) guest's address space */
struct vm_mem mem; /* (i) [m+v] guest memory */
char name[VM_MAX_NAMELEN]; /* (o) virtual machine name */
struct vcpu **vcpu; /* (i) guest vcpus */
@@ -174,6 +172,7 @@ vcpu_cleanup(struct vcpu *vcpu, bool destroy)
vmm_stat_free(vcpu->stats);
fpu_save_area_free(vcpu->guestfpu);
vcpu_lock_destroy(vcpu);
+ free(vcpu, M_VMM);
}
}
@@ -285,7 +284,7 @@ vm_init(struct vm *vm, bool create)
{
int i;
- vm->cookie = vmmops_init(vm, vmspace_pmap(vm->vmspace));
+ vm->cookie = vmmops_init(vm, vmspace_pmap(vm_vmspace(vm)));
MPASS(vm->cookie != NULL);
CPU_ZERO(&vm->active_cpus);
@@ -362,7 +361,7 @@ int
vm_create(const char *name, struct vm **retvm)
{
struct vm *vm;
- struct vmspace *vmspace;
+ int error;
/*
* If vmm.ko could not be successfully initialized then don't attempt
@@ -374,14 +373,13 @@ vm_create(const char *name, struct vm **retvm)
if (name == NULL || strlen(name) >= VM_MAX_NAMELEN)
return (EINVAL);
- vmspace = vmmops_vmspace_alloc(0, 1ul << 39);
- if (vmspace == NULL)
- return (ENOMEM);
-
vm = malloc(sizeof(struct vm), M_VMM, M_WAITOK | M_ZERO);
+ error = vm_mem_init(&vm->mem, 0, 1ul << 39);
+ if (error != 0) {
+ free(vm, M_VMM);
+ return (error);
+ }
strcpy(vm->name, name);
- vm->vmspace = vmspace;
- vm_mem_init(&vm->mem);
sx_init(&vm->vcpus_init_lock, "vm vcpus");
vm->sockets = 1;
@@ -450,11 +448,6 @@ vm_cleanup(struct vm *vm, bool destroy)
if (destroy) {
vm_mem_destroy(vm);
- vmmops_vmspace_free(vm->vmspace);
- vm->vmspace = NULL;
-
- for (i = 0; i < vm->maxcpus; i++)
- free(vm->vcpu[i], M_VMM);
free(vm->vcpu, M_VMM);
sx_destroy(&vm->vcpus_init_lock);
}
@@ -760,12 +753,6 @@ vcpu_notify_event(struct vcpu *vcpu)
vcpu_unlock(vcpu);
}
-struct vmspace *
-vm_vmspace(struct vm *vm)
-{
- return (vm->vmspace);
-}
-
struct vm_mem *
vm_mem(struct vm *vm)
{
@@ -1084,7 +1071,7 @@ vm_handle_paging(struct vcpu *vcpu, bool *retu)
vm = vcpu->vm;
vme = &vcpu->exitinfo;
- pmap = vmspace_pmap(vm->vmspace);
+ pmap = vmspace_pmap(vm_vmspace(vm));
addr = (vme->htval << 2) & ~(PAGE_SIZE - 1);
dprintf("%s: %lx\n", __func__, addr);
@@ -1107,7 +1094,7 @@ vm_handle_paging(struct vcpu *vcpu, bool *retu)
if (pmap_fault(pmap, addr, ftype))
return (0);
- map = &vm->vmspace->vm_map;
+ map = &vm_vmspace(vm)->vm_map;
rv = vm_fault(map, addr, ftype, VM_FAULT_NORMAL, NULL);
if (rv != KERN_SUCCESS) {
printf("%s: vm_fault failed, addr %lx, ftype %d, err %d\n",
@@ -1189,7 +1176,7 @@ vm_run(struct vcpu *vcpu)
if (CPU_ISSET(vcpuid, &vm->suspended_cpus))
return (EINVAL);
- pmap = vmspace_pmap(vm->vmspace);
+ pmap = vmspace_pmap(vm_vmspace(vm));
vme = &vcpu->exitinfo;
evinfo.rptr = NULL;
evinfo.sptr = &vm->suspend;
diff --git a/sys/sys/user.h b/sys/sys/user.h
index 3183f0792256..1704bc089d85 100644
--- a/sys/sys/user.h
+++ b/sys/sys/user.h
@@ -617,7 +617,8 @@ struct kinfo_vmobject {
} kvo_type_spec; /* Type-specific union */
uint64_t kvo_me; /* Uniq handle for anon obj */
uint64_t kvo_laundry; /* Number of laundry pages. */
- uint64_t _kvo_qspare[5];
+ uint64_t kvo_wired; /* Number of wired pages. */
+ uint64_t _kvo_qspare[4];
uint32_t kvo_swapped; /* Number of swapped pages */
uint32_t kvo_flags;
uint32_t _kvo_ispare[6];
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index 6d9ea8bf9d93..5b4517d2bf0c 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -2522,15 +2522,13 @@ vm_object_list_handler(struct sysctl_req *req, bool swap_only)
continue;
}
mtx_unlock(&vm_object_list_mtx);
+
+ memset(kvo, 0, sizeof(*kvo));
kvo->kvo_size = ptoa(obj->size);
kvo->kvo_resident = obj->resident_page_count;
kvo->kvo_ref_count = obj->ref_count;
kvo->kvo_shadow_count = atomic_load_int(&obj->shadow_count);
kvo->kvo_memattr = obj->memattr;
- kvo->kvo_active = 0;
- kvo->kvo_inactive = 0;
- kvo->kvo_laundry = 0;
- kvo->kvo_flags = 0;
if (!swap_only) {
vm_page_iter_init(&pages, obj);
VM_RADIX_FOREACH(m, &pages) {
@@ -2549,12 +2547,12 @@ vm_object_list_handler(struct sysctl_req *req, bool swap_only)
kvo->kvo_inactive++;
else if (vm_page_in_laundry(m))
kvo->kvo_laundry++;
+
+ if (vm_page_wired(m))
+ kvo->kvo_wired++;
}
}
- kvo->kvo_vn_fileid = 0;
- kvo->kvo_vn_fsid = 0;
- kvo->kvo_vn_fsid_freebsd11 = 0;
freepath = NULL;
fullpath = "";
vp = NULL;
diff --git a/targets/pseudo/userland/Makefile.depend b/targets/pseudo/userland/Makefile.depend
index 5f72461ab12e..e21d7dd70eb7 100644
--- a/targets/pseudo/userland/Makefile.depend
+++ b/targets/pseudo/userland/Makefile.depend
@@ -806,6 +806,12 @@ DIRDEPS+= \
usr.sbin/blacklistd
.endif
+.if ${MK_BLOCKLIST_SUPPORT} != "no"
+DIRDEPS+= \
+ usr.sbin/blocklistctl \
+ usr.sbin/blocklistd
+.endif
+
.if ${MK_CXGBETOOL} != "no"
DIRDEPS+= usr.sbin/cxgbetool
.endif
diff --git a/targets/pseudo/userland/lib/Makefile.depend b/targets/pseudo/userland/lib/Makefile.depend
index 8e1b0282be48..63c7e69719c2 100644
--- a/targets/pseudo/userland/lib/Makefile.depend
+++ b/targets/pseudo/userland/lib/Makefile.depend
@@ -255,6 +255,10 @@ DIRDEPS+= \
DIRDEPS+= lib/libblacklist
.endif
+.if ${MK_BLOCKLIST_SUPPORT} != "no"
+DIRDEPS+= lib/libblocklist
+.endif
+
.if ${MK_ZFS} != "no"
DIRDEPS+= cddl/lib/libzutil
.endif
diff --git a/targets/pseudo/userland/libexec/Makefile.depend b/targets/pseudo/userland/libexec/Makefile.depend
index 4a6d72f914e3..9e5eec3f0c81 100644
--- a/targets/pseudo/userland/libexec/Makefile.depend
+++ b/targets/pseudo/userland/libexec/Makefile.depend
@@ -38,8 +38,8 @@ DIRDEPS = \
libexec/ypxfr \
-.if ${MK_BLACKLIST_SUPPORT} != "no"
-DIRDEPS+= libexec/blacklistd-helper
+.if ${MK_BLOCKLIST_SUPPORT} != "no"
+DIRDEPS+= libexec/blocklistd-helper
.endif
.if ${MK_DMAGENT} != "no"
diff --git a/tests/sys/netpfil/pf/ether.sh b/tests/sys/netpfil/pf/ether.sh
index f0fdce50a7d3..f15dff06f9cd 100644
--- a/tests/sys/netpfil/pf/ether.sh
+++ b/tests/sys/netpfil/pf/ether.sh
@@ -287,6 +287,7 @@ captive_body()
# Run the echo server only on the gw, so we know we've redirectly
# correctly if we get an echo message.
jexec gw /usr/sbin/inetd -p ${PWD}/echo_inetd.pid $(atf_get_srcdir)/echo_inetd.conf
+ sleep 1
# Confirm that we're getting redirected
atf_check -s exit:0 -o match:"^foo$" -x "echo foo | nc -N 198.51.100.2 7"
@@ -305,6 +306,7 @@ captive_body()
# Start a server in srv
jexec srv /usr/sbin/inetd -p ${PWD}/echo_inetd.pid $(atf_get_srcdir)/echo_inetd.conf
+ sleep 1
# And now we can talk to that one.
atf_check -s exit:0 -o match:"^foo$" -x "echo foo | nc -N 198.51.100.2 7"
@@ -364,6 +366,7 @@ captive_long_body()
jexec gw /usr/sbin/inetd -p ${PWD}/gw.pid $(atf_get_srcdir)/echo_inetd.conf
jexec srv /usr/sbin/inetd -p ${PWD}/srv.pid $(atf_get_srcdir)/daytime_inetd.conf
+ sleep p1
echo foo | nc -N 198.51.100.2 13
diff --git a/tests/sys/netpfil/pf/nat.sh b/tests/sys/netpfil/pf/nat.sh
index e55f46418221..1ef87cee3598 100644
--- a/tests/sys/netpfil/pf/nat.sh
+++ b/tests/sys/netpfil/pf/nat.sh
@@ -55,6 +55,9 @@ exhaust_body()
jexec echo ifconfig ${epair_echo}b 198.51.100.2/24 up
jexec echo /usr/sbin/inetd -p ${PWD}/inetd-echo.pid $(atf_get_srcdir)/echo_inetd.conf
+ # Disable checksum offload on one of the interfaces to ensure pf handles that
+ jexec nat ifconfig ${epair_nat}a -txcsum
+
# Enable pf!
jexec nat pfctl -e
pft_set_rules nat \
@@ -474,6 +477,7 @@ no_addrs_random_cleanup()
pft_cleanup
}
+atf_test_case "nat_pass" "cleanup"
nat_pass_head()
{
atf_set descr 'IPv4 NAT on pass rule'
@@ -505,6 +509,7 @@ nat_pass_cleanup()
pft_cleanup
}
+atf_test_case "nat_match" "cleanup"
nat_match_head()
{
atf_set descr 'IPv4 NAT on match rule'
@@ -644,6 +649,7 @@ map_e_pass_cleanup()
pft_cleanup
}
+atf_test_case "binat_compat" "cleanup"
binat_compat_head()
{
atf_set descr 'IPv4 BINAT with nat ruleset'
@@ -710,6 +716,7 @@ binat_compat_cleanup()
kill $(cat ${PWD}/inetd_tester.pid)
}
+atf_test_case "binat_match" "cleanup"
binat_match_head()
{
atf_set descr 'IPv4 BINAT with nat ruleset'
diff --git a/tests/sys/netpfil/pf/rules_counter.sh b/tests/sys/netpfil/pf/rules_counter.sh
index 98f96a7adca1..e80a46e9d6c6 100644
--- a/tests/sys/netpfil/pf/rules_counter.sh
+++ b/tests/sys/netpfil/pf/rules_counter.sh
@@ -153,6 +153,7 @@ atf_test_case "4G" "cleanup"
{
atf_set descr 'Test keepcounter for values above 32 bits'
atf_set require.user root
+ atf_set timeout 900
}
4G_body()
diff --git a/tests/sys/netpfil/pf/syncookie.sh b/tests/sys/netpfil/pf/syncookie.sh
index fad90f3b2618..598ac17c67f5 100644
--- a/tests/sys/netpfil/pf/syncookie.sh
+++ b/tests/sys/netpfil/pf/syncookie.sh
@@ -253,6 +253,9 @@ Creativity, no.
__EOF__
nc -l $addr $port >out &
+ # Give the background nc time to start
+ sleep 1
+
atf_check nc -N $addr $port < in
atf_check -o file:in cat out
diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc
index 13d7703148d2..7cf742616e63 100644
--- a/tools/build/mk/OptionalObsoleteFiles.inc
+++ b/tools/build/mk/OptionalObsoleteFiles.inc
@@ -161,7 +161,26 @@ OLD_FILES+=usr/share/man/man8/bhyveload.8.gz
OLD_DIRS+=usr/share/examples/bhyve
.endif
-.if ${MK_BLACKLIST} == no
+.if ${MK_BLOCKLIST} == no
+OLD_FILES+=etc/blocklistd.conf
+OLD_FILES+=etc/rc.d/blocklistd
+OLD_FILES+=usr/include/blocklist.h
+OLD_FILES+=usr/lib/libblocklist.a
+OLD_FILES+=usr/lib/libblocklist_p.a
+OLD_FILES+=usr/lib/libblocklist.so
+OLD_LIBS+=usr/lib/libblocklist.so.0
+OLD_FILES+=usr/libexec/blocklistd-helper
+OLD_FILES+=usr/sbin/blocklistctl
+OLD_FILES+=usr/sbin/blocklistd
+OLD_FILES+=usr/share/man/man3/blocklist.3.gz
+OLD_FILES+=usr/share/man/man3/blocklist_close.3.gz
+OLD_FILES+=usr/share/man/man3/blocklist_open.3.gz
+OLD_FILES+=usr/share/man/man3/blocklist_r.3.gz
+OLD_FILES+=usr/share/man/man3/blocklist_sa.3.gz
+OLD_FILES+=usr/share/man/man3/blocklist_sa_r.3.gz
+OLD_FILES+=usr/share/man/man5/blocklistd.conf.5.gz
+OLD_FILES+=usr/share/man/man8/blocklistctl.8.gz
+OLD_FILES+=usr/share/man/man8/blocklistd.8.gz
OLD_FILES+=etc/blacklistd.conf
OLD_FILES+=etc/rc.d/blacklistd
OLD_FILES+=usr/include/blacklist.h
diff --git a/tools/build/options/WITHOUT_BLACKLIST b/tools/build/options/WITHOUT_BLACKLIST
index c54c83f27553..df9c9a41227f 100644
--- a/tools/build/options/WITHOUT_BLACKLIST
+++ b/tools/build/options/WITHOUT_BLACKLIST
@@ -1,4 +1,2 @@
-Set this if you do not want to build
-.Xr blacklistd 8
-and
-.Xr blacklistctl 8 .
+This option has been renamed to
+.Va WITHOUT_BLOCKLIST .
diff --git a/tools/build/options/WITHOUT_BLACKLIST_SUPPORT b/tools/build/options/WITHOUT_BLACKLIST_SUPPORT
index ff1c2c43d595..cd484727d636 100644
--- a/tools/build/options/WITHOUT_BLACKLIST_SUPPORT
+++ b/tools/build/options/WITHOUT_BLACKLIST_SUPPORT
@@ -1,6 +1,2 @@
-Build some programs without
-.Xr libblacklist 3
-support, like
-.Xr fingerd 8
-and
-.Xr sshd 8 .
+This option has been renamed to
+.Va WITHOUT_BLOCKLIST_SUPPORT .
diff --git a/tools/build/options/WITHOUT_BLOCKLIST b/tools/build/options/WITHOUT_BLOCKLIST
new file mode 100644
index 000000000000..c456a98c672f
--- /dev/null
+++ b/tools/build/options/WITHOUT_BLOCKLIST
@@ -0,0 +1,4 @@
+Set this if you do not want to build
+.Xr blocklistd 8
+and
+.Xr blocklistctl 8 .
diff --git a/tools/build/options/WITHOUT_BLOCKLIST_SUPPORT b/tools/build/options/WITHOUT_BLOCKLIST_SUPPORT
new file mode 100644
index 000000000000..f06ebc6e4263
--- /dev/null
+++ b/tools/build/options/WITHOUT_BLOCKLIST_SUPPORT
@@ -0,0 +1,6 @@
+Build some programs without
+.Xr libblocklist 3
+support, like
+.Xr fingerd 8
+and
+.Xr sshd 8 .
diff --git a/usr.bin/sockstat/main.c b/usr.bin/sockstat/main.c
index a917672120d5..7fedfd5b8724 100644
--- a/usr.bin/sockstat/main.c
+++ b/usr.bin/sockstat/main.c
@@ -103,6 +103,7 @@ static bool opt_u; /* Show Unix domain sockets */
static u_int opt_v; /* Verbose mode */
static bool opt_w; /* Automatically size the columns */
static bool is_xo_style_encoding;
+static bool show_path_state = false;
/*
* Default protocols to use if no -P was defined.
@@ -584,6 +585,7 @@ gather_sctp(void)
!(local_all_loopback ||
foreign_all_loopback))) {
RB_INSERT(socks_t, &socks, sock);
+ show_path_state = true;
} else {
free_socket(sock);
}
@@ -1485,7 +1487,7 @@ display_sock(struct sock *s, struct col_widths *cw, char *buf, size_t bufsize)
} else if (!is_xo_style_encoding)
xo_emit(" {:encaps/%*s}", cw->encaps, "??");
}
- if (opt_s) {
+ if (opt_s && show_path_state) {
if (faddr != NULL &&
s->proto == IPPROTO_SCTP &&
s->state != SCTP_CLOSED &&
@@ -1545,18 +1547,30 @@ display_sock(struct sock *s, struct col_widths *cw, char *buf, size_t bufsize)
else if (!is_xo_style_encoding)
xo_emit(" {:cc/%-*s}", cw->cc, "??");
}
+ } else if (!is_xo_style_encoding) {
+ if (opt_s)
+ xo_emit(" {:conn-state/%-*s}", cw->conn_state,
+ "??");
+ if (opt_b)
+ xo_emit(" {:bblog-state/%-*s}", cw->bblog_state,
+ "??");
+ if (opt_S)
+ xo_emit(" {:stack/%-*s}", cw->stack, "??");
+ if (opt_C)
+ xo_emit(" {:cc/%-*s}", cw->cc, "??");
}
if (laddr != NULL)
laddr = laddr->next;
if (faddr != NULL)
faddr = faddr->next;
+ xo_emit("\n");
if (!is_xo_style_encoding && (laddr != NULL || faddr != NULL))
xo_emit("{:user/%-*s} {:command/%-*s} {:pid/%*s}"
- " {:fd/%*s}", cw->user, "??", cw->command, "??",
- cw->pid, "??", cw->fd, "??");
+ " {:fd/%*s} {:proto/%-*s}", cw->user, "??",
+ cw->command, "??", cw->pid, "??", cw->fd, "??",
+ cw->proto, "??");
first = false;
}
- xo_emit("\n");
}
static void
@@ -1620,7 +1634,9 @@ display(void)
if (opt_U)
xo_emit(" {T:/%*s}", cw.encaps, "ENCAPS");
if (opt_s) {
- xo_emit(" {T:/%-*s}", cw.path_state, "PATH STATE");
+ if (show_path_state)
+ xo_emit(" {T:/%-*s}", cw.path_state,
+ "PATH STATE");
xo_emit(" {T:/%-*s}", cw.conn_state, "CONN STATE");
}
if (opt_b)
diff --git a/usr.bin/sockstat/sockstat.1 b/usr.bin/sockstat/sockstat.1
index dabb3042bfd4..d14eb967ad0f 100644
--- a/usr.bin/sockstat/sockstat.1
+++ b/usr.bin/sockstat/sockstat.1
@@ -25,7 +25,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd October 7, 2025
+.Dd October 9, 2025
.Dt SOCKSTAT 1
.Os
.Sh NAME
@@ -205,6 +205,7 @@ is specified (only for SCTP or TCP).
The path state if
.Fl s
is specified (only for SCTP).
+This column is only shown when there is at least one path state shown.
.It Li CONN STATE
The connection state if
.Fl s
diff --git a/usr.bin/sockstat/tests/Makefile b/usr.bin/sockstat/tests/Makefile
index 9971bca2d474..5412e9d842aa 100644
--- a/usr.bin/sockstat/tests/Makefile
+++ b/usr.bin/sockstat/tests/Makefile
@@ -1,5 +1,6 @@
ATF_TESTS_C+= sockstat_test
-SRCS.sockstat_test= sockstat_test.c ../sockstat.c
+SRCS.sockstat_test= sockstat_test.c sockstat.c
+.PATH: ${.CURDIR:H}
LIBADD= xo
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c
index 7a7c83fe1ac8..9b4d3a25ee07 100644
--- a/usr.bin/vmstat/vmstat.c
+++ b/usr.bin/vmstat/vmstat.c
@@ -1465,6 +1465,7 @@ display_object(struct kinfo_vmobject *kvo)
xo_emit("{:active/%5ju} ", (uintmax_t)kvo->kvo_active);
xo_emit("{:inactive/%5ju} ", (uintmax_t)kvo->kvo_inactive);
xo_emit("{:laundry/%5ju} ", (uintmax_t)kvo->kvo_laundry);
+ xo_emit("{:wired/%5ju} ", (uintmax_t)kvo->kvo_wired);
xo_emit("{:refcount/%3d} ", kvo->kvo_ref_count);
xo_emit("{:shadowcount/%3d} ", kvo->kvo_shadow_count);
@@ -1568,7 +1569,8 @@ doobjstat(void)
return;
}
xo_emit("{T:RES/%5s} {T:ACT/%5s} {T:INACT/%5s} {T:LAUND/%5s} "
- "{T:REF/%3s} {T:SHD/%3s} {T:CM/%2s} {T:TP/%3s} {T:PATH/%s}\n");
+ "{T:WIRED/%5s} {T:REF/%3s} {T:SHD/%3s} {T:CM/%2s} {T:TP/%3s} "
+ "{T:PATH/%s}\n");
xo_open_list("object");
for (i = 0; i < cnt; i++)
display_object(&kvo[i]);
diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile
index 3c5fd0973a43..44679ca290a5 100644
--- a/usr.sbin/Makefile
+++ b/usr.sbin/Makefile
@@ -121,6 +121,8 @@ SUBDIR.${MK_AUTHPF}+= authpf
SUBDIR.${MK_AUTOFS}+= autofs
SUBDIR.${MK_BLACKLIST}+= blacklistctl
SUBDIR.${MK_BLACKLIST}+= blacklistd
+SUBDIR.${MK_BLOCKLIST}+= blocklistctl
+SUBDIR.${MK_BLOCKLIST}+= blocklistd
SUBDIR.${MK_BLUETOOTH}+= bluetooth
SUBDIR.${MK_BOOTPARAMD}+= bootparamd
SUBDIR.${MK_BSDINSTALL}+= bsdinstall
diff --git a/usr.sbin/acpi/acpidump/acpi.c b/usr.sbin/acpi/acpidump/acpi.c
index 63613d5a4707..026795118832 100644
--- a/usr.sbin/acpi/acpidump/acpi.c
+++ b/usr.sbin/acpi/acpidump/acpi.c
@@ -1913,16 +1913,19 @@ acpi_handle_ivrs_ivmd_type(ACPI_IVRS_MEMORY *addr)
static void
acpi_handle_ivrs_ivmd(ACPI_IVRS_MEMORY *addr)
{
+ UINT16 x16;
+
printf("\tMem Type=%#x(%s) ",
addr->Header.Type, acpi_handle_ivrs_ivmd_type(addr));
switch (addr->Header.Type) {
case ACPI_IVRS_TYPE_MEMORY2:
- printf("Id=%#06x PCISeg=%#x ", addr->Header.DeviceId,
- *(UINT16 *)&addr->Reserved);
+ memcpy(&x16, &addr->Reserved, sizeof(x16));
+ printf("Id=%#06x PCISeg=%#x ", addr->Header.DeviceId, x16);
break;
case ACPI_IVRS_TYPE_MEMORY3:
+ memcpy(&x16, &addr->Reserved, sizeof(x16));
printf("Id=%#06x-%#06x PCISeg=%#x", addr->Header.DeviceId,
- addr->AuxData, *(UINT16 *)&addr->Reserved);
+ addr->AuxData, x16);
break;
}
printf("Start=%#18jx Length=%#jx Flags=",
diff --git a/usr.sbin/blacklistctl/Makefile b/usr.sbin/blacklistctl/Makefile
index 7bdff4158bb4..41c5f44b072b 100644
--- a/usr.sbin/blacklistctl/Makefile
+++ b/usr.sbin/blacklistctl/Makefile
@@ -4,19 +4,20 @@ BLOCKLIST_DIR=${SRCTOP}/contrib/blocklist
PACKAGE= blocklist
PROG= blacklistctl
-SRCS= blacklistctl.c conf.c state.c support.c internal.c \
+SRCS= blacklistctl.c conf.c state.c support.c old_internal.c \
sockaddr_snprintf.c pidfile.c strtoi.c popenve.c
MAN= blacklistctl.8
LDFLAGS+=-L${LIBBLACKLISTDIR}
-LIBADD+= blacklist util
+LIBADD+= blocklist util
CFLAGS+=-I${BLOCKLIST_DIR}/include -I${BLOCKLIST_DIR}/port \
+ -D_PATH_BLCONF=\"/etc/blacklistd.conf\" \
-D_PATH_BLCONTROL=\"/usr/libexec/blacklistd-helper\" \
-DHAVE_CONFIG_H -DHAVE_DB_H -DHAVE_LIBUTIL_H \
-DHAVE_CLOCK_GETTIME -DHAVE_FGETLN -DHAVE_FPARSELN \
-DHAVE_GETPROGNAME -DHAVE_STRLCAT -DHAVE_STRLCPY \
- -DHAVE_STRUCT_SOCKADDR_SA_LEN
+ -DHAVE_STRUCT_SOCKADDR_SA_LEN -DHAVE_SYS_CDEFS_H
# CFLAGS+= -D_REENTRANT
.include <bsd.prog.mk>
diff --git a/usr.sbin/blacklistd/Makefile b/usr.sbin/blacklistd/Makefile
index e0a3ddd80881..490b12d46968 100644
--- a/usr.sbin/blacklistd/Makefile
+++ b/usr.sbin/blacklistd/Makefile
@@ -5,19 +5,20 @@ PACKAGE= blocklist
CONFS= blacklistd.conf
PROG= blacklistd
-SRCS= blacklistd.c conf.c run.c state.c support.c internal.c \
- sockaddr_snprintf.c pidfile.c strtoi.c popenve.c
+SRCS= blacklistd.c conf.c run.c state.c support.c old_internal.c \
+ sockaddr_snprintf.c pidfile.c strtoi.c popenve.c vsyslog_r.c
MAN= blacklistd.8 blacklistd.conf.5
LDFLAGS+=-L${LIBBLACKLISTDIR}
-LIBADD+= blacklist util
+LIBADD+= blocklist util
CFLAGS+=-I${BLOCKLIST_DIR}/include -I${BLOCKLIST_DIR}/port \
+ -D_PATH_BLCONF=\"/etc/blacklistd.conf\" \
-D_PATH_BLCONTROL=\"/usr/libexec/blacklistd-helper\" \
-DHAVE_CONFIG_H -DHAVE_DB_H -DHAVE_LIBUTIL_H \
-DHAVE_CLOCK_GETTIME -DHAVE_FGETLN -DHAVE_FPARSELN \
-DHAVE_GETPROGNAME -DHAVE_STRLCAT -DHAVE_STRLCPY \
- -DHAVE_STRUCT_SOCKADDR_SA_LEN
+ -DHAVE_STRUCT_SOCKADDR_SA_LEN -DHAVE_SYS_CDEFS_H
# CFLAGS+= -D_REENTRANT
.include <bsd.prog.mk>
diff --git a/usr.sbin/blacklistd/blacklistd.conf b/usr.sbin/blacklistd/blacklistd.conf
index b8dee6768cc7..ec995e038574 100644
--- a/usr.sbin/blacklistd/blacklistd.conf
+++ b/usr.sbin/blacklistd/blacklistd.conf
@@ -1,6 +1,9 @@
-#
+# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+# @ The file blacklistd.conf has been renamed to blocklistd.conf @
+# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
# Blacklist rule
-# adr/mask:port type proto owner name nfail disable
+# adr/mask:port type proto owner name nfail duration
[local]
ssh stream * * * 3 24h
ftp stream * * * 3 24h
@@ -9,8 +12,9 @@ submission stream * * * 3 24h
#6161 stream tcp6 christos * 2 10m
* * * * * 3 60
-# adr/mask:port type proto owner name nfail disable
+# adr/mask:port type proto owner name nfail duration
[remote]
#129.168.0.0/16 * * * = * *
+#[2001:db8::]/32:ssh * * * = * *
#6161 = = = =/24 = =
#* stream tcp * = = =
diff --git a/usr.sbin/blocklistctl/Makefile b/usr.sbin/blocklistctl/Makefile
new file mode 100644
index 000000000000..55891bfb2670
--- /dev/null
+++ b/usr.sbin/blocklistctl/Makefile
@@ -0,0 +1,22 @@
+BLOCKLIST_DIR=${SRCTOP}/contrib/blocklist
+.PATH: ${BLOCKLIST_DIR}/bin ${BLOCKLIST_DIR}/port
+
+PACKAGE= blocklist
+
+PROG= blocklistctl
+SRCS= blocklistctl.c conf.c state.c support.c internal.c \
+ sockaddr_snprintf.c pidfile.c strtoi.c popenve.c
+MAN= blocklistctl.8
+
+LDFLAGS+=-L${LIBBLOCKLISTDIR}
+LIBADD+= blocklist util
+
+CFLAGS+=-I${BLOCKLIST_DIR}/include -I${BLOCKLIST_DIR}/port \
+ -D_PATH_BLCONTROL=\"/usr/libexec/blocklistd-helper\" \
+ -DHAVE_CONFIG_H -DHAVE_DB_H -DHAVE_LIBUTIL_H \
+ -DHAVE_CLOCK_GETTIME -DHAVE_FGETLN -DHAVE_FPARSELN \
+ -DHAVE_GETPROGNAME -DHAVE_STRLCAT -DHAVE_STRLCPY \
+ -DHAVE_STRUCT_SOCKADDR_SA_LEN -DHAVE_SYS_CDEFS_H
+# CFLAGS+= -D_REENTRANT
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/blocklistctl/Makefile.depend b/usr.sbin/blocklistctl/Makefile.depend
new file mode 100644
index 000000000000..6b74110bfe08
--- /dev/null
+++ b/usr.sbin/blocklistctl/Makefile.depend
@@ -0,0 +1,18 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libblocklist \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/blocklistd/Makefile b/usr.sbin/blocklistd/Makefile
new file mode 100644
index 000000000000..ccee9637e208
--- /dev/null
+++ b/usr.sbin/blocklistd/Makefile
@@ -0,0 +1,23 @@
+BLOCKLIST_DIR=${SRCTOP}/contrib/blocklist
+.PATH: ${BLOCKLIST_DIR}/bin ${BLOCKLIST_DIR}/port
+
+PACKAGE= blocklist
+
+CONFS= blocklistd.conf
+PROG= blocklistd
+SRCS= blocklistd.c conf.c run.c state.c support.c internal.c \
+ sockaddr_snprintf.c pidfile.c strtoi.c popenve.c vsyslog_r.c
+MAN= blocklistd.8 blocklistd.conf.5
+
+LDFLAGS+=-L${LIBBLOCKLISTDIR}
+LIBADD+= blocklist util
+
+CFLAGS+=-I${BLOCKLIST_DIR}/include -I${BLOCKLIST_DIR}/port \
+ -D_PATH_BLCONTROL=\"/usr/libexec/blocklistd-helper\" \
+ -DHAVE_CONFIG_H -DHAVE_DB_H -DHAVE_LIBUTIL_H \
+ -DHAVE_CLOCK_GETTIME -DHAVE_FGETLN -DHAVE_FPARSELN \
+ -DHAVE_GETPROGNAME -DHAVE_STRLCAT -DHAVE_STRLCPY \
+ -DHAVE_STRUCT_SOCKADDR_SA_LEN -DHAVE_SYS_CDEFS_H
+# CFLAGS+= -D_REENTRANT
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/blocklistd/Makefile.depend b/usr.sbin/blocklistd/Makefile.depend
new file mode 100644
index 000000000000..6b74110bfe08
--- /dev/null
+++ b/usr.sbin/blocklistd/Makefile.depend
@@ -0,0 +1,18 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/arpa \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libblocklist \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/blocklistd/blocklistd.conf b/usr.sbin/blocklistd/blocklistd.conf
new file mode 100644
index 000000000000..c6c7f7c2fafc
--- /dev/null
+++ b/usr.sbin/blocklistd/blocklistd.conf
@@ -0,0 +1,16 @@
+# Blocklist rule
+# adr/mask:port type proto owner name nfail duration
+[local]
+ssh stream * * * 3 24h
+ftp stream * * * 3 24h
+smtp stream * * * 3 24h
+submission stream * * * 3 24h
+#6161 stream tcp6 christos * 2 10m
+* * * * * 3 60
+
+# adr/mask:port type proto owner name nfail duration
+[remote]
+#129.168.0.0/16 * * * = * *
+#[2001:db8::]/32:ssh * * * = * *
+#6161 = = = =/24 = =
+#* stream tcp * = = =
diff --git a/usr.sbin/bsdinstall/scripts/auto b/usr.sbin/bsdinstall/scripts/auto
index 61d52065af2a..8058b1a41dbf 100755
--- a/usr.sbin/bsdinstall/scripts/auto
+++ b/usr.sbin/bsdinstall/scripts/auto
@@ -209,9 +209,9 @@ if [ ! -f $BSDINSTALL_DISTDIR/MANIFEST ]; then
PKGBASE=yes
else
bsddialog --backtitle "$OSNAME Installer" --title "Select Installation Type" \
- --yes-label "Traditional" --no-label "Packages (Experimental)" --yesno \
+ --yes-label "Distribution Sets" --no-label "Packages (Tech Preview)" --yesno \
$PKGBASE_DEFAULT_BUTTON \
- "Would you like to install the base system using traditional distribution sets or packages (experimental)?" 0 0
+ "Would you like to install the base system using traditional distribution sets or packages (technology preview)?" 0 0
if [ $? -eq 1 ]; then
PKGBASE=yes
fi
diff --git a/usr.sbin/bsdinstall/scripts/jail b/usr.sbin/bsdinstall/scripts/jail
index f2c7ef2b37de..3b1b2ee98fff 100755
--- a/usr.sbin/bsdinstall/scripts/jail
+++ b/usr.sbin/bsdinstall/scripts/jail
@@ -175,8 +175,8 @@ fi
if [ ! "$nonInteractive" == "YES" ]; then
bsddialog --backtitle "$OSNAME Installer" --title "Select Installation Type" \
- --yes-label "Traditional" --no-label "Packages (Experimental)" --yesno \
- "Would you like to install the base system using traditional distribution sets or packages (experimental)?" 0 0
+ --yes-label "Distribution Sets" --no-label "Packages (Tech Preview)" --yesno \
+ "Would you like to install the base system using traditional distribution sets or packages (technology preview)?" 0 0
if [ $? -eq 1 ]; then
PKGBASE=yes
fi
diff --git a/usr.sbin/ctld/ctld.cc b/usr.sbin/ctld/ctld.cc
index 10c12f25068e..331c029e282e 100644
--- a/usr.sbin/ctld/ctld.cc
+++ b/usr.sbin/ctld/ctld.cc
@@ -814,6 +814,11 @@ portal_group::open_sockets(struct conf &oldconf)
}
for (portal_up &portal : pg_portals) {
+ if (!portal->prepare()) {
+ cumulated_error++;
+ continue;
+ }
+
/*
* Try to find already open portal and reuse the
* listening socket. We don't care about what portal
diff --git a/usr.sbin/ctld/ctld.hh b/usr.sbin/ctld/ctld.hh
index cc88e6eb590e..3bf18f6a32c0 100644
--- a/usr.sbin/ctld/ctld.hh
+++ b/usr.sbin/ctld/ctld.hh
@@ -151,6 +151,7 @@ struct portal {
p_protocol(protocol) {}
virtual ~portal() = default;
+ virtual bool prepare() { return true; }
bool reuse_socket(portal &oldp);
bool init_socket();
virtual bool init_socket_options(int s __unused) { return true; }
diff --git a/usr.sbin/ctld/nvmf.cc b/usr.sbin/ctld/nvmf.cc
index d1240bfa4f6c..eb116903f5c1 100644
--- a/usr.sbin/ctld/nvmf.cc
+++ b/usr.sbin/ctld/nvmf.cc
@@ -34,11 +34,8 @@
struct nvmf_io_portal final : public nvmf_portal {
nvmf_io_portal(struct portal_group *pg, const char *listen,
- portal_protocol protocol, freebsd::addrinfo_up ai,
- const struct nvmf_association_params &aparams,
- nvmf_association_up na) :
- nvmf_portal(pg, listen, protocol, std::move(ai), aparams,
- std::move(na)) {}
+ portal_protocol protocol, freebsd::addrinfo_up ai) :
+ nvmf_portal(pg, listen, protocol, std::move(ai)) {}
void handle_connection(freebsd::fd_up fd, const char *host,
const struct sockaddr *client_sa) override;
@@ -63,8 +60,6 @@ struct nvmf_transport_group final : public portal_group {
override;
private:
- struct nvmf_association_params init_aparams(portal_protocol protocol);
-
static uint16_t last_port_id;
};
@@ -143,48 +138,55 @@ parse_number(const nvlist_t *nvl, const char *key, uint64_t def, uint64_t minv,
return def;
}
-struct nvmf_association_params
-nvmf_transport_group::init_aparams(portal_protocol protocol)
+bool
+nvmf_portal::prepare()
{
- struct nvmf_association_params params;
- memset(&params, 0, sizeof(params));
+ memset(&p_aparams, 0, sizeof(p_aparams));
/* Options shared between discovery and I/O associations. */
- const nvlist_t *nvl = pg_options.get();
- params.tcp.header_digests = parse_bool(nvl, "HDGST", false);
- params.tcp.data_digests = parse_bool(nvl, "DDGST", false);
- uint64_t value = parse_number(nvl, "MAXH2CDATA", DEFAULT_MAXH2CDATA,
- 4096, UINT32_MAX);
+ freebsd::nvlist_up nvl = portal_group()->options();
+ p_aparams.tcp.header_digests = parse_bool(nvl.get(), "HDGST", false);
+ p_aparams.tcp.data_digests = parse_bool(nvl.get(), "DDGST", false);
+ uint64_t value = parse_number(nvl.get(), "MAXH2CDATA",
+ DEFAULT_MAXH2CDATA, 4096, UINT32_MAX);
if (value % 4 != 0) {
log_warnx("Invalid value \"%ju\" for option MAXH2CDATA",
(uintmax_t)value);
value = DEFAULT_MAXH2CDATA;
}
- params.tcp.maxh2cdata = value;
+ p_aparams.tcp.maxh2cdata = value;
- switch (protocol) {
+ switch (protocol()) {
case portal_protocol::NVME_TCP:
- params.sq_flow_control = parse_bool(nvl, "SQFC", false);
- params.dynamic_controller_model = true;
- params.max_admin_qsize = parse_number(nvl, "max_admin_qsize",
- NVME_MAX_ADMIN_ENTRIES, NVME_MIN_ADMIN_ENTRIES,
- NVME_MAX_ADMIN_ENTRIES);
- params.max_io_qsize = parse_number(nvl, "max_io_qsize",
+ p_aparams.sq_flow_control = parse_bool(nvl.get(), "SQFC",
+ false);
+ p_aparams.dynamic_controller_model = true;
+ p_aparams.max_admin_qsize = parse_number(nvl.get(),
+ "max_admin_qsize", NVME_MAX_ADMIN_ENTRIES,
+ NVME_MIN_ADMIN_ENTRIES, NVME_MAX_ADMIN_ENTRIES);
+ p_aparams.max_io_qsize = parse_number(nvl.get(), "max_io_qsize",
NVME_MAX_IO_ENTRIES, NVME_MIN_IO_ENTRIES,
NVME_MAX_IO_ENTRIES);
- params.tcp.pda = 0;
+ p_aparams.tcp.pda = 0;
break;
case portal_protocol::NVME_DISCOVERY_TCP:
- params.sq_flow_control = false;
- params.dynamic_controller_model = true;
- params.max_admin_qsize = NVME_MAX_ADMIN_ENTRIES;
- params.tcp.pda = 0;
+ p_aparams.sq_flow_control = false;
+ p_aparams.dynamic_controller_model = true;
+ p_aparams.max_admin_qsize = NVME_MAX_ADMIN_ENTRIES;
+ p_aparams.tcp.pda = 0;
break;
default:
__assert_unreachable();
}
- return params;
+ p_association.reset(nvmf_allocate_association(NVMF_TRTYPE_TCP, true,
+ &p_aparams));
+ if (!p_association) {
+ log_warn("Failed to create NVMe controller association");
+ return false;
+ }
+
+ return true;
}
portal_group_up
@@ -209,15 +211,12 @@ bool
nvmf_transport_group::add_portal(const char *value, portal_protocol protocol)
{
freebsd::addrinfo_up ai;
- enum nvmf_trtype trtype;
switch (protocol) {
case portal_protocol::NVME_TCP:
- trtype = NVMF_TRTYPE_TCP;
ai = parse_addr_port(value, "4420");
break;
case portal_protocol::NVME_DISCOVERY_TCP:
- trtype = NVMF_TRTYPE_TCP;
ai = parse_addr_port(value, "8009");
break;
default:
@@ -230,14 +229,6 @@ nvmf_transport_group::add_portal(const char *value, portal_protocol protocol)
return false;
}
- struct nvmf_association_params aparams = init_aparams(protocol);
- nvmf_association_up association(nvmf_allocate_association(trtype, true,
- &aparams));
- if (!association) {
- log_warn("Failed to create NVMe controller association");
- return false;
- }
-
/*
* XXX: getaddrinfo(3) may return multiple addresses; we should turn
* those into multiple portals.
@@ -246,10 +237,10 @@ nvmf_transport_group::add_portal(const char *value, portal_protocol protocol)
portal_up portal;
if (protocol == portal_protocol::NVME_DISCOVERY_TCP) {
portal = std::make_unique<nvmf_discovery_portal>(this, value,
- protocol, std::move(ai), aparams, std::move(association));
+ protocol, std::move(ai));
} else {
portal = std::make_unique<nvmf_io_portal>(this, value,
- protocol, std::move(ai), aparams, std::move(association));
+ protocol, std::move(ai));
need_tcp_transport = true;
}
diff --git a/usr.sbin/ctld/nvmf.hh b/usr.sbin/ctld/nvmf.hh
index 0b4f8d45adfd..6f34a2858ef9 100644
--- a/usr.sbin/ctld/nvmf.hh
+++ b/usr.sbin/ctld/nvmf.hh
@@ -38,13 +38,12 @@ using nvmf_qpair_up = std::unique_ptr<nvmf_qpair, nvmf_qpair_deleter>;
struct nvmf_portal : public portal {
nvmf_portal(struct portal_group *pg, const char *listen,
- portal_protocol protocol, freebsd::addrinfo_up ai,
- const struct nvmf_association_params &aparams,
- nvmf_association_up na) :
- portal(pg, listen, protocol, std::move(ai)),
- p_aparams(aparams), p_association(std::move(na)) {}
+ portal_protocol protocol, freebsd::addrinfo_up ai) :
+ portal(pg, listen, protocol, std::move(ai)) {}
virtual ~nvmf_portal() override = default;
+ virtual bool prepare() override;
+
const struct nvmf_association_params *aparams() const
{ return &p_aparams; }
@@ -58,11 +57,8 @@ private:
struct nvmf_discovery_portal final : public nvmf_portal {
nvmf_discovery_portal(struct portal_group *pg, const char *listen,
- portal_protocol protocol, freebsd::addrinfo_up ai,
- const struct nvmf_association_params &aparams,
- nvmf_association_up na) :
- nvmf_portal(pg, listen, protocol, std::move(ai), aparams,
- std::move(na)) {}
+ portal_protocol protocol, freebsd::addrinfo_up ai) :
+ nvmf_portal(pg, listen, protocol, std::move(ai)) {}
void handle_connection(freebsd::fd_up fd, const char *host,
const struct sockaddr *client_sa) override;
diff --git a/usr.sbin/nfsuserd/nfsuserd.c b/usr.sbin/nfsuserd/nfsuserd.c
index 0e5c9c8f1e50..058253beaf95 100644
--- a/usr.sbin/nfsuserd/nfsuserd.c
+++ b/usr.sbin/nfsuserd/nfsuserd.c
@@ -629,6 +629,7 @@ nfsuserdsrv(struct svc_req *rqstp, SVCXPRT *transp)
syslog(LOG_ERR,
"Group list of user '%s' too big",
pwd->pw_name);
+ ngroup = NGROUPS;
}
nid.nid_ngroup = ngroup;
nid.nid_grps = grps;
diff --git a/usr.sbin/periodic/etc/security/520.pfdenied b/usr.sbin/periodic/etc/security/520.pfdenied
index 9852936257bc..d87dfa0ae64c 100755
--- a/usr.sbin/periodic/etc/security/520.pfdenied
+++ b/usr.sbin/periodic/etc/security/520.pfdenied
@@ -41,7 +41,7 @@ rc=0
if check_yesno_period security_status_pfdenied_enable
then
TMP=`mktemp -t security`
- for _a in "" $(pfctl -a "blacklistd" -sA 2>/dev/null) ${security_status_pfdenied_additionalanchors}
+ for _a in "" $(pfctl -a "blacklistd" -sA 2>/dev/null) $(pfctl -a "blocklistd" -sA 2>/dev/null) ${security_status_pfdenied_additionalanchors}
do
pfctl -a "${_a}" -sr -v -z 2>/dev/null | \
nawk '{if (/^block/) {buf=$0; getline; gsub(" +"," ",$0); if ($5 > 0) print buf$0;} }' >> ${TMP}
diff --git a/usr.sbin/rpc.tlsservd/rpc.tlsservd.c b/usr.sbin/rpc.tlsservd/rpc.tlsservd.c
index f07385a2baa7..fb0501b2db4c 100644
--- a/usr.sbin/rpc.tlsservd/rpc.tlsservd.c
+++ b/usr.sbin/rpc.tlsservd/rpc.tlsservd.c
@@ -168,7 +168,12 @@ main(int argc, char **argv)
rpctls_verbose = false;
ncpu = (u_int)sysconf(_SC_NPROCESSORS_ONLN);
+#ifdef notnow
rpctls_maxthreads = ncpu > 1 ? ncpu / 2 : 1;
+#else
+ /* XXX For now, until fixed properly!! */
+ rpctls_maxthreads = 1;
+#endif
while ((ch = getopt_long(argc, argv, "2C:D:dhl:N:n:mp:r:uvWw", longopts,
NULL)) != -1) {
@@ -199,6 +204,8 @@ main(int argc, char **argv)
if (rpctls_maxthreads < 1 || rpctls_maxthreads > ncpu)
errx(1, "maximum threads must be between 1 and "
"number of CPUs (%d)", ncpu);
+ /* XXX For now, until fixed properly!! */
+ rpctls_maxthreads = 1;
break;
case 'n':
hostname[0] = '@';