]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agotcp: Make error handling in tcp_usr_send() more consistent
Mark Johnston [Fri, 21 May 2021 21:44:40 +0000 (17:44 -0400)]
tcp: Make error handling in tcp_usr_send() more consistent

- Free the input mbuf in a single place instead of in every error path.
- Handle PRUS_NOTREADY consistently.
- Flush the socket's send buffer if an implicit connect fails.  At that
  point the mbuf has already been enqueued but we don't want to keep it
  in the send buffer.

Reviewed by: gallatin, tuexen
Discussed with: jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 7d2608a5d24ec3534dad7f24191f12a8181ea206)

3 years agox86: initialize initial FPU state earlier
Konstantin Belousov [Thu, 27 May 2021 16:26:10 +0000 (19:26 +0300)]
x86: initialize initial FPU state earlier

PR: 255997

(cherry picked from commit c56de177d28295b4b07ad0b17e4faf4f11c9e4f2)

3 years agortld: Rename -t option to -u (ignore LD_ vars)
Konstantin Belousov [Wed, 2 Jun 2021 22:50:49 +0000 (01:50 +0300)]
rtld: Rename -t option to -u (ignore LD_ vars)

(cherry picked from commit e3149e0a02d6d09fb4c3acd085da2509dbab7320)

3 years agortld direct exec: add option to ignore LD_ variables
Konstantin Belousov [Fri, 28 May 2021 23:59:07 +0000 (02:59 +0300)]
rtld direct exec: add option to ignore LD_ variables

(cherry picked from commit d81f999ac22342789f2b3e21206d83d410be4df3)

3 years agoaic7xxx: Fix re-building firmware with -fno-common
Jessica Clarke [Fri, 28 May 2021 18:07:17 +0000 (19:07 +0100)]
aic7xxx: Fix re-building firmware with -fno-common

The generated C output for aicasm_scan.l defines yylineno already, so
references to it from other files should use an extern declaration.

The STAILQ_HEAD use in aicasm_symbol.h also provided an identifier,
causing it to both define the struct type and define a variable of that
struct type, causing any C file including the header to define the same
variable. This variable is not used (and confusingly clashes with a
field name just below) and was likely caused by confusion when switching
between defining fields using similar type macros and defining the type
itself.

Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30525

(cherry picked from commit 5e912f5fec025766521f535d1237330ede7f18e2)

3 years agosmartpqi: clear CCBs allocated on the stack
Edward Tomasz Napierala [Fri, 28 May 2021 06:33:37 +0000 (00:33 -0600)]
smartpqi: clear CCBs allocated on the stack

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

(cherry picked from commit e20e60be501204c3ba742e266afecc6c6e498a6c)

3 years agoNewly added features and bug fixes in latest Microchip SmartPQI driver
PAPANI SRIKANTH [Fri, 28 May 2021 06:17:56 +0000 (00:17 -0600)]
Newly added features and bug fixes in latest Microchip SmartPQI driver

It includes:

1)Newly added TMF feature.
2)Added newly Huawei & Inspur PCI ID's
3)Fixed smartpqi driver hangs in Z-Pool while running on FreeBSD12.1
4)Fixed flooding dmesg in kernel while the controller is offline during in ioctls.
5)Avoided unnecessary host memory allocation for rcb sg buffers.
6)Fixed race conditions while accessing internal rcb structure.
7)Fixed where Logical volumes exposing two different names to the OS it's due to the system memory is overwritten with DMA stale data.
8)Fixed dynamically unloading a smartpqi driver.
9)Added device_shutdown callback instead of deprecated shutdown_final kernel event in smartpqi driver.
10)Fixed where Os is crashed during physical drive hot removal during heavy IO.
11)Fixed OS crash during controller lockup/offline during heavy IO.
12)Fixed coverity issues in smartpqi driver
13)Fixed system crash while creating and deleting logical volume in a continuous loop.
14)Fixed where the volume size is not exposing to OS when it expands.
15)Added HC3 pci id's.

Reviewed by: Scott Benesh (microsemi), Murthy Bhat (microsemi), imp
Differential Revision: https://reviews.freebsd.org/D30182

(cherry picked from commit 9fac68fc3853b696c8479bb3a8181d62cb9f59c9)

3 years agolibpfctl: Improve error handling in pfctl_get_states()
Kristof Provost [Thu, 27 May 2021 09:43:17 +0000 (11:43 +0200)]
libpfctl: Improve error handling in pfctl_get_states()

Ensure that we always free nvlists and other allocated memory.

Reviewed by: scottl
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30493

(cherry picked from commit 27c77f42ae7402c313deec47aa67a8a8e0889410)

3 years agolibpfctl: fix memory leak
Kristof Provost [Thu, 27 May 2021 09:28:36 +0000 (11:28 +0200)]
libpfctl: fix memory leak

When we create an nvlist and insert it into another nvlist we must
remember to destroy it. The nvlist_add_nvlist() function makes a copy,
just like nvlist_add_string() makes a copy of the string.

See also 4483fb47735c29408c72045469c9c4b3e549668b

Reviewed by: scottl
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30492

(cherry picked from commit 6dbb729d35d59cc8bc8451bd56f220f9c35a43f3)

3 years agotcp, udp: Permit binding with AF_UNSPEC if the address is INADDR_ANY
Mark Johnston [Mon, 31 May 2021 22:53:34 +0000 (18:53 -0400)]
tcp, udp: Permit binding with AF_UNSPEC if the address is INADDR_ANY

Prior to commit f161d294b we only checked the sockaddr length, but now
we verify the address family as well.  This breaks at least ttcp.  Relax
the check to avoid breaking compatibility too much: permit AF_UNSPEC if
the address is INADDR_ANY.

Fixes: f161d294b
Reported by: Bakul Shah <bakul@iitbombay.org>
Reviewed by: tuexen
Sponsored by: The FreeBSD Foundation

(cherry picked from commit f96603b56f0f74fa52d8f1ef0be869fca7305b99)

3 years agoktrace: Handle negative array sizes in ktrstructarray
Mark Johnston [Thu, 27 May 2021 19:49:12 +0000 (15:49 -0400)]
ktrace: Handle negative array sizes in ktrstructarray

ktrstructarray() may be used to create copies of kevent(2) change and
event arrays.  It is called before parameter validation is done and so
should check for bogus array lengths before allocating a copy.

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

(cherry picked from commit f88510077377157008f648b7036e1d1c9c83ea23)

3 years agoipfilter: Fix ip_nat memory leak and use-after-free
Cy Schubert [Tue, 25 May 2021 18:54:49 +0000 (11:54 -0700)]
ipfilter: Fix ip_nat memory leak and use-after-free

Unfortunately the wrong elemet is freed, also resulting in use-after-free.

PR: 255859
Submitted by: lylgood@foxmail.com
Reported by: lylgood@foxmail.com

(cherry picked from commit 323a4e2c4e285e6f8eee8db3fe2cb7490a734da0)

