]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoinit: use explicit_bzero() for clearing passwords
Kyle Evans [Wed, 3 Mar 2021 03:38:37 +0000 (21:38 -0600)]
init: use explicit_bzero() for clearing passwords

This is a nop in practice, because it cannot be proven that this
particular bzero() is not significant.  Make it explicit anyways, rather
than relying on an implementation detail of how the password is
collected.

Discussed with: Andrew Gierth <andrew tao146 riddles org uk>

(cherry picked from commit 852f70b24043885f0e438e8fecedd482a9a96d5e)

3 years agoMFC 874b1a35486b570513680c3d456b062ba097e1d9:
Cy Schubert [Tue, 23 Mar 2021 03:11:58 +0000 (20:11 -0700)]
MFC 874b1a35486b570513680c3d456b062ba097e1d9:

ipfilter: simplify ipf_proxy_check() return codes

ipf_proxy_check() returns -1 for an error and 0 or 1 for success.
ipf_proxy_check()'s callers check for error and if the return code
is 0, they change it to 1 prior to returning to their callers. Simply
by returning -1 or 1 we reduce complexity and cycles burned changing
0 to 1.

(cherry picked from commit 874b1a35486b570513680c3d456b062ba097e1d9)

3 years agoMFC 4e38478c595a:
Hans Petter Selasky [Thu, 25 Mar 2021 15:55:02 +0000 (16:55 +0100)]
MFC 4e38478c595a:
ipoib: Fix incorrectly computed IPOIB_CM_RX_SG value.

The computed IPOIB_CM_RX_SG is too small. It doesn't account for fallback
to mbuf clusters when jumbo frames are not available and it also doesn't
account for the packet header and trailer mbuf.

This causes a memory overwrite situation when IPOIB_CM is configured.

While at it add a kernel assert to ensure the mapping array is not overwritten.

PR: 254474
Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 4e38478c595a9e6225b525890d7ee269a203c200)

3 years agoMFC 31070b5bc77a:
Hans Petter Selasky [Tue, 9 Mar 2021 16:41:18 +0000 (17:41 +0100)]
MFC 31070b5bc77a:
Set default alternate setting when USB audio devices are not in use,
to activate power save features.

Differential Revision:  https://reviews.freebsd.org/D28032
Suggested by: Shichun_Ma@Dell.com
Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 31070b5bc77a499009a835650eb9d4bf2eceaa15)

3 years agoFix warning about signed comparison and drop WARNS for ktrdump(8).
Dmitry Chagin [Wed, 24 Mar 2021 07:51:25 +0000 (10:51 +0300)]
Fix warning about signed comparison and drop WARNS for ktrdump(8).

Reviewed By: jhb, imp
Differential Revision: https://reviews.freebsd.org/D29381

(cherry picked from commit 9e5aeba51b431256adfd18b087ee61b09bfd6a79)

3 years agoamd64: Make KPDPphys local to pmap.c
Mark Johnston [Wed, 24 Mar 2021 13:55:22 +0000 (09:55 -0400)]
amd64: Make KPDPphys local to pmap.c

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 7ae2e703366e5ac56373509ececae53ecaa5bc59)

3 years agoFix several dev_clone callbacks to avoid out-of-bounds reads
Mark Johnston [Sun, 28 Mar 2021 15:08:36 +0000 (11:08 -0400)]
Fix several dev_clone callbacks to avoid out-of-bounds reads

Use strncmp() instead of bcmp(), so that we don't have to find the
minimum of the string lengths before comparing.

Reviewed by: kib
Reported by: KASAN
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29463

(cherry picked from commit 3428b6c050d102ba7f95514b29f4f5685d76b645)

3 years agopf tests: pfsync bulk update test
Kristof Provost [Mon, 15 Mar 2021 13:10:55 +0000 (14:10 +0100)]
pf tests: pfsync bulk update test

Test that pfsync works as expected with bulk updates. That is, create
some state before setting up the second firewall. Let that firewall
request a bulk update so it can catch up, and check that it got the
state which was created before it enable pfsync.

PR: 254236
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D29272

(cherry picked from commit 8ad7d25dfc808ca00300f7553a9b28dfc0e99c18)

3 years agopfsync: Unconditionally push packets when requesting state updates
Thomas Kurschel [Mon, 15 Mar 2021 13:28:52 +0000 (14:28 +0100)]
pfsync: Unconditionally push packets when requesting state updates

When we request a bulk sync we need to ensure we actually send out that
request, not just buffer it until we have enough data to send a full
packet.

PR: 254236
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D29271

(cherry picked from commit 9f2e5184173f6af70306678b018270df9a9600f2)

3 years agorpc.lockd: Unconditionally close fds as daemon
Caleb St. John [Fri, 26 Mar 2021 18:00:14 +0000 (14:00 -0400)]
rpc.lockd: Unconditionally close fds as daemon

When lockd is configured with a debug level of > 0 and foreground == 0,
the process is daemonized with a truth noclose argument to daemon().
This doesn't seem to be the desired behavior because that prevents
stdout and stderr from being closed, however, stdout and stderr aren't
used anywhere else. Furthermore, the man pages state that with a higher
debug level it will use the syslog facilities to do so.

Submitted by: Caleb St. John
Discussed with: rmacklem
MFC after: 3 days
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D29415

(cherry picked from commit badcfbacf3840a4097bb79192054481c7674e7d2)

3 years agoalign nfsdumpstate column output
Caleb St. John [Wed, 24 Mar 2021 20:33:41 +0000 (16:33 -0400)]
align nfsdumpstate column output

There are scenarios where an NFS client will mount an NFSv4 export
without specifying a callback address.

When running nfsdumpstate under this circumstance, the column output is
shifted incorrectly which places the "ClientID" value underneath the
"Clientaddr" column.

This diff is a small cosmetic change that prints a blank in the
"Clientaddr" column and ensures the data for the columns are aligned
appropriately.

Submitted by: Caleb St. John
Reviewed by: sef (previous version)
MFC after: 3 days
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D18958

(cherry picked from commit efad9c8ba3cec7f6e39b128b90afab70701fd8d9)

3 years agoHyper-V: hn: Initialize the internal field of per packet info on tx path
Wei Hu [Mon, 15 Mar 2021 10:20:52 +0000 (10:20 +0000)]
Hyper-V: hn: Initialize the internal field of per packet info on tx path

The RSC support feature introduced a bit field "rm_internal" in
struct rndis_pktinfo with total size unchanged.

The guest does not use this field in the tx path. However we need to
initialize it to zero in case older hosts which are not aware of this
field.

Fixes: a491581f ("Hyper-V: hn: Enable vSwitch RSC support")
MFC after: 2 weeks
Sponsored by: Microsoft

(cherry picked from commit 805dbff6c36a6cd84491aa53a02315fa025734cc)

3 years agoHyper-V: hn: Enable vSwitch RSC support in hn netvsc driver
Wei Hu [Fri, 12 Mar 2021 04:35:16 +0000 (04:35 +0000)]
Hyper-V: hn: Enable vSwitch RSC support in hn netvsc driver

Receive Segment Coalescing (RSC) in the vSwitch is a feature available in
Windows Server 2019 hosts and later. It reduces the per packet processing
overhead by coalescing multiple TCP segments when possible. This happens
mostly when TCP traffics are among different guests on same host.
This patch adds netvsc driver support for this feature.

The patch also updates NVS version to 6.1 as needed for RSC
enablement.

