17 hours agoDon't display empty error context. master github/master
imp [Sun, 24 Sep 2017 05:04:06 +0000 (05:04 +0000)]
Don't display empty error context.

Context extraction didn't handle this case and showed uninitialized memory.

Obtained from: OpenBSD lib.c 1.21
Sponsored by: Netflix
Differential Revision:

17 hours agoFix %c for floating values that become 0 when coerced to int.
imp [Sun, 24 Sep 2017 05:04:02 +0000 (05:04 +0000)]
Fix %c for floating values that become 0 when coerced to int.

Obtained from: OpenBSD run.c 1.36 (From Jeremy Devenport)
Sponsored by: Netflix
Differential Revision:

17 hours agoFix uninitialized variable
imp [Sun, 24 Sep 2017 05:03:57 +0000 (05:03 +0000)]
Fix uninitialized variable

echo | awk 'BEGIN {i=$1; print i}' prints a boatload of stack
garbage. NUL terminate the memory returned from malloc to prevent it.

Obtained from: OpenBSD run.c 1.40
Sponsored by: Netflix
Differential Revision:

19 hours agoFix typo from r323945.
cy [Sun, 24 Sep 2017 03:33:26 +0000 (03:33 +0000)]
Fix typo from r323945.

Reported by: Gary Jennejohn <>
Point hat to: cy (me)

20 hours agoSince the page "frame" doesn't belong to a vm object, it can't be paged
alc [Sun, 24 Sep 2017 02:50:59 +0000 (02:50 +0000)]
Since the page "frame" doesn't belong to a vm object, it can't be paged
out.  Since it can't be paged out, it is never actually enqueued in a
paging queue.  Nonetheless, passing PQ_INACTIVE to vm_page_unwire()
creates the appearance that the page "frame" is being enqueued in the
inactive queue.  As of r288122, we can avoid this false impression by
passing PQ_NONE.

MFC after: 1 week

22 hours agoConvert some idioms over to py3k-compatible idioms
ngie [Sun, 24 Sep 2017 00:14:48 +0000 (00:14 +0000)]
Convert some idioms over to py3k-compatible idioms

- Import print_function from __future__ and use print(..) instead of `print ..`.
- Use repr instead of backticks when the object needs to be dumped, unless
  print(..) can do it lazily. Use str instead of backticks as appropriate
  for simplification reasons.

This doesn't fully convert these modules over py3k. It just gets over some of
the trivial compatibility hurdles.

27 hours agoAdd myself as src committer.
fsu [Sat, 23 Sep 2017 19:49:12 +0000 (19:49 +0000)]
Add myself as src committer.

Approved by:    pfg (mentor)

29 hours agoddb(4): Add 'show badstacks' command to show witness badstacks
cem [Sat, 23 Sep 2017 17:48:49 +0000 (17:48 +0000)]
ddb(4): Add 'show badstacks' command to show witness badstacks

Add a DDB command that mirrors sysctl debug.witness.badstacks.

Reapply r323935 after fixing trivial deficiency.  I forgot to compile with
WITNESS enabled.  Thanks emaste@ for fixing the build while I was asleep.

Reported by: rstone
Reviewed by: rstone (previous version)
Sponsored by: Dell EMC Isilon
Differential Revision:

30 hours agobnxt: Choose better HW LRO defaults for performance
shurd [Sat, 23 Sep 2017 16:59:37 +0000 (16:59 +0000)]
bnxt: Choose better HW LRO defaults for performance

1) Choose correct Firmware options for HW LRO for best performance
2) Delete TBD and other comments which are not required.
3) Added sysctl interface to enable / disable / modify different factors
   of HW LRO.
4) Disabled HW LRO by default to avoid issues with packet forwarding

This allows much better control over the LRO configuration via sysctls, and
uses much better defaults.  Hardware LRO can now be enabled/disabled
independantly from the software LRO, and the tuning parameters are exposed.

manpage updates coming soon.

Submitted by: Bhargava Chenna Marreddy <>
Reviewed by: shurd, sbruno
Approved by: sbruno (mentor)
Sponsored by: Broadcom Limited
Differential Revision:

30 hours agoHave ifmp_ring_enqueue() abdicate instead of switch to a consumer
shurd [Sat, 23 Sep 2017 16:46:30 +0000 (16:46 +0000)]
Have ifmp_ring_enqueue() abdicate instead of switch to a consumer

Move TX out of the enqueue() path. As a result, we need
to have ifmp_ring_check_drainage() pick up from the abdicate state.

We also need to either enqueue the TX task, or check drainage
after calling ifmp_ring_enqueue() to ensure it's sent.

This change results in a 30% small packet forwarding improvement.

Reviewed by: olivier, sbruno
Approved by: sbruno (mentor)
Sponsored by: Limelight Networks
Differential Revision:

34 hours agoAfter the r317886 support for TFTP and NFS can be enable simultaneously.
oshogbo [Sat, 23 Sep 2017 12:44:42 +0000 (12:44 +0000)]
After the r317886 support for TFTP and NFS can be enable simultaneously.

The cleanup of this distinction was done in the r318988, but this Makefile
was omitted.

Submitted by: kczekirda@

34 hours agoRevert r323935 as it broke the build
emaste [Sat, 23 Sep 2017 12:35:46 +0000 (12:35 +0000)]
Revert r323935 as it broke the build

subr_witness.c:2577:4: error: use of undeclared identifier 'req'
                        req->oldidx = 0;

38 hours agoGarbage collect usued fields
scottl [Sat, 23 Sep 2017 08:26:42 +0000 (08:26 +0000)]
Garbage collect usued fields

Sponsored by: Netflix

41 hours agoCorrect two misspellings. Also align */.
cy [Sat, 23 Sep 2017 06:00:17 +0000 (06:00 +0000)]
Correct two misspellings. Also align */.