3 years agoMFV d60fa10fd872db7e3d8cb1e161cfdae026c43b14:
Cy Schubert [Wed, 10 Feb 2021 04:25:05 +0000 (20:25 -0800)]
MFV d60fa10fd872db7e3d8cb1e161cfdae026c43b14:

Update unbound 1.13.0 --> 1.13.1.

Includes numerous bugfixes documented at:
https://www.nlnetlabs.nl/projects/unbound/download/#unbound-1-13-1

(cherry picked from commit f44e67d120ad78ef7894241b519ee79fd190a16e)

3 years agonfscl: Fix NFSv4.1/4.2 mount recovery from an expired lease
Rick Macklem [Wed, 19 May 2021 21:52:56 +0000 (14:52 -0700)]
nfscl: Fix NFSv4.1/4.2 mount recovery from an expired lease

The most difficult NFSv4 client recovery case happens when the
lease has expired on the server.  For NFSv4.0, the client will
receive a NFSERR_EXPIRED reply from the server to indicate this
has happened.
For NFSv4.1/4.2, most RPCs have a Sequence operation and, as such,
the client will receive a NFSERR_BADSESSION reply when the lease
has expired for these RPCs.  The client will then call nfscl_recover()
to handle the NFSERR_BADSESSION reply.  However, for the expired lease
case, the first reclaim Open will fail with NFSERR_NOGRACE.

This patch recognizes this case and calls nfscl_expireclient()
to handle the recovery from an expired lease.

This patch only affects NFSv4.1/4.2 mounts when the lease
expires on the server, due to a network partitioning that
exceeds the lease duration or similar.

(cherry picked from commit c28cb257ddfe3339756f6fd659fa4a2efa4de2cb)

3 years agoFix fsck_ufs segfault when it needs to rerun.
Kirk McKusick [Sat, 29 May 2021 02:41:05 +0000 (19:41 -0700)]
Fix fsck_ufs segfault when it needs to rerun.

Sponsored by: Netflix

(cherry picked from commit 5c9e9eb7a27feb24136c16706f3db8ce7c8bbc47)

3 years agopf tests: Only log critical errors from scapy
Kristof Provost [Wed, 26 May 2021 11:07:50 +0000 (13:07 +0200)]
pf tests: Only log critical errors from scapy

See a26e895f3d803cc1f4ee1c2b33c61330998808b9. Silence these new tests as
well.

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

(cherry picked from commit 9d0bc96ef8c0288c05a627b3961edd2da046c5c9)

3 years agopf tests: Test cases for fragment reassembly
Kristof Provost [Thu, 25 Feb 2021 08:50:57 +0000 (09:50 +0100)]
pf tests: Test cases for fragment reassembly

Obtained from: Alexander Bluhm, OpenBSD

(cherry picked from commit d39d5ee2d67f61abc890b51973b5c4a0c81d6647)

3 years agolockprof: move panic check after inspecting the state
Mateusz Guzik [Sun, 23 May 2021 16:04:31 +0000 (16:04 +0000)]
lockprof: move panic check after inspecting the state

(cherry picked from commit e2ab16b1a6c0f556299df21be54f04652ba7169d)

3 years agolockprof: pass lock type as an argument instead of reading the spin flag
Mateusz Guzik [Sun, 23 May 2021 15:25:42 +0000 (17:25 +0200)]
lockprof: pass lock type as an argument instead of reading the spin flag

(cherry picked from commit 6a467cc5e1f673a700f6229e63e9a98ed65264c8)

3 years agolockprof: add contested-only profiling
Mateusz Guzik [Tue, 18 May 2021 19:07:19 +0000 (21:07 +0200)]
lockprof: add contested-only profiling

This allows tracking all wait times with much smaller runtime impact.

For example when doing -j 104 buildkernel on tmpfs:

no profiling: 2921.70s user 282.72s system 6598% cpu 48.562 total
all acquires: 2926.87s user 350.53s system 6656% cpu 49.237 total
contested only: 2919.64s user 290.31s system 6583% cpu 48.756 total

(cherry picked from commit a0842e69aa5f86d61c072544b540ef21b2015211)

3 years agolockprof: retire lock_prof_skipcount
Mateusz Guzik [Tue, 18 May 2021 19:05:42 +0000 (21:05 +0200)]
lockprof: retire lock_prof_skipcount

The implementation uses a global variable for *ALL* calls, defeating the
point of sampling in the first place. Remove it as it clearly remains
unused.

(cherry picked from commit fca5cfd584d81ca291dbd898a8ff60c52d8c3c42)

3 years agonetsmb: Avoid a read-after-free in smb_t2_request_int()
Mark Johnston [Wed, 26 May 2021 13:57:38 +0000 (09:57 -0400)]
netsmb: Avoid a read-after-free in smb_t2_request_int()

Defer freeing the request structure until we've decided whether the
request should be retried.

PR: 255881
MFC after: 1 week

(cherry picked from commit 771e95d2e2ee1b60539f1273c62837b48249590a)

3 years agorpcsec_gss: Use a designated initializer for rpc_gss_ops
Mark Johnston [Wed, 26 May 2021 14:14:35 +0000 (10:14 -0400)]
rpcsec_gss: Use a designated initializer for rpc_gss_ops

No functional change intended.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit ba5bc6e8f9cb9c523d09599d7290a6d75ec9fd8b)

3 years agocxgb: Avoid a read-after-free in get_packet() when cxgb_debug is on
Mark Johnston [Wed, 26 May 2021 14:02:19 +0000 (10:02 -0400)]
cxgb: Avoid a read-after-free in get_packet() when cxgb_debug is on

PR: 255863
MFC after: 1 week

(cherry picked from commit 16f8f89c5c1f324a15a7e0607f03f041a230a572)

3 years agooce: Fix handling of m_pullup() errors in oce_tso_setup()
Mark Johnston [Wed, 26 May 2021 13:49:49 +0000 (09:49 -0400)]
oce: Fix handling of m_pullup() errors in oce_tso_setup()

m_pullup() frees the input mbuf chain upon a failure.  Set *mpp to NULL
in this case to ensure that the caller does not free the chain again.

PR: 255864
Submitted by: Lv Yunlong <lylgood@foxmail.com> (original version)
MFC after: 1 week

(cherry picked from commit 71776d67198fadd7d96937c9bdd22063636b132b)

3 years agoacpi: Add missing error handling to acpi_pci_link_route_irqs()
Mark Johnston [Wed, 26 May 2021 14:34:39 +0000 (10:34 -0400)]
acpi: Add missing error handling to acpi_pci_link_route_irqs()

Otherwise the resouce buffer may have been freed when
AcpiSetCurrentResources() is called, leading to a use-after-free.

PR: 255862
Submitted by: Lv Yunlong <lylgood@foxmail.com> (original version)
MFC after: 1 week

(cherry picked from commit 4cf33275289088e3b0a913a44b5cd549e348094d)

3 years agoThe old thread priority must be stored as part of the EPOCH(9) tracker.
Hans Petter Selasky [Fri, 21 May 2021 08:27:20 +0000 (10:27 +0200)]
The old thread priority must be stored as part of the EPOCH(9) tracker.

