]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agosbin/md5: improve compatibility with coreutils -c option
Stefan Eßer [Sat, 19 Jun 2021 11:27:16 +0000 (13:27 +0200)]
sbin/md5: improve compatibility with coreutils -c option

The -c option expects a digest file in either BSD or coreutils format.

The output for matched and mismatched files is identical to that
of the coreutils version.

The review of these changes included test cases that have already
been committed for the functionality that existed before.
Another test script is added to cover the coreutils compatible
extension implemented by this patch.

This commit contains a tests/Makefile that has been cleaned up
compared to the review version, using an implicit rule to apply the
TESTBASE path at build time (and the scripts have been renamed to
have an extension of .SH instead of .sh to trigger this rule).

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

(cherry picked from commit 84f35b6f86efd004a8f25ef6eecea0f5d02733c4)
(cherry picked from commit c2870e576bd20872ed227375a862e0330ef90ad8)

3 years agomd5: portability fix -- include stdbool.h explicitly
Warner Losh [Thu, 20 May 2021 17:26:46 +0000 (11:26 -0600)]
md5: portability fix -- include stdbool.h explicitly

stdbool.h needs to be included to use type bool variables. Due to
namespace pollution, this gets brought in on FreeBSD, but not on
other systems. Include it explicilty.

Noticed by: arichards@
Sponsored by: Netflix

(cherry picked from commit d0ea5e467f3c44909667c5ee90c3d26653fb6687)

3 years agomd5: Create md5sum, etc compatible programs
Warner Losh [Wed, 19 May 2021 17:26:20 +0000 (11:26 -0600)]
md5: Create md5sum, etc compatible programs

On Linux, there's a similar set of programs to ours, but that end in the
letters 'sum'. These act basically like FreeBSD versions run with the -r
option. Add code so that when the program ends in 'sum' you get the
linux -r behavior. This is enough to make most things that use sha*sum
work correctly (the -c / --check options, as well as the long args are
not implemented). When running with the -sum programs, ignore -t instead
of running internal speed tests and make -c an error.

Reviewed by: sef, and kp and allanjude (earlier version)
Relnotes: yes
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D30309

(cherry picked from commit 086feed850c31c278f25c958b97992d024139896)

3 years agobhyve: add SMBIOS Baseboard Information
Chuck Tuffli [Mon, 12 Apr 2021 15:09:52 +0000 (08:09 -0700)]
bhyve: add SMBIOS Baseboard Information

Add the System Management BIOS Baseboard (or Module) Information
a.k.a. Type 2 structure to the SMBIOS emulation.

(cherry picked from commit 0c6282e842b33a1c86e01b27fc40af9c76fd404e)

3 years agovirtio_blk: Fix issuing T_GET_ID before DRIVER_OK status
Ka Ho Ng [Wed, 5 May 2021 15:16:29 +0000 (23:16 +0800)]
virtio_blk: Fix issuing T_GET_ID before DRIVER_OK status

DRIVER_OK status is set after device_attach() succeeds. For now postpone
disk_create to attach_completed() method.

Sponsored by: The FreeBSD Foundation
Reviewed by: grehan
Approved by: lwhsu (mentor)
Differential Revision: https://reviews.freebsd.org/D30049

(cherry picked from commit 4e1e1d667fc84460c131dfe617b39072e87473ab)

3 years agobhyve: implement rdmsr for MSR_IA32_FEATURE_CONTROL
Corvin Köhne [Thu, 15 Apr 2021 03:49:19 +0000 (13:49 +1000)]
bhyve: implement rdmsr for MSR_IA32_FEATURE_CONTROL

Without the -w option, Windows guests crash on boot. This is caused by a rdmsr
of MSR_IA32_FEATURE_CONTROL. Windows checks this MSR to determine enabled VMX
features. This MSR isn't emulated in bhyve, so a #GP exception is injected
which causes Windows to crash.

Fix by returning a rdmsr of MSR_IA32_FEATURE_CONTROL with Lock Bit set and
VMX disabled to informWindows that VMX isn't available.

(cherry picked from commit 17d214c2ca9f110db3fa2a10d6b448d624e87774)

3 years agosbin/md5: add tests
Stefan Eßer [Fri, 25 Jun 2021 06:51:40 +0000 (08:51 +0200)]
sbin/md5: add tests

While the correctness of the supported hash algorithms can be tested
with the built-in self-test feature, these test cases are meant to
detect changes in the output format.

A follow-up commit will improve the compatibility with the coreutils
versions of the hash programs, and these tests should detect any
unintended side-effects of such a change on existing functionality.

(cherry picked from commit 884fc5527a3ffd9830b941cbec328de1623044cc)

sbin/md5: Create /usr/tests/sbin/md5 directory for placing tests

(Fix by lwhsu (Li-Wen Hsu) to un-break "make distribute".)

(cherry picked from commit cb194afef50dc4e1473413a69462aaf03cfe0ce4)

sbin/md5: fix test case to not write outside temp directory

The bsd-p-test did create files 1.out .. 8.out in the test directory.
This has been fixed and the temporary output files are now written
to the temporary directory.

(cherry picked from commit 95d3044bbdadfca6120a3e7c61c9ebb9a476f369)

Sponsored by: The FreeBSD Foundation (commit cb194afef50dc only)

3 years agoUPDATING: Add entry for commit 841006678745
Rick Macklem [Sat, 26 Jun 2021 23:20:19 +0000 (16:20 -0700)]
UPDATING: Add entry for commit 841006678745

This is a direct commit.

3 years agoparam.h: Bump __FreeBSD_version to 1300510 for commit 841006678745
Rick Macklem [Sat, 26 Jun 2021 23:13:49 +0000 (16:13 -0700)]
param.h: Bump __FreeBSD_version to 1300510 for commit 841006678745

Commit 841006678745 changed the internal KAPI between the krpc
and nfsd modules.  As such, they must both be rebuilt from
sources.

This is a direct commit.

3 years agokrpc: Acquire ref count of CLIENT for backchannel use
Rick Macklem [Fri, 11 Jun 2021 23:57:14 +0000 (16:57 -0700)]
krpc: Acquire ref count of CLIENT for backchannel use

Michael Dexter <editor@callfortesting.org> reported
a crash in FreeNAS, where the first argument to
clnt_bck_svccall() was no longer valid.
This argument is a pointer to the callback CLIENT
structure, which is free'd when the associated
NFSv4 ClientID is free'd.

This appears to have occurred because a callback
reply was still in the socket receive queue when
the CLIENT structure was free'd.

This patch acquires a reference count on the CLIENT
that is not CLNT_RELEASE()'d until the socket structure
is destroyed. This should guarantee that the CLIENT
structure is still valid when clnt_bck_svccall() is called.
It also adds a check for closed or closing to
clnt_bck_svccall() so that it will not process the callback
RPC reply message after the ClientID is free'd.

(cherry picked from commit e1a907a25cfa422c0d1acaf9f91352ada04f4bca)

3 years agonfscl: Add a "has acquired a delegation" flag for delegations
Rick Macklem [Wed, 9 Jun 2021 15:00:43 +0000 (08:00 -0700)]
nfscl: Add a "has acquired a delegation" flag for delegations

A problem was reported via email, where a large (130000+) accumulation
of NFSv4 opens on an NFSv4 mount caused significant lock contention
on the mutex used to protect the client mount's open/lock state.
Although the root cause for the accumulation of opens was not
resolved, it is obvious that the NFSv4 client is not designed to
handle 100000+ opens efficiently.

For a common case where delegations are not being issued by the
NFSv4 server, the code acquires the mutex lock for open/lock state,
finds the delegation list empty and just unlocks the mutex and returns.
This patch adds an NFS mount point flag that is set when a delegation
is issued for the mount.  Then the patched code checks for this flag
before acquiring the open/lock mutex, avoiding the need to acquire
the lock for the case where delegations are not being issued by the
NFSv4 server.
This change appears to be performance neutral for a small number
of opens, but should reduce lock contention for a large number of opens
for the common case where server is not issuing delegations.

This commit should not affect the high level semantics of delegation
handling.

(cherry picked from commit 5e5ca4c8fc53d31bf71e182e08c4ccd8290428c7)