MFC after: 2 weeks
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D29075

(cherry picked from commit a491581f3f8df07cdff0236bd556895205929af4)

3 years agoHyper-V: hn: Store host hash value in flowid
Wei Hu [Wed, 24 Feb 2021 05:07:46 +0000 (05:07 +0000)]
Hyper-V: hn: Store host hash value in flowid

When rx packet contains hash value sent from host, store it in
the mbuf's flowid field so when the same mbuf is on the tx path,
the hash value can be used by the host to determine the outgoing
network queue.

MFC after: 2 weeks
Sponsored by: Microsoft

(cherry picked from commit 80f39bd95f22322152709ea5fae3a3c546044c9c)

3 years agoaccept_filter: Fix filter parameter handling
Mark Johnston [Thu, 25 Mar 2021 21:55:20 +0000 (17:55 -0400)]
accept_filter: Fix filter parameter handling

For filters which implement accf_create, the setsockopt(2) handler
caches the filter name in the socket, but it also incorrectly frees the
buffer containing the copy, leaving a dangling pointer.  Note that no
accept filters provided in the base system are susceptible to this, as
they don't implement accf_create.

Reported by: Alexey Kulaev <alex.qart@gmail.com>
Discussed with: emaste
Security: kernel use-after-free
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 653a437c04440495cd8e7712c7cf39444f26f1ee)

3 years agomountd(8): generate a syslog message when the "V4:" line is missing
Rick Macklem [Tue, 9 Mar 2021 00:08:02 +0000 (16:08 -0800)]
mountd(8): generate a syslog message when the "V4:" line is missing

Daniel reported that NFSv4 mounts were not working despite having
set "nfsv4_server_enable=YES" in /etc/rc.conf.  Mountd was logging a
message that there was no /etc/exports file.
He noted that creating a /etc/exports file with a "V4:" line in it
was needed make NFSv4 mounts work.
At least one "V4:" line in one of the exports(5) file(s) is needed to
make NFSv4 mounts work. This patch fixes mountd.c so that it logs a
message indicting that there is no "V4:" line in any exports(5)
file when NFSv4 mounts are enabled.
To avoid this message being generated erroneously, /etc/rc.d/mountd
is updated to make sure vfs.nfsd.server_max_nfsvers is properly set
before mountd(8) is started.

PR: 253901

(cherry picked from commit 09673fc0f36dd1cca74940a240a9ed0f62228084)

3 years agoOpenSSL: Regen manual pages for 1.1.1k
Jung-uk Kim [Thu, 25 Mar 2021 16:17:52 +0000 (12:17 -0400)]
OpenSSL: Regen manual pages for 1.1.1k

(cherry picked from commit 7595394130a163b7ff53d9ef3f28fcb87f629d17)

3 years agoOpenSSL: Merge OpenSSL 1.1.1k
Jung-uk Kim [Thu, 25 Mar 2021 15:45:19 +0000 (11:45 -0400)]
OpenSSL: Merge OpenSSL 1.1.1k

Merge commit '94fa08a4bcdfbb3434b025d67d014af3b18e5380'

(cherry picked from commit b6c1fdcdf5033d20c61cc77d66f58f31cc65e2ba)

3 years agortsold: Fix validation of RDNSS options
Mark Johnston [Sun, 21 Mar 2021 18:18:10 +0000 (14:18 -0400)]
rtsold: Fix validation of RDNSS options

The header specifies the size of the option in multiples of eight bytes.
The option consists of an eight-byte header followed by one or more IPv6
addresses, so the option is invalid if the size is not equal to 1+2n for
some n>0.  Check this.

The bug can cause random stack data to be formatted as an IPv6 address
and passed to resolvconf(8), but a host able to trigger the bug may also
specify arbitrary addresses this way.

Reported by: Q C <cq674350529@gmail.com>
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 1af332a7d8f86b6fcc1f0f575fe5b06021b54f4c)

3 years agoMFC eeb26cf52c4c51e1571253d57684c442aa79a98d:
Cy Schubert [Wed, 17 Mar 2021 00:06:17 +0000 (17:06 -0700)]
MFC eeb26cf52c4c51e1571253d57684c442aa79a98d:

wpa: import fix for P2P provision discovery processing vulnerability

Latest version available from: https://w1.fi/security/2021-1/

Vulnerability

A vulnerability was discovered in how wpa_supplicant processes P2P
(Wi-Fi Direct) provision discovery requests. Under a corner case
condition, an invalid Provision Discovery Request frame could end up
reaching a state where the oldest peer entry needs to be removed. With
a suitably constructed invalid frame, this could result in use
(read+write) of freed memory. This can result in an attacker within
radio range of the device running P2P discovery being able to cause
unexpected behavior, including termination of the wpa_supplicant process
and potentially code execution.

Vulnerable versions/configurations

wpa_supplicant v1.0-v2.9 with CONFIG_P2P build option enabled

An attacker (or a system controlled by the attacker) needs to be within
radio range of the vulnerable system to send a set of suitably
constructed management frames that trigger the corner case to be reached
in the management of the P2P peer table.

Note: FreeBSD base does not enable P2P.
(cherry picked from commit eeb26cf52c4c51e1571253d57684c442aa79a98d)

3 years agoImplement pci_get_relaxed_ordering_enabled() helper function.
Hans Petter Selasky [Tue, 16 Mar 2021 15:06:42 +0000 (16:06 +0100)]
Implement pci_get_relaxed_ordering_enabled() helper function.

Discussed with: kib@
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 1acf24a044aaa0391c61af4abe7e018c3bf8a37c)

3 years agonvme: Replace potentially long DELAY() with pause().
Alexander Motin [Wed, 17 Mar 2021 14:30:40 +0000 (10:30 -0400)]
nvme: Replace potentially long DELAY() with pause().

In some cases like broken hardware nvme(4) may wait minutes for
controller response before timeout.  Doing so in a tight spin loop
made whole system unresponsive.

Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29309
Sponsored by: iXsystems, Inc.

(cherry picked from commit 4fbbe523653b6d2a0186aca38224efcab941deaa)

3 years agonetmap: fix issues in nm_os_extmem_create()
Vincenzo Maffione [Sat, 20 Mar 2021 17:15:50 +0000 (17:15 +0000)]
netmap: fix issues in nm_os_extmem_create()

- Call vm_object_reference() before vm_map_lookup_done().
- Use vm_mmap_to_errno() to convert vm_map_* return values to errno.
- Fix memory leak of e->obj.

Reported by: markj
Reviewed by: markj
MFC after: 1 week

(cherry picked from commit ee7ffaa2e6e08b63efb4673610875d40964d5058)

3 years agopf: pool/kpool conversion code
Kristof Provost [Thu, 11 Mar 2021 10:37:05 +0000 (11:37 +0100)]
pf: pool/kpool conversion code

stuct pf_pool and struct pf_kpool are different. We should not simply
bcopy() them.

Happily it turns out that their differences were all pointers, and the
userspace provided pointers were overwritten by the kernel, so this did
actually work correctly, but we should fix it anyway.

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

(cherry picked from commit 15b82e00a1640d1b9a1d720c95f65e580be30187)

3 years agoMFC dfb33cb0ef48:
Hans Petter Selasky [Wed, 10 Mar 2021 12:26:09 +0000 (13:26 +0100)]
MFC dfb33cb0ef48:
Allocating the LinuxKPI current structure from a software interrupt thread
must be done using the M_NOWAIT flag after 1ae20f7c70ea .

Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit dfb33cb0ef48084da84072244e8ca486dfcf3a96)