Else recursive use of EPOCH(9) may cause the wrong priority to be restored.

Bump the __FreeBSD_version due to adding new member to the epoch tracker
structure.

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

(cherry picked from commit ef0f7ae934b04a4f90e051d701ba539dd04e7d5b)

3 years agoAdd TCP LRO support for VLAN and VxLAN.
Hans Petter Selasky [Wed, 31 Mar 2021 10:36:36 +0000 (12:36 +0200)]
Add TCP LRO support for VLAN and VxLAN.

This change makes the TCP LRO code more generic and flexible with regards
to supporting multiple different TCP encapsulation protocols and in general
lays the ground for broader TCP LRO support. The main job of the TCP LRO code is
to merge TCP packets for the same flow, to reduce the number of calls to upper
layers. This reduces CPU and increases performance, due to being able to send
larger TSO offloaded data chunks at a time. Basically the TCP LRO makes it
possible to avoid per-packet interaction by the host CPU.

Because the current TCP LRO code was tightly bound and optimized for TCP/IP
over ethernet only, several larger changes were needed. Also a minor bug was
fixed in the flushing mechanism for inactive entries, where the expire time,
"le->mtime" was not always properly set.

To avoid having to re-run time consuming regression tests for every change,
it was chosen to squash the following list of changes into a single commit:
- Refactor parsing of all address information into the "lro_parser" structure.
  This easily allows to reuse parsing code for inner headers.
- Speedup header data comparison. Don't compare field by field, but
  instead use an unsigned long array, where the fields get packed.
- Refactor the IPv4/TCP/UDP checksum computations, so that they may be computed
  recursivly, only applying deltas as the result of updating payload data.
- Make smaller inline functions doing one operation at a time instead of
  big functions having repeated code.
- Refactor the TCP ACK compression code to only execute once
  per TCP LRO flush. This gives a minor performance improvement and
  keeps the code simple.
- Use sbintime() for all time-keeping. This change also fixes flushing
  of inactive entries.
- Try to shrink the size of the LRO entry, because it is frequently zeroed.
- Removed unused TCP LRO macros.
- Cleanup unused TCP LRO statistics counters while at it.
- Try to use __predict_true() and predict_false() to optimise CPU branch
  predictions.

Bump the __FreeBSD_version due to adding new member to the "lro_ctrl" structure.

Tested by: Netflix
Reviewed by: rrs (transport)
Differential Revision: https://reviews.freebsd.org/D29564
Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 9ca874cf740ee68c5742df8b5f9e20910085c011)

3 years agoImplement read-only VM_SHARED flag in the LinuxKPI.
Hans Petter Selasky [Tue, 11 May 2021 18:49:13 +0000 (20:49 +0200)]
Implement read-only VM_SHARED flag in the LinuxKPI.

For use by mmap(2) callbacks.

Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 904390b4787d2e4a0d9d8ca9cb0d6da5a4fb320c)

3 years agoImplement cdev_device_add() and cdev_device_del() in the LinuxKPI.
Hans Petter Selasky [Tue, 11 May 2021 18:51:59 +0000 (20:51 +0200)]
Implement cdev_device_add() and cdev_device_del() in the LinuxKPI.

Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit b8f113cab91f288e5d5e29d21184d1601b87cfdd)

3 years agocdev_del() should only put it's kernel object in the LinuxKPI.
Hans Petter Selasky [Tue, 11 May 2021 18:51:35 +0000 (20:51 +0200)]
cdev_del() should only put it's kernel object in the LinuxKPI.

The destructor takes care of the rest.

Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 67807f5066a012254da9a4535c0f225377afb66d)

3 years agoImplement own command line option for the frequently used -i usbusX -f Y syntax,
Hans Petter Selasky [Fri, 14 May 2021 15:12:57 +0000 (17:12 +0200)]
Implement own command line option for the frequently used -i usbusX -f Y syntax,
-d ugenX.Y, similar to what usbconfig(8) does.

Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit c904e20cc903d28c1090c531c907cdd6865455ff)

3 years agoUpdate ugen(4) manual page.
Hans Petter Selasky [Fri, 14 May 2021 14:34:15 +0000 (16:34 +0200)]
Update ugen(4) manual page.

Fix description of generic USB character devices.

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

(cherry picked from commit c65e2d7092d6cbaf03721ebe46e51cec4bd6ac0f)

3 years agoPropagate down USB explore error codes, so that failures to enumerate USB HUBs
Hans Petter Selasky [Tue, 18 May 2021 13:52:00 +0000 (15:52 +0200)]
Propagate down USB explore error codes, so that failures to enumerate USB HUBs
behind USB HUBs are detected and the USB reset counter logic will kick in
preventing enumeration of continuously failing ports.

Submitted by: phk@
Tested by: bz@
PR: 237666
Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit e5ff940a81b56cb236795e0059c44981053f8404)

3 years agoUpdate usb_timings_sysctl_handler() to accept any value for timings between
Hans Petter Selasky [Tue, 18 May 2021 13:16:29 +0000 (15:16 +0200)]
Update usb_timings_sysctl_handler() to accept any value for timings between
0 milliseconds and 2 seconds inclusivly. Some style fixes while at it.

The USB specification has minimum values and maximum values,
and not only minimum values.

Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 00e501d720d46386e6c8d0ebb4b3a8e98cb0390e)

3 years agoUpdate USB_PORT_RESET_RECOVERY to comply with the USB 2.0 specification which
Hans Petter Selasky [Tue, 18 May 2021 13:22:32 +0000 (15:22 +0200)]
Update USB_PORT_RESET_RECOVERY to comply with the USB 2.0 specification which
says it should be max 10 milliseconds.

This may fix some USB enumeration issues:
> usbd_req_re_enumerate: addr=3, set address failed! (USB_ERR_IOERROR, ignored)
> usbd_setup_device_desc: getting device descriptor at addr 3 failed,

Found by: Zhichao1.Li@dell.com
Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 70ffaaa69c830d26b59136d0b0447ab2f8683db8)

3 years agoFix for use-after-free by if_ioctl() calls from user-space in USB drivers by
Hans Petter Selasky [Tue, 12 Jan 2021 17:51:09 +0000 (18:51 +0100)]
Fix for use-after-free by if_ioctl() calls from user-space in USB drivers by
detaching the ifnet before the miibus.

PR: 252608
Suggested by: jhb@
Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 4eac63af23ddafc2b1dfb2aad2896f4513c37cdd)

3 years agoProperly define EPOCH(9) function macro.
Hans Petter Selasky [Fri, 21 May 2021 08:22:13 +0000 (10:22 +0200)]
Properly define EPOCH(9) function macro.

No functional change intended.

Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit f33168351b3804664f5e82a409d9f956df2802f3)

3 years agoMake sure all tasklets are drained before unloading the LinuxKPI.
Hans Petter Selasky [Fri, 21 May 2021 06:52:59 +0000 (08:52 +0200)]
Make sure all tasklets are drained before unloading the LinuxKPI.
Else use-after-free may happen.

