]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agoFix two typos in source code comments
Gordon Bergling [Sat, 16 Oct 2021 06:09:31 +0000 (08:09 +0200)]
Fix two typos in source code comments

- s/alocated/allocated/
- s/realocated/reallocated/

MFC after: 3 days

2 years agoFix fragmented UDP packets handling since rev.360967.
Maxim Sobolev [Thu, 7 Oct 2021 20:41:40 +0000 (13:41 -0700)]
Fix fragmented UDP packets handling since rev.360967.

Consider IP_MF flag when checking length of the UDP packet to
match the declared value.

Sponsored by: Sippy Software, Inc.
Differential Revision: https://reviews.freebsd.org/D32363
MFC after: 2 weeks

2 years agontp: Revert "Disable ntpd stack gap. When ASLR with STACK GAP != 0 ntpd suffers SIGSEGV."
Cy Schubert [Mon, 16 Aug 2021 15:05:50 +0000 (08:05 -0700)]
ntp: Revert "Disable ntpd stack gap. When ASLR with STACK GAP != 0 ntpd suffers SIGSEGV."

This reverts commit 55263180628a386ad38b4b6621919220b137f770 because the
underlying problem was fixed by 889b56c8cd84c9a9f2d9e3b019c154d6f14d9021.

MFC after: 1 month

2 years agontp: Revert "Disable stack gap for ntpd during build."
Cy Schubert [Mon, 16 Aug 2021 14:46:31 +0000 (07:46 -0700)]
ntp: Revert "Disable stack gap for ntpd during build."

This reverts commit af949c590bd8a00a5973b5875d7e0fa6832ea64a because
889b56c8cd84c9a9f2d9e3b019c154d6f14d9021 fixes the underlying problem.

MFC after: 1 month

2 years agopf tests: ensure that $nr expansion is correct
Kristof Provost [Sun, 3 Oct 2021 16:07:04 +0000 (18:07 +0200)]
pf tests: ensure that $nr expansion is correct

Test the $nr expansion in labels is correct, even if the optimiser
reduces the rule count.

MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D32489

2 years agopfctl: delay label macro expansion until after rule optimisation
Kristof Provost [Wed, 13 Oct 2021 14:06:47 +0000 (16:06 +0200)]
pfctl: delay label macro expansion until after rule optimisation

We used to expand the $nr macro in labels into the rule number prior to
the optimisation step. This would occasionally produce incorrect rule
numbers in the labels.

Delay all macro expansion until after the optimisation step to ensure
that we expand the correct values.

MFC after: 1 week
Reported by: Özkan KIRIK <ozkan.kirik@gmail.com>
Differential Revision: https://reviews.freebsd.org/D32488

2 years agonfscl: Add an argument to nfscl_tryclose()
Rick Macklem [Fri, 15 Oct 2021 21:25:38 +0000 (14:25 -0700)]
nfscl: Add an argument to nfscl_tryclose()

This patch adds a new argument to nfscl_tryclose() to indicate
whether or not it should loop when a NFSERR_DELAY reply is received
from the NFSv4 server.  Since this new argument is always passed in
as "true" at this time, no semantics change should occur.

This is being done to prepare the code for a future patch that fixes
the case where an NFSv4.1/4.2 server replies NFSERR_DELAY to a Close
operation.

MFC after: 2 week

2 years agoAdd libcbor to the build
Ed Maste [Thu, 7 Oct 2021 00:42:40 +0000 (20:42 -0400)]
Add libcbor to the build

From https://github.com/PJK/libcbor:

    libcbor is a C library for parsing and generating CBOR, the general-
    purpose schema-less binary data format.

libcbor will be used by ssh to support FIDO/U2F keys.  It is currently
intended only for use by ssh, and so is installed as a PRIVATELIB and is
placed in the ssh pkgbase package.

cbor_export.h and configuration.h were generated by the upstream CMake
build.  We could create them with bmake rules instead (as NetBSD has
done) but this is a fine start.

This is currently disabled for the 32-bit library build as libfido2 is
not compatible with the COMPAT_32BIT hack in usb_ioctl.h, and there is
no need for libcbor without libfido2.

Reviewed by: kevans
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32347

2 years agomixer(8): Print usage to standard error.
Hans Petter Selasky [Fri, 15 Oct 2021 13:56:00 +0000 (15:56 +0200)]
mixer(8): Print usage to standard error.

Differential Revision: https://reviews.freebsd.org/D32507
Submitted by: christos@
Sponsored by: NVIDIA Networking

2 years agomixer(8): Fix mixer status line for /dev/dspX.vpY mixer devices.
Hans Petter Selasky [Fri, 15 Oct 2021 09:11:44 +0000 (11:11 +0200)]
mixer(8): Fix mixer status line for /dev/dspX.vpY mixer devices.

In some cases when passing /dev/dspX.vpY as mixer devices, m->ci.longname and
m->ci.hw_info will be empty. Don't print any brackets and parentheses
in this case.

Differential Revision: https://reviews.freebsd.org/D32500
Submitted by: christos@
Sponsored by: NVIDIA Networking

2 years agolibthr: Use kern.stacktop for thread stack calculation.
Dawid Gorecki [Wed, 13 Oct 2021 19:06:05 +0000 (21:06 +0200)]
libthr: Use kern.stacktop for thread stack calculation.

Use the new kern.stacktop sysctl to retrieve the address of stack top
instead of kern.usrstack. kern.usrstack does not have any knowledge
of the stack gap, so this can cause problems with thread stacks.
Using kern.stacktop sysctl should fix most of those problems.
kern.usrstack is used as a fallback when kern.stacktop cannot be read.

Rename usrstack variables to stacktop to reflect this change.

Fixes problems with firefox and thunderbird not starting with
stack gap enabled.

PR: 239873
Reviewed by: kib
Obtained from: Semihalf
Sponsored by: Stormshield
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D31898

2 years agokern_exec: Add kern.stacktop sysctl.
Dawid Gorecki [Wed, 13 Oct 2021 19:03:37 +0000 (21:03 +0200)]
kern_exec: Add kern.stacktop sysctl.