3 years agonfscl: Fix generation of va_fsid for a tree of NFSv4 server file systems
Rick Macklem [Mon, 7 Jun 2021 20:48:25 +0000 (13:48 -0700)]
nfscl: Fix generation of va_fsid for a tree of NFSv4 server file systems

Pre-r318997 the code looked like:
if (vp->v_mount->mnt_stat.f_fsid.val[0] != (uint32_t)np->n_vattr.na_filesid[0])
         vap->va_fsid = (uint32_t)np->n_vattr.na_filesid[0];
Doing this assignment got lost by r318997 and, as such, NFSv4 mounts
of servers with trees of file systems on the server is broken, due to duplicate
fileno values for the same st_dev/va_fsid.

Although I could have re-introduced the assignment, since the value of
na_filesid[0] is not guaranteed to be unique across the server file systems,
I felt it was better to always do the hash for na_filesid[0,1].
Since dev_t (st_dev/va_fsid) is now 64bits, I switched to a 64bit hash.

There is a slight chance of a hash conflict where 2 different na_filesid
values map to same va_fsid, which will be documented in the BUGS
section of the man page for mount_nfs(8).  Using a table to keep track
of mappings to catch conflicts would not easily scale to 10,000+ server file
systems and, when the conflict occurs, it only results in fts(3) reporting
a "directory cycle" under certain circumstances.

(cherry picked from commit 03c81af24920e14bd977f34edcd3eb7fb122db19)

3 years agonfsd: Fix NFSv4.1/4.2 Secinfo_no_name when security flavors empty
Rick Macklem [Sat, 5 Jun 2021 03:31:20 +0000 (20:31 -0700)]
nfsd: Fix NFSv4.1/4.2 Secinfo_no_name when security flavors empty

Commit 947bd2479ba9 added support for the Secinfo_no_name operation.
When a non-exported file system is being traversed, the list of
security flavors is empty.  It turns out that the Linux client
mount attempt fails when the security flavors list in the
Secinfo_no_name reply is empty.

This patch modifies Secinfo/Secinfo_no_name so that it replies
with all four security flavors when the list is empty.
This fixes Linux NFSv4.1/4.2 mounts when the file system at
the NFSv4 root (as specified on a V4: exports(5) line) is
not exported.

(cherry picked from commit 56e9d8e38e7eed84901acddca24170eb352d2ed6)

3 years agonfsd: Fix when NFSERR_WRONGSEC may be replied to NFSv4 clients
Rick Macklem [Sat, 5 Jun 2021 23:53:07 +0000 (16:53 -0700)]
nfsd: Fix when NFSERR_WRONGSEC may be replied to NFSv4 clients

Commit d224f05fcfc1 pre-parsed the next operation number for
the put file handle operations.  This patch uses this next
operation number, plus the type of the file handle being set by
the put file handle operation, to implement the rules in RFC5661
Sec. 2.6 with respect to replying NFSERR_WRONGSEC.

This patch also adds a check to see if NFSERR_WRONGSEC should be
replied when about to perform Lookup, Lookupp or Open with a file
name component, so that the NFSERR_WRONGSEC reply is done for
these operations, as required by RFC5661 Sec. 2.6.

This patch does not have any practical effect for the FreeBSD NFSv4
client and I believe that the same is true for the Linux client,
since NFSERR_WRONGSEC is considered a fatal error at this time.

(cherry picked from commit a5df139ec614c34f505bce9de3447fe7b49016e6)

3 years agonfsd: Pre-parse the next NFSv4 operation number for put FH operations
Rick Macklem [Fri, 4 Jun 2021 03:48:26 +0000 (20:48 -0700)]
nfsd: Pre-parse the next NFSv4 operation number for put FH operations

RFC5661 Sec. 2.6 specifies when a NFSERR_WRONGSEC error reply can be done.
For the four operations PutFH, PutrootFH, PutpublicFH and RestoreFH,
NFSERR_WRONGSEC can or cannot be replied, depending upon what operation
follows one of these operations in the compound.

This patch modifies nfsrvd_compound() so that it parses the next operation
number before executing any of the above four operations, storing it in
"nextop".

A future commit will implement use of "nextop" to decide if NFSERR_WRONGSEC
can be replied for the above four operations.

This commit should not change the semantics of performing the compound RPC.

(cherry picked from commit d224f05fcfc13725c43ea0a02d511b3bf6a8ad14)

3 years agonfsd: Fix the failure return for non-fh NFSv4 operations
Rick Macklem [Wed, 2 Jun 2021 22:28:07 +0000 (15:28 -0700)]
nfsd: Fix the failure return for non-fh NFSv4 operations

Without this patch, nfsd_checkrootexp() returns failure
and then the NFSv4 operation would reply NFSERR_WRONGSEC.
RFC5661 Sec. 2.6 only allows a few NFSv4 operations, none
of which call nfsv4_checktootexp(), to return NFSERR_WRONGSEC.
This patch modifies nfsd_checkrootexp() to return the
error instead of a boolean and sets the returned error to an RPC
layer AUTH_ERR, as discussed on nfsv4@ietf.org.
The patch also fixes nfsd_errmap() so that the pseudo
error NFSERR_AUTHERR is handled correctly such that an RPC layer
AUTH_ERR is replied to the NFSv4 client.

The two new "enum auth_stat" values have not yet been assigned
by IANA, but are the expected next two values.

The effect on extant NFSv4 clients of this change appears
limited to reporting a different failure error when a
mount that does not use adequate security is attempted.

(cherry picked from commit 984c71f90300906e106b9714af0e7d9b542c50e6)

3 years agonfsd: Delete extraneous NFSv4 root checks
Rick Macklem [Tue, 1 Jun 2021 02:41:17 +0000 (19:41 -0700)]
nfsd: Delete extraneous NFSv4 root checks

There are several NFSv4.1/4.2 server operation functions which
have unneeded checks for the NFSv4 root being set up.
The checks are not needed because the operations always follow
a Sequence operation, which performs the check.

This patch deletes these checks, simplifying the code so
that a future patch that fixes the checks to conform with
RFC5661 Sec. 2.6 will be less extension.

(cherry picked from commit 1d4afcaca282f4ba249d8508f4149d9c0b058492)

3 years agonfsd: Add support for the NFSv4.1/4.2 Secinfo_no_name operation
Rick Macklem [Mon, 31 May 2021 00:52:43 +0000 (17:52 -0700)]
nfsd: Add support for the NFSv4.1/4.2 Secinfo_no_name operation

The Linux client is now attempting to use the Secinfo_no_name
operation for NFSv4.1/4.2 mounts.  Although it does not seem to
mind the NFSERR_NOTSUPP reply, adding support for it seems
reasonable.

I also noticed that "savflag" needed to be 64bits in
nfsrvd_secinfo() since nd_flag in now 64bits, so I changed
the declaration of it there.  I also added code to set "vp" NULL
after performing Secinfo/Secinfo_no_name, since these
operations consume the current FH, which is represented
by "vp" in nfsrvd_compound().

Fixing when the server replies NFSERR_WRONGSEC so that
it conforms to RFC5661 Sec. 2.6 still needs to be done
in a future commit.

(cherry picked from commit 947bd2479ba9661a99f2415038e7b5fa972ec843)

3 years agoamd64: typo fix: memcmpy -> memcmp in a comment
Mateusz Guzik [Sat, 26 Jun 2021 03:57:47 +0000 (05:57 +0200)]
amd64: typo fix: memcmpy -> memcmp in a comment

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

(cherry picked from commit 9a8e4527f07dbb356bb1942efc09888f957df056)

3 years agozfs: merge openzfs/zfs@aee26af27 (zfs-2.1-release) into stable/13
Martin Matuska [Sat, 26 Jun 2021 11:37:50 +0000 (13:37 +0200)]
zfs: merge openzfs/zfs@aee26af27 (zfs-2.1-release) into stable/13

Notable upstream pull request merges:
  #12172 Use wmsum for arc, abd, dbuf and zfetch statistics
  #12227 Revert Consolidate arc_buf allocation checks
  #12273 zfs_metaslab_mem_limit should be 25 instead of 75
  #12266 Fix flag copying in resume case
  #12276 Update cache file when setting compatibility property