45 hours agoMake struct grouptask gt_name member a char array
shurd [Sat, 23 Sep 2017 01:39:16 +0000 (01:39 +0000)]
Make struct grouptask gt_name member a char array

Previously, it was just a pointer which was copied, but
some callers pass in a stack variable which will go out of scope.
Add GROUPTASK_NAMELEN macro (32) and snprintf() the name into it,
using "grouptask" if name is NULL. We can now safely include
gtask->gt_name in console messages.

Reviewed by: sbruno
Approved by: sbruno (mentor)
Sponsored by: Limelight Networks
Differential Revision:

45 hours agoMake the rx budget a tunable
shurd [Sat, 23 Sep 2017 01:37:01 +0000 (01:37 +0000)]
Make the rx budget a tunable

This allows tuning the rx budget for special load profiles
as well as more easily testing to determine sane defaults.

Reviewed by: sbruno
Approved by: sbruno (mentor)
Sponsored by: Limelight Networks
Differential Revision:

45 hours agoChain mbufs before passing to if_input()
shurd [Sat, 23 Sep 2017 01:35:14 +0000 (01:35 +0000)]
Chain mbufs before passing to if_input()

Build a list of mbufs to pass to if_input() after LRO. Results in
12% small packet forwarding rate improvement.

Reviewed by: sbruno
Approved by: sbruno (mentor)
Sponsored by: Limelight Networks
Differential Revision:

45 hours agoSome small packet performance improvements
shurd [Sat, 23 Sep 2017 01:33:20 +0000 (01:33 +0000)]
Some small packet performance improvements

If the packet is smaller than MTU, disable the TSO flags.
Move TCP header parsing inside the IS_TSO?() test.
Add a new IFLIB_NEED_ZERO_CSUM flag to indicate the checksums need to be zeroed before TX.

Reviewed by: sbruno
Approved by: sbruno (mentor)
Sponsored by: Limelight Networks
Differential Revision:

2 days agoddb(4): Add 'show badstacks' command to show witness badstacks
cem [Fri, 22 Sep 2017 20:01:12 +0000 (20:01 +0000)]
ddb(4): Add 'show badstacks' command to show witness badstacks

Add a DDB command that mirrors sysctl debug.witness.badstacks.

Reported by: rstone
Reviewed by: rstone
Sponsored by: Dell EMC Isilon
Differential Revision:

2 days agoDetect NEON and set HWCAP_NEON if present.
jhb [Fri, 22 Sep 2017 17:58:57 +0000 (17:58 +0000)]
Detect NEON and set HWCAP_NEON if present.

Reviewed by: andrew, ian
MFC after: 2 weeks
Differential Revision:

2 days agoCorrect HWCAP_VFP3* values to match Linux.
jhb [Fri, 22 Sep 2017 17:57:38 +0000 (17:57 +0000)]
Correct HWCAP_VFP3* values to match Linux.

Reviewed by: andrew, ian
MFC after: 2 weeks
Differential Revision:

2 days agoFix 32bit build.
kib [Fri, 22 Sep 2017 16:42:41 +0000 (16:42 +0000)]
Fix 32bit build.

Reported by: emaste
Sponsored by: The FreeBSD Foundation

2 days agoRevert r323812 from release/tools/arm.subr, which has broken the
gjb [Fri, 22 Sep 2017 14:34:27 +0000 (14:34 +0000)]
Revert r323812 from release/tools/arm.subr, which has broken the
build on arm/armv6 images.

Pointyhat: gjb (myself)
MFC after: immediate
MFC note: releng/10.4 has broken because of this
Sponsored by: The FreeBSD Foundation

2 days agoContinuing efforts to provide hardening of FFS, this change adds a
mckusick [Fri, 22 Sep 2017 12:45:15 +0000 (12:45 +0000)]
Continuing efforts to provide hardening of FFS, this change adds a
check hash to cylinder groups. If a check hash fails when a cylinder
group is read, no further allocations are attempted in that cylinder
group until it has been fixed by fsck. This avoids a class of
filesystem panics related to corrupted cylinder group maps. The
hash is done using crc32c.

Check hases are added only to UFS2 and not to UFS1 as UFS1 is primarily
used in embedded systems with small memories and low-powered processors
which need as light-weight a filesystem as possible.

Specifics of the changes:

    Add BX_FSPRIV to reserve a set of eight b_xflags that may be used
    by individual filesystems for their own purpose. Their specific
    definitions are found in the header files for each filesystem
    that uses them. Also add fields to struct buf as noted below.

    It is only necessary to compute a check hash for a cylinder
    group when it is actually read from disk. When calling bread,
    you do not know whether the buffer was found in the cache or
    read. So a new flag (GB_CKHASH) and a pointer to a function to
    perform the hash has been added to breadn_flags to say that the
    function should be called to calculate a hash if the data has
    been read. The check hash is placed in b_ckhash and the B_CKHASH
    flag is set to indicate that a read was done and a check hash
    calculated. Though a rather elaborate mechanism, it should
    also work for check hashing other metadata in the future. A
    kernel internal API change was to change breada into a static
    fucntion and add flags and a function pointer to a check-hash

    Add flags for types of check hashes; stored in a new word in the
    superblock. Define corresponding BX_ flags for the different types
    of check hashes. Add a check hash word in the cylinder group.

    In ffs_getcg do the dance with breadn_flags to get a check hash and
    if one is provided, check it.

    Copy across the BX_FFSTYPES flags in background writes.
    Update the check hash when writing out buffers that need them.

    Recompute check hash when updating snapshot cylinder groups.

    Include libkern/crc32.c in libufs and use it to compute check
    hashes when updating cylinder groups.