With stack gap enabled top of the stack is moved down by a random
amount of bytes. Because of that some multithreaded applications
which use kern.usrstack sysctl to calculate address of stacks for
their threads can fail. Add kern.stacktop sysctl, which can be used
to retrieve address of the stack after stack gap is applied to it.
Returns value identical to kern.usrstack for processes which have
no stack gap.

Reviewed by: kib
Obtained from: Semihalf
Sponsored by: Stormshield
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D31897

2 years agosetrlimit: Take stack gap into account.
Dawid Gorecki [Wed, 13 Oct 2021 19:01:08 +0000 (21:01 +0200)]
setrlimit: Take stack gap into account.

Calling setrlimit with stack gap enabled and with low values of stack
resource limit often caused the program to abort immediately after
exiting the syscall. This happened due to the fact that the resource
limit was calculated assuming that the stack started at sv_usrstack,
while with stack gap enabled the stack is moved by a random number
of bytes.

Save information about stack size in struct vmspace and adjust the
rlim_cur value. If the rlim_cur and stack gap is bigger than rlim_max,
then the value is truncated to rlim_max.

PR: 253208
Reviewed by: kib
Obtained from: Semihalf
Sponsored by: Stormshield
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D31516

2 years agobhyve: ignore low bits of CFGADR
Corvin Köhne [Fri, 15 Oct 2021 07:25:54 +0000 (09:25 +0200)]
bhyve: ignore low bits of CFGADR

Bhyve could emulate wrong PCI registers.
In the best case, the guest reads wrong registers and the device driver would
report some errors.
In the worst case, the guest writes to wrong PCI registers and could brick
hardware when using PCI passthrough.

According to Intels specification, low bits of CFGADR should be
ignored. Some OS like linux may rely on it. Otherwise, bhyve could
emulate a wrong PCI register.

E.g.
If linux would like to read 2 bytes from offset 0x02, following would
happen.
linux:
outl 0x80000002 at CFGADR
inw  at CFGDAT + 2
bhyve:
cfgoff = 0x80000002 & 0xFF = 0x02
coff   = cfgoff + (port - CFGDAT) = 0x02 + 0x02 = 0x04
Bhyve would emulate the register at offset 0x04 not 0x02.

Reviewed By: #bhyve, grehan
Differential Revision: https://reviews.freebsd.org/D31819
Sponsored by:        Beckhoff Automation GmbH & Co. KG

2 years agonfscl: Restructure nfscl_freeopen() slightly
Rick Macklem [Fri, 15 Oct 2021 00:28:01 +0000 (17:28 -0700)]
nfscl: Restructure nfscl_freeopen() slightly

This patch factors the unlinking of the nfsclopen structure out of
nfscl_freeopen() into a separate function called nfscl_unlinkopen().
It also adds a new argument to nfscl_freeopen() to conditionally do
the unlink.  Since this new argument is always passed in as "true"
at this time, no semantics change should occur.

This is being done to prepare the code for a future patch that fixes
the case where an NFSv4.1/4.2 server replies NFSERR_DELAY to a Close
operation.

MFC after: 2 week

2 years agoktls: Defer creation of threads and zones until first use.
John Baldwin [Thu, 14 Oct 2021 22:48:34 +0000 (15:48 -0700)]
ktls: Defer creation of threads and zones until first use.

Run ktls_init() when the first KTLS session is created rather than
unconditionally during boot.  This avoids creating unused threads and
allocating unused resources on systems which do not use KTLS.

Reviewed by: gallatin, markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D32487

2 years agoFix typo in comment
Konstantin Belousov [Thu, 14 Oct 2021 20:03:36 +0000 (23:03 +0300)]
Fix typo in comment

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agoStyle
Konstantin Belousov [Thu, 14 Oct 2021 19:30:18 +0000 (22:30 +0300)]
Style

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agocxgbe: Only run ktls_tick when NIC TLS is enabled.
John Baldwin [Thu, 14 Oct 2021 17:59:16 +0000 (10:59 -0700)]
cxgbe: Only run ktls_tick when NIC TLS is enabled.

Previously the body of ktls_tick was a nop when NIC TLS was disabled,
but the callout was still scheduled consuming power on otherwise-idle
systems with Chelsio T6 adapters.  Now the callout only runs while NIC
TLS is enabled on at least one interface of an adapter.

Reported by: mav
Reviewed by: np, mav
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D32491

2 years agoFix a syntax error in 1b85b68da0b2
Alex Richardson [Thu, 14 Oct 2021 16:44:13 +0000 (17:44 +0100)]
Fix a syntax error in 1b85b68da0b2

Reported by: Michael Butler, jenkins

2 years agollvm-readobj: Attach to buildsystem
Cameron Katri [Thu, 14 Oct 2021 16:00:27 +0000 (17:00 +0100)]
llvm-readobj: Attach to buildsystem

Also install it as readelf when MK_LLVM_BINUTILS is set.

Reviewed By: dim, arichardson
Differential Revision: https://reviews.freebsd.org/D32058

2 years agopowerpc64: make radix with superpages default
Leandro Lupori [Thu, 14 Oct 2021 16:13:27 +0000 (13:13 -0300)]
powerpc64: make radix with superpages default

As Radix MMU with superpages enabled is now stable, make it the
default choice on supported hardware (POWER9 and above), since its
performance is greater than that of HPT MMU.

Reviewed by: alfredo, jhibbits
Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D30797

2 years agoFix RISC-V build
Li-Wen Hsu [Thu, 14 Oct 2021 15:20:12 +0000 (23:20 +0800)]
Fix RISC-V build

Fixes: d5fd5cdc063

2 years agonvme: Reduce traffic to the doorbell register
Warner Losh [Thu, 14 Oct 2021 14:44:37 +0000 (08:44 -0600)]
nvme: Reduce traffic to the doorbell register