Obtained from: OpenZFS
OpenZFS commit: aee26af277c91abeb0e1cfe27cc48cc328fdb881

3 years agopf: store L4 headers in pf_pdesc
Kristof Provost [Fri, 4 Jun 2021 08:52:07 +0000 (10:52 +0200)]
pf: store L4 headers in pf_pdesc

Rather than pointers to the headers store full copies. This brings us
slightly closer to what OpenBSD does, and also makes more sense than
storing pointers to stack variable copies of the headers.

Reviewed by: donner, scottl
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30719

(cherry picked from commit d38630f6192a40934912fbffc52c9650776c2b53)

3 years agopf: Mark struct pf_pdesc as kernel only
Kristof Provost [Wed, 3 Mar 2021 09:28:14 +0000 (10:28 +0100)]
pf: Mark struct pf_pdesc as kernel only

This structure is only used by the kernel module internally. It's not
shared with user space, so hide it behind #ifdef _KERNEL.

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

(cherry picked from commit 29698ed904737ebfd139a21e39e5421cf81badd8)

3 years agoFix scripted installation from media without local distfiles.
Nathan Whitehorn [Fri, 28 May 2021 13:53:42 +0000 (09:53 -0400)]
Fix scripted installation from media without local distfiles.

The bsdinstall script target did not have the infrastructure to fetch
distfiles from a remote server the way the interactive installer does
on e.g. bootonly media. Solve this by factoring out the parts of the
installer that deal with fetching missing distributions into a new
install stage called 'fetchmissingdists', which is called by both the
interactive and scripted installer frontends.

In the course of these changes, cleaned up a few other issues with
the fetching of missing distribution files and added a warning if
fetching the MANIFEST file, which is used to verify the integrity of
the distribution files. We should at some point add cryptographic
signatures to MANIFEST so that it can be fetched safely if not present
on the install media (which it is for bootonly media).

Initial patch by: Vinícius Zavam
PR: 255659, 250928
Reviewed by: dteske
MFC after: 4 weeks
Differential Revision: https://reviews.freebsd.org/D27121

(cherry picked from commit 40923b0c81cc2c151388ec5ead59f4bed89ac432)

3 years agoWork around bogus old gcc "initializer element is not constant" error
Dimitry Andric [Fri, 25 Jun 2021 18:42:38 +0000 (20:42 +0200)]
Work around bogus old gcc "initializer element is not constant" error

After df3b437c1e073eb83e9a93af1c417f3ee8d0de3b, older gcc's such as
4.2.1 (still used on earlier branches for e.g. mips and powerpc) and
6.3.0 (still used for some cross-builds) started throwing bogus errors
like:

In file included from /workspace/src/lib/msun/src/s_llround.c:11:0:
/workspace/src/lib/msun/src/s_lround.c:54:31: error: initializer element is not constant
 static const type dtype_min = type_min - 0.5;
                               ^~~~~~~~
/workspace/src/lib/msun/src/s_lround.c:55:31: error: initializer element is not constant
 static const type dtype_max = type_max + 0.5;
                               ^~~~~~~~

Since 'type_min' and 'type_max' are constants declared just above these
lines this error is nonsensical, but older gcc's are not smart enough.

Work around the error by reusing the (type)DTYPE_MIN and (type)DTYPE_MAX
macros, so I can MFC this right away, unbreaking a few stable builds.

(cherry picked from commit 0bcd49c13ada1461bcea85e0466811ddcb290b5e)

3 years agoFix failures in libm's lround_test after clang 12 import
Dimitry Andric [Tue, 22 Jun 2021 16:38:27 +0000 (18:38 +0200)]
Fix failures in libm's lround_test after clang 12 import

It turned out that the (type)DTYPE_MAX conversions at the top of
s_lround.c are now emitted as cvtsi2sd instructions, at least on SSE
capable CPUs. This caused the FE_INEXACT flag to always be set, at least
for the double and float variants. Under clang 11, the whole INRANGE()
comparisons were still optimized away, but this has "improved" in clang
12, due to stricter adherence to the -ffp-exception-behavior=maytrap
compiler flag.

To avoid run-time integer to float conversions, use static constants
instead, so they are computed at compile time, and the INRANGE()
statements are optimized away again, if applicable.

While here, use an integer instead of a floating type to store the test
results in lround_test.c, as this is more appropriate, and we can also
drop the volatile hack.

Reported by: arichardson

(cherry picked from commit df3b437c1e073eb83e9a93af1c417f3ee8d0de3b)

3 years agoDisable llvm generating 128-bit multiply libcalls on 32-bit ARM
Dimitry Andric [Tue, 22 Jun 2021 20:26:13 +0000 (22:26 +0200)]
Disable llvm generating 128-bit multiply libcalls on 32-bit ARM

Merge commit 789708617d20 from llvm git (Koutheir Attouchi):

  Do not generate calls to the 128-bit function __multi3() on 32-bit ARM

  Re-applying this patch after bots failures. Should be fine now.

  The function __multi3() is undefined on 32-bit ARM, so a call to it should
  never be emitted. Instead, plain instructions need to be generated to
  perform 128-bit multiplications.

  Differential Revision: https://reviews.llvm.org/D103906

Reported by: mmel

(cherry picked from commit 014a40f8f643a5dad6a6ba5c4bf6ea5d4f445fe6)

3 years agoFix clang assertion while building recent www/chromium
Dimitry Andric [Mon, 21 Jun 2021 18:46:34 +0000 (20:46 +0200)]
Fix clang assertion while building recent www/chromium

Merge commit c8227f06b335 from llvm git (by Arthur Eubanks):

  [clang] Don't assert in EmitAggregateCopy on trivial_abi types

  Fixes PR42961.

  Reviewed By: rnk

  Differential Revision: https://reviews.llvm.org/D97872

PR: 256721, 255570
Reported by: jbeich

(cherry picked from commit e7e517981a6591c79fb49cd8810361b0f3ad5983)

3 years agoConsolidate machine/endian.h definitions
Mitchell Horne [Mon, 1 Mar 2021 15:07:54 +0000 (11:07 -0400)]
Consolidate machine/endian.h definitions

This change serves two purposes.

First, we take advantage of the compiler provided endian definitions to
eliminate some long-standing duplication between the different versions
of this header. __BYTE_ORDER__ has been defined since GCC 4.6, so there
is no need to rely on platform defaults or e.g. __MIPSEB__ to determine
endianness. A new common sub-header is added, but there should be no
changes to the visibility of these definitions.

Second, this eliminates the hand-rolled __bswapNN() routines, again in
favor of the compiler builtins. This was done already for x86 in
e6ff6154d203. The benefit here is that we no longer have to maintain our
own implementations on each arch, and can instead rely on the compiler
to emit appropriate instructions or libcalls, as available. This should
result in equivalent or better code generation. Notably 32-bit arm will
start using the `rev` instruction for these routines, which is available
on armv6+.

PR: 236920
Reviewed by: arichardson, imp
Tested by: bdragon (BE powerpc)
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D29012

(cherry picked from commit 720dc6bcb5a8c4283802576e2ef54f42b33fa8d4)

3 years agoUpdate cache file when setting compatibility property
Brian Behlendorf [Thu, 24 Jun 2021 21:30:02 +0000 (14:30 -0700)]
Update cache file when setting compatibility property

Unlike most other properties the 'compatibility' property is stored
in the pool config object and not the DMU_OT_POOL_PROPS object.

This had the advantage that the compatibility information is available
without needing to fully import the pool (it can be read with zdb).
However, this means we need to make sure to update both the copy of
the config in the MOS and the cache file.  This wasn't being done.

This commit adds a call to spa_async_request() to ensure the copy of
the config in the cache file gets updated as well as the one stored
in the pool.  This same change is made for the 'comment' property
which suffers from the same inconsistency.

Reviewed-by: Sean Eric Fagan <sef@ixsystems.com>
Reviewed-by: Colm Buckley <colm@tuatha.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #12261
Closes #12276

3 years agoFix flag copying in resume case
Paul Dagnelie [Thu, 24 Jun 2021 19:42:01 +0000 (12:42 -0700)]
Fix flag copying in resume case

