dragonfly.git
10 months agodhcpcd: Update README.DRAGONFLY for 10.0.2
Roy Marples [Wed, 19 Jul 2023 14:52:00 +0000 (15:52 +0100)]
dhcpcd: Update README.DRAGONFLY for 10.0.2

10 months agoMerge branch 'vendor/DHCPCD'
Roy Marples [Wed, 19 Jul 2023 14:50:24 +0000 (15:50 +0100)]
Merge branch 'vendor/DHCPCD'

10 months agoImport dhcpcd-10.0.2 with the following changes:
Roy Marples [Wed, 19 Jul 2023 14:48:06 +0000 (15:48 +0100)]
Import dhcpcd-10.0.2 with the following changes:
 * BSD: When we get RTM_NEWADDR the interface must have IFF_UP
 * BSD: Fix non INET6 builds
 * DHCP: Don't enforce the message came port 67
 * privsep: Allow zero length messages through
 * dhcpcd: deal with HANGUP and EPIPE better
 * dhcpcd: Fix waitip address family
 * privsep: Check if we have a root process before sending it stuff
 * privsep: Only unlink control sockets if we created them
 * common: Improve valid_domain and check correct return
 * common: Allow hwaddr_ntoa to print an empty string
 * privsep: Send only what we have put in the buffer to script env

10 months agosys/vfs/hammer2: Use HAMMER2_VOLUME_BYTES for volume header size
Tomohiro Kusumi [Wed, 19 Jul 2023 08:08:06 +0000 (01:08 -0700)]
sys/vfs/hammer2: Use HAMMER2_VOLUME_BYTES for volume header size

Both HAMMER2_PBUFSIZE and HAMMER2_VOLUME_BYTES are 64KiB,
but HAMMER2_VOLUME_BYTES should be used for volume header size
when explicitly getting / reading a volume header block.
It's been mix of these two.

10 months agosys/vfs/hammer2: Fix XOP structure used in hammer2_inode_chain_flush()
Tomohiro Kusumi [Sun, 16 Jul 2023 08:34:16 +0000 (01:34 -0700)]
sys/vfs/hammer2: Fix XOP structure used in hammer2_inode_chain_flush()

hammer2_inode_flush_desc expects hammer2_xop_flush_t, not hammer2_xop_fsync_t.
It's been compiling since both have a common header at offset 0,
and hammer2_xop_flush_t doesn't have any other fields.

11 months agopf - Fix PF_AEQ and PF_ANEQ macro checks
Matthew Dillon [Sun, 9 Jul 2023 01:04:29 +0000 (18:04 -0700)]
pf - Fix PF_AEQ and PF_ANEQ macro checks

* These macros were improperly checking IPV6 addresses in IPV4 packets
  when the IPV4 test fails.  While the resulting conditional still works
  (the IPV6 test is guaranteed to also fail in this case), the code was
  overrunning the packet header in some cases by accessing IPV6 fields
  beyond the end of an IPV4 packet.

* Fix the macros.

11 months agonetwork - Remove ip_len header-length adjustment
Matthew Dillon [Sun, 9 Jul 2023 01:00:31 +0000 (18:00 -0700)]
network - Remove ip_len header-length adjustment

* This should remove the last main code path modifications to packet
  mbuf contents.  The IP header in the mbuf is now basically left alone
  whenever possible, bringing us in-line with FreeBSD and Linux and
  removing cache-line bounces between cpus and between a cpu and the
  related PCIe DMA.

* Do not adjust ip_len to remove the IP header length.

* Various protocol stacks do the subtraction themselves, when needed.

* Various bits of code that added the length back in to execute a function
  then removed it again cleaned up.

* IP reassembly (in ip_input.c and pf_norm.c) cleaned up.

11 months agonetwork - Remove host-order translations of ipv4 ip_off and ip_len
Matthew Dillon [Sat, 8 Jul 2023 03:33:47 +0000 (20:33 -0700)]
network - Remove host-order translations of ipv4 ip_off and ip_len

* Do not translate ip_off and ip_len to host order and then back again
  in the network stack.  The fields are now left in network order.

11 months agoip_forward: Migrate cpu if hash doesn't match.
Kyle Butt [Wed, 5 Jul 2023 15:01:47 +0000 (09:01 -0600)]
ip_forward: Migrate cpu if hash doesn't match.

Packet filter re-writes can cause the call to ip_forward to be on the
wrong CPU. Detect this case and correct it. Check M_HASH at the
beginning of ip_input and dispatch to a new CPU if we aren't in the
right place. This mirrors what is done for packets that are destined to
the transport layer. This causes ip_forward and ip_output to be called
on the correct CPU, including any states that are created by output
rules.

11 months agousr.sbin/makefs/hammer2: Allow "-o I" setcheck|setcomp against PFS root
Tomohiro Kusumi [Tue, 4 Jul 2023 07:12:23 +0000 (00:12 -0700)]
usr.sbin/makefs/hammer2: Allow "-o I" setcheck|setcomp against PFS root

It's been returning error for "/" which is PFS root inode.

11 months agousr.sbin/makefs/hammer2: Fix link count handling in "-o R" option
Tomohiro Kusumi [Mon, 3 Jul 2023 07:23:04 +0000 (00:23 -0700)]
usr.sbin/makefs/hammer2: Fix link count handling in "-o R" option

Sanity check in hammer2_linkq_cleanup() is valid only when "-o R=/".
If a non-root directory was specified, not all links may exist under
that directory, and as a result unused linkq element remains.

While here change calloc to ecalloc and fix goto label name.

11 months agousr.sbin/makefs/hammer2: Fix broken extra-directory case
Tomohiro Kusumi [Sun, 2 Jul 2023 08:45:15 +0000 (01:45 -0700)]
usr.sbin/makefs/hammer2: Fix broken extra-directory case

-t hammer2 has been broken when [extra-directory ...] was specified.
(Looks like -t msdos is broken as well with extra-directory.)

Constructing a path via "dir + cur->name" was not same as
"cur->root + cur->path + cur->name" for extra-directory files
as extra-directory files don't exist under dir.

11 months agousr.sbin/makefs/hammer2: Support hardlink creation in "-o R" option
Tomohiro Kusumi [Sat, 1 Jul 2023 09:02:10 +0000 (02:02 -0700)]
usr.sbin/makefs/hammer2: Support hardlink creation in "-o R" option