Four utilities are affected:

    Add the check hashes when building the cylinder groups.

    Verify and update check hashes when checking and writing cylinder groups.

    Offer to add check hashes to existing filesystems.
    Precompute check hashes when rebuilding cylinder group
    (although this will be done when it is written in fsutil.c
    it is necessary to do it early before comparing with the old
    cylinder group)

    Print out the new check hash flag(s)

    Needs to add libufs now used by pass5.c imported from fsck_ffs.

Reviewed by: kib
Tested by: Peter Holm (pho)

2 days agoClean up error messages related to device discovery
scottl [Fri, 22 Sep 2017 12:07:03 +0000 (12:07 +0000)]
Clean up error messages related to device discovery

Sponsored by: Netflix

2 days agoMFV r323917: 8648 Fix range locking in ZIL commit codepath
avg [Fri, 22 Sep 2017 08:27:27 +0000 (08:27 +0000)]
MFV r323917: 8648 Fix range locking in ZIL commit codepath

  I'm opening this bug to track integration of the following ZFS on Linux
  commit into illumos:

  commit f763c3d1df569a8d6b60bcb5e95cf07aa7a189e6
  Author: LOLi <>
  Date:   Mon Aug 21 17:59:48 2017 +0200

      Fix range locking in ZIL commit codepath

      Since OpenZFS 7578 (1b7c1e5) if we have a ZVOL with logbias=throughput
      we will force WR_INDIRECT itxs in zvol_log_write() setting itx->itx_lr
      offset and length to the offset and length of the BIO from
      zvol_write()->zvol_log_write(): these offset and length are later used
      to take a range lock in zillog->zl_get_data function: zvol_get_data().

      Now suppose we have a ZVOL with blocksize=8K and push 4K writes to
      offset 0: we will only be range-locking 0-4096. This means the
      ASSERTion we make in dbuf_unoverride() is no longer valid because now
      dmu_sync() is called from zilog's get_data functions holding a partial
      lock on the dbuf.

      Fix this by taking a range lock on the whole block in zvol_get_data().

Reviewed-by: Chunwei Chen <>
Reviewed-by: Brian Behlendorf <>
Signed-off-by: loli10K <>
Reviewed by: Igor Kozhukhov <>
Reviewed by: Matt Ahrens <>
Reviewed by: Andriy Gapon <>
Reviewed by: Alexander Motin <>
Approved by: Robert Mustacchi <>
Author: LOLi <>

MFC after: 10 days

2 days agoExtend sysctl description for hw.usb.disable_enumeration .
hselasky [Fri, 22 Sep 2017 08:21:35 +0000 (08:21 +0000)]
Extend sysctl description for hw.usb.disable_enumeration .

PR: 222505
Submitted by: Julian H. Stacey <>
MFC after: 1 week
Sponsored by: Mellanox Technologies

2 days agoMFV r323914: 8661 remove "zil-cw2" dtrace probe
avg [Fri, 22 Sep 2017 08:21:14 +0000 (08:21 +0000)]
MFV r323914: 8661 remove "zil-cw2" dtrace probe

  The "zil-cw1" dtrace probe was previously removed in 8558, and the "zil-cw2"
  probe should have been removed in that patch as well. Unfortunately, the "zil-
  cw2" was not removed in 8558, so this bug is to track it's removal.

Reviewed by: Serapheim Dimitropoulos <>
Reviewed by: Matthew Ahrens <>
Reviewed by: Igor Kozhukhov <>
Approved by: Robert Mustacchi <>
Author: Prakash Surya <>

MFC after: 1 week

2 days agoAdd support for 32-bit compatibility IOCTLs in the LinuxKPI.
hselasky [Fri, 22 Sep 2017 08:12:08 +0000 (08:12 +0000)]
Add support for 32-bit compatibility IOCTLs in the LinuxKPI.

Bump the FreeBSD version to force recompilation of external
kernel modules due to structure change.

PR: 222504
Submitted by: Greg V <>
MFC after: 1 week
Sponsored by: Mellanox Technologies

2 days agolibefi: define EISA PNP constants
tsoome [Fri, 22 Sep 2017 07:44:36 +0000 (07:44 +0000)]
libefi: define EISA PNP constants

Define EISA PNP constants and use them, also fix ID for 0x701

2 days agolibefi: efipart_hdinfo_add_filepath should check strtol result
tsoome [Fri, 22 Sep 2017 07:40:05 +0000 (07:40 +0000)]
libefi: efipart_hdinfo_add_filepath should check strtol result

Use errno for error checking.

2 days agolibefi: efipart.c cstyle fix for efipart_print_common()
tsoome [Fri, 22 Sep 2017 07:37:42 +0000 (07:37 +0000)]
libefi: efipart.c cstyle fix for efipart_print_common()

The else statement should have { }

2 days agolibefi: efipart_strategy() should return ENXIO when there is no media
tsoome [Fri, 22 Sep 2017 07:34:08 +0000 (07:34 +0000)]
libefi: efipart_strategy() should return ENXIO when there is no media

We should return ENXIO to indicate the situation with device present,
but no media.

2 days agolibefi: pdinfo_t pd_unit and pd_open should be unsigned
tsoome [Fri, 22 Sep 2017 07:29:26 +0000 (07:29 +0000)]
libefi: pdinfo_t pd_unit and pd_open should be unsigned

The device index, partition index and reference counter are all positive
numbers. However, since our internal partition number may be negative
to indicate GPT table, the compare expression need to take care when comparing
pdinfo_t and partition data.

2 days agoAdd missing locking. Found by Coverity while scanning the usrsctp
tuexen [Fri, 22 Sep 2017 06:33:01 +0000 (06:33 +0000)]
Add missing locking. Found by Coverity while scanning the usrsctp

MFC after: 1 week