3 years agoMFC d1cbe7908986:
Hans Petter Selasky [Wed, 10 Mar 2021 09:50:01 +0000 (10:50 +0100)]
MFC d1cbe7908986:
Allocating the LinuxKPI current structure from an interrupt thread must be
done using the M_NOWAIT flag after 1ae20f7c70ea .

Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit d1cbe79089868226625c12ef49f51214d79aa427)

3 years agoMFC 6eb60f5b7f7d:
Hans Petter Selasky [Wed, 10 Mar 2021 11:21:01 +0000 (12:21 +0100)]
MFC 6eb60f5b7f7d:
Use the word "LinuxKPI" instead of "Linux compatibility", to not confuse with
user-space Linux compatibility support. No functional change.

Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 6eb60f5b7f7df1a59de139260aebfa0aa5f6d79e)

3 years agoMFC ebe5cf355dca:
Hans Petter Selasky [Fri, 5 Mar 2021 11:44:06 +0000 (12:44 +0100)]
MFC ebe5cf355dca:
Implement basic support for allocating memory from a specific numa node
in the LinuxKPI.

Differential Revision: https://reviews.freebsd.org/D29077
Reviewed by: markj@ and kib@
Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit ebe5cf355dca1d7827a70b99a9d9c4f97f78691d)

3 years agoMFC c743a6bd4fc0:
Hans Petter Selasky [Sat, 6 Mar 2021 10:25:12 +0000 (11:25 +0100)]
MFC c743a6bd4fc0:
Implement mallocarray_domainset(9) variant of mallocarray(9).

Reviewed by: kib @
Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit c743a6bd4fc0d1be30f9bc9996333ac0ba079563)

3 years agoDrop EFI_STAGING_SIZE back down to 64M
Warner Losh [Thu, 17 Dec 2020 17:02:09 +0000 (17:02 +0000)]
Drop EFI_STAGING_SIZE back down to 64M

vmware can't cope with anything larger than 64MB. Drop this back to
64MB everywhere but arm.

PR: 251866
MFC After: 1 week

(cherry picked from commit 4d6047edb675e52b8fad57135ab3ded8e66d0dac)

3 years agoO_RELATIVE_BENEATH: return ENOTCAPABLE instead of EINVAL for abs path
Konstantin Belousov [Sun, 28 Feb 2021 23:59:12 +0000 (01:59 +0200)]
O_RELATIVE_BENEATH: return ENOTCAPABLE instead of EINVAL for abs path

Tested by: pho

(cherry picked from commit 28cd3a673e0e32b009fd573764956b280d1affe1)

3 years agonameicap_check_dotdot: trim tracker on check
Konstantin Belousov [Sun, 28 Feb 2021 00:15:21 +0000 (02:15 +0200)]
nameicap_check_dotdot: trim tracker on check

Tested by: pho

(cherry picked from commit 49c98a4bf3a87ace0df99056fa683805c1645e61)

3 years agoAdd nameicap_cleanup_from(), to clean tracker list starting from some element
Konstantin Belousov [Sun, 28 Feb 2021 00:14:43 +0000 (02:14 +0200)]
Add nameicap_cleanup_from(), to clean tracker list starting from some element

Tested by: pho

(cherry picked from commit e8a2862aa0384c75603f801625e309a3dae0ed05)

3 years agonameicap_tracker_add: avoid duplicates in the tracker list
Konstantin Belousov [Sun, 28 Feb 2021 00:13:19 +0000 (02:13 +0200)]
nameicap_tracker_add: avoid duplicates in the tracker list

Tested by: pho

(cherry picked from commit 2388ad7c293fbc89ee239a1adcb87fd158c4e8e9)

3 years agoDo not call nameicap_tracker_add() for dotdot case.
Konstantin Belousov [Sun, 28 Feb 2021 00:12:43 +0000 (02:12 +0200)]
Do not call nameicap_tracker_add() for dotdot case.

Tested by: pho

(cherry picked from commit 59e749428111c029116a4302a544c7cc18b33772)

3 years agoopen(2): Remove O_BENEATH and AT_BENEATH
Konstantin Belousov [Tue, 16 Feb 2021 03:31:40 +0000 (05:31 +0200)]
open(2): Remove O_BENEATH and AT_BENEATH

Discussed with: emaste, re
Tested by: pho

(cherry picked from commit 20e91ca36a56b8db1e6677f577ad011b66dd6eb3)

3 years agobc: Upgrade to version 3.2.4
Stefan Eßer [Sun, 27 Dec 2020 20:53:09 +0000 (21:53 +0100)]
bc: Upgrade to version 3.2.4

This update changes the behavior of "-e" or "-f" in BC_ENV_ARGS:

Use of these options on the command line makes bc exit after executing
the given commands. These options will not cause bc to exit when
passed via the environment (but EOF in STDIN or -e or -f on the
command line will make bc exit as before).

The same applies to DC_ENV_ARGS with regard to the dc program.

Make length(0) and length(0.0) return 1 for compatibility with GNU bc
and the traditional FreeBSD bc.

Fix a potential division by zero error in a non-standard (extended)
math library function.

(cherry picked from commit e458944cf9deec51d03ec751050a58ddf43e796f)
(cherry picked from commit 9a995fe186257315e7b3d01e24c55d86bb18fd32)
(cherry picked from commit 4aa71da8dc004aa5027836259433e5bff3cd9104)
(cherry picked from commit 028616d0dd69a3da7a30cb94d35f040bf2ced6b9)
(cherry picked from commit f165641df4da1752f8bb1f55c1e602cdb657fba4)
(cherry picked from commit 893ecb52db5ed47d6c1e8698334d34e0df651612)

3 years agoUse C11 anonymous unions.
Dmitry Chagin [Mon, 10 Jun 2019 05:28:03 +0000 (05:28 +0000)]
Use C11 anonymous unions.

PR: 215202
Reported by: glebius

(cherry picked from commit a5ec4a9dba5629dfe146ae9534e91e5e957747eb)

3 years agolinux: make timerfd_settime(2) set expirations count to zero
shu [Wed, 3 Feb 2021 16:51:45 +0000 (16:51 +0000)]
linux: make timerfd_settime(2) set expirations count to zero

On Linux, read(2) from a timerfd file descriptor returns an unsigned
8-byte integer (uint64_t) containing the number of expirations
that have occurred, if the timer has already expired one or more
times since its settings were last modified using timerfd_settime(),
or since the last successful read(2).  That's to say, once we do
a read or call timerfd_settime(), timer fd's expiration count should
be zero.  Some Linux applications create timerfd and add it to epoll
with LT mode, when event comes, they do timerfd_settime instead
of read to stop event source from trigger.  On FreeBSD,
timerfd_settime(2) didn't set the count to zero, which caused high
CPU utilization.

PR: 252820
Submitted by: ankohuu_outlook.com (Shunchao Hu)
Differential Revision: https://reviews.freebsd.org/D28231

(cherry picked from commit ae71b794cbed19e5e25effc3438720ad452ab87c)

3 years agoMerge tcsh 6.22.03-ceccc7f
Dmitry Chagin [Sun, 14 Mar 2021 16:33:13 +0000 (19:33 +0300)]
Merge tcsh 6.22.03-ceccc7f

PR: 252663