which was missing part in 5e8b0eb766966577a1da788053d7ccaa443fa222.

If the underlying file system of destination files doesn't support
hardlink and/or creation fails, the failure is simply ignored.
It falls back on previous behavior (create different inodes with the
same file contents).

11 months agousr.sbin/makefs/hammer2: Support inode timestamp in "-o R" option
Tomohiro Kusumi [Sat, 1 Jul 2023 08:12:51 +0000 (01:12 -0700)]
usr.sbin/makefs/hammer2: Support inode timestamp in "-o R" option

which was missing part in 5e8b0eb766966577a1da788053d7ccaa443fa222.

Get timestamp from source inode within image file, and use that to
update newly created directory and regular file.

If the underlying file system of destination files doesn't support
timestamp and/or updating fails, the failure is simply ignored.

11 months agousr.sbin/makefs/hammer2: Fix memory leak from retired xops
Tomohiro Kusumi [Fri, 30 Jun 2023 08:13:58 +0000 (01:13 -0700)]
usr.sbin/makefs/hammer2: Fix memory leak from retired xops

Add missing kfrees from 9d036237cbc59969257aaea138ddec5dbd8e181b.

11 months agousr.sbin/makefs/hammer2: Support recursive read for "-o R" option
Tomohiro Kusumi [Tue, 27 Jun 2023 08:25:15 +0000 (01:25 -0700)]
usr.sbin/makefs/hammer2: Support recursive read for "-o R" option

"-o R" option currently creates 0 byte file if a given path is
a directory, as directory inode size is set to 0.

Change this to recursively walk directories, and retrieve directories
and regular files under that directory. Specifying "-o R=/" does
the reverse of what makefs(8) does.

It currently has following limitations.
- Only directory and regular file are supported, other types are ignored.
- Hard links are not ignored, but files are retrieved as different inodes
 and link count is not preserved.
- Inode timestamp is not preserved.
- Anything that HAMMER2 and this option support, but underlying
 file system doesn't is unsupported.

11 months agousr.sbin/makefs/hammer2: Introduce XOP fifo realloc
Tomohiro Kusumi [Tue, 27 Jun 2023 07:30:19 +0000 (00:30 -0700)]
usr.sbin/makefs/hammer2: Introduce XOP fifo realloc

Since makefs HAMMER2 used a serialized single threaded xops,
it was not possible to have more than HAMMER2_XOPFIFO fifo entries.

Change this to realloc XOP fifo whenever it hits current limit.
This is also what Free|Net|OpenBSD HAMMER2 currently do until they
support multi-threaded xops.

This makes possible to support VOP_READDIR, and that makes possible
to support recursive read for "-o R" option.

11 months agoopenresolv: Update README.DRAGONFLY for 3.13.2
Roy Marples [Tue, 27 Jun 2023 14:54:23 +0000 (15:54 +0100)]
openresolv: Update README.DRAGONFLY for 3.13.2

11 months agoMerge branch 'vendor/OPENRESOLV'
Roy Marples [Tue, 27 Jun 2023 14:52:03 +0000 (15:52 +0100)]
Merge branch 'vendor/OPENRESOLV'

11 months agoopenresolv: Update to version 3.13.2 with the following changes: vendor/OPENRESOLV
Roy Marples [Tue, 27 Jun 2023 14:47:22 +0000 (15:47 +0100)]
openresolv: Update to version 3.13.2 with the following changes:
* Do not return error from -i when no interfaces are configured
* unbound can now add generic options to forward zones

11 months agoUpdate the pciconf(8) database.
Sascha Wildner [Sun, 25 Jun 2023 00:51:35 +0000 (02:51 +0200)]
Update the pciconf(8) database.

May 23, 2023 snapshot from https://pci-ids.ucw.cz

11 months agousr.sbin/makefs/hammer2: Avoid overlapped snprintf buffer
Tomohiro Kusumi [Sun, 25 Jun 2023 04:59:07 +0000 (21:59 -0700)]
usr.sbin/makefs/hammer2: Avoid overlapped snprintf buffer

When "-o R" path argument contained symlink, the output path
was partly copying from/to the same buffer in stack. Use a
different buffer.

While here, move 64KB buffer for reading from stack to heap.

11 months agousr.sbin/makefs: Add HAMMER2 offline read / VOP_READ support
Tomohiro Kusumi [Sat, 24 Jun 2023 06:45:51 +0000 (23:45 -0700)]
usr.sbin/makefs: Add HAMMER2 offline read / VOP_READ support

The offline read takes HAMMER2 specific "-o R" option.
`image-file` argument is a valid HAMMER2 image file or block device.
Unlike other offline commands, `directory` must be a valid directory.

e.g.
$ makefs -t hammer2 -o R=/path/to/file /dev/adx /a/b/c
$ makefs -t hammer2 -o R=/path/to/file /path/to/hammer2.img /a/b/c

The "-o R" option requires file path argument. The file is retrieved
from `image-file` and written to a file under `directory`.
In the examples above, /path/to/file is retrieved as /a/b/c/file
on success.

11 months agousr.sbin/makefs/hammer2: Support VOP_READLINK
Tomohiro Kusumi [Fri, 23 Jun 2023 05:45:05 +0000 (22:45 -0700)]
usr.sbin/makefs/hammer2: Support VOP_READLINK

This makes possible for path component lookup against HAMMER2 image
to handle symlinks with limitations below.

1. It can't support symlink with absolute path destination by design,
 unless you can assume a given image is to be mounted at /.
2. It currently doesn't support "..". This is another non obvious
 case where a path could reach to outside of the image.

The regular HAMMER2 image creation doesn't use this (instead makefs
uses real readlink(2) when scanning a source directory).

11 months agousr.sbin/makefs/hammer2: Allow broken symlink when populating
Tomohiro Kusumi [Thu, 22 Jun 2023 05:40:11 +0000 (22:40 -0700)]
usr.sbin/makefs/hammer2: Allow broken symlink when populating

Symlinks need to be tested with lstat(2).
Using stat(2) for sanity doesn't allow creation of a broken symlink
whose source is also a broken symlink.

11 months agousr.sbin/makefs/hammer2: Fix use-after-free caused by unmodified inode
Tomohiro Kusumi [Tue, 20 Jun 2023 07:28:19 +0000 (00:28 -0700)]
usr.sbin/makefs/hammer2: Fix use-after-free caused by unmodified inode