2 days agoAdd missing socket lock.
tuexen [Fri, 22 Sep 2017 06:07:47 +0000 (06:07 +0000)]
Add missing socket lock.

MFC after: 1 week

2 days Like r323869, skip SHA HMAC tests on non-SHA drivers
cem [Fri, 22 Sep 2017 04:41:48 +0000 (04:41 +0000)] Like r323869, skip SHA HMAC tests on non-SHA drivers

Sponsored by: Dell EMC Isilon

2 days Fix whitespace style errors
cem [Fri, 22 Sep 2017 04:25:44 +0000 (04:25 +0000)] Fix whitespace style errors

I accidentally introduced different whitespace style in r323878.  I'm not
used to using tabs for indentation in Python scripts.

Whitespace only; no functional change.

Sponsored by: Dell EMC Isilon

2 days agoefilib.h: typo in structure member description
tsoome [Fri, 22 Sep 2017 02:58:47 +0000 (02:58 +0000)]
efilib.h: typo in structure member description

The link should be replaced by list.

2 days agor323885 did miss efilib.h update
tsoome [Fri, 22 Sep 2017 02:56:26 +0000 (02:56 +0000)]
r323885 did miss efilib.h update

The efilib.h update was left out from r323885 by mistake.

2 days agolibefi: efi_devpath_match local len should be unsigned
tsoome [Fri, 22 Sep 2017 02:53:01 +0000 (02:53 +0000)]
libefi: efi_devpath_match local len should be unsigned

DevicePathNodeLength() will always return unsigned value.

2 days agocam iosched: Bettar account IOPS for smoother performance
imp [Fri, 22 Sep 2017 02:36:36 +0000 (02:36 +0000)]
cam iosched: Bettar account IOPS for smoother performance

Prevent cam_iosched_iops_tick() from discarding 'unspent' ios unless
it's a new accounting interval.

Previously ios that weren't used between ticks were lost, as a result
the iops limiter could enforce a limit below the configured maximum.

Obtained from: ElectroBSD
Submitted by: Fabian Keil
PR: 221974

2 days agocam iosched: Enforce iop limits below the quanta value
imp [Fri, 22 Sep 2017 02:36:32 +0000 (02:36 +0000)]
cam iosched: Enforce iop limits below the quanta value

Previously the iops limiter would always allow at least
quanta ios per second as cam_iosched_iops_tick() never set
ios->l_value1 below 1.

Submitted by: Fabian Keil <>
Obtained from: ElectroBSD
PR: 221974

2 days agoSupport AEAD requests with non-GCM algorithms.
jhb [Fri, 22 Sep 2017 00:34:46 +0000 (00:34 +0000)]
Support AEAD requests with non-GCM algorithms.

In particular, support chaining an AES cipher with an HMAC for a request
including AAD.  This permits submitting requests from userland to encrypt
objects like IPSec packets using these algorithms.

In the non-GCM case, the authentication crypto descriptor covers both the
AAD and the ciphertext.  The GCM case remains unchanged.  This matches
the requests created internally in IPSec.  For the non-GCM case, the
COP_F_CIPHER_FIRST is also supported since the ordering matters.

Note that while this can be used to simulate IPSec requests from userland,
this ioctl cannot currently be used to perform TLS requests using AES-CBC
and MAC-before-encrypt.

Reviewed by: cem
Sponsored by: Chelsio Communications
Differential Revision:

2 days agoAdd a new COP_F_CIPHER_FIRST flag for struct crypt_op.
jhb [Fri, 22 Sep 2017 00:21:58 +0000 (00:21 +0000)]
Add a new COP_F_CIPHER_FIRST flag for struct crypt_op.

This requests that the cipher be performed before rather than after
the HMAC when both are specified for a single operation.

Reviewed by: cem
Sponsored by: Chelsio Communications
Differential Revision:

2 days agoPlace the AAD before the plaintext/ciphertext for CIOCRYPTAEAD.
jhb [Fri, 22 Sep 2017 00:15:54 +0000 (00:15 +0000)]
Place the AAD before the plaintext/ciphertext for CIOCRYPTAEAD.

Software crypto implementations don't care how the buffer is laid out,
but hardware implementations may assume that the AAD is always before
the plain/cipher text and that the hash/tag is immediately after the end
of the plain/cipher text.

In particular, this arrangement matches the layout of both IPSec packets
and TLS frames.  Linux's crypto framework also assumes this layout for
AEAD requests.

Reviewed by: cem
Sponsored by: Chelsio Communications
Differential Revision:

2 days agoFix undeclared identifier error introduced in r323879
shurd [Thu, 21 Sep 2017 23:27:35 +0000 (23:27 +0000)]
Fix undeclared identifier error introduced in r323879

It doesn't appear to be safe to use gtask->gt_name.

Reported by: Mark Johnston, Jenkins
Reviewed by: sbruno
Approved by: sbruno (mentor)
Sponsored by: Limelight Networks
Differential Revision:

2 days agolibefi: efipart.c should use calloc()
tsoome [Thu, 21 Sep 2017 23:22:18 +0000 (23:22 +0000)]
libefi: efipart.c should use calloc()

The device specific *_add functions are using malloc() + memset,
should use calloc instead.

2 days agolibefi: efi_devpath_match() should return bool
tsoome [Thu, 21 Sep 2017 23:14:07 +0000 (23:14 +0000)]
libefi: efi_devpath_match() should return bool

The current implementation of efi_devpath_match() is returning values 0 or 1,
so it should be updated to return bool.

2 days agoAlways create usr/local/etc -> /etc/local symlink
imp [Thu, 21 Sep 2017 23:10:56 +0000 (23:10 +0000)]
Always create usr/local/etc -> /etc/local symlink