(cherry picked from commit 5224c2a3bc95b431f729f3692f264395248d8acc)

3 years agoRemove wrong inline keyword.
Dmitry Chagin [Thu, 30 May 2019 16:11:20 +0000 (16:11 +0000)]
Remove wrong inline keyword.

Reported by: markj
MFC after: 1 week

(cherry picked from commit c8124e20e5493651b5adca11c0c796cdcf5b2696)

3 years agoComplete LOCAL_PEERCRED support. Cache pid of the remote process in the
Dmitry Chagin [Thu, 30 May 2019 14:24:26 +0000 (14:24 +0000)]
Complete LOCAL_PEERCRED support. Cache pid of the remote process in the
struct xucred. Do not bump XUCRED_VERSION as struct layout is not changed.

PR: 215202
Differential Revision: https://reviews.freebsd.org/D20415

(cherry picked from commit c5afec6e895a11c64f58eb99e493adb8ad5dc361)

3 years agoAdd warning to the Linuxulator makefiles that building it outside of a
Dmitry Chagin [Mon, 13 May 2019 18:28:40 +0000 (18:28 +0000)]
Add warning to the Linuxulator makefiles that building it outside of a
kernel does not make sence.

PR: 222861
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20179

(cherry picked from commit 6e4cf32e95841b4c3ef0caeb80802bf528a35cd0)

3 years agopf tests: Fix unsupported ping6 argument
Kristof Provost [Sat, 20 Mar 2021 14:47:50 +0000 (15:47 +0100)]
pf tests: Fix unsupported ping6 argument

ping6 (in stable/12) does not support '-t'. Change it to '-X'.

Direct commit to stable/12.

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

3 years agopf tests: Test tos/dscp matching
Kristof Provost [Wed, 3 Mar 2021 20:15:39 +0000 (21:15 +0100)]
pf tests: Test tos/dscp matching

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

(cherry picked from commit 9d3b2bcf761041bbe79da3de25f2e4142d90b46a)

3 years agopfctl: Add missing 'va' code point name
Kristof Provost [Thu, 4 Mar 2021 12:50:28 +0000 (13:50 +0100)]
pfctl: Add missing 'va' code point name

Add the 'va' (voice-admit, RFC5865) symbolic name.

Reviewed by: rgrimes, gbe (man page)
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29069

(cherry picked from commit b4e3f3c2de6e6dc614f99615e50d0d87f3367ca0)

3 years agofind(1): Refine the HISTORY within the manual page.
Gordon Bergling [Sat, 13 Mar 2021 18:28:26 +0000 (19:28 +0100)]
find(1): Refine the HISTORY within the manual page.

A simple find command appeared in Version 1 AT&T UNIX and was removed in
Version 3 AT&T UNIX. It was rewritten for Version 5 AT&T UNIX and later
be enhanced for the Programmer's Workbench (PWB). These changes were
later incorporated in AT&T UNIX v7.

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

(cherry picked from commit a9275d996c229a30879baa42a6d02d24663ac43b)

3 years agofind(1): Mark -not as an extensions to POSIX
Daniel Ebdrup Jensen [Tue, 23 Feb 2021 15:23:09 +0000 (16:23 +0100)]
find(1): Mark -not as an extensions to POSIX

While here, change mdoc macro from Ic to Fl.

PR: 253499
Reported by: Michael Siegel <bugcounterism at malbolge.net>

(cherry picked from commit 75e6f664c469927ca73ecd7b16a8058bc292a451)

3 years agonet80211: Fix a typo in a comment
Gordon Bergling [Sat, 13 Mar 2021 14:51:30 +0000 (15:51 +0100)]
net80211: Fix a typo in a comment

- destionation -> destination
- while here, fix some whitespace issues

(cherry picked from commit d197bf2b20e7efc6ffef520bf96d5f642e26a015)

3 years agoi386: Fix a few typos
Gordon Bergling [Sat, 13 Mar 2021 15:10:01 +0000 (16:10 +0100)]
i386: Fix a few typos

- wheter -> whether
- while here, fix some whitespace issues

(cherry picked from commit 564a3ac63abe166c6174ed3a58e78859a738ee58)

3 years agopf: Fully remove interrupt events on vnet cleanup
Kristof Provost [Wed, 10 Mar 2021 21:56:11 +0000 (22:56 +0100)]
pf: Fully remove interrupt events on vnet cleanup

swi_remove() removes the software interrupt handler but does not remove
the associated interrupt event.
This is visible when creating and remove a vnet jail in `procstat -t
12`.

We can remove it manually with intr_event_destroy().

PR: 254171
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29211

(cherry picked from commit cecfaf9bede9665d6a10f1e575cd5d575450cff7)

3 years agopf: Simplify cleanup
Kristof Provost [Wed, 10 Mar 2021 14:15:16 +0000 (15:15 +0100)]
pf: Simplify cleanup

We can now counter_u64_free(NULL), so remove the checks.

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

(cherry picked from commit 28dc2c954f5096ae594ed5cd7a83d66ce4bf1ded)

3 years agopf: Remove redundant kif != NULL checks
Kristof Provost [Wed, 10 Mar 2021 14:50:42 +0000 (15:50 +0100)]
pf: Remove redundant kif != NULL checks

pf_kkif_free() already checks for NULL, so we don't have to check before
we call it.

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

(cherry picked from commit 913e7dc3e0eb7df78ec0e7ecc7dd160a316a3ac6)

3 years agoaltq: Increase maximum number of CBQ and HFSC classes
Kristof Provost [Wed, 3 Mar 2021 10:06:49 +0000 (11:06 +0100)]
altq: Increase maximum number of CBQ and HFSC classes

In some configurations we need more classes than ALTQ supports by
default.  Increase the maximum number of classes we allow.
This will only cost us a comparatively trivial amount of memory, so
there's little reason not to do so.

If ever we find we want even more we may want to consider turning these
defines into a tunable, but for now do the easy thing.

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

(cherry picked from commit 448732b8e2d9bf4e2656a2e5a9e88cc58b88d4f4)

3 years agopf: Retrieve DSCP value from the IPv6 header
Kristof Provost [Wed, 3 Mar 2021 20:33:42 +0000 (21:33 +0100)]
pf: Retrieve DSCP value from the IPv6 header

Teach pf to read the DSCP value from the IPv6 header so that we can
match on them.

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

(cherry picked from commit f19323847ca894af8a58839f6a2a41691a8e2245)

3 years agopf: Factor out pf_krule_free()
Kristof Provost [Wed, 10 Mar 2021 10:10:04 +0000 (11:10 +0100)]
pf: Factor out pf_krule_free()

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

(cherry picked from commit 5e9dae8e149ae8848f52148b665f3a0d031ca40f)

3 years agonetmap: fix memory leak in NETMAP_REQ_PORT_INFO_GET
Vincenzo Maffione [Mon, 15 Mar 2021 17:39:18 +0000 (17:39 +0000)]
netmap: fix memory leak in NETMAP_REQ_PORT_INFO_GET

The netmap_ioctl() function has a reference counting bug in case of
NETMAP_REQ_PORT_INFO_GET command. When `hdr->nr_name[0] == '\0'`,
the function does not decrease the refcount of "nmd", which is
increased by netmap_mem_find(), causing a refcount leak.

Reported by: Xiyu Yang <sherllyyang00@gmail.com>
Submitted by: Carl Smith <carl.smith@alliedtelesis.co.nz>
MFC after: 3 days
PR: 254311

