freebsd.git
22 months agozfs: merge openzfs/zfs@b3d0568cf
Martin Matuska [Sat, 13 Aug 2022 23:13:55 +0000 (01:13 +0200)]
zfs: merge openzfs/zfs@b3d0568cf

Notable upstream pull request merges:
  #9372 Implement a new type of zfs receive: corrective receive (-c)
  #13635 Add snapshots_changed as property
  #13636 Add support for per dataset zil stats and use wmsum counters
  #13643 Fix scrub resume from newly created hole
  #13670 Fix memory allocation for the checksum benchmark
  #13695 Skip checksum benchmarks on systems with slow cpu
  #13711 zpool: fix redundancy check after vdev removal

Obtained from: OpenZFS
OpenZFS commit: b3d0568cfd65458c92f7ab3d7bb709087992628e

22 months agorc.d/hostid: Skip warning on systems w/o smbios
Colin Percival [Fri, 12 Aug 2022 23:48:26 +0000 (16:48 -0700)]
rc.d/hostid: Skip warning on systems w/o smbios

The first time a FreeBSD system boots, it obtains a hostuuid and hostid
from the smbios.system.uuid kernel environment variable.  If this value
is found to be invalid, a warning is printed and the boot pauses for
two seconds to give the user a chance to read it.

If the FreeBSD kernel is launched directly in a virtual machine rather
than via the FreeBSD boot loader, the smbios.system.uuid environment
variable might not be set; in this case, there's no need to alert the
user and delay the boot process since the lack of a "hardware" uuid is
entirely expected.

Distinguish between the cases of "invalid UUID" and "no UUID", warning
and delaying the boot only in the former case.  In both cases we still
generate a random UUID in software.

Reviewed by: delphij
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D36185

22 months agolapic_init: Reduce LOOPS
Colin Percival [Fri, 12 Aug 2022 23:51:34 +0000 (16:51 -0700)]
lapic_init: Reduce LOOPS

While I'm here, instrument lapic_init with TSLOG so it shows up (or
typically not, after this change) on flamecharts.

Reviewed by: kib
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D36186

22 months agoLRO: fix BPF filters for lagg in the hpts path
Andrew Gallatin [Sat, 13 Aug 2022 00:15:46 +0000 (20:15 -0400)]
LRO: fix BPF filters for lagg in the hpts path

When in the hpts path, we need to handle BPF filters since aggregated
packets do not pass up the stack in the normal way. This is already
done for most interfaces, but lagg needs special handling. This is
because packets received via a lagg are passed up the stack with
the leaf interface's ifp stored in m_pkthdr.rcvif.

To handle lagg packets, we must identify that the passed rcvif is
currently a lagg port by checking for IFT_IEEE8023ADLAG or
IFT_INFINIBANDLAG (since lagg changes the lagg port's type to that
when an interface becomes a lagg member). Then we need to find the
lagg's ifp, and handle any BPF listeners on the lagg.

Note: It is possible to have multiple BPF filters, one on a member
port and one on the lagg itself. That is why we have to have 2
checks and 2 ETHER_BPF_MTAPs.

Reviewed by: jhb, rrs
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D36136

22 months agoReplace a dead cross reference with the proper (I think) macro.
Jens Schweikhardt [Sat, 13 Aug 2022 20:54:00 +0000 (22:54 +0200)]
Replace a dead cross reference with the proper (I think) macro.

22 months agoExplicitly initialize rather than reading newly allocated UFS inodes.
Kirk McKusick [Sat, 13 Aug 2022 20:50:08 +0000 (13:50 -0700)]
Explicitly initialize rather than reading newly allocated UFS inodes.

The function ffs_vgetf() is used to find or load UFS inodes into a
vnode. It first looks up the inode and if found in the cache its
vnode is returned. If it is not already in the cache, a new vnode
is allocated and its associated inode read in from the disk. The
read is done even for inodes that are being initially created.
The contents for the inode on the disk are assumed to be empty. If
the on-disk contents had been corrupted either due to a hardware
glitch or an agent deliberately trying to exploit the system, the
UFS code could panic from the unexpected partially-allocated inode.