A couple flags weren't being copied in the case where we're doing size
estimation on a resume.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Signed-off-by: Paul Dagnelie <pcd@delphix.com>
Closes: #12266
3 years agozfs_metaslab_mem_limit should be 25 instead of 75
jumbi77 [Thu, 24 Jun 2021 17:02:54 +0000 (19:02 +0200)]
zfs_metaslab_mem_limit should be 25 instead of 75

According to current zfs man page zfs_metaslab_mem_limit should be
25 instead of 75.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Mark Maybee <mark.maybee@delphix.com>
Signed-off-by: jumbi77@users.noreply.github.com
Closes #12273

3 years agoStop using "zstreamdump" in tests/
Rich Ercolani [Thu, 24 Jun 2021 16:38:33 +0000 (12:38 -0400)]
Stop using "zstreamdump" in tests/

zstreamdump was replaced with "zstream dump"; let's stop using the
old name, compat symlink or no.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #12277

3 years agoUpdate libera webchat client URL
Jonathon [Thu, 24 Jun 2021 00:14:58 +0000 (00:14 +0000)]
Update libera webchat client URL

Libera have made a webchat client available. This change builds on #12127.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Jonathon Fernyhough <jonathon@m2x.dev>
Closes #12251

3 years agogcc 11 cleanup
Attila Fülöp [Wed, 23 Jun 2021 23:57:06 +0000 (01:57 +0200)]
gcc 11 cleanup

Compiling with gcc 11.1.0 produces three new warnings.
Change the code slightly to avoid them.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Signed-off-by: Attila Fülöp <attila@fueloep.org>
Closes #12130
Closes #12188
Closes #12237

3 years agoZTS: Add known exceptions
Brian Behlendorf [Wed, 23 Jun 2021 22:53:13 +0000 (15:53 -0700)]
ZTS: Add known exceptions

The receive-o-x_props_override test case reliably fails on the
FreeBSD main builders (but not on Linux), until the root cause is
understood add this test to the FreeBSD exception list.

On Linux the alloc_class_012_pos test case may occasionally fail.
This is a known false positive which has also been added to the
Linux exception list until the test can be made entirely reliable.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #12272

3 years agoAnnotated dprintf as printf-like
Rich Ercolani [Wed, 23 Jun 2021 04:53:45 +0000 (00:53 -0400)]
Annotated dprintf as printf-like

ZFS loves using %llu for uint64_t, but that requires a cast to not
be noisy - which is even done in many, though not all, places.
Also a couple places used %u for uint64_t, which were promoted
to %llu.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #12233

3 years agoRevert Consolidate arc_buf allocation checks
Antonio Russo [Wed, 23 Jun 2021 04:39:15 +0000 (22:39 -0600)]
Revert Consolidate arc_buf allocation checks

This reverts commit 13fac09868b4e4e08cc3ef7b937ac277c1c407b1.

Per the discussion in #11531, the reverted commit---which intended only
to be a cleanup commit---introduced a subtle, unintended change in
behavior.

Care was taken to partially revert and then reapply 10b3c7f5e4
which would otherwise have caused a conflict.  These changes were
squashed in to this commit.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Suggested-by: @chrisrd
Suggested-by: robn@despairlabs.com
Signed-off-by: Antonio Russo <aerusso@aerusso.net>
Closes #11531
Closes #12227

3 years agoUse wmsum for arc, abd, dbuf and zfetch statistics. (#12172)
Alexander Motin [Thu, 17 Jun 2021 00:19:34 +0000 (20:19 -0400)]
Use wmsum for arc, abd, dbuf and zfetch statistics. (#12172)

wmsum was designed exactly for cases like these with many updates
and rare reads.  It allows to completely avoid atomic operations on
congested global variables.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Mark Maybee <mark.maybee@delphix.com>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored-By: iXsystems, Inc.
Closes #12172

3 years agojail: Don't allow substitution of valueless jail parameters.
Jamie Gritton [Fri, 18 Jun 2021 16:44:37 +0000 (09:44 -0700)]
jail: Don't allow substitution of valueless jail parameters.
PR: 256544
Reported by: cryptogranny at gmail.com

(cherry picked from commit 5bf6dca2c6dbf63d382e97905e205ded3e8525d2)

3 years agodtrace: fix an out of bound read and a NULL pointer increment
Domagoj Stolfa [Thu, 17 Jun 2021 17:35:33 +0000 (13:35 -0400)]
dtrace: fix an out of bound read and a NULL pointer increment

In dt_cc.c when the provider is an empty string, accessing
strlen(pdp->dtpd_provider) - 1 will result in a pdp->dtpd_provider[-1]
access.

Similarly, in dt_ident.c, if p2 is a NULL pointer, doing a p2++ on it is
undefined behaviour.

Reviewed by: markj
Sponsored by: Google

(cherry picked from commit a877965fa3da218bceaaa0f51c4d7770e64e6df0)

3 years agoamd64 efirt: initialize vm_pages backing EFI runtime memory
Konstantin Belousov [Wed, 16 Jun 2021 01:59:06 +0000 (04:59 +0300)]
amd64 efirt: initialize vm_pages backing EFI runtime memory

(cherry picked from commit 0247c33e89adaf0c7159b847ef7bae9566e55395)

3 years agoUn-staticise vm_page_init_page()
Konstantin Belousov [Thu, 17 Jun 2021 10:58:13 +0000 (13:58 +0300)]
Un-staticise vm_page_init_page()

(cherry picked from commit 5b10e79edba561270001c097fbffcf05d07e9a4a)

3 years agobsnmp: Fix incorrect use of libpfctl
Kristof Provost [Tue, 15 Jun 2021 08:50:32 +0000 (10:50 +0200)]
bsnmp: Fix incorrect use of libpfctl

When we introduced libpfctl in bnsmpd this was done incorrectly, and a
GETRULE call was replaced by pfctl_add_rule().
Change it to pfctl_get_rule().

Reviewed by: donner
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 67cef6d411cef0c3dfcf768ff890b4f97cf513b6)

3 years agokern.mk: fix -Wno-error style to fix build with Clang 12
Greg V [Wed, 10 Mar 2021 22:17:09 +0000 (17:17 -0500)]
kern.mk: fix -Wno-error style to fix build with Clang 12

Clang 12 no longer supports -Wno-error-..., only the -Wno-error=...
style (which is already used everywhere else in the tree).

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

(cherry picked from commit 15565e0a2177f53b086609fecd48991c52dad5eb)

3 years agolibspl: fix NO_CLEAN build
Warner Losh [Tue, 8 Jun 2021 23:56:15 +0000 (17:56 -0600)]
libspl: fix NO_CLEAN build

atomic.S moved to atomic.c, update the cleaup script to remove stale
dependencies for this.

Sponsored by: Netflix

(cherry picked from commit dbbf7cb21ce3e40c9f96a24601fdc536b6e32aca)

3 years agozfs: merge openzfs/zfs@9a865b7fb (zfs-2.1-release) into stable/13
Martin Matuska [Tue, 22 Jun 2021 07:16:24 +0000 (09:16 +0200)]
zfs: merge openzfs/zfs@9a865b7fb (zfs-2.1-release) into stable/13

Notable upstream pull request merges:
  #11904 libspl: implement atomics in terms of atomics

Obtained from: OpenZFS
OpenZFS commit: 9a865b7fb70f44e988f59b31b38eabafe363d6f8

3 years agolibspl: implement atomics in terms of atomics
наб [Mon, 19 Apr 2021 05:13:24 +0000 (07:13 +0200)]
libspl: implement atomics in terms of atomics

This replaces the generic libspl atomic.c atomics implementation
with one based on builtin gcc atomics.  This functionality was added
as an experimental feature in gcc 4.4.  Today even CentOS 7 ships
with gcc 4.8 as the default compiler we can make this the default.

Furthermore, the builtin atomics are as good or better than our
hand-rolled implementation so it's reasonable to drop that custom code.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11904
Closes #12252
Closes #12244

3 years agoAdd quirks for Linux ABI signals handling
Konstantin Belousov [Sat, 5 Jun 2021 18:18:21 +0000 (21:18 +0300)]
Add quirks for Linux ABI signals handling

(cherry picked from commit 870e197d52c1cb8c3ed6d04ddae34dcae57cb657)

3 years agoAdd a knob to disable dequeueing SIGCHLD on waiting for live process
Konstantin Belousov [Sat, 5 Jun 2021 18:24:35 +0000 (21:24 +0300)]
Add a knob to disable dequeueing SIGCHLD on waiting for live process

(cherry picked from commit a12e901a5a65417849c1ccf1e37b8d092fa438da)

3 years agoAdd a knob to not drop signal with default ignored or ignored actions
Konstantin Belousov [Sat, 5 Jun 2021 12:42:27 +0000 (15:42 +0300)]
Add a knob to not drop signal with default ignored or ignored actions

(cherry picked from commit bc38762474caed2d41d2562e28f56aa211f47ceb)

3 years agosigwait: add comment explaining EINTR/ERESTART details
Konstantin Belousov [Mon, 7 Jun 2021 14:59:41 +0000 (17:59 +0300)]
sigwait: add comment explaining EINTR/ERESTART details

(cherry picked from commit acced8b043c5df0ebd51934bca6dcae3322cf890)

3 years agosigwait(2) and sigtimedwait(2) must not be restarted.
Konstantin Belousov [Sun, 6 Jun 2021 23:00:10 +0000 (02:00 +0300)]
sigwait(2) and sigtimedwait(2) must not be restarted.

(cherry picked from commit afb36e289c1d96053b6063b0e548fc7d31dbd239)

3 years agoi386: Add "options HYPERV" to NOTES
Mark Johnston [Wed, 9 Jun 2021 12:58:45 +0000 (08:58 -0400)]
i386: Add "options HYPERV" to NOTES

This unbreaks the LINT build.

Fixes: 97993d1ebf
Reported by: mjg

(cherry picked from commit 334335cb14d4754d45265d19cd3c6e7708cca0c1)

3 years agohyperv: Fix vmbus after the i386 4/4 split
Mark Johnston [Tue, 8 Jun 2021 13:40:30 +0000 (09:40 -0400)]
hyperv: Fix vmbus after the i386 4/4 split

The vmbus ISR needs to live in a trampoline.  Dynamically allocating a
trampoline at driver initialization time poses some difficulties due to
the fact that the KENTER macro assumes that the offset relative to
tramp_idleptd is fixed at static link time.  Another problem is that
native_lapic_ipi_alloc() uses setidt(), which assumes a fixed trampoline
offset.

Rather than fight this, move the Hyper-V ISR to i386/exception.s.  Add a
new HYPERV kernel option to make this optional, and configure it by
default on i386.  This is sufficient to make use of vmbus(4) after the
4/4 split.  Note that vmbus cannot be loaded dynamically and both the
HYPERV option and device must be configured together.  I think this is
not too onerous a requirement, since vmbus(4) was previously
non-functional.

Reported by: Harry Schmalzbauer <freebsd@omnilan.de>
Tested by: Harry Schmalzbauer <freebsd@omnilan.de>
Reviewed by: whu, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 97993d1ebf592ac6689a498d5d0d2afb46758680)