(cherry picked from commit 0ab5902e8ad93d0a9341dcce386b6c571ee02173)

3 years agons8250: don't drop IER_TXRDY on bus_grab/ungrab
Mitchell Horne [Wed, 10 Mar 2021 14:57:12 +0000 (10:57 -0400)]
ns8250: don't drop IER_TXRDY on bus_grab/ungrab

It has been observed that some systems are often unable to resume from
ddb after entering with debug.kdb.enter=1. Checking the status further
shows the terminal is blocked waiting in tty_drain(), but it never makes
progress in clearing the output queue, because sc->sc_txbusy is high.

I noticed that when entering polling mode for the debugger, IER_TXRDY is
set in the failure case. Since this bit is never tracked by the softc,
it will not be restored by ns8250_bus_ungrab(). This creates a race in
which a TX interrupt can be lost, creating the hang described above.
Ensuring that this bit is restored is enough to prevent this, and resume
from ddb as expected.

The solution is to track this bit in the sc->ier field, for the same
lifetime that TX interrupts are enabled.

PR: 223917, 240122
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 7e7f7beee732810d3afcc83828341ac3e139b5bd)

3 years agoFix bug 253158 - Panic: snapacct_ufs2: bad block - mksnap_ffs(8) crash
Kirk McKusick [Fri, 12 Feb 2021 05:31:16 +0000 (21:31 -0800)]
Fix bug 253158 - Panic: snapacct_ufs2: bad block - mksnap_ffs(8) crash

PR:           253158

(cherry picked from commit 8563de2f2799b2cb6f2f06e3c9dddd48dca2a986)
(cherry picked from commit c31480a1f66537e59b02e935a547bcfc76715278)

3 years agonewsyslog(8): Implement a new 'E' flag to not rotate empty log files
Juraj Lutter [Sun, 28 Feb 2021 22:07:14 +0000 (23:07 +0100)]
newsyslog(8): Implement a new 'E' flag to not rotate empty log files

Based on an idea from dvl's coworker, László DANIELISZ, implement
a new flag, 'E', that prevents newsyslog(8) from rotating the empty
log files. This 'E' flag ist mostly usable in conjunction with 'B'
flag that instructs newsyslog(8) to not insert an informational
message into the log file after rotation, keeping it still empty.

Reviewed by: markj, ian, manpages (rpokala)
Approved by: markj, ian, manpages (rpokala)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D28940

(cherry picked from commit c7d27b225df8d7fb36a31a21737d4309593c4604)

3 years agonfsclient: Fix ReadDS/WriteDS/CommitDS nfsstats RPC counts for a NFSv3 DS
Rick Macklem [Tue, 2 Mar 2021 22:18:23 +0000 (14:18 -0800)]
nfsclient: Fix ReadDS/WriteDS/CommitDS nfsstats RPC counts for a NFSv3 DS

During a recent virtual NFSv4 testing event, a bug in the FreeBSD client
was detected when doing I/O DS operations on a Flexible File Layout pNFS
server.  For an NFSv3 DS, the Read/Write/Commit nfsstats were incremented
instead of the ReadDS/WriteDS/CommitDS counts.
This patch fixes this.

Only the RPC counts reported by nfsstat(1) were affected by this bug,
the I/O operations were performed correctly.

MFC after: 2 weeks

(cherry picked from commit c04199affeacbd9e9dda3aaf5ca0b1b180031e78)

3 years agonfsclient: Fix the stripe unit size for a File Layout pNFS layout
Rick Macklem [Mon, 1 Mar 2021 20:49:32 +0000 (12:49 -0800)]
nfsclient: Fix the stripe unit size for a File Layout pNFS layout

During a recent virtual NFSv4 testing event, a bug in the FreeBSD client
was detected when doing a File Layout pNFS DS I/O operation.
The size of the I/O operation was smaller than expected.
The I/O size is specified as a stripe unit size in bits 6->31 of nflh_util
in the layout.  I had misinterpreted RFC5661 and had shifted the value
right by 6 bits. The correct interpretation is to use the value as
presented (it is always an exact multiple of 64), clearing bits 0->5.
This patch fixes this.

Without the patch, I/O through the DSs work, but the I/O size is 1/64th
of what is optimal.

(cherry picked from commit 94f2e42f5e0b78a7a4684d4a4eb62ea470a57eb1)

3 years agonfsclient: add nfs node locking around uses of n_direofoffset
Rick Macklem [Sun, 28 Feb 2021 22:53:54 +0000 (14:53 -0800)]
nfsclient: add nfs node locking around uses of n_direofoffset

During code inspection I noticed that the n_direofoffset field
of the NFS node was being manipulated without any lock being
held to make it SMP safe.
This patch adds locking of the NFS node's mutex around
handling of n_direofoffset to make it SMP safe.

I have not seen any failure that could be attributed to n_direofoffset
being manipulated concurrently by multiple processors, but I think this
is possible, since directories are read with shared vnode
locking, plus locks only on individual buffer cache blocks.
However, there have been as yet unexplained issues w.r.t reading
large directories over NFS that could have conceivably been caused
by concurrent manipulation of n_direofoffset.

(cherry picked from commit 15bed8c46b32dec19e922cb89e12c8970867a303)

3 years agonfsclient: add checks for a server returning the current directory
Rick Macklem [Sun, 28 Feb 2021 22:15:32 +0000 (14:15 -0800)]
nfsclient: add checks for a server returning the current directory

Commit 3fe2c68ba20f dealt with a panic in cache_enter_time() where
the vnode referred to the directory argument.
It would also be possible to get these panics if a broken
NFS server were to return the directory as an new object being
created within the directory or in a Lookup reply.

This patch adds checks to avoid the panics and logs
messages to indicate that the server is broken for the
file object creation cases.

(cherry picked from commit 3e04ab36ba5ce5cbbf6d22f17a01a391a04e465f)

3 years agonfsclient: fix panic in cache_enter_time()
Rick Macklem [Sun, 28 Feb 2021 01:54:05 +0000 (17:54 -0800)]
nfsclient: fix panic in cache_enter_time()

Juraj Lutter (otis@) reported a panic "dvp != vp not true" in
cache_enter_time() called from the NFS client's nfsrpc_readdirplus()
function.
This is specific to an NFSv3 mount with the "rdirplus" mount
option. Unlike NFSv4, NFSv3 replies to ReaddirPlus
includes entries for the current directory.

This trivial patch avoids doing a cache_enter_time()
call for the current directory to avoid the panic.

(cherry picked from commit 3fe2c68ba20fb3365ef91e0b85f88237b5369f38)

3 years agofhlink(2): the syscalls do not take flag
Konstantin Belousov [Sun, 28 Feb 2021 00:38:11 +0000 (02:38 +0200)]
fhlink(2): the syscalls do not take flag

(cherry picked from commit 600756afb532a86a39fb488f5c4fc7e248921655)

3 years agoMake kern.timecounter.hardware tunable
Konstantin Belousov [Sun, 7 Mar 2021 23:50:12 +0000 (01:50 +0200)]
Make kern.timecounter.hardware tunable

(cherry picked from commit 56b9bee63a42dbac712acf540f23a4c3dbd099a9)

3 years agoHyper-V: hn: Relinquish cpu in HN_LOCK to avoid deadlock
Wei Hu [Thu, 15 Oct 2020 11:44:28 +0000 (11:44 +0000)]
Hyper-V: hn: Relinquish cpu in HN_LOCK to avoid deadlock