/usr/local/etc gets created and populated by packages. However, if no
packages are installed when setup_nanobsd is run, this symlink won't
get created, causing problems if packages are installed later (say on
first boot). Therefore, always create the symlink and etc/local. It
does no harm and may help.

Inspired by crochet issue #183 (consuingly says NanoBSD, means crochet)
Sponsored by: Netflix

2 days agoOnly handle _PC_MAX_CANON, _PC_MAX_INPUT, and _PC_VDISABLE for TTY devices.
jhb [Thu, 21 Sep 2017 23:05:32 +0000 (23:05 +0000)]
Only handle _PC_MAX_CANON, _PC_MAX_INPUT, and _PC_VDISABLE for TTY devices.

Move handling of these three pathconf() variables out of vop_stdpathconf()
and into devfs_pathconf() as TTY devices can only be devfs files.  In
addition, only return settings for these three variables for devfs devices
whose device switch has the D_TTY flag set.

Discussed with: bde, kib
Sponsored by: Chelsio Communications

3 days agoUse UFS_LINK_MAX instead of LINK_MAX.
jhb [Thu, 21 Sep 2017 22:33:59 +0000 (22:33 +0000)]
Use UFS_LINK_MAX instead of LINK_MAX.

Submitted by: bde
Sponsored by: Chelsio Communications

3 days agoSimplify i915_gem_wire_page() and avoid unneeded page-busying.
markj [Thu, 21 Sep 2017 22:15:45 +0000 (22:15 +0000)]
Simplify i915_gem_wire_page() and avoid unneeded page-busying.

Reviewed by: alc, kib
MFC after: 1 week

3 days agoImproved logging of gtaskqueue failues
shurd [Thu, 21 Sep 2017 21:14:48 +0000 (21:14 +0000)]
Improved logging of gtaskqueue failues

Check the return code of intr_setaffinity() and log any errors
it returns. When a qid is not located, log an error before returning
failure.  Also, use __func__ rather than hardcoding the function name

Reviewed by: sbruno
Approved by: sbruno (mentor)
Sponsored by: Limelight Networks
Differential Revision:

3 days Actually use NIST-KAT HMAC test vectors and test the right hashes
cem [Thu, 21 Sep 2017 21:07:21 +0000 (21:07 +0000)] Actually use NIST-KAT HMAC test vectors and test the right hashes

Previously, this test was entirely a no-op as no vector in the NIST-KAT file
has a precisely 20-byte key.

Additionally, not every vector in the file is SHA1.  The length field
determines the hash under test, and is now decoded correctly.

Finally, due to a limitation I didn't feel like fixing in, MACs
are truncated to 16 bytes in this test.

With this change and the uncommitted D12437 (to allow key sizes other than
those used in IPSec), the SHA tests in actually test something
and e.g. at least cryptosoft passes the test.

Sponsored by: Dell EMC Isilon

3 days agoFix M_GTASKQUEUE definition
shurd [Thu, 21 Sep 2017 20:34:33 +0000 (20:34 +0000)]
Fix M_GTASKQUEUE definition

Previously had the same short and long description as taskqueues.
This could cause problems with memguard(9) and vmstat -m which use
the short description as a unique identifier.

Reviewed by: sbruno
Approved by: sbruno (mentor)
MFC after: 3 days
Sponsored by: Limelight Networks
Differential Revision:

3 days agobnxt: Fix driver when attached to a VF
shurd [Thu, 21 Sep 2017 20:27:43 +0000 (20:27 +0000)]
bnxt: Fix driver when attached to a VF

- Use HWRM_FUNC_VF_CFG instead of HWRM_FUNC_CFG on VFs
- Fix NPAR/VF detection
- Clean up flag definitions
- Don't allow WoL on VFs

Although the bnxt driver doesn't support SR-IOV so can create VFs yet,
the PF could be running Linux or ESCi with a VF passed through to a
FreeBSD guest.  This fixes the driver for that use case.

Submitted by: Siva Kallam <>
Reviewed by: shurd, sbruno
Approved by: sbruno (mentor)
Sponsored by: Broadcom Limited
Differential Revision:

3 days agoUnprotected modification of ng_iface(4) private data leads to kernel panic.
eugen [Thu, 21 Sep 2017 20:16:10 +0000 (20:16 +0000)]
Unprotected modification of ng_iface(4) private data leads to kernel panic.
Fix a race with per-node read-mostly lock and refcounting for a hook.

PR: 220076
Tested by: peixoto.cassiano
Approved by: avg (mentor), mav (mentor)
MFC after: 1 week
Relnotes: yes
Differential Revision:

3 days Do not run AES-CBC or AES-GCM tests on non-AES crypto(4) drivers
cem [Thu, 21 Sep 2017 18:06:21 +0000 (18:06 +0000)] Do not run AES-CBC or AES-GCM tests on non-AES crypto(4) drivers

For some reason, we only skipped AES-XTS tests if a driver was not in the
aesmodules list.  Skip other AES modes as well to prevent spurious failures
in non-AES drivers.

Sponsored by: Dell EMC Isilon

3 days agoModernize calls to vm_page_unwire(). As of r288122, vm_page_unwire()
alc [Thu, 21 Sep 2017 15:32:41 +0000 (15:32 +0000)]
Modernize calls to vm_page_unwire().  As of r288122, vm_page_unwire()
accepts PQ_NONE as the specified queue and returns a Boolean indicating
whether the page's wire count transitioned to zero.  Use these features
in dev/drm2.

Reviewed by: kib, markj
MFC after: 1 week

3 days agolibefi: devicename.c cleanups
tsoome [Thu, 21 Sep 2017 15:30:20 +0000 (15:30 +0000)]
libefi: devicename.c cleanups

Remove duplicated free()+return statements, default unit to 0
and improve strtol error processing.