This change also partially cherry picks support for the
taskqgroup_drain_all() function.

Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 209d4919c5270fe9e3c1d809cf91355d222dc2f3)

3 years agoAccessing the epoch structure should happen after the INIT_CHECK().
Hans Petter Selasky [Fri, 21 May 2021 09:06:27 +0000 (11:06 +0200)]
Accessing the epoch structure should happen after the INIT_CHECK().
Else the epoch pointer may be NULL.

Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit c82c200622b5380b8346de29879222538653f663)

3 years agoRework for-loop in EPOCH(9) to reduce indentation level.
Hans Petter Selasky [Fri, 21 May 2021 08:20:34 +0000 (10:20 +0200)]
Rework for-loop in EPOCH(9) to reduce indentation level.

No functional change intended.

Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit cc9bb7a9b863c018a069a71392fa9baea98b5fdb)

3 years agotests/libalias: Test LibAliasIn and redirection
Lutz Donnerhacke [Sun, 23 May 2021 12:43:00 +0000 (14:43 +0200)]
tests/libalias: Test LibAliasIn and redirection

Rework the tests to check the correct layer in a single test. Factor
out tests for reuse in other modules. Extend the test suite for
libalias(3) to incoming connections. Test the various types of
redirections.

gettimeofday(3) is almost as expensive as the calls to libalias.
So the call frequency for this call is reduced by a factor of 1000 in
order to neglect it's influence.

Using NAT entries became more realistic: A communication of a random
length of up to 150 packets (10% outgoing, 90% incoming) is applied
for each entry.

Add port forwardings to the performance tests.  This will cause random
incoming packets to match the random port forwardings opends beforehand.

After a long test run, a lot of ressouces have been allocated.
Measure the time tot free them.

Reviewed by: kp (partially)
Differential Revision: https://reviews.freebsd.org/D30412
Differential Revision: https://reviews.freebsd.org/D30408
Differential Revision: https://reviews.freebsd.org/D30405
Differential Revision: https://reviews.freebsd.org/D30443

(cherry picked from commit f1462ab0512c1a0e59f03a7a145df2889bed2997)
(cherry picked from commit 755bab6d55e6e2df168f352f3e2fbdea87002ed8)
(cherry picked from commit 6e87898a2c7e99937656a0c12d03333a43a10c5e)
(cherry picked from commit d62e1ecba07b2acee37e019778087f0f55d977d1)
(cherry picked from commit 5434ebd256a08e452dec376c1488abdf7ff02af8)

Fix various bugs:
(cherry picked from commit ccac04cae538a625cbce224e4005360fa85e1b9d)
(cherry picked from commit 7b8696bf128754712a24ba98ce2d88eed2ee68dc)
(cherry picked from commit fef99da69f983566de3cb8ad4a1b8decc31348ce)
(cherry picked from commit f4c460dacdda5c6e1896a0c51d6096c4f3417b32)

3 years agoiwn(4): Remove duplicate device entry
Gordon Bergling [Sun, 30 May 2021 13:40:33 +0000 (15:40 +0200)]
iwn(4): Remove duplicate device entry

'Intel Centrino Wireless-N 6250' is listed twice in the description
section of the manual page.

PR: 256257
Reported by: Daniel Cervus <danielthedeer at outlook dot com>

(cherry picked from commit 66e2a5803b0f80fff3bb8e3659ae7411ef94cc35)

3 years agotcsh: update to version 6.22.04.
Dmitry Chagin [Wed, 19 May 2021 21:12:27 +0000 (00:12 +0300)]
tcsh: update to version 6.22.04.

Merge commit '174d8b60324d7e8754709f7155e13ca95220b48c' into main.

(cherry picked from commit 6560ac57ce879857203bc456cdc3849808dc0700)

3 years agotcsh: cleanup source tree to reduce diff size.
Dmitry Chagin [Wed, 19 May 2021 21:08:25 +0000 (00:08 +0300)]
tcsh: cleanup source tree to reduce diff size.

Remove makefiles, configure files and unused at build time files
to reduce the diff size. Otherwise the diff contains a lot of
unnecessary lines what makes reviewing and merging proccess so hard,
especially for re@.

(cherry picked from commit 6190ff6104aed4cd753019325a252c4d66495b5e)

3 years agoFix packet cbs/ebs conversion.
Alexander Motin [Wed, 19 May 2021 15:00:21 +0000 (11:00 -0400)]
Fix packet cbs/ebs conversion.

Each packet is counted as 128 bytes by the code, not 125.  Not sure
what I was thinking about here 14 years ago.  May be just a typo.

Reported by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after: 2 weeks

(cherry picked from commit 4a6830761c6552bfe2c118a73a5a461694cb84c7)

3 years agoelfctl: avoid touching file if no change made
Ed Maste [Tue, 25 May 2021 18:25:18 +0000 (14:25 -0400)]
elfctl: avoid touching file if no change made

Suggested by: brooks
Reviewed by: brooks, markj
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30452

(cherry picked from commit 3f2508b7f3855102abed99b846e30e728ba3d04d)

3 years agopf: Move nvlist conversion functions to pf_nv
Kristof Provost [Tue, 18 May 2021 07:24:50 +0000 (09:24 +0200)]
pf: Move nvlist conversion functions to pf_nv

Separate the conversion functions (between kernel structs and nvlists)
to pf_nv. This reduces the size of pf_ioctl.c, which is already quite
large and complex, a good bit. It also keeps all the fairly
straightforward conversion code together.

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

(cherry picked from commit 3032c353882aa70a461ef251b8aa6c59a0829ec5)

3 years agocontrib/bc: update to version 4.0.2
Stefan Eßer [Wed, 12 May 2021 05:49:19 +0000 (07:49 +0200)]
contrib/bc: update to version 4.0.2

Merge commit '2858419a0ee2b8f5827de72c00618bcd69ebc5fc'

This update fixes the initialization of "scale" to 20 if started with
-l and the initial statement leads to an error (e.g. contains a syntax
error). Scale was initialized to 0 in that case.

Another change is the support of job control in interactive mode with
line editing enabled. The control characters have been interpreted as
editing commands only, prior to this version.

(cherry picked from commit 8c39e25220bb88cd027d0c3b0fe86e52f6abd150)

3 years agocontrib/bc: update to version 4.0.1
Stefan Eßer [Thu, 29 Apr 2021 12:29:04 +0000 (14:29 +0200)]
contrib/bc: update to version 4.0.1

This update adds a flush() of the output buffer to the bc print
command.

(cherry picked from commit 8ea9013512494c9f035afa1ffa1e199b44c7904f)

Synch index of contrib/bc with what is in workdir after cloning.

From a workdir perspective this should be a no-op.
See also:
https://lists.freebsd.org/pipermail/freebsd-current/2021-April/079569.html

(cherry picked from commit a0358e3d5184950b4316f105eb292cbafdea208b)