Fix another bug only seen on OpenBSD.

Unlike regular makefs usage for image creation, ioctl commands don't
always modify all in-memory inodes. These unmodified inodes get freed
in makefs vflush() via hammer2_inode_drop() on unmount before PFS sync,
but they need to outlive chains.

Add per-PFS reclaim list to keep all inodes intact during unmount
process until PFS is ready to be freed.

11 months agousr.sbin/makefs/hammer2: Remove redundant hammer2_inode_modify()
Tomohiro Kusumi [Tue, 20 Jun 2023 07:15:25 +0000 (00:15 -0700)]
usr.sbin/makefs/hammer2: Remove redundant hammer2_inode_modify()

The inode setxxx ioctls don't need hammer2_inode_modify() for
intermediate directories.

The inode destroy ioctl needs hammer2_inode_modify() at least
for a direct parent directory of destroy target.

11 months agousr.sbin/makefs/hammer2: Fix minor -Wchar-subscripts warning on NetBSD
Tomohiro Kusumi [Mon, 19 Jun 2023 07:45:34 +0000 (00:45 -0700)]
usr.sbin/makefs/hammer2: Fix minor -Wchar-subscripts warning on NetBSD

Also fix local variable name from 6857f034386455e55e5ca87b75b84db5fcc3522e.

