aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/pwait/pwait.16
-rw-r--r--bin/pwait/pwait.c98
-rw-r--r--bin/pwait/tests/pwait_test.sh38
-rwxr-xr-xcontrib/blocklist/libexec/blocklistd-helper4
-rw-r--r--lib/libpfctl/libpfctl.c3
-rw-r--r--lib/libsys/closefrom.27
-rw-r--r--libexec/blocklistd-helper/blacklistd-helper4
-rwxr-xr-xlibexec/rc/rc.d/blacklistd2
-rwxr-xr-x[-rw-r--r--]libexec/rc/rc.d/blocklistd2
-rw-r--r--libexec/rc/rc.subr29
-rw-r--r--sbin/bsdlabel/bsdlabel.82
-rw-r--r--sbin/bsdlabel/bsdlabel.c2
-rw-r--r--sbin/ipf/ipfs/ipfs.c2
-rw-r--r--sbin/ipfw/ipfw2.c6
-rw-r--r--sbin/pfctl/pfctl.c5
-rw-r--r--share/man/man4/agp.44
-rw-r--r--share/man/man4/upgt.44
-rw-r--r--share/man/man7/stats.73
-rw-r--r--share/man/man7/tuning.73
-rw-r--r--share/man/man9/gone_in.942
-rw-r--r--share/man/man9/insmntque.96
-rw-r--r--share/misc/pci_vendors8
-rw-r--r--share/misc/usb_vendors11
-rw-r--r--sys/arm/nvidia/tegra_ahci.c2
-rw-r--r--sys/arm/nvidia/tegra_lic.c4
-rw-r--r--sys/arm/nvidia/tegra_mc.c2
-rw-r--r--sys/arm/nvidia/tegra_xhci.c4
-rw-r--r--sys/conf/files1
-rw-r--r--sys/dev/acpica/acpi.c4
-rw-r--r--sys/dev/hyperv/netvsc/if_hn.c6
-rw-r--r--sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c2
-rw-r--r--sys/dev/hyperv/utilities/hv_kvp.c2
-rw-r--r--sys/dev/md/md.c8
-rw-r--r--sys/dev/ocs_fc/ocs_device.c2
-rw-r--r--sys/dev/ocs_fc/ocs_els.c4
-rw-r--r--sys/dev/ocs_fc/ocs_gendump.c4
-rw-r--r--sys/dev/ocs_fc/ocs_ioctl.c2
-rw-r--r--sys/dev/ocs_fc/ocs_scsi.c2
-rw-r--r--sys/dev/ocs_fc/ocs_xport.c4
-rw-r--r--sys/dev/virtio/gpu/virtio_gpu.c10
-rw-r--r--sys/dev/virtio/scmi/virtio_scmi.c2
-rw-r--r--sys/dev/xilinx/xlnx_pcib.c32
-rw-r--r--sys/fs/fuse/fuse_ipc.c2
-rw-r--r--sys/fs/fuse/fuse_vnops.c2
-rw-r--r--sys/fs/nfs/nfs_commonsubs.c13
-rw-r--r--sys/isa/isa_common.c4
-rw-r--r--sys/modules/dummynet/Makefile3
-rw-r--r--sys/net/altq/altq_cbq.c2
-rw-r--r--sys/net/altq/altq_fairq.c2
-rw-r--r--sys/net/altq/altq_priq.c2
-rw-r--r--sys/net/if.c34
-rw-r--r--sys/net/if_var.h8
-rw-r--r--sys/netinet/raw_ip.c4
-rw-r--r--sys/netinet/tcp_syncache.c14
-rw-r--r--sys/netpfil/ipfw/ip_dn_glue.c858
-rw-r--r--sys/netpfil/ipfw/ip_dn_private.h10
-rw-r--r--sys/netpfil/ipfw/ip_dummynet.c96
-rw-r--r--sys/tools/gdb/README.txt5
-rw-r--r--sys/tools/gdb/acttrace.py6
-rw-r--r--sys/tools/gdb/pcpu.py2
-rw-r--r--sys/tools/gdb/vnet.py2
-rw-r--r--sys/tools/kernel-gdb.py36
-rw-r--r--tests/sys/file/Makefile2
-rw-r--r--tests/sys/file/closefrom_test.c490
-rw-r--r--tests/sys/fs/fusefs/bad_server.cc8
-rw-r--r--tests/sys/fs/fusefs/mockfs.cc5
-rw-r--r--tests/sys/fs/fusefs/mockfs.hh3
-rw-r--r--tests/sys/netpfil/pf/anchor.sh46
-rw-r--r--usr.bin/id/id.128
-rw-r--r--usr.bin/id/id.c154
-rw-r--r--usr.bin/kyua/Makefile10
71 files changed, 778 insertions, 1461 deletions
diff --git a/bin/pwait/pwait.1 b/bin/pwait/pwait.1
index 83ac8bcef317..d92b829b1d6a 100644
--- a/bin/pwait/pwait.1
+++ b/bin/pwait/pwait.1
@@ -30,7 +30,7 @@
.\" USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
.\" OF SUCH DAMAGE.
.\"
-.Dd January 21, 2021
+.Dd October 22, 2025
.Dt PWAIT 1
.Os
.Sh NAME
@@ -39,7 +39,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl t Ar duration
-.Op Fl ov
+.Op Fl opv
.Ar pid
\&...
.Sh DESCRIPTION
@@ -51,6 +51,8 @@ The following option is available:
.Bl -tag -width indent
.It Fl o
Exit when any of the given processes has terminated.
+.It Fl p
+On exit, print a list of processes that have not terminated.
.It Fl t Ar duration
If any process is still running after
.Ar duration ,
diff --git a/bin/pwait/pwait.c b/bin/pwait/pwait.c
index 27f4c8e9858d..59bf0eb93ced 100644
--- a/bin/pwait/pwait.c
+++ b/bin/pwait/pwait.c
@@ -33,7 +33,9 @@
#include <sys/types.h>
#include <sys/event.h>
+#include <sys/sysctl.h>
#include <sys/time.h>
+#include <sys/tree.h>
#include <sys/wait.h>
#include <err.h>
@@ -46,10 +48,25 @@
#include <sysexits.h>
#include <unistd.h>
+struct pid {
+ RB_ENTRY(pid) entry;
+ pid_t pid;
+};
+
+static int
+pidcmp(const struct pid *a, const struct pid *b)
+{
+ return (a->pid > b->pid ? 1 : a->pid < b->pid ? -1 : 0);
+}
+
+RB_HEAD(pidtree, pid);
+static struct pidtree pids = RB_INITIALIZER(&pids);
+RB_GENERATE_STATIC(pidtree, pid, entry, pidcmp);
+
static void
usage(void)
{
- fprintf(stderr, "usage: pwait [-t timeout] [-ov] pid ...\n");
+ fprintf(stderr, "usage: pwait [-t timeout] [-opv] pid ...\n");
exit(EX_USAGE);
}
@@ -61,22 +78,28 @@ main(int argc, char *argv[])
{
struct itimerval itv;
struct kevent *e;
+ struct pid k, *p;
char *end, *s;
double timeout;
+ size_t sz;
long pid;
pid_t mypid;
- int i, kq, n, nleft, opt, status;
- bool oflag, tflag, verbose;
+ int i, kq, n, ndone, nleft, opt, pid_max, ret, status;
+ bool oflag, pflag, tflag, verbose;
oflag = false;
+ pflag = false;
tflag = false;
verbose = false;
memset(&itv, 0, sizeof(itv));
- while ((opt = getopt(argc, argv, "ot:v")) != -1) {
+ while ((opt = getopt(argc, argv, "opt:v")) != -1) {
switch (opt) {
case 'o':
- oflag = 1;
+ oflag = true;
+ break;
+ case 'p':
+ pflag = true;
break;
case 't':
tflag = true;
@@ -128,16 +151,17 @@ main(int argc, char *argv[])
usage();
}
- kq = kqueue();
- if (kq == -1) {
+ if ((kq = kqueue()) < 0)
err(EX_OSERR, "kqueue");
- }
- e = malloc((argc + tflag) * sizeof(struct kevent));
- if (e == NULL) {
+ sz = sizeof(pid_max);
+ if (sysctlbyname("kern.pid_max", &pid_max, &sz, NULL, 0) != 0) {
+ pid_max = 99999;
+ }
+ if ((e = malloc((argc + tflag) * sizeof(*e))) == NULL) {
err(EX_OSERR, "malloc");
}
- nleft = 0;
+ ndone = nleft = 0;
mypid = getpid();
for (n = 0; n < argc; n++) {
s = argv[n];
@@ -147,7 +171,7 @@ main(int argc, char *argv[])
}
errno = 0;
pid = strtol(s, &end, 10);
- if (pid < 0 || *end != '\0' || errno != 0) {
+ if (pid < 0 || pid > pid_max || *end != '\0' || errno != 0) {
warnx("%s: bad process id", s);
continue;
}
@@ -155,27 +179,29 @@ main(int argc, char *argv[])
warnx("%s: skipping my own pid", s);
continue;
}
- for (i = 0; i < nleft; i++) {
- if (e[i].ident == (uintptr_t)pid) {
- break;
- }
+ if ((p = malloc(sizeof(*p))) == NULL) {
+ err(EX_OSERR, NULL);
}
- if (i < nleft) {
+ p->pid = pid;
+ if (RB_INSERT(pidtree, &pids, p) != NULL) {
/* Duplicate. */
+ free(p);
continue;
}
EV_SET(e + nleft, pid, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, NULL);
if (kevent(kq, e + nleft, 1, NULL, 0, NULL) == -1) {
+ if (errno != ESRCH)
+ err(EX_OSERR, "kevent()");
warn("%ld", pid);
- if (oflag) {
- exit(EX_OK);
- }
+ RB_REMOVE(pidtree, &pids, p);
+ free(p);
+ ndone++;
} else {
nleft++;
}
}
- if (nleft > 0 && tflag) {
+ if ((ndone == 0 || !oflag) && nleft > 0 && tflag) {
/*
* Explicitly detect SIGALRM so that an exit status of 124
* can be returned rather than 142.
@@ -190,7 +216,8 @@ main(int argc, char *argv[])
err(EX_OSERR, "setitimer");
}
}
- while (nleft > 0) {
+ ret = EX_OK;
+ while ((ndone == 0 || !oflag) && ret == EX_OK && nleft > 0) {
n = kevent(kq, NULL, 0, e, nleft + tflag, NULL);
if (n == -1) {
err(EX_OSERR, "kevent");
@@ -200,29 +227,34 @@ main(int argc, char *argv[])
if (verbose) {
printf("timeout\n");
}
- exit(124);
+ ret = 124;
}
+ pid = e[i].ident;
if (verbose) {
status = e[i].data;
if (WIFEXITED(status)) {
printf("%ld: exited with status %d.\n",
- (long)e[i].ident,
- WEXITSTATUS(status));
+ pid, WEXITSTATUS(status));
} else if (WIFSIGNALED(status)) {
printf("%ld: killed by signal %d.\n",
- (long)e[i].ident,
- WTERMSIG(status));
+ pid, WTERMSIG(status));
} else {
- printf("%ld: terminated.\n",
- (long)e[i].ident);
+ printf("%ld: terminated.\n", pid);
}
}
- if (oflag) {
- exit(EX_OK);
+ k.pid = pid;
+ if ((p = RB_FIND(pidtree, &pids, &k)) != NULL) {
+ RB_REMOVE(pidtree, &pids, p);
+ free(p);
+ ndone++;
}
--nleft;
}
}
-
- exit(EX_OK);
+ if (pflag) {
+ RB_FOREACH(p, pidtree, &pids) {
+ printf("%d\n", p->pid);
+ }
+ }
+ exit(ret);
}
diff --git a/bin/pwait/tests/pwait_test.sh b/bin/pwait/tests/pwait_test.sh
index 66bdd6981704..d31ca21cff93 100644
--- a/bin/pwait/tests/pwait_test.sh
+++ b/bin/pwait/tests/pwait_test.sh
@@ -310,6 +310,43 @@ or_flag_cleanup()
wait $p2 $p4 $p6 >/dev/null 2>&1
}
+atf_test_case print
+print_head()
+{
+ atf_set "descr" "Test the -p flag"
+}
+
+print_body()
+{
+ sleep 1 &
+ p1=$!
+
+ sleep 5 &
+ p5=$!
+
+ sleep 10 &
+ p10=$!
+
+ atf_check \
+ -o inline:"$p5\n$p10\n" \
+ -s exit:124 \
+ pwait -t 2 -p $p10 $p5 $p1 $p5 $p10
+
+ atf_check \
+ -e inline:"kill: $p1: No such process\n" \
+ -s exit:1 \
+ kill -0 $p1
+
+ atf_check kill -0 $p5
+ atf_check kill -0 $p10
+}
+
+print_cleanup()
+{
+ kill $p1 $p5 $p10 >/dev/null 2>&1
+ wait $p1 $p5 $p10 >/dev/null 2>&1
+}
+
atf_init_test_cases()
{
atf_add_test_case basic
@@ -318,4 +355,5 @@ atf_init_test_cases()
atf_add_test_case timeout_no_timeout
atf_add_test_case timeout_many
atf_add_test_case or_flag
+ atf_add_test_case print
}
diff --git a/contrib/blocklist/libexec/blocklistd-helper b/contrib/blocklist/libexec/blocklistd-helper
index 1d4a38b1d831..f27cde4ed4ea 100755
--- a/contrib/blocklist/libexec/blocklistd-helper
+++ b/contrib/blocklist/libexec/blocklistd-helper
@@ -258,8 +258,8 @@ flush)
pf)
# dynamically determine which anchors exist
for anchor in $(/sbin/pfctl -a "$2" -s Anchors 2> /dev/null); do
- /sbin/pfctl -a "$anchor" -t "port${anchor##*/}" -T flush 2> /dev/null
- /sbin/pfctl -a "$anchor" -F rules 2> /dev/null
+ /sbin/pfctl -a "$anchor" -t "port${anchor##*/}" -T flush
+ /sbin/pfctl -a "$anchor" -F rules
done
echo OK
;;
diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c
index 8c4b26b98054..17576066fcfd 100644
--- a/lib/libpfctl/libpfctl.c
+++ b/lib/libpfctl/libpfctl.c
@@ -3202,6 +3202,9 @@ pfctl_get_ruleset(struct pfctl_handle *h, const char *path, uint32_t nr, struct
continue;
}
+ rs->nr = nr;
+ strlcpy(rs->path, path, sizeof(rs->path));
+
return (e.error);
}
diff --git a/lib/libsys/closefrom.2 b/lib/libsys/closefrom.2
index 1885a6fdeaa8..e6b4a5a3e9d7 100644
--- a/lib/libsys/closefrom.2
+++ b/lib/libsys/closefrom.2
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd May 17, 2025
+.Dd October 27, 2025
.Dt CLOSEFROM 2
.Os
.Sh NAME
@@ -94,6 +94,11 @@ function first appeared in
.Fx 8.0 .
.Pp
The
+.Fn close_range
+function first appeared in
+.Fx 12.2 .
+.Pp
+The
.Dv CLOSE_RANGE_CLOFORK
flag appeared in
.Fx 15.0 .
diff --git a/libexec/blocklistd-helper/blacklistd-helper b/libexec/blocklistd-helper/blacklistd-helper
index 053c9ce9b2a2..4195f070e8ee 100644
--- a/libexec/blocklistd-helper/blacklistd-helper
+++ b/libexec/blocklistd-helper/blacklistd-helper
@@ -279,8 +279,8 @@ flush)
pf)
# dynamically determine which anchors exist
for anchor in $(/sbin/pfctl -a "$2" -s Anchors 2> /dev/null); do
- /sbin/pfctl -a "$anchor" -t "port${anchor##*/}" -T flush 2> /dev/null
- /sbin/pfctl -a "$anchor" -F rules 2> /dev/null
+ /sbin/pfctl -a "$anchor" -t "port${anchor##*/}" -T flush
+ /sbin/pfctl -a "$anchor" -F rules
done
echo OK
;;
diff --git a/libexec/rc/rc.d/blacklistd b/libexec/rc/rc.d/blacklistd
index 9157e258f43f..175e3e8c56b3 100755
--- a/libexec/rc/rc.d/blacklistd
+++ b/libexec/rc/rc.d/blacklistd
@@ -29,7 +29,7 @@
#
# PROVIDE: blacklistd
-# REQUIRE: netif pf
+# REQUIRE: netif ipfilter ipfw pf
. /etc/rc.subr
diff --git a/libexec/rc/rc.d/blocklistd b/libexec/rc/rc.d/blocklistd
index 24cbae77fd40..f979162ec3e0 100644..100755
--- a/libexec/rc/rc.d/blocklistd
+++ b/libexec/rc/rc.d/blocklistd
@@ -29,7 +29,7 @@
#
# PROVIDE: blocklistd
-# REQUIRE: netif pf
+# REQUIRE: netif ipfilter ipfw pf
. /etc/rc.subr
diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr
index 6be226021949..8317ff5c0922 100644
--- a/libexec/rc/rc.subr
+++ b/libexec/rc/rc.subr
@@ -792,31 +792,18 @@ sort_lite()
#
wait_for_pids()
{
- local _list _prefix _nlist _j
+ local _list _prefix _j
- _list="$@"
- if [ -z "$_list" ]; then
- return
- fi
- _prefix=
- while true; do
- _nlist=""
- for _j in $_list; do
- if kill -0 $_j 2>/dev/null; then
- _nlist="${_nlist}${_nlist:+ }$_j"
- fi
- done
- if [ -z "$_nlist" ]; then
- break
+ for _j in "$@"; do
+ if kill -0 $_j 2>/dev/null; then
+ _list="${_list}${_list:+ }$_j"
fi
- _list=$_nlist
+ done
+ _prefix=
+ while [ -n "$_list" ]; do
echo -n ${_prefix:-"Waiting for PIDS: "}$_list
_prefix=", "
- pwait -o $_list 2>/dev/null
- # At least one of the processes we were waiting for
- # has terminated. Give init a chance to collect it
- # before looping around and checking again.
- sleep 1
+ _list=$(pwait -op $_list 2>/dev/null)
done
if [ -n "$_prefix" ]; then
echo "."
diff --git a/sbin/bsdlabel/bsdlabel.8 b/sbin/bsdlabel/bsdlabel.8
index abea59756aea..cdf3cc249856 100644
--- a/sbin/bsdlabel/bsdlabel.8
+++ b/sbin/bsdlabel/bsdlabel.8
@@ -62,7 +62,7 @@
.Sh DEPRECATION NOTICE
.Nm
is deprecated and is not available in
-.Fx 15.0
+.Fx 16.0
or later.
Use
.Xr gpart 8
diff --git a/sbin/bsdlabel/bsdlabel.c b/sbin/bsdlabel/bsdlabel.c
index a68ee377a97c..912833ec12e3 100644
--- a/sbin/bsdlabel/bsdlabel.c
+++ b/sbin/bsdlabel/bsdlabel.c
@@ -136,7 +136,7 @@ main(int argc, char *argv[])
name = NULL;
fprintf(stderr,
- "WARNING: bsdlabel is deprecated and is not available in FreeBSD 15 or later.\n"
+ "WARNING: bsdlabel is deprecated and is not available in FreeBSD 16 or later.\n"
"Please use gpart instead.\n\n");
while ((ch = getopt(argc, argv, "ABb:efm:nRrw")) != -1)
diff --git a/sbin/ipf/ipfs/ipfs.c b/sbin/ipf/ipfs/ipfs.c
index 6225c6e1154d..94c9f70410f2 100644
--- a/sbin/ipf/ipfs/ipfs.c
+++ b/sbin/ipf/ipfs/ipfs.c
@@ -576,7 +576,7 @@ int readnat(int fd, char *file)
in = (nat_save_t *)malloc(ipn.ipn_dsize);
if (in == NULL) {
- fprintf(stderr, "nat:cannot malloc nat save atruct\n");
+ fprintf(stderr, "nat:cannot malloc nat save struct\n");
goto freenathead;
}
diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c
index a2b3e121e5df..27ccaea2c78f 100644
--- a/sbin/ipfw/ipfw2.c
+++ b/sbin/ipfw/ipfw2.c
@@ -648,11 +648,7 @@ do_cmd(int optname, void *optval, uintptr_t optlen)
if (ipfw_socket < 0)
err(EX_UNAVAILABLE, "socket");
- if (optname == IP_FW_GET ||
- optname == IP_FW_ADD || optname == IP_FW3 ||
- optname == IP_FW_NAT_GET_CONFIG ||
- optname < 0 ||
- optname == IP_FW_NAT_GET_LOG) {
+ if (optname == IP_FW3 || optname < 0) {
if (optname < 0)
optname = -optname;
i = getsockopt(ipfw_socket, IPPROTO_IP, optname, optval,
diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c
index ed317495c2e0..3d2632c1cf74 100644
--- a/sbin/pfctl/pfctl.c
+++ b/sbin/pfctl/pfctl.c
@@ -3167,10 +3167,7 @@ pfctl_show_eth_anchors(int dev, int opts, char *anchorname)
int ret;
if ((ret = pfctl_get_eth_rulesets_info(dev, &ri, anchorname)) != 0) {
- if (ret == ENOENT)
- fprintf(stderr, "Anchor '%s' not found.\n",
- anchorname);
- else
+ if (ret != ENOENT)
errc(1, ret, "DIOCGETETHRULESETS");
return (-1);
}
diff --git a/share/man/man4/agp.4 b/share/man/man4/agp.4
index 2aeb01850085..b7a649117f36 100644
--- a/share/man/man4/agp.4
+++ b/share/man/man4/agp.4
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd November 28, 2007
+.Dd October 24, 2025
.Dt AGP 4
.Os
.Sh NAME
@@ -34,7 +34,7 @@
The
.Nm
driver is slated to be removed in
-.Fx 15.0 .
+.Fx 16.0 .
.Sh DESCRIPTION
The
.Nm
diff --git a/share/man/man4/upgt.4 b/share/man/man4/upgt.4
index 5d4ada1d1a1f..cc5775d252ac 100644
--- a/share/man/man4/upgt.4
+++ b/share/man/man4/upgt.4
@@ -48,7 +48,7 @@
.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd February 18, 2025
+.Dd October 24, 2025
.Dt UPGT 4
.Os
.Sh NAME
@@ -78,7 +78,7 @@ if_upgt_load="YES"
The
.Nm
driver is slated to be removed in
-.Fx 15.0 .
+.Fx 16.0 .
.Sh DESCRIPTION
The
.Nm
diff --git a/share/man/man7/stats.7 b/share/man/man7/stats.7
index 715db70e118b..0b57d525522c 100644
--- a/share/man/man7/stats.7
+++ b/share/man/man7/stats.7
@@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd April 22, 2021
+.Dd October 28, 2025
.Dt STATS 7
.Os
.Sh NAME
@@ -100,6 +100,7 @@ Report ZFS I/O statistics
.Xr stat 1 ,
.Xr systat 1 ,
.Xr intro 7 ,
+.Xr tuning 7 ,
.Xr ctlstat 8 ,
.Xr gstat 8 ,
.Xr ibstat 8 ,
diff --git a/share/man/man7/tuning.7 b/share/man/man7/tuning.7
index ebba551f65d0..44c427c4559d 100644
--- a/share/man/man7/tuning.7
+++ b/share/man/man7/tuning.7
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 23, 2025
+.Dd October 28, 2025
.Dt TUNING 7
.Os
.Sh NAME
@@ -678,6 +678,7 @@ over services you export from your box (web services, email).
.Xr firewall 7 ,
.Xr hier 7 ,
.Xr ports 7 ,
+.Xr stats 7 ,
.Xr boot 8 ,
.Xr bsdinstall 8 ,
.Xr ccdconfig 8 ,
diff --git a/share/man/man9/gone_in.9 b/share/man/man9/gone_in.9
index ebdc1ab19bfa..1b60e1eb10c2 100644
--- a/share/man/man9/gone_in.9
+++ b/share/man/man9/gone_in.9
@@ -23,7 +23,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 August 16, 2021
+.Dd June 24, 2025
.Dt GONE_IN 9
.Os
.Sh NAME
@@ -33,14 +33,15 @@
.Sh SYNOPSIS
.In sys/systm.h
.Ft void
-.Fn gone_in "int major" "const char *msg"
+.Fn gone_in "int major" "const char *msg" "..."
.Ft void
-.Fn gone_in_dev "device_t dev" "int major" "const char *msg"
+.Fn gone_in_dev "device_t dev" "int major" "const char *msg" "..."
.Sh DESCRIPTION
The
-.Fn gone_in
-functions are used to provide a notice that the kernel is using a driver or
-some other functionality that is deprecated, and will be removed in a future
+.Nm gone_in
+functions are used to provide a notice that the kernel is actively using a
+driver or some other functionality that is deprecated, and is planned for
+removal in a future
.Fx
release.
The notice is sent to the kernel
@@ -51,30 +52,29 @@ The
argument specifies the major version of the
.Fx
release that will remove the deprecated functionality.
+The notice shall be printed only once, thus
+.Nm
+functions are safe to use in often executed code paths.
+.Pp
+.Nm gone_in_dev
+will prepend driver name before the notice.
.Pp
In releases before
.Fa major
-the deprecation notice states
-.Do
-Deprecated code (to be removed in FreeBSD
-.Fa major Ns ):
-.Fa msg
-.Dc .
-In releases equal to and after
-.Fa major
-the notice states
+the provided notice will be appended with
.Do
-Obsolete code will be removed soon:
-.Fa msg
+To be removed in FreeBSD
+.Fa major Ns
.Dc .
.Sh EXAMPLES
.Bd -literal -offset indent
void
-sample_init(void)
+example_api(foo_t *args)
{
- /* Initialization code omitted. */
+ gone_in(16, "Warning! %s[%u] uses obsolete API. ",
+ curthread->td_proc->p_comm, curthread->td_proc->p_pid);
- gone_in(14, "Giant-locked filesystem");
+ /* API implementation omitted. */
}
int
@@ -82,7 +82,7 @@ example_driver_attach(struct example_driver_softc *sc)
{
/* Attach code omitted. */
- gone_in_dev(sc->dev, 14, "Giant-locked driver");
+ gone_in_dev(sc->dev, 16, "driver is deprecated");
}
.Ed
.Sh HISTORY
diff --git a/share/man/man9/insmntque.9 b/share/man/man9/insmntque.9
index 869d8767632b..33ba697b10b9 100644
--- a/share/man/man9/insmntque.9
+++ b/share/man/man9/insmntque.9
@@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
.\" DAMAGE.
.\"
-.Dd January 29, 2022
+.Dd October 24, 2025
.Dt INSMNTQUE 9
.Os
.Sh NAME
@@ -56,7 +56,7 @@ The vnode must be exclusively locked.
.Pp
On failure,
.Fn insmntque
-resets vnode' operation vector to the vector of
+resets vnode's operations vector to the vector of
.Xr deadfs 9 ,
clears
.Va v_data ,
@@ -71,7 +71,7 @@ failure is needed, the
function may be used instead.
It does not do any cleanup following a failure, leaving all
the work to the caller.
-In particular, the operation vector
+In particular, the operations vector
.Va v_op
and
.Va v_data
diff --git a/share/misc/pci_vendors b/share/misc/pci_vendors
index 6fb8865340a0..1b13509f002d 100644
--- a/share/misc/pci_vendors
+++ b/share/misc/pci_vendors
@@ -1,8 +1,8 @@
#
# List of PCI ID's
#
-# Version: 2025.07.11
-# Date: 2025-07-11 03:15:02
+# Version: 2025.10.18
+# Date: 2025-10-18 03:15:01
#
# Maintained by Albert Pool, Martin Mares, and other volunteers from
# the PCI ID Project at https://pci-ids.ucw.cz/.
@@ -27979,6 +27979,10 @@
1007 CL4-8D512 NVMe SSD M.2 (DRAM-less)
1008 CL5-8D512 NVMe SSD M.2 (DRAM-less)
100c CL6 Series NVMe SSD M.2 (DRAM-less)
+ 100d PJ1 Series NVMe SSD
+ 1e95 0001 M.2 2280 960 GB
+ 1e95 0002 M.2 2280 1920 GB
+ 1e95 100d M.2 2280 480 GB
1010 CX3 Series NVMe SSD
1e95 0000 M.2 2280 480 GB
1e95 0001 M.2 2280 960 GB
diff --git a/share/misc/usb_vendors b/share/misc/usb_vendors
index 1878f503b676..fa798e65ed9a 100644
--- a/share/misc/usb_vendors
+++ b/share/misc/usb_vendors
@@ -9,8 +9,8 @@
# The latest version can be obtained from
# http://www.linux-usb.org/usb.ids
#
-# Version: 2025.07.26
-# Date: 2025-07-26 20:34:01
+# Version: 2025.09.15
+# Date: 2025-09-15 20:34:02
#
# Vendors, devices and interfaces. Please keep sorted.
@@ -13488,7 +13488,9 @@
0b0d ProjectLab
0000 CenturyCD
0b0e GN Netcom
+ 0301 Jabra EVOLVE 20
0305 Jabra EVOLVE Link MS
+ 030c Jabra EVOLVE 65
0311 Jabra EVOLVE 65
0312 enc060:Buttons Volume up/down/mute + phone [Jabra]
0343 Jabra UC VOICE 150a
@@ -13507,6 +13509,11 @@
2007 GN 2000 Stereo Corded Headset
2456 Jabra SPEAK 810
245e Jabra Link 370
+ 248a Jabra Elite 85h
+ 24b8 Jabra Evolve2 65
+ 24bb Jabra Evolve2 85
+ 24c9 Jabra Link 380
+ 24ca Jabra Link 380
620c Jabra BT620s
9330 Jabra GN9330 Headset
a346 Jabra Engage 75 Stereo
diff --git a/sys/arm/nvidia/tegra_ahci.c b/sys/arm/nvidia/tegra_ahci.c
index 30e28dd33235..efbad6ae618c 100644
--- a/sys/arm/nvidia/tegra_ahci.c
+++ b/sys/arm/nvidia/tegra_ahci.c
@@ -526,7 +526,7 @@ tegra_ahci_ctrl_init(struct tegra_ahci_sc *sc)
rv = sc->soc->init(sc);
if (rv != 0) {
device_printf(sc->dev,
- "SOC specific intialization failed: %d\n", rv);
+ "SOC specific initialization failed: %d\n", rv);
return (rv);
}
}
diff --git a/sys/arm/nvidia/tegra_lic.c b/sys/arm/nvidia/tegra_lic.c
index e1d641635351..6956dc0ca849 100644
--- a/sys/arm/nvidia/tegra_lic.c
+++ b/sys/arm/nvidia/tegra_lic.c
@@ -213,12 +213,12 @@ tegra_lic_attach(device_t dev)
}
sc->parent = OF_device_from_xref(parent_xref);
if (sc->parent == NULL) {
- device_printf(dev, "Cannott find parent controller\n");
+ device_printf(dev, "Cannot find parent controller\n");
goto fail;
}
if (bus_alloc_resources(dev, lic_spec, sc->mem_res)) {
- device_printf(dev, "Cannott allocate resources\n");
+ device_printf(dev, "Cannot allocate resources\n");
goto fail;
}
diff --git a/sys/arm/nvidia/tegra_mc.c b/sys/arm/nvidia/tegra_mc.c
index 2568ff8324af..5703d768e505 100644
--- a/sys/arm/nvidia/tegra_mc.c
+++ b/sys/arm/nvidia/tegra_mc.c
@@ -157,7 +157,7 @@ tegra_mc_intr(void *arg)
if (stat & MC_INT_DECERR_VPR)
printf(" - VPR requirements violated\n");
if (stat & MC_INT_INVALID_APB_ASID_UPDATE)
- printf(" - ivalid APB ASID update\n");
+ printf(" - invalid APB ASID update\n");
if (stat & MC_INT_INVALID_SMMU_PAGE)
printf(" - SMMU address translation error\n");
if (stat & MC_INT_ARBITRATION_EMEM)
diff --git a/sys/arm/nvidia/tegra_xhci.c b/sys/arm/nvidia/tegra_xhci.c
index 474e31981770..b9dac91cccd8 100644
--- a/sys/arm/nvidia/tegra_xhci.c
+++ b/sys/arm/nvidia/tegra_xhci.c
@@ -818,7 +818,7 @@ load_fw(struct tegra_xhci_softc *sc)
DELAY(100);
}
if (i <= 0) {
- device_printf(sc->dev, "Timedout while wating for DMA, "
+ device_printf(sc->dev, "Timedout while waiting for DMA, "
"state: 0x%08X\n",
CSB_RD4(sc, XUSB_CSB_MEMPOOL_L2IMEMOP_RESULT));
return (ETIMEDOUT);
@@ -835,7 +835,7 @@ load_fw(struct tegra_xhci_softc *sc)
DELAY(100);
}
if (i <= 0) {
- device_printf(sc->dev, "Timedout while wating for FALCON cpu, "
+ device_printf(sc->dev, "Timedout while waiting for FALCON cpu, "
"state: 0x%08X\n", CSB_RD4(sc, XUSB_FALCON_CPUCTL));
return (ETIMEDOUT);
}
diff --git a/sys/conf/files b/sys/conf/files
index 13b74e2fc44f..0a24b5e1e39b 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -4550,7 +4550,6 @@ netpfil/ipfw/dn_sched_rr.c optional inet dummynet
netpfil/ipfw/dn_sched_wf2q.c optional inet dummynet
netpfil/ipfw/ip_dummynet.c optional inet dummynet
netpfil/ipfw/ip_dn_io.c optional inet dummynet
-netpfil/ipfw/ip_dn_glue.c optional inet dummynet
netpfil/ipfw/ip_fw2.c optional inet ipfirewall
netpfil/ipfw/ip_fw_bpf.c optional inet ipfirewall
netpfil/ipfw/ip_fw_dynamic.c optional inet ipfirewall \
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index 3f0a7b40245d..e3ff4f6937d2 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -4430,8 +4430,8 @@ acpi_stype_sysctl(SYSCTL_HANDLER_ARGS)
return (EINVAL);
printf("warning: this sysctl expects a sleep type, but an ACPI S-state has "
"been passed to it. This functionality is deprecated; see acpi(4).\n");
- MPASS(sstate < ACPI_S_STATE_COUNT);
- if (acpi_supported_sstates[sstate] == false)
+ if (sstate < ACPI_S_STATE_COUNT &&
+ !acpi_supported_sstates[sstate])
return (EOPNOTSUPP);
new_stype = acpi_sstate_to_stype(sstate);
}
diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c
index ab7671025107..b23c0d76115d 100644
--- a/sys/dev/hyperv/netvsc/if_hn.c
+++ b/sys/dev/hyperv/netvsc/if_hn.c
@@ -3574,7 +3574,7 @@ hn_rxpkt(struct hn_rx_ring *rxr)
}
/*
- * If VF is activated (tranparent/non-transparent mode does not
+ * If VF is activated (transparent/non-transparent mode does not
* matter here).
*
* - Disable LRO
@@ -3591,7 +3591,7 @@ hn_rxpkt(struct hn_rx_ring *rxr)
do_lro = 0;
/*
- * If VF is activated (tranparent/non-transparent mode does not
+ * If VF is activated (transparent/non-transparent mode does not
* matter here), do _not_ mess with unsupported hash types or
* functions.
*/
@@ -7600,7 +7600,7 @@ hn_sysinit(void *arg __unused)
*/
if (hn_xpnt_vf && hn_use_if_start) {
hn_use_if_start = 0;
- printf("hn: tranparent VF mode, if_transmit will be used, "
+ printf("hn: transparent VF mode, if_transmit will be used, "
"instead of if_start\n");
}
#endif
diff --git a/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c b/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
index 29a88e76a579..63ac93a8773c 100644
--- a/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
+++ b/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
@@ -2088,7 +2088,7 @@ create_storvsc_request(union ccb *ccb, struct hv_storvsc_request *reqp)
break;
}
default:
- printf("Unknow flags: %d\n", ccb->ccb_h.flags);
+ printf("Unknown flags: %d\n", ccb->ccb_h.flags);
return(EINVAL);
}
diff --git a/sys/dev/hyperv/utilities/hv_kvp.c b/sys/dev/hyperv/utilities/hv_kvp.c
index 60bade869b49..d8ab583d69fa 100644
--- a/sys/dev/hyperv/utilities/hv_kvp.c
+++ b/sys/dev/hyperv/utilities/hv_kvp.c
@@ -621,7 +621,7 @@ hv_kvp_process_request(void *context, int pending)
} else {
if (!sc->daemon_busy) {
- hv_kvp_log_info("%s: issuing qury to daemon\n", __func__);
+ hv_kvp_log_info("%s: issuing query to daemon\n", __func__);
mtx_lock(&sc->pending_mutex);
sc->req_timed_out = false;
sc->daemon_busy = true;
diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c
index ec1664fac701..9d246d7c78fd 100644
--- a/sys/dev/md/md.c
+++ b/sys/dev/md/md.c
@@ -60,12 +60,13 @@
#include "opt_geom.h"
#include "opt_md.h"
-#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bio.h>
#include <sys/buf.h>
+#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/devicestat.h>
+#include <sys/disk.h>
#include <sys/fcntl.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
@@ -76,11 +77,11 @@
#include <sys/mdioctl.h>
#include <sys/mount.h>
#include <sys/mutex.h>
-#include <sys/sx.h>
#include <sys/namei.h>
#include <sys/proc.h>
#include <sys/queue.h>
#include <sys/rwlock.h>
+#include <sys/sx.h>
#include <sys/sbuf.h>
#include <sys/sched.h>
#include <sys/sf_buf.h>
@@ -88,9 +89,6 @@
#include <sys/uio.h>
#include <sys/unistd.h>
#include <sys/vnode.h>
-#include <sys/disk.h>
-#include <sys/param.h>
-#include <sys/bus.h>
#include <geom/geom.h>
#include <geom/geom_int.h>
diff --git a/sys/dev/ocs_fc/ocs_device.c b/sys/dev/ocs_fc/ocs_device.c
index 7f0c5526b1c3..d9c283541d3c 100644
--- a/sys/dev/ocs_fc/ocs_device.c
+++ b/sys/dev/ocs_fc/ocs_device.c
@@ -825,7 +825,7 @@ __ocs_d_init(ocs_sm_ctx_t *ctx, ocs_sm_event_t evt, void *arg)
ocs_node_transition(node, __ocs_d_wait_topology_notify, NULL);
break;
default:
- node_printf(node, "received PLOGI, with unexpectd topology %d\n",
+ node_printf(node, "received PLOGI, with unexpected topology %d\n",
node->sport->topology);
ocs_assert(FALSE, NULL);
break;
diff --git a/sys/dev/ocs_fc/ocs_els.c b/sys/dev/ocs_fc/ocs_els.c
index c62f71d4eb4f..cf4f01477f69 100644
--- a/sys/dev/ocs_fc/ocs_els.c
+++ b/sys/dev/ocs_fc/ocs_els.c
@@ -314,7 +314,7 @@ _ocs_els_io_free(void *arg)
ocs_list_remove(&node->els_io_pend_list, els);
els->els_pend = 0;
} else {
- ocs_log_err(ocs, "assertion failed: niether els->els_pend nor els->active set\n");
+ ocs_log_err(ocs, "assertion failed: neither els->els_pend nor els->active set\n");
ocs_unlock(&node->active_ios_lock);
return;
}
@@ -363,7 +363,7 @@ ocs_els_make_active(ocs_io_t *els)
} else {
/* must be retrying; make sure it's already active */
if (!els->els_active) {
- ocs_log_err(node->ocs, "assertion failed: niether els->els_pend nor els->active set\n");
+ ocs_log_err(node->ocs, "assertion failed: neither els->els_pend nor els->active set\n");
}
}
ocs_unlock(&node->active_ios_lock);
diff --git a/sys/dev/ocs_fc/ocs_gendump.c b/sys/dev/ocs_fc/ocs_gendump.c
index 83155d90c3a3..6a1abfefadfc 100644
--- a/sys/dev/ocs_fc/ocs_gendump.c
+++ b/sys/dev/ocs_fc/ocs_gendump.c
@@ -153,7 +153,7 @@ ocs_gen_dump(ocs_t *ocs)
ocs_log_test(ocs, "Failed to see dump after 30 secs\n");
rc = -1;
} else {
- ocs_log_debug(ocs, "sucessfully generated dump\n");
+ ocs_log_debug(ocs, "successfully generated dump\n");
}
/* now reset port */
@@ -219,7 +219,7 @@ ocs_fdb_dump(ocs_t *ocs)
return -1;
}
- ocs_log_debug(ocs, "sucessfully generated dump\n");
+ ocs_log_debug(ocs, "successfully generated dump\n");
} else {
ocs_log_err(ocs, "dump request to hw failed\n");
diff --git a/sys/dev/ocs_fc/ocs_ioctl.c b/sys/dev/ocs_fc/ocs_ioctl.c
index 71ba17d5f72a..d3cea434b2be 100644
--- a/sys/dev/ocs_fc/ocs_ioctl.c
+++ b/sys/dev/ocs_fc/ocs_ioctl.c
@@ -796,7 +796,7 @@ ocs_sys_fwupgrade(SYSCTL_HANDLER_ARGS)
break;
default:
ocs_log_warn(ocs,
- "Unexected value change_status: %d\n",
+ "Unexpected value change_status: %d\n",
fw_change_status);
break;
}
diff --git a/sys/dev/ocs_fc/ocs_scsi.c b/sys/dev/ocs_fc/ocs_scsi.c
index af9fc798b01c..1bbf60b9014b 100644
--- a/sys/dev/ocs_fc/ocs_scsi.c
+++ b/sys/dev/ocs_fc/ocs_scsi.c
@@ -720,7 +720,7 @@ ocs_scsi_build_sgls(ocs_hw_t *hw, ocs_hw_io_t *hio, ocs_hw_dif_info_t *hw_dif, o
case OCS_HW_DIF_BK_SIZE_520: blocksize = 520; break;
case OCS_HW_DIF_BK_SIZE_4104: blocksize = 4104; break;
default:
- ocs_log_test(hw->os, "Inavlid hw_dif blocksize %d\n", hw_dif->blk_size);
+ ocs_log_test(hw->os, "Invalid hw_dif blocksize %d\n", hw_dif->blk_size);
return -1;
}
for (i = 0; i < sgl_count; i++) {
diff --git a/sys/dev/ocs_fc/ocs_xport.c b/sys/dev/ocs_fc/ocs_xport.c
index d997ea245132..9e69bf0ed98f 100644
--- a/sys/dev/ocs_fc/ocs_xport.c
+++ b/sys/dev/ocs_fc/ocs_xport.c
@@ -482,12 +482,12 @@ ocs_xport_initialize(ocs_xport_t *xport)
/* Setup persistent topology based on topology mod-param value */
rc = ocs_topology_setup(ocs);
if (rc) {
- ocs_log_err(ocs, "%s: Can't set the toplogy\n", ocs->desc);
+ ocs_log_err(ocs, "%s: Can't set the topology\n", ocs->desc);
return -1;
}
if (ocs_hw_set(&ocs->hw, OCS_HW_TOPOLOGY, ocs->topology) != OCS_HW_RTN_SUCCESS) {
- ocs_log_err(ocs, "%s: Can't set the toplogy\n", ocs->desc);
+ ocs_log_err(ocs, "%s: Can't set the topology\n", ocs->desc);
return -1;
}
ocs_hw_set(&ocs->hw, OCS_HW_RQ_DEFAULT_BUFFER_SIZE, OCS_FC_RQ_SIZE_DEFAULT);
diff --git a/sys/dev/virtio/gpu/virtio_gpu.c b/sys/dev/virtio/gpu/virtio_gpu.c
index 6f786a450900..668eb170304a 100644
--- a/sys/dev/virtio/gpu/virtio_gpu.c
+++ b/sys/dev/virtio/gpu/virtio_gpu.c
@@ -547,7 +547,7 @@ vtgpu_create_2d(struct vtgpu_softc *sc)
return (error);
if (s.resp.type != htole32(VIRTIO_GPU_RESP_OK_NODATA)) {
- device_printf(sc->vtgpu_dev, "Invalid reponse type %x\n",
+ device_printf(sc->vtgpu_dev, "Invalid response type %x\n",
le32toh(s.resp.type));
return (EINVAL);
}
@@ -586,7 +586,7 @@ vtgpu_attach_backing(struct vtgpu_softc *sc)
return (error);
if (s.resp.type != htole32(VIRTIO_GPU_RESP_OK_NODATA)) {
- device_printf(sc->vtgpu_dev, "Invalid reponse type %x\n",
+ device_printf(sc->vtgpu_dev, "Invalid response type %x\n",
le32toh(s.resp.type));
return (EINVAL);
}
@@ -624,7 +624,7 @@ vtgpu_set_scanout(struct vtgpu_softc *sc, uint32_t x, uint32_t y,
return (error);
if (s.resp.type != htole32(VIRTIO_GPU_RESP_OK_NODATA)) {
- device_printf(sc->vtgpu_dev, "Invalid reponse type %x\n",
+ device_printf(sc->vtgpu_dev, "Invalid response type %x\n",
le32toh(s.resp.type));
return (EINVAL);
}
@@ -663,7 +663,7 @@ vtgpu_transfer_to_host_2d(struct vtgpu_softc *sc, uint32_t x, uint32_t y,
return (error);
if (s.resp.type != htole32(VIRTIO_GPU_RESP_OK_NODATA)) {
- device_printf(sc->vtgpu_dev, "Invalid reponse type %x\n",
+ device_printf(sc->vtgpu_dev, "Invalid response type %x\n",
le32toh(s.resp.type));
return (EINVAL);
}
@@ -700,7 +700,7 @@ vtgpu_resource_flush(struct vtgpu_softc *sc, uint32_t x, uint32_t y,
return (error);
if (s.resp.type != htole32(VIRTIO_GPU_RESP_OK_NODATA)) {
- device_printf(sc->vtgpu_dev, "Invalid reponse type %x\n",
+ device_printf(sc->vtgpu_dev, "Invalid response type %x\n",
le32toh(s.resp.type));
return (EINVAL);
}
diff --git a/sys/dev/virtio/scmi/virtio_scmi.c b/sys/dev/virtio/scmi/virtio_scmi.c
index f5427756e971..436711dc0ae2 100644
--- a/sys/dev/virtio/scmi/virtio_scmi.c
+++ b/sys/dev/virtio/scmi/virtio_scmi.c
@@ -386,7 +386,7 @@ virtio_scmi_pdu_get(struct vtscmi_queue *q, void *buf, unsigned int tx_len,
mtx_unlock_spin(&q->p_mtx);
if (pdu == NULL) {
- device_printf(q->dev, "Cannnot allocate PDU.\n");
+ device_printf(q->dev, "Cannot allocate PDU.\n");
return (NULL);
}
diff --git a/sys/dev/xilinx/xlnx_pcib.c b/sys/dev/xilinx/xlnx_pcib.c
index d549ec445ea9..816b33ec1142 100644
--- a/sys/dev/xilinx/xlnx_pcib.c
+++ b/sys/dev/xilinx/xlnx_pcib.c
@@ -1,7 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2020 Ruslan Bukin <br@bsdpad.com>
+ * Copyright (c) 2020-2025 Ruslan Bukin <br@bsdpad.com>
*
* This software was developed by SRI International and the University of
* Cambridge Computer Laboratory (Department of Computer Science and
@@ -84,7 +84,7 @@ struct xlnx_pcib_softc {
struct generic_pcie_fdt_softc fdt_sc;
struct resource *res[4];
struct mtx mtx;
- vm_offset_t msi_page;
+ void *msi_page;
struct xlnx_pcib_irqsrc *isrcs;
device_t dev;
void *intr_cookie[3];
@@ -105,6 +105,12 @@ struct xlnx_pcib_irqsrc {
u_int flags;
};
+static struct ofw_compat_data compat_data[] = {
+ { "xlnx,xdma-host-3.00", 1 },
+ { "xlnx,axi-pcie-host-1.00.a", 1 },
+ { NULL, 0 },
+};
+
static void
xlnx_pcib_clear_err_interrupts(struct generic_pcie_core_softc *sc)
{
@@ -333,12 +339,12 @@ xlnx_pcib_fdt_probe(device_t dev)
if (!ofw_bus_status_okay(dev))
return (ENXIO);
- if (ofw_bus_is_compatible(dev, "xlnx,xdma-host-3.00")) {
- device_set_desc(dev, "Xilinx XDMA PCIe Controller");
- return (BUS_PROBE_DEFAULT);
- }
+ if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
+ return (ENXIO);
+
+ device_set_desc(dev, "Xilinx XDMA PCIe Controller");
- return (ENXIO);
+ return (BUS_PROBE_DEFAULT);
}
static int
@@ -424,8 +430,8 @@ xlnx_pcib_req_valid(struct generic_pcie_core_softc *sc,
bus_space_tag_t t;
uint32_t val;
- t = sc->bst;
- h = sc->bsh;
+ t = rman_get_bustag(sc->res);
+ h = rman_get_bushandle(sc->res);
if ((bus < sc->bus_start) || (bus > sc->bus_end))
return (0);
@@ -467,8 +473,8 @@ xlnx_pcib_read_config(device_t dev, u_int bus, u_int slot,
return (~0U);
offset = PCIE_ADDR_OFFSET(bus - sc->bus_start, slot, func, reg);
- t = sc->bst;
- h = sc->bsh;
+ t = rman_get_bustag(sc->res);
+ h = rman_get_bushandle(sc->res);
data = bus_space_read_4(t, h, offset & ~3);
@@ -512,8 +518,8 @@ xlnx_pcib_write_config(device_t dev, u_int bus, u_int slot,
offset = PCIE_ADDR_OFFSET(bus - sc->bus_start, slot, func, reg);
- t = sc->bst;
- h = sc->bsh;
+ t = rman_get_bustag(sc->res);
+ h = rman_get_bushandle(sc->res);
/*
* 32-bit access used due to a bug in the Xilinx bridge that
diff --git a/sys/fs/fuse/fuse_ipc.c b/sys/fs/fuse/fuse_ipc.c
index 7f754ab7f1d4..bc36f0070d7d 100644
--- a/sys/fs/fuse/fuse_ipc.c
+++ b/sys/fs/fuse/fuse_ipc.c
@@ -694,7 +694,7 @@ fuse_body_audit(struct fuse_ticket *ftick, size_t blen)
break;
case FUSE_FORGET:
- panic("FUSE: a handler has been intalled for FUSE_FORGET");
+ panic("FUSE: a handler has been installed for FUSE_FORGET");
break;
case FUSE_GETATTR:
diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c
index 683ee2f7ad56..97aa23bfb0b0 100644
--- a/sys/fs/fuse/fuse_vnops.c
+++ b/sys/fs/fuse/fuse_vnops.c
@@ -2756,7 +2756,7 @@ fuse_vnop_setextattr(struct vop_setextattr_args *ap)
*/
if (fsess_not_impl(mp, FUSE_REMOVEXATTR))
return (EXTERROR(EOPNOTSUPP, "This server does not "
- "implement removing extended attributess"));
+ "implement removing extended attributes"));
else
return (EXTERROR(EINVAL, "DELETEEXTATTR should be used "
"to remove extattrs"));
diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c
index 8d506a5643a9..8e1a26eef354 100644
--- a/sys/fs/nfs/nfs_commonsubs.c
+++ b/sys/fs/nfs/nfs_commonsubs.c
@@ -4192,10 +4192,15 @@ nfssvc_idname(struct nfsd_idargs *nidp)
nidp->nid_namelen);
if (error == 0 && nidp->nid_ngroup > 0 &&
(nidp->nid_flag & NFSID_ADDUID) != 0) {
- grps = malloc(sizeof(gid_t) * nidp->nid_ngroup, M_TEMP,
- M_WAITOK);
- error = copyin(nidp->nid_grps, grps,
- sizeof(gid_t) * nidp->nid_ngroup);
+ grps = NULL;
+ if (nidp->nid_ngroup > NGROUPS_MAX)
+ error = EINVAL;
+ if (error == 0) {
+ grps = malloc(sizeof(gid_t) * nidp->nid_ngroup, M_TEMP,
+ M_WAITOK);
+ error = copyin(nidp->nid_grps, grps,
+ sizeof(gid_t) * nidp->nid_ngroup);
+ }
if (error == 0) {
/*
* Create a credential just like svc_getcred(),
diff --git a/sys/isa/isa_common.c b/sys/isa/isa_common.c
index 91a0ee1f2f3d..41a63a3c676c 100644
--- a/sys/isa/isa_common.c
+++ b/sys/isa/isa_common.c
@@ -569,8 +569,8 @@ isa_probe_children(device_t dev)
if (err == 0 && idev->id_vendorid == 0 &&
strcmp(kern_ident, "GENERIC") == 0 &&
device_is_attached(child))
- gone_in_dev(child, 16,
- "WARNING: non-PNP ISA device will be removed from GENERIC\n");
+ device_printf(child,
+ "non-PNP ISA device will be removed from GENERIC in FreeBSD 16.\n");
}
/*
diff --git a/sys/modules/dummynet/Makefile b/sys/modules/dummynet/Makefile
index 4ff023e6bca5..a645c1673167 100644
--- a/sys/modules/dummynet/Makefile
+++ b/sys/modules/dummynet/Makefile
@@ -1,7 +1,6 @@
.PATH: ${SRCTOP}/sys/netpfil/ipfw
KMOD= dummynet
-SRCS= ip_dummynet.c
-SRCS+= ip_dn_glue.c ip_dn_io.c
+SRCS= ip_dummynet.c ip_dn_io.c
SRCS+= dn_aqm_codel.c dn_aqm_pie.c
SRCS+= dn_heap.c dn_sched_fifo.c dn_sched_qfq.c dn_sched_rr.c dn_sched_wf2q.c
SRCS+= dn_sched_prio.c dn_sched_fq_codel.c dn_sched_fq_pie.c
diff --git a/sys/net/altq/altq_cbq.c b/sys/net/altq/altq_cbq.c
index fdf39690160b..2333b9ea8678 100644
--- a/sys/net/altq/altq_cbq.c
+++ b/sys/net/altq/altq_cbq.c
@@ -173,6 +173,8 @@ cbq_request(struct ifaltq *ifq, int req, void *arg)
static void
get_class_stats(class_stats_t *statsp, struct rm_class *cl)
{
+ memset(statsp, 0, sizeof(*statsp));
+
statsp->xmit_cnt = cl->stats_.xmit_cnt;
statsp->drop_cnt = cl->stats_.drop_cnt;
statsp->over = cl->stats_.over;
diff --git a/sys/net/altq/altq_fairq.c b/sys/net/altq/altq_fairq.c
index 6069865101a0..0a00168e547e 100644
--- a/sys/net/altq/altq_fairq.c
+++ b/sys/net/altq/altq_fairq.c
@@ -857,6 +857,8 @@ get_class_stats(struct fairq_classstats *sp, struct fairq_class *cl)
{
fairq_bucket_t *b;
+ memset(sp, 0, sizeof(*sp));
+
sp->class_handle = cl->cl_handle;
sp->qlimit = cl->cl_qlimit;
sp->xmit_cnt = cl->cl_xmitcnt;
diff --git a/sys/net/altq/altq_priq.c b/sys/net/altq/altq_priq.c
index 026346639b2e..fec488418546 100644
--- a/sys/net/altq/altq_priq.c
+++ b/sys/net/altq/altq_priq.c
@@ -597,6 +597,8 @@ priq_purgeq(struct priq_class *cl)
static void
get_class_stats(struct priq_classstats *sp, struct priq_class *cl)
{
+ memset(sp, 0, sizeof(*sp));
+
sp->class_handle = cl->cl_handle;
sp->qlength = qlen(cl->cl_q);
sp->qlimit = qlimit(cl->cl_q);
diff --git a/sys/net/if.c b/sys/net/if.c
index b6a798aa0fab..cb9c47c14c32 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -2842,15 +2842,20 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
break;
case SIOCAIFGROUP:
+ {
+ const char *groupname;
+
error = priv_check(td, PRIV_NET_ADDIFGROUP);
if (error)
return (error);
- error = if_addgroup(ifp,
- ((struct ifgroupreq *)data)->ifgr_group);
+ groupname = ((struct ifgroupreq *)data)->ifgr_group;
+ if (strnlen(groupname, IFNAMSIZ) == IFNAMSIZ)
+ return (EINVAL);
+ error = if_addgroup(ifp, groupname);
if (error != 0)
return (error);
break;
-
+ }
case SIOCGIFGROUP:
{
struct epoch_tracker et;
@@ -2862,15 +2867,20 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
}
case SIOCDIFGROUP:
+ {
+ const char *groupname;
+
error = priv_check(td, PRIV_NET_DELIFGROUP);
if (error)
return (error);
- error = if_delgroup(ifp,
- ((struct ifgroupreq *)data)->ifgr_group);
+ groupname = ((struct ifgroupreq *)data)->ifgr_group;
+ if (strnlen(groupname, IFNAMSIZ) == IFNAMSIZ)
+ return (EINVAL);
+ error = if_delgroup(ifp, groupname);
if (error != 0)
return (error);
break;
-
+ }
default:
error = ENOIOCTL;
break;
@@ -3014,9 +3024,17 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct thread *td)
goto out_noref;
case SIOCGIFGMEMB:
- error = if_getgroupmembers((struct ifgroupreq *)data);
- goto out_noref;
+ {
+ struct ifgroupreq *req;
+ req = (struct ifgroupreq *)data;
+ if (strnlen(req->ifgr_name, IFNAMSIZ) == IFNAMSIZ) {
+ error = EINVAL;
+ goto out_noref;
+ }
+ error = if_getgroupmembers(req);
+ goto out_noref;
+ }
#if defined(INET) || defined(INET6)
case SIOCSVH:
case SIOCGVH:
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index f2df612b19c1..961259bb0ca1 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -383,18 +383,18 @@ struct ifg_group {
char ifg_group[IFNAMSIZ];
u_int ifg_refcnt;
void *ifg_pf_kif;
- CK_STAILQ_HEAD(, ifg_member) ifg_members; /* (CK_) */
- CK_STAILQ_ENTRY(ifg_group) ifg_next; /* (CK_) */
+ CK_STAILQ_HEAD(, ifg_member) ifg_members;
+ CK_STAILQ_ENTRY(ifg_group) ifg_next;
};
struct ifg_member {
- CK_STAILQ_ENTRY(ifg_member) ifgm_next; /* (CK_) */
+ CK_STAILQ_ENTRY(ifg_member) ifgm_next;
if_t ifgm_ifp;
};
struct ifg_list {
struct ifg_group *ifgl_group;
- CK_STAILQ_ENTRY(ifg_list) ifgl_next; /* (CK_) */
+ CK_STAILQ_ENTRY(ifg_list) ifgl_next;
};
#ifdef _SYS_EVENTHANDLER_H_
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index 66070faf97e9..bfe608be6b36 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -680,7 +680,6 @@ rip_ctloutput(struct socket *so, struct sockopt *sopt)
break;
case IP_DUMMYNET3: /* generic dummynet v.3 functions */
- case IP_DUMMYNET_GET:
if (ip_dn_ctl_ptr != NULL)
error = ip_dn_ctl_ptr(sopt);
else
@@ -747,9 +746,6 @@ rip_ctloutput(struct socket *so, struct sockopt *sopt)
break;
case IP_DUMMYNET3: /* generic dummynet v.3 functions */
- case IP_DUMMYNET_CONFIGURE:
- case IP_DUMMYNET_DEL:
- case IP_DUMMYNET_FLUSH:
if (ip_dn_ctl_ptr != NULL)
error = ip_dn_ctl_ptr(sopt);
else
diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c
index 3cb538f7054d..3a7755e9f09e 100644
--- a/sys/netinet/tcp_syncache.c
+++ b/sys/netinet/tcp_syncache.c
@@ -1380,6 +1380,7 @@ syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
struct tcpcb *tp;
struct socket *rv = NULL;
struct syncache *sc = NULL;
+ struct ucred *cred;
struct syncache_head *sch;
struct mbuf *ipopts = NULL;
u_int ltflags;
@@ -1408,6 +1409,7 @@ syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
*/
KASSERT(SOLISTENING(so), ("%s: %p not listening", __func__, so));
tp = sototcpcb(so);
+ cred = V_tcp_syncache.see_other ? NULL : crhold(so->so_cred);
#ifdef INET6
if (inc->inc_flags & INC_ISIPV6) {
@@ -1636,16 +1638,16 @@ syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
/*
* sc_cred is only used in syncache_pcblist() to list TCP endpoints in
* TCPS_SYN_RECEIVED state when V_tcp_syncache.see_other is false.
- * Therefore, store the credentials and take a reference count only
- * when needed:
+ * Therefore, store the credentials only when needed:
* - sc is allocated from the zone and not using the on stack instance.
* - the sysctl variable net.inet.tcp.syncache.see_other is false.
* The reference count is decremented when a zone allocated sc is
* freed in syncache_free().
*/
- if (sc != &scs && !V_tcp_syncache.see_other)
- sc->sc_cred = crhold(so->so_cred);
- else
+ if (sc != &scs && !V_tcp_syncache.see_other) {
+ sc->sc_cred = cred;
+ cred = NULL;
+ } else
sc->sc_cred = NULL;
sc->sc_port = port;
sc->sc_ipopts = ipopts;
@@ -1783,6 +1785,8 @@ donenoprobe:
tcp_fastopen_decrement_counter(tfo_pending);
tfo_expanded:
+ if (cred != NULL)
+ crfree(cred);
if (sc == NULL || sc == &scs) {
#ifdef MAC
mac_syncache_destroy(&maclabel);
diff --git a/sys/netpfil/ipfw/ip_dn_glue.c b/sys/netpfil/ipfw/ip_dn_glue.c
deleted file mode 100644
index 0412b730e4df..000000000000
--- a/sys/netpfil/ipfw/ip_dn_glue.c
+++ /dev/null
@@ -1,858 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2010 Riccardo Panicucci, Universita` di Pisa
- * All rights reserved
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- *
- * Binary compatibility support for /sbin/ipfw RELENG_7 and RELENG_8
- */
-
-#include "opt_inet6.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/kernel.h>
-#include <sys/lock.h>
-#include <sys/module.h>
-#include <sys/priv.h>
-#include <sys/proc.h>
-#include <sys/rwlock.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/time.h>
-#include <sys/taskqueue.h>
-#include <net/if.h> /* IFNAMSIZ, struct ifaddr, ifq head, lock.h mutex.h */
-#include <netinet/in.h>
-#include <netinet/ip_var.h> /* ip_output(), IP_FORWARDING */
-#include <netinet/ip_fw.h>
-#include <netinet/ip_dummynet.h>
-
-#include <netpfil/ipfw/ip_fw_private.h>
-#include <netpfil/ipfw/dn_heap.h>
-#include <netpfil/ipfw/ip_dn_private.h>
-#ifdef NEW_AQM
-#include <netpfil/ipfw/dn_aqm.h>
-#endif
-#include <netpfil/ipfw/dn_sched.h>
-
-/* FREEBSD7.2 ip_dummynet.h r191715*/
-
-struct dn_heap_entry7 {
- int64_t key; /* sorting key. Topmost element is smallest one */
- void *object; /* object pointer */
-};
-
-struct dn_heap7 {
- int size;
- int elements;
- int offset; /* XXX if > 0 this is the offset of direct ptr to obj */
- struct dn_heap_entry7 *p; /* really an array of "size" entries */
-};
-
-/* Common to 7.2 and 8 */
-struct dn_flow_set {
- SLIST_ENTRY(dn_flow_set) next; /* linked list in a hash slot */
-
- u_short fs_nr ; /* flow_set number */
- u_short flags_fs;
-#define DNOLD_HAVE_FLOW_MASK 0x0001
-#define DNOLD_IS_RED 0x0002
-#define DNOLD_IS_GENTLE_RED 0x0004
-#define DNOLD_QSIZE_IS_BYTES 0x0008 /* queue size is measured in bytes */
-#define DNOLD_NOERROR 0x0010 /* do not report ENOBUFS on drops */
-#define DNOLD_HAS_PROFILE 0x0020 /* the pipe has a delay profile. */
-#define DNOLD_IS_PIPE 0x4000
-#define DNOLD_IS_QUEUE 0x8000
-
- struct dn_pipe7 *pipe ; /* pointer to parent pipe */
- u_short parent_nr ; /* parent pipe#, 0 if local to a pipe */
-
- int weight ; /* WFQ queue weight */
- int qsize ; /* queue size in slots or bytes */
- int plr[4] ; /* pkt loss rate (2^31-1 means 100%) */
-
- struct ipfw_flow_id flow_mask ;
-
- /* hash table of queues onto this flow_set */
- int rq_size ; /* number of slots */
- int rq_elements ; /* active elements */
- struct dn_flow_queue7 **rq ; /* array of rq_size entries */
-
- u_int32_t last_expired ; /* do not expire too frequently */
- int backlogged ; /* #active queues for this flowset */
-
- /* RED parameters */
-#define SCALE_RED 16
-#define SCALE(x) ( (x) << SCALE_RED )
-#define SCALE_VAL(x) ( (x) >> SCALE_RED )
-#define SCALE_MUL(x,y) ( ( (x) * (y) ) >> SCALE_RED )
- int w_q ; /* queue weight (scaled) */
- int max_th ; /* maximum threshold for queue (scaled) */
- int min_th ; /* minimum threshold for queue (scaled) */
- int max_p ; /* maximum value for p_b (scaled) */
- u_int c_1 ; /* max_p/(max_th-min_th) (scaled) */
- u_int c_2 ; /* max_p*min_th/(max_th-min_th) (scaled) */
- u_int c_3 ; /* for GRED, (1-max_p)/max_th (scaled) */
- u_int c_4 ; /* for GRED, 1 - 2*max_p (scaled) */
- u_int * w_q_lookup ; /* lookup table for computing (1-w_q)^t */
- u_int lookup_depth ; /* depth of lookup table */
- int lookup_step ; /* granularity inside the lookup table */
- int lookup_weight ; /* equal to (1-w_q)^t / (1-w_q)^(t+1) */
- int avg_pkt_size ; /* medium packet size */
- int max_pkt_size ; /* max packet size */
-};
-SLIST_HEAD(dn_flow_set_head, dn_flow_set);
-
-#define DN_IS_PIPE 0x4000
-#define DN_IS_QUEUE 0x8000
-struct dn_flow_queue7 {
- struct dn_flow_queue7 *next ;
- struct ipfw_flow_id id ;
-
- struct mbuf *head, *tail ; /* queue of packets */
- u_int len ;
- u_int len_bytes ;
-
- u_long numbytes;
-
- u_int64_t tot_pkts ; /* statistics counters */
- u_int64_t tot_bytes ;
- u_int32_t drops ;
-
- int hash_slot ; /* debugging/diagnostic */
-
- /* RED parameters */
- int avg ; /* average queue length est. (scaled) */
- int count ; /* arrivals since last RED drop */
- int random ; /* random value (scaled) */
- u_int32_t q_time; /* start of queue idle time */
-
- /* WF2Q+ support */
- struct dn_flow_set *fs ; /* parent flow set */
- int heap_pos ; /* position (index) of struct in heap */
- int64_t sched_time ; /* current time when queue enters ready_heap */
-
- int64_t S,F ; /* start time, finish time */
-};
-
-struct dn_pipe7 { /* a pipe */
- SLIST_ENTRY(dn_pipe7) next; /* linked list in a hash slot */
-
- int pipe_nr ; /* number */
- uint32_t bandwidth; /* really, bytes/tick. */
- int delay ; /* really, ticks */
-
- struct mbuf *head, *tail ; /* packets in delay line */
-
- /* WF2Q+ */
- struct dn_heap7 scheduler_heap ; /* top extract - key Finish time*/
- struct dn_heap7 not_eligible_heap; /* top extract- key Start time */
- struct dn_heap7 idle_heap ; /* random extract - key Start=Finish time */
-
- int64_t V ; /* virtual time */
- int sum; /* sum of weights of all active sessions */
-
- int numbytes;
-
- int64_t sched_time ; /* time pipe was scheduled in ready_heap */
-
- /*
- * When the tx clock come from an interface (if_name[0] != '\0'), its name
- * is stored below, whereas the ifp is filled when the rule is configured.
- */
- char if_name[IFNAMSIZ];
- struct ifnet *ifp ;
- int ready ; /* set if ifp != NULL and we got a signal from it */
-
- struct dn_flow_set fs ; /* used with fixed-rate flows */
-};
-SLIST_HEAD(dn_pipe_head7, dn_pipe7);
-
-/* FREEBSD8 ip_dummynet.h r196045 */
-struct dn_flow_queue8 {
- struct dn_flow_queue8 *next ;
- struct ipfw_flow_id id ;
-
- struct mbuf *head, *tail ; /* queue of packets */
- u_int len ;
- u_int len_bytes ;
-
- uint64_t numbytes ; /* credit for transmission (dynamic queues) */
- int64_t extra_bits; /* extra bits simulating unavailable channel */
-
- u_int64_t tot_pkts ; /* statistics counters */
- u_int64_t tot_bytes ;
- u_int32_t drops ;
-
- int hash_slot ; /* debugging/diagnostic */
-
- /* RED parameters */
- int avg ; /* average queue length est. (scaled) */
- int count ; /* arrivals since last RED drop */
- int random ; /* random value (scaled) */
- int64_t idle_time; /* start of queue idle time */
-
- /* WF2Q+ support */
- struct dn_flow_set *fs ; /* parent flow set */
- int heap_pos ; /* position (index) of struct in heap */
- int64_t sched_time ; /* current time when queue enters ready_heap */
-
- int64_t S,F ; /* start time, finish time */
-};
-
-struct dn_pipe8 { /* a pipe */
- SLIST_ENTRY(dn_pipe8) next; /* linked list in a hash slot */
-
- int pipe_nr ; /* number */
- uint32_t bandwidth; /* really, bytes/tick. */
- int delay ; /* really, ticks */
-
- struct mbuf *head, *tail ; /* packets in delay line */
-
- /* WF2Q+ */
- struct dn_heap7 scheduler_heap ; /* top extract - key Finish time*/
- struct dn_heap7 not_eligible_heap; /* top extract- key Start time */
- struct dn_heap7 idle_heap ; /* random extract - key Start=Finish time */
-
- int64_t V ; /* virtual time */
- int sum; /* sum of weights of all active sessions */
-
- /* Same as in dn_flow_queue, numbytes can become large */
- int64_t numbytes; /* bits I can transmit (more or less). */
- uint64_t burst; /* burst size, scaled: bits * hz */
-
- int64_t sched_time ; /* time pipe was scheduled in ready_heap */
- int64_t idle_time; /* start of pipe idle time */
-
- char if_name[IFNAMSIZ];
- struct ifnet *ifp ;
- int ready ; /* set if ifp != NULL and we got a signal from it */
-
- struct dn_flow_set fs ; /* used with fixed-rate flows */
-
- /* fields to simulate a delay profile */
-#define ED_MAX_NAME_LEN 32
- char name[ED_MAX_NAME_LEN];
- int loss_level;
- int samples_no;
- int *samples;
-};
-
-#define ED_MAX_SAMPLES_NO 1024
-struct dn_pipe_max8 {
- struct dn_pipe8 pipe;
- int samples[ED_MAX_SAMPLES_NO];
-};
-SLIST_HEAD(dn_pipe_head8, dn_pipe8);
-
-/*
- * Changes from 7.2 to 8:
- * dn_pipe:
- * numbytes from int to int64_t
- * add burst (int64_t)
- * add idle_time (int64_t)
- * add profile
- * add struct dn_pipe_max
- * add flag DN_HAS_PROFILE
- *
- * dn_flow_queue
- * numbytes from u_long to int64_t
- * add extra_bits (int64_t)
- * q_time from u_int32_t to int64_t and name idle_time
- *
- * dn_flow_set unchanged
- *
- */
-
-/* NOTE:XXX copied from dummynet.c */
-#define O_NEXT(p, len) ((void *)((char *)p + len))
-static void
-oid_fill(struct dn_id *oid, int len, int type, uintptr_t id)
-{
- oid->len = len;
- oid->type = type;
- oid->subtype = 0;
- oid->id = id;
-}
-/* make room in the buffer and move the pointer forward */
-static void *
-o_next(struct dn_id **o, int len, int type)
-{
- struct dn_id *ret = *o;
- oid_fill(ret, len, type, 0);
- *o = O_NEXT(*o, len);
- return ret;
-}
-
-static size_t pipesize7 = sizeof(struct dn_pipe7);
-static size_t pipesize8 = sizeof(struct dn_pipe8);
-static size_t pipesizemax8 = sizeof(struct dn_pipe_max8);
-
-/* Indicate 'ipfw' version
- * 1: from FreeBSD 7.2
- * 0: from FreeBSD 8
- * -1: unknown (for now is unused)
- *
- * It is update when a IP_DUMMYNET_DEL or IP_DUMMYNET_CONFIGURE request arrives
- * NOTE: if a IP_DUMMYNET_GET arrives and the 'ipfw' version is unknown,
- * it is suppose to be the FreeBSD 8 version.
- */
-static int is7 = 0;
-
-static int
-convertflags2new(int src)
-{
- int dst = 0;
-
- if (src & DNOLD_HAVE_FLOW_MASK)
- dst |= DN_HAVE_MASK;
- if (src & DNOLD_QSIZE_IS_BYTES)
- dst |= DN_QSIZE_BYTES;
- if (src & DNOLD_NOERROR)
- dst |= DN_NOERROR;
- if (src & DNOLD_IS_RED)
- dst |= DN_IS_RED;
- if (src & DNOLD_IS_GENTLE_RED)
- dst |= DN_IS_GENTLE_RED;
- if (src & DNOLD_HAS_PROFILE)
- dst |= DN_HAS_PROFILE;
-
- return dst;
-}
-
-static int
-convertflags2old(int src)
-{
- int dst = 0;
-
- if (src & DN_HAVE_MASK)
- dst |= DNOLD_HAVE_FLOW_MASK;
- if (src & DN_IS_RED)
- dst |= DNOLD_IS_RED;
- if (src & DN_IS_GENTLE_RED)
- dst |= DNOLD_IS_GENTLE_RED;
- if (src & DN_NOERROR)
- dst |= DNOLD_NOERROR;
- if (src & DN_HAS_PROFILE)
- dst |= DNOLD_HAS_PROFILE;
- if (src & DN_QSIZE_BYTES)
- dst |= DNOLD_QSIZE_IS_BYTES;
-
- return dst;
-}
-
-static int
-dn_compat_del(void *v)
-{
- struct dn_pipe7 *p = (struct dn_pipe7 *) v;
- struct dn_pipe8 *p8 = (struct dn_pipe8 *) v;
- struct {
- struct dn_id oid;
- uintptr_t a[1]; /* add more if we want a list */
- } cmd;
-
- /* XXX DN_API_VERSION ??? */
- oid_fill((void *)&cmd, sizeof(cmd), DN_CMD_DELETE, DN_API_VERSION);
-
- if (is7) {
- if (p->pipe_nr == 0 && p->fs.fs_nr == 0)
- return EINVAL;
- if (p->pipe_nr != 0 && p->fs.fs_nr != 0)
- return EINVAL;
- } else {
- if (p8->pipe_nr == 0 && p8->fs.fs_nr == 0)
- return EINVAL;
- if (p8->pipe_nr != 0 && p8->fs.fs_nr != 0)
- return EINVAL;
- }
-
- if (p->pipe_nr != 0) { /* pipe x delete */
- cmd.a[0] = p->pipe_nr;
- cmd.oid.subtype = DN_LINK;
- } else { /* queue x delete */
- cmd.oid.subtype = DN_FS;
- cmd.a[0] = (is7) ? p->fs.fs_nr : p8->fs.fs_nr;
- }
-
- return do_config(&cmd, cmd.oid.len);
-}
-
-static int
-dn_compat_config_queue(struct dn_fs *fs, void* v)
-{
- struct dn_pipe7 *p7 = (struct dn_pipe7 *)v;
- struct dn_pipe8 *p8 = (struct dn_pipe8 *)v;
- struct dn_flow_set *f;
-
- if (is7)
- f = &p7->fs;
- else
- f = &p8->fs;
-
- fs->fs_nr = f->fs_nr;
- fs->sched_nr = f->parent_nr;
- fs->flow_mask = f->flow_mask;
- fs->buckets = f->rq_size;
- fs->qsize = f->qsize;
- fs->plr[0] = f->plr[0];
- fs->plr[1] = f->plr[1];
- fs->plr[2] = f->plr[2];
- fs->plr[3] = f->plr[3];
- fs->par[0] = f->weight;
- fs->flags = convertflags2new(f->flags_fs);
- if (fs->flags & DN_IS_GENTLE_RED || fs->flags & DN_IS_RED) {
- fs->w_q = f->w_q;
- fs->max_th = f->max_th;
- fs->min_th = f->min_th;
- fs->max_p = f->max_p;
- }
-
- return 0;
-}
-
-static int
-dn_compat_config_pipe(struct dn_sch *sch, struct dn_link *p,
- struct dn_fs *fs, void* v)
-{
- struct dn_pipe7 *p7 = (struct dn_pipe7 *)v;
- struct dn_pipe8 *p8 = (struct dn_pipe8 *)v;
- int i = p7->pipe_nr;
-
- sch->sched_nr = i;
- sch->oid.subtype = 0;
- p->link_nr = i;
- fs->fs_nr = i + 2*DN_MAX_ID;
- fs->sched_nr = i + DN_MAX_ID;
-
- /* Common to 7 and 8 */
- p->bandwidth = p7->bandwidth;
- p->delay = p7->delay;
- if (!is7) {
- /* FreeBSD 8 has burst */
- p->burst = p8->burst;
- }
-
- /* fill the fifo flowset */
- dn_compat_config_queue(fs, v);
- fs->fs_nr = i + 2*DN_MAX_ID;
- fs->sched_nr = i + DN_MAX_ID;
-
- /* Move scheduler related parameter from fs to sch */
- sch->buckets = fs->buckets; /*XXX*/
- fs->buckets = 0;
- if (fs->flags & DN_HAVE_MASK) {
- sch->flags |= DN_HAVE_MASK;
- fs->flags &= ~DN_HAVE_MASK;
- sch->sched_mask = fs->flow_mask;
- bzero(&fs->flow_mask, sizeof(struct ipfw_flow_id));
- }
-
- return 0;
-}
-
-static int
-dn_compat_config_profile(struct dn_profile *pf, struct dn_link *p,
- void *v)
-{
- struct dn_pipe8 *p8 = (struct dn_pipe8 *)v;
-
- p8->samples = &(((struct dn_pipe_max8 *)p8)->samples[0]);
-
- pf->link_nr = p->link_nr;
- pf->loss_level = p8->loss_level;
-// pf->bandwidth = p->bandwidth; //XXX bandwidth redundant?
- pf->samples_no = p8->samples_no;
- strncpy(pf->name, p8->name,sizeof(pf->name));
- bcopy(p8->samples, pf->samples, sizeof(pf->samples));
-
- return 0;
-}
-
-/*
- * If p->pipe_nr != 0 the command is 'pipe x config', so need to create
- * the three main struct, else only a flowset is created
- */
-static int
-dn_compat_configure(void *v)
-{
- struct dn_id *buf = NULL, *base;
- struct dn_sch *sch = NULL;
- struct dn_link *p = NULL;
- struct dn_fs *fs = NULL;
- struct dn_profile *pf = NULL;
- int lmax;
- int error;
-
- struct dn_pipe7 *p7 = (struct dn_pipe7 *)v;
- struct dn_pipe8 *p8 = (struct dn_pipe8 *)v;
-
- int i; /* number of object to configure */
-
- lmax = sizeof(struct dn_id); /* command header */
- lmax += sizeof(struct dn_sch) + sizeof(struct dn_link) +
- sizeof(struct dn_fs) + sizeof(struct dn_profile);
-
- base = buf = malloc(lmax, M_DUMMYNET, M_WAITOK|M_ZERO);
- o_next(&buf, sizeof(struct dn_id), DN_CMD_CONFIG);
- base->id = DN_API_VERSION;
-
- /* pipe_nr is the same in p7 and p8 */
- i = p7->pipe_nr;
- if (i != 0) { /* pipe config */
- sch = o_next(&buf, sizeof(*sch), DN_SCH);
- p = o_next(&buf, sizeof(*p), DN_LINK);
- fs = o_next(&buf, sizeof(*fs), DN_FS);
-
- error = dn_compat_config_pipe(sch, p, fs, v);
- if (error) {
- free(buf, M_DUMMYNET);
- return error;
- }
- if (!is7 && p8->samples_no > 0) {
- /* Add profiles*/
- pf = o_next(&buf, sizeof(*pf), DN_PROFILE);
- error = dn_compat_config_profile(pf, p, v);
- if (error) {
- free(buf, M_DUMMYNET);
- return error;
- }
- }
- } else { /* queue config */
- fs = o_next(&buf, sizeof(*fs), DN_FS);
- error = dn_compat_config_queue(fs, v);
- if (error) {
- free(buf, M_DUMMYNET);
- return error;
- }
- }
- error = do_config(base, (char *)buf - (char *)base);
-
- if (buf)
- free(buf, M_DUMMYNET);
- return error;
-}
-
-int
-dn_compat_calc_size(void)
-{
- int need = 0;
- /* XXX use FreeBSD 8 struct size */
- /* NOTE:
- * - half scheduler: schk_count/2
- * - all flowset: fsk_count
- * - all flowset queues: queue_count
- * - all pipe queue: si_count
- */
- need += V_dn_cfg.schk_count * sizeof(struct dn_pipe8) / 2;
- need += V_dn_cfg.fsk_count * sizeof(struct dn_flow_set);
- need += V_dn_cfg.si_count * sizeof(struct dn_flow_queue8);
- need += V_dn_cfg.queue_count * sizeof(struct dn_flow_queue8);
-
- return need;
-}
-
-int
-dn_c_copy_q (void *_ni, void *arg)
-{
- struct copy_args *a = arg;
- struct dn_flow_queue7 *fq7 = (struct dn_flow_queue7 *)*a->start;
- struct dn_flow_queue8 *fq8 = (struct dn_flow_queue8 *)*a->start;
- struct dn_flow *ni = (struct dn_flow *)_ni;
- int size = 0;
-
- /* XXX hash slot not set */
- /* No difference between 7.2/8 */
- fq7->len = ni->length;
- fq7->len_bytes = ni->len_bytes;
- fq7->id = ni->fid;
-
- if (is7) {
- size = sizeof(struct dn_flow_queue7);
- fq7->tot_pkts = ni->tot_pkts;
- fq7->tot_bytes = ni->tot_bytes;
- fq7->drops = ni->drops;
- } else {
- size = sizeof(struct dn_flow_queue8);
- fq8->tot_pkts = ni->tot_pkts;
- fq8->tot_bytes = ni->tot_bytes;
- fq8->drops = ni->drops;
- }
-
- *a->start += size;
- return 0;
-}
-
-int
-dn_c_copy_pipe(struct dn_schk *s, struct copy_args *a, int nq)
-{
- struct dn_link *l = &s->link;
- struct dn_fsk *f = s->fs;
-
- struct dn_pipe7 *pipe7 = (struct dn_pipe7 *)*a->start;
- struct dn_pipe8 *pipe8 = (struct dn_pipe8 *)*a->start;
- struct dn_flow_set *fs;
- int size = 0;
-
- if (is7) {
- fs = &pipe7->fs;
- size = sizeof(struct dn_pipe7);
- } else {
- fs = &pipe8->fs;
- size = sizeof(struct dn_pipe8);
- }
-
- /* These 4 field are the same in pipe7 and pipe8 */
- pipe7->next.sle_next = (struct dn_pipe7 *)DN_IS_PIPE;
- pipe7->bandwidth = l->bandwidth;
- pipe7->delay = l->delay * 1000 / hz;
- pipe7->pipe_nr = l->link_nr - DN_MAX_ID;
-
- if (!is7) {
- if (s->profile) {
- struct dn_profile *pf = s->profile;
- strncpy(pipe8->name, pf->name, sizeof(pf->name));
- pipe8->loss_level = pf->loss_level;
- pipe8->samples_no = pf->samples_no;
- }
- pipe8->burst = div64(l->burst , 8 * hz);
- }
-
- fs->flow_mask = s->sch.sched_mask;
- fs->rq_size = s->sch.buckets ? s->sch.buckets : 1;
-
- fs->parent_nr = l->link_nr - DN_MAX_ID;
- fs->qsize = f->fs.qsize;
- fs->plr[0] = f->fs.plr[0];
- fs->plr[1] = f->fs.plr[1];
- fs->plr[2] = f->fs.plr[2];
- fs->plr[3] = f->fs.plr[3];
- fs->w_q = f->fs.w_q;
- fs->max_th = f->max_th;
- fs->min_th = f->min_th;
- fs->max_p = f->fs.max_p;
- fs->rq_elements = nq;
-
- fs->flags_fs = convertflags2old(f->fs.flags);
-
- *a->start += size;
- return 0;
-}
-
-int
-dn_compat_copy_pipe(struct copy_args *a, void *_o)
-{
- int have = a->end - *a->start;
- int need = 0;
- int pipe_size = sizeof(struct dn_pipe8);
- int queue_size = sizeof(struct dn_flow_queue8);
- int n_queue = 0; /* number of queues */
-
- struct dn_schk *s = (struct dn_schk *)_o;
- /* calculate needed space:
- * - struct dn_pipe
- * - if there are instances, dn_queue * n_instances
- */
- n_queue = (s->sch.flags & DN_HAVE_MASK ? dn_ht_entries(s->siht) :
- (s->siht ? 1 : 0));
- need = pipe_size + queue_size * n_queue;
- if (have < need) {
- D("have %d < need %d", have, need);
- return 1;
- }
- /* copy pipe */
- dn_c_copy_pipe(s, a, n_queue);
-
- /* copy queues */
- if (s->sch.flags & DN_HAVE_MASK)
- dn_ht_scan(s->siht, dn_c_copy_q, a);
- else if (s->siht)
- dn_c_copy_q(s->siht, a);
- return 0;
-}
-
-int
-dn_c_copy_fs(struct dn_fsk *f, struct copy_args *a, int nq)
-{
- struct dn_flow_set *fs = (struct dn_flow_set *)*a->start;
-
- fs->next.sle_next = (struct dn_flow_set *)DN_IS_QUEUE;
- fs->fs_nr = f->fs.fs_nr;
- fs->qsize = f->fs.qsize;
- fs->plr[0] = f->fs.plr[0];
- fs->plr[1] = f->fs.plr[1];
- fs->plr[2] = f->fs.plr[2];
- fs->plr[3] = f->fs.plr[3];
- fs->w_q = f->fs.w_q;
- fs->max_th = f->max_th;
- fs->min_th = f->min_th;
- fs->max_p = f->fs.max_p;
- fs->flow_mask = f->fs.flow_mask;
- fs->rq_elements = nq;
- fs->rq_size = (f->fs.buckets ? f->fs.buckets : 1);
- fs->parent_nr = f->fs.sched_nr;
- fs->weight = f->fs.par[0];
-
- fs->flags_fs = convertflags2old(f->fs.flags);
- *a->start += sizeof(struct dn_flow_set);
- return 0;
-}
-
-int
-dn_compat_copy_queue(struct copy_args *a, void *_o)
-{
- int have = a->end - *a->start;
- int need = 0;
- int fs_size = sizeof(struct dn_flow_set);
- int queue_size = sizeof(struct dn_flow_queue8);
-
- struct dn_fsk *fs = (struct dn_fsk *)_o;
- int n_queue = 0; /* number of queues */
-
- n_queue = (fs->fs.flags & DN_HAVE_MASK ? dn_ht_entries(fs->qht) :
- (fs->qht ? 1 : 0));
-
- need = fs_size + queue_size * n_queue;
- if (have < need) {
- D("have < need");
- return 1;
- }
-
- /* copy flowset */
- dn_c_copy_fs(fs, a, n_queue);
-
- /* copy queues */
- if (fs->fs.flags & DN_HAVE_MASK)
- dn_ht_scan(fs->qht, dn_c_copy_q, a);
- else if (fs->qht)
- dn_c_copy_q(fs->qht, a);
-
- return 0;
-}
-
-int
-copy_data_helper_compat(void *_o, void *_arg)
-{
- struct copy_args *a = _arg;
-
- if (a->type == DN_COMPAT_PIPE) {
- struct dn_schk *s = _o;
- if (s->sch.oid.subtype != 1 || s->sch.sched_nr <= DN_MAX_ID) {
- return 0; /* not old type */
- }
- /* copy pipe parameters, and if instance exists, copy
- * other parameters and eventually queues.
- */
- if(dn_compat_copy_pipe(a, _o))
- return DNHT_SCAN_END;
- } else if (a->type == DN_COMPAT_QUEUE) {
- struct dn_fsk *fs = _o;
- if (fs->fs.fs_nr >= DN_MAX_ID)
- return 0;
- if (dn_compat_copy_queue(a, _o))
- return DNHT_SCAN_END;
- }
- return 0;
-}
-
-/* Main function to manage old requests */
-int
-ip_dummynet_compat(struct sockopt *sopt)
-{
- int error=0;
- void *v = NULL;
- struct dn_id oid;
-
- /* Length of data, used to found ipfw version... */
- int len = sopt->sopt_valsize;
-
- /* len can be 0 if command was dummynet_flush */
- if (len == pipesize7) {
- D("setting compatibility with FreeBSD 7.2");
- is7 = 1;
- }
- else if (len == pipesize8 || len == pipesizemax8) {
- D("setting compatibility with FreeBSD 8");
- is7 = 0;
- }
-
- switch (sopt->sopt_name) {
- default:
- printf("dummynet: -- unknown option %d", sopt->sopt_name);
- error = EINVAL;
- break;
-
- case IP_DUMMYNET_FLUSH:
- oid_fill(&oid, sizeof(oid), DN_CMD_FLUSH, DN_API_VERSION);
- do_config(&oid, oid.len);
- break;
-
- case IP_DUMMYNET_DEL:
- v = malloc(len, M_TEMP, M_WAITOK);
- error = sooptcopyin(sopt, v, len, len);
- if (error)
- break;
- error = dn_compat_del(v);
- free(v, M_TEMP);
- break;
-
- case IP_DUMMYNET_CONFIGURE:
- v = malloc(len, M_TEMP, M_NOWAIT);
- if (v == NULL) {
- error = ENOMEM;
- break;
- }
- error = sooptcopyin(sopt, v, len, len);
- if (error)
- break;
- error = dn_compat_configure(v);
- free(v, M_TEMP);
- break;
-
- case IP_DUMMYNET_GET: {
- void *buf;
- int ret;
- int original_size = sopt->sopt_valsize;
- int size;
-
- ret = dummynet_get(sopt, &buf);
- if (ret)
- return 0;//XXX ?
- size = sopt->sopt_valsize;
- sopt->sopt_valsize = original_size;
- D("size=%d, buf=%p", size, buf);
- ret = sooptcopyout(sopt, buf, size);
- if (ret)
- printf(" %s ERROR sooptcopyout\n", __FUNCTION__);
- if (buf)
- free(buf, M_DUMMYNET);
- }
- }
-
- return error;
-}
diff --git a/sys/netpfil/ipfw/ip_dn_private.h b/sys/netpfil/ipfw/ip_dn_private.h
index 756a997b6ec3..9a43b86791e0 100644
--- a/sys/netpfil/ipfw/ip_dn_private.h
+++ b/sys/netpfil/ipfw/ip_dn_private.h
@@ -437,15 +437,7 @@ struct copy_args {
};
struct sockopt;
-int ip_dummynet_compat(struct sockopt *sopt);
-int dummynet_get(struct sockopt *sopt, void **compat);
-int dn_c_copy_q (void *_ni, void *arg);
-int dn_c_copy_pipe(struct dn_schk *s, struct copy_args *a, int nq);
-int dn_c_copy_fs(struct dn_fsk *f, struct copy_args *a, int nq);
-int dn_compat_copy_queue(struct copy_args *a, void *_o);
-int dn_compat_copy_pipe(struct copy_args *a, void *_o);
-int copy_data_helper_compat(void *_o, void *_arg);
-int dn_compat_calc_size(void);
+int dummynet_get(struct sockopt *sopt);
int do_config(void *p, size_t l);
/* function to drain idle object */
diff --git a/sys/netpfil/ipfw/ip_dummynet.c b/sys/netpfil/ipfw/ip_dummynet.c
index d522f9da0fbe..61442c617753 100644
--- a/sys/netpfil/ipfw/ip_dummynet.c
+++ b/sys/netpfil/ipfw/ip_dummynet.c
@@ -2198,9 +2198,6 @@ compute_space(struct dn_id *cmd, struct copy_args *a)
case DN_FS: /* queue show */
x = DN_C_FS | DN_C_QUEUE;
break;
- case DN_GET_COMPAT: /* compatibility mode */
- need = dn_compat_calc_size();
- break;
}
a->flags = x;
if (x & DN_C_SCH) {
@@ -2226,11 +2223,9 @@ compute_space(struct dn_id *cmd, struct copy_args *a)
}
/*
- * If compat != NULL dummynet_get is called in compatibility mode.
- * *compat will be the pointer to the buffer to pass to ipfw
*/
int
-dummynet_get(struct sockopt *sopt, void **compat)
+dummynet_get(struct sockopt *sopt)
{
int have, i, need, error;
char *start = NULL, *buf;
@@ -2248,37 +2243,28 @@ dummynet_get(struct sockopt *sopt, void **compat)
cmd = &r.o;
- if (!compat) {
- /* copy at least an oid, and possibly a full object */
- error = sooptcopyin(sopt, cmd, sizeof(r), sizeof(*cmd));
- sopt->sopt_valsize = sopt_valsize;
- if (error)
- goto done;
- l = cmd->len;
+ /* copy at least an oid, and possibly a full object */
+ error = sooptcopyin(sopt, cmd, sizeof(r), sizeof(*cmd));
+ sopt->sopt_valsize = sopt_valsize;
+ if (error)
+ goto done;
+ l = cmd->len;
#ifdef EMULATE_SYSCTL
- /* sysctl emulation. */
- if (cmd->type == DN_SYSCTL_GET)
- return kesysctl_emu_get(sopt);
+ /* sysctl emulation. */
+ if (cmd->type == DN_SYSCTL_GET)
+ return kesysctl_emu_get(sopt);
#endif
- if (l > sizeof(r)) {
- /* request larger than default, allocate buffer */
- cmd = malloc(l, M_DUMMYNET, M_NOWAIT);
- if (cmd == NULL) {
- error = ENOMEM;
- goto done;
- }
- error = sooptcopyin(sopt, cmd, l, l);
- sopt->sopt_valsize = sopt_valsize;
- if (error)
- goto done;
+ if (l > sizeof(r)) {
+ /* request larger than default, allocate buffer */
+ cmd = malloc(l, M_DUMMYNET, M_NOWAIT);
+ if (cmd == NULL) {
+ error = ENOMEM;
+ goto done;
}
- } else { /* compatibility */
- error = 0;
- cmd->type = DN_CMD_GET;
- cmd->len = sizeof(struct dn_id);
- cmd->subtype = DN_GET_COMPAT;
- // cmd->id = sopt_valsize;
- D("compatibility mode");
+ error = sooptcopyin(sopt, cmd, l, l);
+ sopt->sopt_valsize = sopt_valsize;
+ if (error)
+ goto done;
}
#ifdef NEW_AQM
@@ -2337,12 +2323,7 @@ dummynet_get(struct sockopt *sopt, void **compat)
}
if (start == NULL) {
- if (compat) {
- *compat = NULL;
- error = 1; // XXX
- } else {
- error = sooptcopyout(sopt, cmd, sizeof(*cmd));
- }
+ error = sooptcopyout(sopt, cmd, sizeof(*cmd));
goto done;
}
ND("have %d:%d sched %d, %d:%d links %d, %d:%d flowsets %d, "
@@ -2355,35 +2336,20 @@ dummynet_get(struct sockopt *sopt, void **compat)
sopt->sopt_valsize = sopt_valsize;
a.type = cmd->subtype;
- if (compat == NULL) {
- memcpy(start, cmd, sizeof(*cmd));
- ((struct dn_id*)(start))->len = sizeof(struct dn_id);
- buf = start + sizeof(*cmd);
- } else
- buf = start;
+ memcpy(start, cmd, sizeof(*cmd));
+ ((struct dn_id*)(start))->len = sizeof(struct dn_id);
+ buf = start + sizeof(*cmd);
a.start = &buf;
a.end = start + have;
/* start copying other objects */
- if (compat) {
- a.type = DN_COMPAT_PIPE;
- dn_ht_scan(V_dn_cfg.schedhash, copy_data_helper_compat, &a);
- a.type = DN_COMPAT_QUEUE;
- dn_ht_scan(V_dn_cfg.fshash, copy_data_helper_compat, &a);
- } else if (a.type == DN_FS) {
+ if (a.type == DN_FS) {
dn_ht_scan(V_dn_cfg.fshash, copy_data_helper, &a);
} else {
dn_ht_scan(V_dn_cfg.schedhash, copy_data_helper, &a);
}
DN_BH_WUNLOCK();
- if (compat) {
- *compat = start;
- sopt->sopt_valsize = buf - start;
- /* free() is done by ip_dummynet_compat() */
- start = NULL; //XXX hack
- } else {
- error = sooptcopyout(sopt, start, buf - start);
- }
+ error = sooptcopyout(sopt, start, buf - start);
done:
if (cmd != &r.o)
free(cmd, M_DUMMYNET);
@@ -2519,17 +2485,9 @@ ip_dn_ctl(struct sockopt *sopt)
error = EINVAL;
break;
- case IP_DUMMYNET_FLUSH:
- case IP_DUMMYNET_CONFIGURE:
- case IP_DUMMYNET_DEL: /* remove a pipe or queue */
- case IP_DUMMYNET_GET:
- D("dummynet: compat option %d", sopt->sopt_name);
- error = ip_dummynet_compat(sopt);
- break;
-
case IP_DUMMYNET3:
if (sopt->sopt_dir == SOPT_GET) {
- error = dummynet_get(sopt, NULL);
+ error = dummynet_get(sopt);
break;
}
l = sopt->sopt_valsize;
diff --git a/sys/tools/gdb/README.txt b/sys/tools/gdb/README.txt
index 8c31565ddc42..ad1544912c3c 100644
--- a/sys/tools/gdb/README.txt
+++ b/sys/tools/gdb/README.txt
@@ -8,6 +8,9 @@ be automatically loaded by kgdb when opening a vmcore, so if you add new GDB
commands or functions, that script should be updated to import them, and you
should document them here.
+When improving these scripts, you can use the "kgdb-reload" command to reload
+them from /usr/lib/debug/boot/kernel/gdb/*.
+
To provide some rudimentary testing, selftest.py tries to exercise all of the
commands and functions defined here. To use it, run selftest.sh to panic the
system. Then, create a kernel dump or attach to the panicked kernel, and invoke
@@ -15,6 +18,8 @@ the script with "python import selftest" in (k)gdb.
Commands:
acttrace Display a backtrace for all on-CPU threads
+kgdb-reload Reload all gdb modules, useful when developing the modules
+ themselves.
Functions:
$PCPU(<field>[, <cpuid>]) Display the value of a PCPU/DPCPU field
diff --git a/sys/tools/gdb/acttrace.py b/sys/tools/gdb/acttrace.py
index 147effbbddf1..fdd18a4833cd 100644
--- a/sys/tools/gdb/acttrace.py
+++ b/sys/tools/gdb/acttrace.py
@@ -13,10 +13,8 @@ from pcpu import *
class acttrace(gdb.Command):
"""
- Register an acttrace command with gdb.
-
- When run, acttrace prints the stack trace of all threads that were on-CPU
- at the time of the panic.
+ Print the stack trace of all threads that were on-CPU at the time of
+ the panic.
"""
def __init__(self):
super(acttrace, self).__init__("acttrace", gdb.COMMAND_USER)
diff --git a/sys/tools/gdb/pcpu.py b/sys/tools/gdb/pcpu.py
index aadc4b2d42df..94c451e6eca5 100644
--- a/sys/tools/gdb/pcpu.py
+++ b/sys/tools/gdb/pcpu.py
@@ -9,7 +9,7 @@ from freebsd import *
class pcpu(gdb.Function):
"""
- Register a function to lookup PCPU and DPCPU variables by name.
+ A function to look up PCPU and DPCPU fields by name.
To look up the value of the PCPU field foo on CPU n, use
$PCPU("foo", n). This works for DPCPU fields too. If the CPU ID is
diff --git a/sys/tools/gdb/vnet.py b/sys/tools/gdb/vnet.py
index 36b4d512a3eb..5f416b2a515a 100644
--- a/sys/tools/gdb/vnet.py
+++ b/sys/tools/gdb/vnet.py
@@ -10,7 +10,7 @@ from freebsd import *
class vnet(gdb.Function):
"""
- Register a function to look up VNET variables by name.
+ A function to look up VNET variables by name.
To look at the value of a VNET variable V_foo, print $V("foo"). The
currently selected thread's VNET is used by default, but can be optionally
diff --git a/sys/tools/kernel-gdb.py b/sys/tools/kernel-gdb.py
index 8a41ef6efab1..990bdaf31fda 100644
--- a/sys/tools/kernel-gdb.py
+++ b/sys/tools/kernel-gdb.py
@@ -4,12 +4,40 @@
# SPDX-License-Identifier: BSD-2-Clause
#
+import importlib
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), "gdb"))
-# Import FreeBSD kernel debugging commands and modules below.
-import acttrace
-import pcpu
-import vnet
+modules = [
+ "acttrace",
+ "freebsd",
+ "pcpu",
+ "vnet"
+]
+
+
+def reload_modules(modules):
+ for mod in modules:
+ if mod in sys.modules:
+ importlib.reload(sys.modules[mod])
+ else:
+ importlib.import_module(mod)
+
+reload_modules(modules)
+
+
+class reload(gdb.Command):
+ """
+ Reload the FreeBSD kernel GDB helper scripts.
+ """
+ def __init__(self):
+ super(reload, self).__init__("kgdb-reload", gdb.COMMAND_USER)
+
+ def invoke(self, arg, from_tty):
+ reload_modules(modules)
+
+
+# Register the reload command with gdb.
+reload()
diff --git a/tests/sys/file/Makefile b/tests/sys/file/Makefile
index beb4452359b7..c1fcef68d08e 100644
--- a/tests/sys/file/Makefile
+++ b/tests/sys/file/Makefile
@@ -3,7 +3,7 @@ TESTSDIR= ${TESTSBASE}/sys/file
BINDIR= ${TESTSDIR}
ATF_TESTS_C+= path_test
-TAP_TESTS_C+= closefrom_test
+ATF_TESTS_C+= closefrom_test
TAP_TESTS_C+= dup_test
ATF_TESTS_C+= fcntlflags_test
TAP_TESTS_SH+= flock_test
diff --git a/tests/sys/file/closefrom_test.c b/tests/sys/file/closefrom_test.c
index 212d048d7566..a51e1630e24d 100644
--- a/tests/sys/file/closefrom_test.c
+++ b/tests/sys/file/closefrom_test.c
@@ -25,13 +25,13 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
/*
* Regression tests for the closefrom(2) system call.
*/
#include <sys/param.h>
#include <sys/mman.h>
+#include <sys/stat.h>
#include <sys/user.h>
#include <sys/wait.h>
#include <errno.h>
@@ -44,67 +44,57 @@
#include <string.h>
#include <unistd.h>
-struct shared_info {
- int failed;
- char tag[64];
- char message[0];
-};
+#include <atf-c.h>
-static int test = 1;
+static char *shared_page;
-static void
-ok(const char *descr)
+/*
+ * A variant of ATF_REQUIRE that is suitable for use in child
+ * processes. Since these tests close stderr, errors are reported to
+ * a shared page of memory checked by the parent process.
+ */
+#define CHILD_REQUIRE(exp) do { \
+ if (!(exp)) \
+ child_fail_require(__FILE__, __LINE__, \
+ #exp " not met"); \
+} while (0)
+
+static __dead2 __printflike(3, 4) void
+child_fail_require(const char *file, int line, const char *fmt, ...)
{
+ FILE *fp;
+ va_list ap;
- printf("ok %d - %s\n", test, descr);
- test++;
-}
+ fp = fmemopen(shared_page, PAGE_SIZE - 1, "w");
+ if (fp == NULL)
+ exit(1);
-static void
-fail(const char *descr, const char *fmt, ...)
-{
- va_list ap;
+ fprintf(fp, "%s:%d: ", file, line);
+ va_start(ap, fmt);
+ vfprintf(fp, fmt, ap);
+ va_end(ap);
+ fclose(fp);
- printf("not ok %d - %s", test, descr);
- test++;
- if (fmt) {
- va_start(ap, fmt);
- printf(" # ");
- vprintf(fmt, ap);
- va_end(ap);
- }
- printf("\n");
- exit(1);
+ exit(0);
}
-#define fail_err(descr) fail((descr), "%s", strerror(errno))
-
-static void
-cok(struct shared_info *info, const char *descr)
+static pid_t
+child_fork(void)
{
-
- info->failed = 0;
- strlcpy(info->tag, descr, sizeof(info->tag));
- exit(0);
+ shared_page = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_ANON |
+ MAP_SHARED, -1, 0);
+ ATF_REQUIRE_MSG(shared_page != MAP_FAILED, "mmap: %s", strerror(errno));
+ return (atf_utils_fork());
}
static void
-cfail(struct shared_info *info, const char *descr, const char *fmt, ...)
+child_wait(pid_t pid)
{
- va_list ap;
-
- info->failed = 1;
- strlcpy(info->tag, descr, sizeof(info->tag));
- if (fmt) {
- va_start(ap, fmt);
- vsprintf(info->message, fmt, ap);
- va_end(ap);
- }
- exit(0);
+ atf_utils_wait(pid, 0, "", "");
+ if (shared_page[0] != '\0')
+ atf_tc_fail("%s", shared_page);
}
-#define cfail_err(info, descr) cfail((info), (descr), "%s", strerror(errno))
-
/*
* Use kinfo_getfile() to fetch the list of file descriptors and figure out
* the highest open file descriptor.
@@ -116,9 +106,8 @@ highest_fd(void)
int cnt, i, highest;
kif = kinfo_getfile(getpid(), &cnt);
- if (kif == NULL)
- fail_err("kinfo_getfile");
- highest = INT_MIN;
+ ATF_REQUIRE_MSG(kif != NULL, "kinfo_getfile: %s", strerror(errno));
+ highest = -1;
for (i = 0; i < cnt; i++)
if (kif[i].kf_fd > highest)
highest = kif[i].kf_fd;
@@ -132,262 +121,253 @@ devnull(void)
int fd;
fd = open(_PATH_DEVNULL, O_RDONLY);
- if (fd < 0)
- fail_err("open(\" "_PATH_DEVNULL" \")");
+ ATF_REQUIRE_MSG(fd != -1, "open(\" "_PATH_DEVNULL" \"): %s",
+ strerror(errno));
return (fd);
}
-int
-main(void)
+ATF_TC_WITHOUT_HEAD(closefrom_simple);
+ATF_TC_BODY(closefrom_simple, tc)
{
- struct shared_info *info;
- pid_t pid;
- int fd, flags, i, start;
-
- printf("1..22\n");
+ int fd, start;
/* We'd better start up with fd's 0, 1, and 2 open. */
- start = devnull();
- if (start < 3)
- fail("open", "bad descriptor %d", start);
- ok("open");
+ start = highest_fd();
+ ATF_REQUIRE(start >= 2);
+
+ fd = devnull();
+ ATF_REQUIRE(fd > start);
/* Make sure highest_fd() works. */
- fd = highest_fd();
- if (start != fd)
- fail("highest_fd", "bad descriptor %d != %d", start, fd);
- ok("highest_fd");
-
- /* Try to use closefrom() for just closing fd 3. */
- closefrom(start);
- fd = highest_fd();
- if (fd != start - 1)
- fail("closefrom", "highest fd %d", fd);
- ok("closefrom");
+ ATF_REQUIRE_INTEQ(fd, highest_fd());
+
+ /* Try to use closefrom() to close just the new fd. */
+ closefrom(fd);
+ ATF_REQUIRE_INTEQ(start, highest_fd());
+}
+
+ATF_TC_WITHOUT_HEAD(closefrom_with_holes);
+ATF_TC_BODY(closefrom_with_holes, tc)
+{
+ int i, start;
+
+ start = highest_fd();
/* Eat up 16 descriptors. */
for (i = 0; i < 16; i++)
(void)devnull();
- fd = highest_fd();
- if (fd != start + 15)
- fail("open 16", "highest fd %d", fd);
- ok("open 16");
+
+ ATF_REQUIRE_INTEQ(start + 16, highest_fd());
/* Close half of them. */
- closefrom(11);
- fd = highest_fd();
- if (fd != 10)
- fail("closefrom", "highest fd %d", fd);
- ok("closefrom");
-
- /* Explicitly close descriptors 6 and 8 to create holes. */
- if (close(6) < 0 || close(8) < 0)
- fail_err("close2 ");
- ok("close 2");
-
- /* Verify that close on 6 and 8 fails with EBADF. */
- if (close(6) == 0)
- fail("close(6)", "did not fail");
- if (errno != EBADF)
- fail_err("close(6)");
- ok("close(6)");
- if (close(8) == 0)
- fail("close(8)", "did not fail");
- if (errno != EBADF)
- fail_err("close(8)");
- ok("close(8)");
-
- /* Close from 4 on. */
- closefrom(4);
- fd = highest_fd();
- if (fd != 3)
- fail("closefrom", "highest fd %d", fd);
- ok("closefrom");
-
- /* Allocate a small SHM region for IPC with our child. */
- info = mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_ANON |
- MAP_SHARED, -1, 0);
- if (info == MAP_FAILED)
- fail_err("mmap");
- ok("mmap");
-
- /* Fork a child process to test closefrom(0). */
- pid = fork();
- if (pid < 0)
- fail_err("fork");
+ closefrom(start + 9);
+ ATF_REQUIRE_INTEQ(start + 8, highest_fd());
+
+ /* Explicitly close two descriptors to create holes. */
+ ATF_REQUIRE_MSG(close(start + 3) == 0, "close(start + 3): %s",
+ strerror(errno));
+ ATF_REQUIRE_MSG(close(start + 5) == 0, "close(start + 5): %s",
+ strerror(errno));
+
+ /* Verify that close on the closed descriptors fails with EBADF. */
+ ATF_REQUIRE_ERRNO(EBADF, close(start + 3) == -1);
+ ATF_REQUIRE_ERRNO(EBADF, close(start + 5) == -1);
+
+ /* Close most remaining descriptors. */
+ closefrom(start + 2);
+ ATF_REQUIRE_INTEQ(start + 1, highest_fd());
+}
+
+ATF_TC_WITHOUT_HEAD(closefrom_zero);
+ATF_TC_BODY(closefrom_zero, tc)
+{
+ pid_t pid;
+ int fd;
+
+ /* Ensure standard descriptors are open. */
+ ATF_REQUIRE(highest_fd() >= 2);
+
+ pid = child_fork();
if (pid == 0) {
/* Child. */
closefrom(0);
fd = highest_fd();
- if (fd >= 0)
- cfail(info, "closefrom(0)", "highest fd %d", fd);
- cok(info, "closefrom(0)");
+ CHILD_REQUIRE(fd == -1);
+ exit(0);
}
- if (wait(NULL) < 0)
- fail_err("wait");
- if (info->failed)
- fail(info->tag, "%s", info->message);
- ok(info->tag);
-
- /* Fork a child process to test closefrom(-1). */
- pid = fork();
- if (pid < 0)
- fail_err("fork");
+
+ child_wait(pid);
+}
+
+ATF_TC_WITHOUT_HEAD(closefrom_negative_one);
+ATF_TC_BODY(closefrom_negative_one, tc)
+{
+ pid_t pid;
+ int fd;
+
+ /* Ensure standard descriptors are open. */
+ ATF_REQUIRE(highest_fd() >= 2);
+
+ pid = child_fork();
if (pid == 0) {
/* Child. */
closefrom(-1);
fd = highest_fd();
- if (fd >= 0)
- cfail(info, "closefrom(-1)", "highest fd %d", fd);
- cok(info, "closefrom(-1)");
+ CHILD_REQUIRE(fd == -1);
+ exit(0);
}
- if (wait(NULL) < 0)
- fail_err("wait");
- if (info->failed)
- fail(info->tag, "%s", info->message);
- ok(info->tag);
-
- /* Dup stdout to 6. */
- if (dup2(1, 6) < 0)
- fail_err("dup2");
- fd = highest_fd();
- if (fd != 6)
- fail("dup2", "highest fd %d", fd);
- ok("dup2");
+
+ child_wait(pid);
+}
+
+ATF_TC_WITHOUT_HEAD(closefrom_in_holes);
+ATF_TC_BODY(closefrom_in_holes, tc)
+{
+ int start;
+
+ start = highest_fd();
+ ATF_REQUIRE(start >= 2);
+
+ /* Dup stdout to a higher fd. */
+ ATF_REQUIRE_INTEQ(start + 4, dup2(1, start + 4));
+ ATF_REQUIRE_INTEQ(start + 4, highest_fd());
/* Do a closefrom() starting in a hole. */
- closefrom(4);
- fd = highest_fd();
- if (fd != 3)
- fail("closefrom", "highest fd %d", fd);
- ok("closefrom");
+ closefrom(start + 2);
+ ATF_REQUIRE_INTEQ(start, highest_fd());
/* Do a closefrom() beyond our highest open fd. */
- closefrom(32);
- fd = highest_fd();
- if (fd != 3)
- fail("closefrom", "highest fd %d", fd);
- ok("closefrom");
+ closefrom(start + 32);
+ ATF_REQUIRE_INTEQ(start, highest_fd());
+}
+
+ATF_TC_WITHOUT_HEAD(closerange_basic);
+ATF_TC_BODY(closerange_basic, tc)
+{
+ struct stat sb;
+ int i, start;
- /* Chew up another 8 fd */
+ start = highest_fd();
+
+ /* Open 8 file descriptors */
for (i = 0; i < 8; i++)
(void)devnull();
- fd = highest_fd();
- start = fd - 7;
+ ATF_REQUIRE_INTEQ(start + 8, highest_fd());
/* close_range() a hole in the middle */
- close_range(start + 3, start + 5, 0);
- for (i = start + 3; i < start + 6; ++i) {
- if (close(i) == 0 || errno != EBADF) {
- --i;
- break;
- }
- }
- if (i != start + 6)
- fail("close_range", "failed to close at %d in %d - %d", i + 1,
- start + 3, start + 6);
- ok("close_range");
+ ATF_REQUIRE_INTEQ(0, close_range(start + 3, start + 5, 0));
+ for (i = start + 3; i < start + 6; ++i)
+ ATF_REQUIRE_ERRNO(EBADF, fstat(i, &sb) == -1);
/* close_range from the middle of the hole */
- close_range(start + 4, start + 6, 0);
- if ((i = highest_fd()) != fd)
- fail("close_range", "highest fd %d", i);
- ok("close_range");
+ ATF_REQUIRE_INTEQ(0, close_range(start + 4, start + 6, 0));
+ ATF_REQUIRE_INTEQ(start + 8, highest_fd());
/* close_range to the end; effectively closefrom(2) */
- close_range(start + 3, ~0L, 0);
- if ((i = highest_fd()) != start + 2)
- fail("close_range", "highest fd %d", i);
- ok("close_range");
+ ATF_REQUIRE_INTEQ(0, close_range(start + 3, ~0L, 0));
+ ATF_REQUIRE_INTEQ(start + 2, highest_fd());
/* Now close the rest */
- close_range(start, start + 4, 0);
- fd = highest_fd();
- if (fd != 3)
- fail("close_range", "highest fd %d", fd);
- ok("close_range");
-
- /* Fork a child process to test closefrom(0) twice. */
- pid = fork();
- if (pid < 0)
- fail_err("fork");
+ ATF_REQUIRE_INTEQ(0, close_range(start + 1, start + 4, 0));
+ ATF_REQUIRE_INTEQ(start, highest_fd());
+}
+
+ATF_TC_WITHOUT_HEAD(closefrom_zero_twice);
+ATF_TC_BODY(closefrom_zero_twice, tc)
+{
+ pid_t pid;
+ int fd;
+
+ /* Ensure standard descriptors are open. */
+ ATF_REQUIRE(highest_fd() >= 2);
+
+ pid = child_fork();
if (pid == 0) {
/* Child. */
closefrom(0);
+ fd = highest_fd();
+ CHILD_REQUIRE(fd == -1);
closefrom(0);
- cok(info, "closefrom(0)");
+ fd = highest_fd();
+ CHILD_REQUIRE(fd == -1);
+ exit(0);
}
- if (wait(NULL) < 0)
- fail_err("wait");
- if (info->failed)
- fail(info->tag, "%s", info->message);
- ok(info->tag);
- /* test CLOSE_RANGE_CLOEXEC */
+ child_wait(pid);
+}
+
+static void
+require_fd_flag(int fd, const char *descr, const char *descr2, int flag,
+ bool set)
+{
+ int flags;
+
+ flags = fcntl(fd, F_GETFD);
+ ATF_REQUIRE_MSG(flags >= 0, "fcntl(.., F_GETFD): %s", strerror(errno));
+
+ if (set) {
+ ATF_REQUIRE_MSG((flags & flag) == flag,
+ "%s did not set %s on fd %d", descr, descr2, fd);
+ } else {
+ ATF_REQUIRE_MSG((flags & flag) == 0,
+ "%s set %s when it should not have on fd %d", descr, descr2,
+ fd);
+ }
+}
+
+ATF_TC_WITHOUT_HEAD(closerange_CLOEXEC);
+ATF_TC_BODY(closerange_CLOEXEC, tc)
+{
+ int i, start;
+
+ start = highest_fd();
+ ATF_REQUIRE(start >= 2);
+
for (i = 0; i < 8; i++)
(void)devnull();
- fd = highest_fd();
- start = fd - 8;
- if (close_range(start + 1, start + 4, CLOSE_RANGE_CLOEXEC) < 0)
- fail_err("close_range(..., CLOSE_RANGE_CLOEXEC)");
- flags = fcntl(start, F_GETFD);
- if (flags < 0)
- fail_err("fcntl(.., F_GETFD)");
- if ((flags & FD_CLOEXEC) != 0)
- fail("close_range", "CLOSE_RANGE_CLOEXEC set close-on-exec "
- "when it should not have on fd %d", start);
- for (i = start + 1; i <= start + 4; i++) {
- flags = fcntl(i, F_GETFD);
- if (flags < 0)
- fail_err("fcntl(.., F_GETFD)");
- if ((flags & FD_CLOEXEC) == 0)
- fail("close_range", "CLOSE_RANGE_CLOEXEC did not set "
- "close-on-exec on fd %d", i);
- }
- for (; i < start + 8; i++) {
- flags = fcntl(i, F_GETFD);
- if (flags < 0)
- fail_err("fcntl(.., F_GETFD)");
- if ((flags & FD_CLOEXEC) != 0)
- fail("close_range", "CLOSE_RANGE_CLOEXEC set close-on-exec "
- "when it should not have on fd %d", i);
+ ATF_REQUIRE_INTEQ(start + 8, highest_fd());
+
+ ATF_REQUIRE_INTEQ(0, close_range(start + 2, start + 5,
+ CLOSE_RANGE_CLOEXEC));
+ for (i = 1; i < 9; i++) {
+ require_fd_flag(start + i, "CLOSE_RANGE_CLOEXEC",
+ "close-on-exec", FD_CLOEXEC, i >= 2 && i <= 5);
}
- if (close_range(start, start + 8, 0) < 0)
- fail_err("close_range");
- ok("close_range(..., CLOSE_RANGE_CLOEXEC)");
+ ATF_REQUIRE_INTEQ(0, close_range(start + 1, start + 8, 0));
+}
+
+ATF_TC_WITHOUT_HEAD(closerange_CLOFORK);
+ATF_TC_BODY(closerange_CLOFORK, tc)
+{
+ int i, start;
+
+ start = highest_fd();
+ ATF_REQUIRE(start >= 2);
- /* test CLOSE_RANGE_CLOFORK */
for (i = 0; i < 8; i++)
(void)devnull();
- fd = highest_fd();
- start = fd - 8;
- if (close_range(start + 1, start + 4, CLOSE_RANGE_CLOFORK) < 0)
- fail_err("close_range(..., CLOSE_RANGE_CLOFORK)");
- flags = fcntl(start, F_GETFD);
- if (flags < 0)
- fail_err("fcntl(.., F_GETFD)");
- if ((flags & FD_CLOFORK) != 0)
- fail("close_range", "CLOSE_RANGE_CLOFORK set close-on-exec "
- "when it should not have on fd %d", start);
- for (i = start + 1; i <= start + 4; i++) {
- flags = fcntl(i, F_GETFD);
- if (flags < 0)
- fail_err("fcntl(.., F_GETFD)");
- if ((flags & FD_CLOFORK) == 0)
- fail("close_range", "CLOSE_RANGE_CLOFORK did not set "
- "close-on-exec on fd %d", i);
- }
- for (; i < start + 8; i++) {
- flags = fcntl(i, F_GETFD);
- if (flags < 0)
- fail_err("fcntl(.., F_GETFD)");
- if ((flags & FD_CLOFORK) != 0)
- fail("close_range", "CLOSE_RANGE_CLOFORK set close-on-exec "
- "when it should not have on fd %d", i);
+ ATF_REQUIRE_INTEQ(start + 8, highest_fd());
+
+ ATF_REQUIRE_INTEQ(0, close_range(start + 2, start + 5,
+ CLOSE_RANGE_CLOFORK));
+ for (i = 1; i < 9; i++) {
+ require_fd_flag(start + i, "CLOSE_RANGE_CLOFORK",
+ "close-on-fork", FD_CLOFORK, i >= 2 && i <= 5);
}
- if (close_range(start, start + 8, 0) < 0)
- fail_err("close_range");
- ok("close_range(..., CLOSE_RANGE_CLOFORK)");
+ ATF_REQUIRE_INTEQ(0, close_range(start + 1, start + 8, 0));
+}
- return (0);
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, closefrom_simple);
+ ATF_TP_ADD_TC(tp, closefrom_with_holes);
+ ATF_TP_ADD_TC(tp, closefrom_zero);
+ ATF_TP_ADD_TC(tp, closefrom_negative_one);
+ ATF_TP_ADD_TC(tp, closefrom_in_holes);
+ ATF_TP_ADD_TC(tp, closerange_basic);
+ ATF_TP_ADD_TC(tp, closefrom_zero_twice);
+ ATF_TP_ADD_TC(tp, closerange_CLOEXEC);
+ ATF_TP_ADD_TC(tp, closerange_CLOFORK);
+
+ return (atf_no_error());
}
diff --git a/tests/sys/fs/fusefs/bad_server.cc b/tests/sys/fs/fusefs/bad_server.cc
index c3d195735446..825523cac2bb 100644
--- a/tests/sys/fs/fusefs/bad_server.cc
+++ b/tests/sys/fs/fusefs/bad_server.cc
@@ -64,12 +64,12 @@ TEST_F(BadServer, ShortWrite)
out.header.error = 0;
out.header.unique = 0; // Asynchronous notification
out.expected_errno = EINVAL;
- m_mock->write_response(out);
/*
- * Tell the event loop to quit. The kernel has already disconnected us
+ * Tell the event loop to quit. The kernel will disconnect us
* because of the short write.
*/
- m_mock->m_quit = true;
+ m_mock->m_expect_unmount = true;
+ m_mock->write_response(out);
}
/*
@@ -98,7 +98,7 @@ TEST_F(BadServer, ErrorWithPayload)
out.push_back(std::move(out1));
// The kernel may disconnect us for bad behavior, so don't try
- // to read any more.
+ // to read or write any more.
m_mock->m_quit = true;
}));
diff --git a/tests/sys/fs/fusefs/mockfs.cc b/tests/sys/fs/fusefs/mockfs.cc
index 55c191716629..b6a32d9b60af 100644
--- a/tests/sys/fs/fusefs/mockfs.cc
+++ b/tests/sys/fs/fusefs/mockfs.cc
@@ -433,7 +433,8 @@ MockFS::MockFS(int max_read, int max_readahead, bool allow_other,
m_child_pid(-1),
m_maxwrite(MIN(max_write, max_max_write)),
m_nready(-1),
- m_quit(false)
+ m_quit(false),
+ m_expect_unmount(false)
{
struct sigaction sa;
struct iovec *iov = NULL;
@@ -979,7 +980,7 @@ void MockFS::read_request(mockfs_buf_in &in, ssize_t &res) {
}
res = read(m_fuse_fd, &in, sizeof(in));
- if (res < 0 && !m_quit) {
+ if (res < 0 && errno != EBADF && !m_quit && !m_expect_unmount) {
m_quit = true;
FAIL() << "read: " << strerror(errno);
}
diff --git a/tests/sys/fs/fusefs/mockfs.hh b/tests/sys/fs/fusefs/mockfs.hh
index 4b0628d34dd7..f98a5337c9d1 100644
--- a/tests/sys/fs/fusefs/mockfs.hh
+++ b/tests/sys/fs/fusefs/mockfs.hh
@@ -360,6 +360,9 @@ class MockFS {
/* Tell the daemon to shut down ASAP */
bool m_quit;
+ /* Tell the daemon that the server might forcibly unmount us */
+ bool m_expect_unmount;
+
/* Create a new mockfs and mount it to a tempdir */
MockFS(int max_read, int max_readahead, bool allow_other,
bool default_permissions, bool push_symlinks_in, bool ro,
diff --git a/tests/sys/netpfil/pf/anchor.sh b/tests/sys/netpfil/pf/anchor.sh
index 64ca84b34c3d..f321c742788e 100644
--- a/tests/sys/netpfil/pf/anchor.sh
+++ b/tests/sys/netpfil/pf/anchor.sh
@@ -123,6 +123,51 @@ nested_anchor_cleanup()
pft_cleanup
}
+atf_test_case "deeply_nested" "cleanup"
+deeply_nested_head()
+{
+ atf_set descr 'Test setting and retrieving deeply nested anchors'
+ atf_set require.user root
+}
+
+deeply_nested_body()
+{
+ pft_init
+
+ epair=$(vnet_mkepair)
+ vnet_mkjail alcatraz ${epair}a
+
+ pft_set_rules alcatraz \
+ "anchor \"foo\" { \n\
+ anchor \"bar\" { \n\
+ anchor \"foobar\" { \n\
+ pass on ${epair}a \n\
+ } \n\
+ anchor \"quux\" { \n\
+ pass on ${epair}a \n\
+ } \n\
+ } \n\
+ anchor \"baz\" { \n\
+ pass on ${epair}a \n\
+ } \n\
+ anchor \"qux\" { \n\
+ pass on ${epair}a \n\
+ } \n\
+ }"
+
+ atf_check -s exit:0 -o \
+ inline:" foo\n foo/bar\n foo/bar/foobar\n foo/bar/quux\n foo/baz\n foo/qux\n" \
+ jexec alcatraz pfctl -sA
+
+ atf_check -s exit:0 -o inline:" foo/bar/foobar\n foo/bar/quux\n" \
+ jexec alcatraz pfctl -a foo/bar -sA
+}
+
+deeply_nested_cleanup()
+{
+ pft_cleanup
+}
+
atf_test_case "wildcard" "cleanup"
wildcard_head()
{
@@ -498,6 +543,7 @@ atf_init_test_cases()
atf_add_test_case "pr183198"
atf_add_test_case "pr279225"
atf_add_test_case "nested_anchor"
+ atf_add_test_case "deeply_nested"
atf_add_test_case "wildcard"
atf_add_test_case "nested_label"
atf_add_test_case "quick"
diff --git a/usr.bin/id/id.1 b/usr.bin/id/id.1
index b8dafb6650b0..62c941f84798 100644
--- a/usr.bin/id/id.1
+++ b/usr.bin/id/id.1
@@ -28,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd March 5, 2011
+.Dd October 23, 2025
.Dt ID 1
.Os
.Sh NAME
@@ -50,12 +50,18 @@
.Nm
.Fl c
.Nm
+.Fl d
+.Op Ar user
+.Nm
.Fl g Op Fl nr
.Op Ar user
.Nm
.Fl p
.Op Ar user
.Nm
+.Fl s
+.Op Ar user
+.Nm
.Fl u Op Fl nr
.Op Ar user
.Sh DESCRIPTION
@@ -90,6 +96,8 @@ Ignored for compatibility with other
implementations.
.It Fl c
Display current login class.
+.It Fl d
+Display the home directory of the current or specified user.
.It Fl g
Display the effective group ID as a number.
.It Fl n
@@ -128,6 +136,8 @@ Display the real ID for the
and
.Fl u
options instead of the effective ID.
+.It Fl s
+Display the shell of the current or specified user.
.It Fl u
Display the effective user ID as a number.
.El
@@ -174,8 +184,20 @@ bob pts/5 Dec 4 19:51
.Sh STANDARDS
The
.Nm
-function is expected to conform to
-.St -p1003.2 .
+utility is expected to conform to
+.St -p1003.1-2024 .
+The
+.Fl A ,
+.Fl M ,
+.Fl P ,
+.Fl c ,
+.Fl d ,
+.Fl p ,
+and
+.Fl s
+options are
+.Fx
+extensions.
.Sh HISTORY
The
historic
diff --git a/usr.bin/id/id.c b/usr.bin/id/id.c
index 7112e0dddb91..5f9d2670caa3 100644
--- a/usr.bin/id/id.c
+++ b/usr.bin/id/id.c
@@ -53,79 +53,94 @@ static void pretty(struct passwd *);
#ifdef USE_BSM_AUDIT
static void auditid(void);
#endif
-static void group(struct passwd *, int);
+static void group(struct passwd *, bool);
static void maclabel(void);
+static void dir(struct passwd *);
+static void shell(struct passwd *);
static void usage(void);
static struct passwd *who(char *);
-static int isgroups, iswhoami;
+static bool isgroups, iswhoami;
int
main(int argc, char *argv[])
{
struct group *gr;
struct passwd *pw;
- int Gflag, Mflag, Pflag, ch, gflag, id, nflag, pflag, rflag, uflag;
- int Aflag, cflag;
- int error;
- const char *myname;
+#ifdef USE_BSM_AUDIT
+ bool Aflag;
+#endif
+ bool Gflag, Mflag, Pflag;
+ bool cflag, dflag, gflag, nflag, pflag, rflag, sflag, uflag;
+ int ch, combo, error, id;
+ const char *myname, *optstr;
char loginclass[MAXLOGNAME];
- Gflag = Mflag = Pflag = gflag = nflag = pflag = rflag = uflag = 0;
- Aflag = cflag = 0;
+#ifdef USE_BSM_AUDIT
+ Aflag = false;
+#endif
+ Gflag = Mflag = Pflag = false;
+ cflag = dflag = gflag = nflag = pflag = rflag = sflag = uflag = false;
- myname = strrchr(argv[0], '/');
- myname = (myname != NULL) ? myname + 1 : argv[0];
+ myname = getprogname();
+ optstr = "AGMPacdgnprsu";
if (strcmp(myname, "groups") == 0) {
- isgroups = 1;
- Gflag = nflag = 1;
+ isgroups = true;
+ optstr = "";
+ Gflag = nflag = true;
}
else if (strcmp(myname, "whoami") == 0) {
- iswhoami = 1;
- uflag = nflag = 1;
+ iswhoami = true;
+ optstr = "";
+ uflag = nflag = true;
}
- while ((ch = getopt(argc, argv,
- (isgroups || iswhoami) ? "" : "APGMacgnpru")) != -1)
+ while ((ch = getopt(argc, argv, optstr)) != -1) {
switch(ch) {
#ifdef USE_BSM_AUDIT
case 'A':
- Aflag = 1;
+ Aflag = true;
break;
#endif
case 'G':
- Gflag = 1;
+ Gflag = true;
break;
case 'M':
- Mflag = 1;
+ Mflag = true;
break;
case 'P':
- Pflag = 1;
+ Pflag = true;
break;
case 'a':
break;
case 'c':
- cflag = 1;
+ cflag = true;
+ break;
+ case 'd':
+ dflag = true;
break;
case 'g':
- gflag = 1;
+ gflag = true;
break;
case 'n':
- nflag = 1;
+ nflag = true;
break;
case 'p':
- pflag = 1;
+ pflag = true;
break;
case 'r':
- rflag = 1;
+ rflag = true;
+ break;
+ case 's':
+ sflag = true;
break;
case 'u':
- uflag = 1;
+ uflag = true;
break;
- case '?':
default:
usage();
}
+ }
argc -= optind;
argv += optind;
@@ -134,16 +149,13 @@ main(int argc, char *argv[])
if ((cflag || Aflag || Mflag) && argc > 0)
usage();
- switch(Aflag + Gflag + Mflag + Pflag + gflag + pflag + uflag) {
- case 1:
- break;
- case 0:
- if (!nflag && !rflag)
- break;
- /* FALLTHROUGH */
- default:
+ combo = Aflag + Gflag + Mflag + Pflag + gflag + pflag + uflag;
+ if (combo + dflag + sflag > 1)
+ usage();
+ if (combo > 1)
+ usage();
+ if (combo == 0 && (nflag || rflag))
usage();
- }
pw = *argv ? who(*argv) : NULL;
@@ -183,6 +195,11 @@ main(int argc, char *argv[])
exit(0);
}
+ if (dflag) {
+ dir(pw);
+ exit(0);
+ }
+
if (Gflag) {
group(pw, nflag);
exit(0);
@@ -203,6 +220,11 @@ main(int argc, char *argv[])
exit(0);
}
+ if (sflag) {
+ shell(pw);
+ exit(0);
+ }
+
id_print(pw);
exit(0);
}
@@ -217,7 +239,7 @@ pretty(struct passwd *pw)
if (pw) {
(void)printf("uid\t%s\n", pw->pw_name);
(void)printf("groups\t");
- group(pw, 1);
+ group(pw, true);
} else {
if ((login = getlogin()) == NULL)
err(1, "getlogin");
@@ -243,7 +265,7 @@ pretty(struct passwd *pw)
(void)printf("rgid\t%u\n", rid);
}
(void)printf("groups\t");
- group(NULL, 1);
+ group(NULL, true);
}
}
@@ -366,7 +388,7 @@ auditid(void)
#endif
static void
-group(struct passwd *pw, int nflag)
+group(struct passwd *pw, bool nflag)
{
struct group *gr;
int cnt, id, lastid, ngroups;
@@ -452,41 +474,57 @@ who(char *u)
static void
pline(struct passwd *pw)
{
-
- if (!pw) {
+ if (pw == NULL) {
if ((pw = getpwuid(getuid())) == NULL)
err(1, "getpwuid");
}
-
(void)printf("%s:%s:%d:%d:%s:%ld:%ld:%s:%s:%s\n", pw->pw_name,
- pw->pw_passwd, pw->pw_uid, pw->pw_gid, pw->pw_class,
- (long)pw->pw_change, (long)pw->pw_expire, pw->pw_gecos,
- pw->pw_dir, pw->pw_shell);
+ pw->pw_passwd, pw->pw_uid, pw->pw_gid, pw->pw_class,
+ (long)pw->pw_change, (long)pw->pw_expire, pw->pw_gecos,
+ pw->pw_dir, pw->pw_shell);
}
+static void
+dir(struct passwd *pw)
+{
+ if (pw == NULL) {
+ if ((pw = getpwuid(getuid())) == NULL)
+ err(1, "getpwuid");
+ }
+ printf("%s\n", pw->pw_dir);
+}
static void
-usage(void)
+shell(struct passwd *pw)
{
+ if (pw == NULL) {
+ if ((pw = getpwuid(getuid())) == NULL)
+ err(1, "getpwuid");
+ }
+ printf("%s\n", pw->pw_shell);
+}
+static void
+usage(void)
+{
if (isgroups)
(void)fprintf(stderr, "usage: groups [user]\n");
else if (iswhoami)
(void)fprintf(stderr, "usage: whoami\n");
else
- (void)fprintf(stderr, "%s\n%s%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
- "usage: id [user]",
+ (void)fprintf(stderr,
+ "usage: id [user]\n"
#ifdef USE_BSM_AUDIT
- " id -A\n",
-#else
- "",
+ " id -A\n"
#endif
- " id -G [-n] [user]",
- " id -M",
- " id -P [user]",
- " id -c",
- " id -g [-nr] [user]",
- " id -p [user]",
- " id -u [-nr] [user]");
+ " id -G [-n] [user]\n"
+ " id -M\n"
+ " id -P [user]\n"
+ " id -c\n"
+ " id -d [user]\n"
+ " id -g [-nr] [user]\n"
+ " id -p [user]\n"
+ " id -s [user]\n"
+ " id -u [-nr] [user]\n");
exit(1);
}
diff --git a/usr.bin/kyua/Makefile b/usr.bin/kyua/Makefile
index 178a1d083b79..d6131651afbf 100644
--- a/usr.bin/kyua/Makefile
+++ b/usr.bin/kyua/Makefile
@@ -182,25 +182,25 @@ FILESGROUPS+= EXAMPLES
CONFS= kyua.conf-default
CONFSDIR= ${KYUA_CONFDIR}
CONFSNAME= kyua.conf
-CONFSDIRTAGS= package=tests
+CONFSDIRTAGS= package=kyua
DOCS= AUTHORS CONTRIBUTORS LICENSE
DOCSDIR= ${KYUA_DOCDIR}
-DOCSTAGS= package=tests
+DOCSTAGS= package=kyua
EXAMPLES= Kyuafile.top kyua.conf
EXAMPLESDIR= ${KYUA_EGDIR}
-EXAMPLESTAGS= package=tests
+EXAMPLESTAGS= package=kyua
.PATH: ${KYUA_SRCDIR}/examples
MISC= context.html index.html report.css test_result.html
MISCDIR= ${KYUA_MISCDIR}
-MISCTAGS= package=tests
+MISCTAGS= package=kyua
.PATH: ${KYUA_SRCDIR}/misc
STORE= migrate_v1_v2.sql migrate_v2_v3.sql schema_v3.sql
STOREDIR= ${KYUA_STOREDIR}
-STORETAGS= package=tests
+STORETAGS= package=kyua
.PATH: ${KYUA_SRCDIR}/store
CLEANFILES+= ${MAN}