3 years agorun(4): fix manual after d6fd321ef60d43dce9f437187c94a7de2b91ab69.
Dmitry Chagin [Sun, 23 May 2021 13:35:31 +0000 (16:35 +0300)]
run(4): fix manual after d6fd321ef60d43dce9f437187c94a7de2b91ab69.

PR: 255759

(cherry picked from commit 43f5d5bf01fdf821e8037272c636a9be18323e00)

3 years agorun(4): add support for ASUS USB-N14 wireless adaptor.
Dmitry Chagin [Sat, 22 May 2021 10:52:12 +0000 (13:52 +0300)]
run(4): add support for ASUS USB-N14 wireless adaptor.

PR: 255759
Submitted by: john.lmurdoch at gmail.com

(cherry picked from commit d6fd321ef60d43dce9f437187c94a7de2b91ab69)

3 years agoDRIVER_MODULE(9): Correct the SYNOPSIS of EARLY_DRIVER_MODULE()
J.R. Oldroyd [Mon, 24 May 2021 14:54:45 +0000 (16:54 +0200)]
DRIVER_MODULE(9): Correct the SYNOPSIS of EARLY_DRIVER_MODULE()

The man page SYNOPSIS for EARLY_DRIVER_MODULE() shows that it has
an "enum sysinit_elem_order order" argument.

The actual macro in sys/bus.h does not have an order argument.

PR: 256103
Reported by: J.R. Oldroyd <fbsd at opal dot com>
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D30411

(cherry picked from commit 3fdd5c1e49cbc0a77935eb34e3561c6021b93650)

3 years agonfsd: Add support for CLAIM_DELEG_CUR_FH to the NFSv4.1/4.2 Open
Rick Macklem [Tue, 18 May 2021 22:53:54 +0000 (15:53 -0700)]
nfsd: Add support for CLAIM_DELEG_CUR_FH to the NFSv4.1/4.2 Open

The Linux NFSv4.1/4.2 client now uses the CLAIM_DELEG_CUR_FH
variant of the Open operation when delegations are recalled and
the client has a local open of the file.  This patch adds
support for this variant of Open to the NFSv4.1/4.2 server.

This patch only affects mounts from Linux clients when delegations
are enabled on the server.

(cherry picked from commit b3d4c70dc60f1913f2363751b905b562c39ca126)

3 years agonfsd: Reduce the callback timeout to 800msec
Rick Macklem [Tue, 18 May 2021 23:17:58 +0000 (16:17 -0700)]
nfsd: Reduce the callback timeout to 800msec

Recent discussion on the nfsv4@ietf.org mailing list confirmed
that an NFSv4 server should reply to an RPC in less than 1second.
If an NFSv4 RPC requires a delegation be recalled,
the server will attempt a CB_RECALL callback.
If the client is not responsive, the RPC reply will be delayed
until the callback times out.
Without this patch, the timeout is set to 4 seconds (set in
ticks, but used as seconds), resulting in the RPC reply taking over 4sec.
This patch redefines the constant as being in milliseconds and it
implements that for a value of 800msec, to ensure the RPC
reply is sent in less than 1second.

This patch only affects mounts from clients when delegations
are enabled on the server and the client is unresponsive to callbacks.

(cherry picked from commit fc0dc94029df8150301b925bda690b20d9d0bcbf)

3 years agotaskqueue: Add missing comma to TASKQUEUE_FAST_DEFINE_THREAD
Colin Percival [Tue, 25 May 2021 03:37:55 +0000 (20:37 -0700)]
taskqueue: Add missing comma to TASKQUEUE_FAST_DEFINE_THREAD

Add missing comma to TASKQUEUE_FAST_DEFINE_THREAD arguments to prevent
compilation errors.

Submitted by: ashafer_badland.io

(cherry picked from commit 27f09959d5f507465cc7f202c1b34987f0cdee55)

3 years agoptrace: add an option to not kill debuggees on debugger exit
Konstantin Belousov [Tue, 18 May 2021 16:26:22 +0000 (19:26 +0300)]
ptrace: add an option to not kill debuggees on debugger exit

(cherry picked from commit fd3ac06f452f47332e2f6fec8347579265c96104)

3 years agosys_process.c: extract ptrace_unsuspend()
Konstantin Belousov [Tue, 18 May 2021 16:25:50 +0000 (19:25 +0300)]
sys_process.c: extract ptrace_unsuspend()

(cherry picked from commit d7a7ea5be60753c140a39ec6fa30e5ca4014dbb5)

3 years agoMove mnt_maxsymlinklen into appropriate fs mount data structures
Konstantin Belousov [Tue, 18 May 2021 01:42:03 +0000 (04:42 +0300)]
Move mnt_maxsymlinklen into appropriate fs mount data structures

For MFC, mnt_maxsymlinklen was replaced by padding of type u_int,
to restore KBI after 57d877348b2c.

(cherry picked from commit f784da883fd5a744fcaf4ccfc550ca497ea5d7a6)

3 years agotcp: Use local CC data only in the correct context
Richard Scheffenegger [Wed, 26 May 2021 17:45:06 +0000 (19:45 +0200)]
tcp: Use local CC data only in the correct context

Most CC algos do use local data, and when calling
newreno_cong_signal from there, the latter misinterprets
the data as its own struct, leading to incorrect behavior.

Reported by:  chengc_netapp.com
Reviewed By:  chengc_netapp.com, tuexen, #transport
MFC after:    3 days
Sponsored By: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D30470

(cherry picked from commit c358f1857f0c749ad166fb9e9bef04f4033f3a72)

3 years agoNFSv4 server: Re-establish the delegation recall timeout
Rick Macklem [Sun, 16 May 2021 23:40:01 +0000 (16:40 -0700)]
NFSv4 server: Re-establish the delegation recall timeout

Commit 7a606f280a3e allowed the server to do retries of CB_RECALL
callbacks every couple of seconds.  This was needed to allow the
Linux client to re-establish the back channel.
However this patch broke the delegation timeout check, such that
it would just keep retrying CB_RECALLS.
If the client has crashed or been network patitioned from the
server, this continues until the client TCP reconnects to
the server and re-establishes the back channel.

This patch modifies the code such that it still times out the
delegation recall after some minutes, so that the server will
allow the conflicting client request once the delegation times out.

This patch only affects the NFSv4 server when delegations are
enabled and a NFSv4 client that holds a delegation has crashed
or been network partitioned from the server for at least several
minutes when a delegation needs to be recalled.

(cherry picked from commit 46269d66ed02598c86756d81a7d7b27ec0f0c5cd)

3 years agoktls.h: Guard includes behind _KERNEL
Mark Johnston [Sat, 22 May 2021 16:12:19 +0000 (12:12 -0400)]
ktls.h: Guard includes behind _KERNEL

These are not needed when including ktls.h to get sockopt definitions.

Reviewed by: gallatin, jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 5c7ef43e9625528da93b308a97aab0858f7eaec6)