3 years agoExport various 128 bit long double functions from libgcc_s.so.1
Dimitry Andric [Mon, 14 Jun 2021 19:17:05 +0000 (21:17 +0200)]
Export various 128 bit long double functions from libgcc_s.so.1

These were already compiled for some time on aarch64 and riscv, by
including lib/libcompiler_rt/Makefile.inc, but never exported in the
shared library. Since gcc exports these under version GCC_4.6.0, we do
the same.

This review should replace D11482 for now. For e.g. amd64 more work is
still to be done, as compiler-rt does not seem to support 128 bit long
double math for that architecture.

Reviewed by: cem
Differential Revision: https://reviews.freebsd.org/D28690

(cherry picked from commit 790a6be5a1699291c6da87871426d0c56dedcc89)

3 years agoConsistently use the SOCKBUF_MTX() and SOCK_MTX() macros
Mark Johnston [Mon, 14 Jun 2021 21:32:32 +0000 (17:32 -0400)]
Consistently use the SOCKBUF_MTX() and SOCK_MTX() macros

This makes it easier to change the socket locking protocols.  No
functional change intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit a100217489405e5926230c50d97aa3f886df5385)

3 years agoConsistently use the SOLISTENING() macro
Mark Johnston [Mon, 14 Jun 2021 21:32:27 +0000 (17:32 -0400)]
Consistently use the SOLISTENING() macro

Some code was using it already, but in many places we were testing
SO_ACCEPTCONN directly.  As a small step towards fixing some bugs
involving synchronization with listen(2), make the kernel consistently
use SOLISTENING().  No functional change intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit f4bb1869ddd2bca89b6b6bfaf4d866efdd9243cf)

3 years agoamd64: Fix propagation of LDT updates
Mark Johnston [Mon, 14 Jun 2021 21:32:18 +0000 (17:32 -0400)]
amd64: Fix propagation of LDT updates

When a process has used sysarch(2) to specify descriptors for its
private LDT, upon rfork(RFMEM) descriptors are copied into the new child
process.  Any updates to the descriptors are thus reflected to all other
processes sharing the vmspace.  However, this is incorrect in the rather
obscure case where the child process was created before the LDT was
modified.  Fix this by only modifying other processes which already
share the LDT.

Reported by: syzkaller
Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 70dd5eebc025badb7b835dfee3915d8b5f1e7468)

3 years agocpucontrol: fix extended signature matching code to avoid fallthough
Dan Nelson [Mon, 14 Jun 2021 19:28:16 +0000 (15:28 -0400)]
cpucontrol: fix extended signature matching code to avoid fallthough

PR: 256502

(cherry picked from commit 87799c5f85dc0aed7e53ca841504e3b2ffc88498)

3 years agostand: Fix __elfN(loadimage) return value
Mark Johnston [Sun, 6 Jun 2021 20:40:25 +0000 (16:40 -0400)]
stand: Fix __elfN(loadimage) return value

Caller functions expect __elfN(loadimage) to return a value of zero on
failure and the file size on success.

PR: 256390
Reviewed by: markj

(cherry picked from commit 1ea87e2a70c31454a8696ab2979d13d21c5575d2)

3 years agozfs: merge openzfs/zfs@3de7aeb68 (zfs-2.1-release) into stable/13
Martin Matuska [Sun, 20 Jun 2021 13:16:16 +0000 (15:16 +0200)]
zfs: merge openzfs/zfs@3de7aeb68 (zfs-2.1-release) into stable/13

Notable upstream pull request merges:
  #12054 Avoid deadlock when removing L2ARC devices under I/O
  #12221 vdev_draid_min_asize() ignores reserved space

Obtained from: OpenZFS
OpenZFS commit: 3de7aeb68ac1cc1fedd99506671d9028ad1a3c20

3 years agotests: Revise FIB lookups per second benchmarking routines
Marko Zec [Thu, 17 Jun 2021 06:49:09 +0000 (08:49 +0200)]
tests: Revise FIB lookups per second benchmarking routines

Fix a bug in the LPM SEQ benchmark (missing break inside a switch block)
by restructuring the test loop, while introducing additional two
synthetic test options:

ANN: scan only the address space announced in current RIB
REP: repeat lookups over several keys in a sliding window scheme

The total of eight combinations of test options are now available
through dedicated sysctl hooks.

Differential Revision: <https://reviews.freebsd.org/D30311>
Reviewed by: melifaro
MFC after: 3 days

(cherry picked from commit b6f8436b094daf7b1c429ce74997a4daf6994fcb)

3 years agoRevise FIB lookups per second benchmarking routines.
Marko Zec [Wed, 5 May 2021 10:28:17 +0000 (12:28 +0200)]
Revise FIB lookups per second benchmarking routines.

Add a LPS benchmark variant which introduces artificial dependencies
between successive lookups. While here, instead of writing the results
from the lookups to a huge array, add them to an accumulator, in a more
lightweight attempt at preventing the CPU's OOO machinery from
discarding the lookup results if they would be completely unused.