--
warning: array subscript has type 'char' [-Wchar-subscripts]
 1694 |  } else if (isdigit(comp_level_str[0])) {

11 months agousr.sbin/makefs/hammer2: Trim redundant / in input path
Tomohiro Kusumi [Mon, 19 Jun 2023 04:43:43 +0000 (21:43 -0700)]
usr.sbin/makefs/hammer2: Trim redundant / in input path

HAMMER2 ioctl commands in makefs(8) that need to resolve input path
components fail if the path contains consecutive or leading or tailing /.
Trim these /'s, instead of just trailing ones.

11 months agousr.sbin/makefs/hammer2: Fix assert bug when running ioctl commands
Tomohiro Kusumi [Mon, 19 Jun 2023 04:02:33 +0000 (21:02 -0700)]
usr.sbin/makefs/hammer2: Fix assert bug when running ioctl commands

The dir pointer should be NULL when running HAMMER2 ioctl command
with "--" for directory, and in that case assert(dir!=NULL) in common
paths are wrong.

Only seen this on OpenBSD which means only OpenBSD had NULL for
an uninitialized pointer in stack.

--
assertion "dir != NULL" failed: file "hammer2.c", line 269, function "hammer2_makefs"
assertion "dir != NULL" failed: file "hammer2.c", line 658, function "hammer2_validate"

11 months agousr.sbin/makefs/hammer2: Fix -Wunused-but-set-variable warnings on Linux
Tomohiro Kusumi [Sun, 18 Jun 2023 09:45:12 +0000 (02:45 -0700)]
usr.sbin/makefs/hammer2: Fix -Wunused-but-set-variable warnings on Linux

Local variables *iroot and lhc are set but never used.
Also fix sys/vfs/hammer2/hammer2_ioctl.c which is basically the same file.

Also remove "Get the clid" comment in the next line which didn't make
sense since 6f445d15835c6677a0a79c8d168ef44d0b9b22c3 in 2018.

11 months agousr.sbin/makefs: Add HAMMER2 offline inode setcheck|setcomp support
Tomohiro Kusumi [Sat, 17 Jun 2023 07:26:21 +0000 (00:26 -0700)]
usr.sbin/makefs: Add HAMMER2 offline inode setcheck|setcomp support

This commit adds "setcheck" and "setcomp" commands to "-o I" option.
`image-file` argument is a valid HAMMER2 image file or block device.
`directory` argument is unused, but needs to be a valid path or "--".

e.g.
$ makefs -t hammer2 -o I=setcheck:/path/to/file:sha192 /dev/adx --
$ makefs -t hammer2 -o I=setcomp:/path/to/file:zlib:6 /path/to/hammer2.img --

"setcheck" takes `:<inode_path>:<check_algo>` string after command name.
"setcomp" takes `:<inode_path>:<comp_algo>[:<comp_level>]` string
after command name. These are equivalent to hammer2(8) setcheck and
setcomp directives.

11 months agousr.sbin/makefs: Add HAMMER2 offline inode get support
Tomohiro Kusumi [Fri, 16 Jun 2023 07:15:21 +0000 (00:15 -0700)]
usr.sbin/makefs: Add HAMMER2 offline inode get support

The offline inode takes HAMMER2 specific "-o I" option.
`image-file` argument is a valid HAMMER2 image file or block device.
`directory` argument is unused, but needs to be a valid path or "--".

e.g.
$ makefs -t hammer2 -o I=get:/path/to/file /dev/adx --
$ makefs -t hammer2 -o I=get:/path/to/file /path/to/hammer2.img --

The "-o I" option requires inode command name argument, which is
currently only "get". "get" takes `:<inode_path>` string after command
name. "get" is equivalent to hammer2(8) printinode directive.

11 months agousr.sbin/makefs: Add offline HAMMER2IOC_VERSION_GET support
Tomohiro Kusumi [Thu, 15 Jun 2023 07:28:07 +0000 (00:28 -0700)]
usr.sbin/makefs: Add offline HAMMER2IOC_VERSION_GET support

The offline version get uses existing "-o V" option with no argument.
`image-file` argument is a valid HAMMER2 image file or block device.
`directory` argument is unused, but needs to be a valid path or "--".

e.g.
$ makefs -t hammer2 -o V /dev/adx --
$ makefs -t hammer2 -o V /path/to/hammer2.img --

There is no hammer2(8) directive for this as it's internally used.

11 months agousr.sbin/makefs: Introduce hammer2_makefs_options_t::ioctl_cmd flag
Tomohiro Kusumi [Thu, 15 Jun 2023 06:12:08 +0000 (23:12 -0700)]
usr.sbin/makefs: Introduce hammer2_makefs_options_t::ioctl_cmd flag

rather than having boolean flag for each ioctl command
since now that many of the hammer2(8) ioctls are implemented.

11 months agousr.sbin/makefs: Minor cleanup
Tomohiro Kusumi [Wed, 14 Jun 2023 06:13:47 +0000 (23:13 -0700)]
usr.sbin/makefs: Minor cleanup

12 months agousr.sbin/makefs: Fix "-o D" option when intermediate directories exist
Tomohiro Kusumi [Mon, 12 Jun 2023 08:44:12 +0000 (01:44 -0700)]
usr.sbin/makefs: Fix "-o D" option when intermediate directories exist

HAMMER2_DELETE_FILE assumes a given inode is a directory containing
dirent whose name is destroy.path. Therefore ioctl caller side needs
to split path components and only pass the last component along with
its direct parent directory inode.

It currently worked only when a target file path is the last component
without intermediate directories (no intermediate '/').

hammer2_ioc_destroy_t::path should be renamed to "name", as it
doesn't allow a file "path".

12 months agousr.sbin/makefs: Fix makefs(8) man page on -m option
Tomohiro Kusumi [Sun, 11 Jun 2023 07:05:56 +0000 (00:05 -0700)]
usr.sbin/makefs: Fix makefs(8) man page on -m option

-m and -o m are different options (latter is HAMMER2 specific),
and this context refers to -o m option.

12 months agousr.sbin/makefs: Add HAMMER2 offline PFS get|lookup|create|delete|snapshot support
Tomohiro Kusumi [Sat, 10 Jun 2023 08:12:06 +0000 (01:12 -0700)]
usr.sbin/makefs: Add HAMMER2 offline PFS get|lookup|create|delete|snapshot support

The offline PFS takes HAMMER2 specific "-o P" option.
`image-file` argument is a valid HAMMER2 image file or block device.
`directory` argument is unused, but needs to be a valid path or "--".

e.g.
$ makefs -t hammer2 -o P=get /dev/adx --
$ makefs -t hammer2 -o P=lookup:name /path/to/hammer2.img --
$ makefs -t hammer2 -o P=create:name /dev/adx --
$ makefs -t hammer2 -o P=delete:name /path/to/hammer2.img --
$ makefs -t hammer2 -o P=snapshot:name /dev/adx --
$ makefs -t hammer2 -o P=snapshot /path/to/hammer2.img --

The "-o P" option requires PFS command name argument, which are
"get" (alias "list"), "lookup", "create", "delete" and "snapshot".
lookup, create and delete take `:<pfs_name>` string after command name.
snapshot takes optional `:<pfs_name>` string after command name.

Use -m option (default "DATA") to specify target PFS for snapshot.

12 months agousr.sbin/makefs: Minor fix / cleanup
Tomohiro Kusumi [Fri, 9 Jun 2023 07:04:11 +0000 (00:04 -0700)]
usr.sbin/makefs: Minor fix / cleanup

12 months agousr.sbin/makefs: Add HAMMER2 emergency mode support
Tomohiro Kusumi [Fri, 9 Jun 2023 07:07:01 +0000 (00:07 -0700)]
usr.sbin/makefs: Add HAMMER2 emergency mode support

The "-o E" option sets emergency mode flag.
This can be used in conjunction with other operations,
but there is no point in using this option for regular usage.

12 months agonvme - Print detailed status on I/O error
Matthew Dillon [Thu, 8 Jun 2023 17:41:24 +0000 (10:41 -0700)]
nvme - Print detailed status on I/O error

* Print a rate-limited detailed status when a NVME I/O error occurs.

* Make the nvme_sync_delay sysctl __read_mostly

12 months agolibc - pthread_key_create() adjustments
Matthew Dillon [Fri, 2 Jun 2023 23:56:36 +0000 (16:56 -0700)]
libc - pthread_key_create() adjustments

* Have libc's stub conditionals ignore any error return from
  pthread_key_create() stubs, in case we decide to change the
  stub in the future.

* Change pthread_key_create() to start allocating keys at key #1
  to work around issues with third party programs making assumptions
  about the valid key range.

12 months agousr.sbin/makefs: Add HAMMER2 offline destroy support
Tomohiro Kusumi [Thu, 8 Jun 2023 07:46:22 +0000 (00:46 -0700)]
usr.sbin/makefs: Add HAMMER2 offline destroy support

The offline destroy takes HAMMER2 specific "-o D" option.
`image-file` argument is a valid HAMMER2 image file or block device.
`directory` argument is unused, but needs to be a valid path or "--".

e.g.
$ makefs -t hammer2 -o D=/a.out /dev/adx --
$ makefs -t hammer2 -o D=1234 /path/to/hammer2.img --

The "-o D" option reuires file path or inode number argument.
- If it's a file path, optarg must start with '/'.
- If it's an inum, optarg must start with "0x" or '0'-'9'.
Note that destroy by inum seems broken not only in makefs, but also
in real HAMMER2 ioctl.

12 months agousr.sbin/makefs/hammer2: Minor cleanup
Tomohiro Kusumi [Thu, 8 Jun 2023 07:12:29 +0000 (00:12 -0700)]
usr.sbin/makefs/hammer2: Minor cleanup

12 months agousr.sbin/makefs: Add HAMMER2 offline growfs support
Tomohiro Kusumi [Wed, 7 Jun 2023 08:12:14 +0000 (01:12 -0700)]
usr.sbin/makefs: Add HAMMER2 offline growfs support

The offline growfs takes HAMMER2 specific "-o G" option.
`image-file` argument is a valid HAMMER2 image file or block device.
`directory` argument is unused, but needs to be a valid path or "--".

e.g.
$ makefs -t hammer2 -o G /dev/adx --
$ makefs -t hammer2 -o G /path/to/hammer2.img --

By default expands volume to image file or block device size.
If -s option is specified, use that size.
No shrink support in the same way hammer2(8) growfs doesn't.

12 months agousr.sbin/makefs: Sync with sys/vfs/hammer2
Tomohiro Kusumi [Wed, 7 Jun 2023 08:34:12 +0000 (01:34 -0700)]
usr.sbin/makefs: Sync with sys/vfs/hammer2

Sync with following sys/vfs/hammer2 commits.

$ git log --pretty="%h %s" 01a24a934a5d6fd384584e1d72f1f9dd25bb98d3.. -- sys/vfs/hammer2/
0f90a2c50b sys/vfs/hammer2: Fail ioctl(HAMMER2IOC_GROWFS) if size > devvp size
a3364d7fa7 sys/vfs/hammer2: Change growfs kprintf format %jd -> %016jx for hammer2_off_t

12 months agosys/vfs/hammer2: Fail ioctl(HAMMER2IOC_GROWFS) if size > devvp size
Tomohiro Kusumi [Wed, 7 Jun 2023 07:49:20 +0000 (00:49 -0700)]
sys/vfs/hammer2: Fail ioctl(HAMMER2IOC_GROWFS) if size > devvp size

Currently, ioctl(HAMMER2IOC_GROWFS) with growfs->size larger than
devvp size can destroy the volume. The ioctl needs to fail if size
> devvp size.

Note that hammer2(8) growfs directive always uses growfs->size == 0,
meaning the volume is always expanded to its devvp size.

12 months agosys/vfs/hammer2: Change growfs kprintf format %jd -> %016jx for hammer2_off_t
Tomohiro Kusumi [Wed, 7 Jun 2023 07:25:24 +0000 (00:25 -0700)]
sys/vfs/hammer2: Change growfs kprintf format %jd -> %016jx for hammer2_off_t

like all other kprintfs in HAMMER2.
These sizes are usually block device size (i.e. multilple of 1GiB).

12 months agousr.sbin/makefs: Add HAMMER2 offline bulkfree support
Tomohiro Kusumi [Sat, 3 Jun 2023 07:12:15 +0000 (00:12 -0700)]
usr.sbin/makefs: Add HAMMER2 offline bulkfree support

Since makefs HAMMER2 implements the entire HAMMER2 logic in userspace
with selected vops using single threaded xops, it's actually trivial
to support other operations, e.g. HAMMER2 ioctls.

This commit adds bulkfree (free unreferenced blocks by scanning the
entire data chains from vchain) option to makefs. Unlike the existing
hammer2(8) "bulkfree" directive which requires live filesystem, this
option enables offline bulkfree against unmounted HAMMER2 image.

The offline bulkfree takes HAMMER2 specific "-o B" option. When this
option is specified, makefs runs offline bulkfree against `image-file`
argument instead of creating one, hence it must be a valid HAMMER2
image. `image-file` can be either a regular file or block device.
Unlike normal use case, `directory` argument is unused, but it's
still required. It can be any valid path or simply "--".

e.g.
$ makefs -t hammer2 -o B /dev/adx --
$ makefs -t hammer2 -o B /path/to/hammer2.img --

Technically, all HAMMER2 ioctls can be implemented in makefs as
offline version, but "bulkfree" and "growfs" are probably the only
hammer2(8) directives that make sense to exist as offline version.

Note that the limitation regarding OOM mentioned in 2d60b848f2 also
applies to bulkfree, i.e. makefs(8) could fail with partially written
`image-file` if it contains insane number of files or directories.

12 months agousr.sbin/makefs: Sync with sys/vfs/hammer2
Tomohiro Kusumi [Fri, 2 Jun 2023 08:35:15 +0000 (01:35 -0700)]
usr.sbin/makefs: Sync with sys/vfs/hammer2

Sync with following sys/vfs/hammer2 commits.

$ git log --pretty="%h %s" 6966bebf98ca11fee72e5ba9849224a5049211dd.. -- sys/vfs/hammer2/
23d820f091 sys/vfs/hammer2: Use howmany() to calculate bulkfree bmap size
e12df3bcd3 sys/vfs/hammer2: Fix comment on bmradix in freemap
8d92096877 sys/vfs/hammer2: Remove obsolete comments in freemap
f517f709f2 sys/vfs/hammer2: Remove redundant NULL chain test in bulkfree
c4cc6dbe36 sys/vfs/hammer2: Remove obsolete code/comment in freemap
a4cea70ee4 sys/vfs/hammer2: Fix 53b767003a to use plural
53b767003a sys/vfs/hammer2: Fix multiple "radii" -> "radix"

12 months agoboot: Expose SMBIOS entry point via kenv
Aaron LI [Sat, 6 May 2023 00:48:11 +0000 (08:48 +0800)]
boot: Expose SMBIOS entry point via kenv

The SMBIOS Reference Specification (v3.6.0) says (in Section 5.2.1):

"On UEFI-based systems, the SMBIOS Entry Point structure can be located
by looking in the EFI Configuration Table for the SMBIOS GUID
(SMBIOS_TABLE_GUID, {EB9D2D31-2D88-11D3-9A16- 0090273FC14D}) and using
the associated pointer."

So export the SMBIOS entry point via kenv to allow the SMBIOS table be
found in UEFI-only mode, where the BIOS is not mapped into the standard
address space and thus the SMBIOS table might not appear between 0xf0000
and 0xfffff.  For example, dmidecode(8) was failing with:

    Scanning /dev/mem for entry point.
    # No SMBIOS nor DMI entry point found, sorry.

Use the same kenv 'hint.smbios.0.mem' as FreeBSD to help with dports(7).

Refer-to: FreeBSD (revision 307326)
Discussed-with: swildner

12 months agoboot/efi: Recognize four more configuration tables
Aaron LI [Fri, 5 May 2023 23:24:30 +0000 (07:24 +0800)]
boot/efi: Recognize four more configuration tables

Recognize the following four configuration tables:
f2fd1544-9794-4a2c-992e-e5bbcf20e394 (SMBIOS3_TABLE_GUID)
b122a263-3661-4f68-9929-78f8b0d62180 (EFI_SYSTEM_RESOURCE_TABLE_GUID)
ee4e5898-3914-4259-9d6e-dc7bd79403cf (LZMA_CUSTOM_DECOMPRESS_GUIDE)
00781ca1-5de3-405f-abb8-379c3c076984 (AMI_ROM_LAYOUT_GUID)

Tested on my HPE MicroServer Gen10, which has SMBIOS3_TABLE_GUID,
EFI_SYSTEM_RESOURCE_TABLE_GUID and AMI_ROM_LAYOUT_GUID.

Refer-to: https://reviews.freebsd.org/D14036

12 months agostand/contrib: Add two more TianoCore EDK II headers
Aaron LI [Fri, 5 May 2023 23:10:16 +0000 (07:10 +0800)]
stand/contrib: Add two more TianoCore EDK II headers

Taken from the 'stable202302' release of repository:
https://github.com/tianocore/edk2

Paths:
- MdeModulePkg/Include/Guid/LzmaDecompress.h
- MdePkg/Include/Guid/SystemResourceTable.h

Modification: changed CRLF line endings to LF.

Suggested-by: swildner
12 months agox86_64/identcpu: Print supported XSAVE features
Aaron LI [Sat, 29 Apr 2023 03:20:04 +0000 (11:20 +0800)]
x86_64/identcpu: Print supported XSAVE features

Referred to FreeBSD.

12 months agox86_64/identcpu: Print more CPU features
Aaron LI [Sat, 29 Apr 2023 03:18:00 +0000 (11:18 +0800)]
x86_64/identcpu: Print more CPU features

Generally keep in sync with 'x86_64/include/specialreg.h'.

12 months agox86_64/identcpu: Add comments to features for consistency
Aaron LI [Sat, 29 Apr 2023 03:11:52 +0000 (11:11 +0800)]
x86_64/identcpu: Add comments to features for consistency

12 months agox86_64/identcpu: Style cleanups
Aaron LI [Sat, 29 Apr 2023 03:05:13 +0000 (11:05 +0800)]
x86_64/identcpu: Style cleanups

12 months agox86_64/identcpu: Add printing of CPU family and model
Aaron LI [Sat, 29 Apr 2023 01:39:24 +0000 (09:39 +0800)]
x86_64/identcpu: Add printing of CPU family and model

Obtained-from: FreeBSD

12 months agox86_64/identcpu: Remove whitespace in printing CPU vendor/ID/stepping
Aaron LI [Sat, 29 Apr 2023 01:33:40 +0000 (09:33 +0800)]
x86_64/identcpu: Remove whitespace in printing CPU vendor/ID/stepping

For consistency with the prints of other CPU features.

Obtained-from: FreeBSD

12 months agox86_64/specialreg.h: Add several more CPUID defines
Aaron LI [Sat, 29 Apr 2023 01:24:29 +0000 (09:24 +0800)]
x86_64/specialreg.h: Add several more CPUID defines

Obtained from NetBSD and FreeBSD.

12 months agosys/vfs/hammer2: Use howmany() to calculate bulkfree bmap size
Tomohiro Kusumi [Sun, 28 May 2023 09:15:12 +0000 (02:15 -0700)]
sys/vfs/hammer2: Use howmany() to calculate bulkfree bmap size

Note that the calculation here is based on the ratio below.
1GB (layer1 size) : 32KB (layer1 bmap total) = hmp->total_size : size

12 months agosys/vfs/hammer2: Fix comment on bmradix in freemap
Tomohiro Kusumi [Fri, 19 May 2023 08:30:26 +0000 (01:30 -0700)]
sys/vfs/hammer2: Fix comment on bmradix in freemap

The maximum radix is 16 (HAMMER2_RADIX_MAX),
so bmradix for radix > HAMMER2_FREEMAP_BLOCK_RADIX is either
4 (2 << (15-14)) for 32KiB or 8 (2 << (16-14)) for 64KiB.

12 months agostand - cleanup efi boot, fix corrupted free()
Matthew Dillon [Sat, 20 May 2023 06:32:51 +0000 (23:32 -0700)]
stand - cleanup efi boot, fix corrupted free()

* When freeing failed load resources, two of the resources allocated
  by boot services were being freed via free(), causing a panic.

* Do not complain if a path component is not a directory, simply fail.
  Remove unnecessary noise from alternative config file tests.

* Pre-assign NULL to pointers so they are NULL during error paths.
  Target procedures do not necessarily set them in error paths.

* Display EFI errors in hex, not virtually unreadable decimal.

* Cleanup for readability.

12 months agosys/vfs/hammer2: Remove obsolete comments in freemap
Tomohiro Kusumi [Thu, 18 May 2023 06:45:16 +0000 (23:45 -0700)]
sys/vfs/hammer2: Remove obsolete comments in freemap

ip, bref->key, bits, mask no longer appear here since commits in 2013.

12 months agosys/vfs/hammer2: Remove redundant NULL chain test in bulkfree
Tomohiro Kusumi [Tue, 16 May 2023 05:10:21 +0000 (22:10 -0700)]
sys/vfs/hammer2: Remove redundant NULL chain test in bulkfree

chain is never NULL at this point (see right above this),
and there are chain dereferences without test after this as well.

13 months agosys/vfs/hammer2: Remove obsolete code/comment in freemap
Tomohiro Kusumi [Fri, 12 May 2023 06:26:29 +0000 (23:26 -0700)]
sys/vfs/hammer2: Remove obsolete code/comment in freemap

The code for this comment (freemap_radix) was removed in
93f3933ac3e2ad37a7ba775663c711b13588f147 in 2013.

The #if0'd code right below this is unrelated code from
different commit, and it also does not compile anymore.

13 months agosys/vfs/hammer2: Fix 53b767003a to use plural
Tomohiro Kusumi [Fri, 12 May 2023 06:22:12 +0000 (23:22 -0700)]
sys/vfs/hammer2: Fix 53b767003a to use plural

suggested-by: swildner

13 months agostand/edk2: Reorganize the edk2 contrib hierarchy a bit.
Sascha Wildner [Thu, 11 May 2023 02:34:39 +0000 (04:34 +0200)]
stand/edk2: Reorganize the edk2 contrib hierarchy a bit.

* Move sys/contrib/edk2 to stand/contrib/edk2 where it really belongs.

* Put the *Pkg dir as an additional layer. Work that is currently in
  progress will require headers from other *Pkg's and we don't want to
  jumble them all into one directory.

In-discussion-with: aly

13 months agoRemove two empty private namespaces. One was commented out anyway.
Sascha Wildner [Tue, 9 May 2023 18:53:17 +0000 (20:53 +0200)]
Remove two empty private namespaces. One was commented out anyway.

13 months agolibz: Stop exporting internal functions.
Sascha Wildner [Tue, 9 May 2023 18:44:45 +0000 (20:44 +0200)]
libz: Stop exporting internal functions.

By default, this affects the following functions, which are now local:

0000000000009d1d t _tr_align
0000000000009d17 t _tr_flush_bits
0000000000009e09 t _tr_flush_block
0000000000009b8d t _tr_init
0000000000009bfa t _tr_stored_block
000000000000a433 t _tr_tally
0000000000004d69 t gz_error
000000000000ccbd t inflate_fast
000000000000dc92 t inflate_table
000000000000dc6e t zcalloc
000000000000dc81 t zcfree

Remove them from the ZLIBprivate_1.0 namespace, too. Also remove
gz_intmax here. It is not built on DragonFly.

13 months agosys/vfs/hammer2: Fix multiple "radii" -> "radix"
Tomohiro Kusumi [Tue, 9 May 2023 08:00:04 +0000 (01:00 -0700)]
sys/vfs/hammer2: Fix multiple "radii" -> "radix"

13 months agousr.sbin/makefs: Sync with sys/vfs/hammer2
Tomohiro Kusumi [Sat, 6 May 2023 10:12:22 +0000 (03:12 -0700)]
usr.sbin/makefs: Sync with sys/vfs/hammer2

Sync with following sys/vfs/hammer2 commits.

$ git log --pretty="%h %s" a0373a75974db9f2e5b8420fcc1111337d553f30.. -- sys/vfs/hammer2/
cbf2d85db0 sys/vfs/hammer2: Fix -Wformat warnings on other platforms
2a6d3b8baa sys/vfs/hammer2: Fix memory leak for second PFS mount and after

13 months agousr.sbin/makefs: Fix -Wformat warnings on other platforms
Tomohiro Kusumi [Sat, 6 May 2023 06:00:27 +0000 (23:00 -0700)]
usr.sbin/makefs: Fix -Wformat warnings on other platforms

Mostly from HAMMER2, except for DragonFly specific makefs_daddr_t
part in ffs/buf.c. Includes the same diff as cbf2d85db0.

13 months agosys/vfs/hammer2: Fix -Wformat warnings on other platforms
Tomohiro Kusumi [Thu, 4 May 2023 08:12:07 +0000 (01:12 -0700)]
sys/vfs/hammer2: Fix -Wformat warnings on other platforms

bref.key and meta.inum are always casted to "%ld" / long
(rather than intmax_t or long long) in sys/vfs/hammer2.

13 months agoamdpm.4: Mention intpm(4) in SEE ALSO
Aaron LI [Wed, 3 May 2023 11:53:53 +0000 (19:53 +0800)]
amdpm.4: Mention intpm(4) in SEE ALSO

13 months agointpm.4: Update description and supported chipsets
Aaron LI [Wed, 3 May 2023 11:51:17 +0000 (19:51 +0800)]
intpm.4: Update description and supported chipsets

Well, the intpm(4) Intel power management driver actually supports
some AMD chipsets.

Also update SEE ALSO items.

Obtained-from: FreeBSD

13 months agostand/boot: Fix typos.
Sascha Wildner [Wed, 3 May 2023 15:05:47 +0000 (17:05 +0200)]
stand/boot: Fix typos.

13 months agousr.sbin/makefs/hammer2: Print chian/dio count on vflush()
Tomohiro Kusumi [Wed, 3 May 2023 08:11:12 +0000 (01:11 -0700)]
usr.sbin/makefs/hammer2: Print chian/dio count on vflush()

in addition to inode count currently printed.

13 months agosys/vfs/hammer2: Fix memory leak for second PFS mount and after
Tomohiro Kusumi [Sat, 29 Apr 2023 05:30:09 +0000 (22:30 -0700)]
sys/vfs/hammer2: Fix memory leak for second PFS mount and after

When mounting, hmp and its ->devvpl are initialized only if it's
the first PFS mount of that hmp. For the second PFS mount and after,
malloc'd memory in a devvpl list (64 bytes per device per PFS)
has been leaked.

Found on FreeBSD on kldunload.
--
Warning: memory type hammer2_mount leaked memory on destroy (1 allocations, 64 bytes leaked).

13 months agousr.sbin/makefs/hammer2: Use blkno -1 for logical vnode for clarity
Tomohiro Kusumi [Tue, 25 Apr 2023 06:30:19 +0000 (23:30 -0700)]
usr.sbin/makefs/hammer2: Use blkno -1 for logical vnode for clarity

At logical vnode layer, only bio_offset from uio_offset is used,
in the same way DragonFly VFS does. Since blkno should never be used,
set it to -1.

Then the bio_offset turns into bref's data_off through chain lookup.
At physical vnode layer, bref's data_off turns into a buf associated
with dio's devvp.

At this point dio's devvp buf needs a valid blkno (but not a valid
offset as getblk/bread/bwrite functions in ffs/buf.c are based on
FreeBSD VFS) to calculate file offset within image.