3 years agoFix handling of embedded symbolic links (and history lesson).
Kirk McKusick [Mon, 17 May 2021 00:02:42 +0000 (17:02 -0700)]
Fix handling of embedded symbolic links (and history lesson).

Sponsored by: Netflix

(cherry picked from commit 9a2fac6ba65fbd14d37ccedbc2aec27a190128ea)

3 years agotests/libalias: Reduce stress
Lutz Donnerhacke [Sun, 23 May 2021 20:41:26 +0000 (22:41 +0200)]
tests/libalias: Reduce stress

Due to the new, external performance test utility, the regular test
suite can reduce the stress test to a fair amount of activity.

(cherry picked from commit a660948b7b2d875591aba3713620424c51330038)

3 years agolibalias: replace placeholder with static constant
Lutz Donnerhacke [Thu, 13 May 2021 21:47:57 +0000 (23:47 +0200)]
libalias: replace placeholder with static constant

The field nullAddress in struct libalias is never set and never used.
It exists as a placeholder for an unused argument only.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30253

(cherry picked from commit 189f8eea138a78b09c9f19114b1362b0df1cf87d)
(cherry picked from commit b03a41befeaf17ef25da96fc7bc2dc19c9a6b253)

3 years agoFix a use after free in update_rtm_from_rc().
Alexander V. Chernikov [Fri, 14 May 2021 16:03:08 +0000 (16:03 +0000)]
Fix a use after free in update_rtm_from_rc().

update_rtm_from_rc() calls update_rtm_from_info() internally.
The latter one may update provided prtm pointer with a new rtm.
Reassign rtm from prtm afeter calling update_rtm_from_info() to
 avoid touching the freed rtm.

PR: 255871
Submitted by: lylgood@foxmail.com

3 years agoFix panic when trying to delete non-existent gateway in multipath route.
Alexander V. Chernikov [Fri, 7 May 2021 20:36:50 +0000 (20:36 +0000)]
Fix panic when trying to delete non-existent gateway in multipath route.

IF non-existend gateway was specified, the code responsible for calculating
 an updated nexthop group, returned the same already-used nexthop group.
After the route table update, the operation result contained the same
 old & new nexthop groups. Thus, the code responsible for decomposing
 the notification to the list of simple nexthop-level notifications,
 was not able to find any differences. As a result, it hasn't updated any
  of the "simple" notification fields, resulting in empty rtentry pointer.
This empty pointer was the direct reason of a panic.

Fix the problem by returning ESRCH when the new nexthop group is the same
 as the old one after applying gateway filter.

Reported by: Michael <michael.adm at gmail.com>
PR: 255665

3 years agoAdd support for Gemini Lake LPSS UARTs.
Konstantin Belousov [Sun, 23 May 2021 16:38:54 +0000 (19:38 +0300)]
Add support for Gemini Lake LPSS UARTs.

PR: 256101

(cherry picked from commit eaf00819bcfa90ab7ac8af324826eb985197d8c8)

3 years agotest/libalias: Tests for instantiation and outgoing NAT
Lutz Donnerhacke [Sun, 16 May 2021 21:37:37 +0000 (23:37 +0200)]
test/libalias: Tests for instantiation and outgoing NAT

In order to modify libalias for performance, the existing
functionality must not change.  Enforce this.

Testing LibAliasOut functionality. This concentrates the typical use
case of initiating data transfers from the inside.  Provide a
exhaustive test for the data structure in order to check for
performance improvements.

In order to compare upcoming changes for their effectivness, measure
performance by counting opertions and the runtime of each operation
over the time.  Accumulate all tests in a single instance, so make it
complicated over the time.  If you wait long enough, you will notice
the expiry of old flows.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D30307
Differential Revision: https://reviews.freebsd.org/D30335
Differential Revision: https://reviews.freebsd.org/D30379

(cherry picked from commit 7fd8baee756efa18b6bbb17cbf3a652eb2058d87)
(cherry picked from commit c1fbb54f4b100d576da7ab065d1887a21f691936)
(cherry picked from commit 33c1bdfc3e098862100bab7a8dc729d8c78ffa7c)

3 years agolibalias: Style cleanup
Lutz Donnerhacke [Fri, 14 May 2021 13:08:08 +0000 (15:08 +0200)]
libalias: Style cleanup

libalias is a convolut of various coding styles modified by a series
of different editors enforcing interesting convetions on spacing and
comments.

This patch is a baseline to start with a perfomance rework of
libalias.  Upcoming patches should be focus on the code, not on the
style.  That's why most annoying style errors should be fixed
beforehand.

Reviewed by: hselasky
Discussed by: emaste
Differential Revision: https://reviews.freebsd.org/D30259

(cherry picked from commit effc8e57fbf03d7f1423c662caf2b63f0d1d21a9)

At some places the ASSERT was inserted before variable declarations are
finished.  This is fixed now.

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

(cherry picked from commit 2e6b07866f9e1520626a1523f6609cc411bdda1c)

3 years agonullfs: dirty v_object must imply the need for inactivation
Konstantin Belousov [Fri, 21 May 2021 07:30:19 +0000 (10:30 +0300)]
nullfs: dirty v_object must imply the need for inactivation

(cherry picked from commit 42881526d401e7a9c09241e392b7ffa18cfe11d6)

3 years agovn_need_pageq_flush(): simplify
Konstantin Belousov [Fri, 21 May 2021 07:34:27 +0000 (10:34 +0300)]
vn_need_pageq_flush(): simplify

(cherry picked from commit d713bf79273ad928f591dee2f8a553487e515e9b)

3 years ago.github: Attempt to un-break Clang 9 action
Jessica Clarke [Sat, 29 May 2021 03:36:36 +0000 (04:36 +0100)]
.github: Attempt to un-break Clang 9 action

GitHub removed Clang 9 from the 20.04 image[1], breaking this build.
Thus, manually add the specific versioned packages we need for the
Ubuntu jobs to ensure they're installed. Note that we don't do the same
for macOS, as Homebrew does not allow multiple llvm@N to co-exist,
giving an error if you attempt to install a second one. In practice we
don't actually use the compiler field here for anything other than the
build name, it's only the cross-bindir that matters, so when it
eventually moves to 12 the name will get confusing but the job will
still work.

MFC after: immediately

[1] https://github.com/actions/virtual-environments/commit/15a610677be406d250c1f6732b03c8b87e693a0a

(cherry picked from commit e5f5b6a75c0aa0f51a399e2002d15b51211630b5)

3 years agolibradius: Fix attribute length validation in rad_get_attr(3)
Mark Johnston [Fri, 28 May 2021 14:41:43 +0000 (10:41 -0400)]
libradius: Fix attribute length validation in rad_get_attr(3)

The length of the attribute header needs to be excluded when comparing
the attribute length against the length of the packet.  Otherwise,
validation may incorrectly fail when fetching the final attribute in a
message.

Fixes: 8d5c78130 ("libradius: Fix input validation bugs")
Reported by: Peter Eriksson
Tested by: Peter Eriksson
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6bb5699d2b59491097bc21ffa3c097cdd4853f89)