3 days agoWe use a few different ifdef's names to check if we are using Casper or not,
oshogbo [Thu, 21 Sep 2017 14:41:41 +0000 (14:41 +0000)]
We use a few different ifdef's names to check if we are using Casper or not,
let's standardize this. Now we are always use WITH_CASPER name.

Discussed with: emaste@
MFC after: 1 month

3 days agoAmmend bin/cat/cat.c so the output is the same aside
sevan [Thu, 21 Sep 2017 14:14:49 +0000 (14:14 +0000)]
Ammend bin/cat/cat.c so the output is the same aside
from blank lines being numbered or unnumbered, depending on whether cat
was invoked with -ne or -be.

At present, when cat is invoked with -be, there is an aditional
difference that the '$' on blank lines is placed on the far left of the

Discussed in bug 210607.

While here, revert the workaround from r304035 which skipped the unit test for
this issue previously.

PR: 210607
Submitted by: myself
Reviewed by: bdrewery
Obtained from: NetBSD
Relnotes: yes
Differential Revision:

3 days agobridge: Set module version
kp [Thu, 21 Sep 2017 14:14:01 +0000 (14:14 +0000)]
bridge: Set module version

This ensures that the loader will not load the module if it's also built in to
the kernel.

PR: 220860
Submitted by: Eugene Grosbein <>
Reported by: Marie Helene Kvello-Aune <>

3 days agoCode cleanup, no functional change.
tuexen [Thu, 21 Sep 2017 11:56:31 +0000 (11:56 +0000)]
Code cleanup, no functional change.

MFC after: 1 week

3 days agoPlug memory leak in case when nvlist allocation succeeds, but nvpair
oshogbo [Thu, 21 Sep 2017 10:28:22 +0000 (10:28 +0000)]
Plug memory leak in case when nvlist allocation succeeds, but nvpair
allocation fails.

Submitted by: pjd@
MFC after: 1 month
Sponsored by: Wheel Systems

3 days agoSimplify the code by _not_ expecting success under 'fail'.
oshogbo [Thu, 21 Sep 2017 10:18:02 +0000 (10:18 +0000)]
Simplify the code by _not_ expecting success under 'fail'.

Submitted by: pjd@ and oshogbo@
MFC after: 1 month
Sponsored by: Wheel Systems

3 days agoIMHO it is possible that failure will be treated as success because we don't
oshogbo [Thu, 21 Sep 2017 10:16:44 +0000 (10:16 +0000)]
IMHO it is possible that failure will be treated as success because we don't
initialize nvp on every loop iteration and the code under 'fail'(!) label
detects success by checking of nvp != NULL.

Submitted by: pjd@
MFC after: 1 month
Sponsored by:   Wheel Systems

3 days agoFree 'value' only once we are done freeing all individual
oshogbo [Thu, 21 Sep 2017 10:14:43 +0000 (10:14 +0000)]
Free 'value' only once we are done freeing all individual

Submitted by:   pjd@
MFC after: 1 month
Found by:       scan-build
Sponsored by:   Wheel Systems

3 days agoRemove an 'unused' function.
n_hibma [Thu, 21 Sep 2017 10:13:48 +0000 (10:13 +0000)]
Remove an 'unused' function.

This function was only set in and only at the very end after
the disk image had been successfully created. The only difference will be
that the message 'Error encountered. Please check...' will not appear if exits with an error after the disk image has been created.

3 days agoBecause nvp wasn't initialized on every loop iteration once we jumped
oshogbo [Thu, 21 Sep 2017 10:10:42 +0000 (10:10 +0000)]
Because nvp wasn't initialized on every loop iteration once we jumped
to 'fail' on error it was treated as success, because nvp!=NULL. Fix this
by not handling success under 'fail' label and by using separate variable
for parent nvpair.

If we succeeded to allocate nvlist, but failed to allocated nvpair we
would leak nvls[ii] on return. Destroy it when we cannot allocate nvpair,
before we goto fail.

Submitted by: pjd@ and oshogbo@ (minor changes)
Found by:       scan-build
MFC after: 1 month
Sponsored by: Wheel Systems

3 days agoMake the code consistent by always using 'fail' label.
oshogbo [Thu, 21 Sep 2017 10:06:00 +0000 (10:06 +0000)]
Make the code consistent by always using 'fail' label.

Submitted by: pjd@ and oshogbo@
MFC after: 1 month
Sponsored by: Wheel Systems

3 days agoThe 'while (array != NULL) { }' suggests scan-build that array may be
oshogbo [Thu, 21 Sep 2017 10:03:14 +0000 (10:03 +0000)]
The 'while (array != NULL) { }' suggests scan-build that array may be
initially NULL, which is not possible. Change the loop to
'do {} while (array != NULL)' to satisfy scan-build and assert that
array really cannot be NULL just in case.

Submitted by: pjd@
Found by: scan-build
MFC after: 1 month
Sponsored by: Wheel Systems

3 days agoRemove redundant initialization. Don't use variable - just return the value.
oshogbo [Thu, 21 Sep 2017 10:00:16 +0000 (10:00 +0000)]
Remove redundant initialization. Don't use variable - just return the value.
Make scan-build happy by casting to 'void *' instead of 'void **'.

Submitted by: pjd@
MFC after: 1 month
Found by: scan-build and cppcheck
Sponsored by: Wheel Systems

3 days agoFree the control structure after using is, not before.
tuexen [Thu, 21 Sep 2017 09:47:56 +0000 (09:47 +0000)]
Free the control structure after using is, not before.
Found by Coverity while scanning the usrsctp library.
MFC after: 1 week

3 days agoFix up style for consistency.
n_hibma [Thu, 21 Sep 2017 09:27:44 +0000 (09:27 +0000)]
Fix up style for consistency.

3 days agoSpeling mistakes.
n_hibma [Thu, 21 Sep 2017 09:22:41 +0000 (09:22 +0000)]
Speling mistakes.