net.route.test.run_lps_rnd measures LPS throughput with independent
uniformly random keys

net.route.test.run_lps_seq measures LPS throughput with uniformly
random keys with artificial interdependencies
Reviewed by: melifaro
MFC after: 7 days
Differential Revision: https://reviews.freebsd.org/D30096

(cherry picked from commit a43104ebe7630111d7e7debc56aacf49787dcf43)

3 years agoAdd IPv4 fib lookup performance tests with uniform keys.
Alexander V. Chernikov [Tue, 30 Mar 2021 12:43:55 +0000 (13:43 +0100)]
Add IPv4 fib lookup performance tests with uniform keys.

Submitted by: zec
MFC after: 1 week

(cherry picked from commit b8598e2ff65ab82da0cf6861ee12f078b40bc252)

3 years agobsdconfig: add a new mirror in Bulgaria
Philip Paeps [Thu, 17 Jun 2021 13:07:37 +0000 (21:07 +0800)]
bsdconfig: add a new mirror in Bulgaria

Provided by Telepoint Mirror Service.

Reported by: Valentin Nikolov <mirror@telepoint.bg>

(cherry picked from commit 1c9605fe1e190197b3846e01dce1e491bef0ec34)

3 years agobsdinstall: add a new mirror in Bulgaria
Philip Paeps [Thu, 17 Jun 2021 13:07:37 +0000 (21:07 +0800)]
bsdinstall: add a new mirror in Bulgaria

Provided by Telepoint Mirror Service.

Reported by: Valentin Nikolov <mirror@telepoint.bg>

(cherry picked from commit 7daa45becfd32cb38933bfdc87e8a10fc982d188)

3 years agoipfw: Update the pfil mbuf pointer in ipfw_check_frame()
Mark Johnston [Wed, 16 Jun 2021 13:46:56 +0000 (09:46 -0400)]
ipfw: Update the pfil mbuf pointer in ipfw_check_frame()

ipfw_chk() might call m_pullup() and thus can change the mbuf chain
head.  In this case, the new chain head has to be returned to the pfil
hook caller, otherwise the pfil hook caller is left with a dangling
pointer.

Note that this affects only the link-layer hooks installed when the
net.link.ether.ipfw sysctl is set to 1.

PR: 256439, 254015, 255069, 255104
Fixes: f355cb3e6
Reviewed by: ae
Sponsored by: The FreeBSD Foundation

(cherry picked from commit bc6a2267fffeafd3946637607a74cfd639398f9d)

3 years agoipfw.8: synopsis misses nat show form
Lutz Donnerhacke [Mon, 10 May 2021 16:30:42 +0000 (18:30 +0200)]
ipfw.8: synopsis misses nat show form

Document the existing behavior, which is currently only available by
reading third party documentation or the source code itself.

PR: 254617
Submitted by: Oliver Kiddle
Differential Revision: https://reviews.freebsd.org/D30189

(cherry picked from commit c8250c5ada85fec8936e8eb8695d7cb80a3ce8ab)

3 years agoAvoid deadlock when removing L2ARC devices under I/O
George Amanakis [Thu, 17 Jun 2021 00:17:42 +0000 (03:17 +0300)]
Avoid deadlock when removing L2ARC devices under I/O

In case we have I/O and try to remove an L2ARC device a deadlock might
occur. arc_read()->zio_read()->zfs_blkptr_verify() waits for SCL_VDEV
to be dropped while holding the hash_lock. However, spa_l2cache_load()
holds SCL_ALL and waits for the hash_lock in l2arc_evict().

Fix this by moving zfs_blkptr_verify() to the top top arc_read() before
the hash_lock is taken. Verify the block pointer and return a checksum
error if damaged rather than halting the system, by using
BLK_VERIFY_LOG instead of BLK_VERIFY_HALT.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Mark Maybee <mark.maybee@delphix.com>
Signed-off-by: George Amanakis <gamanakis@gmail.com>
Closes #12054

3 years agofusefs: reenable the WriteCluster.cluster_write_err test
Alan Somers [Sun, 30 May 2021 22:51:56 +0000 (16:51 -0600)]
fusefs: reenable the WriteCluster.cluster_write_err test

The underlying panic was just fixed by
revision 27006229f7a40a18a61a0e8fd270bc583326b690

PR: 238565
MFC with: 27006229f7a40a18a61a0e8fd270bc583326b690

(cherry picked from commit 425bbe9e64f7af6bdb30a099bd90a32885de1ab8)

3 years agoDelete obsolete Solaris compat files
Alan Somers [Mon, 24 May 2021 14:47:44 +0000 (08:47 -0600)]
Delete obsolete Solaris compat files

These files have been unused ever since the OpenSolaris import

Sponsored by: Axcient
Reviewed By: freqlabs
Differential Revision: https://reviews.freebsd.org/D30371

(cherry picked from commit fc3ba3e9fac03897d17c318b79b52d91cfb87b9e)

3 years agogmultipath: make physpath distinct from the underlying providers'
Alan Somers [Thu, 22 Apr 2021 21:09:03 +0000 (15:09 -0600)]
gmultipath: make physpath distinct from the underlying providers'

zfsd uses a device's physical path attribute to automatically replace a
missing ZFS disk when a blank disk is inserted into the same physical
slot.  Currently gmultipath passes through its underlying providers'
physical path attribute.  That may cause zfsd to replace a missing
gmultipath provider with a newly arrived, single-path disk.  That would
be bad.

This commit fixes that problem by simply appending "/mp" to the
underlying providers' physical path, in a manner similar to what geli
already does.

Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D29941

(cherry picked from commit 420dbe763f15b076751443edfeeb4f676deb3c44)

3 years agopf: don't hold a lock during copyout()
Kristof Provost [Mon, 14 Jun 2021 12:04:02 +0000 (14:04 +0200)]
pf: don't hold a lock during copyout()

copyout() can trigger page faults, so it may potentially sleep.

Reported by: avg
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 8b5f4e692b1d1585ecfc6690552650114e3e704e)

3 years agopf: use M_WAITOK where possible
Kristof Provost [Wed, 9 Jun 2021 12:00:07 +0000 (14:00 +0200)]
pf: use M_WAITOK where possible

In the ioctl path use M_WAITOK allocations whereever possible. These are
less sensitive to memory pressure, and ioctl requests have no hard
deadlines.

Reviewed by: donner
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30702

(cherry picked from commit ea21980a3facfed4c2c6fd10d0f16276564fb540)

3 years agodummynet: free(NULL, M_DUMMYNET); is safe
Kristof Provost [Fri, 21 May 2021 14:55:07 +0000 (16:55 +0200)]
dummynet: free(NULL, M_DUMMYNET); is safe

There's no need to check pointers for NULL before free()ing them.

No functional change.

MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30382

(cherry picked from commit 1b2dbe37fa32d7255faf7d1feec7bb31414a8102)

3 years agodummynet: Fix schedlist and aqmlist locking
Kristof Provost [Fri, 21 May 2021 12:26:49 +0000 (14:26 +0200)]
dummynet: Fix schedlist and aqmlist locking

These are global (i.e. shared across vnets) structures, so we need
global lock to protect them.  However, we look up entries in these lists
(find_aqm_type(), find_sched_type()) and return them. We must ensure
that the returned structures cannot go away while we are using them.

Resolve this by using NET_EPOCH(). The structures can be safely accessed
under it, and we postpone their cleanup until we're sure they're no
longer used.

MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30381

(cherry picked from commit 51d73df18e4d120f6f062062c18efae3ed5193a6)

3 years agoVNETify dummynet
Tom Jones [Sat, 15 May 2021 12:36:45 +0000 (14:36 +0200)]
VNETify dummynet

This moves dn_cfg and other parameters into per VNET variables.

The taskqueue and control state remains global.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D29274

(cherry picked from commit fe3bcfbda30e763a3ec56083b3a19cebbeaf8952)

3 years agoIntroduce DXR as an IPv4 longest prefix matching / FIB module
Marko Zec [Wed, 5 May 2021 11:45:52 +0000 (13:45 +0200)]
Introduce DXR as an IPv4 longest prefix matching / FIB module