13 months agousr.sbin/makefs/ffs: Remove m_buf::b_is_hammer2
Tomohiro Kusumi [Sat, 22 Apr 2023 07:41:49 +0000 (00:41 -0700)]
usr.sbin/makefs/ffs: Remove m_buf::b_is_hammer2

FreeBSD makefs(8) now calls brelse() on bwrite(), whereas DragonFly
has had that behavior specifically for HAMMER2 to emulate VFS behavior.

m_buf::b_is_hammer2 flag which was introduced for this reason now
needs to be removed, otherwise it attempts to double free struct m_buf.

13 months agousr.sbin/makefs/ffs: Sync buf.c with FreeBSD
Tomohiro Kusumi [Sat, 22 Apr 2023 07:29:32 +0000 (00:29 -0700)]
usr.sbin/makefs/ffs: Sync buf.c with FreeBSD

Bring in following FreeBSD commits,
while keeping DragonFly specific code for HAMMER2.

Note that msdosfs_vnops.c diff in FreeBSD e5551216d8e5 was never
merged to DragonFly makefs(8), so no need to apply (revert).

Sun Apr 16 15:45:17 2023 -0400 e5551216d8e5 makefs: call brelse from bread
Tue Apr 11 11:21:36 2023 -0400 af7624ed3145 makefs: use %s and __func__ in printf messages
Mon Apr 10 18:50:27 2023 -0400 1d1ffa2efd2a makefs: use size_t or ssize_t where appropriate

