aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.inc12
-rw-r--r--UPDATING5
-rw-r--r--contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.h5
-rw-r--r--contrib/pjdfstest/tests/ftruncate/12.t2
-rw-r--r--contrib/pjdfstest/tests/link/05.t11
-rw-r--r--contrib/pjdfstest/tests/link/15.t2
-rw-r--r--contrib/pjdfstest/tests/mkdir/11.t2
-rw-r--r--contrib/pjdfstest/tests/mkfifo/11.t2
-rw-r--r--contrib/pjdfstest/tests/open/19.t2
-rw-r--r--contrib/pjdfstest/tests/symlink/11.t2
-rw-r--r--contrib/pjdfstest/tests/truncate/12.t2
-rw-r--r--contrib/tzcode/localtime.c12
-rw-r--r--crypto/openssh/misc.c6
-rw-r--r--lib/geom/shsec/gshsec.87
-rw-r--r--lib/libc/riscv/string/Makefile.inc10
-rw-r--r--lib/libc/riscv/string/bcopy.c14
-rw-r--r--lib/libc/riscv/string/bzero.c14
-rw-r--r--lib/libc/riscv/string/memchr.S188
-rw-r--r--lib/libc/riscv/string/memcpy.S217
-rw-r--r--lib/libc/riscv/string/memset.S95
-rw-r--r--lib/libc/riscv/string/strchrnul.S116
-rw-r--r--lib/libc/riscv/string/strlen.S77
-rw-r--r--lib/libc/riscv/string/strnlen.S143
-rw-r--r--lib/libc/riscv/string/strrchr.S127
-rw-r--r--lib/libpam/static_libpam/Makefile1
-rw-r--r--lib/libpfctl/libpfctl.c95
-rw-r--r--lib/libpfctl/libpfctl.h5
-rw-r--r--lib/libsys/pathconf.28
-rw-r--r--lib/libsys/revoke.24
-rw-r--r--libexec/rc/rc.subr14
-rw-r--r--release/Makefile.vm3
-rw-r--r--release/tools/gce.conf2
-rw-r--r--sbin/ifconfig/ifconfig.83
-rw-r--r--sbin/pfctl/pfctl.c6
-rw-r--r--sbin/pfctl/pfctl.h2
-rw-r--r--sbin/pfctl/pfctl_radix.c4
-rw-r--r--sbin/pfctl/pfctl_table.c13
-rw-r--r--share/man/man4/ddb.412
-rw-r--r--share/man/man4/dtrace_io.44
-rw-r--r--share/man/man4/u3g.44
-rw-r--r--share/man/man5/style.Makefile.524
-rw-r--r--share/man/man7/d.7124
-rw-r--r--share/man/man7/simd.735
-rw-r--r--share/man/man9/atomic.954
-rw-r--r--share/man/man9/bus_alloc_resource.924
-rw-r--r--share/man/man9/bus_attach_children.92
-rw-r--r--share/misc/bsd-family-tree6
-rw-r--r--share/mk/bsd.prog.mk4
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_audio.c71
-rw-r--r--sys/cam/cam_xpt.c8
-rw-r--r--sys/compat/linuxkpi/common/include/linux/pm.h14
-rw-r--r--sys/compat/linuxkpi/common/src/linux_page.c4
-rw-r--r--sys/contrib/vchiq/interface/vchiq_arm/vchiq_2835_arm.c13
-rw-r--r--sys/contrib/vchiq/interface/vchiq_arm/vchiq_arm.c28
-rw-r--r--sys/dev/amdtemp/amdtemp.c2
-rw-r--r--sys/dev/ath/ath_hal/ar5416/ar5416_cal_iq.c2
-rw-r--r--sys/dev/bwi/if_bwi.c2
-rw-r--r--sys/dev/cesa/cesa.c4
-rw-r--r--sys/dev/ciss/ciss.c2
-rw-r--r--sys/dev/igc/if_igc.c2
-rw-r--r--sys/dev/isci/scil/scic_sds_remote_node_context.c4
-rw-r--r--sys/dev/mfi/mfi.c2
-rw-r--r--sys/dev/nvme/nvme_ctrlr.c9
-rw-r--r--sys/dev/nvme/nvme_pci.c48
-rw-r--r--sys/dev/nvme/nvme_private.h6
-rw-r--r--sys/dev/nvmf/controller/nvmft_controller.c2
-rw-r--r--sys/dev/oce/oce_sysctl.c12
-rw-r--r--sys/dev/random/fenestrasX/fx_pool.c3
-rw-r--r--sys/dev/random/random_harvestq.c6
-rw-r--r--sys/dev/thunderbolt/nhi.c1
-rw-r--r--sys/dev/thunderbolt/nhi_pci.c10
-rw-r--r--sys/dev/thunderbolt/nhi_var.h1
-rw-r--r--sys/dev/uart/uart_bus_fdt.c6
-rw-r--r--sys/dev/uart/uart_dev_snps.c10
-rw-r--r--sys/dev/usb/serial/u3g.c2
-rw-r--r--sys/dev/usb/usbdevs2
-rw-r--r--sys/dev/vnic/nicvf_main.c2
-rw-r--r--sys/fs/nfs/nfs_commonsubs.c31
-rw-r--r--sys/fs/nfs/nfs_var.h4
-rw-r--r--sys/fs/nfsclient/nfs_clrpcops.c2
-rw-r--r--sys/fs/nfsclient/nfs_clstate.c3
-rw-r--r--sys/fs/nfsclient/nfs_clvfsops.c8
-rw-r--r--sys/fs/nfsclient/nfs_clvnops.c8
-rw-r--r--sys/fs/nfsserver/nfs_nfsdport.c18
-rw-r--r--sys/fs/nfsserver/nfs_nfsdserv.c9
-rw-r--r--sys/kern/kern_jail.c2
-rw-r--r--sys/kern/kern_loginclass.c2
-rw-r--r--sys/kern/kern_prot.c23
-rw-r--r--sys/kern/kern_racct.c19
-rw-r--r--sys/kern/subr_bus.c2
-rw-r--r--sys/kern/subr_syscall.c10
-rw-r--r--sys/net/pfvar.h9
-rw-r--r--sys/netinet/in_pcb.c156
-rw-r--r--sys/netinet/in_pcb.h17
-rw-r--r--sys/netinet/tcp.h1
-rw-r--r--sys/netinet/tcp_usrreq.c286
-rw-r--r--sys/netinet/tcp_var.h29
-rw-r--r--sys/netinet6/mld6.c1
-rw-r--r--sys/netipsec/ipsec_offload.c8
-rw-r--r--sys/netpfil/ipfw/pmod/tcpmod.c25
-rw-r--r--sys/netpfil/pf/if_pfsync.c3
-rw-r--r--sys/netpfil/pf/pf.c2
-rw-r--r--sys/netpfil/pf/pf_if.c2
-rw-r--r--sys/netpfil/pf/pf_ioctl.c13
-rw-r--r--sys/netpfil/pf/pf_lb.c117
-rw-r--r--sys/netpfil/pf/pf_nl.c44
-rw-r--r--sys/netpfil/pf/pf_nl.h2
-rw-r--r--sys/netpfil/pf/pf_table.c12
-rw-r--r--sys/powerpc/include/openpicvar.h9
-rw-r--r--sys/powerpc/ofw/openpic_ofw.c18
-rw-r--r--sys/powerpc/powermac/cpcht.c33
-rw-r--r--sys/powerpc/powerpc/openpic.c55
-rw-r--r--sys/powerpc/psim/openpic_iobus.c17
-rw-r--r--sys/riscv/riscv/fpe.c66
-rw-r--r--sys/riscv/vmm/vmm.c4
-rw-r--r--sys/riscv/vmm/vmm_aplic.c10
-rw-r--r--sys/riscv/vmm/vmm_aplic.h1
-rw-r--r--sys/sys/bus.h42
-rw-r--r--sys/sys/param.h2
-rw-r--r--tests/sys/netpfil/pf/ioctl/validation.c58
-rw-r--r--tests/sys/netpfil/pf/nat.sh47
-rwxr-xr-xtests/sys/netpfil/pf/src_track.sh74
-rw-r--r--tests/sys/netpfil/pf/table.sh62
-rwxr-xr-xtools/build/depend-cleanup.sh27
-rw-r--r--usr.bin/id/id.c10
-rw-r--r--usr.bin/sockstat/main.c170
-rw-r--r--usr.bin/sockstat/sockstat.17
-rw-r--r--usr.bin/truss/syscalls.c2
-rw-r--r--usr.sbin/bhyve/bhyve.87
-rw-r--r--usr.sbin/cron/lib/env.c5
-rw-r--r--usr.sbin/pkg/Makefile1
131 files changed, 2536 insertions, 853 deletions
diff --git a/Makefile.inc1 b/Makefile.inc1
index e341599ac505..81af336ecfa2 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -471,7 +471,7 @@ SUBDIR+= ${_DIR}
# by calling 'makedb' in share/man. This is only relevant for
# install/distribute so they build the whatis file after every manpage is
# installed.
-.if make(installworld) || make(install)
+.if make(installworld) || make(install) || make(distributeworld) || make(distribute)
SUBDIR+=.WAIT
.endif
SUBDIR+=etc
diff --git a/UPDATING b/UPDATING
index d89afb7ef429..3f425d9da7c8 100644
--- a/UPDATING
+++ b/UPDATING
@@ -27,6 +27,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 16.x IS SLOW:
world, or to merely disable the most expensive debugging functionality
at runtime, run "ln -s 'abort:false,junk:false' /etc/malloc.conf".)
+20251102:
+ Commit e5aa60d06958 changed the internal KAPI between
+ the NFS modules. As such, they all need to be rebuilt
+ from sources. __FreeBSD_version was bumped to 1600004 for this.
+
20251025:
flua(1) has moved to the new FreeBSD-flua package. If you use flua,
you may want to install this package if it's not otherwise installed
diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.h b/contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.h
index 7d090ba682b3..7ab63905ed4f 100644
--- a/contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.h
+++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.h
@@ -78,11 +78,6 @@ public:
void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
- bool IsAArch64OutlineAtomicsDefault(
- const llvm::opt::ArgList &Args) const override {
- return true;
- }
-
UnwindTableLevel
getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override;
bool isPIEDefault(const llvm::opt::ArgList &Args) const override;
diff --git a/contrib/pjdfstest/tests/ftruncate/12.t b/contrib/pjdfstest/tests/ftruncate/12.t
index 98f3daeaf461..022f2cdae47a 100644
--- a/contrib/pjdfstest/tests/ftruncate/12.t
+++ b/contrib/pjdfstest/tests/ftruncate/12.t
@@ -22,7 +22,7 @@ EFBIG|EINVAL)
;;
*)
echo "not ok ${ntest}"
- ntest=`expr ${ntest} + 1`
+ ntest=$((ntest + 1))
;;
esac
expect 0 unlink ${n0}
diff --git a/contrib/pjdfstest/tests/link/05.t b/contrib/pjdfstest/tests/link/05.t
index 5a18c2103e1d..4641e3605efb 100644
--- a/contrib/pjdfstest/tests/link/05.t
+++ b/contrib/pjdfstest/tests/link/05.t
@@ -2,7 +2,7 @@
# vim: filetype=sh noexpandtab ts=8 sw=8
# $FreeBSD: head/tools/regression/pjdfstest/tests/link/05.t 211352 2010-08-15 21:24:17Z pjd $
-desc="link returns EMLINK if the link count of the file named by name1 would exceed 32767"
+desc="link returns EMLINK if the link count of the file named by name1 would exceed {PC_LINK_MAX}"
dir=`dirname $0`
. ${dir}/../misc.sh
@@ -16,19 +16,20 @@ n1=`namegen`
n2=`namegen`
expect 0 mkdir ${n0} 0755
-n=`mdconfig -a -n -t malloc -s 1m` || exit
+n=`mdconfig -a -n -t malloc -s 2m` || exit
newfs -i 1 /dev/md${n} >/dev/null || exit
mount /dev/md${n} ${n0} || exit
+link_max=`${fstest} pathconf ${n0} _PC_LINK_MAX`
expect 0 create ${n0}/${n1} 0644
i=1
-while :; do
+while [ ${i} -le ${link_max} ]; do
link ${n0}/${n1} ${n0}/${i} >/dev/null 2>&1
if [ $? -ne 0 ]; then
break
fi
- i=`expr $i + 1`
+ i=$((i + 1))
done
-test_check $i -eq 32767
+test_check $i -eq ${link_max}
expect EMLINK link ${n0}/${n1} ${n0}/${n2}
diff --git a/contrib/pjdfstest/tests/link/15.t b/contrib/pjdfstest/tests/link/15.t
index cb41ad503370..0dc7648df5cb 100644
--- a/contrib/pjdfstest/tests/link/15.t
+++ b/contrib/pjdfstest/tests/link/15.t
@@ -26,7 +26,7 @@ while :; do
if [ $? -ne 0 ]; then
break
fi
- i=`expr $i + 1`
+ i=$((i + 1))
done
expect ENOSPC link ${n0}/${n1} ${n0}/${n2}
umount /dev/md${n}
diff --git a/contrib/pjdfstest/tests/mkdir/11.t b/contrib/pjdfstest/tests/mkdir/11.t
index 118ca3af8896..f162f6d4eb86 100644
--- a/contrib/pjdfstest/tests/mkdir/11.t
+++ b/contrib/pjdfstest/tests/mkdir/11.t
@@ -24,7 +24,7 @@ while :; do
if [ $? -ne 0 ]; then
break
fi
- i=`expr $i + 1`
+ i=$((i + 1))
done
expect ENOSPC mkdir ${n0}/${n1} 0755
umount /dev/md${n}
diff --git a/contrib/pjdfstest/tests/mkfifo/11.t b/contrib/pjdfstest/tests/mkfifo/11.t
index 39cfea4e40f7..73d4a5d09f30 100644
--- a/contrib/pjdfstest/tests/mkfifo/11.t
+++ b/contrib/pjdfstest/tests/mkfifo/11.t
@@ -24,7 +24,7 @@ while :; do
if [ $? -ne 0 ]; then
break
fi
- i=`expr $i + 1`
+ i=$((i + 1))
done
expect ENOSPC mkfifo ${n0}/${n1} 0644
umount /dev/md${n}
diff --git a/contrib/pjdfstest/tests/open/19.t b/contrib/pjdfstest/tests/open/19.t
index 4bc2df2a4313..e3c5b35fd96b 100644
--- a/contrib/pjdfstest/tests/open/19.t
+++ b/contrib/pjdfstest/tests/open/19.t
@@ -24,7 +24,7 @@ while :; do
if [ $? -ne 0 ]; then
break
fi
- i=`expr $i + 1`
+ i=$((i + 1))
done
expect ENOSPC open ${n0}/${i} O_RDONLY,O_CREAT 0644
umount /dev/md${n}
diff --git a/contrib/pjdfstest/tests/symlink/11.t b/contrib/pjdfstest/tests/symlink/11.t
index b1be674370ad..5d5e864674d6 100644
--- a/contrib/pjdfstest/tests/symlink/11.t
+++ b/contrib/pjdfstest/tests/symlink/11.t
@@ -24,7 +24,7 @@ while :; do
if [ $? -ne 0 ]; then
break
fi
- i=`expr $i + 1`
+ i=$((i + 1))
done
expect ENOSPC symlink test ${n0}/${n1}
umount /dev/md${n}
diff --git a/contrib/pjdfstest/tests/truncate/12.t b/contrib/pjdfstest/tests/truncate/12.t
index 98f3daeaf461..022f2cdae47a 100644
--- a/contrib/pjdfstest/tests/truncate/12.t
+++ b/contrib/pjdfstest/tests/truncate/12.t
@@ -22,7 +22,7 @@ EFBIG|EINVAL)
;;
*)
echo "not ok ${ntest}"
- ntest=`expr ${ntest} + 1`
+ ntest=$((ntest + 1))
;;
esac
expect 0 unlink ${n0}
diff --git a/contrib/tzcode/localtime.c b/contrib/tzcode/localtime.c
index 1668475ea646..58099d234e2b 100644
--- a/contrib/tzcode/localtime.c
+++ b/contrib/tzcode/localtime.c
@@ -1583,15 +1583,15 @@ tzdata_is_fresh(void)
struct timespec now;
if (clock_gettime(CLOCK_MONOTONIC, &now) < 0)
- return 0;
+ return 1;
- if ((now.tv_sec - last_checked >= __tz_change_interval) ||
- (last_checked > now.tv_sec)) {
+ if (last_checked == 0 || last_checked > now.tv_sec ||
+ now.tv_sec - last_checked >= __tz_change_interval) {
last_checked = now.tv_sec;
- return 1;
+ return 0;
}
- return 0;
+ return 1;
}
#endif /* DETECT_TZ_CHANGES */
@@ -1642,7 +1642,7 @@ tzset_unlocked_name(char const *name)
? lcl_is_set < 0
: 0 < lcl_is_set && strcmp(lcl_TZname, name) == 0)
#ifdef DETECT_TZ_CHANGES
- if (tzdata_is_fresh() == 0)
+ if (tzdata_is_fresh())
#endif /* DETECT_TZ_CHANGES */
return;
# ifdef ALL_STATE
diff --git a/crypto/openssh/misc.c b/crypto/openssh/misc.c
index dd0bd032ae3c..1ed71646ebe4 100644
--- a/crypto/openssh/misc.c
+++ b/crypto/openssh/misc.c
@@ -2535,8 +2535,10 @@ format_absolute_time(uint64_t t, char *buf, size_t len)
time_t tt = t > SSH_TIME_T_MAX ? SSH_TIME_T_MAX : t;
struct tm tm;
- localtime_r(&tt, &tm);
- strftime(buf, len, "%Y-%m-%dT%H:%M:%S", &tm);
+ if (localtime_r(&tt, &tm) == NULL)
+ strlcpy(buf, "UNKNOWN-TIME", len);
+ else
+ strftime(buf, len, "%Y-%m-%dT%H:%M:%S", &tm);
}
/*
diff --git a/lib/geom/shsec/gshsec.8 b/lib/geom/shsec/gshsec.8
index d4477de3a71e..f80ab9384fe3 100644
--- a/lib/geom/shsec/gshsec.8
+++ b/lib/geom/shsec/gshsec.8
@@ -1,3 +1,6 @@
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
.\" Copyright (c) 2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>
.\" All rights reserved.
.\"
@@ -64,7 +67,7 @@ the rest of them.
The first argument to
.Nm
indicates an action to be performed:
-.Bl -tag -width ".Cm destroy"
+.Bl -tag -width indent
.It Cm label
Set up a shared secret device from the given components with the specified
.Ar name .
@@ -92,7 +95,7 @@ See
.El
.Pp
Additional options:
-.Bl -tag -width ".Fl f"
+.Bl -tag -width indent
.It Fl f
Force the removal of the specified shared secret device.
.It Fl h
diff --git a/lib/libc/riscv/string/Makefile.inc b/lib/libc/riscv/string/Makefile.inc
new file mode 100644
index 000000000000..6dae6b2cb62d
--- /dev/null
+++ b/lib/libc/riscv/string/Makefile.inc
@@ -0,0 +1,10 @@
+MDSRCS+= \
+ bcopy.c \
+ bzero.c \
+ memchr.S \
+ memcpy.S \
+ memset.S \
+ strlen.S \
+ strnlen.S \
+ strchrnul.S \
+ strrchr.S
diff --git a/lib/libc/riscv/string/bcopy.c b/lib/libc/riscv/string/bcopy.c
new file mode 100644
index 000000000000..0dee529fb9df
--- /dev/null
+++ b/lib/libc/riscv/string/bcopy.c
@@ -0,0 +1,14 @@
+/*-
+ * Public domain.
+ */
+
+#include <string.h>
+
+#undef bcopy /* _FORTIFY_SOURCE */
+
+void
+bcopy(const void *src, void *dst, size_t len)
+{
+
+ memmove(dst, src, len);
+}
diff --git a/lib/libc/riscv/string/bzero.c b/lib/libc/riscv/string/bzero.c
new file mode 100644
index 000000000000..d82f3061865b
--- /dev/null
+++ b/lib/libc/riscv/string/bzero.c
@@ -0,0 +1,14 @@
+/*-
+ * Public domain.
+ */
+
+#include <string.h>
+
+#undef bzero /* _FORTIFY_SOURCE */
+
+void
+bzero(void *b, size_t len)
+{
+
+ memset(b, 0, len);
+}
diff --git a/lib/libc/riscv/string/memchr.S b/lib/libc/riscv/string/memchr.S
new file mode 100644
index 000000000000..e6e04bfae96a
--- /dev/null
+++ b/lib/libc/riscv/string/memchr.S
@@ -0,0 +1,188 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Strahinja Stanisic <strajabot@FreeBSD.org>
+ */
+
+#include <machine/asm.h>
+
+/*
+ * a0 - const void *b
+ * a1 - int c
+ * a2 - size_t len
+ */
+ENTRY(memchr)
+ /*
+ * a0 - const char *ptr
+ * a1 - char cccccccc[8]
+ * a2 - char iter[8]
+ * a3 - uint8_t *end
+ * a4 - uint64_t *end_align
+ * a5 - uint64_t *end_unroll
+ */
+
+ beqz a2, .Lno_match
+
+ /* c = (uint8_t) c */
+ andi a1, a1, 0xFF
+
+ /*
+ * t0 = 0x0101010101010101
+ * t1 = 0x8080808080808080
+ * t2 = b << 3
+ * cccccccc = (uint8_t)c * t0
+ * end = b + len;
+ * ptr = b & ~0b111
+ */
+ add a3, a0, a2
+ li t0, 0x01010101
+ sltu t2, a0, a3
+ slli t1, t0, 32
+ neg t2, t2
+ or t0, t0, t1
+ and a3, a3, t2
+ slli t1, t0, 7
+ slli t2, a0, 3
+ and a0, a0, ~0b111
+ mul a1, t0, a1
+
+ ld a2, (a0)
+
+ /*
+ * mask_start = REP8_0x01 ^ (REP8_0x01 << t2)
+ * iter = iter ^ cccccccc
+ * iter = iter | mask_start
+ */
+ sll t2, t0, t2
+ xor a2, a2, a1
+ xor t2, t2, t0
+ or a2, a2, t2
+
+ /* has_zero(iter)
+ * end_align = (end + 7) & ~0b111;
+ */
+ addi a4, a3, 7
+ not t2, a2
+ sub a2, a2, t0
+ and t2, t2, t1
+ andi a4, a4, ~0b111
+ and a2, a2, t2
+
+ /* ptr = ptr + 8 */
+ addi a0, a0, 8
+
+ bnez a2, .Lfind_zero
+
+ /* if(ptr == end_align) */
+ beq a0, a4, .Lno_match
+
+ /* end_unroll = end_align & ~0b1111 */
+ andi a5, a4, ~0b1111
+
+ /*
+ * Instead of branching to check if `ptr` is 16-byte aligned:
+ * - Probe the next 8 bytes for `c`
+ * - Align `ptr` down to the nearest 16-byte boundary
+ *
+ * If `ptr` was already 16-byte aligned, those 8 bytes will be
+ * checked again inside the unrolled loop.
+ *
+ * This removes an unpredictable branch and improves performance.
+ */
+
+ ld a2, (a0)
+ xor a2, a2, a1
+
+ not t2, a2
+ sub a2, a2, t0
+ and t2, t2, t1
+ and a2, a2, t2
+
+ addi a0, a0, 8
+
+ bnez a2, .Lfind_zero
+
+ andi a0, a0, ~0b1111
+
+ /* while(ptr != end_unroll) */
+ beq a0, a5, .Lskip_loop
+.Lloop:
+ ld a2, (a0)
+ ld t3, 8(a0)
+
+ xor a2, a2, a1
+ xor t3, t3, a1
+
+ not t2, a2
+ not t4, t3
+ sub a2, a2, t0
+ sub t3, t3, t0
+ and t2, t2, t1
+ and t4, t4, t1
+ and a2, a2, t2
+ and t3, t3, t4
+
+ addi a0, a0, 8
+
+ bnez a2, .Lfind_zero
+
+ /* move into iter for find_zero */
+ mv a2, t3
+
+ addi a0, a0, 8
+
+ bnez a2, .Lfind_zero
+
+ bne a0, a5, .Lloop
+.Lskip_loop:
+
+ /* there might be one 8byte left */
+ beq a0, a4, .Lno_match
+
+ ld a2, (a0)
+ xor a2, a2, a1
+
+ not t2, a2
+ sub a2, a2, t0
+ and t2, t2, t1
+ and a2, a2, t2
+
+ addi a0, a0, 8
+
+ beqz a2, .Lno_match
+
+.Lfind_zero:
+ /*
+ * ptr = ptr - 8
+ * t1 = 0x0001020304050607
+ * iter = iter & (-iter)
+ * iter = iter >> 7
+ * iter = iter * t1
+ * iter = iter >> 56
+ */
+ li t1, 0x10203000
+ neg t0, a2
+ slli t1, t1, 4
+ and a2, a2, t0
+ addi t1, t1, 0x405
+ srli a2, a2, 7
+ slli t1, t1, 16
+ addi a0, a0, -8
+ addi t1, t1, 0x607
+ mul a2, a2, t1
+ srli a2, a2, 56
+
+ /* left = end - ptr */
+ sub t0, a3, a0
+
+ /* return iter < left ? ptr + iter : NULL */
+ sltu t1, a2, t0
+ neg t1, t1
+ add a0, a0, a2
+ and a0, a0, t1
+ ret
+
+.Lno_match:
+ li a0, 0
+ ret
+END(memchr)
diff --git a/lib/libc/riscv/string/memcpy.S b/lib/libc/riscv/string/memcpy.S
new file mode 100644
index 000000000000..7536514df777
--- /dev/null
+++ b/lib/libc/riscv/string/memcpy.S
@@ -0,0 +1,217 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Strahinja Stanisic <strajabot@FreeBSD.org>
+ */
+
+#include <machine/asm.h>
+
+/*
+ * a0 - void* dst
+ * a1 - const void* src
+ * a2 - size_t len
+ */
+ENTRY(memcpy)
+ beqz a2, .Lreturn
+
+ /* diff = (dstv - srcv) & 0b111 */
+ sub t0, a0, a1
+ andi t0, t0, 0b111
+
+ sltiu t1, a2, 8
+
+ /* we never change a0, because memcpy returns the original dst */
+ mv a3, a0
+
+ /* len < 8 */
+ bnez t1, .Lend
+
+ /* t1 = (-dst) & 0b111 */
+ neg t1, a0
+ andi t1, t1, 0b111
+
+ sub a2, a2, t1
+
+ la t2, .Lduff_start
+ slli t3, t1, 3
+ sub t2, t2, t3
+ jr t2
+ lb t3, 6(a1)
+ sb t3, 6(a3)
+ lb t3, 5(a1)
+ sb t3, 5(a3)
+ lb t3, 4(a1)
+ sb t3, 4(a3)
+ lb t3, 3(a1)
+ sb t3, 3(a3)
+ lb t3, 2(a1)
+ sb t3, 2(a3)
+ lb t3, 1(a1)
+ sb t3, 1(a3)
+ lb t3, 0(a1)
+ sb t3, 0(a3)
+.Lduff_start:
+
+ add a1, a1, t1
+ add a3, a3, t1
+
+ beqz a2, .Lreturn
+
+ beqz t0, .Lmemcpy8
+
+ /*
+ * a4 - size_t right_shift
+ * a5 - size_t left_shift
+ * a6 - size_t whole (number of dword stores)
+ */
+
+ /* right_shift = (src % 0b111) * 8; */
+ andi a4, a1, 0b111
+ slli a4, a4, 3
+
+ /* left_shift = 64 - right_shift */
+ neg a5, a4
+
+ /* whole = len / 8 */
+ srli a6, a2, 3
+
+ /* len = len % 8 */
+ andi a2, a2, 0b111
+
+ /* t0 - uint64_t* ptr */
+
+ /* ptr = src & ~0b111 */
+ andi t0, a1, ~0b111
+
+ /* src += whole * 8 */
+ slli t1, a6, 3
+ add a1, a1, t1
+
+ /*
+ * t1 - uint64_t low
+ * t2 - uint64_t high
+ */
+
+ /* low = *ptr++ */
+ ld t1, (t0)
+ addi t0, t0, 8
+
+ /* low >>= right_shift */
+ srl t1, t1, a4
+
+ beqz a6, .Llmain_skip
+.Llmain:
+ /* high = *ptr++ */
+ ld t2, (t0)
+ addi t0, t0, 8
+
+ /* whole-- */
+ addi a6, a6, -1
+
+ /* temp = (high << left_shift) | low */
+ sll t3, t2, a5
+ or t3, t3, t1
+
+ /* low = high >> right_shift */
+ srl t1, t2, a4
+
+ /* *dst++ = temp */
+ sd t3, (a3)
+ addi a3, a3, 8
+
+ bnez a6, .Llmain
+
+.Llmain_skip:
+
+.Lend:
+ la t1, .Lduff_end
+ slli t2, a2, 3
+ sub t1, t1, t2
+ jr t1
+ lb t2, 6(a1)
+ sb t2, 6(a3)
+ lb t2, 5(a1)
+ sb t2, 5(a3)
+ lb t2, 4(a1)
+ sb t2, 4(a3)
+ lb t2, 3(a1)
+ sb t2, 3(a3)
+ lb t2, 2(a1)
+ sb t2, 2(a3)
+ lb t2, 1(a1)
+ sb t2, 1(a3)
+ lb t2, 0(a1)
+ sb t2, 0(a3)
+.Lduff_end:
+
+.Lreturn:
+ ret
+
+/* exectued when dst - src is multiple of 8
+ * a0 - void* dst
+ * a1 - const void* src
+ * a2 - size_t len
+ */
+.Lmemcpy8:
+
+ beqz a2, .Lreturn
+
+ slti t0, a2, 128
+ bnez t0, .Llmain8_64_skip
+
+ /* a4 - uint64_t* end_unroll */
+
+ /* end_unroll = dst + len / 64 * 64 */
+ andi t0, a2, ~0b111111
+ add a4, a3, t0
+
+ /* len = len % 64 */
+ andi a2, a2, 0b111111
+
+.Llmain8_64:
+ ld t0, 0(a1)
+ ld t1, 8(a1)
+ ld t2, 16(a1)
+ ld t3, 24(a1)
+ sd t0, 0(a3)
+ sd t1, 8(a3)
+ sd t2, 16(a3)
+ sd t3, 24(a3)
+ ld t0, 32(a1)
+ ld t1, 40(a1)
+ ld t2, 48(a1)
+ ld t3, 56(a1)
+ sd t0, 32(a3)
+ sd t1, 40(a3)
+ sd t2, 48(a3)
+ sd t3, 56(a3)
+ addi a3, a3, 64
+ addi a1, a1, 64
+ bne a3, a4, .Llmain8_64
+.Llmain8_64_skip:
+
+ beqz a2, .Lreturn
+
+ /* a4 - uint64_t* end_align */
+
+ /* end_align = (dst + len) & ~0b111 */
+ add a4, a3, a2
+ andi a4, a4, ~0b111
+
+ /* len = len % 8 */
+ andi a2, a2, 0b111
+
+ beq a3, a4, .Llmain8_skip
+.Llmain8:
+ ld t0, (a1)
+ sd t0, (a3)
+ addi a3, a3, 8
+ addi a1, a1, 8
+ bne a3, a4, .Llmain8
+.Llmain8_skip:
+
+ la t1, .Lduff_end
+ slli t2, a2, 3
+ sub t1, t1, t2
+ jr t1
+END(memcpy)
diff --git a/lib/libc/riscv/string/memset.S b/lib/libc/riscv/string/memset.S
new file mode 100644
index 000000000000..ca435dfdd5c1
--- /dev/null
+++ b/lib/libc/riscv/string/memset.S
@@ -0,0 +1,95 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Strahinja Stanisic <strajabot@FreeBSD.org>
+ */
+
+#include <machine/asm.h>
+
+/*
+ * register a0 - void *dest
+ * register a1 - int c
+ * register a2 - size_t len
+ */
+ENTRY(memset)
+ andi a1, a1, 0xFF
+
+ sltiu t1, a2, 8
+ mv t0, a0
+ bnez t1, .Lend
+
+ li t1, 0x0101010101010101
+ mul a1, a1, t1
+
+ andi t1, a0, 0b111
+ andi t0, a0, ~0b111
+
+ beqz t1, .Lloop_store_64
+
+ la t2, .Lduff_start
+ slli t3, t1, 2
+ add t2, t2, t3
+ jr -4(t2)
+.Lduff_start:
+ sb a1, 1(t0)
+ sb a1, 2(t0)
+ sb a1, 3(t0)
+ sb a1, 4(t0)
+ sb a1, 5(t0)
+ sb a1, 6(t0)
+ sb a1, 7(t0)
+
+ /* a3 = a3 -(8-a) <=> a3 = a3 + (a-8) */
+ addi t1, t1, -8
+ add a2, a2, t1
+ addi t0, t0, 8
+
+.Lloop_store_64:
+ slti t1, a2, 64
+ bnez t1, .Lstore_rest
+ sd a1, 0(t0)
+ sd a1, 8(t0)
+ sd a1, 16(t0)
+ sd a1, 24(t0)
+ sd a1, 32(t0)
+ sd a1, 40(t0)
+ sd a1, 48(t0)
+ sd a1, 56(t0)
+ addi a2, a2, -64
+ addi t0, t0, 64
+ j .Lloop_store_64
+
+.Lstore_rest:
+ la t2, .Lduff_rest
+ andi t3, a2, ~0b111
+ srli t4, t3, 1
+ sub t2, t2, t4
+ jr t2
+ sd a1, 56(t0)
+ sd a1, 48(t0)
+ sd a1, 40(t0)
+ sd a1, 32(t0)
+ sd a1, 24(t0)
+ sd a1, 16(t0)
+ sd a1, 8(t0)
+ sd a1, 0(t0)
+.Lduff_rest:
+ add t0, t0, t3
+ sub a2, a2, t3
+
+.Lend:
+ slli a2, a2, 2
+ la t2, .Lduff_end
+ sub t2, t2, a2
+ jr t2
+ sb a1, 6(t0)
+ sb a1, 5(t0)
+ sb a1, 4(t0)
+ sb a1, 3(t0)
+ sb a1, 2(t0)
+ sb a1, 1(t0)
+ sb a1, (t0)
+.Lduff_end:
+ ret
+END(memset)
+
diff --git a/lib/libc/riscv/string/strchrnul.S b/lib/libc/riscv/string/strchrnul.S
new file mode 100644
index 000000000000..8abba71c4199
--- /dev/null
+++ b/lib/libc/riscv/string/strchrnul.S
@@ -0,0 +1,116 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Strahinja Stanisic <strajabot@FreeBSD.org>
+ */
+
+#include <machine/asm.h>
+
+ .weak strchrnul
+ .set strchrnul, __strchrnul
+
+/*
+ * a0 - const char *str
+ * a1 - int c;
+ */
+ENTRY(__strchrnul)
+ /*
+ * a0 - const char *ptr;
+ * a1 - char cccccccc[8];
+ * a2 - char iter[8];
+ * a3 - char mask_end
+ */
+
+ /* int to char */
+ andi a1, a1, 0xFF
+
+ /* t0 = 0x0101010101010101 */
+ li t0, 0x01010101
+ slli t1, t0, 32
+ or t0, t0, t1
+
+ /* t1 = 0x8080808080808080 */
+ slli t1, t0, 7
+
+ /* spread char across bytes */
+ mul a1, a1, t0
+
+ /* align_offset */
+ andi t2, a0, 0b111
+
+ /* align pointer */
+ andi a0, a0, ~0b111
+
+ /* if pointer is aligned skip to loop */
+ beqz t2, .Lloop
+
+ ld a2, (a0)
+
+ /* mask_start calculation */
+ slli t2, t2, 3
+ neg t2, t2
+ srl t2, t0, t2
+
+ /* fill bytes before start with non-zero */
+ or a3, a2, t2
+
+ xor a2, a2, a1
+ or a2, a2, t2
+
+ /* has_zero for \0 */
+ not t3, a3
+ not t2, a2
+ sub a3, a3, t0
+ sub a2, a2, t0
+ and a3, a3, t3
+ and a2, a2, t2
+ and a3, a3, t1
+ and a2, a2, t1
+
+
+ /* if \0 or c was found, exit */
+ or a2, a2, a3
+ addi a0, a0, 8
+ bnez a2, .Lfind_char
+
+
+.Lloop:
+ ld a2, (a0)
+
+ /* has_zero for both \0 or c */
+ xor a3, a2, a1
+
+ not t2, a2
+ not t3, a3
+ sub a2, a2, t0
+ sub a3, a3, t0
+ and a2, a2, t2
+ and a3, a3, t3
+ and a2, a2, t1
+ and a3, a3, t1
+
+ /* if \0 or c was found, exit */
+ or a2, a2, a3
+ addi a0, a0, 8
+ beqz a2, .Lloop
+
+.Lfind_char:
+ addi a0, a0, -8
+
+ /* isolate lowest set bit */
+ neg t0, a2
+ and a2, a2, t0
+
+ li t0, 0x0001020304050607
+ srli a2, a2, 7
+
+ /* lowest set bit is 2^(8*k)
+ * multiplying by it shifts the idx array in t0 by k bytes to the left */
+ mul a2, a2, t0
+
+ /* highest byte contains idx of first zero */
+ srli a2, a2, 56
+
+ add a0, a0, a2
+ ret
+END(__strchrnul)
diff --git a/lib/libc/riscv/string/strlen.S b/lib/libc/riscv/string/strlen.S
new file mode 100644
index 000000000000..3beb160f2e6f
--- /dev/null
+++ b/lib/libc/riscv/string/strlen.S
@@ -0,0 +1,77 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Strahinja Stanisic <strajabot@FreeBSD.org>
+ */
+
+#include <machine/asm.h>
+
+/*
+ * https://graphics.stanford.edu/~seander/bithacks.html#ZeroInWord
+ * uses haszero(v) (((v) - 0x01010101UL) & ~(v) & 0x80808080UL)
+ * which evalutates > 0 when there is zero in v
+ *
+ * register a0 - char *s
+ */
+ENTRY(strlen)
+ /*
+ * register a0 - char *str_start
+ * register a1 - char *str_ptr
+ * register a2 - char[8] iter
+ */
+
+ /* load constants for haszero */
+ li t0, 0x0101010101010101
+ slli t1, t0, 7 # 0x8080808080808080, avoid li
+
+ /* check alignment of str_start */
+ andi a1, a0, ~0b111
+ ld a2, (a1)
+ beq a1, a0, .Lhas_zero
+
+ /* fill bytes before str_start with non-zero */
+ slli t2, a0, 3
+ addi t3, t2, -64
+ neg t3, t3
+ srl t3, t0, t3
+ or a2, a2, t3
+
+ /* unrolled iteration of haszero */
+ not t2, a2
+ sub a2, a2, t0
+ and a2, a2, t2
+ and a2, a2, t1
+
+ bnez a2, .Lfind_zero
+
+.Lloop_has_zero:
+ ld a2, 8(a1)
+ addi a1, a1, 8 # move ptr to next 8byte
+.Lhas_zero:
+ not t2, a2
+ sub a2, a2, t0
+ and a2, a2, t2
+ and a2, a2, t1
+
+ beqz a2, .Lloop_has_zero
+
+.Lfind_zero:
+ /* use (iter & -iter) to isolate lowest set bit */
+ sub a3, zero, a2 #a3 = -iter
+ and t1, a2, a3 #t1 = (iter & -iter)
+
+ li t0, 0x0001020304050607
+ srli t1, t1, 7
+ /*
+ * lowest set bit is 2^(8*k)
+ * multiplying by it shifts the idx array in t0 by k bytes to the left
+ */
+ mul t1, t1, t0
+ /* highest byte contains idx of first zero */
+ srli t1, t1, 56
+
+ add a1, a1, t1
+ sub a0, a1, a0
+ ret
+END(strlen)
+
diff --git a/lib/libc/riscv/string/strnlen.S b/lib/libc/riscv/string/strnlen.S
new file mode 100644
index 000000000000..c0fd959548ff
--- /dev/null
+++ b/lib/libc/riscv/string/strnlen.S
@@ -0,0 +1,143 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Strahinja Stanisic <strajabot@FreeBSD.org>
+ */
+
+#include <machine/asm.h>
+
+/*
+ * a0 - const char *s
+ * a1 - size_t maxlen;
+ */
+ENTRY(strnlen)
+ /*
+ * a0 - const char *s;
+ * a1 - size_t maxlen;
+ * a2 - uint64_t *ptr;
+ * a3 - char iter[8];
+ * a4 - uint64_t *end_align;
+ * a5 - uint64_t *end_unroll;
+ */
+
+ beqz a1, .Lnot_found
+
+ /* ptr = s & ~0b111 */
+ /* t0 = 0x0101010101010101 */
+ /* t1 = 0x8080808080808080 */
+ /* end_align = (s + maxlen + 7) & ~0b111 */
+ /* mask_start = t0 >> ((-s.value) << 3) */
+ add a4, a0, a1
+ li t0, 0x01010101
+ addi a4, a4, 7
+ slli t1, t0, 32
+ neg t2, a0
+ andi a4, a4, ~0b111
+ or t0, t0, t1
+ slli t2, t2, 3
+ andi a2, a0, ~0b111
+ slli t1, t0, 7
+ srl t2, t0, t2
+
+ /* if pointer is aligned skip to loop */
+ beq a0, a2, .Lskip_start
+
+ /* iter = *ptr */
+ ld a3, (a2)
+
+ /* iter = iter | mask_start */
+ or a3, a3, t2
+
+ /* has_zero */
+ not t2, a3
+ sub a3, a3, t0
+ and t2, t2, t1
+ and a3, a3, t2
+
+ addi a2, a2, 8
+ bnez a3, .Lfind_zero
+
+.Lskip_start:
+ /* end_unroll */
+ sub t2, a4, a2
+ andi t2, t2, ~0b1111
+ add a5, a2, t2
+
+ /* while (ptr != end_unroll) */
+ beq a2, a5, .Lskip_loop
+.Lloop:
+ ld a3, (a2)
+ ld a6, 8(a2)
+
+ /* has_zero */
+ not t2, a3
+ not t3, a6
+ sub a3, a3, t0
+ sub a6, a6, t0
+ and t2, t2, t1
+ and t3, t3, t1
+ and a3, a3, t2
+ and a6, a6, t3
+
+ addi a2, a2, 8
+ bnez a3, .Lfind_zero
+
+ mv a3, a6
+
+ addi a2, a2, 8
+ bnez a3, .Lfind_zero
+
+ bne a2, a5, .Lloop
+
+.Lskip_loop:
+
+ beq a2, a4, .Lnot_found
+
+ ld a3, (a2)
+
+ /* has_zero */
+ not t2, a3
+ sub a3, a3, t0
+ and t2, t2, t1
+ and a3, a3, t2
+
+
+ addi a2, a2, 8
+ beqz a3, .Lnot_found
+
+.Lfind_zero:
+
+ /* move ptr back */
+ addi a2, a2, -8
+
+ /* isolate lowest set bit */
+ neg t0, a3
+ and a3, a3, t0
+
+ li t0, 0x0001020304050607
+ srli a3, a3, 7
+
+ /* lowest set bit is 2^(8*k)
+ * multiplying by it shifts the idx array in t0 by k bytes to the left */
+ mul a3, a3, t0
+
+ /* highest byte contains idx of first zero */
+ srli a3, a3, 56
+
+ /* zero_idx */
+ sub a2, a2, a0
+ add a2, a2, a3
+
+ /* min(zero_idx, maxlen) */
+ sub a2, a2, a1
+ srai t1, a2, 63
+ and a2, a2, t1
+ add a0, a1, a2
+
+ ret
+
+.Lnot_found:
+ mv a0, a1
+ ret
+
+END(strnlen)
diff --git a/lib/libc/riscv/string/strrchr.S b/lib/libc/riscv/string/strrchr.S
new file mode 100644
index 000000000000..e922a692e77f
--- /dev/null
+++ b/lib/libc/riscv/string/strrchr.S
@@ -0,0 +1,127 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2024 Strahinja Stanisic <strajabot@FreeBSD.org>
+ */
+
+#include <machine/asm.h>
+
+ .weak rindex
+ .set rindex, strrchr
+
+/*
+ * a0 - const char *s
+ * a1 - int c
+ */
+ENTRY(strrchr)
+ /*
+ * a0 - const char *ptr_align
+ * a1 - temporary
+ * a2 - temporary
+ * a3 - temporary
+ * a4 - temporary
+ * a5 - const char[8] cccccccc
+ * a6 - const uint64_t *save_align
+ * a7 - const uint64_t save_iter
+ * t0 - const uintr64_t REP8_0X01
+ * t1 - const uintr64_t REP8_0X80
+ */
+
+ /*
+ * save_align = 0
+ * save_iter = 0xFFFFFFFFFFFFFF00
+ * REP8_0X01 = 0x0101010101010101
+ * cccccccc = (char)c * REP8_0X01
+ * REP8_0X80 = (REP8_0X80 << 7) << ((str % 8) * 8)
+ * ptr_align = str - str % 8
+ */
+ li t0, 0x01010101
+ li a6, 0
+ slli a2, a0, 3
+ slli t1, t0, 32
+ li a7, 0xFFFFFFFFFFFFFF00
+ or t0, t0, t1
+ andi a1, a1, 0xFF
+ slli t1, t0, 7
+ andi a0, a0, ~0b111
+ mul a5, a1, t0
+ sll t1, t1, a2
+
+.Lloop: /* do { */
+ ld a1, 0(a0) /* a1 -> data = *ptr_align */
+ not a3, a1 /* a3 -> nhz = ~data */
+ xor a2, a1, a5 /* a2 -> iter = data ^ cccccccc */
+ sub a1, a1, t0 /* a1 -> hz = data - REP8_0X01 */
+ not a4, a2 /* a4 -> nhc = ~iter */
+ and a1, a1, a3 /* hz = hz & nhz */
+ sub a3, a2, t0 /* a3 -> hc = iter - REP8_0X01 */
+ and a1, a1, t1 /* hz = hz & REP8_0X80 */
+ and a3, a3, a4 /* hc = hc & nhc */
+ addi a4, a1, -1 /* a4 -> mask_end = hz - 1 */
+ and a3, a3, t1 /* hc = hc & REP8_0X80 */
+ xor a4, a4, a1 /* mask_end = mask_end ^ hz */
+ addi a0, a0, 8 /* ptr_align = ptr_align + 8 */
+ and a3, a3, a4 /* hc = hc & mask_end */
+ slli t1, t0, 7 /* REP8_0X80 = REP8_0X01 << 7 */
+ not a4, a4 /* mask_end = ~mask_end */
+
+ beqz a3, .Lskip_save /* if(!hc) goto skip_save */
+ or a2, a2, a4 /* iter = iter | mask_end */
+ addi a6, a0, -8 /* save_align = ptr_align - 8 */
+ mv a7, a2 /* save_iter = iter */
+
+.Lskip_save:
+ beqz a1, .Lloop /* } while(!hz) */
+
+.Lfind_char:
+ /*
+ * a1 -> iter = save_iter
+ * a2 -> mask_iter = 0xFF00000000000000
+ * a3 -> match_off = 7
+ */
+ li a2, 0xFF
+ mv a1, a7
+ slli a2, a2, 56
+ li a3, 7
+
+ and a0, a1, a2
+ srli a2, a2, 8
+ beqz a0, .Lret
+
+ addi a3, a3, -1
+ and a0, a1, a2
+ srli a2, a2, 8
+ beqz a0, .Lret
+
+ addi a3, a3, -1
+ and a0, a1, a2
+ srli a2, a2, 8
+ beqz a0, .Lret
+
+ addi a3, a3, -1
+ and a0, a1, a2
+ srli a2, a2, 8
+ beqz a0, .Lret
+
+ addi a3, a3, -1
+ and a0, a1, a2
+ srli a2, a2, 8
+ beqz a0, .Lret
+
+ addi a3, a3, -1
+ and a0, a1, a2
+ srli a2, a2, 8
+ beqz a0, .Lret
+
+ addi a3, a3, -1
+ and a0, a1, a2
+ srli a2, a2, 8
+ beqz a0, .Lret
+
+ addi a3, a3, -1
+
+.Lret:
+ /* return save_align + match_offset */
+ add a0, a6, a3
+ ret
+END(strrchr)
diff --git a/lib/libpam/static_libpam/Makefile b/lib/libpam/static_libpam/Makefile
index 8830f09ef0da..703e6a4a2f00 100644
--- a/lib/libpam/static_libpam/Makefile
+++ b/lib/libpam/static_libpam/Makefile
@@ -45,6 +45,7 @@ MAN=
MANNODEV=
INCS=
MLINKS=
+MANNODEVLINKS=
MK_TESTS= no
#
diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c
index 17576066fcfd..e739e55033e2 100644
--- a/lib/libpfctl/libpfctl.c
+++ b/lib/libpfctl/libpfctl.c
@@ -2597,6 +2597,101 @@ pfctl_table_del_addrs_h(struct pfctl_handle *h, struct pfr_table *tbl, struct pf
return (ret);
}
+struct pfctl_change {
+ int add;
+ int del;
+ int change;
+};
+#define _OUT(_field) offsetof(struct pfctl_change, _field)
+static struct snl_attr_parser ap_table_set_addr[] = {
+ { .type = PF_TA_NBR_ADDED, .off = _OUT(add), .cb = snl_attr_get_uint32 },
+ { .type = PF_TA_NBR_DELETED, .off = _OUT(del), .cb = snl_attr_get_uint32 },
+ { .type = PF_TA_NBR_CHANGED, .off = _OUT(change), .cb = snl_attr_get_uint32 },
+};
+#undef _OUT
+SNL_DECLARE_PARSER(table_set_addr_parser, struct genlmsghdr, snl_f_p_empty, ap_table_set_addr);
+
+static int
+_pfctl_table_set_addrs_h(struct pfctl_handle *h, struct pfr_table *tbl, struct pfr_addr
+ *addrs, int size, int *nadd, int *ndel, int *nchange, int flags)
+{
+ struct snl_writer nw;
+ struct snl_errmsg_data e = {};
+ struct nlmsghdr *hdr;
+ struct pfctl_change change = { 0 };
+ uint32_t seq_id;
+ int family_id;
+
+ family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
+ if (family_id == 0)
+ return (ENOTSUP);
+
+ snl_init_writer(&h->ss, &nw);
+ hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_TABLE_SET_ADDR);
+
+ snl_add_msg_attr_table(&nw, PF_TA_TABLE, tbl);
+ snl_add_msg_attr_u32(&nw, PF_TA_FLAGS, flags);
+ for (int i = 0; i < size; i++)
+ snl_add_msg_attr_pfr_addr(&nw, PF_TA_ADDR, &addrs[i]);
+
+ if ((hdr = snl_finalize_msg(&nw)) == NULL)
+ return (ENXIO);
+ seq_id = hdr->nlmsg_seq;
+
+ if (! snl_send_message(&h->ss, hdr))
+ return (ENXIO);
+
+ while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) {
+ if (! snl_parse_nlmsg(&h->ss, hdr, &table_set_addr_parser, &change))
+ continue;
+ }
+
+ if (nadd)
+ *nadd = change.add;
+ if (ndel)
+ *ndel = change.del;
+ if (nchange)
+ *nchange = change.change;
+
+ return (e.error);
+}
+
+int
+pfctl_table_set_addrs_h(struct pfctl_handle *h, struct pfr_table *tbl,
+ struct pfr_addr *addr, int size, int *nadd, int *ndel,
+ int *nchange, int flags)
+{
+ int ret;
+ int off = 0;
+ int partial_add, partial_del, partial_change;
+ int chunk_size;
+
+ do {
+ flags &= ~(PFR_FLAG_START | PFR_FLAG_DONE);
+ if (off == 0)
+ flags |= PFR_FLAG_START;
+ chunk_size = MIN(size - off, 256);
+ if ((chunk_size + off) == size)
+ flags |= PFR_FLAG_DONE;
+ ret = _pfctl_table_set_addrs_h(h, tbl, &addr[off], chunk_size,
+ &partial_add, &partial_del, &partial_change, flags);
+ if (ret != 0)
+ break;
+ if (! (flags & PFR_FLAG_DONE)) {
+ assert(partial_del == 0);
+ }
+ if (nadd)
+ *nadd += partial_add;
+ if (ndel)
+ *ndel += partial_del;
+ if (nchange)
+ *nchange += partial_change;
+ off += chunk_size;
+ } while (off < size);
+
+ return (ret);
+}
+
int
pfctl_table_set_addrs(int dev, struct pfr_table *tbl, struct pfr_addr
*addr, int size, int *size2, int *nadd, int *ndel, int *nchange, int flags)
diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h
index 5880e1a88371..ae4b18dabe75 100644
--- a/lib/libpfctl/libpfctl.h
+++ b/lib/libpfctl/libpfctl.h
@@ -523,7 +523,10 @@ int pfctl_table_del_addrs_h(struct pfctl_handle *h, struct pfr_table *tbl,
struct pfr_addr *addr, int size, int *ndel, int flags);
int pfctl_table_del_addrs(int dev, struct pfr_table *tbl, struct pfr_addr
*addr, int size, int *ndel, int flags);
-int pfctl_table_set_addrs(int dev, struct pfr_table *tbl, struct pfr_addr
+int pfctl_table_set_addrs_h(struct pfctl_handle *h, struct pfr_table *tbl,
+ struct pfr_addr *addr, int size, int *nadd, int *ndel,
+ int *nchange, int flags);
+int pfctl_table_set_addrs(int dev, struct pfr_table *tbl, struct pfr_addr
*addr, int size, int *size2, int *nadd, int *ndel, int *nchange,
int flags);
int pfctl_table_get_addrs(int dev, struct pfr_table *tbl, struct pfr_addr
diff --git a/lib/libsys/pathconf.2 b/lib/libsys/pathconf.2
index 5a983a3a13e2..5348128be706 100644
--- a/lib/libsys/pathconf.2
+++ b/lib/libsys/pathconf.2
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd August 6, 2025
+.Dd October 31, 2025
.Dt PATHCONF 2
.Os
.Sh NAME
@@ -180,7 +180,8 @@ Return 1 if named attributes are enabled for the file system, otherwise 0.
.It Li _PC_HAS_NAMEDATTR
Return 1 if one or more named attributes exist for the file, otherwise 0.
.It Li _PC_HAS_HIDDENSYSTEM
-Return 1 if both
+Return 1 if all of the
+.Dv UF_ARCHIVE ,
.Dv UF_HIDDEN
and
.Dv UF_SYSTEM
@@ -192,6 +193,9 @@ Returns the block size required for block cloning via
.Xr copy_file_range 2
for a file system if block cloning is supported,
otherwise 0.
+.It Li _PC_CASE_INSENSITIVE
+Return 1 if the file system performs case insensitive lookups,
+otherwise 0.
.El
.Sh RETURN VALUES
If the call to
diff --git a/lib/libsys/revoke.2 b/lib/libsys/revoke.2
index f5ae1e92c357..938d2f083e27 100644
--- a/lib/libsys/revoke.2
+++ b/lib/libsys/revoke.2
@@ -28,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 25, 2016
+.Dd October 24, 2025
.Dt REVOKE 2
.Os
.Sh NAME
@@ -62,7 +62,7 @@ using a special close method which does not block.
Access to a file may be revoked only by its owner or the super user.
The
.Fn revoke
-system call is currently supported only for block and character special
+system call is currently supported only for character special
device files.
It is normally used to prepare a terminal device for a new login session,
preventing any access by a previous user of the terminal.
diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr
index 8317ff5c0922..e4ad14f582d6 100644
--- a/libexec/rc/rc.subr
+++ b/libexec/rc/rc.subr
@@ -121,11 +121,22 @@ dotted=
dot()
{
local f verify
+ local dot_dir dot_file
o_verify_set off verify
for f in "$@"; do
if [ -f $f -a -s $f ]; then
dotted="$dotted $f"
+ case $f in
+ */*)
+ dot_dir=${f%/*}
+ dot_file=${f##*/}
+ ;;
+ *)
+ dot_dir=.
+ dot_file=$f
+ ;;
+ esac
. $f
fi
done
@@ -152,8 +163,7 @@ vdot()
for f in "$@"; do
[ -f $f -a -s $f ] || continue
if is_verified $f 2> /dev/null; then
- dotted="$dotted $f"
- . $f
+ dot $f
else
rc=80 # EAUTH
fi
diff --git a/release/Makefile.vm b/release/Makefile.vm
index 336e8fc82299..a04f779ebebb 100644
--- a/release/Makefile.vm
+++ b/release/Makefile.vm
@@ -101,10 +101,13 @@ QEMUTGT=emulator-portinstall
.endif
QEMUTGT?=
+.if (defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE)) || \
+ (defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES))
.if (defined(WITHOUT_QEMU) && !defined(NO_ROOT)) || \
(!defined(WITHOUT_QEMU) && defined(NO_ROOT))
.error WITHOUT_QEMU requires NO_ROOT (and vice versa)
.endif
+.endif
.if defined(WITH_CLOUDWARE) && !empty(WITH_CLOUDWARE) && !empty(CLOUDWARE)
. for _CW in ${CLOUDWARE}
diff --git a/release/tools/gce.conf b/release/tools/gce.conf
index a7ccfc27a75c..b0a65c2981e1 100644
--- a/release/tools/gce.conf
+++ b/release/tools/gce.conf
@@ -21,7 +21,7 @@ vm_extra_install_base() {
echo 'search google.internal' > ${DESTDIR}/etc/resolv.conf
echo 'nameserver 169.254.169.254' >> ${DESTDIR}/etc/resolv.conf
echo 'nameserver 8.8.8.8' >> ${DESTDIR}/etc/resolv.conf
- metalog_add ./etc/resolv.conf
+ metalog_add_data ./etc/resolv.conf
}
vm_extra_pre_umount() {
diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8
index d4f8d2b5747a..627b7cd3f9e3 100644
--- a/sbin/ifconfig/ifconfig.8
+++ b/sbin/ifconfig/ifconfig.8
@@ -630,6 +630,9 @@ This is useful for devices which have multiple physical layer interfaces
.It Cm name Ar name
Set the interface name to
.Ar name .
+The
+.Ar name
+may not be longer than 15 characters.
.It Cm rxcsum , txcsum , rxcsum6 , txcsum6
If the driver supports user-configurable checksum offloading,
enable receive (or transmit) checksum offloading on the interface.
diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c
index 3d2632c1cf74..02d6c9c84a32 100644
--- a/sbin/pfctl/pfctl.c
+++ b/sbin/pfctl/pfctl.c
@@ -2618,6 +2618,8 @@ pfctl_apply_limit(struct pfctl *pf, const char *opt, unsigned int limit)
int
pfctl_load_limit(struct pfctl *pf, unsigned int index, unsigned int limit)
{
+ static int restore_limit_handler_armed = 0;
+
if (pfctl_set_limit(pf->h, index, limit)) {
if (errno == EBUSY)
warnx("Current pool size exceeds requested %s limit %u",
@@ -2626,6 +2628,9 @@ pfctl_load_limit(struct pfctl *pf, unsigned int index, unsigned int limit)
warnx("Cannot set %s limit to %u",
pf_limits[index].name, limit);
return (1);
+ } else if (restore_limit_handler_armed == 0) {
+ atexit(pfctl_restore_limits);
+ restore_limit_handler_armed = 1;
}
return (0);
}
@@ -3474,7 +3479,6 @@ main(int argc, char *argv[])
if ((opts & PF_OPT_NOACTION) == 0) {
pfctl_read_limits(pfh);
- atexit(pfctl_restore_limits);
}
if (opts & PF_OPT_DISABLE)
diff --git a/sbin/pfctl/pfctl.h b/sbin/pfctl/pfctl.h
index 136f51ea08f9..c540c6348d84 100644
--- a/sbin/pfctl/pfctl.h
+++ b/sbin/pfctl/pfctl.h
@@ -110,7 +110,7 @@ int pfr_clr_astats(struct pfr_table *, struct pfr_addr *, int, int *, int);
int pfr_clr_addrs(struct pfr_table *, int *, int);
int pfr_add_addrs(struct pfr_table *, struct pfr_addr *, int, int *, int);
int pfr_del_addrs(struct pfr_table *, struct pfr_addr *, int, int *, int);
-int pfr_set_addrs(struct pfr_table *, struct pfr_addr *, int, int *,
+int pfr_set_addrs(struct pfr_table *, struct pfr_addr *, int,
int *, int *, int *, int);
int pfr_get_addrs(struct pfr_table *, struct pfr_addr *, int *, int);
int pfr_get_astats(struct pfr_table *, struct pfr_astats *, int *, int);
diff --git a/sbin/pfctl/pfctl_radix.c b/sbin/pfctl/pfctl_radix.c
index 98f907738d95..3b7161420e33 100644
--- a/sbin/pfctl/pfctl_radix.c
+++ b/sbin/pfctl/pfctl_radix.c
@@ -163,11 +163,11 @@ pfr_del_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size,
int
pfr_set_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size,
- int *size2, int *nadd, int *ndel, int *nchange, int flags)
+ int *nadd, int *ndel, int *nchange, int flags)
{
int ret;
- ret = pfctl_table_set_addrs(dev, tbl, addr, size, size2, nadd, ndel,
+ ret = pfctl_table_set_addrs_h(pfh, tbl, addr, size, nadd, ndel,
nchange, flags);
if (ret) {
errno = ret;
diff --git a/sbin/pfctl/pfctl_table.c b/sbin/pfctl/pfctl_table.c
index 4955e1791fd7..aae347712547 100644
--- a/sbin/pfctl/pfctl_table.c
+++ b/sbin/pfctl/pfctl_table.c
@@ -236,17 +236,8 @@ pfctl_table(int argc, char *argv[], char *tname, const char *command,
CREATE_TABLE;
if (opts & PF_OPT_VERBOSE)
flags |= PFR_FLAG_FEEDBACK;
- for (;;) {
- int sz2 = b.pfrb_msize;
-
- RVTEST(pfr_set_addrs(&table, b.pfrb_caddr, b.pfrb_size,
- &sz2, &nadd, &ndel, &nchange, flags));
- if (sz2 <= b.pfrb_msize) {
- b.pfrb_size = sz2;
- break;
- } else
- pfr_buf_grow(&b, sz2);
- }
+ RVTEST(pfr_set_addrs(&table, b.pfrb_caddr, b.pfrb_size,
+ &nadd, &ndel, &nchange, flags));
if (nadd)
xprintf(opts, "%d addresses added", nadd);
if (ndel)
diff --git a/share/man/man4/ddb.4 b/share/man/man4/ddb.4
index 3c4894c03d62..a882a5204fb2 100644
--- a/share/man/man4/ddb.4
+++ b/share/man/man4/ddb.4
@@ -24,7 +24,7 @@
.\" any improvements or extensions that they make and grant Carnegie Mellon
.\" the rights to redistribute these changes.
.\"
-.Dd June 10, 2025
+.Dd October 31, 2025
.Dt DDB 4
.Os
.Sh NAME
@@ -604,12 +604,15 @@ The
modifier will print command line arguments for each process.
.\"
.Pp
-.It Ic show Cm all tcpcbs Ns Op Li / Ns Cm b Ns Cm l
+.It Ic show Cm all tcpcbs Ns Op Li / Ns Cm b Ns Cm i Ns Cm l
Show the same output as "show tcpcb" does, but for all
TCP control blocks within the system.
The
.Cm b
modifier will request BBLog entries to be printed.
+If the
+.Cm i
+modifier is provided, the corresponding IP control block is also shown.
Using the
.Cm l
modifier will limit the output to TCP control blocks, which are locked.
@@ -1106,7 +1109,7 @@ on i386.)
Not present on some platforms.
.\"
.Pp
-.It Ic show Cm tcpcb Ns Oo Li / Ns Cm b Oc Ar addr
+.It Ic show Cm tcpcb Ns Oo Li / Ns Cm b Ns Cm i Oc Ar addr
Print TCP control block
.Vt struct tcpcb
lying at address
@@ -1117,6 +1120,9 @@ header file.
The
.Cm b
modifier will request BBLog entries to be printed.
+If the
+.Cm i
+modifier is provided, the corresponding IP control block is also shown.
.\"
.Pp
.It Ic show Cm thread Op Ar addr | tid
diff --git a/share/man/man4/dtrace_io.4 b/share/man/man4/dtrace_io.4
index 30ec44768fbf..1699cebab8e9 100644
--- a/share/man/man4/dtrace_io.4
+++ b/share/man/man4/dtrace_io.4
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd April 18, 2015
+.Dd October 26, 2025
.Dt DTRACE_IO 4
.Os
.Sh NAME
@@ -84,7 +84,7 @@ The following script shows a per-process breakdown of total I/O by disk device:
io:::start
{
- @[args[1]->device_name, execname, pid] = sum(args[0]->bio_bcount);
+ @[args[1]->device_name, execname, pid] = sum(args[0]->bio_length);
}
END
diff --git a/share/man/man4/u3g.4 b/share/man/man4/u3g.4
index 51c883b8378e..c7bf1f98880a 100644
--- a/share/man/man4/u3g.4
+++ b/share/man/man4/u3g.4
@@ -94,14 +94,14 @@ Qualcomm Inc. GOBI 1000, 2000 and 3000 devices with MDM1000 or MDM2000 chipsets
.It
QUECTEL BGX, ECX, EGX, EMX, EPX, RGX series
.It
-Quectel EM160R
+Quectel EM160R, EM060K
.Pq see Sx CAVEATS
.It
Huawei B190, E180v, E220, E3372, E3372v153, E5573Cs322, ('<Huawei Mobile>')
.It
Novatel U740, MC950D, X950D, etc.
.It
-Sierra MC875U, MC8775U, etc.
+Sierra MC875U, MC8775U, EM7590, etc.
.It
Panasonic CF-F9 GOBI
.El
diff --git a/share/man/man5/style.Makefile.5 b/share/man/man5/style.Makefile.5
index fe8754924575..9a2f1b069d99 100644
--- a/share/man/man5/style.Makefile.5
+++ b/share/man/man5/style.Makefile.5
@@ -1,7 +1,7 @@
.\"
.\" SPDX-License-Identifier: BSD-3-Clause
.\"
-.\" Copyright (c) 2002-2003, 2023 David O'Brien <obrien@FreeBSD.org>
+.\" Copyright (c) 2002-2003, 2023, 2025 David O'Brien <deo@NUXI.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd July 17, 2023
+.Dd October 29, 2025
.Dt STYLE.MAKEFILE 5
.Os
.Sh NAME
@@ -179,6 +179,21 @@ settings between the
and
.Fl I Ns 's.
.It
+Lists that span more than one line should be formatted as follows:
+.Bd -literal -offset indent
+SRCS+=<SP>\\
+<TAB>main.c<SP>\\
+<TAB>trace.c<SP>\\
+<TAB>zoo.c \\
+\&
+.Ed
+Specifically, the last item in the list should have a trailing '\\'.
+This is to avoid causing a "false diff" or "false blame" when
+a new item is appended at the end.
+In general the list should be English language alphabetized.
+A list of libraries or header inclusion paths are notable exceptions
+if needed for proper building.
+.It
Do not use GCCisms (such as
.Fl g
and
@@ -233,9 +248,6 @@ For variables that are only checked with
.Fn defined ,
do not provide any fake value.
.El
-.Pp
-The desire to express a logical grouping often means not obeying some of the
-above.
.Sh EXAMPLES
The simplest program
.Pa Makefile
@@ -270,5 +282,7 @@ manual page and first appeared in
.An David O'Brien Aq deo@NUXI.org
.Sh BUGS
There are few hard and fast style rules here.
+The desire to express a logical grouping sometimes means not obeying some of the
+above.
The style of many things is too dependent on the context of the whole makefile,
or the lines surrounding it.
diff --git a/share/man/man7/d.7 b/share/man/man7/d.7
index 4b00d3d71c79..59b3389b121b 100644
--- a/share/man/man7/d.7
+++ b/share/man/man7/d.7
@@ -198,6 +198,130 @@ The number of nanoseconds since the Epoch
Suitable for timestamping logs.
.El
.Sh BUILT-IN FUNCTIONS
+.\" Keep the indentation wide enough for the reader to be able to skim through
+.\" function names quickly.
+.Bl -tag -width "size_t strlen"
+.It Ft string Fn strchr "string s" "char c"
+Return a substring of
+.Fa s
+starting at the first occurance of
+.Fa c
+in
+.Fa s .
+Return
+.Dv NULL
+if
+.Fa c
+does not occur in
+.Fa s .
+.Pp
+For example,
+.Bd -literal -compact -offset indent
+strchr("abc", 'b');
+.Ed
+returns
+.Ql "bc"
+and
+.Bd -literal -compact -offset indent
+strchr("abc", 'd');
+.Ed
+returns
+.Dv NULL .
+.It Ft string Fn strjoin "string s1" "string s2"
+Return a string resulting from concatenating
+.Fa s1
+and
+.Fa s2 .
+.Pp
+For example,
+.Bd -literal -compact -offset indent
+strjoin("abc", "def")
+.Ed
+returns
+.Ql abcdef .
+.It Ft string Fn strrchr "string s" "char c"
+Return a substring of
+.Fa s
+starting at the last occurance of
+.Fa c
+in
+.Fa s .
+Similar to
+.Fn strchr .
+.It Ft string Fn strstr "string haystack" "string needle"
+Return a substring of
+.Fa haystack
+starting at the first occurrence of
+.Fa needle .
+Return
+.Dv NULL
+if
+.Fa needle
+is not a substring of
+.Fa haystack .
+.Pp
+For example,
+.Bd -literal -compact -offset indent
+strstr("abc1bc2", "bc")
+.Ed
+returns
+.Ql bc1bc2
+and
+.Bd -literal -compact -offset indent
+strstr("abc", "xy")
+.Ed
+returns
+.Dv NULL .
+.It Ft string Fn strtok "string s" "string separators"
+Tokenize
+.Fa s
+with
+.Fa separators .
+.Pp
+For example,
+.Bd -literal -compact -offset indent
+strtok("abcdefg", "xyzd")
+.Ed
+returns
+.Ql abc .
+.It Ft size_t Fn strlen "string s"
+Return the length of string
+.Fa s .
+.It Ft string Fn substr "string s" "int position" "[int length]"
+Return a
+substring of string
+.Fa s
+starting at
+.Fa position .
+The substring will be at most
+.Fa length Ns -long .
+If
+.Fa length
+is not specified, use the rest of the string.
+If
+.Fa position
+is greater than
+the size of
+.Fa s ,
+return an empty string.
+.Pp
+For example,
+.Bd -literal -compact -offset indent
+substr("abcd", 2)
+.Ed
+returns
+.Ql cd ,
+.Bd -literal -compact -offset indent
+substr("abcd", 2, 1)
+.Ed
+returns
+.Ql c ,
+and
+.Bd -literal -compact -offset indent
+substr("abcd", 99)
+.Ed
+returns an empty string.
+.El
.Ss Aggregation Functions
.Bl -tag -compact -width "llquantize(value, factor, low, high, nsteps)"
.It Fn avg value
diff --git a/share/man/man7/simd.7 b/share/man/man7/simd.7
index d5092348d9b3..3343508df504 100644
--- a/share/man/man7/simd.7
+++ b/share/man/man7/simd.7
@@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE
.
-.Dd November 18, 2024
+.Dd October 21, 2025
.Dt SIMD 7
.Os
.Sh NAME
@@ -50,38 +50,38 @@ can be used to override this mechanism.
.Pp
Enhanced functions are present for the following architectures:
.Bl -column FUNCTION_________ aarch64_ arm_ amd64_ i386_ ppc64_ -offset indent
-.It Em FUNCTION Ta Em AARCH64 Ta Em ARM Ta Em AMD64 Ta Em I386 Ta Em PPC64
+.It Em FUNCTION Ta Em AARCH64 Ta Em ARM Ta Em AMD64 Ta Em I386 Ta Em PPC64 Ta Em RISC-V
.It bcmp Ta A Ta Ta S1 Ta S
-.It bcopy Ta A Ta S Ta S Ta S Ta SV
-.It bzero Ta A Ta S Ta S Ta S
+.It bcopy Ta A Ta S Ta S Ta S Ta SV Ta S
+.It bzero Ta A Ta S Ta S Ta S Ta Ta S
.It div Ta Ta Ta S Ta S
-.It index Ta A Ta Ta S1
+.It index Ta A Ta Ta S1 Ta Ta S
.It ldiv Ta Ta Ta S Ta S
.It lldiv Ta Ta Ta S
-.It memchr Ta A Ta Ta S1
+.It memchr Ta A Ta Ta S1 Ta Ta Ta S
.It memcmp Ta A Ta S Ta S1 Ta S
.It memccpy Ta A Ta Ta S1
-.It memcpy Ta A Ta S Ta S Ta S Ta SV
+.It memcpy Ta A Ta S Ta S Ta S Ta SV Ta S
.It memmove Ta A Ta S Ta S Ta S Ta SV
.It memrchr Ta A Ta Ta S1
-.It memset Ta A Ta S Ta S Ta S
-.It rindex Ta A Ta Ta S1 Ta S
+.It memset Ta A Ta S Ta S Ta S Ta Ta S
+.It rindex Ta A Ta Ta S1 Ta S Ta Ta S
.It stpcpy Ta A Ta Ta S1
.It stpncpy Ta Ta Ta S1
.It strcat Ta A Ta Ta S1 Ta S
-.It strchr Ta A Ta Ta S1 Ta S
-.It strchrnul Ta A Ta Ta S1
+.It strchr Ta A Ta Ta S1 Ta S Ta Ta S
+.It strchrnul Ta A Ta Ta S1 Ta Ta Ta S
.It strcmp Ta A Ta S Ta S1 Ta S
.It strcpy Ta A Ta Ta S1 Ta S Ta S2
.It strcspn Ta S Ta Ta S2
.It strlcat Ta A Ta Ta S1
.It strlcpy Ta A Ta Ta S1
-.It strlen Ta A Ta S Ta S1
+.It strlen Ta A Ta S Ta S1 Ta Ta Ta S
.It strncat Ta A Ta Ta S1
.It strncmp Ta A Ta S Ta S1 Ta S
.It strncpy Ta Ta Ta S1 Ta Ta S2
-.It strnlen Ta A Ta Ta S1
-.It strrchr Ta A Ta Ta S1 Ta S
+.It strnlen Ta A Ta Ta S1 Ta Ta Ta S
+.It strrchr Ta A Ta Ta S1 Ta S Ta Ta S
.It strpbrk Ta S Ta Ta S2
.It strsep Ta S Ta Ta S2
.It strspn Ta S Ta Ta S2
@@ -207,10 +207,13 @@ for
.Fx 11.0
for
.Cm aarch64 ,
-and
.Fx 12.0
for
-.Cm powerpc64 .
+.Cm powerpc64 ,
+and
+.Fx 16.0
+for
+.Cm riscv64 .
SIMD-enhanced functions were first added with
.Fx 13.0
for
diff --git a/share/man/man9/atomic.9 b/share/man/man9/atomic.9
index c9133c6311a5..b027a0ff0bca 100644
--- a/share/man/man9/atomic.9
+++ b/share/man/man9/atomic.9
@@ -182,35 +182,42 @@ This variant is the default.
The second variant has acquire semantics, and the third variant has release
semantics.
.Pp
-When an atomic operation has acquire semantics, the operation must have
+An atomic operation can only have
+.Em acquire
+semantics if it performs a load
+from memory.
+When an atomic operation has acquire semantics, a load performed as
+part of the operation must have
completed before any subsequent load or store (by program order) is
performed.
Conversely, acquire semantics do not require that prior loads or stores have
-completed before the atomic operation is performed.
-An atomic operation can only have acquire semantics if it performs a load
-from memory.
+completed before a load from the atomic operation is performed.
To denote acquire semantics, the suffix
.Dq Li _acq
is inserted into the function name immediately prior to the
.Dq Li _ Ns Aq Fa type
suffix.
-For example, to subtract two integers ensuring that the subtraction is
+For example, to subtract two integers ensuring that the load of
+the value from memory is
completed before any subsequent loads and stores are performed, use
.Fn atomic_subtract_acq_int .
.Pp
+An atomic operation can only have
+.Em release
+semantics if it performs a store to memory.
When an atomic operation has release semantics, all prior loads or stores
-(by program order) must have completed before the operation is performed.
-Conversely, release semantics do not require that the atomic operation must
+(by program order) must have completed before a store executed as part of
+the operation that is performed.
+Conversely, release semantics do not require that a store from the atomic
+operation must
have completed before any subsequent load or store is performed.
-An atomic operation can only have release semantics if it performs a store
-to memory.
To denote release semantics, the suffix
.Dq Li _rel
is inserted into the function name immediately prior to the
.Dq Li _ Ns Aq Fa type
suffix.
For example, to add two long integers ensuring that all prior loads and
-stores are completed before the addition is performed, use
+stores are completed before the store of the result is performed, use
.Fn atomic_add_rel_long .
.Pp
When a release operation by one thread
@@ -235,6 +242,33 @@ section.
However, they will not prevent the compiler or processor from moving loads
or stores into the critical section, which does not violate the semantics of
a mutex.
+.Ss Architecture-dependent caveats for compare-and-swap
+The
+.Fn atomic_[f]cmpset_<type>
+operations, specifically those without explicitly specified memory
+ordering, are defined as relaxed.
+Consequently, a thread's accesses to memory locations different from
+that of the atomic operation can be reordered in relation to the
+atomic operation.
+.Pp
+However, the implementation on the
+.Sy amd64
+and
+.Sy i386
+architectures provide sequentially consistent semantics.
+In particular, the reordering mentioned above cannot occur.
+.Pp
+On the
+.Sy arm64/aarch64
+architecture, the operation may include either acquire
+semantics on the constituent load or release semantics
+on the constituent store.
+This means that accesses to other locations in program order
+before the atomic, might be observed as executed after the load
+that is the part of the atomic operation (but not after the store
+from the operation due to release).
+Similarly, accesses after the atomic might be observed as executed
+before the store.
.Ss Thread Fence Operations
Alternatively, a programmer can use atomic thread fence operations to
constrain the reordering of accesses.
diff --git a/share/man/man9/bus_alloc_resource.9 b/share/man/man9/bus_alloc_resource.9
index 84a4c9c530c9..5d309229a34e 100644
--- a/share/man/man9/bus_alloc_resource.9
+++ b/share/man/man9/bus_alloc_resource.9
@@ -26,7 +26,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 May 20, 2016
+.Dd October 30, 2025
.Dt BUS_ALLOC_RESOURCE 9
.Os
.Sh NAME
@@ -43,14 +43,14 @@
.In machine/resource.h
.Ft struct resource *
.Fo bus_alloc_resource
-.Fa "device_t dev" "int type" "int *rid" "rman_res_t start" "rman_res_t end"
+.Fa "device_t dev" "int type" "int rid" "rman_res_t start" "rman_res_t end"
.Fa "rman_res_t count" "u_int flags"
.Fc
.Ft struct resource *
-.Fn bus_alloc_resource_any "device_t dev" "int type" "int *rid" "u_int flags"
+.Fn bus_alloc_resource_any "device_t dev" "int type" "int rid" "u_int flags"
.Ft struct resource *
.Fo bus_alloc_resource_anywhere
-.Fa "device_t dev" "int type" "int *rid" "rman_res_t count" "u_int flags"
+.Fa "device_t dev" "int type" "int rid" "rman_res_t count" "u_int flags"
.Fc
.Sh DESCRIPTION
This is an easy interface to the resource-management functions.
@@ -106,15 +106,13 @@ for I/O memory
.El
.It
.Fa rid
-points to a bus specific handle that identifies the resource being allocated.
+is a bus specific handle that identifies the resource being allocated.
For ISA this is an index into an array of resources that have been setup
for this device by either the PnP mechanism, or via the hints mechanism.
For PCCARD, this is an index into the array of resources described by the PC Card's
CIS entry.
For PCI, the offset into PCI config space which has the BAR to use to access
the resource.
-The bus methods are free to change the RIDs that they are given as a parameter.
-You must not depend on the value you gave it earlier.
.It
.Fa start
and
@@ -175,20 +173,12 @@ A pointer to
is returned on success, a null pointer otherwise.
.Sh EXAMPLES
This is some example code that allocates a 32 byte I/O port range and an IRQ.
-The values of
-.Va portid
-and
-.Va irqid
-should be saved in the softc of the device after these calls.
.Bd -literal
struct resource *portres, *irqres;
- int portid, irqid;
- portid = 0;
- irqid = 0;
- portres = bus_alloc_resource(dev, SYS_RES_IOPORT, &portid,
+ portres = bus_alloc_resource(dev, SYS_RES_IOPORT, 0,
0ul, ~0ul, 32, RF_ACTIVE);
- irqres = bus_alloc_resource_any(dev, SYS_RES_IRQ, &irqid,
+ irqres = bus_alloc_resource_any(dev, SYS_RES_IRQ, 0,
RF_ACTIVE | RF_SHAREABLE);
.Ed
.Sh SEE ALSO
diff --git a/share/man/man9/bus_attach_children.9 b/share/man/man9/bus_attach_children.9
index 5e3ca4c5e906..81a24a428d8e 100644
--- a/share/man/man9/bus_attach_children.9
+++ b/share/man/man9/bus_attach_children.9
@@ -105,7 +105,7 @@ Detached devices are not deleted.
.Pp
.Fn bus_detach_children
is typically called at the start of a bus driver's
-.Xr DEVICE_ATTACH 9
+.Xr DEVICE_DETACH 9
method to give child devices a chance to veto the detach request.
It is usually paired with a later call to
.Fn device_delete_children 9
diff --git a/share/misc/bsd-family-tree b/share/misc/bsd-family-tree
index b0502dfc7925..82e9ac45c495 100644
--- a/share/misc/bsd-family-tree
+++ b/share/misc/bsd-family-tree
@@ -479,7 +479,10 @@ FreeBSD 5.2 | | | |
| | | | | DragonFly 6.4.1
| | | | | DragonFly 6.4.2
| FreeBSD | | | |
- | 14.3 | | OpenBSD 7.8 |
+ | 14.3 | | | |
+ | macOS | | |
+ | 26 | | |
+ | | | OpenBSD 7.8 |
| | | | |
FreeBSD 16 -current | NetBSD -current OpenBSD -current DragonFly -current
| | | | |
@@ -925,6 +928,7 @@ OpenBSD 7.7 2025-04-28 [OBD]
DragonFly 6.4.1 2025-04-30 [DFB]
DragonFly 6.4.2 2025-05-09 [DFB]
FreeBSD 14.3 2025-06-10 [FBD]
+macOS 26 2025-09-15 [APL]
OpenBSD 7.8 2025-10-22 [OBD]
Bibliography
diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk
index 10e1c177e2b2..5697845079e2 100644
--- a/share/mk/bsd.prog.mk
+++ b/share/mk/bsd.prog.mk
@@ -49,9 +49,11 @@ CXXFLAGS+= -mretpoline
LDFLAGS+= -Wl,-zretpolineplt
.endif
.else
+.if !defined(_NO_INCLUDE_COMPILERMK)
.warning Retpoline requested but not supported by compiler or linker
.endif
.endif
+.endif
# LLD sensibly defaults to -znoexecstack, so do the same for BFD
LDFLAGS.bfd+= -Wl,-znoexecstack
.if ${MK_BRANCH_PROTECTION} != "no"
@@ -71,9 +73,11 @@ CFLAGS+= -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clan
CXXFLAGS+= -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
.endif
.else
+.if !defined(_NO_INCLUDE_COMPILERMK)
.warning INIT_ALL (${OPT_INIT_ALL}) requested but not supported by compiler
.endif
.endif
+.endif
# Zero used registers on return (mitigate some ROP)
.if ${MK_ZEROREGS} != "no"
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_audio.c b/sys/arm/broadcom/bcm2835/bcm2835_audio.c
index 13f309dd3f11..2df6ac76124f 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_audio.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_audio.c
@@ -132,6 +132,7 @@ struct bcm2835_audio_info {
uint32_t flags_pending;
+ int verbose_trace;
/* Worker thread state */
int worker_state;
};
@@ -140,6 +141,29 @@ struct bcm2835_audio_info {
#define BCM2835_AUDIO_LOCKED(sc) mtx_assert(&(sc)->lock, MA_OWNED)
#define BCM2835_AUDIO_UNLOCK(sc) mtx_unlock(&(sc)->lock)
+#define BCM2835_LOG_ERROR(sc,...) \
+ do { \
+ device_printf((sc)->dev, __VA_ARGS__); \
+ } while(0)
+
+#define BCM2835_LOG_INFO(sc,...) \
+ do { \
+ if (sc->verbose_trace > 0) \
+ device_printf((sc)->dev, __VA_ARGS__); \
+ } while(0)
+
+#define BCM2835_LOG_WARN(sc,...) \
+ do { \
+ if (sc->verbose_trace > 1) \
+ device_printf((sc)->dev, __VA_ARGS__); \
+ } while(0)
+
+#define BCM2835_LOG_TRACE(sc,...) \
+ do { \
+ if(sc->verbose_trace > 2) \
+ device_printf((sc)->dev, __VA_ARGS__); \
+ } while(0)
+
static const char *
dest_description(uint32_t dest)
{
@@ -236,8 +260,9 @@ bcm2835_audio_callback(void *param, const VCHI_CALLBACK_REASON_T reason, void *m
device_printf(sc->dev, "available_space == %d, count = %d, perr=%d\n",
ch->available_space, count, perr);
device_printf(sc->dev,
- "retrieved_samples = %lld, submitted_samples = %lld\n",
- ch->retrieved_samples, ch->submitted_samples);
+ "retrieved_samples = %ju, submitted_samples = %ju\n",
+ (uintmax_t)ch->retrieved_samples,
+ (uintmax_t)ch->submitted_samples);
}
ch->available_space += count;
ch->retrieved_samples += count;
@@ -247,7 +272,8 @@ bcm2835_audio_callback(void *param, const VCHI_CALLBACK_REASON_T reason, void *m
}
BCM2835_AUDIO_UNLOCK(sc);
} else
- printf("%s: unknown m.type: %d\n", __func__, m.type);
+ BCM2835_LOG_WARN(sc, "%s: unknown m.type: %d\n", __func__,
+ m.type);
}
/* VCHIQ stuff */
@@ -259,13 +285,13 @@ bcm2835_audio_init(struct bcm2835_audio_info *sc)
/* Initialize and create a VCHI connection */
status = vchi_initialise(&sc->vchi_instance);
if (status != 0) {
- printf("vchi_initialise failed: %d\n", status);
+ BCM2835_LOG_ERROR(sc, "vchi_initialise failed: %d\n", status);
return;
}
status = vchi_connect(NULL, 0, sc->vchi_instance);
if (status != 0) {
- printf("vchi_connect failed: %d\n", status);
+ BCM2835_LOG_ERROR(sc, "vchi_connect failed: %d\n", status);
return;
}
@@ -297,7 +323,8 @@ bcm2835_audio_release(struct bcm2835_audio_info *sc)
if (sc->vchi_handle != VCHIQ_SERVICE_HANDLE_INVALID) {
success = vchi_service_close(sc->vchi_handle);
if (success != 0)
- printf("vchi_service_close failed: %d\n", success);
+ BCM2835_LOG_ERROR(sc, "vchi_service_close failed: %d\n",
+ success);
vchi_service_release(sc->vchi_handle);
sc->vchi_handle = VCHIQ_SERVICE_HANDLE_INVALID;
}
@@ -327,7 +354,9 @@ bcm2835_audio_start(struct bcm2835_audio_chinfo *ch)
&m, sizeof m, VCHI_FLAGS_BLOCK_UNTIL_QUEUED, NULL);
if (ret != 0)
- printf("%s: vchi_msg_queue failed (err %d)\n", __func__, ret);
+ BCM2835_LOG_ERROR(sc,
+ "%s: vchi_msg_queue failed (err %d)\n", __func__,
+ ret);
}
}
@@ -346,7 +375,9 @@ bcm2835_audio_stop(struct bcm2835_audio_chinfo *ch)
&m, sizeof m, VCHI_FLAGS_BLOCK_UNTIL_QUEUED, NULL);
if (ret != 0)
- printf("%s: vchi_msg_queue failed (err %d)\n", __func__, ret);
+ BCM2835_LOG_ERROR(sc,
+ "%s: vchi_msg_queue failed (err %d)\n", __func__,
+ ret);
}
}
@@ -362,7 +393,9 @@ bcm2835_audio_open(struct bcm2835_audio_info *sc)
&m, sizeof m, VCHI_FLAGS_BLOCK_UNTIL_QUEUED, NULL);
if (ret != 0)
- printf("%s: vchi_msg_queue failed (err %d)\n", __func__, ret);
+ BCM2835_LOG_ERROR(sc,
+ "%s: vchi_msg_queue failed (err %d)\n", __func__,
+ ret);
}
}
@@ -384,7 +417,9 @@ bcm2835_audio_update_controls(struct bcm2835_audio_info *sc, uint32_t volume, ui
&m, sizeof m, VCHI_FLAGS_BLOCK_UNTIL_QUEUED, NULL);
if (ret != 0)
- printf("%s: vchi_msg_queue failed (err %d)\n", __func__, ret);
+ BCM2835_LOG_ERROR(sc,
+ "%s: vchi_msg_queue failed (err %d)\n", __func__,
+ ret);
}
}
@@ -404,7 +439,9 @@ bcm2835_audio_update_params(struct bcm2835_audio_info *sc, uint32_t fmt, uint32_
&m, sizeof m, VCHI_FLAGS_BLOCK_UNTIL_QUEUED, NULL);
if (ret != 0)
- printf("%s: vchi_msg_queue failed (err %d)\n", __func__, ret);
+ BCM2835_LOG_ERROR(sc,
+ "%s: vchi_msg_queue failed (err %d)\n", __func__,
+ ret);
}
}
@@ -452,14 +489,15 @@ bcm2835_audio_write_samples(struct bcm2835_audio_chinfo *ch, void *buf, uint32_t
&m, sizeof m, VCHI_FLAGS_BLOCK_UNTIL_QUEUED, NULL);
if (ret != 0)
- printf("%s: vchi_msg_queue failed (err %d)\n", __func__, ret);
+ BCM2835_LOG_ERROR(sc, "%s: vchi_msg_queue failed (err %d)\n",
+ __func__, ret);
while (count > 0) {
int bytes = MIN((int)m.u.write.max_packet, (int)count);
ret = vchi_msg_queue(sc->vchi_handle,
buf, bytes, VCHI_FLAGS_BLOCK_UNTIL_QUEUED, NULL);
if (ret != 0)
- printf("%s: vchi_msg_queue failed: %d\n",
+ BCM2835_LOG_ERROR(sc, "%s: vchi_msg_queue failed: %d\n",
__func__, ret);
buf = (char *)buf + bytes;
count -= bytes;
@@ -577,7 +615,8 @@ bcm2835_audio_create_worker(struct bcm2835_audio_info *sc)
sc->worker_state = WORKER_RUNNING;
if (kproc_create(bcm2835_audio_worker, (void*)sc, &newp, 0, 0,
"bcm2835_audio_worker") != 0) {
- printf("failed to create bcm2835_audio_worker\n");
+ BCM2835_LOG_ERROR(sc,
+ "failed to create bcm2835_audio_worker\n");
}
}
@@ -830,6 +869,9 @@ vchi_audio_sysctl_init(struct bcm2835_audio_info *sc)
SYSCTL_ADD_INT(ctx, tree, OID_AUTO, "starved",
CTLFLAG_RD, &sc->pch.starved,
sc->pch.starved, "number of starved conditions");
+ SYSCTL_ADD_INT(ctx, tree, OID_AUTO, "trace",
+ CTLFLAG_RW, &sc->verbose_trace,
+ sc->verbose_trace, "enable tracing of transfers");
}
static void
@@ -861,6 +903,7 @@ bcm2835_audio_delayed_init(void *xsc)
bcm2835_audio_open(sc);
sc->volume = 75;
sc->dest = DEST_AUTO;
+ sc->verbose_trace = 0;
if (mixer_init(sc->dev, &bcmmixer_class, sc)) {
device_printf(sc->dev, "mixer_init failed\n");
diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c
index cae29226d13c..a11b688c4456 100644
--- a/sys/cam/cam_xpt.c
+++ b/sys/cam/cam_xpt.c
@@ -1046,6 +1046,7 @@ xpt_announce_periph(struct cam_periph *periph, char *announce_string)
sbuf_set_drain(&sb, sbuf_printf_drain, NULL);
xpt_announce_periph_sbuf(periph, &sb, announce_string);
(void)sbuf_finish(&sb);
+ (void)sbuf_delete(&sb);
}
void
@@ -1122,6 +1123,7 @@ xpt_denounce_periph(struct cam_periph *periph)
sbuf_set_drain(&sb, sbuf_printf_drain, NULL);
xpt_denounce_periph_sbuf(periph, &sb);
(void)sbuf_finish(&sb);
+ (void)sbuf_delete(&sb);
}
void
@@ -5547,7 +5549,7 @@ xpt_cam_path_debug(struct cam_path *path, const char *fmt, ...)
{
struct sbuf sbuf;
char buf[XPT_PRINT_LEN]; /* balance to not eat too much stack */
- struct sbuf *sb = sbuf_new(&sbuf, buf, sizeof(buf), SBUF_FIXEDLEN);
+ struct sbuf *sb = sbuf_new(&sbuf, buf, sizeof(buf), SBUF_FIXEDLEN | SBUF_INCLUDENUL);
va_list ap;
sbuf_set_drain(sb, sbuf_printf_drain, NULL);
@@ -5566,7 +5568,7 @@ xpt_cam_dev_debug(struct cam_ed *dev, const char *fmt, ...)
{
struct sbuf sbuf;
char buf[XPT_PRINT_LEN]; /* balance to not eat too much stack */
- struct sbuf *sb = sbuf_new(&sbuf, buf, sizeof(buf), SBUF_FIXEDLEN);
+ struct sbuf *sb = sbuf_new(&sbuf, buf, sizeof(buf), SBUF_FIXEDLEN | SBUF_INCLUDENUL);
va_list ap;
sbuf_set_drain(sb, sbuf_printf_drain, NULL);
@@ -5585,7 +5587,7 @@ xpt_cam_debug(const char *fmt, ...)
{
struct sbuf sbuf;
char buf[XPT_PRINT_LEN]; /* balance to not eat too much stack */
- struct sbuf *sb = sbuf_new(&sbuf, buf, sizeof(buf), SBUF_FIXEDLEN);
+ struct sbuf *sb = sbuf_new(&sbuf, buf, sizeof(buf), SBUF_FIXEDLEN | SBUF_INCLUDENUL);
va_list ap;
sbuf_set_drain(sb, sbuf_printf_drain, NULL);
diff --git a/sys/compat/linuxkpi/common/include/linux/pm.h b/sys/compat/linuxkpi/common/include/linux/pm.h
index c8d943027909..932697e0eda8 100644
--- a/sys/compat/linuxkpi/common/include/linux/pm.h
+++ b/sys/compat/linuxkpi/common/include/linux/pm.h
@@ -97,4 +97,18 @@ pm_wakeup_event(struct device *dev __unused, unsigned int x __unused)
pr_debug("%s: TODO\n", __func__);
}
+/*
+ * We do not need to specify anything here as a VT switch always happens on
+ * suspend/resume.
+ */
+static inline void
+pm_vt_switch_required(struct device *dev __unused, bool required __unused)
+{
+}
+
+static inline void
+pm_vt_switch_unregister(struct device *dev __unused)
+{
+}
+
#endif /* _LINUXKPI_LINUX_PM_H */
diff --git a/sys/compat/linuxkpi/common/src/linux_page.c b/sys/compat/linuxkpi/common/src/linux_page.c
index 628af17df853..9cc981b2ba43 100644
--- a/sys/compat/linuxkpi/common/src/linux_page.c
+++ b/sys/compat/linuxkpi/common/src/linux_page.c
@@ -345,6 +345,10 @@ retry:
page = vm_page_grab_iter(vm_obj, pindex, VM_ALLOC_NOCREAT, &pages);
if (page == NULL) {
page = PHYS_TO_VM_PAGE(IDX_TO_OFF(pfn));
+ if (page == NULL) {
+ pctrie_iter_reset(&pages);
+ return (VM_FAULT_SIGBUS);
+ }
if (!vm_page_busy_acquire(page, VM_ALLOC_WAITFAIL)) {
pctrie_iter_reset(&pages);
goto retry;
diff --git a/sys/contrib/vchiq/interface/vchiq_arm/vchiq_2835_arm.c b/sys/contrib/vchiq/interface/vchiq_arm/vchiq_2835_arm.c
index 0150ce72f0a4..185e81e71bdc 100644
--- a/sys/contrib/vchiq/interface/vchiq_arm/vchiq_2835_arm.c
+++ b/sys/contrib/vchiq/interface/vchiq_arm/vchiq_2835_arm.c
@@ -204,8 +204,8 @@ vchiq_platform_init(VCHIQ_STATE_T *state)
bcm_mbox_write(BCM2835_MBOX_CHAN_VCHIQ, (unsigned int)g_slot_phys);
vchiq_log_info(vchiq_arm_log_level,
- "vchiq_init - done (slots %x, phys %x)",
- (unsigned int)vchiq_slot_zero, g_slot_phys);
+ "vchiq_init - done (slots %zx, phys %zx)",
+ (size_t)vchiq_slot_zero, g_slot_phys);
vchiq_call_connected_callbacks();
@@ -451,10 +451,7 @@ create_pagelist(char __user *buf, size_t count, unsigned short type,
}
vchiq_log_trace(vchiq_arm_log_level,
- "create_pagelist - %x (%d bytes @%p)", (unsigned int)pagelist, count, buf);
-
- if (!pagelist)
- return -ENOMEM;
+ "create_pagelist - %zx (%zu bytes @%p)", (size_t)pagelist, count, buf);
addrs = pagelist->addrs;
pages = (vm_page_t*)(addrs + num_pages);
@@ -549,7 +546,9 @@ free_pagelist(BULKINFO_T *bi, int actual)
pagelist = bi->pagelist;
vchiq_log_trace(vchiq_arm_log_level,
- "free_pagelist - %x, %d (%lu bytes @%p)", (unsigned int)pagelist, actual, pagelist->length, bi->buf);
+ "free_pagelist - %zx, %d (%lu bytes @%p)",
+ (size_t)pagelist, (int)actual, (unsigned long)pagelist->length,
+ bi->buf);
num_pages =
(pagelist->length + pagelist->offset + PAGE_SIZE - 1) /
diff --git a/sys/contrib/vchiq/interface/vchiq_arm/vchiq_arm.c b/sys/contrib/vchiq/interface/vchiq_arm/vchiq_arm.c
index 763cd9ce9417..e25c4d738922 100644
--- a/sys/contrib/vchiq/interface/vchiq_arm/vchiq_arm.c
+++ b/sys/contrib/vchiq/interface/vchiq_arm/vchiq_arm.c
@@ -442,8 +442,8 @@ vchiq_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int fflag,
#define _IOC_TYPE(x) IOCGROUP(x)
vchiq_log_trace(vchiq_arm_log_level,
- "vchiq_ioctl - instance %x, cmd %s, arg %p",
- (unsigned int)instance,
+ "vchiq_ioctl - instance %zx, cmd %s, arg %p",
+ (size_t)instance,
((_IOC_TYPE(cmd) == VCHIQ_IOC_MAGIC) &&
(_IOC_NR(cmd) <= VCHIQ_IOC_MAX)) ?
ioctl_names[_IOC_NR(cmd)] : "<invalid>", arg);
@@ -745,8 +745,8 @@ vchiq_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int fflag,
break;
}
vchiq_log_info(vchiq_arm_log_level,
- "found bulk_waiter %x for pid %d",
- (unsigned int)waiter, current->p_pid);
+ "found bulk_waiter %zx for pid %d",
+ (size_t)waiter, current->p_pid);
args.userdata = &waiter->bulk_waiter;
}
status = vchiq_bulk_transfer
@@ -776,8 +776,8 @@ vchiq_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int fflag,
list_add(&waiter->list, &instance->bulk_waiter_list);
lmutex_unlock(&instance->bulk_waiter_list_mutex);
vchiq_log_info(vchiq_arm_log_level,
- "saved bulk_waiter %x for pid %d",
- (unsigned int)waiter, current->p_pid);
+ "saved bulk_waiter %zx for pid %d",
+ (size_t)waiter, current->p_pid);
memcpy((void *)
&(((VCHIQ_QUEUE_BULK_TRANSFER_T *)
@@ -860,9 +860,9 @@ vchiq_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int fflag,
if (args.msgbufsize < msglen) {
vchiq_log_error(
vchiq_arm_log_level,
- "header %x: msgbufsize"
+ "header %zx: msgbufsize"
" %x < msglen %x",
- (unsigned int)header,
+ (size_t)header,
args.msgbufsize,
msglen);
WARN(1, "invalid message "
@@ -1031,8 +1031,8 @@ vchiq_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int fflag,
ret = -EFAULT;
} else {
vchiq_log_error(vchiq_arm_log_level,
- "header %x: bufsize %x < size %x",
- (unsigned int)header, args.bufsize,
+ "header %zx: bufsize %x < size %x",
+ (size_t)header, args.bufsize,
header->size);
WARN(1, "invalid size\n");
ret = -EMSGSIZE;
@@ -1435,9 +1435,9 @@ vchiq_dump_platform_instances(void *dump_context)
instance = service->instance;
if (instance && !instance->mark) {
len = snprintf(buf, sizeof(buf),
- "Instance %x: pid %d,%s completions "
+ "Instance %zx: pid %d,%s completions "
"%d/%d",
- (unsigned int)instance, instance->pid,
+ (size_t)instance, instance->pid,
instance->connected ? " connected, " :
"",
instance->completion_insert -
@@ -1465,8 +1465,8 @@ vchiq_dump_platform_service_state(void *dump_context, VCHIQ_SERVICE_T *service)
char buf[80];
int len;
- len = snprintf(buf, sizeof(buf), " instance %x",
- (unsigned int)service->instance);
+ len = snprintf(buf, sizeof(buf), " instance %zx",
+ (size_t)service->instance);
if ((service->base.callback == service_callback) &&
user_service->is_vchi) {
diff --git a/sys/dev/amdtemp/amdtemp.c b/sys/dev/amdtemp/amdtemp.c
index 79ccdc8c79fb..b1ecb014a2b0 100644
--- a/sys/dev/amdtemp/amdtemp.c
+++ b/sys/dev/amdtemp/amdtemp.c
@@ -642,7 +642,7 @@ amdtemp_intrhook(void *arg)
OID_AUTO, "temperature",
CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE,
dev, sensor, amdtemp_sysctl, "IK",
- "Current temparature");
+ "Current temperature");
}
}
if (sc->sc_ich.ich_arg != NULL)
diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_cal_iq.c b/sys/dev/ath/ath_hal/ar5416/ar5416_cal_iq.c
index a0c27828bbc1..50d7cc0aa7a8 100644
--- a/sys/dev/ath/ath_hal/ar5416/ar5416_cal_iq.c
+++ b/sys/dev/ath/ath_hal/ar5416/ar5416_cal_iq.c
@@ -76,7 +76,7 @@ ar5416IQCalibration(struct ath_hal *ah, uint8_t numChains)
HALDEBUG(ah, HAL_DEBUG_PERCAL,
"Start IQ Cal and Correction for Chain %d\n", i);
HALDEBUG(ah, HAL_DEBUG_PERCAL,
- "Orignal: iq_corr_meas = 0x%08x\n", iqCorrMeas);
+ "Original: iq_corr_meas = 0x%08x\n", iqCorrMeas);
iqCorrNeg = 0;
/* iqCorrMeas is always negative. */
diff --git a/sys/dev/bwi/if_bwi.c b/sys/dev/bwi/if_bwi.c
index 85146d4c4010..80fc5e9e47af 100644
--- a/sys/dev/bwi/if_bwi.c
+++ b/sys/dev/bwi/if_bwi.c
@@ -2900,7 +2900,7 @@ bwi_plcp_header(const struct ieee80211_rate_table *rt,
else if (modtype == IEEE80211_T_DS)
bwi_ds_plcp_header(plcp, pkt_len, rate);
else
- panic("unsupport modulation type %u\n", modtype);
+ panic("unsupported modulation type %u\n", modtype);
}
static int
diff --git a/sys/dev/cesa/cesa.c b/sys/dev/cesa/cesa.c
index 405b619d6e5b..7439dcdbc1ee 100644
--- a/sys/dev/cesa/cesa.c
+++ b/sys/dev/cesa/cesa.c
@@ -286,7 +286,7 @@ cesa_alloc_tdesc(struct cesa_softc *sc)
CESA_GENERIC_ALLOC_LOCKED(sc, ctd, tdesc);
if (!ctd)
- device_printf(sc->sc_dev, "TDMA descriptors pool exhaused. "
+ device_printf(sc->sc_dev, "TDMA descriptors pool exhausted. "
"Consider increasing CESA_TDMA_DESCRIPTORS.\n");
return (ctd);
@@ -299,7 +299,7 @@ cesa_alloc_sdesc(struct cesa_softc *sc, struct cesa_request *cr)
CESA_GENERIC_ALLOC_LOCKED(sc, csd, sdesc);
if (!csd) {
- device_printf(sc->sc_dev, "SA descriptors pool exhaused. "
+ device_printf(sc->sc_dev, "SA descriptors pool exhausted. "
"Consider increasing CESA_SA_DESCRIPTORS.\n");
return (NULL);
}
diff --git a/sys/dev/ciss/ciss.c b/sys/dev/ciss/ciss.c
index d4ede91f6b35..dd3df631119a 100644
--- a/sys/dev/ciss/ciss.c
+++ b/sys/dev/ciss/ciss.c
@@ -3140,7 +3140,7 @@ ciss_cam_action(struct cam_sim *sim, union ccb *ccb)
}
default: /* we can't do this */
- debug(1, "unspported func_code = 0x%x", ccb->ccb_h.func_code);
+ debug(1, "unsupported func_code = 0x%x", ccb->ccb_h.func_code);
ccb->ccb_h.status = CAM_REQ_INVALID;
break;
}
diff --git a/sys/dev/igc/if_igc.c b/sys/dev/igc/if_igc.c
index f199a128c783..d6c06803990f 100644
--- a/sys/dev/igc/if_igc.c
+++ b/sys/dev/igc/if_igc.c
@@ -2816,7 +2816,7 @@ igc_add_hw_stats(struct igc_softc *sc)
"Oversized Packets Received");
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "recv_jabber",
CTLFLAG_RD, &sc->stats.rjc,
- "Recevied Jabber");
+ "Received Jabber");
SYSCTL_ADD_UQUAD(ctx, stat_list, OID_AUTO, "recv_errs",
CTLFLAG_RD, &sc->stats.rxerrc,
"Receive Errors");
diff --git a/sys/dev/isci/scil/scic_sds_remote_node_context.c b/sys/dev/isci/scil/scic_sds_remote_node_context.c
index aa1e8d840282..42dd81aa1874 100644
--- a/sys/dev/isci/scil/scic_sds_remote_node_context.c
+++ b/sys/dev/isci/scil/scic_sds_remote_node_context.c
@@ -663,7 +663,7 @@ SCI_STATUS scic_sds_remote_node_context_invalidating_state_event_handler(
SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
- "SCIC Remote Node Context 0x%x was suspeneded by hardware while being invalidated.\n",
+ "SCIC Remote Node Context 0x%x was suspended by hardware while being invalidated.\n",
this_rnc
));
status = SCI_SUCCESS;
@@ -718,7 +718,7 @@ SCI_STATUS scic_sds_remote_node_context_resuming_state_event_handler(
SCIC_LOG_OBJECT_SSP_REMOTE_TARGET |
SCIC_LOG_OBJECT_SMP_REMOTE_TARGET |
SCIC_LOG_OBJECT_STP_REMOTE_TARGET,
- "SCIC Remote Node Context 0x%x was suspeneded by hardware while being resumed.\n",
+ "SCIC Remote Node Context 0x%x was suspended by hardware while being resumed.\n",
this_rnc
));
status = SCI_SUCCESS;
diff --git a/sys/dev/mfi/mfi.c b/sys/dev/mfi/mfi.c
index 13e5dfc84fd1..a7d98f06aea3 100644
--- a/sys/dev/mfi/mfi.c
+++ b/sys/dev/mfi/mfi.c
@@ -2829,7 +2829,7 @@ mfi_check_command_post(struct mfi_softc *sc, struct mfi_command *cm)
if (ld->ld_id == cm->cm_frame->dcmd.mbox[0])
break;
}
- KASSERT(ld != NULL, ("volume dissappeared"));
+ KASSERT(ld != NULL, ("volume disappeared"));
if (cm->cm_frame->header.cmd_status == MFI_STAT_OK) {
mtx_unlock(&sc->mfi_io_lock);
bus_topo_lock();
diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c
index f212759a5500..e607667decf5 100644
--- a/sys/dev/nvme/nvme_ctrlr.c
+++ b/sys/dev/nvme/nvme_ctrlr.c
@@ -1762,9 +1762,14 @@ noadminq:
bus_release_resource(ctrlr->dev, SYS_RES_IRQ,
rman_get_rid(ctrlr->res), ctrlr->res);
- if (ctrlr->bar4_resource != NULL) {
+ if (ctrlr->msix_table_resource != NULL) {
bus_release_resource(dev, SYS_RES_MEMORY,
- ctrlr->bar4_resource_id, ctrlr->bar4_resource);
+ ctrlr->msix_table_resource_id, ctrlr->msix_table_resource);
+ }
+
+ if (ctrlr->msix_pba_resource != NULL) {
+ bus_release_resource(dev, SYS_RES_MEMORY,
+ ctrlr->msix_pba_resource_id, ctrlr->msix_pba_resource);
}
bus_release_resource(dev, SYS_RES_MEMORY,
diff --git a/sys/dev/nvme/nvme_pci.c b/sys/dev/nvme/nvme_pci.c
index c07a68d2f0dc..cecb05ca0a92 100644
--- a/sys/dev/nvme/nvme_pci.c
+++ b/sys/dev/nvme/nvme_pci.c
@@ -152,11 +152,15 @@ static int
nvme_ctrlr_allocate_bar(struct nvme_controller *ctrlr)
{
ctrlr->resource_id = PCIR_BAR(0);
+ ctrlr->msix_table_resource_id = -1;
+ ctrlr->msix_table_resource = NULL;
+ ctrlr->msix_pba_resource_id = -1;
+ ctrlr->msix_pba_resource = NULL;
ctrlr->resource = bus_alloc_resource_any(ctrlr->dev, SYS_RES_MEMORY,
&ctrlr->resource_id, RF_ACTIVE);
- if(ctrlr->resource == NULL) {
+ if (ctrlr->resource == NULL) {
nvme_printf(ctrlr, "unable to allocate pci resource\n");
return (ENOMEM);
}
@@ -166,15 +170,32 @@ nvme_ctrlr_allocate_bar(struct nvme_controller *ctrlr)
ctrlr->regs = (struct nvme_registers *)ctrlr->bus_handle;
/*
- * The NVMe spec allows for the MSI-X table to be placed behind
- * BAR 4/5, separate from the control/doorbell registers. Always
- * try to map this bar, because it must be mapped prior to calling
- * pci_alloc_msix(). If the table isn't behind BAR 4/5,
- * bus_alloc_resource() will just return NULL which is OK.
+ * The NVMe spec allows for the MSI-X tables to be placed behind
+ * BAR 4 and/or 5, separate from the control/doorbell registers.
*/
- ctrlr->bar4_resource_id = PCIR_BAR(4);
- ctrlr->bar4_resource = bus_alloc_resource_any(ctrlr->dev, SYS_RES_MEMORY,
- &ctrlr->bar4_resource_id, RF_ACTIVE);
+
+ ctrlr->msix_table_resource_id = pci_msix_table_bar(ctrlr->dev);
+ ctrlr->msix_pba_resource_id = pci_msix_pba_bar(ctrlr->dev);
+
+ if (ctrlr->msix_table_resource_id >= 0 &&
+ ctrlr->msix_table_resource_id != ctrlr->resource_id) {
+ ctrlr->msix_table_resource = bus_alloc_resource_any(ctrlr->dev,
+ SYS_RES_MEMORY, &ctrlr->msix_table_resource_id, RF_ACTIVE);
+ if (ctrlr->msix_table_resource == NULL) {
+ nvme_printf(ctrlr, "unable to allocate msi-x table resource\n");
+ return (ENOMEM);
+ }
+ }
+ if (ctrlr->msix_pba_resource_id >= 0 &&
+ ctrlr->msix_pba_resource_id != ctrlr->resource_id &&
+ ctrlr->msix_pba_resource_id != ctrlr->msix_table_resource_id) {
+ ctrlr->msix_pba_resource = bus_alloc_resource_any(ctrlr->dev,
+ SYS_RES_MEMORY, &ctrlr->msix_pba_resource_id, RF_ACTIVE);
+ if (ctrlr->msix_pba_resource == NULL) {
+ nvme_printf(ctrlr, "unable to allocate msi-x pba resource\n");
+ return (ENOMEM);
+ }
+ }
return (0);
}
@@ -200,9 +221,14 @@ bad:
ctrlr->resource_id, ctrlr->resource);
}
- if (ctrlr->bar4_resource != NULL) {
+ if (ctrlr->msix_table_resource != NULL) {
+ bus_release_resource(dev, SYS_RES_MEMORY,
+ ctrlr->msix_table_resource_id, ctrlr->msix_table_resource);
+ }
+
+ if (ctrlr->msix_pba_resource != NULL) {
bus_release_resource(dev, SYS_RES_MEMORY,
- ctrlr->bar4_resource_id, ctrlr->bar4_resource);
+ ctrlr->msix_pba_resource_id, ctrlr->msix_pba_resource);
}
if (ctrlr->tag)
diff --git a/sys/dev/nvme/nvme_private.h b/sys/dev/nvme/nvme_private.h
index 04a47d799350..dd45e1acd0aa 100644
--- a/sys/dev/nvme/nvme_private.h
+++ b/sys/dev/nvme/nvme_private.h
@@ -235,8 +235,10 @@ struct nvme_controller {
* separate from the control registers which are in BAR 0/1. These
* members track the mapping of BAR 4/5 for that reason.
*/
- int bar4_resource_id;
- struct resource *bar4_resource;
+ int msix_table_resource_id;
+ struct resource *msix_table_resource;
+ int msix_pba_resource_id;
+ struct resource *msix_pba_resource;
int msi_count;
uint32_t enable_aborts;
diff --git a/sys/dev/nvmf/controller/nvmft_controller.c b/sys/dev/nvmf/controller/nvmft_controller.c
index 390467534ca2..e618972f46cf 100644
--- a/sys/dev/nvmf/controller/nvmft_controller.c
+++ b/sys/dev/nvmf/controller/nvmft_controller.c
@@ -31,7 +31,7 @@ nvmft_printf(struct nvmft_controller *ctrlr, const char *fmt, ...)
va_list ap;
size_t retval;
- sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN);
+ sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN | SBUF_INCLUDENUL);
sbuf_set_drain(&sb, sbuf_printf_drain, &retval);
sbuf_printf(&sb, "nvmft%u: ", ctrlr->cntlid);
diff --git a/sys/dev/oce/oce_sysctl.c b/sys/dev/oce/oce_sysctl.c
index 1b903d8d027a..544bec9438c4 100644
--- a/sys/dev/oce/oce_sysctl.c
+++ b/sys/dev/oce/oce_sysctl.c
@@ -716,7 +716,7 @@ oce_add_stats_sysctls_be3(POCE_SOFTC sc,
"Total Received Bytes");
SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_frags",
CTLFLAG_RD, &stats->rx.t_rx_frags, 0,
- "Total Received Fragements");
+ "Total Received Fragments");
SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_mcast_pkts",
CTLFLAG_RD, &stats->rx.t_rx_mcast_pkts, 0,
"Total Received Multicast Packets");
@@ -748,7 +748,7 @@ oce_add_stats_sysctls_be3(POCE_SOFTC sc,
"Receive Packets");
SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_bytes",
CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_bytes,
- "Recived Bytes");
+ "Received Bytes");
SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rx_frags",
CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_frags, 0,
"Received Fragments");
@@ -786,7 +786,7 @@ oce_add_stats_sysctls_be3(POCE_SOFTC sc,
"ERX Errors");
SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "alignment_errors",
CTLFLAG_RD, &stats->u0.be.rx_drops_too_many_frags, 0,
- "RX Alignmnet Errors");
+ "RX Alignment Errors");
SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "in_range_errors",
CTLFLAG_RD, &stats->u0.be.rx_in_range_errors, 0,
"In Range Errors");
@@ -932,7 +932,7 @@ oce_add_stats_sysctls_xe201(POCE_SOFTC sc,
"Total Received Bytes");
SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_frags",
CTLFLAG_RD, &stats->rx.t_rx_frags, 0,
- "Total Received Fragements");
+ "Total Received Fragments");
SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "total_mcast_pkts",
CTLFLAG_RD, &stats->rx.t_rx_mcast_pkts, 0,
"Total Received Multicast Packets");
@@ -961,7 +961,7 @@ oce_add_stats_sysctls_xe201(POCE_SOFTC sc,
"Receive Packets");
SYSCTL_ADD_QUAD(ctx, queue_stats_list, OID_AUTO, "rx_bytes",
CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_bytes,
- "Recived Bytes");
+ "Received Bytes");
SYSCTL_ADD_UINT(ctx, queue_stats_list, OID_AUTO, "rx_frags",
CTLFLAG_RD, &sc->rq[i]->rx_stats.rx_frags, 0,
"Received Fragments");
@@ -989,7 +989,7 @@ oce_add_stats_sysctls_xe201(POCE_SOFTC sc,
"CRC Errors");
SYSCTL_ADD_UQUAD(ctx, rx_stat_list, OID_AUTO, "alignment_errors",
CTLFLAG_RD, &stats->u0.xe201.rx_alignment_errors,
- "RX Alignmnet Errors");
+ "RX Alignment Errors");
SYSCTL_ADD_UINT(ctx, rx_stat_list, OID_AUTO, "in_range_errors",
CTLFLAG_RD, &stats->u0.xe201.rx_in_range_errors, 0,
"In Range Errors");
diff --git a/sys/dev/random/fenestrasX/fx_pool.c b/sys/dev/random/fenestrasX/fx_pool.c
index 8e63b345a1bd..b6ffc202769e 100644
--- a/sys/dev/random/fenestrasX/fx_pool.c
+++ b/sys/dev/random/fenestrasX/fx_pool.c
@@ -127,7 +127,7 @@ static const struct fxrng_ent_cls fxrng_garbage = {
*/
static const struct fxrng_ent_char {
const struct fxrng_ent_cls *entc_cls;
-} fxrng_ent_char[ENTROPYSOURCE] = {
+} fxrng_ent_char[/*ENTROPYSOURCE*/] = {
[RANDOM_CACHED] = {
.entc_cls = &fxrng_hi_push,
},
@@ -213,6 +213,7 @@ static const struct fxrng_ent_char {
.entc_cls = &fxrng_hi_pull,
},
};
+CTASSERT(nitems(fxrng_ent_char) == ENTROPYSOURCE);
/* Useful for single-bit-per-source state. */
BITSET_DEFINE(fxrng_bits, ENTROPYSOURCE);
diff --git a/sys/dev/random/random_harvestq.c b/sys/dev/random/random_harvestq.c
index 643dbac1fc8b..b591ffd3b544 100644
--- a/sys/dev/random/random_harvestq.c
+++ b/sys/dev/random/random_harvestq.c
@@ -88,7 +88,7 @@ static void random_sources_feed(void);
static __read_mostly bool epoch_inited;
static __read_mostly epoch_t rs_epoch;
-static const char *random_source_descr[ENTROPYSOURCE];
+static const char *random_source_descr[];
/*
* How many events to queue up. We create this many items in
@@ -109,6 +109,7 @@ volatile int random_kthread_control;
* Updates are synchronized by the harvest mutex.
*/
__read_frequently u_int hc_source_mask;
+CTASSERT(ENTROPYSOURCE <= sizeof(hc_source_mask) * NBBY);
struct random_sources {
CK_LIST_ENTRY(random_sources) rrs_entries;
@@ -647,7 +648,7 @@ SYSCTL_PROC(_kern_random_harvest, OID_AUTO, mask_bin,
random_print_harvestmask, "A",
"Entropy harvesting mask (printable)");
-static const char *random_source_descr[ENTROPYSOURCE] = {
+static const char *random_source_descr[/*ENTROPYSOURCE*/] = {
[RANDOM_CACHED] = "CACHED",
[RANDOM_ATTACH] = "ATTACH",
[RANDOM_KEYBOARD] = "KEYBOARD",
@@ -678,6 +679,7 @@ static const char *random_source_descr[ENTROPYSOURCE] = {
[RANDOM_PURE_ARM_TRNG] = "PURE_ARM_TRNG",
/* "ENTROPYSOURCE" */
};
+CTASSERT(nitems(random_source_descr) == ENTROPYSOURCE);
static int
random_print_harvestmask_symbolic(SYSCTL_HANDLER_ARGS)
diff --git a/sys/dev/thunderbolt/nhi.c b/sys/dev/thunderbolt/nhi.c
index 205e69c16253..30a72652535a 100644
--- a/sys/dev/thunderbolt/nhi.c
+++ b/sys/dev/thunderbolt/nhi.c
@@ -322,6 +322,7 @@ nhi_detach(struct nhi_softc *sc)
tbdev_remove_interface(sc);
nhi_pci_disable_interrupts(sc);
+ nhi_pci_free_interrupts(sc);
nhi_free_ring0(sc);
diff --git a/sys/dev/thunderbolt/nhi_pci.c b/sys/dev/thunderbolt/nhi_pci.c
index 7dacff523cef..865963e275ec 100644
--- a/sys/dev/thunderbolt/nhi_pci.c
+++ b/sys/dev/thunderbolt/nhi_pci.c
@@ -67,7 +67,7 @@ static int nhi_pci_suspend(device_t);
static int nhi_pci_resume(device_t);
static void nhi_pci_free(struct nhi_softc *);
static int nhi_pci_allocate_interrupts(struct nhi_softc *);
-static void nhi_pci_free_interrupts(struct nhi_softc *);
+static void nhi_pci_free_resources(struct nhi_softc *);
static int nhi_pci_icl_poweron(struct nhi_softc *);
static device_method_t nhi_methods[] = {
@@ -253,7 +253,7 @@ static void
nhi_pci_free(struct nhi_softc *sc)
{
- nhi_pci_free_interrupts(sc);
+ nhi_pci_free_resources(sc);
if (sc->parent_dmat != NULL) {
bus_dma_tag_destroy(sc->parent_dmat);
@@ -307,7 +307,7 @@ nhi_pci_allocate_interrupts(struct nhi_softc *sc)
return (error);
}
-static void
+void
nhi_pci_free_interrupts(struct nhi_softc *sc)
{
int i;
@@ -319,7 +319,11 @@ nhi_pci_free_interrupts(struct nhi_softc *sc)
}
pci_release_msi(sc->dev);
+}
+static void
+nhi_pci_free_resources(struct nhi_softc *sc)
+{
if (sc->irq_table != NULL) {
bus_release_resource(sc->dev, SYS_RES_MEMORY,
sc->irq_table_rid, sc->irq_table);
diff --git a/sys/dev/thunderbolt/nhi_var.h b/sys/dev/thunderbolt/nhi_var.h
index 2b9e878af47d..e79ecc954c1f 100644
--- a/sys/dev/thunderbolt/nhi_var.h
+++ b/sys/dev/thunderbolt/nhi_var.h
@@ -217,6 +217,7 @@ struct nhi_dispatch {
int nhi_pci_configure_interrupts(struct nhi_softc *sc);
void nhi_pci_enable_interrupt(struct nhi_ring_pair *r);
void nhi_pci_disable_interrupts(struct nhi_softc *sc);
+void nhi_pci_free_interrupts(struct nhi_softc *sc);
int nhi_pci_get_uuid(struct nhi_softc *sc);
int nhi_read_lc_mailbox(struct nhi_softc *, u_int reg, uint32_t *val);
int nhi_write_lc_mailbox(struct nhi_softc *, u_int reg, uint32_t val);
diff --git a/sys/dev/uart/uart_bus_fdt.c b/sys/dev/uart/uart_bus_fdt.c
index 431f2962adb2..e9a7e04e4e0c 100644
--- a/sys/dev/uart/uart_bus_fdt.c
+++ b/sys/dev/uart/uart_bus_fdt.c
@@ -239,6 +239,12 @@ uart_cpu_fdt_probe(struct uart_class **classp, bus_space_tag_t *bst,
}
/*
+ * Grab the default rclk from the uart class.
+ */
+ if (clk == 0)
+ clk = class->uc_rclk;
+
+ /*
* Retrieve serial attributes.
*/
if (uart_fdt_get_shift(node, &shift) != 0)
diff --git a/sys/dev/uart/uart_dev_snps.c b/sys/dev/uart/uart_dev_snps.c
index 6067920e3c2a..0372a220282b 100644
--- a/sys/dev/uart/uart_dev_snps.c
+++ b/sys/dev/uart/uart_dev_snps.c
@@ -113,7 +113,17 @@ struct uart_class uart_snps_class = {
.uc_rclk = 0,
};
+struct uart_class uart_snps_jh7110_class = {
+ "snps",
+ snps_methods,
+ sizeof(struct snps_softc),
+ .uc_ops = &uart_ns8250_ops,
+ .uc_range = 8,
+ .uc_rclk = 24000000,
+};
+
static struct ofw_compat_data compat_data[] = {
+ { "starfive,jh7110-uart", (uintptr_t)&uart_snps_jh7110_class },
{ "snps,dw-apb-uart", (uintptr_t)&uart_snps_class },
{ "marvell,armada-38x-uart", (uintptr_t)&uart_snps_class },
{ NULL, (uintptr_t)NULL }
diff --git a/sys/dev/usb/serial/u3g.c b/sys/dev/usb/serial/u3g.c
index a549f93b2af1..0fc774d83ee1 100644
--- a/sys/dev/usb/serial/u3g.c
+++ b/sys/dev/usb/serial/u3g.c
@@ -531,6 +531,7 @@ static const STRUCT_USB_HOST_ID u3g_devs[] = {
U3G_DEV(QUECTEL, RG520, 0),
U3G_DEV(QUECTEL, EC200, 0),
U3G_DEV(QUECTEL, EC200S, 0),
+ U3G_DEV(QUECTEL, EM060K, 0),
U3G_DEV(QUECTEL, EC200T, 0),
U3G_DEV(QUECTEL, UC200, 0),
U3G_DEV(SIERRA, AC402, 0),
@@ -600,6 +601,7 @@ static const STRUCT_USB_HOST_ID u3g_devs[] = {
U3G_DEV(SIERRA, EM7455_2, 0),
U3G_DEV(SIERRA, EM7565, 0),
U3G_DEV(SIERRA, EM7565_2, 0),
+ U3G_DEV(SIERRA, EM7590, 0),
U3G_DEV(SILABS, SAEL, U3GINIT_SAEL_M460),
U3G_DEV(STELERA, C105, 0),
U3G_DEV(STELERA, E1003, 0),
diff --git a/sys/dev/usb/usbdevs b/sys/dev/usb/usbdevs
index 2318e6bd0017..bb039f59ce19 100644
--- a/sys/dev/usb/usbdevs
+++ b/sys/dev/usb/usbdevs
@@ -4070,6 +4070,7 @@ product QUECTEL RG500 0x0800 Quectel RG500/RM500/RG510/RM510
product QUECTEL RG520 0x0801 Quectel RG520/RM520/SG520
product QUECTEL EC200 0x6000 Quectel EC200/UC200
product QUECTEL EC200S 0x6002 Quectel EC200S
+product QUECTEL EM060K 0x6008 Quectel EM060K
product QUECTEL EC200T 0x6026 Quectel EC200T
product QUECTEL UC200 0x6120 Quectel UC200
@@ -4431,6 +4432,7 @@ product SIERRA EM7455 0x9078 Sierra Wireless EM7455 Qualcomm Snapdragon X7 LTE-
product SIERRA EM7455_2 0x9079 Sierra Wireless EM7455 Qualcomm Snapdragon X7 LTE-A
product SIERRA EM7565 0x9090 Sierra Wireless EM7565 Qualcomm Snapdragon X7 LTE-A
product SIERRA EM7565_2 0x9091 Sierra Wireless EM7565 Qualcomm Snapdragon X7 LTE-A
+product SIERRA EM7590 0xc081 Sierra Wireless EM7590 Qualcomm Snapdragon X7 LTE-A
/* Sigmatel products */
product SIGMATEL WBT_3052 0x4200 WBT-3052 IrDA/USB Bridge
diff --git a/sys/dev/vnic/nicvf_main.c b/sys/dev/vnic/nicvf_main.c
index dd44e420c78f..59f7abeacdd5 100644
--- a/sys/dev/vnic/nicvf_main.c
+++ b/sys/dev/vnic/nicvf_main.c
@@ -1402,7 +1402,7 @@ nicvf_allocate_net_interrupts(struct nicvf *nic)
/* MSI-X must be configured by now */
if (!nic->msix_enabled) {
- device_printf(nic->dev, "Cannot alloacte queue interrups. "
+ device_printf(nic->dev, "Cannot alloacte queue interrupts. "
"MSI-X interrupts disabled.\n");
return (ENXIO);
}
diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c
index f580a394a735..707ad5749ab2 100644
--- a/sys/fs/nfs/nfs_commonsubs.c
+++ b/sys/fs/nfs/nfs_commonsubs.c
@@ -658,7 +658,7 @@ nfscl_fillsattr(struct nfsrv_descript *nd, struct vattr *vap,
NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_TIMECREATE);
(void) nfsv4_fillattr(nd, vp->v_mount, vp, NULL, vap, NULL, 0,
&attrbits, NULL, NULL, 0, 0, 0, 0, (uint64_t)0, NULL,
- false, false, false, 0);
+ false, false, false, 0, NULL, false);
break;
}
}
@@ -1706,11 +1706,18 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp,
attrsum += NFSX_UNSIGNED;
break;
case NFSATTRBIT_CASEINSENSITIVE:
- NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED);
+ NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED);
if (compare) {
if (!(*retcmpp)) {
- if (*tl != newnfs_false)
- *retcmpp = NFSERR_NOTSAME;
+ if (vp == NULL || VOP_PATHCONF(vp,
+ _PC_CASE_INSENSITIVE,
+ &has_pathconf) != 0)
+ has_pathconf = 0;
+ if ((has_pathconf != 0 &&
+ *tl != newnfs_true) ||
+ (has_pathconf == 0 &&
+ *tl != newnfs_false))
+ *retcmpp = NFSERR_NOTSAME;
}
} else if (pc != NULL) {
pc->pc_caseinsensitive =
@@ -2690,7 +2697,8 @@ nfsv4_fillattr(struct nfsrv_descript *nd, struct mount *mp, vnode_t vp,
nfsattrbit_t *attrbitp, struct ucred *cred, NFSPROC_T *p, int isdgram,
int reterr, int supports_nfsv4acls, int at_root, uint64_t mounted_on_fileno,
struct statfs *pnfssf, bool xattrsupp, bool has_hiddensystem,
- bool has_namedattr, uint32_t clone_blksize)
+ bool has_namedattr, uint32_t clone_blksize, fsid_t *fsidp,
+ bool has_caseinsensitive)
{
int bitpos, retnum = 0;
u_int32_t *tl;
@@ -2865,10 +2873,12 @@ nfsv4_fillattr(struct nfsrv_descript *nd, struct mount *mp, vnode_t vp,
break;
case NFSATTRBIT_FSID:
NFSM_BUILD(tl, u_int32_t *, NFSX_V4FSID);
+ if (fsidp == NULL)
+ fsidp = &mp->mnt_stat.f_fsid;
*tl++ = 0;
- *tl++ = txdr_unsigned(mp->mnt_stat.f_fsid.val[0]);
+ *tl++ = txdr_unsigned(fsidp->val[0]);
*tl++ = 0;
- *tl = txdr_unsigned(mp->mnt_stat.f_fsid.val[1]);
+ *tl = txdr_unsigned(fsidp->val[1]);
retnum += NFSX_V4FSID;
break;
case NFSATTRBIT_UNIQUEHANDLES:
@@ -2914,8 +2924,11 @@ nfsv4_fillattr(struct nfsrv_descript *nd, struct mount *mp, vnode_t vp,
retnum += NFSX_UNSIGNED;
break;
case NFSATTRBIT_CASEINSENSITIVE:
- NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = newnfs_false;
+ NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED);
+ if (has_caseinsensitive)
+ *tl = newnfs_true;
+ else
+ *tl = newnfs_false;
retnum += NFSX_UNSIGNED;
break;
case NFSATTRBIT_CASEPRESERVING:
diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h
index 16a76c060e78..7db3952ecf5c 100644
--- a/sys/fs/nfs/nfs_var.h
+++ b/sys/fs/nfs/nfs_var.h
@@ -398,7 +398,7 @@ void nfsrv_wcc(struct nfsrv_descript *, int, struct nfsvattr *, int,
int nfsv4_fillattr(struct nfsrv_descript *, struct mount *, vnode_t, NFSACL_T *,
struct vattr *, fhandle_t *, int, nfsattrbit_t *, struct ucred *,
NFSPROC_T *, int, int, int, int, uint64_t, struct statfs *, bool, bool,
- bool, uint32_t);
+ bool, uint32_t, fsid_t *, bool);
void nfsrv_fillattr(struct nfsrv_descript *, struct nfsvattr *);
struct mbuf *nfsrv_adj(struct mbuf *, int, int);
void nfsrv_postopattr(struct nfsrv_descript *, int, struct nfsvattr *);
@@ -740,7 +740,7 @@ int nfsvno_updfilerev(vnode_t, struct nfsvattr *, struct nfsrv_descript *,
int nfsvno_fillattr(struct nfsrv_descript *, struct mount *, vnode_t,
struct nfsvattr *, fhandle_t *, int, nfsattrbit_t *,
struct ucred *, NFSPROC_T *, int, int, int, int, uint64_t, bool, bool,
- bool, uint32_t);
+ bool, uint32_t, bool);
int nfsrv_sattr(struct nfsrv_descript *, vnode_t, struct nfsvattr *, nfsattrbit_t *,
NFSACL_T *, NFSPROC_T *);
int nfsv4_sattr(struct nfsrv_descript *, vnode_t, struct nfsvattr *, nfsattrbit_t *,
diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c
index b61218958550..f5deef183efb 100644
--- a/sys/fs/nfsclient/nfs_clrpcops.c
+++ b/sys/fs/nfsclient/nfs_clrpcops.c
@@ -5452,7 +5452,7 @@ nfsrpc_setaclrpc(vnode_t vp, struct ucred *cred, NFSPROC_T *p,
NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_ACL);
(void) nfsv4_fillattr(nd, vp->v_mount, vp, aclp, NULL, NULL, 0,
&attrbits, NULL, NULL, 0, 0, 0, 0, (uint64_t)0, NULL, false, false,
- false, 0);
+ false, 0, NULL, false);
error = nfscl_request(nd, vp, p, cred);
if (error)
return (error);
diff --git a/sys/fs/nfsclient/nfs_clstate.c b/sys/fs/nfsclient/nfs_clstate.c
index aa9d01fc4632..712d49c7160c 100644
--- a/sys/fs/nfsclient/nfs_clstate.c
+++ b/sys/fs/nfsclient/nfs_clstate.c
@@ -3701,7 +3701,8 @@ nfscl_docb(struct nfsrv_descript *nd, NFSPROC_T *p)
if (!error)
(void) nfsv4_fillattr(nd, NULL, NULL, NULL, &va,
NULL, 0, &rattrbits, NULL, p, 0, 0, 0, 0,
- (uint64_t)0, NULL, false, false, false, 0);
+ (uint64_t)0, NULL, false, false, false, 0,
+ NULL, false);
break;
case NFSV4OP_CBRECALL:
NFSCL_DEBUG(4, "cbrecall\n");
diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c
index 5ea7eab07632..212c88f28930 100644
--- a/sys/fs/nfsclient/nfs_clvfsops.c
+++ b/sys/fs/nfsclient/nfs_clvfsops.c
@@ -927,7 +927,7 @@ nfs_mount(struct mount *mp)
struct vnode *vp;
struct thread *td;
char *hst;
- u_char nfh[NFSX_FHMAX], krbname[100], dirpath[100], srvkrbname[100];
+ u_char nfh[NFSX_FHMAX], krbname[100], *dirpath, srvkrbname[100];
char *cp, *opt, *name, *secname, *tlscertname;
int nametimeo = NFS_DEFAULT_NAMETIMEO;
int negnametimeo = NFS_DEFAULT_NEGNAMETIMEO;
@@ -943,6 +943,7 @@ nfs_mount(struct mount *mp)
newflag = 0;
tlscertname = NULL;
hst = malloc(MNAMELEN, M_TEMP, M_WAITOK);
+ dirpath = malloc(MNAMELEN, M_TEMP, M_WAITOK);
if (vfs_filteropt(mp->mnt_optnew, nfs_opts)) {
error = EINVAL;
goto out;
@@ -1329,7 +1330,7 @@ nfs_mount(struct mount *mp)
goto out;
} else if (nfs_mount_parse_from(mp->mnt_optnew,
&args.hostname, (struct sockaddr_in **)&nam, dirpath,
- sizeof(dirpath), &dirlen) == 0) {
+ MNAMELEN, &dirlen) == 0) {
has_nfs_from_opt = 1;
bcopy(args.hostname, hst, MNAMELEN);
hst[MNAMELEN - 1] = '\0';
@@ -1387,7 +1388,7 @@ nfs_mount(struct mount *mp)
if (has_nfs_from_opt == 0) {
if (vfs_getopt(mp->mnt_optnew,
"dirpath", (void **)&name, NULL) == 0)
- strlcpy(dirpath, name, sizeof (dirpath));
+ strlcpy(dirpath, name, MNAMELEN);
else
dirpath[0] = '\0';
dirlen = strlen(dirpath);
@@ -1472,6 +1473,7 @@ out:
MNT_IUNLOCK(mp);
}
free(hst, M_TEMP);
+ free(dirpath, M_TEMP);
return (error);
}
diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c
index f80cf30669ca..795a8d106051 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -4677,12 +4677,13 @@ nfs_pathconf(struct vop_pathconf_args *ap)
clone_blksize = 0;
if ((NFS_ISV34(vp) && (ap->a_name == _PC_LINK_MAX ||
ap->a_name == _PC_NAME_MAX || ap->a_name == _PC_CHOWN_RESTRICTED ||
- ap->a_name == _PC_NO_TRUNC)) ||
+ ap->a_name == _PC_NO_TRUNC ||
+ ap->a_name == _PC_CASE_INSENSITIVE)) ||
(NFS_ISV4(vp) && (ap->a_name == _PC_ACL_NFS4 ||
ap->a_name == _PC_HAS_NAMEDATTR ||
ap->a_name == _PC_CLONE_BLKSIZE))) {
/*
- * Since only the above 4 a_names are returned by the NFSv3
+ * Since only the above 5 a_names are returned by the NFSv3
* Pathconf RPC, there is no point in doing it for others.
* For NFSv4, the Pathconf RPC (actually a Getattr Op.) can
* be used for _PC_ACL_NFS4, _PC_HAS_NAMEDATTR and
@@ -4849,6 +4850,9 @@ nfs_pathconf(struct vop_pathconf_args *ap)
case _PC_CLONE_BLKSIZE:
*ap->a_retval = clone_blksize;
break;
+ case _PC_CASE_INSENSITIVE:
+ *ap->a_retval = pc.pc_caseinsensitive;
+ break;
default:
error = vop_stdpathconf(ap);
diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c
index 9fe3f4426124..841ec2315f1c 100644
--- a/sys/fs/nfsserver/nfs_nfsdport.c
+++ b/sys/fs/nfsserver/nfs_nfsdport.c
@@ -2114,7 +2114,7 @@ nfsvno_fillattr(struct nfsrv_descript *nd, struct mount *mp, struct vnode *vp,
struct ucred *cred, struct thread *p, int isdgram, int reterr,
int supports_nfsv4acls, int at_root, uint64_t mounted_on_fileno,
bool xattrsupp, bool has_hiddensystem, bool has_namedattr,
- uint32_t clone_blksize)
+ uint32_t clone_blksize, bool has_caseinsensitive)
{
struct statfs *sf;
int error;
@@ -2135,7 +2135,7 @@ nfsvno_fillattr(struct nfsrv_descript *nd, struct mount *mp, struct vnode *vp,
error = nfsv4_fillattr(nd, mp, vp, NULL, &nvap->na_vattr, fhp, rderror,
attrbitp, cred, p, isdgram, reterr, supports_nfsv4acls, at_root,
mounted_on_fileno, sf, xattrsupp, has_hiddensystem, has_namedattr,
- clone_blksize);
+ clone_blksize, NULL, has_caseinsensitive);
free(sf, M_TEMP);
NFSEXITCODE2(0, nd);
return (error);
@@ -2468,7 +2468,7 @@ nfsrvd_readdirplus(struct nfsrv_descript *nd, int isdgram,
int bextpg0, bextpg1, bextpgsiz0, bextpgsiz1;
size_t atsiz;
long pathval;
- bool has_hiddensystem, has_namedattr, xattrsupp;
+ bool has_caseinsensitive, has_hiddensystem, has_namedattr, xattrsupp;
if (nd->nd_repstat) {
nfsrv_postopattr(nd, getret, &at);
@@ -2949,6 +2949,7 @@ ateof:
xattrsupp = false;
has_hiddensystem = false;
has_namedattr = false;
+ has_caseinsensitive = false;
clone_blksize = 0;
if (nvp != NULL) {
supports_nfsv4acls =
@@ -2978,6 +2979,11 @@ ateof:
&pathval) != 0)
pathval = 0;
clone_blksize = pathval;
+ if (VOP_PATHCONF(nvp,
+ _PC_CASE_INSENSITIVE,
+ &pathval) != 0)
+ pathval = 0;
+ has_caseinsensitive = pathval > 0;
NFSVOPUNLOCK(nvp);
} else
supports_nfsv4acls = 0;
@@ -2999,7 +3005,7 @@ ateof:
supports_nfsv4acls, at_root,
mounted_on_fileno, xattrsupp,
has_hiddensystem, has_namedattr,
- clone_blksize);
+ clone_blksize, has_caseinsensitive);
} else {
dirlen += nfsvno_fillattr(nd, new_mp,
nvp, nvap, &nfh, r, &attrbits,
@@ -3007,7 +3013,7 @@ ateof:
supports_nfsv4acls, at_root,
mounted_on_fileno, xattrsupp,
has_hiddensystem, has_namedattr,
- clone_blksize);
+ clone_blksize, has_caseinsensitive);
}
if (nvp != NULL)
vrele(nvp);
@@ -6405,7 +6411,7 @@ nfsrv_setacldsdorpc(fhandle_t *fhp, struct ucred *cred, NFSPROC_T *p,
* the same type (VREG).
*/
nfsv4_fillattr(nd, NULL, vp, aclp, NULL, NULL, 0, &attrbits, NULL,
- NULL, 0, 0, 0, 0, 0, NULL, false, false, false, 0);
+ NULL, 0, 0, 0, 0, 0, NULL, false, false, false, 0, NULL, false);
error = newnfs_request(nd, nmp, NULL, &nmp->nm_sockreq, NULL, p, cred,
NFS_PROG, NFS_VER4, NULL, 1, NULL, NULL);
if (error != 0) {
diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c
index 67af0cf71175..394b63c2ab07 100644
--- a/sys/fs/nfsserver/nfs_nfsdserv.c
+++ b/sys/fs/nfsserver/nfs_nfsdserv.c
@@ -252,7 +252,7 @@ nfsrvd_getattr(struct nfsrv_descript *nd, int isdgram,
struct thread *p = curthread;
size_t atsiz;
long pathval;
- bool has_hiddensystem, has_namedattr, xattrsupp;
+ bool has_caseinsensitive, has_hiddensystem, has_namedattr, xattrsupp;
uint32_t clone_blksize;
if (nd->nd_repstat)
@@ -336,6 +336,10 @@ nfsrvd_getattr(struct nfsrv_descript *nd, int isdgram,
&pathval) != 0)
pathval = 0;
clone_blksize = pathval;
+ if (VOP_PATHCONF(vp, _PC_CASE_INSENSITIVE,
+ &pathval) != 0)
+ pathval = 0;
+ has_caseinsensitive = pathval > 0;
mp = vp->v_mount;
if (nfsrv_enable_crossmntpt != 0 &&
vp->v_type == VDIR &&
@@ -371,7 +375,8 @@ nfsrvd_getattr(struct nfsrv_descript *nd, int isdgram,
isdgram, 1, supports_nfsv4acls,
at_root, mounted_on_fileno,
xattrsupp, has_hiddensystem,
- has_namedattr, clone_blksize);
+ has_namedattr, clone_blksize,
+ has_caseinsensitive);
vfs_unbusy(mp);
}
vrele(vp);
diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c
index 267b60ffb5bc..523b7e314a10 100644
--- a/sys/kern/kern_jail.c
+++ b/sys/kern/kern_jail.c
@@ -3047,6 +3047,8 @@ do_jail_attach(struct thread *td, struct prison *pr, int drflags)
setsugid(p);
#ifdef RACCT
racct_proc_ucred_changed(p, oldcred, newcred);
+#endif
+#ifdef RCTL
crhold(newcred);
#endif
PROC_UNLOCK(p);
diff --git a/sys/kern/kern_loginclass.c b/sys/kern/kern_loginclass.c
index 55db6c28a1db..0c111c4f78d8 100644
--- a/sys/kern/kern_loginclass.c
+++ b/sys/kern/kern_loginclass.c
@@ -225,6 +225,8 @@ sys_setloginclass(struct thread *td, struct setloginclass_args *uap)
proc_set_cred(p, newcred);
#ifdef RACCT
racct_proc_ucred_changed(p, oldcred, newcred);
+#endif
+#ifdef RCTL
crhold(newcred);
#endif
PROC_UNLOCK(p);
diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c
index a4c5bcc52529..3c145851b683 100644
--- a/sys/kern/kern_prot.c
+++ b/sys/kern/kern_prot.c
@@ -696,7 +696,7 @@ kern_setcred(struct thread *const td, const u_int flags,
gid_t *groups = NULL;
gid_t smallgroups[CRED_SMALLGROUPS_NB];
int error;
- bool cred_set;
+ bool cred_set = false;
/* Bail out on unrecognized flags. */
if (flags & ~SETCREDF_MASK)
@@ -839,17 +839,32 @@ kern_setcred(struct thread *const td, const u_int flags,
if (cred_set) {
setsugid(p);
to_free_cred = old_cred;
+#ifdef RACCT
+ racct_proc_ucred_changed(p, old_cred, new_cred);
+#endif
+#ifdef RCTL
+ crhold(new_cred);
+#endif
MPASS(error == 0);
} else
error = EAGAIN;
unlock_finish:
PROC_UNLOCK(p);
+
/*
* Part 3: After releasing the process lock, we perform cleanups and
* finishing operations.
*/
+#ifdef RCTL
+ if (cred_set) {
+ rctl_proc_ucred_changed(p, new_cred);
+ /* Paired with the crhold() just above. */
+ crfree(new_cred);
+ }
+#endif
+
#ifdef MAC
if (mac_set_proc_data != NULL)
mac_set_proc_finish(td, proc_label_set, mac_set_proc_data);
@@ -982,6 +997,8 @@ sys_setuid(struct thread *td, struct setuid_args *uap)
proc_set_cred(p, newcred);
#ifdef RACCT
racct_proc_ucred_changed(p, oldcred, newcred);
+#endif
+#ifdef RCTL
crhold(newcred);
#endif
PROC_UNLOCK(p);
@@ -1390,6 +1407,8 @@ sys_setreuid(struct thread *td, struct setreuid_args *uap)
proc_set_cred(p, newcred);
#ifdef RACCT
racct_proc_ucred_changed(p, oldcred, newcred);
+#endif
+#ifdef RCTL
crhold(newcred);
#endif
PROC_UNLOCK(p);
@@ -1536,6 +1555,8 @@ sys_setresuid(struct thread *td, struct setresuid_args *uap)
proc_set_cred(p, newcred);
#ifdef RACCT
racct_proc_ucred_changed(p, oldcred, newcred);
+#endif
+#ifdef RCTL
crhold(newcred);
#endif
PROC_UNLOCK(p);
diff --git a/sys/kern/kern_racct.c b/sys/kern/kern_racct.c
index 2aab151aba08..17b64ad00bb5 100644
--- a/sys/kern/kern_racct.c
+++ b/sys/kern/kern_racct.c
@@ -1236,16 +1236,20 @@ racct_updatepcpu_containers(void)
racct_updatepcpu_post, NULL, NULL);
}
+static bool
+racct_proc_to_skip(const struct proc *p)
+{
+ PROC_LOCK_ASSERT(p, MA_OWNED);
+ return (p->p_state != PRS_NORMAL || (p->p_flag & P_IDLEPROC) != 0);
+}
+
static void
racctd(void)
{
struct proc *p;
- struct proc *idle;
ASSERT_RACCT_ENABLED();
- idle = STAILQ_FIRST(&cpuhead)->pc_idlethread->td_proc;
-
for (;;) {
racct_decay();
@@ -1253,12 +1257,7 @@ racctd(void)
FOREACH_PROC_IN_SYSTEM(p) {
PROC_LOCK(p);
- if (p == idle) {
- PROC_UNLOCK(p);
- continue;
- }
- if (p->p_state != PRS_NORMAL ||
- (p->p_flag & P_IDLEPROC) != 0) {
+ if (racct_proc_to_skip(p)) {
PROC_UNLOCK(p);
continue;
}
@@ -1284,7 +1283,7 @@ racctd(void)
*/
FOREACH_PROC_IN_SYSTEM(p) {
PROC_LOCK(p);
- if (p->p_state != PRS_NORMAL) {
+ if (racct_proc_to_skip(p)) {
PROC_UNLOCK(p);
continue;
}
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index bf5bda7e058d..b84f69cfd03e 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -4633,7 +4633,7 @@ bus_release_resources(device_t dev, const struct resource_spec *rs,
* parent of @p dev.
*/
struct resource *
-bus_alloc_resource(device_t dev, int type, int *rid, rman_res_t start,
+(bus_alloc_resource)(device_t dev, int type, int *rid, rman_res_t start,
rman_res_t end, rman_res_t count, u_int flags)
{
struct resource *res;
diff --git a/sys/kern/subr_syscall.c b/sys/kern/subr_syscall.c
index d5b3b62f0821..48896529f685 100644
--- a/sys/kern/subr_syscall.c
+++ b/sys/kern/subr_syscall.c
@@ -55,8 +55,8 @@ syscallenter(struct thread *td)
struct proc *p;
struct syscall_args *sa;
struct sysent *se;
- int error, traced;
- bool sy_thr_static;
+ int error;
+ bool sy_thr_static, traced;
VM_CNT_INC(v_syscall);
p = td->td_proc;
@@ -219,7 +219,7 @@ syscallret(struct thread *td)
struct proc *p;
struct syscall_args *sa;
ksiginfo_t ksi;
- int traced;
+ bool traced;
KASSERT(td->td_errno != ERELOOKUP,
("ERELOOKUP not consumed syscall %d", td->td_sa.code));
@@ -250,9 +250,9 @@ syscallret(struct thread *td)
}
#endif
- traced = 0;
+ traced = false;
if (__predict_false(p->p_flag & P_TRACED)) {
- traced = 1;
+ traced = true;
PROC_LOCK(p);
td->td_dbgflags |= TDB_SCX;
PROC_UNLOCK(p);
diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h
index 8aefe514946e..ce266a267f3c 100644
--- a/sys/net/pfvar.h
+++ b/sys/net/pfvar.h
@@ -2038,14 +2038,15 @@ struct pfioc_trans {
} *array;
};
-#define PFR_FLAG_ATOMIC 0x00000001 /* unused */
+#define PFR_FLAG_START 0x00000001
#define PFR_FLAG_DUMMY 0x00000002
#define PFR_FLAG_FEEDBACK 0x00000004
#define PFR_FLAG_CLSTATS 0x00000008
#define PFR_FLAG_ADDRSTOO 0x00000010
#define PFR_FLAG_REPLACE 0x00000020
#define PFR_FLAG_ALLRSETS 0x00000040
-#define PFR_FLAG_ALLMASK 0x0000007F
+#define PFR_FLAG_DONE 0x00000080
+#define PFR_FLAG_ALLMASK 0x000000FF
#ifdef _KERNEL
#define PFR_FLAG_USERIOCTL 0x10000000
#endif
@@ -2435,6 +2436,7 @@ extern struct pf_ksrc_node *pf_find_src_node(struct pf_addr *,
struct pf_srchash **, pf_sn_types_t, bool);
extern void pf_unlink_src_node(struct pf_ksrc_node *);
extern u_int pf_free_src_nodes(struct pf_ksrc_node_list *);
+extern void pf_free_src_node(struct pf_ksrc_node *);
extern void pf_print_state(struct pf_kstate *);
extern void pf_print_flags(uint16_t);
extern int pf_addr_wrap_neq(struct pf_addr_wrap *,
@@ -2521,6 +2523,9 @@ uint16_t pf_qname2qid(const char *, bool);
void pfr_initialize(void);
void pfr_cleanup(void);
+struct pfr_kentry *
+ pfr_kentry_byaddr(struct pfr_ktable *, struct pf_addr *, sa_family_t,
+ int);
int pfr_match_addr(struct pfr_ktable *, struct pf_addr *, sa_family_t);
void pfr_update_stats(struct pfr_ktable *, struct pf_addr *, sa_family_t,
u_int64_t, int, int, int);
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 712ff28768dc..edc6c8f29cc0 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -3058,143 +3058,7 @@ db_print_inconninfo(struct in_conninfo *inc, const char *name, int indent)
ntohs(inc->inc_fport));
}
-static void
-db_print_inpflags(int inp_flags)
-{
- int comma;
-
- comma = 0;
- if (inp_flags & INP_RECVOPTS) {
- db_printf("%sINP_RECVOPTS", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & INP_RECVRETOPTS) {
- db_printf("%sINP_RECVRETOPTS", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & INP_RECVDSTADDR) {
- db_printf("%sINP_RECVDSTADDR", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & INP_ORIGDSTADDR) {
- db_printf("%sINP_ORIGDSTADDR", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & INP_HDRINCL) {
- db_printf("%sINP_HDRINCL", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & INP_HIGHPORT) {
- db_printf("%sINP_HIGHPORT", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & INP_LOWPORT) {
- db_printf("%sINP_LOWPORT", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & INP_ANONPORT) {
- db_printf("%sINP_ANONPORT", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & INP_RECVIF) {
- db_printf("%sINP_RECVIF", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & INP_MTUDISC) {
- db_printf("%sINP_MTUDISC", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & INP_RECVTTL) {
- db_printf("%sINP_RECVTTL", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & INP_DONTFRAG) {
- db_printf("%sINP_DONTFRAG", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & INP_RECVTOS) {
- db_printf("%sINP_RECVTOS", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & IN6P_IPV6_V6ONLY) {
- db_printf("%sIN6P_IPV6_V6ONLY", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & IN6P_PKTINFO) {
- db_printf("%sIN6P_PKTINFO", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & IN6P_HOPLIMIT) {
- db_printf("%sIN6P_HOPLIMIT", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & IN6P_HOPOPTS) {
- db_printf("%sIN6P_HOPOPTS", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & IN6P_DSTOPTS) {
- db_printf("%sIN6P_DSTOPTS", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & IN6P_RTHDR) {
- db_printf("%sIN6P_RTHDR", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & IN6P_RTHDRDSTOPTS) {
- db_printf("%sIN6P_RTHDRDSTOPTS", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & IN6P_TCLASS) {
- db_printf("%sIN6P_TCLASS", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & IN6P_AUTOFLOWLABEL) {
- db_printf("%sIN6P_AUTOFLOWLABEL", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & INP_ONESBCAST) {
- db_printf("%sINP_ONESBCAST", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & INP_DROPPED) {
- db_printf("%sINP_DROPPED", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & INP_SOCKREF) {
- db_printf("%sINP_SOCKREF", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & IN6P_RFC2292) {
- db_printf("%sIN6P_RFC2292", comma ? ", " : "");
- comma = 1;
- }
- if (inp_flags & IN6P_MTU) {
- db_printf("IN6P_MTU%s", comma ? ", " : "");
- comma = 1;
- }
-}
-
-static void
-db_print_inpvflag(u_char inp_vflag)
-{
- int comma;
-
- comma = 0;
- if (inp_vflag & INP_IPV4) {
- db_printf("%sINP_IPV4", comma ? ", " : "");
- comma = 1;
- }
- if (inp_vflag & INP_IPV6) {
- db_printf("%sINP_IPV6", comma ? ", " : "");
- comma = 1;
- }
- if (inp_vflag & INP_IPV6PROTO) {
- db_printf("%sINP_IPV6PROTO", comma ? ", " : "");
- comma = 1;
- }
-}
-
-static void
+void
db_print_inpcb(struct inpcb *inp, const char *name, int indent)
{
@@ -3204,38 +3068,36 @@ db_print_inpcb(struct inpcb *inp, const char *name, int indent)
indent += 2;
db_print_indent(indent);
- db_printf("inp_flow: 0x%x\n", inp->inp_flow);
+ db_printf("inp_flow: 0x%x inp_label: %p\n", inp->inp_flow,
+ inp->inp_label);
db_print_inconninfo(&inp->inp_inc, "inp_conninfo", indent);
db_print_indent(indent);
- db_printf("inp_label: %p inp_flags: 0x%x (",
- inp->inp_label, inp->inp_flags);
- db_print_inpflags(inp->inp_flags);
- db_printf(")\n");
+ db_printf("inp_flags: 0x%b\n", inp->inp_flags, INP_FLAGS_BITS);
db_print_indent(indent);
- db_printf("inp_sp: %p inp_vflag: 0x%x (", inp->inp_sp,
- inp->inp_vflag);
- db_print_inpvflag(inp->inp_vflag);
- db_printf(")\n");
+ db_printf("inp_sp: %p inp_vflag: 0x%b\n", inp->inp_sp,
+ inp->inp_vflag, INP_VFLAGS_BITS);
db_print_indent(indent);
db_printf("inp_ip_ttl: %d inp_ip_p: %d inp_ip_minttl: %d\n",
inp->inp_ip_ttl, inp->inp_ip_p, inp->inp_ip_minttl);
- db_print_indent(indent);
#ifdef INET6
if (inp->inp_vflag & INP_IPV6) {
+ db_print_indent(indent);
db_printf("in6p_options: %p in6p_outputopts: %p "
"in6p_moptions: %p\n", inp->in6p_options,
inp->in6p_outputopts, inp->in6p_moptions);
+ db_print_indent(indent);
db_printf("in6p_icmp6filt: %p in6p_cksum %d "
"in6p_hops %u\n", inp->in6p_icmp6filt, inp->in6p_cksum,
inp->in6p_hops);
} else
#endif
{
+ db_print_indent(indent);
db_printf("inp_ip_tos: %d inp_ip_options: %p "
"inp_ip_moptions: %p\n", inp->inp_ip_tos,
inp->inp_options, inp->inp_moptions);
diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h
index 9e0618e87601..60f129bce216 100644
--- a/sys/netinet/in_pcb.h
+++ b/sys/netinet/in_pcb.h
@@ -539,6 +539,9 @@ void inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp,
#define INP_IPV6 0x2
#define INP_IPV6PROTO 0x4 /* opened under IPv6 protocol */
+/* inp_vflags description for use with printf(9) %b identifier. */
+#define INP_VFLAGS_BITS "\20\1INP_IPV4\2INP_IPV6\3INP_IPV6PROTO"
+
/*
* Flags for inp_flags.
*/
@@ -582,6 +585,17 @@ void inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp,
IN6P_TCLASS|IN6P_AUTOFLOWLABEL|IN6P_RFC2292|\
IN6P_MTU)
+/* inp_flags description for use with printf(9) %b identifier. */
+#define INP_FLAGS_BITS "\20" \
+ "\1INP_RECVOPTS\2INP_RECVRETOPTS\3INP_RECVDSTADDR\4INP_HDRINCL" \
+ "\5INP_HIGHPORT\6INP_LOWPORT\7INP_ANONPORT\10INP_RECVIF" \
+ "\11INP_MTUDISC\12INP_FREED\13INP_RECVTTL\14INP_DONTFRAG" \
+ "\15INP_BINDANY\16INP_INHASHLIST\17INP_RECVTOS\20IN6P_IPV6_V6ONLY" \
+ "\21IN6P_PKTINFO\22IN6P_HOPLIMIT\23IN6P_HOPOPTS\24IN6P_DSTOPTS" \
+ "\25IN6P_RTHDR\26IN6P_RTHDRDSTOPTS\27IN6P_TCLASS\30IN6P_AUTOFLOWLABEL" \
+ "\31INP_INLBGROUP\32INP_ONESBCAST\33INP_DROPPED\34INP_SOCKREF" \
+ "\35INP_RESERVED_0\36INP_BOUNDFIB\37IN6P_RFC2292\40IN6P_MTU"
+
/*
* Flags for inp_flags2.
*/
@@ -730,6 +744,9 @@ int in_pcbquery_txrlevel(struct inpcb *, uint32_t *);
void in_pcboutput_txrtlmt(struct inpcb *, struct ifnet *, struct mbuf *);
void in_pcboutput_eagain(struct inpcb *);
#endif
+#ifdef DDB
+void db_print_inpcb(struct inpcb *, const char *, int);
+#endif
#endif /* _KERNEL */
#endif /* !_NETINET_IN_PCB_H_ */
diff --git a/sys/netinet/tcp.h b/sys/netinet/tcp.h
index 41a49b318cd5..cab7d1c5e726 100644
--- a/sys/netinet/tcp.h
+++ b/sys/netinet/tcp.h
@@ -541,7 +541,6 @@ struct tcp_log_user {
#define TCP_HYBRID_PACING_H_MS 0x0008 /* A client hint for maxseg is present */
#define TCP_HYBRID_PACING_ENABLE 0x0010 /* We are enabling hybrid pacing else disable */
#define TCP_HYBRID_PACING_S_MSS 0x0020 /* Clent wants us to set the mss overriding gp est in CU */
-#define TCP_HAS_PLAYOUT_MS 0x0040 /* The client included the chunk playout milliseconds: deprecate */
/* the below are internal only flags */
#define TCP_HYBRID_PACING_USER_MASK 0x0FFF /* Non-internal flags mask */
#define TCP_HYBRID_PACING_SETMSS 0x1000 /* Internal flag that tells us we set the mss on this entry */
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 98c934955121..4d1a6455d09e 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -2799,258 +2799,6 @@ db_print_tstate(int t_state)
}
static void
-db_print_tflags(u_int t_flags)
-{
- int comma;
-
- comma = 0;
- if (t_flags & TF_ACKNOW) {
- db_printf("%sTF_ACKNOW", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_DELACK) {
- db_printf("%sTF_DELACK", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_NODELAY) {
- db_printf("%sTF_NODELAY", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_NOOPT) {
- db_printf("%sTF_NOOPT", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_SENTFIN) {
- db_printf("%sTF_SENTFIN", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_REQ_SCALE) {
- db_printf("%sTF_REQ_SCALE", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_RCVD_SCALE) {
- db_printf("%sTF_RECVD_SCALE", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_REQ_TSTMP) {
- db_printf("%sTF_REQ_TSTMP", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_RCVD_TSTMP) {
- db_printf("%sTF_RCVD_TSTMP", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_SACK_PERMIT) {
- db_printf("%sTF_SACK_PERMIT", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_NEEDSYN) {
- db_printf("%sTF_NEEDSYN", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_NEEDFIN) {
- db_printf("%sTF_NEEDFIN", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_NOPUSH) {
- db_printf("%sTF_NOPUSH", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_PREVVALID) {
- db_printf("%sTF_PREVVALID", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_WAKESOR) {
- db_printf("%sTF_WAKESOR", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_GPUTINPROG) {
- db_printf("%sTF_GPUTINPROG", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_MORETOCOME) {
- db_printf("%sTF_MORETOCOME", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_SONOTCONN) {
- db_printf("%sTF_SONOTCONN", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_LASTIDLE) {
- db_printf("%sTF_LASTIDLE", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_RXWIN0SENT) {
- db_printf("%sTF_RXWIN0SENT", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_FASTRECOVERY) {
- db_printf("%sTF_FASTRECOVERY", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_WASFRECOVERY) {
- db_printf("%sTF_WASFRECOVERY", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_SIGNATURE) {
- db_printf("%sTF_SIGNATURE", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_FORCEDATA) {
- db_printf("%sTF_FORCEDATA", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_TSO) {
- db_printf("%sTF_TSO", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_TOE) {
- db_printf("%sTF_TOE", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_CLOSED) {
- db_printf("%sTF_CLOSED", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_SENTSYN) {
- db_printf("%sTF_SENTSYN", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_LRD) {
- db_printf("%sTF_LRD", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_CONGRECOVERY) {
- db_printf("%sTF_CONGRECOVERY", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_WASCRECOVERY) {
- db_printf("%sTF_WASCRECOVERY", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags & TF_FASTOPEN) {
- db_printf("%sTF_FASTOPEN", comma ? ", " : "");
- comma = 1;
- }
-}
-
-static void
-db_print_tflags2(u_int t_flags2)
-{
- int comma;
-
- comma = 0;
- if (t_flags2 & TF2_PLPMTU_BLACKHOLE) {
- db_printf("%sTF2_PLPMTU_BLACKHOLE", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_PLPMTU_PMTUD) {
- db_printf("%sTF2_PLPMTU_PMTUD", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_PLPMTU_MAXSEGSNT) {
- db_printf("%sTF2_PLPMTU_MAXSEGSNT", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_LOG_AUTO) {
- db_printf("%sTF2_LOG_AUTO", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_DROP_AF_DATA) {
- db_printf("%sTF2_DROP_AF_DATA", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_ECN_PERMIT) {
- db_printf("%sTF2_ECN_PERMIT", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_ECN_SND_CWR) {
- db_printf("%sTF2_ECN_SND_CWR", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_ECN_SND_ECE) {
- db_printf("%sTF2_ECN_SND_ECE", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_ACE_PERMIT) {
- db_printf("%sTF2_ACE_PERMIT", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_HPTS_CPU_SET) {
- db_printf("%sTF2_HPTS_CPU_SET", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_FBYTES_COMPLETE) {
- db_printf("%sTF2_FBYTES_COMPLETE", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_ECN_USE_ECT1) {
- db_printf("%sTF2_ECN_USE_ECT1", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_TCP_ACCOUNTING) {
- db_printf("%sTF2_TCP_ACCOUNTING", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_HPTS_CALLS) {
- db_printf("%sTF2_HPTS_CALLS", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_MBUF_L_ACKS) {
- db_printf("%sTF2_MBUF_L_ACKS", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_MBUF_ACKCMP) {
- db_printf("%sTF2_MBUF_ACKCMP", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_SUPPORTS_MBUFQ) {
- db_printf("%sTF2_SUPPORTS_MBUFQ", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_MBUF_QUEUE_READY) {
- db_printf("%sTF2_MBUF_QUEUE_READY", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_DONT_SACK_QUEUE) {
- db_printf("%sTF2_DONT_SACK_QUEUE", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_CANNOT_DO_ECN) {
- db_printf("%sTF2_CANNOT_DO_ECN", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_PROC_SACK_PROHIBIT) {
- db_printf("%sTF2_PROC_SACK_PROHIBIT", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_IPSEC_TSO) {
- db_printf("%sTF2_IPSEC_TSO", comma ? ", " : "");
- comma = 1;
- }
- if (t_flags2 & TF2_NO_ISS_CHECK) {
- db_printf("%sTF2_NO_ISS_CHECK", comma ? ", " : "");
- comma = 1;
- }
-}
-
-static void
-db_print_toobflags(char t_oobflags)
-{
- int comma;
-
- comma = 0;
- if (t_oobflags & TCPOOB_HAVEDATA) {
- db_printf("%sTCPOOB_HAVEDATA", comma ? ", " : "");
- comma = 1;
- }
- if (t_oobflags & TCPOOB_HADDATA) {
- db_printf("%sTCPOOB_HADDATA", comma ? ", " : "");
- comma = 1;
- }
-}
-
-static void
db_print_bblog_state(int state)
{
switch (state) {
@@ -3088,7 +2836,8 @@ db_print_bblog_state(int state)
}
static void
-db_print_tcpcb(struct tcpcb *tp, const char *name, int indent, bool show_bblog)
+db_print_tcpcb(struct tcpcb *tp, const char *name, int indent, bool show_bblog,
+ bool show_inpcb)
{
db_print_indent(indent);
@@ -3096,6 +2845,9 @@ db_print_tcpcb(struct tcpcb *tp, const char *name, int indent, bool show_bblog)
indent += 2;
+ if (show_inpcb)
+ db_print_inpcb(tptoinpcb(tp), "t_inpcb", indent);
+
db_print_indent(indent);
db_printf("t_segq first: %p t_segqlen: %d t_dupacks: %d\n",
TAILQ_FIRST(&tp->t_segq), tp->t_segqlen, tp->t_dupacks);
@@ -3110,14 +2862,10 @@ db_print_tcpcb(struct tcpcb *tp, const char *name, int indent, bool show_bblog)
db_printf(")\n");
db_print_indent(indent);
- db_printf("t_flags: 0x%x (", tp->t_flags);
- db_print_tflags(tp->t_flags);
- db_printf(")\n");
+ db_printf("t_flags: 0x%b\n", tp->t_flags, TF_BITS);
db_print_indent(indent);
- db_printf("t_flags2: 0x%x (", tp->t_flags2);
- db_print_tflags2(tp->t_flags2);
- db_printf(")\n");
+ db_printf("t_flags2: 0x%b\n", tp->t_flags2, TF2_BITS);
db_print_indent(indent);
db_printf("snd_una: 0x%08x snd_max: 0x%08x snd_nxt: 0x%08x\n",
@@ -3164,9 +2912,8 @@ db_print_tcpcb(struct tcpcb *tp, const char *name, int indent, bool show_bblog)
tp->t_rttupdated, tp->max_sndwnd, tp->t_softerror);
db_print_indent(indent);
- db_printf("t_oobflags: 0x%x (", tp->t_oobflags);
- db_print_toobflags(tp->t_oobflags);
- db_printf(") t_iobc: 0x%02x\n", tp->t_iobc);
+ db_printf("t_oobflags: 0x%b t_iobc: 0x%02x\n", tp->t_oobflags,
+ TCPOOB_BITS, tp->t_iobc);
db_print_indent(indent);
db_printf("snd_scale: %u rcv_scale: %u request_r_scale: %u\n",
@@ -3227,33 +2974,36 @@ db_print_tcpcb(struct tcpcb *tp, const char *name, int indent, bool show_bblog)
DB_SHOW_COMMAND(tcpcb, db_show_tcpcb)
{
struct tcpcb *tp;
- bool show_bblog;
+ bool show_bblog, show_inpcb;
if (!have_addr) {
- db_printf("usage: show tcpcb <addr>\n");
+ db_printf("usage: show tcpcb[/bi] <addr>\n");
return;
}
show_bblog = strchr(modif, 'b') != NULL;
+ show_inpcb = strchr(modif, 'i') != NULL;
tp = (struct tcpcb *)addr;
-
- db_print_tcpcb(tp, "tcpcb", 0, show_bblog);
+ db_print_tcpcb(tp, "tcpcb", 0, show_bblog, show_inpcb);
}
DB_SHOW_ALL_COMMAND(tcpcbs, db_show_all_tcpcbs)
{
VNET_ITERATOR_DECL(vnet_iter);
struct inpcb *inp;
- bool only_locked, show_bblog;
+ struct tcpcb *tp;
+ bool only_locked, show_bblog, show_inpcb;
only_locked = strchr(modif, 'l') != NULL;
show_bblog = strchr(modif, 'b') != NULL;
+ show_inpcb = strchr(modif, 'i') != NULL;
VNET_FOREACH(vnet_iter) {
CURVNET_SET(vnet_iter);
CK_LIST_FOREACH(inp, &V_tcbinfo.ipi_listhead, inp_list) {
if (only_locked &&
inp->inp_lock.rw_lock == RW_UNLOCKED)
continue;
- db_print_tcpcb(intotcpcb(inp), "tcpcb", 0, show_bblog);
+ tp = intotcpcb(inp);
+ db_print_tcpcb(tp, "tcpcb", 0, show_bblog, show_inpcb);
if (db_pager_quit)
break;
}
diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h
index c3be95c80798..f9297be46af7 100644
--- a/sys/netinet/tcp_var.h
+++ b/sys/netinet/tcp_var.h
@@ -795,6 +795,17 @@ tcp_packets_this_ack(struct tcpcb *tp, tcp_seq ack)
#define TF_WASCRECOVERY 0x40000000 /* was in congestion recovery */
#define TF_FASTOPEN 0x80000000 /* TCP Fast Open indication */
+/* t_flags description for use with printf(9) %b identifier. */
+#define TF_BITS "\20" \
+ "\1TF_ACKNOW\2TF_DELACK\3TF_NODELAY\4TF_NOOPT" \
+ "\5TF_SENTFIN\6TF_REQ_SCALE\7TF_RCVD_SCALE\10TF_REQ_TSTMP" \
+ "\11TF_RCVD_TSTMP\12TF_SACK_PERMIT\13TF_NEEDSYN\14TF_NEEDFIN" \
+ "\15TF_NOPUSH\16TF_PREVVALID\17TF_WAKESOR\20TF_GPUTINPROG" \
+ "\21TF_MORETOCOME\22TF_SONOTCONN\23TF_LASTIDLE\24TF_RXWIN0SENT" \
+ "\25TF_FASTRECOVERY\26TF_WASFRECOVERY\27TF_SIGNATURE\30TF_FORCEDATA" \
+ "\31TF_TSO\32TF_TOE\33TF_CLOSED\34TF_SENTSYN" \
+ "\35TF_LRD\36TF_CONGRECOVERY\37TF_WASCRECOVERY\40TF_FASTOPEN"
+
#define IN_FASTRECOVERY(t_flags) (t_flags & TF_FASTRECOVERY)
#define ENTER_FASTRECOVERY(t_flags) t_flags |= TF_FASTRECOVERY
#define EXIT_FASTRECOVERY(t_flags) t_flags &= ~TF_FASTRECOVERY
@@ -815,6 +826,9 @@ tcp_packets_this_ack(struct tcpcb *tp, tcp_seq ack)
#define TCPOOB_HAVEDATA 0x01
#define TCPOOB_HADDATA 0x02
+/* t_oobflags description for use with printf(9) %b identifier. */
+#define TCPOOB_BITS "\20\1TCPOOB_HAVEDATA\2TCPOOB_HADDATA"
+
/*
* Flags for the extended TCP flags field, t_flags2
*/
@@ -842,6 +856,21 @@ tcp_packets_this_ack(struct tcpcb *tp, tcp_seq ack)
#define TF2_IPSEC_TSO 0x00200000 /* IPSEC + TSO supported */
#define TF2_NO_ISS_CHECK 0x00400000 /* Don't check SEG.ACK against ISS */
+/* t_flags2 description for use with printf(9) %b identifier. */
+#define TF2_BITS "\20" \
+ "\1TF2_PLPMTU_BLACKHOLE\2TF2_PLPMTU_PMTUD" \
+ "\3TF2_PLPMTU_MAXSEGSNT\4TF2_LOG_AUTO" \
+ "\5TF2_DROP_AF_DATA\6TF2_ECN_PERMIT" \
+ "\7TF2_ECN_SND_CWR\10TF2_ECN_SND_ECE" \
+ "\11TF2_ACE_PERMIT\12TF2_HPTS_CPU_SET" \
+ "\13TF2_FBYTES_COMPLETE\14TF2_ECN_USE_ECT1" \
+ "\15TF2_TCP_ACCOUNTING\16TF2_HPTS_CALLS" \
+ "\17TF2_MBUF_L_ACKS\20TF2_MBUF_ACKCMP" \
+ "\21TF2_SUPPORTS_MBUFQ\22TF2_MBUF_QUEUE_READY" \
+ "\23TF2_DONT_SACK_QUEUE\24TF2_CANNOT_DO_ECN" \
+ "\25TF2_PROC_SACK_PROHIBIT\26TF2_IPSEC_TSO" \
+ "\27TF2_NO_ISS_CHECK"
+
/*
* Structure to hold TCP options that are only used during segment
* processing (in tcp_input), but not held in the tcpcb.
diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c
index a825658bd9ee..5dfe48908a4f 100644
--- a/sys/netinet6/mld6.c
+++ b/sys/netinet6/mld6.c
@@ -3267,6 +3267,7 @@ mld_init(void *unused __unused)
mld_po.ip6po_hbh = &mld_ra.hbh;
mld_po.ip6po_prefer_tempaddr = IP6PO_TEMPADDR_NOTPREFER;
mld_po.ip6po_flags = IP6PO_DONTFRAG;
+ mld_po.ip6po_valid = IP6PO_VALID_HLIM | IP6PO_VALID_HBH;
callout_init(&mldslow_callout, 1);
callout_reset(&mldslow_callout, hz / MLD_SLOWHZ, mld_slowtimo, NULL);
diff --git a/sys/netipsec/ipsec_offload.c b/sys/netipsec/ipsec_offload.c
index 8a09d5f37b4a..59a107881676 100644
--- a/sys/netipsec/ipsec_offload.c
+++ b/sys/netipsec/ipsec_offload.c
@@ -300,7 +300,7 @@ ipsec_accel_sa_newkey_cb(if_t ifp, void *arg)
dprintf("ipsec_accel_sa_install_newkey: cannot alloc "
"drv_spi if %s spi %#x\n", if_name(ifp),
be32toh(tq->sav->spi));
- return (ENOMEM);
+ return (0);
}
error = ifp->if_ipsec_accel_m->if_sa_newkey(ifp, tq->sav,
drv_spi, &priv);
@@ -329,7 +329,7 @@ ipsec_accel_sa_newkey_cb(if_t ifp, void *arg)
}
}
out:
- return (error);
+ return (0);
}
static void
@@ -663,7 +663,7 @@ ipsec_accel_spdadd_cb(if_t ifp, void *arg)
if (error != 0) {
dprintf("ipsec_accel_spdadd: %s if_spdadd %p remember res %d\n",
if_name(ifp), sp, error);
- return (error);
+ return (0);
}
error = ifp->if_ipsec_accel_m->if_spdadd(ifp, sp, inp, &i->ifdata);
if (error != 0) {
@@ -671,7 +671,7 @@ ipsec_accel_spdadd_cb(if_t ifp, void *arg)
dprintf("ipsec_accel_spdadd: %s if_spdadd %p res %d\n",
if_name(ifp), sp, error);
}
- return (error);
+ return (0);
}
static void
diff --git a/sys/netpfil/ipfw/pmod/tcpmod.c b/sys/netpfil/ipfw/pmod/tcpmod.c
index 0338dc792c64..50074ee98cca 100644
--- a/sys/netpfil/ipfw/pmod/tcpmod.c
+++ b/sys/netpfil/ipfw/pmod/tcpmod.c
@@ -57,7 +57,8 @@ VNET_DEFINE_STATIC(uint32_t, tcpmod_setmss_eid) = 0;
#define V_tcpmod_setmss_eid VNET(tcpmod_setmss_eid)
static int
-tcpmod_setmss(struct mbuf **mp, struct tcphdr *tcp, int tlen, uint16_t mss)
+tcpmod_setmss(struct mbuf **mp, struct tcphdr *tcp, int tlen, uint16_t mss,
+ int *done)
{
struct mbuf *m;
u_char *cp;
@@ -72,8 +73,10 @@ tcpmod_setmss(struct mbuf **mp, struct tcphdr *tcp, int tlen, uint16_t mss)
* TCP header with options.
*/
*mp = m = m_pullup(m, m->m_pkthdr.len);
- if (m == NULL)
+ if (m == NULL) {
+ *done = 1;
return (ret);
+ }
}
/* Parse TCP options. */
for (tlen -= sizeof(struct tcphdr), cp = (u_char *)(tcp + 1);
@@ -114,7 +117,7 @@ tcpmod_setmss(struct mbuf **mp, struct tcphdr *tcp, int tlen, uint16_t mss)
#ifdef INET6
static int
-tcpmod_ipv6_setmss(struct mbuf **mp, uint16_t mss)
+tcpmod_ipv6_setmss(struct mbuf **mp, uint16_t mss, int *done)
{
struct ip6_hdr *ip6;
struct ip6_hbh *hbh;
@@ -142,13 +145,13 @@ tcpmod_ipv6_setmss(struct mbuf **mp, uint16_t mss)
/* We must have TCP options and enough data in a packet. */
if (hlen <= sizeof(struct tcphdr) || hlen > plen)
return (IP_FW_DENY);
- return (tcpmod_setmss(mp, tcp, hlen, mss));
+ return (tcpmod_setmss(mp, tcp, hlen, mss, done));
}
#endif /* INET6 */
#ifdef INET
static int
-tcpmod_ipv4_setmss(struct mbuf **mp, uint16_t mss)
+tcpmod_ipv4_setmss(struct mbuf **mp, uint16_t mss, int *done)
{
struct tcphdr *tcp;
struct ip *ip;
@@ -162,7 +165,7 @@ tcpmod_ipv4_setmss(struct mbuf **mp, uint16_t mss)
/* We must have TCP options and enough data in a packet. */
if (hlen <= sizeof(struct tcphdr) || hlen > plen)
return (IP_FW_DENY);
- return (tcpmod_setmss(mp, tcp, hlen, mss));
+ return (tcpmod_setmss(mp, tcp, hlen, mss, done));
}
#endif /* INET */
@@ -206,19 +209,23 @@ ipfw_tcpmod(struct ip_fw_chain *chain, struct ip_fw_args *args,
switch (args->f_id.addr_type) {
#ifdef INET
case 4:
- ret = tcpmod_ipv4_setmss(&args->m, htons(icmd->arg1));
+ ret = tcpmod_ipv4_setmss(&args->m, htons(icmd->arg1),
+ done);
break;
#endif
#ifdef INET6
case 6:
- ret = tcpmod_ipv6_setmss(&args->m, htons(icmd->arg1));
+ ret = tcpmod_ipv6_setmss(&args->m, htons(icmd->arg1),
+ done);
break;
#endif
}
/*
* We return zero in both @ret and @done on success, and ipfw_chk()
* will update rule counters. Otherwise a packet will not be matched
- * by rule.
+ * by rule. We passed @done around above in case we hit a fatal error
+ * somewhere, we'll return non-zero but signal that rule processing
+ * cannot succeed.
*/
return (ret);
}
diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c
index 66bc99df2afa..de69ecbb0985 100644
--- a/sys/netpfil/pf/if_pfsync.c
+++ b/sys/netpfil/pf/if_pfsync.c
@@ -546,6 +546,9 @@ pfsync_state_import(union pfsync_state_union *sp, int flags, int msg_version)
PF_RULES_RASSERT();
+ if (strnlen(sp->pfs_1301.ifname, IFNAMSIZ) == IFNAMSIZ)
+ return (EINVAL);
+
if (sp->pfs_1301.creatorid == 0) {
if (V_pf_status.debug >= PF_DEBUG_MISC)
printf("%s: invalid creator id: %08x\n", __func__,
diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index fd70fb1c8a36..a39f5fe58cd6 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -1007,7 +1007,7 @@ pf_src_node_exists(struct pf_ksrc_node **sn, struct pf_srchash *sh)
return (false);
}
-static void
+void
pf_free_src_node(struct pf_ksrc_node *sn)
{
diff --git a/sys/netpfil/pf/pf_if.c b/sys/netpfil/pf/pf_if.c
index f3be036ef745..6f41d453a7d1 100644
--- a/sys/netpfil/pf/pf_if.c
+++ b/sys/netpfil/pf/pf_if.c
@@ -702,7 +702,7 @@ pfi_table_update(struct pfr_ktable *kt, struct pfi_kkif *kif, uint8_t net,
}
if ((e = pfr_set_addrs(&kt->pfrkt_t, V_pfi_buffer, V_pfi_buffer_cnt, &size2,
- NULL, NULL, NULL, 0, PFR_TFLAG_ALLMASK)))
+ NULL, NULL, NULL, PFR_FLAG_START | PFR_FLAG_DONE, PFR_TFLAG_ALLMASK)))
printf("%s: cannot set %d new addresses into table %s: %d\n",
__func__, V_pfi_buffer_cnt, kt->pfrkt_name, e);
}
diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c
index a4557f139ae5..5ec67021068b 100644
--- a/sys/netpfil/pf/pf_ioctl.c
+++ b/sys/netpfil/pf/pf_ioctl.c
@@ -4792,6 +4792,17 @@ DIOCCHANGEADDR_error:
error = ENODEV;
goto fail;
}
+ if (strnlen(io->pfrio_table.pfrt_anchor, MAXPATHLEN)
+ == MAXPATHLEN) {
+ error = EINVAL;
+ goto fail;
+ }
+ if (strnlen(io->pfrio_table.pfrt_name, PF_TABLE_NAME_SIZE)
+ == PF_TABLE_NAME_SIZE) {
+ error = EINVAL;
+ goto fail;
+ }
+
PF_RULES_WLOCK();
error = pfr_clr_tables(&io->pfrio_table, &io->pfrio_ndel,
io->pfrio_flags | PFR_FLAG_USERIOCTL);
@@ -5131,7 +5142,7 @@ DIOCCHANGEADDR_error:
error = pfr_set_addrs(&io->pfrio_table, pfras,
io->pfrio_size, &io->pfrio_size2, &io->pfrio_nadd,
&io->pfrio_ndel, &io->pfrio_nchange, io->pfrio_flags |
- PFR_FLAG_USERIOCTL, 0);
+ PFR_FLAG_START | PFR_FLAG_DONE | PFR_FLAG_USERIOCTL, 0);
PF_RULES_WUNLOCK();
if (error == 0 && io->pfrio_flags & PFR_FLAG_FEEDBACK)
error = copyout(pfras, io->pfrio_buffer, totlen);
diff --git a/sys/netpfil/pf/pf_lb.c b/sys/netpfil/pf/pf_lb.c
index 5d85e16f18e3..7aeb8266ca8c 100644
--- a/sys/netpfil/pf/pf_lb.c
+++ b/sys/netpfil/pf/pf_lb.c
@@ -535,6 +535,63 @@ pf_get_mape_sport(struct pf_pdesc *pd, struct pf_krule *r,
return (1);
}
+static __inline u_short
+pf_check_src_node_valid(struct pf_ksrc_node *sn, struct pf_kpool *rpool)
+{
+ struct pf_addr *raddr, *rmask;
+ struct pf_addr *caddr; /* cached redirection address */
+ struct pf_kpooladdr *pa;
+ sa_family_t raf;
+ sa_family_t caf; /* cached redirection AF */
+ u_short valid = 0;
+
+ KASSERT(sn != NULL, ("sn is NULL"));
+ KASSERT(rpool != NULL, ("rpool is NULL"));
+
+ /* check if the cached entry is still valid */
+
+ if (sn->type == PF_SN_LIMIT) {
+ /* Always valid as it does not store redirection address */
+ return (1);
+ }
+
+ mtx_lock(&rpool->mtx);
+ caddr = &(sn->raddr);
+ caf = sn->raf;
+
+ TAILQ_FOREACH(pa, &rpool->list, entries) {
+ if (PF_AZERO(caddr, caf)) {
+ valid = 1;
+ goto done;
+ } else if (pa->addr.type == PF_ADDR_DYNIFTL) {
+ if (pfr_kentry_byaddr(pa->addr.p.dyn->pfid_kt, caddr, caf, 0)) {
+ valid = 1;
+ goto done;
+ }
+ } else if (pa->addr.type == PF_ADDR_TABLE) {
+ if (pfr_kentry_byaddr(pa->addr.p.tbl, caddr, caf, 0)) {
+ valid = 1;
+ goto done;
+ }
+ } else if (pa->addr.type != PF_ADDR_NOROUTE) {
+ /* PF_ADDR_URPFFAILED, PF_ADDR_RANGE, PF_ADDR_ADDRMASK */
+ raddr = &(pa->addr.v.a.addr);
+ rmask = &(pa->addr.v.a.mask);
+ raf = pa->af;
+ if (raf == caf && pf_match_addr(0, raddr, rmask, caddr, caf)) {
+ valid = 1;
+ goto done;
+ }
+ }
+ /* else PF_ADDR_NOROUTE */
+ }
+
+done:
+ mtx_unlock(&rpool->mtx);
+
+ return (valid);
+}
+
u_short
pf_map_addr(sa_family_t saf, struct pf_krule *r, struct pf_addr *saddr,
struct pf_addr *naddr, struct pfi_kkif **nkif, sa_family_t *naf,
@@ -874,6 +931,45 @@ pf_map_addr_sn(sa_family_t saf, struct pf_krule *r, struct pf_addr *saddr,
if (sn != NULL) {
PF_SRC_NODE_LOCK_ASSERT(sn);
+ /*
+ * Check if source node's redirection address still exists
+ * in pool from which the SN was created. If not, delete it.
+ * Similar to pf_kill_srcnodes(). Unlink the source node
+ * from tree, unlink it from states, then free it. Do not
+ * overlap source node and state locks to avoid LOR.
+ */
+ if (!pf_check_src_node_valid(sn, rpool)) {
+ pf_unlink_src_node(sn);
+ PF_SRC_NODE_UNLOCK(sn);
+ if (V_pf_status.debug >= PF_DEBUG_NOISY) {
+ printf("%s: stale src tracking (%d) ",
+ __func__, sn_type);
+ pf_print_host(saddr, 0, saf);
+ printf(" to ");
+ pf_print_host(&(sn->raddr), 0, sn->raf);
+ if (nkif)
+ printf("@%s", sn->rkif->pfik_name);
+ printf("\n");
+ }
+
+ for (int i = 0; i <= V_pf_hashmask; i++) {
+ struct pf_idhash *ih = &V_pf_idhash[i];
+ struct pf_kstate *st;
+
+ PF_HASHROW_LOCK(ih);
+ LIST_FOREACH(st, &ih->states, entry) {
+ if (st->sns[sn->type] == sn) {
+ st->sns[sn->type] = NULL;
+ }
+ }
+ PF_HASHROW_UNLOCK(ih);
+ }
+ pf_free_src_node(sn);
+ counter_u64_add(V_pf_status.scounters[SCNT_SRC_NODE_REMOVALS], 1);
+ sn = NULL;
+ goto map_addr;
+ }
+
(*naf) = sn->raf;
/* If the supplied address is the same as the current one we've
@@ -902,9 +998,10 @@ pf_map_addr_sn(sa_family_t saf, struct pf_krule *r, struct pf_addr *saddr,
goto done;
}
+map_addr:
/*
- * Source node has not been found. Find a new address and store it
- * in variables given by the caller.
+ * Source node has not been found or is invalid. Find a new address
+ * and store it in variables given by the caller.
*/
if ((reason = pf_map_addr(saf, r, saddr, naddr, nkif, naf, init_addr,
rpool)) != 0) {
@@ -974,6 +1071,7 @@ pf_get_transaddr(struct pf_test_ctx *ctx, struct pf_krule *r,
{
struct pf_pdesc *pd = ctx->pd;
struct pf_addr *naddr;
+ int idx;
uint16_t *nportp;
uint16_t low, high;
u_short reason;
@@ -988,8 +1086,19 @@ pf_get_transaddr(struct pf_test_ctx *ctx, struct pf_krule *r,
return (PFRES_MEMORY);
}
- naddr = &ctx->nk->addr[1];
- nportp = &ctx->nk->port[1];
+ switch (nat_action) {
+ case PF_NAT:
+ idx = pd->sidx;
+ break;
+ case PF_BINAT:
+ idx = 1;
+ break;
+ case PF_RDR:
+ idx = pd->didx;
+ break;
+ }
+ naddr = &ctx->nk->addr[idx];
+ nportp = &ctx->nk->port[idx];
switch (nat_action) {
case PF_NAT:
diff --git a/sys/netpfil/pf/pf_nl.c b/sys/netpfil/pf/pf_nl.c
index 082b9b565153..21d4db1b8478 100644
--- a/sys/netpfil/pf/pf_nl.c
+++ b/sys/netpfil/pf/pf_nl.c
@@ -2100,6 +2100,7 @@ struct nl_parsed_table_addrs {
size_t addr_count;
int nadd;
int ndel;
+ int nchange;
};
#define _OUT(_field) offsetof(struct pfr_addr, _field)
static const struct nlattr_parser nla_p_pfr_addr[] = {
@@ -2209,6 +2210,42 @@ pf_handle_table_del_addrs(struct nlmsghdr *hdr, struct nl_pstate *npt)
return (error);
}
+static int
+pf_handle_table_set_addrs(struct nlmsghdr *hdr, struct nl_pstate *npt)
+{
+ struct nl_parsed_table_addrs attrs = { 0 };
+ struct nl_writer *nw = npt->nw;
+ struct genlmsghdr *ghdr_new;
+ int error;
+
+ error = nl_parse_nlmsg(hdr, &table_addr_parser, npt, &attrs);
+ if (error != 0)
+ return (error);
+
+ PF_RULES_WLOCK();
+ error = pfr_set_addrs(&attrs.table, &attrs.addrs[0],
+ attrs.addr_count, NULL, &attrs.nadd, &attrs.ndel, &attrs.nchange,
+ attrs.flags | PFR_FLAG_USERIOCTL, 0);
+ PF_RULES_WUNLOCK();
+
+ if (!nlmsg_reply(nw, hdr, sizeof(struct genlmsghdr)))
+ return (ENOMEM);
+
+ ghdr_new = nlmsg_reserve_object(nw, struct genlmsghdr);
+ ghdr_new->cmd = PFNL_CMD_TABLE_DEL_ADDR;
+ ghdr_new->version = 0;
+ ghdr_new->reserved = 0;
+
+ nlattr_add_u32(nw, PF_TA_NBR_ADDED, attrs.nadd);
+ nlattr_add_u32(nw, PF_TA_NBR_DELETED, attrs.ndel);
+ nlattr_add_u32(nw, PF_TA_NBR_CHANGED, attrs.nchange);
+
+ if (!nlmsg_end(nw))
+ return (ENOMEM);
+
+ return (error);
+}
+
static const struct nlhdr_parser *all_parsers[] = {
&state_parser,
&addrule_parser,
@@ -2460,6 +2497,13 @@ static const struct genl_cmd pf_cmds[] = {
.cmd_flags = GENL_CMD_CAP_DO | GENL_CMD_CAP_HASPOL,
.cmd_priv = PRIV_NETINET_PF,
},
+ {
+ .cmd_num = PFNL_CMD_TABLE_SET_ADDR,
+ .cmd_name = "TABLE_SET_ADDRS",
+ .cmd_cb = pf_handle_table_set_addrs,
+ .cmd_flags = GENL_CMD_CAP_DO | GENL_CMD_CAP_HASPOL,
+ .cmd_priv = PRIV_NETINET_PF,
+ },
};
void
diff --git a/sys/netpfil/pf/pf_nl.h b/sys/netpfil/pf/pf_nl.h
index c46c8f2b2592..d1538ab4ff5b 100644
--- a/sys/netpfil/pf/pf_nl.h
+++ b/sys/netpfil/pf/pf_nl.h
@@ -69,6 +69,7 @@ enum {
PFNL_CMD_CLR_ADDRS = 31,
PFNL_CMD_TABLE_ADD_ADDR = 32,
PFNL_CMD_TABLE_DEL_ADDR = 33,
+ PFNL_CMD_TABLE_SET_ADDR = 34,
__PFNL_CMD_MAX,
};
#define PFNL_CMD_MAX (__PFNL_CMD_MAX -1)
@@ -483,6 +484,7 @@ enum pf_table_addrs_t {
PF_TA_FLAGS = 3, /* u32 */
PF_TA_NBR_ADDED = 4, /* u32 */
PF_TA_NBR_DELETED = 5, /* u32 */
+ PF_TA_NBR_CHANGED = 6, /* u32 */
};
#ifdef _KERNEL
diff --git a/sys/netpfil/pf/pf_table.c b/sys/netpfil/pf/pf_table.c
index 73ec18fa7646..0e2b9fe1cac8 100644
--- a/sys/netpfil/pf/pf_table.c
+++ b/sys/netpfil/pf/pf_table.c
@@ -399,7 +399,8 @@ pfr_set_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size,
PF_RULES_WASSERT();
- ACCEPT_FLAGS(flags, PFR_FLAG_DUMMY | PFR_FLAG_FEEDBACK);
+ ACCEPT_FLAGS(flags, PFR_FLAG_START | PFR_FLAG_DONE |
+ PFR_FLAG_DUMMY | PFR_FLAG_FEEDBACK);
if (pfr_validate_table(tbl, ignore_pfrt_flags, flags &
PFR_FLAG_USERIOCTL))
return (EINVAL);
@@ -411,7 +412,8 @@ pfr_set_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size,
tmpkt = pfr_create_ktable(&V_pfr_nulltable, 0, 0);
if (tmpkt == NULL)
return (ENOMEM);
- pfr_mark_addrs(kt);
+ if (flags & PFR_FLAG_START)
+ pfr_mark_addrs(kt);
SLIST_INIT(&addq);
SLIST_INIT(&delq);
SLIST_INIT(&changeq);
@@ -444,6 +446,7 @@ pfr_set_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size,
}
p = pfr_create_kentry(&ad,
(kt->pfrkt_flags & PFR_TFLAG_COUNTERS) != 0);
+ p->pfrke_mark = PFR_FB_ADDED;
if (p == NULL)
senderr(ENOMEM);
if (pfr_route_kentry(tmpkt, p)) {
@@ -459,7 +462,8 @@ _skip:
if (flags & PFR_FLAG_FEEDBACK)
bcopy(&ad, addr + i, sizeof(ad));
}
- pfr_enqueue_addrs(kt, &delq, &xdel, ENQUEUE_UNMARKED_ONLY);
+ if (flags & PFR_FLAG_DONE)
+ pfr_enqueue_addrs(kt, &delq, &xdel, ENQUEUE_UNMARKED_ONLY);
if ((flags & PFR_FLAG_FEEDBACK) && *size2) {
if (*size2 < size+xdel) {
*size2 = size+xdel;
@@ -2071,7 +2075,7 @@ pfr_lookup_table(struct pfr_table *tbl)
(struct pfr_ktable *)tbl));
}
-static struct pfr_kentry *
+struct pfr_kentry *
pfr_kentry_byaddr(struct pfr_ktable *kt, struct pf_addr *a, sa_family_t af,
int exact)
{
diff --git a/sys/powerpc/include/openpicvar.h b/sys/powerpc/include/openpicvar.h
index 3a170a8a35fe..12f01cb80406 100644
--- a/sys/powerpc/include/openpicvar.h
+++ b/sys/powerpc/include/openpicvar.h
@@ -28,6 +28,8 @@
#ifndef _POWERPC_OPENPICVAR_H_
#define _POWERPC_OPENPICVAR_H_
+#include <sys/kobj.h>
+
#define OPENPIC_DEVSTR "OpenPIC Interrupt Controller"
#define OPENPIC_IRQMAX 256 /* h/w allows more */
@@ -75,16 +77,11 @@ int openpic_common_attach(device_t, uint32_t);
/*
* PIC interface.
*/
-void openpic_bind(device_t dev, u_int irq, cpuset_t cpumask, void **);
void openpic_config(device_t, u_int, enum intr_trigger, enum intr_polarity);
-void openpic_dispatch(device_t, struct trapframe *);
void openpic_enable(device_t, u_int, u_int, void **);
void openpic_eoi(device_t, u_int, void *);
-void openpic_ipi(device_t, u_int);
-void openpic_mask(device_t, u_int, void *);
void openpic_unmask(device_t, u_int, void *);
-int openpic_suspend(device_t dev);
-int openpic_resume(device_t dev);
+DECLARE_CLASS(openpic_class);
#endif /* _POWERPC_OPENPICVAR_H_ */
diff --git a/sys/powerpc/ofw/openpic_ofw.c b/sys/powerpc/ofw/openpic_ofw.c
index fdab55fb30f5..4083e9eba749 100644
--- a/sys/powerpc/ofw/openpic_ofw.c
+++ b/sys/powerpc/ofw/openpic_ofw.c
@@ -68,29 +68,15 @@ static device_method_t openpic_ofw_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, openpic_ofw_probe),
DEVMETHOD(device_attach, openpic_ofw_attach),
- DEVMETHOD(device_suspend, openpic_suspend),
- DEVMETHOD(device_resume, openpic_resume),
/* PIC interface */
- DEVMETHOD(pic_bind, openpic_bind),
- DEVMETHOD(pic_config, openpic_config),
- DEVMETHOD(pic_dispatch, openpic_dispatch),
- DEVMETHOD(pic_enable, openpic_enable),
- DEVMETHOD(pic_eoi, openpic_eoi),
- DEVMETHOD(pic_ipi, openpic_ipi),
- DEVMETHOD(pic_mask, openpic_mask),
- DEVMETHOD(pic_unmask, openpic_unmask),
-
DEVMETHOD(pic_translate_code, openpic_ofw_translate_code),
DEVMETHOD_END
};
-static driver_t openpic_ofw_driver = {
- "openpic",
- openpic_ofw_methods,
- sizeof(struct openpic_softc),
-};
+DEFINE_CLASS_1(openpic, openpic_ofw_driver, openpic_ofw_methods,
+ sizeof(struct openpic_softc), openpic_class);
EARLY_DRIVER_MODULE(openpic, ofwbus, openpic_ofw_driver, 0, 0,
BUS_PASS_INTERRUPT);
diff --git a/sys/powerpc/powermac/cpcht.c b/sys/powerpc/powermac/cpcht.c
index 138aefda5cdb..448144c9749e 100644
--- a/sys/powerpc/powermac/cpcht.c
+++ b/sys/powerpc/powermac/cpcht.c
@@ -113,7 +113,7 @@ static device_method_t cpcht_methods[] = {
struct cpcht_irq {
enum {
IRQ_NONE, IRQ_HT, IRQ_MSI, IRQ_INTERNAL
- } irq_type;
+ } irq_type;
int ht_source;
@@ -287,7 +287,7 @@ cpcht_configure_htbridge(device_t dev, phandle_t child)
sc->htirq_map[irq].irq_type = IRQ_HT;
sc->htirq_map[irq].ht_source = i;
- sc->htirq_map[irq].ht_base = sc->sc_data +
+ sc->htirq_map[irq].ht_base = sc->sc_data +
(((((s & 0x1f) << 3) | (f & 0x07)) << 8) | (ptr));
PCIB_WRITE_CONFIG(dev, b, s, f,
@@ -298,13 +298,13 @@ cpcht_configure_htbridge(device_t dev, phandle_t child)
/*
* Apple uses a non-compliant IO/APIC that differs
- * in how we signal EOIs. Check if this device was
+ * in how we signal EOIs. Check if this device was
* made by Apple, and act accordingly.
*/
vend = PCIB_READ_CONFIG(dev, b, s, f,
PCIR_DEVVENDOR, 4);
if ((vend & 0xffff) == 0x106b)
- sc->htirq_map[irq].apple_eoi =
+ sc->htirq_map[irq].apple_eoi =
(sc->htirq_map[irq].ht_base - ptr) + 0x60;
}
}
@@ -318,7 +318,7 @@ cpcht_read_config(device_t dev, u_int bus, u_int slot, u_int func, u_int reg,
vm_offset_t caoff;
sc = device_get_softc(dev);
- caoff = sc->sc_data +
+ caoff = sc->sc_data +
(((((slot & 0x1f) << 3) | (func & 0x07)) << 8) | reg);
if (bus == 0 && (!(sc->sc_populated_slots & (1 << slot)) || func > 0))
@@ -350,7 +350,7 @@ cpcht_write_config(device_t dev, u_int bus, u_int slot, u_int func,
vm_offset_t caoff;
sc = device_get_softc(dev);
- caoff = sc->sc_data +
+ caoff = sc->sc_data +
(((((slot & 0x1f) << 3) | (func & 0x07)) << 8) | reg);
if (bus == 0 && (!(sc->sc_populated_slots & (1 << slot)) || func > 0))
@@ -520,16 +520,12 @@ static device_method_t openpic_cpcht_methods[] = {
DEVMETHOD(device_attach, openpic_cpcht_attach),
/* PIC interface */
- DEVMETHOD(pic_bind, openpic_bind),
DEVMETHOD(pic_config, openpic_cpcht_config),
- DEVMETHOD(pic_dispatch, openpic_dispatch),
DEVMETHOD(pic_enable, openpic_cpcht_enable),
DEVMETHOD(pic_eoi, openpic_cpcht_eoi),
- DEVMETHOD(pic_ipi, openpic_ipi),
- DEVMETHOD(pic_mask, openpic_mask),
DEVMETHOD(pic_unmask, openpic_cpcht_unmask),
- { 0, 0 },
+ DEVMETHOD_END
};
struct openpic_cpcht_softc {
@@ -538,11 +534,8 @@ struct openpic_cpcht_softc {
struct mtx sc_ht_mtx;
};
-static driver_t openpic_cpcht_driver = {
- "htpic",
- openpic_cpcht_methods,
- sizeof(struct openpic_cpcht_softc),
-};
+DEFINE_CLASS_1(htpic, openpic_cpcht_driver, openpic_cpcht_methods,
+ sizeof(struct openpic_cpcht_softc), openpic_class);
EARLY_DRIVER_MODULE(openpic, unin, openpic_cpcht_driver, 0, 0,
BUS_PASS_INTERRUPT);
@@ -553,7 +546,7 @@ openpic_cpcht_probe(device_t dev)
const char *type = ofw_bus_get_type(dev);
if (strcmp(type, "open-pic") != 0)
- return (ENXIO);
+ return (ENXIO);
device_set_desc(dev, OPENPIC_DEVSTR);
return (0);
@@ -582,7 +575,7 @@ openpic_cpcht_attach(device_t dev)
* Interrupts 0-3 are internally sourced and are level triggered
* active low. Interrupts 4-123 are connected to a pulse generator
* and should be programmed as edge triggered low-to-high.
- *
+ *
* IBM CPC945 Manual, Section 9.3.
*/
@@ -631,7 +624,7 @@ openpic_cpcht_config(device_t dev, u_int irq, enum intr_trigger trig,
/* Mask the IRQ while we fiddle settings */
out32rb(cpcht_irqmap[irq].ht_base + 4, ht_irq | HTAPIC_MASK);
-
+
/* Program the interrupt sense */
ht_irq &= ~(HTAPIC_TRIGGER_LEVEL | HTAPIC_REQUEST_EOI);
if (trig == INTR_TRIGGER_EDGE) {
@@ -671,7 +664,7 @@ openpic_cpcht_enable(device_t dev, u_int irq, u_int vec, void **priv)
mtx_unlock_spin(&sc->sc_ht_mtx);
}
-
+
openpic_cpcht_eoi(dev, irq, *priv);
}
diff --git a/sys/powerpc/powerpc/openpic.c b/sys/powerpc/powerpc/openpic.c
index 0c717aaf6060..aa28f63cb6f5 100644
--- a/sys/powerpc/powerpc/openpic.c
+++ b/sys/powerpc/powerpc/openpic.c
@@ -225,7 +225,7 @@ openpic_common_attach(device_t dev, uint32_t node)
* PIC I/F methods
*/
-void
+static void
openpic_bind(device_t dev, u_int irq, cpuset_t cpumask, void **priv __unused)
{
struct openpic_softc *sc;
@@ -280,18 +280,7 @@ openpic_config(device_t dev, u_int irq, enum intr_trigger trig,
openpic_write(sc, OPENPIC_SRC_VECTOR(irq), x);
}
-static int
-openpic_intr(void *arg)
-{
- device_t dev = (device_t)(arg);
-
- /* XXX Cascaded PICs do not pass non-NULL trapframes! */
- openpic_dispatch(dev, NULL);
-
- return (FILTER_HANDLED);
-}
-
-void
+static void
openpic_dispatch(device_t dev, struct trapframe *tf)
{
struct openpic_softc *sc;
@@ -311,6 +300,17 @@ openpic_dispatch(device_t dev, struct trapframe *tf)
}
}
+static int
+openpic_intr(void *arg)
+{
+ device_t dev = (device_t)(arg);
+
+ /* XXX Cascaded PICs do not pass non-NULL trapframes! */
+ openpic_dispatch(dev, NULL);
+
+ return (FILTER_HANDLED);
+}
+
void
openpic_enable(device_t dev, u_int irq, u_int vector, void **priv __unused)
{
@@ -343,7 +343,7 @@ openpic_eoi(device_t dev, u_int irq __unused, void *priv __unused)
openpic_write(sc, OPENPIC_PCPU_EOI(cpuid), 0);
}
-void
+static void
openpic_ipi(device_t dev, u_int cpu)
{
struct openpic_softc *sc;
@@ -357,7 +357,7 @@ openpic_ipi(device_t dev, u_int cpu)
sched_unpin();
}
-void
+static void
openpic_mask(device_t dev, u_int irq, void *priv __unused)
{
struct openpic_softc *sc;
@@ -393,7 +393,7 @@ openpic_unmask(device_t dev, u_int irq, void *priv __unused)
}
}
-int
+static int
openpic_suspend(device_t dev)
{
struct openpic_softc *sc;
@@ -424,7 +424,7 @@ openpic_suspend(device_t dev)
return (0);
}
-int
+static int
openpic_resume(device_t dev)
{
struct openpic_softc *sc;
@@ -453,3 +453,24 @@ openpic_resume(device_t dev)
return (0);
}
+
+static device_method_t openpic_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_suspend, openpic_suspend),
+ DEVMETHOD(device_resume, openpic_resume),
+
+ /* PIC interface */
+ DEVMETHOD(pic_bind, openpic_bind),
+ DEVMETHOD(pic_config, openpic_config),
+ DEVMETHOD(pic_dispatch, openpic_dispatch),
+ DEVMETHOD(pic_enable, openpic_enable),
+ DEVMETHOD(pic_eoi, openpic_eoi),
+ DEVMETHOD(pic_ipi, openpic_ipi),
+ DEVMETHOD(pic_mask, openpic_mask),
+ DEVMETHOD(pic_unmask, openpic_unmask),
+
+ DEVMETHOD_END
+};
+
+DEFINE_CLASS_0(openpic, openpic_class, openpic_methods,
+ sizeof(struct openpic_softc));
diff --git a/sys/powerpc/psim/openpic_iobus.c b/sys/powerpc/psim/openpic_iobus.c
index bf5bd8235a6c..21950e248b6d 100644
--- a/sys/powerpc/psim/openpic_iobus.c
+++ b/sys/powerpc/psim/openpic_iobus.c
@@ -69,22 +69,11 @@ static device_method_t openpic_iobus_methods[] = {
DEVMETHOD(device_probe, openpic_iobus_probe),
DEVMETHOD(device_attach, openpic_iobus_attach),
- /* PIC interface */
- DEVMETHOD(pic_config, openpic_config),
- DEVMETHOD(pic_dispatch, openpic_dispatch),
- DEVMETHOD(pic_enable, openpic_enable),
- DEVMETHOD(pic_eoi, openpic_eoi),
- DEVMETHOD(pic_ipi, openpic_ipi),
- DEVMETHOD(pic_mask, openpic_mask),
- DEVMETHOD(pic_unmask, openpic_unmask),
- { 0, 0 }
+ DEVMETHOD_END
};
-static driver_t openpic_iobus_driver = {
- "openpic",
- openpic_iobus_methods,
- sizeof(struct openpic_softc)
-};
+DEFINE_CLASS_1(openpic, openpic_iobus_driver, openpic_iobus_methods,
+ sizeof(struct openpic_softc), openpic_class);
DRIVER_MODULE(openpic, iobus, openpic_iobus_driver, 0, 0);
diff --git a/sys/riscv/riscv/fpe.c b/sys/riscv/riscv/fpe.c
index b6c66e5e4f09..63103a794a8e 100644
--- a/sys/riscv/riscv/fpe.c
+++ b/sys/riscv/riscv/fpe.c
@@ -69,39 +69,39 @@ fpe_store(struct fpreg *regs)
__asm __volatile(
"frcsr %0 \n"
- "fsd f0, (16 * 0)(%1)\n"
- "fsd f1, (16 * 1)(%1)\n"
- "fsd f2, (16 * 2)(%1)\n"
- "fsd f3, (16 * 3)(%1)\n"
- "fsd f4, (16 * 4)(%1)\n"
- "fsd f5, (16 * 5)(%1)\n"
- "fsd f6, (16 * 6)(%1)\n"
- "fsd f7, (16 * 7)(%1)\n"
- "fsd f8, (16 * 8)(%1)\n"
- "fsd f9, (16 * 9)(%1)\n"
- "fsd f10, (16 * 10)(%1)\n"
- "fsd f11, (16 * 11)(%1)\n"
- "fsd f12, (16 * 12)(%1)\n"
- "fsd f13, (16 * 13)(%1)\n"
- "fsd f14, (16 * 14)(%1)\n"
- "fsd f15, (16 * 15)(%1)\n"
- "fsd f16, (16 * 16)(%1)\n"
- "fsd f17, (16 * 17)(%1)\n"
- "fsd f18, (16 * 18)(%1)\n"
- "fsd f19, (16 * 19)(%1)\n"
- "fsd f20, (16 * 20)(%1)\n"
- "fsd f21, (16 * 21)(%1)\n"
- "fsd f22, (16 * 22)(%1)\n"
- "fsd f23, (16 * 23)(%1)\n"
- "fsd f24, (16 * 24)(%1)\n"
- "fsd f25, (16 * 25)(%1)\n"
- "fsd f26, (16 * 26)(%1)\n"
- "fsd f27, (16 * 27)(%1)\n"
- "fsd f28, (16 * 28)(%1)\n"
- "fsd f29, (16 * 29)(%1)\n"
- "fsd f30, (16 * 30)(%1)\n"
- "fsd f31, (16 * 31)(%1)\n"
- : "=&r"(fcsr), "=r"(fp_x), "=m"(*fp_x));
+ "fsd f0, (16 * 0)(%2)\n"
+ "fsd f1, (16 * 1)(%2)\n"
+ "fsd f2, (16 * 2)(%2)\n"
+ "fsd f3, (16 * 3)(%2)\n"
+ "fsd f4, (16 * 4)(%2)\n"
+ "fsd f5, (16 * 5)(%2)\n"
+ "fsd f6, (16 * 6)(%2)\n"
+ "fsd f7, (16 * 7)(%2)\n"
+ "fsd f8, (16 * 8)(%2)\n"
+ "fsd f9, (16 * 9)(%2)\n"
+ "fsd f10, (16 * 10)(%2)\n"
+ "fsd f11, (16 * 11)(%2)\n"
+ "fsd f12, (16 * 12)(%2)\n"
+ "fsd f13, (16 * 13)(%2)\n"
+ "fsd f14, (16 * 14)(%2)\n"
+ "fsd f15, (16 * 15)(%2)\n"
+ "fsd f16, (16 * 16)(%2)\n"
+ "fsd f17, (16 * 17)(%2)\n"
+ "fsd f18, (16 * 18)(%2)\n"
+ "fsd f19, (16 * 19)(%2)\n"
+ "fsd f20, (16 * 20)(%2)\n"
+ "fsd f21, (16 * 21)(%2)\n"
+ "fsd f22, (16 * 22)(%2)\n"
+ "fsd f23, (16 * 23)(%2)\n"
+ "fsd f24, (16 * 24)(%2)\n"
+ "fsd f25, (16 * 25)(%2)\n"
+ "fsd f26, (16 * 26)(%2)\n"
+ "fsd f27, (16 * 27)(%2)\n"
+ "fsd f28, (16 * 28)(%2)\n"
+ "fsd f29, (16 * 29)(%2)\n"
+ "fsd f30, (16 * 30)(%2)\n"
+ "fsd f31, (16 * 31)(%2)\n"
+ : "=&r"(fcsr), "=m"(*fp_x) : "r"(fp_x));
regs->fp_fcsr = fcsr;
}
diff --git a/sys/riscv/vmm/vmm.c b/sys/riscv/vmm/vmm.c
index 24b4be89af48..a9eb9d144336 100644
--- a/sys/riscv/vmm/vmm.c
+++ b/sys/riscv/vmm/vmm.c
@@ -319,10 +319,6 @@ vm_alloc_vcpu(struct vm *vm, int vcpuid)
if (vcpuid < 0 || vcpuid >= vm_get_maxcpus(vm))
return (NULL);
- /* Some interrupt controllers may have a CPU limit */
- if (vcpuid >= aplic_max_cpu_count(vm->cookie))
- return (NULL);
-
vcpu = (struct vcpu *)
atomic_load_acq_ptr((uintptr_t *)&vm->vcpu[vcpuid]);
if (__predict_true(vcpu != NULL))
diff --git a/sys/riscv/vmm/vmm_aplic.c b/sys/riscv/vmm/vmm_aplic.c
index 4df41f2de1a5..74cb4fef4273 100644
--- a/sys/riscv/vmm/vmm_aplic.c
+++ b/sys/riscv/vmm/vmm_aplic.c
@@ -577,13 +577,3 @@ aplic_sync_hwstate(struct hypctx *hypctx)
{
}
-
-int
-aplic_max_cpu_count(struct hyp *hyp)
-{
- int16_t max_count;
-
- max_count = vm_get_maxcpus(hyp->vm);
-
- return (max_count);
-}
diff --git a/sys/riscv/vmm/vmm_aplic.h b/sys/riscv/vmm/vmm_aplic.h
index 49510221b419..96018fe9adda 100644
--- a/sys/riscv/vmm/vmm_aplic.h
+++ b/sys/riscv/vmm/vmm_aplic.h
@@ -49,6 +49,5 @@ void aplic_cpuinit(struct hypctx *hypctx);
void aplic_cpucleanup(struct hypctx *hypctx);
void aplic_flush_hwstate(struct hypctx *hypctx);
void aplic_sync_hwstate(struct hypctx *hypctx);
-int aplic_max_cpu_count(struct hyp *hyp);
#endif /* !_VMM_APLIC_H_ */
diff --git a/sys/sys/bus.h b/sys/sys/bus.h
index e7ce152160f8..4cc8091bf775 100644
--- a/sys/sys/bus.h
+++ b/sys/sys/bus.h
@@ -600,6 +600,48 @@ bus_alloc_resource_anywhere(device_t dev, int type, int *rid,
return (bus_alloc_resource(dev, type, rid, 0, ~0, count, flags));
}
+/* Compat shims for bus_alloc_resource API. */
+static __inline struct resource *
+bus_alloc_resource_const(device_t dev, int type, int rid, rman_res_t start,
+ rman_res_t end, rman_res_t count, u_int flags)
+{
+ return (bus_alloc_resource(dev, type, &rid, start, end, count, flags));
+}
+
+static __inline struct resource *
+bus_alloc_resource_any_const(device_t dev, int type, int rid, u_int flags)
+{
+ return (bus_alloc_resource(dev, type, &rid, 0, ~0, 1, flags));
+}
+
+static __inline struct resource *
+bus_alloc_resource_anywhere_const(device_t dev, int type, int rid,
+ rman_res_t count, u_int flags)
+{
+ return (bus_alloc_resource(dev, type, &rid, 0, ~0, count, flags));
+}
+
+#define bus_alloc_resource(dev, type, rid, start, end, count, flags) \
+ _Generic((rid), \
+ int *: bus_alloc_resource, \
+ unsigned int *: bus_alloc_resource, \
+ default: bus_alloc_resource_const) \
+ ((dev), (type), (rid), (start), (end), (count), (flags))
+
+#define bus_alloc_resource_any(dev, type, rid, flags) \
+ _Generic((rid), \
+ int *: bus_alloc_resource_any, \
+ unsigned int *: bus_alloc_resource_any, \
+ default: bus_alloc_resource_any_const) \
+ ((dev), (type), (rid), (flags))
+
+#define bus_alloc_resource_anywhere(dev, type, rid, count, flags) \
+ _Generic((rid), \
+ int *: bus_alloc_resource_anywhere, \
+ unsigned int *: bus_alloc_resource_anywhere, \
+ default: bus_alloc_resource_anywhere_const) \
+ ((dev), (type), (rid), (count), (flags))
+
/* Compat shims for simpler bus resource API. */
int bus_adjust_resource_old(device_t child, int type, struct resource *r,
rman_res_t start, rman_res_t end);
diff --git a/sys/sys/param.h b/sys/sys/param.h
index 7cfa3c6aa4a8..bdfe4a1cfde3 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -74,7 +74,7 @@
* cannot include sys/param.h and should only be updated here.
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 1600002
+#define __FreeBSD_version 1600004
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
diff --git a/tests/sys/netpfil/pf/ioctl/validation.c b/tests/sys/netpfil/pf/ioctl/validation.c
index 3e03163cc752..bb060e22f3a0 100644
--- a/tests/sys/netpfil/pf/ioctl/validation.c
+++ b/tests/sys/netpfil/pf/ioctl/validation.c
@@ -194,6 +194,38 @@ ATF_TC_CLEANUP(gettables, tc)
COMMON_CLEANUP();
}
+ATF_TC_WITH_CLEANUP(clrtables);
+ATF_TC_HEAD(clrtables, tc)
+{
+ atf_tc_set_md_var(tc, "require.user", "root");
+ atf_tc_set_md_var(tc, "require.kmods", "pf");
+}
+
+ATF_TC_BODY(clrtables, tc)
+{
+ struct pfioc_table io;
+ struct pfr_table tbl;
+ int flags;
+
+ COMMON_HEAD();
+
+ flags = 0;
+
+ memset(&io, '/', sizeof(io));
+ io.pfrio_flags = flags;
+ io.pfrio_buffer = &tbl;
+ io.pfrio_esize = 0;
+ io.pfrio_size = 1;
+
+ if (ioctl(dev, DIOCRCLRTABLES, &io) == 0)
+ atf_tc_fail("Request with unterminated anchor name succeeded");
+}
+
+ATF_TC_CLEANUP(clrtables, tc)
+{
+ COMMON_CLEANUP();
+}
+
ATF_TC_WITH_CLEANUP(gettstats);
ATF_TC_HEAD(gettstats, tc)
{
@@ -949,11 +981,36 @@ ATF_TC_CLEANUP(natlook, tc)
COMMON_CLEANUP();
}
+ATF_TC_WITH_CLEANUP(addstate);
+ATF_TC_HEAD(addstate, tc)
+{
+ atf_tc_set_md_var(tc, "require.user", "root");
+ atf_tc_set_md_var(tc, "require.kmods", "pfsync");
+}
+
+ATF_TC_BODY(addstate, tc)
+{
+ struct pfioc_state st;
+
+ COMMON_HEAD();
+
+ memset(&st, 'a', sizeof(st));
+ st.state.timeout = PFTM_TCP_FIRST_PACKET;
+
+ ATF_CHECK_ERRNO(EINVAL, ioctl(dev, DIOCADDSTATE, &st) == -1);
+}
+
+ATF_TC_CLEANUP(addstate, tc)
+{
+ COMMON_CLEANUP();
+}
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, addtables);
ATF_TP_ADD_TC(tp, deltables);
ATF_TP_ADD_TC(tp, gettables);
+ ATF_TP_ADD_TC(tp, clrtables);
ATF_TP_ADD_TC(tp, getastats);
ATF_TP_ADD_TC(tp, gettstats);
ATF_TP_ADD_TC(tp, clrtstats);
@@ -974,6 +1031,7 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, rpool_mtx);
ATF_TP_ADD_TC(tp, rpool_mtx2);
ATF_TP_ADD_TC(tp, natlook);
+ ATF_TP_ADD_TC(tp, addstate);
return (atf_no_error());
}
diff --git a/tests/sys/netpfil/pf/nat.sh b/tests/sys/netpfil/pf/nat.sh
index 1ef87cee3598..0824671fa0f1 100644
--- a/tests/sys/netpfil/pf/nat.sh
+++ b/tests/sys/netpfil/pf/nat.sh
@@ -477,15 +477,49 @@ no_addrs_random_cleanup()
pft_cleanup
}
-atf_test_case "nat_pass" "cleanup"
-nat_pass_head()
+atf_test_case "nat_pass_in" "cleanup"
+nat_pass_in_head()
{
- atf_set descr 'IPv4 NAT on pass rule'
+ atf_set descr 'IPv4 NAT on inbound pass rule'
atf_set require.user root
atf_set require.progs scapy
}
-nat_pass_body()
+nat_pass_in_body()
+{
+ setup_router_server_ipv4
+ # Delete the route back to make sure that the traffic has been NAT-ed
+ jexec server route del -net ${net_tester} ${net_server_host_router}
+ # Provide routing back to the NAT address
+ jexec server route add 203.0.113.0/24 ${net_server_host_router}
+ jexec router route add 203.0.113.0/24 -iface ${epair_tester}b
+
+ pft_set_rules router \
+ "block" \
+ "pass in on ${epair_tester}b inet proto tcp nat-to 203.0.113.0 keep state" \
+ "pass out on ${epair_server}a inet proto tcp keep state"
+
+ ping_server_check_reply exit:0 --ping-type=tcp3way --send-sport=4201
+
+ jexec router pfctl -qvvsr
+ jexec router pfctl -qvvss
+ jexec router ifconfig
+ jexec router netstat -rn
+}
+
+nat_pass_in_cleanup()
+{
+ pft_cleanup
+}
+
+nat_pass_out_head()
+{
+ atf_set descr 'IPv4 NAT on outbound pass rule'
+ atf_set require.user root
+ atf_set require.progs scapy
+}
+
+nat_pass_out_body()
{
setup_router_server_ipv4
# Delete the route back to make sure that the traffic has been NAT-ed
@@ -504,7 +538,7 @@ nat_pass_body()
jexec router netstat -rn
}
-nat_pass_cleanup()
+nat_pass_out_cleanup()
{
pft_cleanup
}
@@ -874,7 +908,8 @@ atf_init_test_cases()
atf_add_test_case "no_addrs_random"
atf_add_test_case "map_e_compat"
atf_add_test_case "map_e_pass"
- atf_add_test_case "nat_pass"
+ atf_add_test_case "nat_pass_in"
+ atf_add_test_case "nat_pass_out"
atf_add_test_case "nat_match"
atf_add_test_case "binat_compat"
atf_add_test_case "binat_match"
diff --git a/tests/sys/netpfil/pf/src_track.sh b/tests/sys/netpfil/pf/src_track.sh
index d86b4ce6c466..1b09030f6174 100755
--- a/tests/sys/netpfil/pf/src_track.sh
+++ b/tests/sys/netpfil/pf/src_track.sh
@@ -588,6 +588,79 @@ mixed_af_cleanup()
pft_cleanup
}
+atf_test_case "check_valid" "cleanup"
+check_valid_head()
+{
+ atf_set descr 'Test if source node is invalidated on change in redirection pool'
+ atf_set require.user root
+ atf_set require.progs python3 scapy
+}
+
+check_valid_body()
+{
+ setup_router_server_nat64
+
+ # Clients will connect from another network behind the router.
+ # This allows for using multiple source addresses.
+ jexec router route add -6 ${net_clients_6}::/${net_clients_6_mask} ${net_tester_6_host_tester}
+
+ jexec server1 ifconfig ${epair_server1}b inet6 ${net_server1_6}::42:1/128 alias
+ jexec server1 ifconfig ${epair_server1}b inet6 ${net_server1_6}::42:2/128 alias
+
+ jexec router pfctl -e
+ pft_set_rules router \
+ "set debug loud " \
+ "set state-policy if-bound" \
+ "table <targets> { ${net_server1_6}::42:1 }" \
+ "pass in on ${epair_tester}b \
+ route-to { (${epair_server1}a <targets>) } \
+ sticky-address \
+ proto tcp \
+ keep state"
+
+ atf_check -s exit:0 ${common_dir}/pft_ping.py \
+ --sendif ${epair_tester}a --replyif ${epair_tester}a \
+ --fromaddr ${net_clients_6}::1 --to ${host_server_6} \
+ --ping-type=tcp3way --send-sport=4201
+
+ # A source node is created using the original redirection target
+ nodes=$(mktemp) || exit 1
+ jexec router pfctl -qvvsS | normalize_pfctl_s > $nodes
+ node_regexp='2001:db8:44::1 -> 2001:db8:4201::42:1 .* states 1,.* route sticky-address'
+ grep -qE "${node_regexp}" $nodes || atf_fail "Source node not found for '${node_regexp}'"
+
+ # Change contents of the redirection table
+ echo ${net_server1_6}::42:2 | jexec router pfctl -Tr -t targets -f -
+
+ atf_check -s exit:0 ${common_dir}/pft_ping.py \
+ --sendif ${epair_tester}a --replyif ${epair_tester}a \
+ --fromaddr ${net_clients_6}::1 --to ${host_server_6} \
+ --ping-type=tcp3way --send-sport=4202
+
+ # The original source node was deleted, a new one was created.
+ # It has 1 states.
+ jexec router pfctl -qvvsS | normalize_pfctl_s > $nodes
+ node_regexp='2001:db8:44::1 -> 2001:db8:4201::42:2 .* states 1,.* route sticky-address'
+ grep -qE "${node_regexp}" $nodes || atf_fail "Source node not found for '${node_regexp}'"
+
+ atf_check -s exit:0 ${common_dir}/pft_ping.py \
+ --sendif ${epair_tester}a --replyif ${epair_tester}a \
+ --fromaddr ${net_clients_6}::1 --to ${host_server_6} \
+ --ping-type=tcp3way --send-sport=4203
+
+ # Without redirection table change the source node is reused.
+ # It has 2 states.
+ jexec router pfctl -qvvsS | normalize_pfctl_s > $nodes
+ node_regexp='2001:db8:44::1 -> 2001:db8:4201::42:2 .* states 2,.* route sticky-address'
+ grep -qE "${node_regexp}" $nodes || atf_fail "Source node not found for '${node_regexp}'"
+}
+
+check_valid_cleanup()
+{
+ pft_cleanup
+}
+
+
atf_init_test_cases()
{
atf_add_test_case "source_track"
@@ -598,4 +671,5 @@ atf_init_test_cases()
atf_add_test_case "sn_types_compat"
atf_add_test_case "sn_types_pass"
atf_add_test_case "mixed_af"
+ atf_add_test_case "check_valid"
}
diff --git a/tests/sys/netpfil/pf/table.sh b/tests/sys/netpfil/pf/table.sh
index 69fe12fc9804..6761ce652beb 100644
--- a/tests/sys/netpfil/pf/table.sh
+++ b/tests/sys/netpfil/pf/table.sh
@@ -747,6 +747,67 @@ in_anchor_cleanup()
pft_cleanup
}
+atf_test_case "replace" "cleanup"
+replace_head()
+{
+ atf_set descr 'Test table replace command'
+ atf_set require.user root
+}
+
+replace_body()
+{
+ pft_init
+ pwd=$(pwd)
+
+ epair_send=$(vnet_mkepair)
+ ifconfig ${epair_send}a 192.0.2.1/24 up
+
+ vnet_mkjail alcatraz ${epair_send}b
+ jexec alcatraz ifconfig ${epair_send}b 192.0.2.2/24 up
+ jexec alcatraz pfctl -e
+
+ pft_set_rules alcatraz \
+ "table <foo> counters { 192.0.2.1 }" \
+ "block all" \
+ "pass in from <foo> to any" \
+ "pass out from any to <foo>" \
+ "set skip on lo"
+
+ atf_check -s exit:0 -o ignore ping -c 3 192.0.2.2
+
+ # Replace the address
+ atf_check -s exit:0 -e "match:1 addresses added." -e "match:1 addresses deleted." \
+ jexec alcatraz pfctl -t foo -T replace 192.0.2.3
+ atf_check -s exit:0 -o "match:192.0.2.3" \
+ jexec alcatraz pfctl -t foo -T show
+ atf_check -s exit:2 -o ignore ping -c 3 192.0.2.2
+
+ # Negated address
+ atf_check -s exit:0 -e "match:1 addresses changed." \
+ jexec alcatraz pfctl -t foo -T replace "!192.0.2.3"
+
+ # Now add 500 addresses
+ for i in `seq 1 2`; do
+ for j in `seq 1 250`; do
+ echo "1.${i}.${j}.1" >> ${pwd}/foo.lst
+ done
+ done
+ atf_check -s exit:0 -e "match:500 addresses added." -e "match:1 addresses deleted." \
+ jexec alcatraz pfctl -t foo -T replace -f ${pwd}/foo.lst
+
+ atf_check -s exit:0 -o "not-match:192.0.2.3" \
+ jexec alcatraz pfctl -t foo -T show
+
+ # Loading the same list produces no changes.
+ atf_check -s exit:0 -e "match:no changes." \
+ jexec alcatraz pfctl -t foo -T replace -f ${pwd}/foo.lst
+}
+
+replace_cleanup()
+{
+ pft_cleanup
+}
+
atf_init_test_cases()
{
atf_add_test_case "v4_counters"
@@ -765,4 +826,5 @@ atf_init_test_cases()
atf_add_test_case "large"
atf_add_test_case "show_recursive"
atf_add_test_case "in_anchor"
+ atf_add_test_case "replace"
}
diff --git a/tools/build/depend-cleanup.sh b/tools/build/depend-cleanup.sh
index aa01db6ccc37..d751118a79a2 100755
--- a/tools/build/depend-cleanup.sh
+++ b/tools/build/depend-cleanup.sh
@@ -476,3 +476,30 @@ if [ -f "$OBJTOP"/usr.sbin/moused/moused ]; then
echo "Removing old moused binary"
run rm -fv "$OBJTOP"/usr.sbin/moused/moused
fi
+
+if [ ${MACHINE} = riscv ]; then
+ # 20251031 df21a004be23 libc: scalar strrchr() in RISC-V assembly
+ clean_dep lib/libc strrchr c
+
+ # 20251031 563efdd3bd5d libc: scalar memchr() in RISC-V assembly
+ clean_dep lib/libc memchr c
+
+ # 20251031 40a958d5850d libc: scalar memset() in RISC-V assembly
+ clean_dep lib/libc memset c
+
+ # 20251031 e09c1583eddd libc: scalar strlen() in RISC-V assembly
+ clean_dep lib/libc strlen c
+
+ # 20251031 25fdd86a4c92 libc: scalar memcpy() in RISC-V assembly
+ clean_dep lib/libc memcpy c
+
+ # 20251031 5a52f0704435 libc: scalar strnlen() in RISC-V assembly
+ clean_dep lib/libc strnlen c
+
+ # 20251031 08af0bbc9c7d libc: scalar strchrnul() in RISC-V assembly
+ clean_dep lib/libc strchrnul c
+
+ # 20251031 b5dbf3de5611 libc/riscv64: implement bcopy() and bzero() through memcpy() and memset()
+ clean_dep lib/libc bcopy c "libc.string.bcopy.c"
+ clean_dep lib/libc bzero c "libc.string.bzero.c"
+fi
diff --git a/usr.bin/id/id.c b/usr.bin/id/id.c
index 5f9d2670caa3..7ba07daad11e 100644
--- a/usr.bin/id/id.c
+++ b/usr.bin/id/id.c
@@ -67,19 +67,13 @@ main(int argc, char *argv[])
{
struct group *gr;
struct passwd *pw;
-#ifdef USE_BSM_AUDIT
- bool Aflag;
-#endif
- bool Gflag, Mflag, Pflag;
+ bool Aflag, Gflag, Mflag, Pflag;
bool cflag, dflag, gflag, nflag, pflag, rflag, sflag, uflag;
int ch, combo, error, id;
const char *myname, *optstr;
char loginclass[MAXLOGNAME];
-#ifdef USE_BSM_AUDIT
- Aflag = false;
-#endif
- Gflag = Mflag = Pflag = false;
+ Aflag = Gflag = Mflag = Pflag = false;
cflag = dflag = gflag = nflag = pflag = rflag = sflag = uflag = false;
myname = getprogname();
diff --git a/usr.bin/sockstat/main.c b/usr.bin/sockstat/main.c
index 07663e54534d..1f174d827e1a 100644
--- a/usr.bin/sockstat/main.c
+++ b/usr.bin/sockstat/main.c
@@ -88,6 +88,7 @@ static bool opt_A; /* Show kernel address of pcb */
static bool opt_b; /* Show BBLog state */
static bool opt_C; /* Show congestion control */
static bool opt_c; /* Show connected sockets */
+static bool opt_F; /* Show sockets for selected user only */
static bool opt_f; /* Show FIB numbers */
static bool opt_I; /* Show spliced socket addresses */
static bool opt_i; /* Show inp_gencnt */
@@ -115,6 +116,12 @@ static size_t default_numprotos = nitems(default_protos);
static int *protos; /* protocols to use */
static size_t numprotos; /* allocated size of protos[] */
+/*
+ * Show sockets for user username or UID specified
+ */
+static char *filter_user_optarg = NULL; /* saved optarg for username/UID resolving */
+static uid_t filter_user_uid; /* UID to show sockets for */
+
struct addr {
union {
struct sockaddr_storage address;
@@ -217,6 +224,18 @@ _enforce_ksize(size_t received_size, size_t expected_size, const char *struct_na
}
#define enforce_ksize(_sz, _struct) (_enforce_ksize(_sz, sizeof(_struct), #_struct))
+static inline bool
+filtered_uid(uid_t i_uid)
+{
+ return ((i_uid) == filter_user_uid);
+}
+
+static inline bool
+need_nosocks(void)
+{
+ return !(opt_F || (opt_j >= 0));
+}
+
static int
get_proto_type(const char *proto)
{
@@ -758,7 +777,8 @@ gather_inet(int proto)
if (sock->socket != 0)
RB_INSERT(socks_t, &socks, sock);
else
- SLIST_INSERT_HEAD(&nosocks, sock, socket_list);
+ if (need_nosocks())
+ SLIST_INSERT_HEAD(&nosocks, sock, socket_list);
}
out:
free(buf);
@@ -862,6 +882,8 @@ getfiles(void)
struct xfile *xfiles;
size_t len, olen;
+ int filenum = 0;
+
olen = len = sizeof(*xfiles);
if ((xfiles = malloc(len)) == NULL)
xo_err(1, "malloc()");
@@ -880,14 +902,23 @@ getfiles(void)
if ((files = malloc(nfiles * sizeof(struct file))) == NULL)
xo_err(1, "malloc()");
+ /* Fill files structure, optionally for specified user */
for (int i = 0; i < nfiles; i++) {
- files[i].xf_data = xfiles[i].xf_data;
- files[i].xf_pid = xfiles[i].xf_pid;
- files[i].xf_uid = xfiles[i].xf_uid;
- files[i].xf_fd = xfiles[i].xf_fd;
- RB_INSERT(files_t, &ftree, &files[i]);
+ if (opt_F && !filtered_uid(xfiles[i].xf_uid))
+ continue;
+ files[filenum].xf_data = xfiles[i].xf_data;
+ files[filenum].xf_pid = xfiles[i].xf_pid;
+ files[filenum].xf_uid = xfiles[i].xf_uid;
+ files[filenum].xf_fd = xfiles[i].xf_fd;
+ RB_INSERT(files_t, &ftree, &files[filenum]);
+ filenum++;
}
+ /* Adjust global nfiles to match the number of files we
+ * actually filled into files[] array
+ */
+ nfiles = filenum;
+
free(xfiles);
}
@@ -1584,6 +1615,24 @@ display_sock(struct sock *s, struct col_widths *cw, char *buf, size_t bufsize)
static void
display(void)
{
+ static const char *__HDR_USER="USER",
+ *__HDR_COMMAND="COMMAND",
+ *__HDR_PID="PID",
+ *__HDR_FD="FD",
+ *__HDR_PROTO="PROTO",
+ *__HDR_LOCAL_ADDRESS="LOCAL ADDRESS",
+ *__HDR_FOREIGN_ADDRESS="FOREIGN ADDRESS",
+ *__HDR_PCB_KVA="PCB KVA",
+ *__HDR_FIB="FIB",
+ *__HDR_SPLICE_ADDRESS="SPLICE ADDRESS",
+ *__HDR_ID="ID",
+ *__HDR_ENCAPS="ENCAPS",
+ *__HDR_PATH_STATE="PATH STATE",
+ *__HDR_CONN_STATE="CONN STATE",
+ *__HDR_BBLOG_STATE="BBLOG STATE",
+ *__HDR_STACK="STACK",
+ *__HDR_CC="CC";
+
struct passwd *pwd;
struct file *xf;
struct sock *s;
@@ -1598,23 +1647,23 @@ display(void)
if (!is_xo_style_encoding) {
cw = (struct col_widths) {
- .user = strlen("USER"),
+ .user = strlen(__HDR_USER),
.command = 10,
- .pid = strlen("PID"),
- .fd = strlen("FD"),
- .proto = strlen("PROTO"),
- .local_addr = opt_w ? strlen("LOCAL ADDRESS") : 21,
- .foreign_addr = opt_w ? strlen("FOREIGN ADDRESS") : 21,
+ .pid = strlen(__HDR_PID),
+ .fd = strlen(__HDR_FD),
+ .proto = strlen(__HDR_PROTO),
+ .local_addr = opt_w ? strlen(__HDR_LOCAL_ADDRESS) : 21,
+ .foreign_addr = opt_w ? strlen(__HDR_FOREIGN_ADDRESS) : 21,
.pcb_kva = 18,
- .fib = strlen("FIB"),
- .splice_address = strlen("SPLICE ADDRESS"),
- .inp_gencnt = strlen("ID"),
- .encaps = strlen("ENCAPS"),
- .path_state = strlen("PATH STATE"),
- .conn_state = strlen("CONN STATE"),
- .bblog_state = strlen("BBLOG STATE"),
- .stack = strlen("STACK"),
- .cc = strlen("CC"),
+ .fib = strlen(__HDR_FIB),
+ .splice_address = strlen(__HDR_SPLICE_ADDRESS),
+ .inp_gencnt = strlen(__HDR_ID),
+ .encaps = strlen(__HDR_ENCAPS),
+ .path_state = strlen(__HDR_PATH_STATE),
+ .conn_state = strlen(__HDR_CONN_STATE),
+ .bblog_state = strlen(__HDR_BBLOG_STATE),
+ .stack = strlen(__HDR_STACK),
+ .cc = strlen(__HDR_CC),
};
calculate_column_widths(&cw);
} else
@@ -1625,34 +1674,34 @@ display(void)
xo_open_list("socket");
if (!opt_q) {
xo_emit("{T:/%-*s} {T:/%-*s} {T:/%*s} {T:/%*s} {T:/%-*s} "
- "{T:/%-*s} {T:/%-*s}", cw.user, "USER", cw.command,
- "COMMAND", cw.pid, "PID", cw.fd, "FD", cw.proto,
- "PROTO", cw.local_addr, "LOCAL ADDRESS",
- cw.foreign_addr, "FOREIGN ADDRESS");
+ "{T:/%-*s} {T:/%-*s}", cw.user, __HDR_USER, cw.command,
+ __HDR_COMMAND, cw.pid, __HDR_PID, cw.fd, __HDR_FD, cw.proto,
+ __HDR_PROTO, cw.local_addr, __HDR_LOCAL_ADDRESS,
+ cw.foreign_addr, __HDR_FOREIGN_ADDRESS);
if (opt_A)
- xo_emit(" {T:/%-*s}", cw.pcb_kva, "PCB KVA");
+ xo_emit(" {T:/%-*s}", cw.pcb_kva, __HDR_PCB_KVA);
if (opt_f)
/* RT_MAXFIBS is 65535. */
- xo_emit(" {T:/%*s}", cw.fib, "FIB");
+ xo_emit(" {T:/%*s}", cw.fib, __HDR_FIB);
if (opt_I)
xo_emit(" {T:/%-*s}", cw.splice_address,
- "SPLICE ADDRESS");
+ __HDR_SPLICE_ADDRESS);
if (opt_i)
- xo_emit(" {T:/%*s}", cw.inp_gencnt, "ID");
+ xo_emit(" {T:/%*s}", cw.inp_gencnt, __HDR_ID);
if (opt_U)
- xo_emit(" {T:/%*s}", cw.encaps, "ENCAPS");
+ xo_emit(" {T:/%*s}", cw.encaps, __HDR_ENCAPS);
if (opt_s) {
if (show_path_state)
xo_emit(" {T:/%-*s}", cw.path_state,
- "PATH STATE");
- xo_emit(" {T:/%-*s}", cw.conn_state, "CONN STATE");
+ __HDR_PATH_STATE);
+ xo_emit(" {T:/%-*s}", cw.conn_state, __HDR_CONN_STATE);
}
if (opt_b)
- xo_emit(" {T:/%-*s}", cw.bblog_state, "BBLOG STATE");
+ xo_emit(" {T:/%-*s}", cw.bblog_state, __HDR_BBLOG_STATE);
if (opt_S)
- xo_emit(" {T:/%-*s}", cw.stack, "STACK");
+ xo_emit(" {T:/%-*s}", cw.stack, __HDR_STACK);
if (opt_C)
- xo_emit(" {T:/%-*s}", cw.cc, "CC");
+ xo_emit(" {T:/%-*s}", cw.cc, __HDR_CC);
xo_emit("\n");
}
cap_setpassent(cappwd, 1);
@@ -1684,7 +1733,7 @@ display(void)
xo_close_instance("socket");
}
}
- if (opt_j >= 0)
+ if (!need_nosocks())
goto out;
SLIST_FOREACH(s, &nosocks, socket_list) {
if (!check_ports(s))
@@ -1775,11 +1824,44 @@ jail_getvnet(int jid)
return (vnet);
}
+/*
+ * Parse username and/or UID
+ */
+static bool
+parse_filter_user(void)
+{
+ struct passwd *pwd;
+ char *ep;
+ uid_t uid;
+ bool rv = false;
+
+ uid = (uid_t)strtol(filter_user_optarg, &ep, 10);
+
+ /* Open and/or rewind capsicumized password file */
+ cap_setpassent(cappwd, 1);
+
+ if (*ep == '\0') {
+ /* We have an UID specified, check if it's valid */
+ if ((pwd = cap_getpwuid(cappwd, uid)) == NULL)
+ goto out;
+ filter_user_uid = uid;
+ } else {
+ /* Check if we have a valid username */
+ if ((pwd = cap_getpwnam(cappwd, filter_user_optarg)) == NULL)
+ goto out;
+ filter_user_uid = pwd->pw_uid;
+ }
+
+ rv = true;
+out:
+ return (rv);
+}
+
static void
usage(void)
{
xo_error(
-"usage: sockstat [--libxo ...] [-46AbCcfIiLlnqSsUuvw] [-j jid] [-p ports]\n"
+"usage: sockstat [--libxo ...] [-46AbCcfIiLlnqSsUuvw] [-F uid/username] [-j jid] [-p ports]\n"
" [-P protocols]\n");
exit(1);
}
@@ -1789,8 +1871,8 @@ main(int argc, char *argv[])
{
cap_channel_t *capcas;
cap_net_limit_t *limit;
- const char *pwdcmds[] = { "setpassent", "getpwuid" };
- const char *pwdfields[] = { "pw_name" };
+ const char *pwdcmds[] = { "setpassent", "getpwuid", "getpwnam" };
+ const char *pwdfields[] = { "pw_name", "pw_uid" };
int protos_defined = -1;
int o, i, err;
@@ -1803,7 +1885,7 @@ main(int argc, char *argv[])
is_xo_style_encoding = true;
}
opt_j = -1;
- while ((o = getopt(argc, argv, "46AbCcfIij:Llnp:P:qSsUuvw")) != -1)
+ while ((o = getopt(argc, argv, "46AbCcF:fIij:Llnp:P:qSsUuvw")) != -1)
switch (o) {
case '4':
opt_4 = true;
@@ -1823,6 +1905,11 @@ main(int argc, char *argv[])
case 'c':
opt_c = true;
break;
+ case 'F':
+ /* Save optarg for later use when we enter capabilities mode */
+ filter_user_optarg = optarg;
+ opt_F = true;
+ break;
case 'f':
opt_f = true;
break;
@@ -1934,6 +2021,9 @@ main(int argc, char *argv[])
if (cap_pwd_limit_fields(cappwd, pwdfields, nitems(pwdfields)) < 0)
xo_err(1, "Unable to apply pwd commands limits");
+ if (opt_F && !parse_filter_user())
+ xo_errx(1, "Invalid username or UID specified");
+
if ((!opt_4 && !opt_6) && protos_defined != -1)
opt_4 = opt_6 = true;
if (!opt_4 && !opt_6 && !opt_u)
diff --git a/usr.bin/sockstat/sockstat.1 b/usr.bin/sockstat/sockstat.1
index 1498fb1d88f7..b0fae81ee566 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 14, 2025
+.Dd October 29, 2025
.Dt SOCKSTAT 1
.Os
.Sh NAME
@@ -35,6 +35,7 @@
.Nm
.Op Fl -libxo
.Op Fl 46AbCcfIiLlnqSsUuvw
+.Op Fl F Ar user
.Op Fl j Ar jail
.Op Fl p Ar ports
.Op Fl P Ar protocols
@@ -73,6 +74,10 @@ Display the congestion control module, if applicable.
This is currently only implemented for TCP.
.It Fl c
Show connected sockets.
+.It Fl F Ar user
+Show sockets for specified
+.Ar user
+(user name or UID) only.
.It Fl f
Show the FIB number of each socket.
.It Fl I
diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c
index 656d642e1f19..7b299bd2e1ff 100644
--- a/usr.bin/truss/syscalls.c
+++ b/usr.bin/truss/syscalls.c
@@ -403,7 +403,7 @@ static const struct syscall_decode decoded_syscalls[] = {
{ .name = "nanosleep", .ret_type = 1, .nargs = 1,
.args = { { Timespec, 0 } } },
{ .name = "nmount", .ret_type = 1, .nargs = 3,
- .args = { { Ptr, 0 }, { UInt, 1 }, { Mountflags, 2 } } },
+ .args = { { Iovec | IN, 0 }, { UInt, 1 }, { Mountflags, 2 } } },
{ .name = "open", .ret_type = 1, .nargs = 3,
.args = { { Name | IN, 0 }, { Open, 1 }, { Octal, 2 } } },
{ .name = "openat", .ret_type = 1, .nargs = 4,
diff --git a/usr.sbin/bhyve/bhyve.8 b/usr.sbin/bhyve/bhyve.8
index 3df9f79c3b2c..27e067f50394 100644
--- a/usr.sbin/bhyve/bhyve.8
+++ b/usr.sbin/bhyve/bhyve.8
@@ -1,3 +1,6 @@
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
.\" Copyright (c) 2013 Peter Grehan
.\" All rights reserved.
.\"
@@ -22,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd September 16, 2025
+.Dd October 28, 2025
.Dt BHYVE 8
.Os
.Sh NAME
@@ -125,7 +128,7 @@ xAPIC mode is the default setting so this option is redundant.
It will be deprecated in a future version.
.It Fl C
Include guest memory in core files.
-.It Fl c Op Ar setting ...
+.It Fl c Oo Oo Cm cpus= Oc Ns Ar numcpus Oc Ns Oo Cm ,sockets= Ns Ar n Oc Ns Oo Cm ,cores= Ns Ar n Oc Ns Oo Cm ,threads= Ns Ar n Oc
Number of guest virtual CPUs
and/or the CPU topology.
The default value for each of
diff --git a/usr.sbin/cron/lib/env.c b/usr.sbin/cron/lib/env.c
index 287dd8636293..5a2d7ad60756 100644
--- a/usr.sbin/cron/lib/env.c
+++ b/usr.sbin/cron/lib/env.c
@@ -55,7 +55,7 @@ env_copy(char **envp)
for (count = 0; envp[count] != NULL; count++)
;
- p = (char **) malloc((count+1) * sizeof(char *)); /* 1 for the NULL */
+ p = (char **) reallocarray(NULL, count+1, sizeof(char *)); /* 1 for the NULL */
if (p == NULL) {
errno = ENOMEM;
return NULL;
@@ -112,8 +112,7 @@ env_set(char **envp, char *envstr)
* one, save our string over the old null pointer, and return resized
* array.
*/
- p = (char **) realloc((void *) envp,
- (unsigned) ((count+1) * sizeof(char *)));
+ p = (char **) reallocarray(envp, count+1, sizeof(char *));
if (p == NULL) {
/* XXX env_free(envp); */
errno = ENOMEM;
diff --git a/usr.sbin/pkg/Makefile b/usr.sbin/pkg/Makefile
index 0420065bb7eb..68b862826992 100644
--- a/usr.sbin/pkg/Makefile
+++ b/usr.sbin/pkg/Makefile
@@ -1,5 +1,6 @@
PACKAGE= pkg-bootstrap
+.MAKEFLAGS: -W
_BRANCH!= ${MAKE} -C ${SRCTOP}/release -V BRANCH
BRANCH?= ${_BRANCH}
.if ${BRANCH:MCURRENT} != ""