DXR maintains compressed lookup structures with a trivial search
procedure.  A two-stage trie is indexed by the more significant bits of
the search key (IPv4 address), while the remaining bits are used for
finding the next hop in a sorted array.  The tradeoff between memory
footprint and search speed depends on the split between the trie and
the remaining binary search.  The default of 20 bits of the key being
used for trie indexing yields good performance (see below) with
footprints of around 2.5 Bytes per prefix with current BGP snapshots.

Rebuilding lookup structures takes some time, which is compensated for by
batching several RIB change requests into a single FIB update, i.e. FIB
synchronization with the RIB may be delayed for a fraction of a second.
RIB to FIB synchronization, next-hop table housekeeping, and lockless
lookup capability is provided by the FIB_ALGO infrastructure.

DXR works well on modern CPUs with several MBytes of caches, especially
in VMs, where is outperforms other currently available IPv4 FIB
algorithms by a large margin.

Reviewed by: melifaro
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29821

(cherry picked from commit 2aca58e16f507bfcad127a0865a9d5c75c5eedc3)

3 years agoDo not forward datagrams originated by link-local addresses
Zhenlei Huang [Tue, 18 May 2021 20:51:37 +0000 (22:51 +0200)]
Do not forward datagrams originated by link-local addresses

The current implement of ip_input() reject packets destined for
169.254.0.0/16, but not those original from 169.254.0.0/16 link-local
addresses.

Fix to fully respect RFC 3927 section 2.7.

PR: 255388
Reviewed by: donner, rgrimes, karels
Differential Revision: https://reviews.freebsd.org/D29968
Reviewed by: rgrimes, donner, karels, marcus, emaste
Differential Revision: https://reviews.freebsd.org/D30374

(cherry picked from commit 3d846e48227e2e78c1e7b35145f57353ffda56ba)
(cherry picked from commit 03b0505b8fe848f33f2f38fe89dd5538908c847e)

3 years agonetgraph/bridge: malloc without flags
Lutz Donnerhacke [Sun, 13 Jun 2021 22:00:35 +0000 (00:00 +0200)]
netgraph/bridge: malloc without flags

During tests an assert was triggered and pointed to missing flags in
the newlink function of ng_bridge(4).

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

(cherry picked from commit 4c3280e58727e900d4c217054fe655e3512380f1)

3 years agoLinuxKPI: add fault_flag_allow_retry_first
Greg V [Wed, 9 Jun 2021 23:09:16 +0000 (19:09 -0400)]
LinuxKPI: add fault_flag_allow_retry_first

Used by drm 5.7.

Reviewed by: bz, hselasky, nc
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30673

(cherry picked from commit 597cc550e7b98294617cdd41800e9f132b6bcad9)

3 years agovmm: Let guests enable SMEP/SMAP if the host supports it
Mark Johnston [Wed, 26 May 2021 13:34:52 +0000 (09:34 -0400)]
vmm: Let guests enable SMEP/SMAP if the host supports it

Reviewed by: kib, grehan, jhb
Tested by: grehan (AMD)
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 4c599db71af56c28bb0388e73bd0570a3873c0ec)

3 years agotests/netgraph: Tests for ng_vlan_rotate
Lutz Donnerhacke [Sun, 6 Jun 2021 23:56:12 +0000 (01:56 +0200)]
tests/netgraph: Tests for ng_vlan_rotate

Test functionality of ng_vlan_rotate(4):
 - Rotate 1 to 9 stagged vlans in any possible direction and length
 - Rotate random combinations of ethertypes (8100, 88a8, 9100)
 - Automatic reverse rotating for backward data flow
 - Test too many and too few vlans

Reviewed by: kp (earlier version)
Differential Revision: https://reviews.freebsd.org/D30670

(cherry picked from commit 6b08e68be111d50931b0d30145f8b7e3402decaf)

3 years agotests/netgraph: Tests for ng_hub
Lutz Donnerhacke [Thu, 3 Jun 2021 22:22:29 +0000 (00:22 +0200)]
tests/netgraph: Tests for ng_hub

Test functionality of ng_hub(4):
 - replicting traffic to anything but the sending hook
 - persistence
 - an unrestricted loop
 - implementation limits with many hooks.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D30633

(cherry picked from commit 7863faa78ae271017c404c635b2a9d07379d4316)

3 years agorc.d: liberate powerd from ACPI dependency
Andriy Gapon [Tue, 8 Jun 2021 17:08:10 +0000 (20:08 +0300)]
rc.d: liberate powerd from ACPI dependency

For instance, many non-ACPI ARM systems have CPU power / frequency
levels.

(cherry picked from commit 20eb6bd8c598fdbf4e96ed4ca64a609be255ccba)

3 years agork3328_cru: fix a typo in the SCLK_I2S2 gate definition
Andriy Gapon [Wed, 9 Jun 2021 07:44:41 +0000 (10:44 +0300)]
rk3328_cru: fix a typo in the SCLK_I2S2 gate definition

(cherry picked from commit ffc5dc788f05dec5fd11aff8f216c37cd56fcd7f)

3 years agozfs: unbreak stable/13 build on i386 after b0c251b0d
Martin Matuska [Wed, 16 Jun 2021 01:47:02 +0000 (03:47 +0200)]
zfs: unbreak stable/13 build on i386 after b0c251b0d

The build was broken because upstream merged e76373de7 (author: mav)
without fef8bd41f from openzfs/zfs/master into openzfs/zfs/zfs-2.1-release.

Temporary fix until upstream decides a way to solve this problem.

Patch by: mav
Differential Revision: https://reviews.freebsd.org/D30783

(direct commit)

3 years agozfs: unbreak stable/13 clang build on non-x86 archs after b0c251b0d
Martin Matuska [Wed, 16 Jun 2021 00:38:42 +0000 (02:38 +0200)]
zfs: unbreak stable/13 clang build on non-x86 archs after b0c251b0d

(direct commit)

3 years agosystemd: import: expand $ZPOOL_IMPORT_OPTS correctly
наб [Mon, 14 Jun 2021 15:48:53 +0000 (17:48 +0200)]
systemd: import: expand $ZPOOL_IMPORT_OPTS correctly

Turns out $ZPOOL_IMPORT_OPTS expands in a shell-like fashion,
yielding 'import' '-aN' '-o' 'cachefile=none' for an unset variable,
and 'import' '-aN' '-o' 'cachefile=none' 'word1' 'word2' for a
white-spaced one, but ${ZPOOL_IMPORT_OPTS} expands like "${Z_I_O}"
would in a shell, yielding 'import' '-aN' '-o' 'cachefile=none' ''
(empty) and 'import' '-aN' '-o' 'cachefile=none' 'word1 word2' (spaced)

Fixes eec5ba113e1d285d445333079a3e8184872ad00a "dracut: 90zfs: respect
zfs_force=1 on systemd systems"

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes: #12231
3 years agovdev_draid_min_asize() ignores reserved space
Matthew Ahrens [Sun, 13 Jun 2021 17:48:53 +0000 (10:48 -0700)]
vdev_draid_min_asize() ignores reserved space

vdev_draid_min_asize() returns the minimum size of a child vdev.  This
is used when determining if a disk is big enough to replace a child.
It's also used by zdb to determine how big of a child to make to test
replacement.

vdev_draid_min_asize() says that the child’s asize has to be at least
1/Nth of the entire draid’s asize, which is the same logic as raidz.
However, this contradicts the code in vdev_draid_open(), which
calculates the draid’s asize based on a reduced child size:

  An additional 32MB of scratch space is reserved at the end of each
  child for use by the dRAID expansion feature

So the problem is that you can replace a draid disk with one that’s
vdev_draid_min_asize(), but it actually needs to be larger to accommodate
the additional 32MB.  The replacement is allowed and everything works at
first (since the reserved space is at the end, and we don’t try to use
it yet), but when you try to close and reopen the pool,
vdev_draid_open() calculates a smaller asize for the draid, because of
the smaller leaf, which is not allowed.

I think the confusion is that vdev_draid_min_asize() is correctly
returning the amount of required *allocatable* space in a leaf, but the
actual *size* of the leaf needs to be at least 32MB more than that.
ztest_vdev_attach_detach() assumes that it can attach that size of
device, and it actually can (the kernel/libzpool accepts it), but it
then later causes zdb to not be able to open the pool.