Reduce traffic to doorbell register when processing multiple completion
events at once. Only write it at the end of the loop after we've
processed everything (assuming we found at least one completion,
even if that completion wasn't valid).

Sponsored by: Netflix
Reviewed by: mav
Differential Revision: https://reviews.freebsd.org/D32470

2 years agopowerpc64: fix OFWFB with Radix MMU
Leandro Lupori [Thu, 14 Oct 2021 13:39:52 +0000 (10:39 -0300)]
powerpc64: fix OFWFB with Radix MMU

Current implementation of Radix MMU doesn't support mapping
arbitrary virtual addresses, such as the ones generated by
"direct mapping" I/O addresses. This caused the system to hang, when
early I/O addresses, such as those used by OpenFirmware Frame Buffer,
were remapped after the MMU was up.

To avoid having to modify mmu_radix_kenter_attr just to support this
use case, this change makes early I/O map use virtual addresses from
KVA area instead (similar to what mmu_radix_mapdev_attr does), as
these can be safely remapped later.

Reviewed by: alfredo (earlier version), jhibbits (in irc)
MFC after: 2 weeks
Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D31232

2 years agong_ppp(4): Fix a typo in a comment
Gordon Bergling [Thu, 14 Oct 2021 13:30:32 +0000 (15:30 +0200)]
ng_ppp(4): Fix a typo in a comment

- s/delcared/declared/

MFC after: 3 days

2 years agounionfs: Ensure SAVENAME is set for unionfs vnode operations
Jason A. Harmening [Sun, 26 Sep 2021 02:56:04 +0000 (19:56 -0700)]
unionfs: Ensure SAVENAME is set for unionfs vnode operations

"rm-style" system calls such as kern_frmdirat() and kern_funlinkat()
don't supply SAVENAME to preserve the pathname buffer for subsequent
vnode ops.  For unionfs this poses an issue because the pathname may
be needed for a relookup operation in unionfs_remove()/unionfs_rmdir().
Currently unionfs doesn't check for this case, leading to a panic on
DIAGNOSTIC kernels and use-after-free of cn_nameptr otherwise.

The unionfs node's stored buffer would suffice as a replacement for
cnp->cn_nameptr in some (but not all) cases, but it's cleaner to just
ensure that unionfs vnode ops always have a valid cn_nameptr by setting
SAVENAME in unionfs_lookup().

While here, do some light cleanup in unionfs_lookup() and assert that
HASBUF is always present in the relevant relookup calls.

Reported by: pho
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D32148

2 years agoselsocket: handle sopoll() errors correctly
Brooks Davis [Wed, 13 Oct 2021 23:43:06 +0000 (00:43 +0100)]
selsocket: handle sopoll() errors correctly

Without this change, unmounting smbfs filesystems with an INVARIANTS
kernel would panic after 10e64782ed59727e8c9fe4a5c7e17f497903c8eb.

Found by: markj
Reviewed by: markj, jhb
Obtained from: CheriBSD
MFC after: 3 days
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D32492

2 years agobpf(4): Fix a misnamed constant
Felix Johnson [Wed, 13 Oct 2021 23:00:41 +0000 (19:00 -0400)]
bpf(4): Fix a misnamed constant

rarpd.c was modified in r19859 to use REVARP_REQUEST instead of
ARPOP_REVREQUEST.

PR: 183333
MFC after: 3 days
Reported by: pluknet <pluknet@gmail.com>

2 years agonfscl: Make nfscl_getlayout() acquire the correct pNFS layout
Rick Macklem [Wed, 13 Oct 2021 22:48:54 +0000 (15:48 -0700)]
nfscl: Make nfscl_getlayout() acquire the correct pNFS layout

Without this patch, if a pNFS read layout has already been acquired
for a file, writes would be redirected to the Metadata Server (MDS),
because nfscl_getlayout() would not acquire a read/write layout for
the file.  This happened because there was no "mode" argument to
nfscl_getlayout() to indicate whether reading or writing was being done.
Since doing I/O through the Metadata Server is not encouraged for some
pNFS servers, it is preferable to get a read/write layout for writes
instead of redirecting the write to the MDS.

This patch adds a access mode argument to nfscl_getlayout() and
nfsrpc_getlayout(), so that nfscl_getlayout() knows to acquire a read/write
layout for writing, even if a read layout has already been acquired.
This patch only affects NFSv4.1/4.2 client behaviour when pNFS ("pnfs" mount
option against a server that supports pNFS) is in use.

This problem was detected during a recent NFSv4 interoperability
testing event held by the IETF working group.

MFC after: 2 week

2 years agoTemporarily skip sys.netgraph.hub.loop on RISC-V in CI
Li-Wen Hsu [Wed, 13 Oct 2021 21:31:22 +0000 (05:31 +0800)]
Temporarily skip sys.netgraph.hub.loop on RISC-V in CI

This case panics kernel.

PR: 259157
Sponsored by: The FreeBSD Foundation

2 years agorelease: add _LOCATION to the list of required AZURE variables
Glen Barber [Wed, 13 Oct 2021 21:11:48 +0000 (17:11 -0400)]
release: add _LOCATION to the list of required AZURE variables

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

2 years agorelease: use tab-delimited variables in AZURE_UPLOAD_CONF
Glen Barber [Wed, 13 Oct 2021 20:39:10 +0000 (16:39 -0400)]
release: use tab-delimited variables in AZURE_UPLOAD_CONF

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

2 years agoktls: Ensure FIFO encryption order for TLS 1.0.
John Baldwin [Wed, 13 Oct 2021 19:30:15 +0000 (12:30 -0700)]
ktls: Ensure FIFO encryption order for TLS 1.0.

TLS 1.0 records are encrypted as one continuous CBC chain where the
last block of the previous record is used as the IV for the next
record.  As a result, TLS 1.0 records cannot be encrypted out of order
but must be encrypted as a FIFO.

If the later pages of a sendfile(2) request complete before the first
pages, then TLS records can be encrypted out of order.  For TLS 1.1
and later this is fine, but this can break for TLS 1.0.

To cope, add a queue in each TLS session to hold TLS records that
contain valid unencrypted data but are waiting for an earlier TLS
record to be encrypted first.

- In ktls_enqueue(), check if a TLS record being queued is the next
  record expected for a TLS 1.0 session.  If not, it is placed in
  sorted order in the pending_records queue in the TLS session.

  If it is the next expected record, queue it for SW encryption like
  normal.  In addition, check if this new record (really a potential
  batch of records) was holding up any previously queued records in
  the pending_records queue.  Any of those records that are now in
  order are also placed on the queue for SW encryption.

- In ktls_destroy(), free any TLS records on the pending_records
  queue.  These mbufs are marked M_NOTREADY so were not freed when the
  socket buffer was purged in sbdestroy().  Instead, they must be
  freed explicitly.

Reviewed by: gallatin, markj
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D32381

2 years agoktls: Reject attempts to enable AES-CBC with TLS 1.3.
John Baldwin [Wed, 13 Oct 2021 19:12:58 +0000 (12:12 -0700)]
ktls: Reject attempts to enable AES-CBC with TLS 1.3.

AES-CBC cipher suites are not supported in TLS 1.3.

Reported by: syzbot+ab501c50033ec01d53c6@syzkaller.appspotmail.com
Reviewed by: tuexen, markj
Differential Revision: https://reviews.freebsd.org/D32404

2 years agoRemove in_ifaddr_lock acquisiton to access in_ifaddrhead.
Gleb Smirnoff [Fri, 8 Oct 2021 19:56:24 +0000 (12:56 -0700)]
Remove in_ifaddr_lock acquisiton to access in_ifaddrhead.

An IPv4 address is embedded into an ifaddr which is freed
via epoch. And the in_ifaddrhead is already a CK list. Use
the network epoch to protect against use after free.

Next step would be to CK-ify the in_addr hash and get rid of the...

Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D32434

2 years agomount: Check for !VDIR mount points before handling -o emptydir
Mark Johnston [Wed, 13 Oct 2021 00:11:02 +0000 (20:11 -0400)]
mount: Check for !VDIR mount points before handling -o emptydir

To implement -o emptydir, vfs_emptydir() checks that the passed
directory is empty.  This should be done after checking whether the
vnode is of type VDIR, though, or vfs_emptydir() may end up calling
VOP_READDIR on a non-directory.

Reported by: syzbot+4006732c69fb0f792b2c@syzkaller.appspotmail.com
Reviewed by: kib, imp
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32475

2 years agortld: Do not install libmap.conf when installing the COMPAT32 version
Emmanuel Vadot [Wed, 13 Oct 2021 12:40:26 +0000 (14:40 +0200)]
rtld: Do not install libmap.conf when installing the COMPAT32 version

This has the effect of installing the same file twice at the same location
and confuse pkgbase as we add this file twice in the package config part.

MFC after:  1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG

2 years agopf: Introduce pf_nvbool()
Kristof Provost [Wed, 13 Oct 2021 09:00:46 +0000 (11:00 +0200)]
pf: Introduce pf_nvbool()

Similar to the existing functions for strings and ints, this lets us
simplify some of the nvlist conversion code.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agonative-xtools: avoid libllvm while populating the sysroot
Kyle Evans [Wed, 13 Oct 2021 09:21:28 +0000 (04:21 -0500)]
native-xtools: avoid libllvm while populating the sysroot

Prior to 021385aba562, MK_CLANG=no was sufficient to avoid descending
into lib/clang, but the referenced change added a couple of other
enabling knobs. Turn those off, too, to continue avoiding libllvm.

With this change, we no longer end up with a libllvm using the wrong
default target triple; `poudriere jail -cx` works once again.

Reported by: bhughes, imp, probably others
Fixes: 021385aba562 ("Add WITH_LLVM_BINUTILS to install LLVM ...")

2 years agoAllow the BPF to be select for write. This is needed for boost:asio
Hartmut Brandt [Sun, 10 Oct 2021 15:03:51 +0000 (17:03 +0200)]
Allow the BPF to be select for write. This is needed for boost:asio
which otherwise fails to handle BPFs.
Reviewed by: ae
Differential Revision: https://reviews.freebsd.org/D31967

2 years agobhyve: Update usage and synopsis for the -k flag
Mateusz Piotrowski [Tue, 12 Oct 2021 19:49:43 +0000 (21:49 +0200)]
bhyve: Update usage and synopsis for the -k flag

Let's make it clear to users that -k is for configuration files.
Also, point to bhyve_config(5) in the paragraph describing the flag.

Reviewed by: jhb
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D32467

2 years agoacpi(4): Correct outdated sysctl
Felix Johnson [Wed, 13 Oct 2021 00:42:14 +0000 (20:42 -0400)]
acpi(4): Correct outdated sysctl

This changes the location of cx_supported sysctl to dev.cpu.N.

PR: 214370
MFC after: 3 days

2 years agortld direct exec: add -d option
Konstantin Belousov [Mon, 11 Oct 2021 22:26:54 +0000 (01:26 +0300)]
rtld direct exec: add -d option

to ignore lack of execute permission on the binary.  The check is a
bad security theatre anyway.

Reviewed by: arichardson, imp
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32464

2 years agonfscl: Fix another deadlock related to the NFSv4 clientID lock
Rick Macklem [Wed, 13 Oct 2021 00:21:01 +0000 (17:21 -0700)]
nfscl: Fix another deadlock related to the NFSv4 clientID lock

Without this patch, it is possible to hang the NFSv4 client,
when a rename/remove is being done on a file where the client
holds a delegation, if pNFS is being used.  For a delegation
to be returned, dirty data blocks must be flushed to the NFSv4
server.  When pNFS is in use, a shared lock on the clientID
must be acquired while doing a write to the DS(s).
However, if rename/remove is doing the delegation return
an exclusive lock will be acquired on the clientID, preventing
the write to the DS(s) from acquiring a shared lock on the clientID.

This patch stops rename/remove from doing a delegation return
if pNFS is enabled.  Since doing delegation return in the same
compound as rename/remove is only an optimization, not doing
so should not cause problems.

This problem was detected during a recent NFSv4 interoperability
testing event held by the IETF working group.

MFC after: 1 week

2 years agocrt_malloc: Be more persistent when handling mmap() failure
Konstantin Belousov [Mon, 11 Oct 2021 16:13:31 +0000 (19:13 +0300)]
crt_malloc: Be more persistent when handling mmap() failure

In the situation with limited address space, together with
fragmentation, it is possible for mmap() request in morecore() to fail
when asking for required size + NPOOLPAGES, but succeed without the
addend.  Retry allocation there.

PR: 259076
Reported by: Denis Koreshkov <dynamic-wind@mail.ru>
Reviewed by: arichardson
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32474

2 years agocrt_malloc: use uintptr_t instead of long for arithmetic on addresses
Konstantin Belousov [Tue, 12 Oct 2021 21:39:07 +0000 (00:39 +0300)]
crt_malloc: use uintptr_t instead of long for arithmetic on addresses

and avoid unneeded casts

Reviewed by: arichardson (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32474

2 years agoStop creating socket aio kprocs during boot.
John Baldwin [Tue, 12 Oct 2021 21:03:07 +0000 (14:03 -0700)]
Stop creating socket aio kprocs during boot.

Create the initial pool of kprocs on demand when the first socket AIO
request is submitted instead.  The pool of kprocs used for other AIO
requests is similarly created on first use.

Reviewed by: asomers
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D32468

2 years agonvme: Restore hotplug warning
Warner Losh [Tue, 12 Oct 2021 20:25:16 +0000 (14:25 -0600)]
nvme: Restore hotplug warning

Restore hotplug warning in recovery state machine. No functional change
other than what message gets printed.

Sponsored by: Netflix

2 years agopthread_np.3: Add a manpage summarizing all of the pthread extensions.
Felix Johnson [Thu, 7 Oct 2021 17:45:21 +0000 (10:45 -0700)]
pthread_np.3: Add a manpage summarizing all of the pthread extensions.

PR: 197299
MFC after: 1 week

2 years agoRestore PPS_SYNC in NOTES
Konstantin Belousov [Mon, 11 Oct 2021 22:02:35 +0000 (01:02 +0300)]
Restore PPS_SYNC in NOTES

This partially reverts e81e77c5a055, leaving the option both in
GENERICs on amd64/arm64/arm, and in global NOTES file.  Apparently
this better matches existing practice, where we do not try to hard
to make LINT and GENERIC complimentary.

Requested and reviewed by: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

2 years agoPrevent repeated deallocation of a resource.
Ruslan Bukin [Tue, 12 Oct 2021 19:13:44 +0000 (20:13 +0100)]
Prevent repeated deallocation of a resource.
Also deactivate resource if needed.

Discussed with: jrtc27
Differential Revision: https://reviews.freebsd.org/D32458

2 years agobhyve.8: Fix markup of the -G flag
Mateusz Piotrowski [Tue, 12 Oct 2021 14:06:52 +0000 (16:06 +0200)]
bhyve.8: Fix markup of the -G flag

2 years agoStop reading the arm64 domain when it's known
Andrew Turner [Tue, 12 Oct 2021 11:39:14 +0000 (12:39 +0100)]
Stop reading the arm64 domain when it's known

There is no need to read the domain on arm64 when there is only one
in the ACPI tables. This can also happen when the table is missing
as it is unneeded.

Reported by: dch
Sponsored by: The FreeBSD Foundation

2 years agokqueue(9): correct spelling of kn_fop
Kyle Evans [Sun, 3 Oct 2021 15:59:52 +0000 (10:59 -0500)]
kqueue(9): correct spelling of kn_fop

2 years agofifos: delegate unhandled kqueue filters to underlying filesystem
Kyle Evans [Sat, 2 Oct 2021 05:23:03 +0000 (00:23 -0500)]
fifos: delegate unhandled kqueue filters to underlying filesystem

This gives the vfs layer a chance to provide handling for EVFILT_VNODE,
for instance.  Change pipe_specops to use the default vop_kqfilter to
accommodate fifoops that don't specify the method (i.e. all in-tree).

Based on a patch by Jan Kokemüller.

PR: 225934
Reviewed by: kib, markj (both pre-KASSERT)
Differential Revision: https://reviews.freebsd.org/D32271

2 years agostress2: Use two memory disks for this test
Peter Holm [Tue, 12 Oct 2021 06:45:19 +0000 (06:45 +0000)]
stress2: Use two memory disks for this test

2 years agonfscl: Fix a deadlock related to the NFSv4 clientID lock
Rick Macklem [Tue, 12 Oct 2021 04:58:24 +0000 (21:58 -0700)]
nfscl: Fix a deadlock related to the NFSv4 clientID lock

Without this patch, it is possible for a process doing an NFSv4
Open/create of a file to block to allow another process
to acquire the exclusive lock on the clientID when holding
a shared lock on the clientID.  As such, both processes
deadlock, with one wanting the exclusive lock, while the
other holds the shared lock.  This deadlock is unlikely to occur
unless delegations are in use on the NFSv4 mount.

This patch fixes the problem by not deferring to the process
waiting for the exclusive lock when a shared lock (reference cnt)
is already held by the process.

This problem was detected during a recent NFSv4 interoperability
testing event held by the IETF working group.

MFC after: 1 week

2 years agoSkip sys.net.if_lagg_test.status_stress in CI
Li-Wen Hsu [Mon, 11 Oct 2021 21:40:24 +0000 (05:40 +0800)]
Skip sys.net.if_lagg_test.status_stress in CI

This case panics the machine fairly often and we should run
stress tests separately.

Sponsored by: The FreeBSD Foundation

2 years agoforward declare struct thread
Warner Losh [Mon, 11 Oct 2021 18:59:39 +0000 (12:59 -0600)]
forward declare struct thread

sys/sysctl.h moved struct thread forward declaration under #ifdef
_KERNEL and so this header fails when included from userland. Add a
forward declaration here.

Fixes:       99eefc727eba
Sponsored by: Netflix

2 years agoRevert "bootstrap: No need to disable shared libraries for bootstrap tools"
Warner Losh [Mon, 11 Oct 2021 17:49:48 +0000 (11:49 -0600)]
Revert "bootstrap: No need to disable shared libraries for bootstrap tools"

This reverts commit e8f26e5dc859a8fbc663e108421f657325ca3054.

Although the change worked locally, it's breaking something in the CI
build for the riscv64 build (which makes no sense it would only break
that since we're building host tools to bootstrap at that point).

Sponsored by: Netflix

2 years agosysctl.h: Less namespace pollution
Warner Losh [Mon, 11 Oct 2021 17:15:08 +0000 (11:15 -0600)]
sysctl.h: Less namespace pollution

Remove unused struct ctlname. It is unused. Move struct thread to
inside #if _KERNEL.

Sponsored by: Netflix
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D32457

2 years agosysctl: make sys/sysctl.h self contained
Warner Losh [Mon, 11 Oct 2021 17:14:51 +0000 (11:14 -0600)]
sysctl: make sys/sysctl.h self contained

sys/sysctl.h only needs u_int and size_t from sys/types.h. When the
sysctl interface was designed, having one more more prerequisites
(especially sys/types.h) was the norm. Times have changed, and to make
things more portable, make sys/types.h optional. We do this by including
sys/_types.h, defining size_t if needed, and changing u_int to 'unsigned
int' in a prototype for userland builds. For kernel builds, sys/types.h
is still required.

Sponsored by: Netflix
Reviewed by: kib, jhb
Differential Revision: https://reviews.freebsd.org/D31827

2 years agobootstrap: No need to disable shared libraries for bootstrap tools
Warner Losh [Mon, 11 Oct 2021 17:13:39 +0000 (11:13 -0600)]
bootstrap: No need to disable shared libraries for bootstrap tools

There's no need to disable shared libraries when building the bootstrap
tools. This was added on 2000 (commit ad879ce9552c) when the perl
bootstrap was added (libperl and miniperl) and saved a fair amount of
time (perl took a long time to build on 2000-era hardware).

For many years now, however, we rarely build any libraries when
bootstrapping. Even when we do, the optimization saves at most a few
seconds when upgrading since the libraries built have been small. Shared
libraries are more robust accross versions that static libraries due to
creaping dependencies (we aren't crossing versions of share libraries,
though, just using what's on the host). In addition, linux and macos
have been building like this for some time because static binaries on
those systems are difficult to impossible.

Sponsored by: Netflix
Reviewed by: arichardson, bapt
Differential Revision: https://reviews.freebsd.org/D32443

2 years agoO_PATH: allow vfs_extattr syscalls
Greg V [Sun, 10 Oct 2021 12:45:31 +0000 (15:45 +0300)]
O_PATH: allow vfs_extattr syscalls

These calls do operate on vnodes only, not file contents.
This is useful for e.g. the xdg-document-portal fuse filesystem.

Reviewed by: kib, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D32438

2 years agolast: improve non-UTF8 locale output after libxo support was added
Piotr Pawel Stefaniak [Sun, 10 Oct 2021 07:16:59 +0000 (09:16 +0200)]
last: improve non-UTF8 locale output after libxo support was added

Some strftime(3) conversion specifications will generate strings encoded
with the current locale, not necessarily UTF8. As per xo_format.5, use
the h string modifier so that libxo interprets it appropriately.

Reviewed by: eugen, philip
Differential Revision: https://reviews.freebsd.org/D32437

2 years agoRevert "last(1): unbreak for 8-bit locales"
Piotr Pawel Stefaniak [Sun, 10 Oct 2021 06:37:36 +0000 (08:37 +0200)]
Revert "last(1): unbreak for 8-bit locales"

This reverts commits 8e67c427b5 (unbreak for 8-bit locales), 0ca58ca151
(correction after r351413), and f424ec1b80 (fix style after r351459).

A simpler fix can be done by using the h modifier for strings that are
encoded with the current locale.

Reviewed by: eugen, philip
Differential Revision: https://reviews.freebsd.org/D32437

2 years agonanosleep.2: use appropriate macros
Piotr Pawel Stefaniak [Sat, 9 Oct 2021 16:00:01 +0000 (18:00 +0200)]
nanosleep.2: use appropriate macros

Reported by: kib
Fixes: bf8f6ffcb66a

2 years agovfs: remove thread argument from VOP_STAT
Mateusz Guzik [Fri, 1 Oct 2021 22:25:39 +0000 (00:25 +0200)]
vfs: remove thread argument from VOP_STAT

and fo_stat.

2 years agovfs: remove cn_thread
Mateusz Guzik [Fri, 1 Oct 2021 21:16:54 +0000 (23:16 +0200)]
vfs: remove cn_thread

It is always curthread.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D32453

2 years agoAdd missing const after 6c4f95161d6e
Alex Richardson [Mon, 11 Oct 2021 12:20:36 +0000 (13:20 +0100)]
Add missing const after 6c4f95161d6e

I accidentally didn't include hunk in the committed patch.

Fixes: 6c4f95161d6e ("virtio: make the write_config buffer argument const")

2 years agocross-build: fix some redeclaration warnings during bootstrap
Alex Richardson [Mon, 13 Sep 2021 09:11:47 +0000 (10:11 +0100)]
cross-build: fix some redeclaration warnings during bootstrap

MFC after: 3 days

2 years agovirtio: make the write_config buffer argument const
Alex Richardson [Mon, 11 Oct 2021 10:52:17 +0000 (11:52 +0100)]
virtio: make the write_config buffer argument const

No functional change intended, but noticed that we could add const here
while adding linuxkpi support for virtio.

Reviewed By: bryanv, imp
Differential Revision: https://reviews.freebsd.org/D32370

2 years agolinuxkpi: implement ida_alloc()
Alex Richardson [Fri, 8 Oct 2021 08:36:30 +0000 (09:36 +0100)]
linuxkpi: implement ida_alloc()

Needed for the virtio-gpu driver.

Reviewed By: #linuxkpi, manu, bz, hselasky
Differential Revision: https://reviews.freebsd.org/D32366

2 years agolinuxkpi: Allow BUILD_BUG_ON in if statements without braces
Alex Richardson [Fri, 8 Oct 2021 08:35:31 +0000 (09:35 +0100)]
linuxkpi: Allow BUILD_BUG_ON in if statements without braces

I got a compilation failure in virtio-gpu without this change.

Reviewed By: #linuxkpi, manu, bz, hselasky
Differential Revision: https://reviews.freebsd.org/D32366

2 years agolinuxkpi: add PAGE_ALIGNED macro
Alex Richardson [Fri, 8 Oct 2021 08:33:21 +0000 (09:33 +0100)]
linuxkpi: add PAGE_ALIGNED macro

Needed for the virtio-gpu driver.

Reviewed By: #linuxkpi, manu, bz, hselasky
Differential Revision: https://reviews.freebsd.org/D32366

2 years agolinuxkpi: Add sg_init_one
Alex Richardson [Fri, 8 Oct 2021 08:32:46 +0000 (09:32 +0100)]
linuxkpi: Add sg_init_one

Needed for the virtio-gpu driver.

Reviewed By: #linuxkpi, manu, bz, hselasky
Differential Revision: https://reviews.freebsd.org/D32366

2 years agoUpdate OptionalObsoleteFiles.inc after 021385aba562
Alex Richardson [Mon, 11 Oct 2021 10:46:30 +0000 (11:46 +0100)]
Update OptionalObsoleteFiles.inc after 021385aba562

I forgot to update this file so make delete-old would incorrectly remove
the newly-installed LLVM binutils. While touching the file also update
for 8e1c989abbd1 since ObsoleteFiles.inc now inludes the tablegen binaries.

Reported by: Herbert J. Skuhra <herbert@gojira.at>
Reviewed By: emaste, imp

Differential Revision: https://reviews.freebsd.org/D32022

2 years agoTeach the readelf about arm64 gnu properties
Andrew Turner [Fri, 17 Sep 2021 15:54:31 +0000 (15:54 +0000)]
Teach the readelf about arm64 gnu properties

On arm64 binaries can be tagged as using BTI or PAC. Add support to
decode these to the elftoolchain readelf.

To simplify the code use a table based method to find the flag
description table.

Reviewed by: emaste
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32315

2 years agoAllocate arm64 per-CPU data in the correct domain
Andrew Turner [Wed, 6 Oct 2021 15:08:04 +0000 (15:08 +0000)]
Allocate arm64 per-CPU data in the correct domain

To minimise NUMA traffic allocate the pcpu, dpcpu, and boot stacks in
the correct domain when possible.

Submitted by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32338

2 years agoOnly demote when needed in the arm64 pmap_change_props_locked
Andrew Turner [Wed, 6 Oct 2021 16:38:22 +0000 (17:38 +0100)]
Only demote when needed in the arm64 pmap_change_props_locked

When changing page table properties there is no need to demote a
level 1 or level 2 block if we are changing the entire memory range the
block is mapping. In this case just change the block directly.

Reported by: alc, kib, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32339

2 years agoAdd pmap_change_prot on arm64
Andrew Turner [Mon, 20 Sep 2021 16:49:18 +0000 (16:49 +0000)]
Add pmap_change_prot on arm64

Support changing the protection of preloaded kernel modules by
implementing pmap_change_prot on arm64 and calling it from
preload_protect.

Reviewed by: alc (previous version)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32026

2 years agonfsd: Disable the NFSv4.2 Allocate operation by default
Rick Macklem [Mon, 11 Oct 2021 01:46:02 +0000 (18:46 -0700)]
nfsd: Disable the NFSv4.2 Allocate operation by default

Some exported file systems, such as ZFS ones, cannot do VOP_ALLOCATE().
Since an NFSv4.2 server must either support the Allocate operation for
all file systems or not support it at all, define a sysctl called
vfs.nfsd.enable_v42allocate to enable the Allocate operation.
This sysctl is false by default and can only be set true if all
exported file systems (or all DSs for a pNFS server) can perform
VOP_ALLOCATE().

Unfortunately, there is no way to know if a ZFS file system will
be exported once the nfsd is operational, even if there are none
exported when the nfsd is started up, so enabling Allocate must
be done manually for a server configuration.

This problem was detected during a recent NFSv4 interoperability
testing event held by the IETF working group.

MFC after: 2 weeks

2 years agonfscl: Fix NFS VOP_ALLOCATE for mounts without Allocate support
Rick Macklem [Sun, 10 Oct 2021 21:27:52 +0000 (14:27 -0700)]
nfscl: Fix NFS VOP_ALLOCATE for mounts without Allocate support

Without this patch, nfs_allocate() fell back on using vop_stdallocate()
for NFS mounts without Allocate operation support.  This was incorrect,
since some file systems, such as ZFS, cannot do allocate via
vop_stdallocate(), which uses writes to try and allocate blocks.

Also, fix nfs_allocate() to return EINVAL when mounts cannot do Allocate,
since that is the correct error for posix_fallocate(2).
Note that Allocate is only supported by some NFSv4.2 servers.

MFC after: 2 weeks

2 years agoEnable PPS_SYNC on amd64, arm64 and armv7
Konstantin Belousov [Sun, 10 Oct 2021 12:20:45 +0000 (15:20 +0300)]
Enable PPS_SYNC on amd64, arm64 and armv7

Remove the option from NOTES/LINT, and add to NOTES for powerpc and
riscv.

PR: 259036
Requested by: John Hay <john@sanren.ac.za>
Discussed with: ian, imp
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

2 years agovfs: add predicts to getvnode and getvnode_path
Mateusz Guzik [Sun, 10 Oct 2021 18:17:50 +0000 (18:17 +0000)]
vfs: add predicts to getvnode and getvnode_path

2 years agoRetire code added to support CloudABI
Mateusz Guzik [Wed, 28 Apr 2021 20:55:03 +0000 (22:55 +0200)]
Retire code added to support CloudABI

CloudABI was removed in cf0ee8738e31aa9e6fbf4dca4dac56d89226a71a

2 years agocross-build: Remove redundant lines.
Warner Losh [Sun, 10 Oct 2021 16:21:49 +0000 (10:21 -0600)]
cross-build: Remove redundant lines.

There's two identical gid_from_group lines in a row. We only need one.
Ditto for uid_from_user().

Sponsored by: Netflix
Reviewed by: bapt, jrtc27
Differential Revision: https://reviews.freebsd.org/D32442

2 years agoncurses: fix typo in makefile
Baptiste Daroussin [Sun, 10 Oct 2021 16:52:21 +0000 (18:52 +0200)]
ncurses: fix typo in makefile

2 years agoObsoleteFiles.inc: stop removing pthread_mutexattr_get/setpshared.3
Konstantin Belousov [Sun, 10 Oct 2021 14:38:20 +0000 (17:38 +0300)]
ObsoleteFiles.inc: stop removing pthread_mutexattr_get/setpshared.3

The man pages were added by 6bda192013fc8e (as symlinks).

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agounzip: Fix segmentation fault if a zip file contains buggy filename.
Yoshihiro Takahashi [Sun, 10 Oct 2021 11:49:19 +0000 (20:49 +0900)]
unzip: Fix segmentation fault if a zip file contains buggy filename.

PR:             259011
Reported by:    Robert Morris
Submitted by:   ak
MFC after::     1 week

2 years agorescue: fix after with to a ldscript of libncursesw.a
Baptiste Daroussin [Sun, 10 Oct 2021 06:53:41 +0000 (08:53 +0200)]
rescue: fix after with to a ldscript of libncursesw.a

2 years agoncurses: convert libncursesw.a into a static ldscript
Baptiste Daroussin [Sun, 10 Oct 2021 05:37:26 +0000 (07:37 +0200)]
ncurses: convert libncursesw.a into a static ldscript

Introduce the notion of static linker scripts to allow libncursesw.a to
track its dependency on libtinfow.a

this allows the build of older freebsd source tree to happen and make
static linking in part with dynamic linking which already provides a
ldscript

This fixes a bootstrapping FreeBSD 12 or 13 on recent FreeBSD 14

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D32435

2 years agovmci: fix panic due to freeing unallocated resources
Mark Peek [Sat, 9 Oct 2021 21:21:16 +0000 (14:21 -0700)]
vmci: fix panic due to freeing unallocated resources

Summary:
An error mapping PCI resources results in a panic due to unallocated
resources being freed up. This change puts the appropriate checks in
place to prevent the panic.

PR: 252445
Reported by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
Tested by: marcus
MFC after: 1 week
Sponsored by: VMware

Test Plan:
Along with user testing, also simulated error by inserting a ENXIO
return in vmci_map_bars().

Reviewed by: marcus
Subscribers: imp
Differential Revision: https://reviews.freebsd.org/D32016

2 years agoreadlinkat(2): allow O_PATH fd
Konstantin Belousov [Sat, 9 Oct 2021 05:12:05 +0000 (08:12 +0300)]
readlinkat(2): allow O_PATH fd

PR: 258856
Reported by: ashish
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32390

2 years agotimecounter: Let kern.timecounter.stepwarnings be set as a tunable
Mark Johnston [Sat, 9 Oct 2021 16:34:06 +0000 (12:34 -0400)]
timecounter: Let kern.timecounter.stepwarnings be set as a tunable

MFC after: 1 week

2 years agobhyve: Map the MSI-X table unconditionally for passthrough
Mark Johnston [Sat, 9 Oct 2021 15:36:19 +0000 (11:36 -0400)]
bhyve: Map the MSI-X table unconditionally for passthrough

It is possible for the PBA to reside in the same page as the MSI-X
table.  And, while devices are not supposed to do this, at least some
Intel wifi devices place registers in a page shared with the MSI-X
table.  To handle the first case we currently map the PBA page using
/dev/mem, and the second case is not handled.

Kill two birds with one stone: map the MSI-X table BAR using the
PCIOCBARMMAP ioctl instead of /dev/mem, and map the entire table so that
accesses beyond the bounds of the table can be emulated.  Regions of the
BAR not containing the table are left unmapped.

Reviewed by: bz, grehan, jhb
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32359

2 years agosbin/mount_fusefs/mount_fusefs.8: Fix typos
Elyes HAOUAS [Fri, 8 Oct 2021 16:44:48 +0000 (18:44 +0200)]
sbin/mount_fusefs/mount_fusefs.8: Fix typos

"expicitly" --> "explicitly"
"uknown" --> "unknown"

Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
MFC after: 3 days
Pull Request: https://github.com/freebsd/freebsd-src/pull/552

2 years ago[fib_algo][dxr] Retire counters which are no longer used
Marko Zec [Sat, 9 Oct 2021 11:47:10 +0000 (13:47 +0200)]
[fib_algo][dxr] Retire counters which are no longer used

The number of chunks can still be tracked via vmstat -z|fgrep dxr.

MFC after: 3 days

2 years ago[fib_algo][dxr] Improve incremental updating strategy
Marko Zec [Sat, 9 Oct 2021 11:22:27 +0000 (13:22 +0200)]
[fib_algo][dxr] Improve incremental updating strategy

Tracking the number of unused holes in the trie and the range table
was a bad metric based on which full trie and / or range rebuilds
were triggered, which would happen in vain by far too frequently,
particularly with live BGP feeds.

Instead, track the total unused space inside the trie and range table
structures, and trigger rebuilds if the percentage of unused space
exceeds a sysctl-tunable threshold.

MFC after: 3 days
PR: 257965