Rather then having fsck_ffs(8) verify that all unallocated inodes
are properly empty, it is easier and quicker to add a flag to
ffs_vgetf() to indicate that the request is for a newly allocated
inode. When set, the disk read is skipped and the inode is set to
its expected empty (zero'ed out) initial state. As a side benefit,
an unneeded disk I/O is avoided.

Reported by:  Peter Holm
Sponsored by: The FreeBSD Foundation

22 months agoFix wrong section number in man page cross references.
Jens Schweikhardt [Sat, 13 Aug 2022 20:42:23 +0000 (22:42 +0200)]
Fix wrong section number in man page cross references.

22 months agoFix wrong section number in man page cross references.
Jens Schweikhardt [Sat, 13 Aug 2022 20:30:19 +0000 (22:30 +0200)]
Fix wrong section number in man page cross references.

22 months agoCorrectness cleanups in fsck_ffs(8).
Kirk McKusick [Sat, 13 Aug 2022 20:27:37 +0000 (13:27 -0700)]
Correctness cleanups in fsck_ffs(8).

Allocation or I/O failures in fsck_ffs(8) could cause segment
faults because of missing checks or not-yet-initialized data
structures. Correct these issues.

Reported by:  Peter Holm
Sponsored by: The FreeBSD Foundation

22 months agostand: Fix a couple of comment typos in f8a199f28f9d
Jessica Clarke [Sat, 13 Aug 2022 19:48:30 +0000 (20:48 +0100)]
stand: Fix a couple of comment typos in f8a199f28f9d

The commit message documented it as /etc/src.conf but the comment in the
source mentioned the non-existent /etc/loader.conf.

Fixes: f8a199f28f9d ("stand: Raise limit to 550,000 bytes for loader")

22 months agoMove the ability to search for alternate UFS superblocks from fsck_ffs(8)
Kirk McKusick [Sat, 13 Aug 2022 19:41:53 +0000 (12:41 -0700)]
Move the ability to search for alternate UFS superblocks from fsck_ffs(8)
into ffs_sbsearch() to allow use by other parts of the system.

Historically only fsck_ffs(8), the UFS filesystem checker, had code
to track down and use alternate UFS superblocks. Since fsdb(8) used
much of the fsck_ffs(8) implementation it had some ability to track
down alternate superblocks.

This change extracts the code to track down alternate superblocks
from fsck_ffs(8) and puts it into a new function ffs_sbsearch() in
sys/ufs/ffs/ffs_subr.c. Like ffs_sbget() and ffs_sbput() also found
in ffs_subr.c, these functions can be used directly by the kernel
subsystems. Additionally they are exported to the UFS library,
libufs(8) so that they can be used by user-level programs. The new
functions added to libufs(8) are sbfind(3) that is an alternative
to sbread(3) and sbsearch(3) that is an alternative to sbget(3).
See their manual pages for further details.

The utilities that have been changed to search for superblocks are
dumpfs(8), fsdb(8), ffsinfo(8), and fsck_ffs(8). Also, the prtblknos(8)
tool found in tools/diag/prtblknos searches for superblocks.

The UFS specific mount code uses the superblock search interface
when mounting the root filesystem and when the administrator doing
a mount(8) command specifies the force flag (-f). The standalone UFS
boot code (found in stand/libsa/ufs.c) uses the superblock search
code in the hope of being able to get the system up and running so
that fsck_ffs(8) can be used to get the filesystem cleaned up.

The following utilities have not been changed to search for
superblocks: clri(8), tunefs(8), snapinfo(8), fstyp(8), quot(8),
dump(8), fsirand(8), growfs(8), quotacheck(8), gjournal(8), and
glabel(8). When these utilities fail, they do report the cause of
the failure. The one exception is the tasting code used to try and
figure what a given disk contains. The tasting code will remain
silent so as not to put out a slew of messages as it trying to taste
every new mass storage device that shows up.

Reviewed by: kib
Reviewed by: Warner Losh
Tested by:   Peter Holm
Differential Revision: https://reviews.freebsd.org/D36053
Sponsored by: The FreeBSD Foundation

22 months agobhyve nvme: Fix out-of-bound IOV array access
Chuck Tuffli [Thu, 9 Jun 2022 18:19:32 +0000 (11:19 -0700)]
bhyve nvme: Fix out-of-bound IOV array access

Summary:
NVMe operations indicate the memory region(s) associated with a command
via physical region pages (PRPs). Since each PRP has a fixed size,
contiguous memory regions larger than the PRP size require multiple PRP
entries.

Instead of issuing a blockif call for each PRP, the NVMe emulation
concatenates multiple contiguous PRP entries into a single blockif
request. The test for contiguous regions has a bug such that it
mistakenly treats an initial PRP address of zero as a contiguous range
and concatenates it with the previous. But because there is no previous
IOV, the concatenation code corrupts the IO request structure and leads
to a segmentation fault when the blockif request completes.

Fix is to test for the existence of a previous range before trying to
concatenate the current range with the previous one.

While in the area, rename pci_nvme_append_iov_req()'s lba parameter to
offset to match its usage.

PR:             264177
Reported by:    Robert Morris <rtm@lcs.mit.edu>
Reviewed by: jhb
MFC after:      2 weeks
Differential Revision: https://reviews.freebsd.org/D35328

22 months agoFix wrong capitalization in man page references.
Jens Schweikhardt [Sat, 13 Aug 2022 18:46:59 +0000 (20:46 +0200)]
Fix wrong capitalization in man page references.

22 months agomrsas module: Use MACHINE_ARCH exlcusively
Warner Losh [Sat, 13 Aug 2022 17:53:22 +0000 (11:53 -0600)]
mrsas module: Use MACHINE_ARCH exlcusively

TARGET_ARCH is always wrong when not used at the toplevel Makefile*, or
in something that has to be included from there. Switch to using
MACHINE_ARCH exclusively here since there's no benefit from assigning
TARGET_ARCH the value of MACHINE_ARCH and then using TARGET_ARCH (and
make TARGET_ARCH=xxx won't work).

Sponsored by: Netflix

22 months agoFix a broken man page reference.
Jens Schweikhardt [Sat, 13 Aug 2022 15:40:29 +0000 (17:40 +0200)]
Fix a broken man page reference.

22 months agostand: Only compile decompression routines
Warner Losh [Sat, 13 Aug 2022 03:30:24 +0000 (21:30 -0600)]
stand: Only compile decompression routines

We don't need the compress rotuines, nor zstd_opt.c. Remove them.
Expand the number of places we omit code for IN_LIBSA (which are FreeBSD
specific). Due to the agressive optimization, though, this doesn't
reduce the size of the loader. It does reduce the number of 'false
positives' for places to omit to reduce the size as well as reducing the
build time slightly.

Sponsored by: Netflix
Reviewed by: tsoome, delphij
Differential Revision: https://reviews.freebsd.org/D36145

22 months agostand: Compile out the extensive superblock diagnostic messages for BIOS loader
Warner Losh [Fri, 12 Aug 2022 17:08:36 +0000 (11:08 -0600)]
stand: Compile out the extensive superblock diagnostic messages for BIOS loader

The BIOS loader operates in a very constrained environment. The messages
for the super block integrity tests take up about 12k of space. Compile
them out for the BIOS loader, while leaving it intact for all other
loaders that aren't space constrained. These aren't used in the 'super
tiny' *boot* programs, so no adjustment is needed there.

We reply on the fact that (a) i386 doesn't support 32-bit UEFI booting
and (b) LIBSA_CPUARCH is "i386" when building on both i386 and when
we're building the 32-bit libsa32 library.

This saves about 12k of space for this constrained envrionment and will
take a bit of the pressure off some machines where the loader has grown
too big for their BIOS (see comments in i386/loader/Makefile for
details).

Sponsored by: Netflix
Reviewed by: mckusick
Differential Revision: https://reviews.freebsd.org/D36175

22 months agostand: Raise limit to 550,000 bytes for loader
Warner Losh [Fri, 12 Aug 2022 04:59:51 +0000 (22:59 -0600)]
stand: Raise limit to 550,000 bytes for loader

Raise the limit for /boot/loader to be 550k. The IBM PC imposes a limit
of 640k of RAM below 1MB, which is needed for real mode calls. BTX takes
40k of that. The BIOS takes some amount (25k seems a good "99% take less
than or equal to this" estimate for that, though some systems consume
more). Most typical setups need 25k of stack.  This leaves 550k for
code. We set the limit to 550,000 which gives about an extra 13,000
bytes of buffer for machines that whose setups use a little more stack
or whose BIOS reserves a bit more...

Add this derivation in the Makefile. Also recommend setting LOADERSIZE
lower in /etc/src.conf when the loader has to run on a system whose BIOS
takes up more space, or for a complex setup. Add a recipe for how to
find how much RAM your BIOS uses as well (thanks to jhb@ for the
trick). Network cards that boot via PXE and HBAs with their BIOS enabled
are known to be large consumers of lomem space.

Sponsored by: Netflix
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D36152

22 months agosys/vm: Add TSLOG to some functions
Colin Percival [Fri, 12 Aug 2022 23:52:47 +0000 (16:52 -0700)]
sys/vm: Add TSLOG to some functions

The functions pbuf_init, kva_alloc, and keg_alloc_slab are significant
contributors to the kernel boot time when FreeBSD boots inside the
Firecracker VMM.  Instrument them so they show up on flamecharts.

22 months agokeysock: explicitly initialized LIST_HEAD
Gleb Smirnoff [Fri, 12 Aug 2022 19:29:26 +0000 (12:29 -0700)]
keysock: explicitly initialized LIST_HEAD

This is supposed to fix syzcaller report.

Reported by: syzbot+1e08b5f9f7f00383ddea@syzkaller.appspotmail.com
Fixes: ea7be1293b48385f27b97c5f112e4cad93cbd33b

22 months agoprotosw: change prototype for pr_control
Gleb Smirnoff [Fri, 12 Aug 2022 19:08:18 +0000 (12:08 -0700)]
protosw: change prototype for pr_control

For some reason protosw.h is used during world complation and userland
is not aware of caddr_t, a relic from the first version of C.  Broken
buildworld is good reason to get rid of yet another caddr_t in kernel.

Fixes: 886fc1e80490fb03e72e306774766cbb2c733ac6

22 months agomac_ddb: Fix the show rman validator.
John Baldwin [Fri, 12 Aug 2022 17:20:05 +0000 (10:20 -0700)]
mac_ddb: Fix the show rman validator.

The validator always returned true due to an incorrect check.

Reviewed by: mhorne, imp
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D36125

22 months agoWhen -u option is used also set USER, HOME and SHELL variables.
Maxim Sobolev [Thu, 11 Aug 2022 01:44:20 +0000 (18:44 -0700)]
When -u option is used also set USER, HOME and SHELL variables.
This is consistent with what other uid-morphing utilities
do, i.e. jexec(1), su(1) etc.

MFC after:      2 weeks
Reviewed by:    gbe
Differential Revision:  https://reviews.freebsd.org/D36148

22 months agonetinet: do not broadcast PRC_REDIRECT_HOST on ICMP redirect
Gleb Smirnoff [Fri, 12 Aug 2022 15:31:28 +0000 (08:31 -0700)]
netinet: do not broadcast PRC_REDIRECT_HOST on ICMP redirect

This is expensive and useless call.  It has been useless since Alexander
melifaro@ moved the forwarding table to nexthops with passive invalidation.
What happens now is that cached route in a inpcb would get invalidated
on next ip_output().

These were the last users of pfctlinput(), so garbage collect it.

Reviewed by: melifaro
Differential revision: https://reviews.freebsd.org/D36156

22 months agoprotosw: provide prototypes for all protocol switch methods
Gleb Smirnoff [Fri, 12 Aug 2022 15:30:34 +0000 (08:30 -0700)]
protosw: provide prototypes for all protocol switch methods

Reviewed by: melifaro
Differential revision: https://reviews.freebsd.org/D36153

22 months agonetinet6: simplify defrouter_select_fib()
Alexander V. Chernikov [Fri, 12 Aug 2022 11:43:14 +0000 (11:43 +0000)]
netinet6: simplify defrouter_select_fib()

* factor out underlying llentry check into a separate function and use it consistently
* enter epoch once instead of per-router enter/exit
* don't execute body with fibnum = `RT_ALL_FIBS`

Differential Revision: https://reviews.freebsd.org/D35523
MFC after: 2 weeks

22 months agorouting: add rib_match_gw() helper
Alexander V. Chernikov [Fri, 12 Aug 2022 09:31:21 +0000 (09:31 +0000)]
routing: add rib_match_gw() helper

Finish 02e05b8faec1:
* add gateway matcher function that can be used in rib_del_route_px()
 or any rib_walk-family functions. It will be used in the upcoming
 migration to the new KPI
* rename gw_fulter_func to match_gw_one() to better signal the
 function purpose / semantic.

MFC after: 1 month

22 months agoDocument implicit dependencies of the mlx5(4) & friends.
Maxim Sobolev [Thu, 11 Aug 2022 23:28:27 +0000 (16:28 -0700)]
Document implicit dependencies of the mlx5(4) & friends.

MFC after:      2 weeks

22 months agostand: Go back to a.out format for /boot/loader
Warner Losh [Thu, 11 Aug 2022 23:29:10 +0000 (17:29 -0600)]
stand: Go back to a.out format for /boot/loader

Turns out there's two hidden a.out dependencies. pxeldr.S assumes it has
access to the a.out header from /boot/loader and cdboot.S assumes that
/boot/loader is also a.out and doesn't use boot2.

So, go back to making a.out files for these and adjust the size checks
to use ls, but we only need to check loader.bin. Trim the size we check
against by 2,000. The difference in size between loader and loader.bin
is about 3000 bytes, but clang15 produces binaries that are a smidge
bigger so we need to relax the check just a little and accept some
additional risk for the moment.

Add some comments to loader's Makefile about this.

Sponsored by: Netflix
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D36142

22 months agoInstall working pkgconfig .pc files for compat libraries
Alex Richardson [Thu, 11 Aug 2022 22:17:52 +0000 (23:17 +0100)]
Install working pkgconfig .pc files for compat libraries

The default ones are install them to /usr/libdata/pkgconfig, and we can't
use this path for compat libraries, so we use /usr/lib<suffix>/pkgconfigi here.

Test Plan: grep -rn libdir= ./usr/lib32/pkgconfig/*.pc
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D34939

22 months agomac: s/0/false/ in macros denoting probe enablement
Mateusz Guzik [Thu, 11 Aug 2022 22:11:24 +0000 (22:11 +0000)]
mac: s/0/false/ in macros denoting probe enablement

No functional changes.

22 months agorouting: unbreak the build of a bunch of kernels
Mateusz Guzik [Thu, 11 Aug 2022 21:50:37 +0000 (21:50 +0000)]
routing: unbreak the build of a bunch of kernels

Sponsored by: Rubicon Communications, LLC ("Netgate")

22 months agox86: remove MP_WATCHDOG
Mateusz Guzik [Tue, 9 Aug 2022 20:34:46 +0000 (22:34 +0200)]
x86: remove MP_WATCHDOG

It does not work with ULE, which is the default scheduler for over a
decade.

Reviewed by: emaste, kib
Differential Revision: https://reviews.freebsd.org/D36094

22 months agoctladm: Fix typo in command line help.
Alexander Motin [Thu, 11 Aug 2022 20:53:50 +0000 (16:53 -0400)]
ctladm: Fix typo in command line help.

MFC after: 1 week

22 months agortsock: subscribe to ifnet eventhandlers instead of direct calls.
Alexander V. Chernikov [Thu, 11 Aug 2022 20:09:45 +0000 (20:09 +0000)]
rtsock: subscribe to ifnet eventhandlers instead of direct calls.

Stop treating rtsock as a "special" consumer and use already-provided
 ifaddr arrival/departure notifications.

MFC after: 2 weeks

Test Plan:
```
21:05 [0] m@devel0 route -n monitor

-> ifconfig vtnet0.2 create

got message of size 24 on Tue Aug  9 21:05:44 2022
RTM_IFANNOUNCE: interface arrival/departure: len 24, if# 3, what: arrival

got message of size 168 on Tue Aug  9 21:05:54 2022
RTM_IFINFO: iface status change: len 168, if# 3, link: up, flags:<BROADCAST,RUNNING,SIMPLEX,MULTICAST>

-> ifconfig vtnet0.2 destroy

got message of size 24 on Tue Aug  9 21:05:54 2022
RTM_IFANNOUNCE: interface arrival/departure: len 24, if# 3, what: departure

```

Reviewed By: glebius
Differential Revision: https://reviews.freebsd.org/D36095
MFC after: 2 weeks

22 months agoiconv_std: complete the //IGNORE support
Kyle Evans [Tue, 22 Feb 2022 07:15:04 +0000 (01:15 -0600)]
iconv_std: complete the //IGNORE support

Previously, it would only ignore failures due to csmapper conversion
failure.  It may be the case that the input string contains invalid
sequences that also need to be ignored.

A good example of //IGNORE application is sanitizing user- or remotely-
specified strings that are expected to be UTF-8; perhaps as part of a
pipeline that will feed the result into a system less tested against or
tolerant of illegal UTF-8 sequences.

Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D34345

22 months agolibc: iconv: add mb_cur_min for encoder traits
Kyle Evans [Tue, 22 Feb 2022 07:12:27 +0000 (01:12 -0600)]
libc: iconv: add mb_cur_min for encoder traits

A future commit will actually implement //IGNORE so that applications
using base iconv can, e.g., sanitize UTF-8 strings.  To do this, the
iconv_std module needs to be able to determine the minimum width for any
given encoding so that it can skip that many bytes in the input buffer.
This is mainly an issue for UTF-16 and UTF-32.

This commit bumps shlib versions to 5 for libiconv modules to reflect
the ABI change.  It also fixes OptionalObsoleteFiles to remove the
libiconv modules if WITHOUT_ICONV is in use.

re: _ENCODING_MB_CUR_MIN, note that this file (citrus_stdenc_template.h)
is included at the bottom of an encoding *implementation*, so the
implementation is free to #define it prior.  UTF1632 is a good example,
as it redefines the minimum to be a property on the encodinginfo, and
the minimum is set to 2 or 4 bytes for UTF-16 and UTF-32 respectively.

Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D34344

22 months agolibc: iconv: push option ignore into citrus_iconv_open()
Kyle Evans [Tue, 22 Feb 2022 07:10:05 +0000 (01:10 -0600)]
libc: iconv: push option ignore into citrus_iconv_open()

Make it vaguely aware of options in the sense that it now knows that it
can zap any trailing //.  It now copies the entire string in realsrc and
realdst, then terminates them at the options.

__bsd___iconv_open can now stop trying to allocate memory just for this
purpose, and the new version is technically more correct.  GNU libiconv
will ignore options on the `in` codeset and still do the right thing.

Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D34343

22 months agoiconv: only conditionally use ICONV_SET_DISCARD_ILSEQ
Kyle Evans [Tue, 22 Feb 2022 05:05:28 +0000 (23:05 -0600)]
iconv: only conditionally use ICONV_SET_DISCARD_ILSEQ

If the -c flag is used, then we can set it with ICONV_SET_DISCARD_ILSEQ;
otherwise, leave it alone.  The user may have specified //IGNORE in the
'to' codeset specification, there's no reason we can't allow that but
we'll currently turn it off.

Reviewed by: thj
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D34342

22 months agotools: test: iconv: fix open_2 to not segfault
Kyle Evans [Tue, 11 Jan 2022 23:41:10 +0000 (17:41 -0600)]
tools: test: iconv: fix open_2 to not segfault

Record error condition when iconv_open() fails rather than leaving a
bogus iconv_t that iconv_close() can later choke on; this is one failure
mode.

If we opened MAX_LIMIT files with success, we need to rewind one so that
we don't iconv_close() one past the end of cd; this is the second
failure mode.

Sponsored by: Klara, Inc.

22 months agostand: Make BIOS loader size limits settable
Warner Losh [Thu, 11 Aug 2022 16:24:58 +0000 (10:24 -0600)]
stand: Make BIOS loader size limits settable

It's sometimes desirable to override the size limit: It's a soft limit
and there are times we exceed the limit by just a little bit and don't
want the build to fail (or we are hitting runtime failures below the
510,000 byte limit).

Sponsored by: Netflix

22 months agostand: i386_fmtdev can be reduced to devformat
Warner Losh [Thu, 11 Aug 2022 15:09:03 +0000 (09:09 -0600)]
stand: i386_fmtdev can be reduced to devformat

devformat produces the same output as i386_fmtdev, so just use it to
reduce on the dependencies.

Sponsored by: Netflix
Reviewed by: tsoome
Differential Revision: https://reviews.freebsd.org/D35927

22 months agostand: uboot_fmtdev can be reduced to devformat
Warner Losh [Thu, 11 Aug 2022 15:08:52 +0000 (09:08 -0600)]
stand: uboot_fmtdev can be reduced to devformat

devformat produces the same output as uboot_fmtdev, so just use it to
reduce on the dependencies.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D35926

22 months agostand: userboot_fmtdev can be reduced to devformat
Warner Losh [Thu, 11 Aug 2022 15:08:26 +0000 (09:08 -0600)]
stand: userboot_fmtdev can be reduced to devformat

devformat produces the same output as userboot_fmtdev, so just use it to
reduce on the dependencies. In addition, we don't need to use the
incomplete struct userboot_devdesc type, we can use struct devdesc
instead (in fact, there's no userboot_devdesc defined anywhere).

Sponsored by: Netflix
Reviewed by: jhb (prior version)
Differential Revision: https://reviews.freebsd.org/D35925

22 months agostand: efi_fmtdev can be reduced to devformat
Warner Losh [Thu, 11 Aug 2022 15:08:08 +0000 (09:08 -0600)]
stand: efi_fmtdev can be reduced to devformat

devformat produces the same output as efi_fmtdev, so just use it to
reduce on the dependencies.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D35924

22 months agostand: Replace zfs_fmtdev with generic devformat()
Warner Losh [Thu, 11 Aug 2022 15:07:44 +0000 (09:07 -0600)]
stand: Replace zfs_fmtdev with generic devformat()

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D35973

22 months agostand: For zfs, set dv_fmtdev to zfs_fmtdev
Warner Losh [Thu, 11 Aug 2022 15:07:26 +0000 (09:07 -0600)]
stand: For zfs, set dv_fmtdev to zfs_fmtdev

Add a generic way to get the string representation of a zfs device / mount.

Sponsored by: Netflix
Reviewed by: tsoome (prior version)
Differential Revision: https://reviews.freebsd.org/D35923

22 months agostand: Use devformat instead of disk_devfmt
Warner Losh [Thu, 11 Aug 2022 15:07:13 +0000 (09:07 -0600)]
stand: Use devformat instead of disk_devfmt

Use devformat instead of disk_devfmt. This allows us to avoid knowing
the details of the device that's underneath us. Remove disk.h include
and the -I${LDRSRC} from the build of ufs.c since they are no longer
needed.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D35922

22 months agostand: Use devformat rather than disk_devfmt
Warner Losh [Thu, 11 Aug 2022 15:06:53 +0000 (09:06 -0600)]
stand: Use devformat rather than disk_devfmt

Fix layering violation and use devformat to get the string
representation of the device to see if we're mounted yet or not. Remove
added include to pickup disk.h.

Sponsored by: Netflix
Reviewed by: tsoome (prior version)
Differential Revision: https://reviews.freebsd.org/D35919

22 months agostand: Add disk_fmtdev for dv_fmtdev for all the disk devices
Warner Losh [Thu, 11 Aug 2022 15:06:28 +0000 (09:06 -0600)]
stand: Add disk_fmtdev for dv_fmtdev for all the disk devices

All of the archsw fmtdev functions treat DEVT_DISK as a call to
disk_fmtdev. Set all disks' dv_fmtdev to disk_fmtdev so devformat
will return the same thing.

Sponsored by: Netflix
Reviewed by: tsoome (prior version)
Differential Revision: https://reviews.freebsd.org/D35917

22 months agostand: Add devformat to return formatted string for a device
Warner Losh [Thu, 11 Aug 2022 15:06:09 +0000 (09:06 -0600)]
stand: Add devformat to return formatted string for a device

Use dv_fmtdev to return a formatted string for a device. If this is a
null pointer, return the device name and unit followed by a colon (eg
disk3:).

Sponsored by: Netflix
Reviewed by: tsoome (prior version)
Differential Revision: https://reviews.freebsd.org/D35916

22 months agostand: Add dv_devfmt to return a string represenation of the device
Warner Losh [Thu, 11 Aug 2022 15:05:34 +0000 (09:05 -0600)]
stand: Add dv_devfmt to return a string represenation of the device

Add a new pointer, dv_devfmt, to allow devices to format themselves. We
will use this to simplify many of the fmtdev functions in the tree as
they are all almost the same, or all are isomorphic to each other.

Sponsored by: Netflix
Reviewed by: tsoome (prior version)
Differential Revision: https://reviews.freebsd.org/D35915

22 months agostand: Change zfs_fmtdev to take a struct devdesc *
Warner Losh [Thu, 11 Aug 2022 15:05:15 +0000 (09:05 -0600)]
stand: Change zfs_fmtdev to take a struct devdesc *

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D35974

22 months agostand: Change disk_fmtdev to take a struct devdesc *
Warner Losh [Thu, 11 Aug 2022 15:04:50 +0000 (09:04 -0600)]
stand: Change disk_fmtdev to take a struct devdesc *

We do a number of games with ploymorphism for different types struct
*devdesc. Adjust one place that this affects to take the address of the
base class (most others have void * at the moment). This is more type
safe than a bare void *.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D35914

22 months agostand: Move i386_devdesc to a union
Warner Losh [Thu, 11 Aug 2022 15:04:08 +0000 (09:04 -0600)]
stand: Move i386_devdesc to a union

Rather than have the magic, hand-crafted fields that have to align with
fields in other structures at the end of i386_devdesc, make it into
anonymous union and adjust the code accordingly. This is safer and
similar to what CAM does.

Sponsored by: Netflix
Reviewed by: kevans, tsoome (prior version)
Differential Revision: https://reviews.freebsd.org/D35965

22 months agostand: Remove unnecessary include
Warner Losh [Thu, 11 Aug 2022 14:59:48 +0000 (08:59 -0600)]
stand: Remove unnecessary include

stdbool.h is implied by stand.h, so remove it.

Sponsored by: Netflix

22 months agoraw ip6: merge rip6_output() into rip6_send()
Gleb Smirnoff [Thu, 11 Aug 2022 16:19:37 +0000 (09:19 -0700)]
raw ip6: merge rip6_output() into rip6_send()

While here remove some code that was compat legacy back in 2005, added
in a1f7e5f8ee7fe.

Reviewed by: melifaro
Differential revision: https://reviews.freebsd.org/D36128

22 months agoraw ip: merge rip_output() into rip_send()
Gleb Smirnoff [Thu, 11 Aug 2022 16:19:37 +0000 (09:19 -0700)]
raw ip: merge rip_output() into rip_send()

While here, address the unlocked 'dst' read.  Solve that by storing
a pointer either to the inpcb or to the sockaddr.  If we end up
copying address out of the inpcb, that would be done under the read
lock section.

Reviewed by: melifaro
Differential revision: https://reviews.freebsd.org/D36127

22 months agoprotosw: retire pr_output method
Gleb Smirnoff [Thu, 11 Aug 2022 16:19:37 +0000 (09:19 -0700)]
protosw: retire pr_output method

The only place to execute this method was raw_usend(). Only those
protocols that used raw socket were able to actually enter that method.
All pr_output assignments being deleted by this commit were a dead code
for many years.

Reviewed by: melifaro
Differential revision: https://reviews.freebsd.org/D36126

22 months agoRetire 4.4BSD raw sockets
Gleb Smirnoff [Thu, 11 Aug 2022 16:19:36 +0000 (09:19 -0700)]
Retire 4.4BSD raw sockets

Until today the remnants of the original code had provided some aid
in implementation of routing socket and IPSEC key socket.  There were
more obfuscation rather than generalisation with this aid.

A historical reference on the original idea of the raw sockets can
be found in chapter 11 of 4.4BSD System Manager Manual:

https://raw.githubusercontent.com/sergev/4.4BSD-Lite2/master/usr/share/doc/smm/18.net.pdf

Reviewed by: melifaro
Differential revision: https://reviews.freebsd.org/D36124

22 months agokeysock: do not use raw socket code
Gleb Smirnoff [Thu, 11 Aug 2022 16:19:36 +0000 (09:19 -0700)]
keysock: do not use raw socket code

This makes key socket implementation self contained and removes one
of the last dependencies on the raw socket code and pr_output method.

There are very subtle API visible changes:
- now key socket would return EOPNOTSUPP instead of EINVAL on
  syscalls that are not supposed to be called on a key socket.
- key socket buffer sizes are now controlled by net.key sysctls instead
  of net.raw.  The latter were not documented anywhere, and even Internet
  search doesn't find any references or discussions related to them.

Reviewed by: melifaro
Differential revision: https://reviews.freebsd.org/D36123

22 months agortsock: do not use raw socket code
Gleb Smirnoff [Thu, 11 Aug 2022 16:19:36 +0000 (09:19 -0700)]
rtsock: do not use raw socket code

This makes routing socket implementation self contained and removes one
of the last dependencies on the raw socket code and pr_output method.

There are very subtle API visible changes:
- now routing socket would return EOPNOTSUPP instead of EINVAL on
  syscalls that are not supposed to be called on a routing socket.
- routing socket buffer sizes are now controlled by net.rtsock
  sysctls instead of net.raw.  The latter were not documented
  anywhere, and even Internet search doesn't find any references
  or discussions related to these sysctls.

Reviewed by: melifaro
Differential revision: https://reviews.freebsd.org/D36122

22 months agortsock: do not allocate mbufs_tags(9) just to store a 8-bit value
Gleb Smirnoff [Thu, 11 Aug 2022 16:19:36 +0000 (09:19 -0700)]
rtsock: do not allocate mbufs_tags(9) just to store a 8-bit value

Use local storage of the mbuf packet header instead.

Reviewed by: melifaro
Differential revision: https://reviews.freebsd.org/D36121

22 months agonetinet: get interface event notifications directly via EVENTHANDLER(9)
Gleb Smirnoff [Thu, 11 Aug 2022 16:19:36 +0000 (09:19 -0700)]
netinet: get interface event notifications directly via EVENTHANDLER(9)

The old mechanism of getting them via domains/protocols control input
is a relict from the previous century, when nothing like EVENTHANDLER(9)
existed yet.  Retire PRC_IFDOWN/PRC_IFUP as netinet was the only one
to use them.

Reviewed by: melifaro
Differential revision: https://reviews.freebsd.org/D36116

22 months agomakefs: Fix a memory leak in fs_layout_one()
Mark Johnston [Thu, 11 Aug 2022 14:18:13 +0000 (10:18 -0400)]
makefs: Fix a memory leak in fs_layout_one()

Check the canmount property before building the mountpoint string.

Reported by: Coverity
Fixes: 240afd8c1fcc ("makefs: Add ZFS support")
Sponsored by: The FreeBSD Foundation

22 months agomakefs: Fix memory leaks in dsl_dir_finalize_props()
Mark Johnston [Thu, 11 Aug 2022 14:18:06 +0000 (10:18 -0400)]
makefs: Fix memory leaks in dsl_dir_finalize_props()

nvstring_get() returns a copy of the string, not a pointer into the
nvlist's internal buffer.

Reported by: Coverity
Fixes: 240afd8c1fcc ("makefs: Add ZFS support")
Sponsored by: The FreeBSD Foundation

22 months agorouting: fix non-debug build
Mateusz Guzik [Thu, 11 Aug 2022 14:12:59 +0000 (14:12 +0000)]
routing: fix non-debug build

Sponsored by: Rubicon Communications, LLC ("Netgate")

22 months agoAdjust function definition in subr_devmap.c to avoid clang 15 warning
Andrew Turner [Thu, 11 Aug 2022 12:04:58 +0000 (13:04 +0100)]
Adjust function definition in subr_devmap.c to avoid clang 15 warning

With clang 15, the following -Werror warning is produced:

    sys/kern/subr_devmap.c:87:19: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    devmap_print_table()
                      ^
                       void

This is because devmap_print_table() and devmap_lastaddr() are declared
with a (void) argument list, but defined with an empty argument list.
Make the definition match the declaration.

Sponsored by: The FreeBSD Foundation

22 months agoAdjust function definition in ofw to avoid clang 15 warning
Andrew Turner [Thu, 11 Aug 2022 12:02:50 +0000 (13:02 +0100)]
Adjust function definition in ofw to avoid clang 15 warning

With clang 15, the following -Werror warning is produced:

    sys/dev/ofw/openfirm.c:826:9: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    OF_enter()
            ^
             void

This is because OF_enter() and OF_exit are declared with a (void)
argument list, but defined with an empty argument list. Make the
definition match the declaration.

Sponsored by: The FreeBSD Foundation

22 months agoAdjust function definition in hwpmc to avoid clang 15 warning
Andrew Turner [Thu, 11 Aug 2022 12:02:33 +0000 (13:02 +0100)]
Adjust function definition in hwpmc to avoid clang 15 warning

With clang 15, the following -Werror warning is produced:

    sys/dev/hwpmc/hwpmc_arm64.c:530:21: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    pmc_arm64_initialize()
                        ^
                         void

This is because many of the functions are declared with a (void)
argument list, but defined with an empty argument list. Make the
definition match the declaration.

Sponsored by: The FreeBSD Foundation

22 months agorouting: populate fibs with interface routes after growing net.fibs.
Alexander V. Chernikov [Sun, 7 Aug 2022 20:26:19 +0000 (20:26 +0000)]
routing: populate fibs with interface routes after growing net.fibs.

Currently it is possible to extend number of fibs in runtime, but this
 functionality is of limited use when net.add_addrs_all_fibs is
 non-zero, as the routing tables are created empty.

This change automatically populate newly-created fibs with the kernel-originated
 interface routes (filtered by RTF_PINNED flag) if net.add_addrs_all_fibs
 is set.

```
-> sysctl net.add_addr_allfibs=1
net.add_addr_allfibs: 0 -> 1
-> sysctl net.fibs
net.fibs: 2
-> sysctl net.fibs=3
net.fibs: 2 -> 3

BEFORE:
-> setfib 2 netstat -rn
Routing tables (fib: 2)

AFTER:
-> setfib 2 netstat -rn
Routing tables (fib: 2)

Internet:
Destination        Gateway            Flags     Netif Expire
10.0.0.0/24        link#1             U        vtnet0
10.0.0.5           link#1             UHS         lo0
127.0.0.1          link#2             UH          lo0

Internet6:
Destination                       Gateway                       Flags     Netif Expire
::1                               link#2                        UHS         lo0
2a01:4f9:3a:fa00::/64             link#1                        U        vtnet0
2a01:4f9:3a:fa00:5054:ff:fe15:4a3b link#1                       UHS         lo0
fe80::%vtnet0/64                  link#1                        U        vtnet0
fe80::5054:ff:fe15:4a3b%vtnet0    link#1                        UHS         lo0
fe80::%lo0/64                     link#2                        U           lo0
fe80::1%lo0                       link#2                        UHS         lo0
```

Differential Revision: https://reviews.freebsd.org/D36075
MFC after: 1 month

22 months agorouting: fixup empty mask prefix handling after 2ce553854cbd.
Alexander V. Chernikov [Thu, 11 Aug 2022 11:41:42 +0000 (11:41 +0000)]
routing: fixup empty mask prefix handling after 2ce553854cbd.

MFC after: 1 month

22 months agorouting: fix build warning without ROUTE_MPATH
Alexander V. Chernikov [Thu, 11 Aug 2022 09:46:28 +0000 (09:46 +0000)]
routing: fix build warning without ROUTE_MPATH

Reported by: Gary Jennejohn <garyj@gmx.de>
MFC after: 1 month

22 months agoif_ovpn tests: Test using a TCP socket for DCO
Kristof Provost [Thu, 11 Aug 2022 08:34:01 +0000 (10:34 +0200)]
if_ovpn tests: Test using a TCP socket for DCO

This used to trigger panics, so try to reproduce it.
Create an if_ovpn interface, set a new peer on it with a TCP fd (as
opposed to the expected UDP) and ensure that this is rejected.

Sponsored by: Rubicon Communications, LLC ("Netgate")

22 months agoif_ovpn: reject non-UDP sockets
Kristof Provost [Thu, 11 Aug 2022 08:30:39 +0000 (10:30 +0200)]
if_ovpn: reject non-UDP sockets

We must ensure that the fd provided by userspace is really for a UDP
socket. If it's not we'll panic in udp_set_kernel_tunneling().

Reported by: Gert Doering <gert@greenie.muc.de>
Sponsored by: Rubicon Communications, LLC ("Netgate")

22 months agoAdd RockChip RK356X support to existing RockChip thermal driver.
Søren Schmidt [Thu, 11 Aug 2022 08:26:39 +0000 (08:26 +0000)]
Add RockChip RK356X support to existing RockChip thermal driver.

22 months agostress2: Added a regression test
Peter Holm [Thu, 11 Aug 2022 07:42:02 +0000 (09:42 +0200)]
stress2: Added a regression test

22 months agoAdd support for RK3568 to RockChip GRF and SPI drivers.
Ganbold Tsagaankhuu [Thu, 11 Aug 2022 05:32:48 +0000 (05:32 +0000)]
Add support for RK3568 to RockChip GRF and SPI drivers.
Partially from https://reviews.freebsd.org/D36027

Submitted by: sos

22 months agostand: impose 510,000 byte limit for /boot/loader and /boot/pxeldr
Warner Losh [Thu, 11 Aug 2022 03:19:01 +0000 (21:19 -0600)]
stand: impose 510,000 byte limit for /boot/loader and /boot/pxeldr

The BIOS method of booting imposes an absolute limit of 640k for the
size of the program being run due to btx. In practice, this means that
programs larger than about 500kiB will fail in odd ways as the stack /
heap will overflow.

Pick 510,000 as the cutoff line semi-arbitrarily. loader_lua is now
almost too big and we want to break the build when it crosses this
threshold. In my experience, below 500,000 always works, above 520,000
always seems to fail with things getting bad somewhere between 512,000
to 515,000. 510,000 is as close to the line as I think we can go, though
experience may dictate we need to lower this in the future.

This is at-best a stop-breakage until we have a better way to subset the
boot loader for BIOS booting to allow better, more fined-tuned
/boot/loaders for the many different environments they have to run
in. This likely means we'll have a graphical loader than understands a
few filesystmes for installation, and a non-graphical loader that
understands the most filesystems possible for everything else in the
future. Our build infrastructure needs some work before we can do that,
however.

At this late date, it likely isn't worth the efforts to move parts of
the loader into high memory. There's a number of assumptions about where
the stack is, where buffers reside, etc that are fulfilled when it lives
in the first 640k that would need bounce buffers and/or other counter
measures if we were to split it up. All BIOS calls are done in 16-bit
mode with SEG:OFF addresses, requiring them to be in the first 640k of
RAM. And nearly all machines in the last decade can boot with UEFI
(though there's some exceptions, so it isn't worth killing outright
yet).

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D36129

22 months agostand: i386/amd64: Always use elf format for /boot/loader and pxeldr
Warner Losh [Thu, 11 Aug 2022 03:18:32 +0000 (21:18 -0600)]
stand: i386/amd64: Always use elf format for /boot/loader and pxeldr

The first level boot blocks have understood how to load ELF code since
1999. Switch /boot/loader and /boot/pxeldr over to being ELF format so
that in-tree tools can examine them more closely. In addition, one
could, in theory, now have a 'lo-mem' and a 'hi-mem' segment (though a
lot of work would need to be done with bounce buffers, btx, code segment
marking, etc for an arrangement like that to work).

As far as I can tell, this is the last a.out binary in the tree. There
are several raw binaries left, but everything else is ELF.

Reviewed by: emaste, kevans
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D36130

22 months agocontrib/tzdata: import tzdata 2022b
Philip Paeps [Thu, 11 Aug 2022 02:48:24 +0000 (10:48 +0800)]
contrib/tzdata: import tzdata 2022b

Changes: https://github.com/eggert/tz/blob/2022b/NEWS

MFC after: 3 days

22 months agoImport tzdata 2022b
Philip Paeps [Thu, 11 Aug 2022 02:23:48 +0000 (10:23 +0800)]
Import tzdata 2022b

22 months agoacpi: mark INVARIANTS variables as __diagused
Ed Maste [Wed, 10 Aug 2022 00:39:28 +0000 (20:39 -0400)]
acpi: mark INVARIANTS variables as __diagused

Fixes INVARIANTS build with Clang 15, which previously failed due to
set-but-not-used variable warnings.

Reviewed by: jhb
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36096

22 months agorouting: fix build without ROUTE_MPATH
Alexander V. Chernikov [Wed, 10 Aug 2022 20:44:43 +0000 (20:44 +0000)]
routing: fix build without ROUTE_MPATH

MFC after: 1 month

22 months agosdio: Add CCCR speed defines
Emmanuel Vadot [Wed, 14 Jul 2021 15:25:36 +0000 (17:25 +0200)]
sdio: Add CCCR speed defines

Those are the defines needed to change speed on a SDIO card.

22 months agosdio: Do not allow setting a block size if function doesn't support it
Emmanuel Vadot [Wed, 26 May 2021 11:15:58 +0000 (13:15 +0200)]
sdio: Do not allow setting a block size if function doesn't support it

22 months agosdio: Always use increment address for read/write_4
Emmanuel Vadot [Fri, 21 May 2021 11:33:34 +0000 (13:33 +0200)]
sdio: Always use increment address for read/write_4

SDIO CMD53 (RW Extented) can either write to the same address (useful for FIFO)
or auto increment the destination address (to write to multiple registers).
It is more logical to have read/write_4 to use incremental mode and make other
helper function for writing to a FIFO destination especially since most FIFO
write/read will be 8bits based and not 32bits based.

22 months agosdio: Change the sdio helper name and arg order
Emmanuel Vadot [Fri, 21 May 2021 09:56:39 +0000 (11:56 +0200)]
sdio: Change the sdio helper name and arg order

Do not use b/l but _1/_4 also address comes first and then data.
This makes them closer to something like bus_space_{read,write}
We have no users in the tree.

22 months agoopencrypto: mark INVARIANTS variables as __diagused
Ed Maste [Tue, 9 Aug 2022 23:23:19 +0000 (19:23 -0400)]
opencrypto: mark INVARIANTS variables as __diagused

Fixes INVARIANTS build with Clang 15, which previously failed due to
set-but-not-used variable warnings.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

22 months agodevd: move all devd notification logic to a separate file.
Alexander V. Chernikov [Tue, 9 Aug 2022 15:55:23 +0000 (15:55 +0000)]
devd: move all devd notification logic to a separate file.

Currently, subr_bus.c shares logic for (a) maintaining all HW devices
 (e.g. discovery/attach/detach logic) and (b) generic devctl notification
 layer for devices/PMU/GEOM/interfaces/etc).
These two subsystems share really tiny interaction interface, composed of 3
 notification functions. With that in mind, move devctl layer to a
 separate file, establishing a clear notification interface between the
 sub.c bus layer and the provider (devctl).

The primary driver of this change is netlink implementation (D36002).
The idea is to propagate device-level events to netlink as well, so all
 netlink customers can subscribe to these changes.
The long-term goal is to deprecate devctl and to use netlink as the
 kernel<> userland transport provided netlink gets enough traction.

Reviewed by: imp, markj
Differential Revision: https://reviews.freebsd.org/D36091
MFC after: 1 month

22 months agorouting: move rtentry and subscription code out of route_ctl.c
Alexander V. Chernikov [Mon, 8 Aug 2022 13:54:17 +0000 (13:54 +0000)]
routing: move rtentry and subscription code out of route_ctl.c

route_ctl.c size has grown considerably since initial introduction.
Factor out non-relevant parts:
* all rtentry logic, such as creation/destruction and accessors
 goes to net/route/route_rtentry.c
* all rtable subscription logic goes to net/route/route_subscription.c

Differential Revision: https://reviews.freebsd.org/D36074
MFC after: 1 month

22 months agorouting: add rib_<add|del>_route_px() functions operating with nexthops.
Alexander V. Chernikov [Thu, 4 Aug 2022 14:55:30 +0000 (14:55 +0000)]
routing: add rib_<add|del>_route_px() functions operating with nexthops.

This change adds public KPI to work with routes using pre-created
 nexthops, instead of using data from addrinfo structures. These
 functions will be later used for adding/deleting kernel-originated
 routes and upcoming netlink protocol.

As a part of providing this KPI, low-level route addition code has been
 reworked to provide more control over route creation or change.
 Specifically, a number of operation flags
 (RTM_F_<CREATE|EXCL|REPLACE|APPEND>) have been added, defining the
 desired behaviour the the route already exists (or not exists). This
 change required some changes in the multipath addition code, resulting
 in moving this code to route_ctl.c, rendering mpath_ctl.c empty.

Differential Revision: https://reviews.freebsd.org/D36073
MFC after: 1 month

22 months agorouting: split nexthop creation and rtentry creation.
Alexander V. Chernikov [Thu, 4 Aug 2022 12:35:31 +0000 (12:35 +0000)]
routing: split nexthop creation and rtentry creation.

This change is required for the upcoming introduction of the next
 nexhop-based operations KPI, as it will create rtentry and nexthops
 at different stages of route table modification.

Differential Revision: https://reviews.freebsd.org/D36072
MFC after: 2 weeks

22 months agorouting: refactor #2
Alexander V. Chernikov [Wed, 3 Aug 2022 08:20:40 +0000 (08:20 +0000)]
routing: refactor #2

* Use same filter func (rib_filter_f_t) for nexhtop groups to
 simplify callbacks.
* simplify conditional route deletion & remove the need to pass
 rt_addrinfo to the low-level deletion functions
* speedup rib_walk_del() by removing an additional per-prefix lookup

Differential Revision: https://reviews.freebsd.org/D36071
MFC after: 1 month

22 months agorouting: refactor control cmds #1
Alexander V. Chernikov [Tue, 2 Aug 2022 12:44:20 +0000 (12:44 +0000)]
routing: refactor control cmds #1

This and the follow-up routing-related changes target to remove or
 reduce `struct rt_addrinfo` usage and use recently-landed nhop(9)
 KPI instead.
Traditionally `rt_addrinfo` structure has been used to propagate all necessary
information between the protocol/rtsock and a routing layer. Many
functions inside routing subsystem uses it internally. However, using
this structure became somewhat complicated, as there are too many ways
of specifying a single state and verifying data consistency is hard.
For example, arerouting flgs consistent with mask/gateway sockaddr pointers?
Is mask really a host mask? Are sockaddr "valid" (e.g. properly zeroed, masked,
have proper length)? Are they mutable? Is the suggested interface specified
 by the interface index embedded into the sockadd_dl gateway, or passed
 as RTAX_IFP parameter, or directly provided by rti_ifp or it needs to
 be derived from the ifa?
These (and other similar) questions have to be considered every time when
 a function has `rt_addrinfo` pointer as an argument.

The new approach is to bring more control back to the protocols and
construct the desired routing objects themselves - in the end, it's the
protocol/subsystem who knows the desired outcome.

This specific diff changes the following:
* add explicit basic low-level radix operations:
 add_route() (renamed from add_route_nhop())
 delete_route() (factored from change_route_nhop())
 change_route() (renamed from change_route_nhop)
* remove "info" parameter from change_route_conditional() as a part
 of reducing rt_addrinfo usage in the internal KPIs
* add lookup_prefix_rt() wrapper for doing re-lookups after
 RIB lock/unlock

Differential Revision: https://reviews.freebsd.org/D36070
MFC after: 2 weeks

22 months agotcp: utilize new solisten_clone() and solisten_enqueue()
Gleb Smirnoff [Wed, 10 Aug 2022 18:09:34 +0000 (11:09 -0700)]
tcp: utilize new solisten_clone() and solisten_enqueue()

This streamlines cloning of a socket from a listener.  Now we do not
drop the inpcb lock during creation of a new socket, do not do useless
state transitions, and put a fully initialized socket+inpcb+tcpcb into
the listen queue.

Before this change, first we would allocate the socket and inpcb+tcpcb via
tcp_usr_attach() as TCPS_CLOSED, link them into global list of pcbs, unlock
pcb and put this onto incomplete queue (see 6f3caa6d815).  Then, after
sonewconn() we would lock it again, transition into TCPS_SYN_RECEIVED,
insert into inpcb hash, finalize initialization of tcpcb.  And then, in
call into tcp_do_segment() and upon transition to TCPS_ESTABLISHED call
soisconnected().  This call would lock the listening socket once again
with a LOR protection sequence and then we would relocate the socket onto
the complete queue and only now it is ready for accept(2).

Reviewed by: rrs, tuexen
Differential revision: https://reviews.freebsd.org/D36064

22 months agosockets: provide solisten_clone(), solisten_enqueue()
Gleb Smirnoff [Wed, 10 Aug 2022 18:09:34 +0000 (11:09 -0700)]
sockets: provide solisten_clone(), solisten_enqueue()

as alternative KPI to sonewconn().  The latter has three stages:
- check the listening socket queue limits
- allocate a new socket
- call into protocol attach method
- link the new socket into the listen queue of the listening socket

The attach method, originally designed for a creation of socket by the
socket(2) syscall has slightly different semantics than attach of a socket
cloned by listener.  Make it possible for protocols to call into the
first stage, then perform a different attach, and then call into the
final stage.  The first stage, that checks limits and clones a socket
is called solisten_clone(), and the function that enqueues the socket
is solisten_enqueue().

Reviewed by: tuexen
Differential revision: https://reviews.freebsd.org/D36063

22 months agoinpcb: gather v4/v6 handling code into in_pcballoc() from protocols
Gleb Smirnoff [Wed, 10 Aug 2022 18:09:34 +0000 (11:09 -0700)]
inpcb: gather v4/v6 handling code into in_pcballoc() from protocols

Reviewed by: rrs, tuexen
Differential revision: https://reviews.freebsd.org/D36062

22 months agomodules: if_awg: Add miibus_if.h to the source
Emmanuel Vadot [Sun, 14 Nov 2021 19:53:10 +0000 (20:53 +0100)]
modules: if_awg: Add miibus_if.h to the source

Needed by the module.

22 months agomodules: aw_mmc: Add mmc_pwrseq_if to the source
Emmanuel Vadot [Sun, 14 Nov 2021 19:52:44 +0000 (20:52 +0100)]
modules: aw_mmc: Add mmc_pwrseq_if to the source

Needed by the module.