This commit changes vdev_draid_min_asize() to return the required size
of the leaf, not the size that draid will make available to the metaslab
allocator.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Mark Maybee <mark.maybee@delphix.com>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #11459
Closes #12221

3 years agoDo not hash unlinked inodes
Paul Zuchowski [Sat, 12 Jun 2021 00:00:33 +0000 (20:00 -0400)]
Do not hash unlinked inodes

In zfs_znode_alloc we always hash inodes.  If the
znode is unlinked, we do not need to hash it.  This
fixes the problem where zfs_suspend_fs is doing zrele
(iput) in an async fashion, and zfs_resume_fs unlinked
drain processing will try to hash an inode that could
still be hashed, resulting in a panic.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alan Somers <asomers@gmail.com>
Signed-off-by: Paul Zuchowski <pzuchowski@datto.com>
Closes #9741
Closes #11223
Closes #11648
Closes #12210

3 years agoAdded uncompress requirement
Rich Ercolani [Fri, 11 Jun 2021 15:38:23 +0000 (11:38 -0400)]
Added uncompress requirement

Having an old enough version of "file" and no "uncompress" program
installed can cause rpmbuild as root to crash and mangle rpmdb.

So let's add a build dependency for RPM-based systems.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes: #12071
Closes: #12168
3 years agoZTS: Add zfs_clone_livelist_dedup.ksh to Makefile.am
Brian Behlendorf [Fri, 11 Jun 2021 15:21:36 +0000 (08:21 -0700)]
ZTS: Add zfs_clone_livelist_dedup.ksh to Makefile.am

Commit 86b5f4c12 added a new zfs_clone_livelist_dedup.ksh test case
but didn't include it in the Makefile.am.  This results in the test
not being included in the dist tarball so it's never run by the CI.

Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes: #12224
3 years agofread: improve performance for unbuffered reads
Pedro F. Giffuni [Mon, 31 May 2021 01:48:38 +0000 (20:48 -0500)]
fread: improve performance for unbuffered reads

We can use the buffer passed to fread(3) directly in the FILE *.
The buffer needs to be reset before each call to __srefill().
This preserves the expected behavior in all cases.

The change was found originally in OpenBSD and later adopted by NetBSD.

MFC after: 2 weeks
Obtained from: OpenBSD (CVS 1.18)

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

3 years agolibcasper: fix descriptors numbers
Mariusz Zaborski [Wed, 9 Jun 2021 21:46:51 +0000 (23:46 +0200)]
libcasper: fix descriptors numbers

Casper services expect that the first 3 descriptors (stdin/stdout/stderr)
will point to /dev/null. Which Casper will ensure later. The Casper
services are forked from the original process. If the initial process
closes one of those descriptors, Casper may reuse one of them for it on
purpose. If this is the case, then renumarate the descriptors used by
Casper to higher numbers. This is done already after the fork, so it
doesn't break the parent process.

PR: 255339
Reported by: Borja Marcos <borjam (at) sarenet.es>
Tested by: jkim@

(cherry picked from commit aa310ebfba3d49a0b6b03a103b969731a8136a73)

3 years agotests/netgraph: Tests for ng_bridge
Lutz Donnerhacke [Fri, 4 Jun 2021 10:59:00 +0000 (12:59 +0200)]
tests/netgraph: Tests for ng_bridge

Test functionality of ng_bridge(4):
 - replicating traffic to anything but the sending hook
 - persistence
 - detect loops
 - unicast to only one link of many
 - stretch to implementation limits on broadcast

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D30647
Differential Revision: https://reviews.freebsd.org/D30699

(cherry picked from commit 61814702398ce29430b2bef75cbdd6fd2c07ad12)
(cherry picked from commit 5554abd9cc9702af30af90925b33c5efff4e7d88)

3 years agotests/netgraph: Inital framework for testing libnetgraph
Lutz Donnerhacke [Wed, 2 Jun 2021 22:29:46 +0000 (00:29 +0200)]
tests/netgraph: Inital framework for testing libnetgraph

Provide a framework of functions to test various netgraph modules.
Tests contain:
 - creating, renaming, and destroying nodes
 - connecting and removing hooks
 - sending and receiving data
 - sending ASCII messages and receiving binary responses
 - errors can be passed for indiviual inspection or fail the test

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D30629
Differential Revision: https://reviews.freebsd.org/D30657
Differential Revision: https://reviews.freebsd.org/D30671
Differential Revision: https://reviews.freebsd.org/D30699

(cherry picked from commit 24ea1dbf257aa6757f469bcd859f90e9ad851e59)
(cherry picked from commit 09307dbfb888a98232096c751a96ecb3344aa77c)
(cherry picked from commit 9021c46603bf29b9700f24b8dce8796b434d7c8f)
(cherry picked from commit 5554abd9cc9702af30af90925b33c5efff4e7d88)

Also contains some fixups:
 - indent all files correctly
 - finish factoring out
 - remove debugging code
 - check for renaming issues reported in PR241954

PR: 241954
Differential Revision: https://reviews.freebsd.org/D30692
Differential Revision: https://reviews.freebsd.org/D30714
Differential Revision: https://reviews.freebsd.org/D30713

(cherry picked from commit a664ade93972ce617f0888ff79e715dff9cf0f87)
(cherry picked from commit 0afa9be03937d60cb5aeba64c81e3e2165bd3737)
(cherry picked from commit 43e4821315c31db067e23564b9bfafb519e77b2b)

3 years agotcp: Missing mfree in rack and bbr
Randall Stewart [Fri, 11 Jun 2021 15:38:08 +0000 (11:38 -0400)]
tcp: Missing mfree in rack and bbr

Recently (Nov) we added logic that protects against a peer negotiating a timestamp, and
then not including a timestamp. This involved in the input path doing a goto done_with_input
label. Now I suspect the code was cribbed from one in Rack that has to do with the SYN.
This had a bug, i.e. it should have a m_freem(m) before going to the label (bbr had this
missing m_freem() but rack did not). This then caused the missing m_freem to show
up in both BBR and Rack. Also looking at the code referencing m->m_pkthdr.lro_nsegs
later (after processing) is not a good idea, even though its only for logging. Best to
copy that off before any frees can take place.

Reviewed by: mtuexen
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D30727

(cherry picked from commit ba1b3e48f5be320f0590bc357ea53fdc3e4edc65)

3 years agotcp: Mbuf leak while holding a socket buffer lock.
Randall Stewart [Thu, 10 Jun 2021 12:33:57 +0000 (08:33 -0400)]
tcp: Mbuf leak while holding a socket buffer lock.

When running at NF the current Rack and BBR changes with the recent
commits from Richard that cause the socket buffer lock to be held over
the ip_output() call and then finally culminating in a call to tcp_handle_wakeup()
we get a lot of leaked mbufs. I don't think that this leak is actually caused
by holding the lock or what Richard has done, but is exposing some other
bug that has probably been lying dormant for a long time. I will continue to
look (using his changes) at what is going on to try to root cause out the issue.

In the meantime I can't leave the leaks out for everyone else. So this commit
will revert all of Richards changes and move both Rack and BBR back to just
doing the old sorwakeup_locked() calls after messing with the so_rcv buffer.

We may want to look at adding back in Richards changes after I have pinpointed
the root cause of the mbuf leak and fixed it.

Reviewed by: mtuexen,rscheff
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D30704

(cherry picked from commit 67e892819b26c198e4232c7586ead7f854f848c5)

3 years agotcp: LRO timestamps have lost their previous precision
Randall Stewart [Wed, 9 Jun 2021 17:58:54 +0000 (13:58 -0400)]
tcp: LRO timestamps have lost their previous precision

Recently we had a rewrite to tcp_lro.c that was tested but one subtle change
was the move to a less precise timestamp. This causes all kinds of chaos
in tcp's that do pacing and needs to be fixed to use the more precise
time that was there before.

Reviewed by: mtuexen, gallatin, hselasky
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D30695

(cherry picked from commit b45daaea95abd8bda52caaacf120f9197caab3e7)