The try lock loop in HN_LOCK put the thread spinning on cpu if the lock
is not available. It is possible to cause deadlock if the thread holding
the lock is sleeping. Relinquish the cpu to work around this problem even
it doesn't completely solve the issue. The priority inversion could cause
the livelock no matter how less likely it could happen. A more complete
solution may be needed in the future.

Reported by: Microsoft, Netapp
MFC after: 2 weeks
Sponsored by: Microsoft

(cherry picked from commit b3460f44524b145c6c8a760ebe65052560a810bf)

3 years agoHyper-V: pcib: Check revoke status during device attach
Wei Hu [Thu, 15 Oct 2020 05:57:20 +0000 (05:57 +0000)]
Hyper-V: pcib: Check revoke status during device attach

It is possible that the vmbus pcib channel is revoked during attach path.
The attach path could be waiting for response from host and this response will never
arrive since the channel has already been revoked from host point of view. Check
this situation during wait complete and return failed if this happens.

Reported by: Netapp
MFC after: 2 weeks
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D26486

(cherry picked from commit 75c2786c25fef9a6f8239c9fc1631cd17756579b)

3 years agoHyper-V: storvsc: Enhance srb_status code handling.
Wei Hu [Mon, 31 Aug 2020 09:05:45 +0000 (09:05 +0000)]
Hyper-V: storvsc: Enhance srb_status code handling.

In hv_storvsc_io_request() when coring, prevent changing of the send channel
from the base channel to another one. storvsc_poll always probes on the base
channel.

Based upon conversations with Microsoft, changed the handling of srb_status
codes. Most we should never get, others yes. All are treated as retry-able
except for two. We should not get these statuses, but if we ever do, the I/O
state is not known.

Submitted by: Alexander Sideropoulos <Alexander.Sideropoulos@netapp.com>
Reviewed by: trasz, allanjude, whu
MFC after: 1 week
Sponsored by: Netapp Inc
Differential Revision: https://reviews.freebsd.org/D25756

(cherry picked from commit 2a0ce39d086ffe13782c9dc1e24bb240abbe790a)

3 years agohyperv/vmbus: Fix the wrong size in ndis_offload structure
Wei Hu [Tue, 9 Jul 2019 08:21:14 +0000 (08:21 +0000)]
hyperv/vmbus: Fix the wrong size in ndis_offload structure

Submitted by: whu
MFC after: 2 weeks
Sponsored by: Microsoft

(cherry picked from commit 23a499203c5b3fd74f781d1383269a6e168588cf)

3 years agohyperv/vmbus: Update VMBus version 4.0 and 5.0 support.
Wei Hu [Tue, 9 Jul 2019 07:24:18 +0000 (07:24 +0000)]
hyperv/vmbus: Update VMBus version 4.0 and 5.0 support.

Add VMBus protocol version 4.0. and 5.0 to support Windows 10 and newer HyperV hosts.

For VMBus 4.0 and newer HyperV, the netvsc gpadl teardown must be done after vmbus close.

Submitted by: whu
MFC after: 2 weeks
Sponsored by: Microsoft

(cherry picked from commit ace5ce7e701e5a98c23f820d4f126e5c265aa667)

3 years agoPrevent framebuffer mmio space from being allocated to other devices on HyperV.
Wei Hu [Thu, 30 Jul 2020 07:26:11 +0000 (07:26 +0000)]
Prevent framebuffer mmio space from being allocated to other devices on HyperV.

On Gen2 VMs, Hyper-V provides mmio space for framebuffer.
This mmio address range is not useable for other PCI devices.
Currently only efifb driver is using this range without reserving
it from system.
Therefore, vmbus driver reserves it before any other PCI device
drivers start to request mmio addresses.

PR: 222996
Submitted by: weh@microsoft.com
Reported by: dmitry_kuleshov@ukr.net
Reviewed by: decui@microsoft.com
Sponsored by: Microsoft

(cherry picked from commit c565776195f2f2b62427af07f6b1a9b7670cbc1f)

3 years agoMake software iSCSI more configurable.
Alexander Motin [Thu, 28 Jan 2021 20:53:49 +0000 (15:53 -0500)]
Make software iSCSI more configurable.

Move software iSCSI tunables/sysctls into kern.icl.soft subtree.
Replace several hardcoded length constants there with variables.

While there, stretch the limits to better match Linux' open-iscsi
and our own initiator with new MAXPHYS of 1MB.  Our CTL target is
also optimized for up to 1MB I/Os, so there is also a match now.
For Windows 10 and VMware 6.7 initiators at default settings it
should make no change, since previous limits were sufficient there.

Tests of QD1 1MB writes from FreeBSD over 10GigE link show throughput
increase by 29% on idle connection and 132% with concurrent QD8 reads.

MFC after: 3 days
Sponsored by: iXsystems, Inc.

(cherry picked from commit b75168ed24ca74f65929e5c57d4fed5f0ab08f2a)

3 years agoMove ic_check_send_space clear to the actual check.
Alexander Motin [Wed, 3 Mar 2021 20:21:26 +0000 (15:21 -0500)]
Move ic_check_send_space clear to the actual check.

It closes tiny race when the flag could be set between being cleared
and the space is checked, that would create us some more work.  The
flag setting is protected by both locks, so we can clear it in either
place, but in between both locks are dropped.

MFC after: 1 week

(cherry picked from commit afc3e54eeee635a525c88e4678cc38e3219302c3)

3 years agoRestore condition removed in df3747c6607b.
Alexander Motin [Wed, 3 Mar 2021 16:58:04 +0000 (11:58 -0500)]
Restore condition removed in df3747c6607b.

I think it allowed to avoid some TX thread wakeups while the socket
buffer is full.  But add there another options if ic_check_send_space
is set, which means socket just reported that new space appeared, so
it may have sense to pull more data from ic_to_send for better TX
coalescing.

MFC after: 1 week

(cherry picked from commit aff9b9ee894e3e6b6d8c7e4182d6b973804df853)

3 years agoReplace STAILQ_SWAP() with simpler STAILQ_CONCAT().
Alexander Motin [Tue, 2 Mar 2021 23:39:44 +0000 (18:39 -0500)]
Replace STAILQ_SWAP() with simpler STAILQ_CONCAT().

Also remove stray STAILQ_REMOVE_AFTER(), not causing problems only
because STAILQ_SWAP() fixed corrupted stqh_last.

MFC after: 1 week

(cherry picked from commit df3747c6607be12d48db825653e6adfc3041e97f)

3 years agoFix initiator panic after 6895f89fe54e.
Alexander Motin [Tue, 2 Mar 2021 21:07:22 +0000 (16:07 -0500)]
Fix initiator panic after 6895f89fe54e.

There are sessions without socket that are not disconnecting yet.

MFC after: 3 weeks

(cherry picked from commit 06e9c710998b83a3be21f7f264187fff5d590bc3)

3 years agoOptimize TX coalescing by keeping pointer to last mbuf.
Alexander Motin [Tue, 2 Mar 2021 04:31:34 +0000 (23:31 -0500)]
Optimize TX coalescing by keeping pointer to last mbuf.

Before m_cat() each time traversed through all the coalesced chain.

MFC after: 1 week

(cherry picked from commit b85a67f54a40053e75658a17c620b89bafaba67f)