3 days agoNo need to wakeup, since sctp_add_to_readq() does it.
tuexen [Thu, 21 Sep 2017 09:18:05 +0000 (09:18 +0000)]
No need to wakeup, since sctp_add_to_readq() does it.

MFC after: 1 week

3 days Add a seatbelt that we're actually testing anything
cem [Thu, 21 Sep 2017 05:46:28 +0000 (05:46 +0000)] Add a seatbelt that we're actually testing anything

Without nist-kat installed, is a no-op.  Showing 'success' in
that case is unhelpful.

Sponsored by: Dell EMC Isilon

3 days agoAdd a few definitions for Flex File Layout for pNFS.
rmacklem [Thu, 21 Sep 2017 00:41:12 +0000 (00:41 +0000)]
Add a few definitions for Flex File Layout for pNFS.

These definitions will be used by a future commit.

3 days agoRemove an ancient comment about the existence of READ(16) and WRITE(16).
jkim [Thu, 21 Sep 2017 00:03:59 +0000 (00:03 +0000)]
Remove an ancient comment about the existence of READ(16) and WRITE(16).

MFC after: 3 days

4 days agoUse in_localip() function instead of unlocked access to addresses hash
ae [Wed, 20 Sep 2017 22:35:28 +0000 (22:35 +0000)]
Use in_localip() function instead of unlocked access to addresses hash
to determine that an address is our local.

PR: 220078
MFC after: 1 week

4 days agoDo not acquire IPFW_WLOCK when a named object is created and destroyed.
ae [Wed, 20 Sep 2017 22:00:06 +0000 (22:00 +0000)]
Do not acquire IPFW_WLOCK when a named object is created and destroyed.

Acquiring of IPFW_WLOCK is requried for cases when we are going to
change some data that can be accessed during processing of packets flow.
When we create new named object, there are not yet any rules, that
references it, thus holding IPFW_UH_WLOCK is enough to safely update
needed structures. When we destroy an object, we do this only when its
reference counter becomes zero. And it is safe to not acquire IPFW_WLOCK,
because noone references it. The another case is when we failed to finish
some action and thus we are doing rollback and destroying an object, in
this case it is still not referenced by rules and no need to acquire

This also fixes panic with INVARIANTS due to recursive IPFW_WLOCK acquiring.

MFC after: 1 week
Sponsored by: Yandex LLC

4 days agoFix queue depth for nda.
imp [Wed, 20 Sep 2017 21:42:25 +0000 (21:42 +0000)]
Fix queue depth for nda.

1/4 of the number of queues times queue entries is too limiting. It
works up to about 4k IOPS / 3.0GB/s for hardware that can do
4.4k/3.2GB/s with nvd. 3/4 works better, though it highlights issues
in the fairness of nda's choice of TRIM vs READ. That will be fixed

4 days agoProtect the address workqueue timer by a mutex.
tuexen [Wed, 20 Sep 2017 21:29:54 +0000 (21:29 +0000)]
Protect the address workqueue timer by a mutex.

MFC after: 1 week

4 days agocam iosched: Call cam_iosched_limiter_init() after ios->current is set to the default
imp [Wed, 20 Sep 2017 21:26:01 +0000 (21:26 +0000)]
cam iosched: Call cam_iosched_limiter_init() after ios->current is set to the default

Previously ios->current was set to 0 until the first
cam_iosched_cl_maybe_steer() call.

PR: 221954
Obtained from: ElectroBSD
Submitted by: Fabian Keil
Differential Revision:

4 days agocam iosched: Schedule cam_iosched_ticker() quanta times per second
imp [Wed, 20 Sep 2017 21:25:56 +0000 (21:25 +0000)]
cam iosched: Schedule cam_iosched_ticker() quanta times per second

Previously callout_reset() was called with a "ticks" value that was
off by one.  As a result cam_iosched_ticker() was called a bit too
frequently: On systems with hz=1000 a quanta value of 200 resulted in
~250 calls and a value of 100 in ~111 calls.

For the "queue_depth" and "bandwidth" limiters the difference doesn't
matter but the "iops" limiter depends on the scheduling to enforce the
correct maximum.

PR: 221956
Obtained from: ElectroBSD
Submitted by: Fabian Keil
Differential Revision:

4 days agocam iosched: Add a handler for the quanta sysctl to enforce valid values
imp [Wed, 20 Sep 2017 21:19:53 +0000 (21:19 +0000)]
cam iosched: Add a handler for the quanta sysctl to enforce valid values

Invalid values can result in devision-by-zero panics or other
undefined behaviour so lets not allow them.

PR: 221957
Obtained from: ElectroBSD
Submitted by: Fabian Keil
Differential Revision:

4 days agocam iosched: Use the write queue for BIO_ZONE commands
imp [Wed, 20 Sep 2017 21:13:20 +0000 (21:13 +0000)]
cam iosched: Use the write queue for BIO_ZONE commands

Use the write queue for BIO_ZONE commands so they can't get executed
ahead of writes that were sent after them. More generally, since they
introduce strong ordering into the list, they need to go to the write
queue (which is the only queue that BIO_ORDERED is honored for at the
moment). In fact, fix mismatch between queueing and dequeueing code by
changing this to queue all non-reads (and non-trims) to the write

As a side effect this prevents the kernel message:
kernel: Found bio_cmd = 0x9
which cam_iosched_next_bio() emits when finding commands
other than BIO_READ in the read queue.

PR: 221973
Obtained from: ElectroBSD
Submitted by: Fabian Keil
Differential Revision:

4 days agoFix iflib netmap RX
shurd [Wed, 20 Sep 2017 20:40:49 +0000 (20:40 +0000)]
Fix iflib netmap RX