3 years agoFix scripted installs on EFI systems using ZFS root with zfsboot.
Nathan Whitehorn [Fri, 14 May 2021 12:30:41 +0000 (08:30 -0400)]
Fix scripted installs on EFI systems using ZFS root with zfsboot.

Unlike attended installations, scripted installs did not mount non-ZFS
partitions when ZFS root (via zfsboot) was selected. Since this included
the ESP, the EFI loader was not installed. Copy logic from the
attended-install path to make this work.

PR: 255824, 255081
MFC after: 1 week
Obtained from: Mark Huizer

(cherry picked from commit 34766aa8cb514472c571f8b0e90e833833acef51)

3 years agoldconfig(8): update manpage to reality
Konstantin Belousov [Sat, 15 May 2021 05:12:35 +0000 (08:12 +0300)]
ldconfig(8): update manpage to reality

(cherry picked from commit a19e14ca2d36aa9d5bd392881abd85bf9e2e89ad)

3 years agoixgbe: Improve device name strings
Kevin Bowling [Wed, 21 Apr 2021 02:35:14 +0000 (19:35 -0700)]
ixgbe: Improve device name strings

This is just clerical work to ease bug triage and may be used to set
expectations around the ability for anyone in the community to perform
testing and development on older parts.

Approved by: erj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D29876

(cherry picked from commit fdbcd35a75e596a78b4c0330eaded476eaa14797)

3 years agoe1000: Rework em_msi_link interrupt filter
Kevin Bowling [Sun, 25 Apr 2021 08:22:23 +0000 (01:22 -0700)]
e1000: Rework em_msi_link interrupt filter

* Fix 82574 Link Status Changes, carrying the OTHER mask bit around as
  needed.
* Move igb-class LSC re-arming out of FAST back into the handler.
* Clarify spurious/other interrupt re-arms in FAST.

In MSI-X mode, 82574 and igb-class devices use an interrupt filter to
handle Link Status Changes. We want to do LSC re-arms in the handler
to take advantage of autoclear (EIAC) single shot behavior.

82574 uses 'Other' in ICR and IMS for LSC interrupt types when in MSI-X
mode, so we need to set and re-arm the 'Other' bit during attach and
after ICR reads in the FAST handler if not an LSC or after handling on
LSC due to autoclearing.

This work was primarily done to address the referenced PR, but inspired
some clarification and improvement for igb-class devices once the
intentions of previous bug fix attempts became clearer.

PR: 211219
Reported by: Alexey <aserp3@gmail.com>
Tested by: kbowling (I210 lagg), markj (I210)
Approved by: markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D29943

(cherry picked from commit eea55de7b10808b86277d7fdbed2d05d3c6db1b2)

3 years agoe1000: Improve device name strings
Kevin Bowling [Wed, 21 Apr 2021 05:27:48 +0000 (22:27 -0700)]
e1000: Improve device name strings

This is just clerical work to ease bug triage and may be used to set
expectations around the ability for anyone in the community to perform
testing and development on older parts (this driver covers over 20 years
of silicon)

Reviewed by: erj
Approved by: markj
Sponsored by: Pink Floyd - Any Colour You Like (in kind)
Differential Revision: https://reviews.freebsd.org/D29872

(cherry picked from commit 0f6bea61edb4d055fe6e340aab3685054a582020)

3 years agoe1000: Correct promisc multicast filter handling
Kevin Bowling [Fri, 16 Apr 2021 23:15:50 +0000 (16:15 -0700)]
e1000: Correct promisc multicast filter handling

There are a number of issues in the e1000 multicast filter handling
that have been present for a long time. Take the updated approach from
ixgbe(4) which does not have the issues.

The issues are outlined in the PR, in particular this solves crossing
over and under the hardware's filter limit, not programming the
hardware filter when we are above its limit, disabling SBP (show bad
packets) when the tunable is enabled and exiting promiscuous mode, and
an off-by-one error in the em_copy_maddr function.

PR: 140647
Reported by: jtl
Reviewed by: markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D29789

(cherry picked from commit 4b38eed76da9c36f09bff33b5cf15687cd99016f)

3 years agoixgbe: Clean up unneeded set in ixgbe_if_multi_set
Kevin Bowling [Mon, 19 Apr 2021 19:22:22 +0000 (12:22 -0700)]
ixgbe: Clean up unneeded set in ixgbe_if_multi_set

We don't need to set the bits here since the if/else if/else statements
fully cover setting these bit pairs.

Reported by: markj
Reviewed by: markj, erj
Approved by: #intel_networking
MFC aftter: 1 week
Differential Revision: https://reviews.freebsd.org/D29827

(cherry picked from commit deecaa144526a5d001aeb99149e2139601388427)

3 years agoscsi(4): fix "NMVe" typo
Mitchell Horne [Fri, 21 May 2021 14:50:15 +0000 (11:50 -0300)]
scsi(4): fix "NMVe" typo

(cherry picked from commit 788401188f950001cd9796cdcea9a7e5f92050ab)

3 years agobuild(7): use a more relevant example for PORTS_MODULES
Mitchell Horne [Sat, 15 May 2021 14:14:52 +0000 (11:14 -0300)]
build(7): use a more relevant example for PORTS_MODULES

emulators/kqemu-kmod no longer exists in the ports tree.

Reviewed by: imp, bcr
Differential Revision: https://reviews.freebsd.org/D30261

(cherry picked from commit 7fbc0c98a8efaef86d72759372ec7746d929302e)

3 years agoufs: Avoid M_WAITOK allocations when building a dirhash
Don Morris [Thu, 20 May 2021 14:54:38 +0000 (10:54 -0400)]
ufs: Avoid M_WAITOK allocations when building a dirhash

At this point the directory's vnode lock is held, so blocking while
waiting for free pages makes the system more susceptible to deadlock in
low memory conditions.  This is particularly problematic on NUMA systems
as UMA currently implements a strict first-touch policy.

ufsdirhash_build() already uses M_NOWAIT for other allocations and
already handled failures for the block array allocation, so just convert
to M_NOWAIT.

PR: 253992
Reviewed by: markj, mckusick, vangyzen

(cherry picked from commit f17a5900850b4d449a91cbe9c61dfb62373c3cd1)

3 years agonetgraph/ng_bridge: Avoid cache thrashing
Lutz Donnerhacke [Thu, 11 Feb 2021 22:59:11 +0000 (23:59 +0100)]
netgraph/ng_bridge: Avoid cache thrashing

Hint the compiler, that this update is needed at most once per second.
Only in this case the memory line needs to be written.  This will
reduce the amount of cache trashing during forward of most frames.

Suggested by: zec
Approved by: zec
Differential Revision: https://reviews.freebsd.org/D28601

(cherry picked from commit 4dfe70fdbda05453e824bc9edfc0d09eab7b2929)

3 years agonetgraph/ng_bridge: become SMP aware
Lutz Donnerhacke [Tue, 12 Jan 2021 21:28:29 +0000 (22:28 +0100)]
netgraph/ng_bridge: become SMP aware