3 years agoOptimize out few extra memory accesses.
Alexander Motin [Mon, 1 Mar 2021 23:35:45 +0000 (18:35 -0500)]
Optimize out few extra memory accesses.

MFC after: 1 week

(cherry picked from commit a59e2982fe3e6339629cc77fe9d349d60e03a05e)

3 years agoMicro-optimize OOA queue processing.
Alexander Motin [Sat, 27 Feb 2021 15:14:05 +0000 (10:14 -0500)]
Micro-optimize OOA queue processing.

- Move ctl_get_cmd_entry() calls from every OOA traversal to when
  the requests first inserted, storing seridx in struct ctl_scsiio.
- Move some checks out of the loop in ctl_check_ooa().
- Replace checks for errors that can not happen with asserts.
- Transpose ctl_serialize_table, so that any OOA traversal accessed
  only one row (cache line).  Compact it from enum to uint8_t.
- Optimize static branch predictions in hottest places.

Due to O(n) nature on deep LUN queues this can be the hottest code
path in CTL, and additional 20% of IOPS I see in some 4KB I/O tests
are good to have in reserve.  About 50% of CPU time here according
to the profiles is now spent in two memory accesses per traversed
request in OOA.

Sponsored by: iXsystems, Inc.
MFC after: 2 weeks

(cherry picked from commit 9d9fd8b79f0ebe59f791c8225fa01ab59858b7b5)

3 years agoCoalesce socket reads in software iSCSI.
Alexander Motin [Mon, 22 Feb 2021 17:23:35 +0000 (12:23 -0500)]
Coalesce socket reads in software iSCSI.

Instead of 2-4 socket reads per PDU this can do as low as one read
per megabyte, dramatically reducing TCP overhead and lock contention.

With this on iSCSI target I can write more than 4GB/s through a
single connection.

MFC after: 1 month

(cherry picked from commit 6895f89fe54e0858aea70d2bd2a9651f45d7998e)

3 years agoFix build after 2c7dc6bae9fd.
Alexander Motin [Sun, 21 Feb 2021 22:21:14 +0000 (17:21 -0500)]
Fix build after 2c7dc6bae9fd.

MFC after: 1 month

(cherry picked from commit c02a28754bc229c05e8baf9b6632cbd59bc73e48)

3 years agoRefactor CTL datamove KPI.
Alexander Motin [Sun, 21 Feb 2021 21:45:14 +0000 (16:45 -0500)]
Refactor CTL datamove KPI.

 - Make frontends call unified CTL core method ctl_datamove_done()
to report move completion.  It allows to reduce code duplication
in differerent backends by accounting DMA time in common code.
 - Add to ctl_datamove_done() and be_move_done() callback samethr
argument, reporting whether the callback is called in the same
context as ctl_datamove().  It allows for some cases like iSCSI
write with immediate data or camsim frontend write save one context
switch, since we know that the context is sleepable.
 - Remove data_move_done() methods from struct ctl_backend_driver,
unused since forever.

MFC after:  1 month

(cherry picked from commit 2c7dc6bae9fd5c2fa0a65768df8e4e99c2f159f1)

3 years agoMicrooptimize CTL I/O queues.
Alexander Motin [Fri, 19 Feb 2021 20:42:57 +0000 (15:42 -0500)]
Microoptimize CTL I/O queues.

Switch OOA queue from TAILQ to LIST and change its direction, so that
we traverse it forward, not backward.  There is only one place where
we really need other direction, and it is not critical.

Use STAILQ_REMOVE_HEAD() instead of STAILQ_REMOVE() in backends.

Replace few impossible conditions with assertions.

MFC after: 1 month

(cherry picked from commit 05d882b780f5be2da6f3d3bfef9160aacc4888d6)

3 years agoSave context switch per I/O for iSCSI and IOCTL frontends.
Alexander Motin [Fri, 19 Feb 2021 03:07:32 +0000 (22:07 -0500)]
Save context switch per I/O for iSCSI and IOCTL frontends.

Introduce new CTL core KPI ctl_run(), preprocessing I/Os in the caller
context instead of scheduling another thread just for that.  This call
may sleep, that is not acceptable for some frontends like the original
CAM/FC one, but iSCSI already has separate sleepable per-connection RX
threads, and another thread scheduling is mostly just a waste of time.
IOCTL frontend actually waits for the I/O completion in the caller
thread, so the use of another thread for this has even less sense.

With this change I can measure ~5% IOPS improvement on 4KB iSCSI I/Os
to ZFS.

MFC after: 1 month

(cherry picked from commit 812c9f48a2b7bccc31b2a6077b299822357832e4)

3 years agoMove XPT_IMMEDIATE_NOTIFY handling out of periph lock.
Alexander Motin [Thu, 18 Feb 2021 21:22:01 +0000 (16:22 -0500)]
Move XPT_IMMEDIATE_NOTIFY handling out of periph lock.

It is a rare, but still better to not have lock dependencies.

MFC after: 1 month

(cherry picked from commit c67a2909a629db138227993e1093e66bb6c00af5)

3 years agoqat.4: Fix some firmware module names
Mark Johnston [Wed, 3 Mar 2021 14:07:53 +0000 (09:07 -0500)]
qat.4: Fix some firmware module names

PR: 252984

(cherry picked from commit 3adf72a36b9b151eef57e3d83f71a3a9fbacb78d)

3 years agoPartially revert libcxxrt changes to avoid _Unwind_Exception change
Dimitry Andric [Wed, 10 Mar 2021 21:31:40 +0000 (22:31 +0100)]
Partially revert libcxxrt changes to avoid _Unwind_Exception change

After the recent cherry-picking of libcxxrt commits 0ee0dbfb0d26 and
d2b3fadf2db5, users reported that editors/libreoffice packages from the
official package builders did not start anymore. It turns out that the
combination of these commits subtly changes the ABI, requiring all
applications that depend on internal details of struct _Unwind_Exception
(available via unwind-arm.h and unwind-itanium.h) to be recompiled.

However, the FreeBSD package builders always use -RELEASE jails, so
these still use the old declaration of struct _Unwind_Exception, which
is not entirely compatible. In particular, LibreOffice uses this struct
in its internal "uno bridge" component, where it attempts to setup its
own exception handling mechanism.

To fix this incompatibility, go back to the old declarations of struct
_Unwind_Exception, and restore the __LP64__ specific workaround we had
in place before (which was to cope with yet another, older ABI bug).

Effectively, this reverts upstream libcxxrt commits 88bdf6b290da
("Specify double-word alignment for ARM unwind") and b96169641f79
("Updated Itanium unwind"), and reapplies our commit 3c4fd2463bb2
("libcxxrt: add padding in __cxa_allocate_* to fix alignment").

PR: 253840

3 years agoThe list of ports in configuration path shall be protected by locks,
Gleb Smirnoff [Tue, 8 Dec 2020 16:46:00 +0000 (16:46 +0000)]
The list of ports in configuration path shall be protected by locks,
epoch shall be used only for fast path.  Thus use LAGG_XLOCK() in
lagg_[un]register_vlan.  This fixes sleeping in epoch panic.

PR: 240609
(cherry picked from commit e1074ed6a08033ee571b4bedb3ffe6049a4a7361)

3 years agoBuild lib/msun tests with compiler builtins disabled
Dimitry Andric [Tue, 23 Feb 2021 20:03:32 +0000 (21:03 +0100)]
Build lib/msun tests with compiler builtins disabled