13 months agousr.sbin/makefs/hammer2: Change fsinode::priv -> param
Tomohiro Kusumi [Sat, 22 Apr 2023 07:09:01 +0000 (00:09 -0700)]
usr.sbin/makefs/hammer2: Change fsinode::priv -> param

FreeBSD makefs(8) now has a void* pointer ->param for ZFS support
which points to fs specific data structure.

makefs HAMMER2 has had a void* pointer ->priv for the same purpose,
so rename it to ->param to sync with FreeBSD, though no intention
to bring in ZFS support.

13 months agousr.sbin/makefs/hammer2: Avoid #include "makefs.h" in hammer2.h
Tomohiro Kusumi [Sat, 22 Apr 2023 07:01:12 +0000 (00:01 -0700)]
usr.sbin/makefs/hammer2: Avoid #include "makefs.h" in hammer2.h

Not a build error from ddd1d3d1ff2fecb3b58ce152a65095abaf634491,
but safer to avoid including "makefs.h" in usr.sbin/makefs/hammer2/hammer2.h
which basically shouldn't know anything about makefs(8).

13 months agousr.sbin/makefs/hammer2: Include <stdbool.h> for hammer2_update_time()
Tomohiro Kusumi [Sat, 22 Apr 2023 06:55:19 +0000 (23:55 -0700)]
usr.sbin/makefs/hammer2: Include <stdbool.h> for hammer2_update_time()