RXQ setup for netmap was broken because netmap_rxq_init was getting called
before IFDI_INIT - thus we ended up with ring tail pointer being reset to zero.

Reviewed by: sbruno
Approved by: sbruno (mentor)
Sponsored by: Limelight Networks
Differential Revision:

4 days ago1. ql_hw.c:
davidcs [Wed, 20 Sep 2017 20:07:45 +0000 (20:07 +0000)]
1. ql_hw.c:
In ql_hw_send() return EINVAL when TSO framelength exceeds max
supported length by HW.(davidcs)
2. ql_os.c:
In qla_send() call bus_dmamap_unload before freeing mbuf or
recreating dmmamap.(davidcs)
In qla_fp_taskqueue() Add additional checks for IFF_DRV_RUNNING
Fix qla_clear_tx_buf() call bus_dmamap_sync() before freeing

MFC after:5 days

4 days agoaesni(4): Fix another trivial typo (aensi -> aesni)
cem [Wed, 20 Sep 2017 18:31:36 +0000 (18:31 +0000)]
aesni(4): Fix another trivial typo (aensi -> aesni)

Sponsored by: Dell EMC Isilon

4 days agox86: Decode AMD "Extended Feature Extensions ID EBX" bits
cem [Wed, 20 Sep 2017 18:30:37 +0000 (18:30 +0000)]
x86: Decode AMD "Extended Feature Extensions ID EBX" bits

In particular, this determines CPU support for the CLZERO instruction.

(No, I am not making this name up.)

Sponsored by: Dell EMC Isilon

4 days agoaesni(4): Fix trivial typo (AQUIRE -> ACQUIRE)
cem [Wed, 20 Sep 2017 17:53:25 +0000 (17:53 +0000)]
aesni(4): Fix trivial typo (AQUIRE -> ACQUIRE)

Sponsored by: Dell EMC Isilon

4 days agoMFV r323789: 8473 scrub does not detect errors on active spares
asomers [Wed, 20 Sep 2017 16:31:00 +0000 (16:31 +0000)]
MFV r323789:  8473 scrub does not detect errors on active spares

Scrubbing is supposed to detect and repair all errors in the pool. However,
it wrongly ignores active spare devices. The problem can easily be
reproduced in OpenZFS at git rev 0ef125d with these commands:

truncate -s 64m /tmp/a /tmp/b /tmp/c
sudo zpool create testpool mirror /tmp/a /tmp/b spare /tmp/c
sudo zpool replace testpool /tmp/a /tmp/c
/bin/dd if=/dev/zero bs=1024k count=63 oseek=1 conv=notrunc of=/tmp/c
sudo zpool scrub testpool
zpool status testpool # Will show 0 errors, which is wrong
sudo zpool offline testpool /tmp/a
sudo zpool scrub testpool
zpool status testpool # Will show errors on /tmp/c,
      # which should've already been fixed

FreeBSD head is partially affected: the first scrub will detect some errors, but the second scrub will detect more.

Reviewed by: Andy Stormont <>
Reviewed by: Matt Ahrens <>
Reviewed by: George Wilson <>
Approved by: Richard Lowe <>

MFC after: 1 week
Sponsored by: Spectra Logic Corp

4 days agoBootstrap etcupdate(8) and mergemaster(8) databases when creating
gjb [Wed, 20 Sep 2017 15:49:12 +0000 (15:49 +0000)]
Bootstrap etcupdate(8) and mergemaster(8) databases when creating
virtual machine images and embedded images, similar to what is
done when extracting base.txz to the target root filesystem in
an new installation.

Noticed by: marius
Tested with: head@r323729
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

4 days agoRegenerate usb.conf .
hselasky [Wed, 20 Sep 2017 15:00:00 +0000 (15:00 +0000)]
Regenerate usb.conf .

MFC after: 1 week

4 days agoadd vfs_zfs.abd_chunk_size tunable
avg [Wed, 20 Sep 2017 08:36:31 +0000 (08:36 +0000)]
add vfs_zfs.abd_chunk_size tunable

It is reported that the default value of 4KB results in a substantial
memory use overhead (at least, on some configurations).  Using 1KB seems
to reduce the overhead significantly.

PR: 222377
Reported by: Sean Chittenden <>
MFC after: 1 week

4 days agofix memory leak in g_bio zone introduced in r320452, another ABD fallout
avg [Wed, 20 Sep 2017 08:27:21 +0000 (08:27 +0000)]
fix memory leak in g_bio zone introduced in r320452, another ABD fallout

I overlooked the fact that that ZIO_IOCTL_PIPELINE does not include
ZIO_STAGE_VDEV_IO_DONE stage.  We do allocate a struct bio for an ioctl
zio (a disk cache flush), but we never freed it.

This change splits bio handling into two groups, one for normal
read/write i/o that passes data around and, thus, needs the abd data
tranform; the other group is for "data-less" i/o such as trim and cache

PR: 222288
Reported by: Dan Nelson <>
Tested by: Borja Marcos <>
MFC after: 10 days

4 days agoMFV r323792: 8602 remove unused "dp_early_sync_tasks" field from "dsl_pool" structure
avg [Wed, 20 Sep 2017 07:26:52 +0000 (07:26 +0000)]
MFV r323792: 8602 remove unused "dp_early_sync_tasks" field from "dsl_pool" structure

  When I landed the fix for 8558, I incorrectly added the "dp_early_sync_tasks"
  field to the "dsl_pool" structure. This field is used in DelphixOS, but not in
  illumos. It was incorrectly pulled into illumos, so this bug is to remove it
  from the structure.

Reviewed by: Serapheim Dimitropoulos <>
Reviewed by: Matthew Ahrens <>
Approved by: Robert Mustacchi <>
Author: Prakash Surya <>

MFC after: 1 week