This forces the compiler to emit calls to libm functions, instead of
possibly substituting pre-calculated results at compile time, which
should help to actually test those functions.

Reviewed by: emaste, arichardson, ngie
Differential Revision: https://reviews.freebsd.org/D28577

(cherry picked from commit cf97d2a1dab8f2cddc4466fe64d37818339c73be)

riscv: Add a soft-float implementation of fabs()

We could just use a C implementation using __builtin_fabs(), but using
this assembly version guarantees that there is no additional prolog/epilog
code. Additionally, clang generates worse code for masking off the top bit
than GCC: https://bugs.llvm.org/show_bug.cgi?id=49377.

This fixes the RISCV64 softfloat world build after cf97d2a1dab8. That commit
added -fno-builtin to the msun tests which resulted in the first references to
fabs (previously the compiler inlined all calls).

Reviewed By: dim
Reported by: mjg
Differential Revision: https://reviews.freebsd.org/D28994

(cherry picked from commit 524b018d200408bed5eb0d2b892db5b9fb46808b)

riscv: Fix whitespace issues in fabs added in 524b018d2004

(cherry picked from commit 066dab17e7a4a78d43dbcef8119960ddc8090a73)

3 years agoipfw: add IPv6 support for sockarg opcode.
Andrey V. Elsukov [Tue, 2 Mar 2021 09:45:59 +0000 (12:45 +0300)]
ipfw: add IPv6 support for sockarg opcode.

Sponsored by: Yandex LLC

(cherry picked from commit a9f7eba9597189c0e438f6986067d31dca1c53b0)

3 years agoDo not exit ctl_be_block_worker() prematurely.
Alexander Motin [Sat, 6 Mar 2021 03:39:52 +0000 (22:39 -0500)]
Do not exit ctl_be_block_worker() prematurely.

Return while there are any I/Os in a queue may result in them stuck
indefinitely, since there is only one taskqueue task for all of them.
I think I've reproduced this by switching ha_role to secondary under
heavy load.

MFC after: 3 days

(cherry picked from commit 6ed39db2573bb808ac2c206cd6c831f0be86219c)

3 years agoMove back the isa non-PNP driver deadline to FreeBSD 14.
Warner Losh [Mon, 8 Mar 2021 22:59:48 +0000 (15:59 -0700)]
Move back the isa non-PNP driver deadline to FreeBSD 14.

(cherry picked from commit 6ffdaa5f2d4f0881557f64dabf61fb57541e0fba)

3 years ago[PowerPC] Allow traversal of oversize OF properties.
Brandon Bergren [Fri, 13 Nov 2020 16:49:41 +0000 (16:49 +0000)]
[PowerPC] Allow traversal of oversize OF properties.

In standards such as LoPAPR, property names in excess of the usual 31
characters exist.

This breaks property traversal.

While in IEEE 1275-1994, nextprop is defined explicitly to work with a
32-byte region of memory, using a larger buffer should be fine. There is
actually no way to pass a buffer length to the nextprop call in the OF
client interface, so SLOF actually just blindly overflows the buffer.

So we have to defensively make the buffer larger, to avoid memory
corruption when reading out long properties on live OF systems.

Note also that on real-mode OF, things are pretty tight because we are
allocating against a static bounce buffer in low memory, so we can't just
use a huge buffer to work around this without it being wasteful of our
limited amount of 32-bit physical memory.

This allows a patched ofwdump to operate properly on SLOF (i.e. pseries)
systems, as well as any other PowerPC systems with overlength properties.

Reviewed by: jhibbits
Sponsored by: Tag1 Consulting, Inc.
Differential Revision: https://reviews.freebsd.org/D26669

(cherry picked from commit 26869ad14c70306313405029229a1e2fd94510cd)

3 years ago[PowerPC64] Fix multiple issues in fpsetmask().
Brandon Bergren [Mon, 1 Mar 2021 02:35:53 +0000 (20:35 -0600)]
[PowerPC64] Fix multiple issues in fpsetmask().

Building R exposed a problem in fpsetmask() whereby we were not properly
clamping the provided mask to the valid range.

R initilizes the mask by calling fpsetmask(~0) on FreeBSD. Since we
recently enabled precise exceptions, this was causing an immediate
SIGFPE because we were attempting to set invalid bits in the fpscr.

Properly limit the range of bits that can be set via fpsetmask().

While here, use the correct fp_except_t type instead of fp_rnd_t.

Reported by: pkubaj (in IRC)
Sponsored by: Tag1 Consulting, Inc.

(cherry picked from commit dd95b39235dd81c890aa3cce02a5bb7f91f23803)
(cherry picked from commit a79735386c46298274d71577ab6b4dd00be261cc)

3 years ago[PowerPC] [PowerPCSPE] Fix multiple issues in fpsetmask().
Brandon Bergren [Mon, 1 Mar 2021 03:06:59 +0000 (21:06 -0600)]
[PowerPC] [PowerPCSPE] Fix multiple issues in fpsetmask().

Building R on powerpc64 exposed a problem in fpsetmask() whereby we
were not properly clamping the provided mask to the valid range.

This same issue affects powerpc and powerpcspe.

Properly limit the range of bits that can be set via fpsetmask().

While here, use the correct fp_except_t type instead of fp_rnd_t.

Reported by: pkubaj, jhibbits (in IRC)
Sponsored by: Tag1 Consulting, Inc.

(cherry picked from commit 384ee7cc6e9e4ddc91a6e9e623fcbbe5826bce38)
(cherry picked from commit 8b96d6ac04e7e761ec6b9eff47c801a2b89fbd6d)

3 years ago[PowerPC] Fix SPE floating point environment manipulation
Brandon Bergren [Thu, 12 Dec 2019 17:12:18 +0000 (17:12 +0000)]
[PowerPC] Fix SPE floating point environment manipulation

Fix multiple problems in the powerpcspe floating point code.

* Endianness handling of the SPEFSCR in fenv.h was completely broken.
* Ensure SPEFSCR synchronization requirements are being met.

The __r.__d -> __r transformations were written by jhibbits.

Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D22526

(cherry picked from commit 4f9ed3156c3aff08629d37c8a89ed5ba525b01c9)

3 years agoFix diroffdiroff, probably copy/paste bug.
Alexander Motin [Sun, 28 Feb 2021 14:07:13 +0000 (09:07 -0500)]
Fix diroffdiroff, probably copy/paste bug.

Too long name looks bad in `vmstat -m`.

MFC after: 1 week

(cherry picked from commit d01032736cf067d63e66d6428ffc08e47652600f)

3 years agolibkvm: Plug couple of memory leaks and check possible calloc(3) failure
Jung-uk Kim [Wed, 3 Mar 2021 23:10:00 +0000 (18:10 -0500)]
libkvm: Plug couple of memory leaks and check possible calloc(3) failure

First, r204494 introduced dpcpu_off in struct __kvm and it was allocated
from _kvm_dpcpu_init() but it was not free(3)'ed from kvm_close(3).
Second, r291406 introduced kvm_nlist2(3) and converted kvm_nlist(3) to
use the new function but it did not free the temporary buffer.
Also, check possible calloc(3) failure while I am in the neighborhood.

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

(cherry picked from commit 645eaa2ccaed6eea801d07d6a092974fc1713896)
(cherry picked from commit 483c6da3a20b2064cd655f7cb19e6b98dee677ff)