The node ng_bridge underwent a lot of changes in the last few months.
All those steps were necessary to distinguish between structure
modifying and read-only data transport paths.  Now it's done, the node
can perform frame forwarding on multiple cores in parallel.

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

(cherry picked from commit 9674c2e68c613757ddf5a8780743842b5ac4d74f)

3 years agonetgraph/ng_bridge: move MACs via control message
Lutz Donnerhacke [Tue, 9 Feb 2021 13:28:48 +0000 (14:28 +0100)]
netgraph/ng_bridge: move MACs via control message

Use the new control message to move ethernet addresses from a link to
a new link in ng_bridge(4).  Send this message instead of doing the
work directly requires to move the loop detection into the control
message processing.  This will delay the loop detection by a few
frames.

This decouples the read-only activity from the modification under a
more strict writer lock.

Reviewed by: manpages (gbe)
Differential Revision: https://reviews.freebsd.org/D28559

(cherry picked from commit f6e0c471691e0005e450ec968a9fa3b5346a3c45)

3 years agonetgraph/ng_bridge: learn MACs via control message
Lutz Donnerhacke [Tue, 4 May 2021 20:14:59 +0000 (22:14 +0200)]
netgraph/ng_bridge: learn MACs via control message

Add a new control message to move ethernet addresses to a given link
in ng_bridge(4). Send this message instead of doing the work directly.
This decouples the read-only activity from the modification under a
more strict writer lock.

Decoupling the work is a prerequisite for multithreaded operation.

Approved by: manpages (bcr), kp (earlier version)
Differential Revision: https://reviews.freebsd.org/D28516

(cherry picked from commit b1bd44732d8332930dc6a17092f47a201caff1ef)

3 years agopf: fix ioctl() memory leak
Kristof Provost [Mon, 24 May 2021 06:32:16 +0000 (08:32 +0200)]
pf: fix ioctl() memory leak

When we create an nvlist and insert it into another nvlist we must
remember to destroy it. The nvlist_add_nvlist() function makes a copy,
just like nvlist_add_string() makes a copy of the string. If we don't
we're leaking memory on every (nvlist-based) ioctl() call.

While here remove two redundant 'break' statements.

PR: 255971
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 4483fb47735c29408c72045469c9c4b3e549668b)

3 years agopfctl tests: Test fairq configuration
Kristof Provost [Wed, 19 May 2021 07:52:50 +0000 (09:52 +0200)]
pfctl tests: Test fairq configuration

We used to have a bug where pfctl could crash setting fairq queues. Test
this case and ensure it does not crash pfctl.

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

(cherry picked from commit 9938fcaa6565a660c555a0e9c712842ba1a2d31c)

3 years agopfctl: Fix crash on ALTQ configuration
Kristof Provost [Tue, 18 May 2021 13:03:01 +0000 (15:03 +0200)]
pfctl: Fix crash on ALTQ configuration

The following config could crash pfctl:
altq on igb0 fairq bandwidth 1Gb queue { qLink }
queue qLink fairq(default)

That happens because when we're parsing the parent queue (on igb0) it
doesn't have a parent, and the check in eval_pfqueue_fairq() checks
pa->parent rather than parent.

This was changed in eval_pfqueue_hfsc() in
1d34c9dac8624c5c315ae39ad3ae8e5879b23256, but not for fairq.

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

(cherry picked from commit 26705a39e51eaf5b32efa98fb86df2d4ecfbdc61)

3 years agopf tests: Test the ability to kill floating states by interface
Kristof Provost [Thu, 13 May 2021 08:04:20 +0000 (10:04 +0200)]
pf tests: Test the ability to kill floating states by interface

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

(cherry picked from commit 7bd7933f9a4f1757fdefeee2e1ac8b8c4d299fc3)

3 years agopf: Support killing floating states by interface
Kristof Provost [Thu, 13 May 2021 07:51:28 +0000 (09:51 +0200)]
pf: Support killing floating states by interface

Floating states get assigned to interface 'all' (V_pfi_all), so when we
try to flush all states for an interface states originally created
through this interface are not flushed. Only if-bound states can be
flushed in this way.

Given that we track the original interface we can check if the state's
interface is 'all', and if so compare to the orig_if instead.

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

(cherry picked from commit b62489cc92edbec318fb6c57cdc02b5e3cfa3a67)

3 years agopf: Track the original kif for floating states
Kristof Provost [Wed, 12 May 2021 11:24:57 +0000 (13:24 +0200)]
pf: Track the original kif for floating states

Track (and display) the interface that created a state, even if it's a
floating state (and thus uses virtual interface 'all').

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

(cherry picked from commit d0fdf2b28f9b981d2cb98e9da8a715e046ef1e92)

3 years agopfctl: Use DIOCGETSTATESNV
Kristof Provost [Mon, 10 May 2021 14:51:38 +0000 (16:51 +0200)]
pfctl: Use DIOCGETSTATESNV

Migrate to using the new nvlist-based DIOCGETSTATESNV call to obtain the
states list.

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

(cherry picked from commit bc941291473d8a2164e4ffc3f3e7e6a356cbe747)

3 years agopf: Add DIOCGETSTATESNV
Kristof Provost [Wed, 5 May 2021 19:00:16 +0000 (21:00 +0200)]
pf: Add DIOCGETSTATESNV

Add DIOCGETSTATESNV, an nvlist-based alternative to DIOCGETSTATES.

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

(cherry picked from commit 0592a4c83d67547644763fb023abd5eb28e57f92)

3 years agopf: Add DIOCGETSTATENV
Kristof Provost [Wed, 5 May 2021 12:33:55 +0000 (14:33 +0200)]
pf: Add DIOCGETSTATENV

Add DIOCGETSTATENV, an nvlist-based alternative to DIOCGETSTATE.

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

(cherry picked from commit 1732afaa0dae9d844e341f2c1d6ed4b79c403bfb)

3 years agopfctl: Ensure parent queue is configured for FAIRQ
Kristof Provost [Tue, 18 May 2021 16:22:13 +0000 (18:22 +0200)]
pfctl: Ensure parent queue is configured for FAIRQ

We failed to account for the FAIRQ scheduler in expand_altq(), which led
it to be set up without its parent queue.

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

(cherry picked from commit dc784287967d45ab681dc51e9e20b78c8c535834)

3 years agohda: correct comment about Asus laptop digital mics
Philippe Michaud-Boudreault [Wed, 19 May 2021 14:32:25 +0000 (10:32 -0400)]
hda: correct comment about Asus laptop digital mics

Reported in review D30333

MFC after: 1 week

(cherry picked from commit 5d698386fbfe166df72a17712ffde8cefeecefab)

3 years agokldxref: do not error out if specified path is not directory, for -d mode
Konstantin Belousov [Thu, 20 May 2021 19:12:11 +0000 (22:12 +0300)]
kldxref: do not error out if specified path is not directory, for -d mode

(cherry picked from commit d7751071bc41c63c5dadd81ef4b0a26748d8f9b0)