A bool argument from ddd1d3d1ff2fecb3b58ce152a65095abaf634491 needs <stdbool.h>.
It fails to compile on some platforms.

13 months agodhcpcd: Note upgrade to 10.0.1
Roy Marples [Fri, 21 Apr 2023 09:51:34 +0000 (10:51 +0100)]
dhcpcd: Note upgrade to 10.0.1

13 months agoMerge branch 'vendor/DHCPCD'
Roy Marples [Fri, 21 Apr 2023 09:50:16 +0000 (10:50 +0100)]
Merge branch 'vendor/DHCPCD'

13 months agoUpdate to dhcpcd-10.0.1 with the following changes:
Roy Marples [Fri, 21 Apr 2023 09:43:47 +0000 (10:43 +0100)]
Update to dhcpcd-10.0.1 with the following changes:

 * privsep: keep resources open rather than open/close
 * dhcp6: OPTION_NTP_SERVER is now preferred over OPTION_SNTP_SERVER
 * Misc bug fixes mainly around privsep for many platforms.
 * Fix for reading the some BSD routing table entries.
 * Fix reading authtokens from config.

13 months agobsd-family-tree: Sync with FreeBSD.
Sascha Wildner [Thu, 20 Apr 2023 09:28:18 +0000 (11:28 +0200)]
bsd-family-tree: Sync with FreeBSD.

13 months agoUpdate the pciconf(8) database.
Sascha Wildner [Thu, 20 Apr 2023 09:27:36 +0000 (11:27 +0200)]
Update the pciconf(8) database.

April 10, 2023 snapshot from https://pci-ids.ucw.cz

13 months agosbin/newfs_hammer2: Use uuid_create(3) rather than uuidgen(2)
Tomohiro Kusumi [Wed, 19 Apr 2023 07:20:14 +0000 (00:20 -0700)]
sbin/newfs_hammer2: Use uuid_create(3) rather than uuidgen(2)

for portability.
uuid_create(3), which is a wrapper over uuidgen(2) in DragonFly,
is the common interface among *BSD's.

The code has been using uuid(3) functions except for creation.

13 months agousched - Add support for > 64 cpus
Matthew Dillon [Tue, 18 Apr 2023 17:01:16 +0000 (10:01 -0700)]
usched - Add support for > 64 cpus

* Add support, allow cpumask to be parsed as mask[,mask[,mask[,...]]],
  in 64-bit chunks, lsb chunk first.

13 months agousr.sbin/makefs/hammer2: Derive timestamp from source inodes
Tomohiro Kusumi [Tue, 18 Apr 2023 07:30:26 +0000 (00:30 -0700)]
usr.sbin/makefs/hammer2: Derive timestamp from source inodes

makefs(8) HAMMER2 has been using current time for inode's ctime/mtime.
Change hammer2_update_time() to use current fsnode's timestamp.
Also support -T option.

Note that both hammer2_curnode (current fsnode) and stampst (-T option)
are global variables.

13 months agokernel: Adjust two Makefiles for my recent opt_*.h changes.
Sascha Wildner [Sun, 16 Apr 2023 09:57:34 +0000 (11:57 +0200)]
kernel: Adjust two Makefiles for my recent opt_*.h changes.

13 months agousr.sbin/makefs: Sync with sys/vfs/hammer2
Tomohiro Kusumi [Fri, 14 Apr 2023 07:00:45 +0000 (00:00 -0700)]
usr.sbin/makefs: Sync with sys/vfs/hammer2

Sync with following sys/vfs/hammer2 commits.

$ git log --pretty="%h %s" e49cd5358c56593a7923a00706d26dbc4e8bdaed.. -- sys/vfs/hammer2/
d6f11ef8ed sys/vfs/hammer2: Remove unneeded (char *)bp->b_data cast
0a7ab00601 sys/vfs/hammer2: Comment out unused local variables
8fd12ec463 sys/vfs/hammer2: Remove KKASSERT expecting path to start with "/dev/"
2e3d3c15cd sys/vfs/hammer2: Use HAMMER2_ROOT_VOLUME instead of 0
9be1b0c77a Revert "sys/vfs/hammer2: Avoid void* pointer arithmetic"

13 months agosys/vfs/hammer2: Remove unneeded (char *)bp->b_data cast
Tomohiro Kusumi [Fri, 14 Apr 2023 06:54:53 +0000 (23:54 -0700)]
sys/vfs/hammer2: Remove unneeded (char *)bp->b_data cast

Aside from 9be1b0c77afd935ea1e16400d86ee504c084ff74,
this was the only one originally existed in HAMMER2.

14 months agorbootd: add missing change to make it work
Roy Marples [Thu, 13 Apr 2023 17:05:04 +0000 (18:05 +0100)]
rbootd: add missing change to make it work

14 months agorbootd: Just open /dev/bpf rather than loop /dev/bpfN
Roy Marples [Thu, 13 Apr 2023 17:00:49 +0000 (18:00 +0100)]
rbootd: Just open /dev/bpf rather than loop /dev/bpfN

/dev/bpf is a cloner on modern BSD.
/dev/bpfN needs to go away.

14 months agosys/vfs/hammer2: Comment out unused local variables
Tomohiro Kusumi [Wed, 12 Apr 2023 07:38:07 +0000 (00:38 -0700)]
sys/vfs/hammer2: Comment out unused local variables

Warned on FreeBSD.
bmmask10 is used by #if0'd code, so keep it as comment.

--
warning: variable 'bmmask01' set but not used [-Wunused-but-set-variable]
        hammer2_bitmap_t bmmask01;
                         ^
warning: variable 'bmmask10' set but not used [-Wunused-but-set-variable]
        hammer2_bitmap_t bmmask10;
                         ^