]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agogdb: allow setting/removing hardware watchpoints
Mitchell Horne [Mon, 8 Mar 2021 19:03:45 +0000 (15:03 -0400)]
gdb: allow setting/removing hardware watchpoints

Handle the 'z' and 'Z' remote packets for manipulating hardware
watchpoints.

This could be expanded quite easily to support hardware or software
breakpoints as well.

https://sourceware.org/gdb/onlinedocs/gdb/Packets.html

Reviewed by: cem, markj
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
NetApp PR: 51

(cherry picked from commit 4beb385813c8b1014f8250a31b07fdc09a059713)

3 years agoddb: replace watchpoint set/clear functions
Mitchell Horne [Mon, 8 Mar 2021 15:27:19 +0000 (11:27 -0400)]
ddb: replace watchpoint set/clear functions

Use the new kdb variants. Print more specific error messages.

Reviewed by: jhb, markj
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit 9d81dd5404b3ad7108059d7065814d56a722a96c)

3 years agoarm: implement kdb watchpoint functions
Mitchell Horne [Thu, 4 Mar 2021 00:14:42 +0000 (20:14 -0400)]
arm: implement kdb watchpoint functions

Implement wrappers around the existing debug_monitor interface, to be
consumed by MI kernel debugger code.

For now, the various db_printf() calls in this code remain. In the
future, they could be converted to printf() or removed altogether, to
properly decouple the DDB and GDB options.

Reviewed by: jhb, kib, markj
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit 5a2933d0bf9fb0018349b67a39fa85cbb3740779)

3 years agoarm64: implement kdb watchpoint functions
Mitchell Horne [Thu, 4 Mar 2021 21:53:21 +0000 (17:53 -0400)]
arm64: implement kdb watchpoint functions

Add wrappers around the debug_monitor interface, to be consumed by MI
kernel debugger code.  Update dbg_setup_watchpoint() and
dbg_remove_watchpoint() to return specific error codes, not just -1.

Reviewed by: jhb, kib, markj
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit 3ef68bc62c1e3ca9c452177f5cb9fd4de0df590d)

3 years agox86: implement kdb watchpoint functions
Mitchell Horne [Fri, 19 Feb 2021 22:36:08 +0000 (18:36 -0400)]
x86: implement kdb watchpoint functions

Add wrappers around the dbreg interface that can be consumed by MI
kernel debugger code. The dbreg functions themselves are updated to
return error codes, not just -1. dbreg_set_watchpoint() is extended to
accept access bits as an argument.

Reviewed by: jhb, kib, markj
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit 15dc1d44528a1e2693df41d5452d6ebb42ecafeb)

3 years agoIntroduce kdb-level watchpoint functions
Mitchell Horne [Mon, 8 Mar 2021 15:23:40 +0000 (11:23 -0400)]
Introduce kdb-level watchpoint functions

This basically mirrors what already exists in ddb, but provides a
slightly improved interface. It allows the caller to specify the
watchpoint access type, and returns more specific error codes to
differentiate failure cases.

This will be used to support hardware watchpoints in gdb(4).

Stubs are provided for architectures lacking hardware watchpoint logic
(mips, powerpc, riscv), while other architectures are added individually
in follow-up commits.

Reviewed by: jhb, kib, markj
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit 763107f26c3c3f4c8bb314a7cabc0a5548abff03)

3 years agox86: consolidate hw watchpoint logic into new file
Mitchell Horne [Fri, 19 Mar 2021 19:39:12 +0000 (16:39 -0300)]
x86: consolidate hw watchpoint logic into new file

This is a prerequisite to using these functions outside of ddb, but also
provides some cleanup and minor refactoring. This code is almost
entirely duplicated between the two implementations, the only
significant difference being the lack of dbreg synchronization on i386.

Cleanups are:
 - demote some internal functions to static
 - use the constant NDBREGS instead of a '4' literal
 - remove K&R definitions
 - some added comments

Reviewed by: kib, jhb
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit c02c04f113fe65001bc21363ae3ad08cf6c763eb)

3 years agospigen.4: Fix typos
Mateusz Piotrowski [Sun, 18 Apr 2021 07:45:18 +0000 (09:45 +0200)]
spigen.4: Fix typos

MFC after: 3 days

(cherry picked from commit 40277af7f23405c276edf02c3ddc8e770a06e3f6)

3 years agoRemove reference to the pfctlinput2() from domain(9) after 237c1f932b.
Dmitry Chagin [Tue, 13 Apr 2021 21:40:20 +0000 (00:40 +0300)]
Remove reference to the pfctlinput2() from domain(9) after 237c1f932b.

Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D29751

(cherry picked from commit 86887853c39b0803009579e2b927bd67d524af63)

3 years agoEnable GitHub actions CI for stable/13 as well
Alex Richardson [Tue, 20 Apr 2021 08:50:36 +0000 (09:50 +0100)]
Enable GitHub actions CI for stable/13 as well

All cross-building patches have been merged to stable/13 so it should
also build fine on macOS+Linux.

Reviewed By: uqs
MFC after: immediately
Differential Revision: https://reviews.freebsd.org/D29831

(cherry picked from commit 6bc0bb2936a41674bc992887ba17fddfa928ac90)

3 years agoExplain the newfs naming convention
Mateusz Piotrowski [Wed, 20 Jan 2021 10:40:20 +0000 (11:40 +0100)]
Explain the newfs naming convention

It might be unclear why newfs and newfs_msdos should cross-reference
each other. Add a note explaining it.

This is a follow-up to 74bd20769706041108a573601cf0b61c755bdc56.

Reported by: kib
Reviewed by:    imp, kib, rpokala
MFC after: 3 days

(cherry picked from commit 5b9b65e92fb40703038cbcf61feb4616c42e0b6e)

3 years agodevelopment(7): mention the Git mirror list in the manual page
Evgeniy Khramtsov [Fri, 19 Mar 2021 12:52:21 +0000 (20:52 +0800)]
development(7): mention the Git mirror list in the manual page

MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D29234

(cherry picked from commit 8ef03ce6db330fcc20e800c4d15a9f4915c56c43)

3 years agopowerpc/aim: Update timebase directly on resume instead of through platform
Justin Hibbits [Wed, 31 Mar 2021 16:54:27 +0000 (11:54 -0500)]
powerpc/aim: Update timebase directly on resume instead of through platform

This only works on single-CPU G4 systems, and more work is needed for
dual-CPU systems.  That said, platform sleep does not work, and this is
currently only used for PMU-based CPU speed change.

The elimination of the platform_smp_timebase_sync() call is so that the
timebase sync rendezvous can be enhanced to perform better
synchronization, which requires a full rendezvous.  This would be
impossible to do on this single-threaded run.

(cherry picked from commit 921716186f121a2f6a27178cb302415f37412a79)

3 years agopowerpc/powermac: Constrain 'cpu_sleep()' for AIM to mpc745x
Justin Hibbits [Wed, 31 Mar 2021 16:54:11 +0000 (11:54 -0500)]
powerpc/powermac: Constrain 'cpu_sleep()' for AIM to mpc745x

Rename cpu_sleep() to mpc745x_sleep() to denote what it's actually
intended for.  This function is very G4-specific, and will not work on
any other CPU.  This will afterward eliminate a
platform_smp_timebase_sync() call by directly updating the timebase
instead.

(cherry picked from commit b6d8f3b517dec010f3dfad1b33e9945eaa606be5)

3 years agousr.sbin/services_mkdb: diff reduction against NetBSD.
Xin LI [Sun, 21 Mar 2021 17:22:50 +0000 (10:22 -0700)]
usr.sbin/services_mkdb: diff reduction against NetBSD.

(cherry picked from commit 57b9a062d147563ecda72227f0bb051f60eff608)

3 years agousr.sbin/uefisign: prevent specifying certificate, key or output
Xin LI [Sun, 21 Mar 2021 17:12:34 +0000 (10:12 -0700)]
usr.sbin/uefisign: prevent specifying certificate, key or output
multiple times.

(cherry picked from commit 6234a0bfc8630fc556295812c15d72bde0f6427a)

3 years agopf tests: Test multi-wan rdr
Kristof Provost [Tue, 6 Apr 2021 11:25:49 +0000 (13:25 +0200)]
pf tests: Test multi-wan rdr

This replicates an issue observed on pfSense: https://redmine.pfsense.org/issues/11436

In essence, reply-to is needed to ensure that connections always leave
the WAN interface they came in on, but this confused the state tracking.

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

(cherry picked from commit f37667e2359245ad123fd775c072fd82c81bc476)

3 years agopf: Do not short-circuit processing for REPLY_TO
Kristof Provost [Wed, 7 Apr 2021 13:46:44 +0000 (15:46 +0200)]
pf: Do not short-circuit processing for REPLY_TO

When we find a state for packets that was created by a reply-to rule we
still need to process the packet. The state may require us to modify the
packet (e.g. in rdr or nat cases), which we won't do with the shortcut.

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

(cherry picked from commit 6d786845cf63c8bf57174e3e43b0b5c5eca75be3)

3 years agopf: Add static DTrace probe points
Kristof Provost [Fri, 2 Apr 2021 13:53:34 +0000 (15:53 +0200)]
pf: Add static DTrace probe points

These two have proven to be useful during debugging. We may as well keep
them permanently.
Others will be added as their utility becomes clear.

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

(cherry picked from commit f4c02909167b6f791df470afddfe31cabf009c4d)

3 years agopf: change pf_route so pf only runs when packets enter and leave the stack.
Kristof Provost [Fri, 2 Apr 2021 10:23:42 +0000 (12:23 +0200)]
pf: change pf_route so pf only runs when packets enter and leave the stack.

before this change pf_route operated on the semantic that pf runs
when packets go over an interface, so when pf_route changed which
interface the packet was on it would run pf_test again. this change
changes (restores) the semantic that pf is only supposed to run
when packets go in or out of the network stack, even if route-to
is responsibly for short circuiting past the network stack.

just to be clear, for normal packets (ie, those not touched by
route-to/reply-to/dup-to), there isn't a difference between running
pf when packets enter or leave the stack, or having pf run when a
packet goes over an interface.

the main reason for this change is that running the same packet
through pf multiple times creates confusion for the state table.
by default, pf states are floating, meaning that packets are matched
to states regardless of which interface they're going over. if a
packet leaving on em0 is rerouted out em1, both traversals will end
up using the same state, which at best will make the accounting
look weird, or at worst fail some checks in the state and get
dropped.

another reason for this commit is is to make handling of the changes
that route-to makes consistent with other changes that are made to
packet. eg, when nat is applied to a packet, we don't run pf_test
again with the new addresses.

the main caveat with this diff is you can't have one rule that
pushes a packet out a different interface, and then have a rule on
that second interface that NATs the packet. i'm not convinced this
ever worked reliably or was used much anyway, so we don't think
it's a big concern.

discussed with many, with special thanks to bluhm@, sashan@ and
sthen@ for weathering most of that pain.
ok claudio@ sashan@ jmatthew@

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

(cherry picked from commit 829a69db855b48ff7e8242b95e193a0783c489d9)

3 years agoFix direct route installation with net/bird.
Alexander V. Chernikov [Sat, 10 Apr 2021 15:25:24 +0000 (16:25 +0100)]
Fix direct route installation with net/bird.

Slighly relax the gateway validation rules imposed by the
 2fe5a79425c7, by requiring only first 8 bytes (everyhing
 before sdl_data to be present in the AF_LINK gateway.

Reported by: olivier
PR: 255089

(cherry picked from commit 7f5f3fcc32bfa553faa007579dfcaed84be3b047)

3 years agoRename struct device to struct _device
Mark Johnston [Mon, 12 Apr 2021 13:32:30 +0000 (09:32 -0400)]
Rename struct device to struct _device

types.h defines device_t as a typedef of struct device *.  struct device
is defined in subr_bus.c and almost all of the kernel uses device_t.
The LinuxKPI also defines a struct device, so type confusion can occur.

This causes bugs and ambiguity for debugging tools.  Rename the FreeBSD
struct device to struct _device.

Reviewed by: gbe (man pages)
Reviewed by: rpokala, imp, jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29676

(cherry picked from commit dfff37765ce4ea4fd7db4d293b459dc84008f411)

3 years agonetmap: don't use linux type struct device *
Vincenzo Maffione [Sun, 11 Apr 2021 21:06:43 +0000 (21:06 +0000)]
netmap: don't use linux type struct device *

Such type cannot be used in code that is in common between
FreeBSD and Linux. Use the FreeBSD type instead.

MFC after: 3 days
Reported by: markj
Differential Revision: https://reviews.freebsd.org/D29677

(cherry picked from commit 70275a6735df8a514f48be77418491f2f8dba817)

3 years agolinuxkpi: Fix pcie_set_readrq()
Mark Johnston [Mon, 12 Apr 2021 13:32:21 +0000 (09:32 -0400)]
linuxkpi: Fix pcie_set_readrq()

We were passing a LinuxKPI struct device * to a pci(4) function that
expects a device_t.

Reviewed by: manu, hselasky, bz
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29675

(cherry picked from commit 3f322b22e02d6aae147e9948ab50ca1bee9a9dd4)

3 years agoqlnxr: Properly initialize the Linux device structure
Mark Johnston [Mon, 12 Apr 2021 13:32:08 +0000 (09:32 -0400)]
qlnxr: Properly initialize the Linux device structure

The driver needs to provide a LinuxKPI device structure to register
itself with the IB subsystem.  It was erroneously using a copy of its
FreeBSD device structure for this purpose.

Use linux_pci_attach_device() instead, following the example of the
Chelsio iwarp driver.  Also ensure that we don't leak the faked device
during detach.

Reviewed by: hselasky
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29595

(cherry picked from commit 56cbd386fbaefc009541870ee013b2ff8d096bfc)

3 years agocxgb: Use device_t in preference to struct device *
Mark Johnston [Mon, 12 Apr 2021 13:32:04 +0000 (09:32 -0400)]
cxgb: Use device_t in preference to struct device *

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 9771af4942ec735d3f16d0697bb705a911a67266)

3 years agoal_eth: Use device_t in preference to struct device *
Mark Johnston [Mon, 12 Apr 2021 13:32:02 +0000 (09:32 -0400)]
al_eth: Use device_t in preference to struct device *

Sponsored by: The FreeBSD Foundation

(cherry picked from commit d8b1601d54e94a47af37742420403b16be239ad2)

3 years agogenet: Use device_t in preference to struct device *
Mark Johnston [Mon, 12 Apr 2021 13:31:58 +0000 (09:31 -0400)]
genet: Use device_t in preference to struct device *

Sponsored by: The FreeBSD Foundation

(cherry picked from commit f66a1f40740c63741b6ebe48cb0cbce9e52ef34e)

3 years agoRevert "lib/libc/net/nsdispatch.c: Fix missing unlock and add locking annotations"
Alex Richardson [Mon, 19 Apr 2021 08:36:47 +0000 (09:36 +0100)]
Revert "lib/libc/net/nsdispatch.c: Fix missing unlock and add locking annotations"

This commit should not have introduced any functional changes, but
apparently it did. This appears to have broken LDAP setups.
Reverting for now. Will reland once I have fixed the breakage.

This reverts commit 3496971e61dc9f6e725e57fb7b5f0c57631bbfc2.
Reported By: Александр Недоцуков, brd

(cherry picked from commit 738314e445ceac4d3dd6c77c636044141623b8dc)

3 years agonfsd: make the server repeat CB_RECALL every couple of seconds
Rick Macklem [Mon, 5 Apr 2021 01:15:54 +0000 (18:15 -0700)]
nfsd: make the server repeat CB_RECALL every couple of seconds

Commit 01ae8969a9ee stopped the NFSv4.1/4.2 server from implicitly
binding the back channel to a new TCP connection so that it
conforms to RFC5661, for NFSv4.1/4.2. An effect of this
for the Linux NFS client is that it will do a
BindConnectionToSession when it sees NFSV4SEQ_CBPATHDOWN
set in a sequence reply. This will fix the back channel, but the
first attempt at a callback like CB_RECALL will already have
failed. Without this patch, a CB_RECALL will not be retried
and that can result in a 5 minute delay until the delegation
times out.

This patch modifies the code so that it will retry the
CB_RECALL every couple of seconds, often avoiding the
5 minute delay.

This is not critical for correct behaviour, but avoids
the 5 minute delay for the case where the Linux client
re-binds the back channel via BindConnectionToSession.

(cherry picked from commit 7a606f280a3e174dcdd12736b7b976903809eb9c)

3 years agoEnsure that the mount command shows "with quotas" when quotas are enabled.
Kirk McKusick [Wed, 14 Apr 2021 22:22:12 +0000 (15:22 -0700)]
Ensure that the mount command shows "with quotas" when quotas are enabled.

(cherry picked from commit 14d0cd7225e250015eb6d9c79a7eb4e944211b23)

3 years agonfsd: fix BindConnectionToSession so that it clears "cb path down"
Rick Macklem [Sun, 4 Apr 2021 22:05:39 +0000 (15:05 -0700)]
nfsd: fix BindConnectionToSession so that it clears "cb path down"

Commit 01ae8969a9ee stopped the NFSv4.1/4.2 server from implicitly
binding the back channel to a new TCP connection so that it
conforms to RFC5661, for NFSv4.1/4.2. An effect of this
for the Linux NFS client is that it will do a
BindConnectionToSession when it sees NFSV4SEQ_CBPATHDOWN
set in a sequence reply. It will do this for every RPC
reply until it no longer sees the flag.
Without that patch, this will happen until the client does
an Open, which will clear LCL_CBDOWN.

This patch clears LCL_CBDOWN right away, so that
NFSV4SEQ_CBPATHDOWN will no longer be sent to the client
in Sequence replies and the Linux client will not repeat
the BindConnectionToSession RPCs.

This is not critical for correct behaviour, but reduces
RPC overheads for cases where the Open will not be done
for a while.

(cherry picked from commit 6f2addd838810ce33c7e9ad9543827d45e0b491c)

3 years agosystat.1: Remove Tn macros
Mateusz Piotrowski [Sat, 6 Feb 2021 13:14:20 +0000 (14:14 +0100)]
systat.1: Remove Tn macros

They are no longer supported by mdoc(7).

MFC after: 1 week

(cherry picked from commit fcbaf46b763a91bb41fe68afdcf59a7d210bc2f7)

3 years agosystat.1: Fix synopsis
Mateusz Piotrowski [Wed, 10 Feb 2021 17:02:14 +0000 (18:02 +0100)]
systat.1: Fix synopsis

systat does not have a "-display" flag. Use Ar to indicate that
"display" is meant to be substituted with an actual display command.

(cherry picked from commit e6f59be239aa17f80b44ded4779e29f5d5352b28)

3 years agoossl(4): Install the man page also for arm64
Gordon Bergling [Wed, 14 Apr 2021 16:32:56 +0000 (18:32 +0200)]
ossl(4): Install the man page also for arm64

In 22bd0c9731d7 ossl(4) was ported to arm64. The manual page was
adapted, but never installed since the ossl(4) manual page was
i386 / amd64 only.

Reviewed by: mhorne
Differential Revision: https://reviews.freebsd.org/D29762

(cherry picked from commit b1ab802ce4908b6af93e3a3b4328377003735357)

3 years agotcp: Use jenkins_hash32() in hostcache
Richard Scheffenegger [Thu, 8 Apr 2021 18:28:43 +0000 (20:28 +0200)]
tcp: Use jenkins_hash32() in hostcache

As other parts of the base tcp stack (eg.
tcp fastopen) already use jenkins_hash32,
and the properties appear reasonably good,
switching to use that.

Reviewed By: tuexen, #transport, ae
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29515

(cherry picked from commit b878ec024bbee063f4181c9be08476a864fa6a7b)

3 years agotcp: Use sbuf_drain unconditionally
Richard Scheffenegger [Fri, 2 Apr 2021 18:26:48 +0000 (20:26 +0200)]
tcp: Use sbuf_drain unconditionally

After making sbuf_drain safe for external use,
there is no need to protect the call.

MFC after: 2 weeks
Reviewed By: tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29545

(cherry picked from commit 38ea2bd0698e434ec531b97fa94b24db24e16629)
(cherry picked from commit a04906f0273fa6d80eb3ebf22b9b84e53e6b21e0)

3 years agotcp: Shouldn't drain empty sbuf
Richard Scheffenegger [Thu, 1 Apr 2021 15:18:04 +0000 (17:18 +0200)]
tcp: Shouldn't drain empty sbuf

MFC after: 2 weeks
Reviewed By: tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29524

(cherry picked from commit 9aef4e7c2bd4371e526e4e3feb26064d361ad8ce)

3 years agotcp: Add hash histogram output and validate bucket length accounting
Richard Scheffenegger [Thu, 1 Apr 2021 12:44:05 +0000 (14:44 +0200)]
tcp: Add hash histogram output and validate bucket length accounting

Provide a histogram output to check, if the hashsize or
bucketlimit could be optimized. Also add some basic sanity
checks around the accounting of the hash utilization.

MFC after: 2 weeks
Reviewed By: tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29506

(cherry picked from commit 02f26e98c7f4d43d6bd077421286da455e069146)

3 years agotcp: For hostcache performance, use atomics instead of counters
Richard Scheffenegger [Thu, 1 Apr 2021 08:00:32 +0000 (10:00 +0200)]
tcp: For hostcache performance, use atomics instead of counters

As accessing the tcp hostcache happens frequently on some
classes of servers, it was recommended to use atomic_add/subtract
rather than (per-CPU distributed) counters, which have to be
summed up at high cost to cache efficiency in a hot codepath.

PR: 254333
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Reviewed By: #transport, tuexen, jtl
Differential Revision: https://reviews.freebsd.org/D29522

(cherry picked from commit 529a2a0f2765f6c57c50a5af6be242c03bf714e3)

3 years agotcp: Make hostcache.cache_count MPSAFE by using a counter_u64_t
Richard Scheffenegger [Wed, 31 Mar 2021 17:30:20 +0000 (19:30 +0200)]
tcp: Make hostcache.cache_count MPSAFE  by using a counter_u64_t

Addressing the underlying root cause for cache_count to
show unexpectedly high  values, by protecting all arithmetic on
that global variable by using counter(9).

PR: 254333
Reviewed By: tuexen, #transport
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29510

(cherry picked from commit 95e56d31e348594973affd0ea81d8f8383bc3031)

3 years agotcp: drain tcp_hostcache_list in between per-bucket locks
Richard Scheffenegger [Wed, 31 Mar 2021 17:24:01 +0000 (19:24 +0200)]
tcp: drain tcp_hostcache_list in between per-bucket locks

Explicitly drain the sbuf after completing each hash bucket
to minimize the work performed while holding the hash
bucket lock.

PR: 254333
MFC after: 2 weeks
Reviewed By: tuexen, jhb, #transport
Sponsored by:  NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29483

(cherry picked from commit 869880463cc2ce64e2e6599eaec880a981f3ced6)

3 years agotcp: reduce memory footprint when listing tcp hostcache
Richard Scheffenegger [Sun, 28 Mar 2021 21:12:03 +0000 (23:12 +0200)]
tcp: reduce memory footprint when listing tcp hostcache

In tcp_hostcache_list, the sbuf used would need a large (~2MB)
blocking allocation of memory (M_WAITOK), when listing a
full hostcache. This may stall the requestor for an indeterminate
time.

A further optimization is to return the expected userspace
buffersize right away, rather than preparing the output of
each current entry of the hostcase, provided by: @tuexen.

This makes use of the ready-made functions of sbuf to work
with sysctl, and repeatedly drain the much smaller buffer.

PR: 254333
MFC after: 2 weeks
Reviewed By: #transport, tuexen
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29471

(cherry picked from commit cb0dd7e122b8936ad61a141e65ef8ef874bfebe5)

3 years agoMake sbuf_drain safe for external use
Richard Scheffenegger [Fri, 2 Apr 2021 18:11:45 +0000 (20:11 +0200)]
Make sbuf_drain safe for external use

While sbuf_drain was an internal function, two
KASSERTS checked the sanity of it being called.
However, an external caller may be ignorant if
there is any data to drain, or if an error has
already accumulated. Be nice and return immediately
with the accumulated error.

MFC after: 2 weeks
Reviewed By: tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29544

(cherry picked from commit cad4fd0365a5e3235e715e072e6ee9dffaa7a3ab)

3 years agoExport sbuf_drain to orchestrate lock and drain action
Richard Scheffenegger [Wed, 31 Mar 2021 16:25:53 +0000 (18:25 +0200)]
Export sbuf_drain to orchestrate lock and drain action

While exporting large amounts of data to a sysctl
request, datastructures may need to be locked.

Exporting the sbuf_drain function allows the
coordination between drain events and held
locks, to avoid stalls.

PR: 254333
Reviewed By: jhb
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D29481

(cherry picked from commit c804c8f2c58ba42d476de07fbceff9ac4dd95f0e)

3 years agoed(1): Add two references in the SEE ALSO section
Gordon Bergling [Fri, 9 Apr 2021 07:43:49 +0000 (09:43 +0200)]
ed(1): Add two references in the SEE ALSO section

Obtained from: OpenBSD

(cherry picked from commit 3ce579325e424ce9297546553fb453a4ec62c20b)

3 years agoconfig(8): Mention the authors of a paper in the SEE ALSO section
Gordon Bergling [Fri, 9 Apr 2021 09:20:49 +0000 (11:20 +0200)]
config(8): Mention the authors of a paper in the SEE ALSO section

Obtained from: OpenBSD

(cherry picked from commit 2b59392cb0da804e825c63469beb1934ec4267db)

3 years agolpd(8): Mention the author of a paper in the SEE ALSO section
Gordon Bergling [Fri, 9 Apr 2021 09:29:18 +0000 (11:29 +0200)]
lpd(8): Mention the author of a paper in the SEE ALSO section

Obtained from: OpenBSD

(cherry picked from commit c07aa0a5878f55ef22b8d0ba5f66a728b1407427)

3 years agoarm64: adjust comments in dbg_monitor_exit()
Mitchell Horne [Tue, 13 Apr 2021 17:34:58 +0000 (14:34 -0300)]
arm64: adjust comments in dbg_monitor_exit()

These comments were copied from dbg_monitor_enter(), but the intended
modifications weren't made. Update them to reflect what this code
actually does.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 5742f2d89c03311e8b2d92422c0e2e4063cb2e1d)

3 years agoarm64: clear debug registers after execve(2)
Mitchell Horne [Fri, 9 Apr 2021 14:13:21 +0000 (11:13 -0300)]
arm64: clear debug registers after execve(2)

This is both intuitive and required, as any previous breakpoint settings
may not be applicable to the new process.

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

(cherry picked from commit a2a8b582bdc1c8c1f4da3ae727349327f5fc9dd8)

3 years agormlock(9): add an RM_DUPOK flag
Mitchell Horne [Thu, 8 Apr 2021 17:41:19 +0000 (14:41 -0300)]
rmlock(9): add an RM_DUPOK flag

Allows for duplicate locks to be acquired without witness complaining.
Similar flags exists already for rwlock(9) and sx(9).

Reviewed by: markj
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

(cherry picked from commit 2816bd8442bc323d50434d0e64cb4b7c10a195e8)

3 years agoarm64: clear debug register state on fork
Mitchell Horne [Wed, 7 Apr 2021 19:23:46 +0000 (16:23 -0300)]
arm64: clear debug register state on fork

Following the analogous change for amd64 and i386 in 8223717ce62c,
ensure that new processes start with these registers inactive.

PR: 254661
Reported by: Michał Górny
Reviewed by: kib, emaste
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 1fd001db9c330f133708f3c04c8852f8b07cfed9)

3 years agoPartially revert r248770.
Dmitry Chagin [Fri, 2 Apr 2021 08:43:17 +0000 (11:43 +0300)]
Partially revert r248770.

Under geom(4) nvme_ns_bio_process() is on the path where sleep
is prohibited as g_io_shedule_down() calls THREAD_NO_SLEEPNG()
before geom->start().

Reviewed By: imp
Differential Revision: https://reviews.freebsd.org/D29539

(cherry picked from commit a78109d5db87b08785a822770e2e4fdb15f921b6)

3 years agoRemoved the reference to the deprecated splx API from ifnet(9).
Dmitry Chagin [Fri, 9 Apr 2021 14:22:12 +0000 (17:22 +0300)]
Removed the reference to the deprecated splx API from ifnet(9).

Reviewed by: emaste, markj
PR: 254880
Differential Revision: https://reviews.freebsd.org/D29666

(cherry picked from commit f2400e6e832d42ca72b0d04ecd070598f4a81eb7)

3 years agoAdd a new mode to the scripted partition editor for variant disk names.
Nathan Whitehorn [Fri, 26 Mar 2021 15:39:12 +0000 (11:39 -0400)]
Add a new mode to the scripted partition editor for variant disk names.

If the disk parameter "DEFAULT" is set in place of an actual device name,
or no disk is specified for the PARTITIONS parameter, the installer will
follow the logic used in the automatic-partitioning mode, in which it
will either provide a selection dialog for one of several disks if
several are present or automatically select it if there is only one. This
simplifies the creation of fully-automatic installation media for
hardware or VMs with varying disk names.

Suggested by: Egoitz Aurrekoetxea <egoitz@sarenet.es>
MFC after: 3 weeks
Relnotes: yes

(cherry picked from commit 5140034cc077c416690b4fdb79a96744fe0af0e6)

3 years agoifconfig: Reuse media state in ifmedia_getstate
Ryan Moeller [Fri, 16 Apr 2021 02:32:25 +0000 (22:32 -0400)]
ifconfig: Reuse media state in ifmedia_getstate

This restores behavior lost in code cleanup, fixing a regression after
2803fa471e77dc8f227fe00bbf075de7feb10022 where changing media options
only applies some of the changes, not all.

Reported by: np
Reviewed by: donner
Differential Revision: https://reviews.freebsd.org/D29741

(cherry picked from commit 407fb44c920a580a30dfe7d1add796a7b35a5ac7)

3 years agofbt: Remove some handling for multiple CTF containers
Mark Johnston [Fri, 2 Apr 2021 21:42:26 +0000 (17:42 -0400)]
fbt: Remove some handling for multiple CTF containers

This was ported from illumos but not completely done.  Currently we do
not perform type deduplication between KLDs and the kernel, i.e., kernel
modules have a complete type graph.  So, remove it for now since it's
not functional and complicates the task of modifying various CTF type
definitions, and we are hitting some limits in the current format which
necessitate an update.

No functional change intended.

(cherry picked from commit 4d221f59b851a9c844c84701bab7f4edb7026bd4)

3 years agosys/ck.h: Add an include guard
Kevin Bowling [Sun, 21 Mar 2021 18:50:30 +0000 (11:50 -0700)]
sys/ck.h: Add an include guard

Approved by: cognet
MFC after: 1 week
Sponsored by: BBOX.io
Differential Revision: https://reviews.freebsd.org/D29357

(cherry picked from commit 2595d78f3df2ca389aae259a291f93eb06ecad43)

3 years agonfsv4 client: factor loop contents out into a separate function
Rick Macklem [Thu, 1 Apr 2021 22:36:37 +0000 (15:36 -0700)]
nfsv4 client: factor loop contents out into a separate function

Commit fdc9b2d50fe9 replaced a couple of while loops with LIST_FOREACH()
loops.  This patch factors the body of that loop out into a separate
function called nfscl_checkown().
This prepares the code for future changes to use a hash table of
lists for open searches via file handle.

This patch should not result in a semantics change.

(cherry picked from commit 4e6c2a1ee9af05bf42187e8201af1d03a617834f)

3 years agonfsd: silence rpcb_unset noise for NFSv4 only servers
Rick Macklem [Thu, 1 Apr 2021 22:09:03 +0000 (15:09 -0700)]
nfsd: silence rpcb_unset noise for NFSv4 only servers

An NFSv4 only configuration does not register with
rpcbind(). Without this patch a failure to rpcb_unset()
is reported when the daemon is terminated for this case.

This is harmless noise, but this patch avoids calling
rpcb_unset() for the NFSv4 only case, avoiding the noise.

When called with "-d", it still does the rpcb_unset(),
assuming that the configuration might have been
changed to NFSv4 only and unregistering with
rpcbind() might still be needed.

(cherry picked from commit b43fe9eb4b3365156016ae3477747a46fc094bb8)

3 years agosetclassenvironment: trim leading spaces in variable names
Yuri Pankov [Sun, 11 Apr 2021 22:02:12 +0000 (01:02 +0300)]
setclassenvironment: trim leading spaces in variable names

Trim leading spaces in variable names when the list is e.g.
pretty-formatted in /etc/login.conf or ~/.login_conf.

PR: 247947
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D25649

(cherry picked from commit eeaf9d562fe137e0c52b8c346742dccfc8bde015)

3 years agoAvoid raising unexpected floating point exceptions in libm
Dimitry Andric [Fri, 9 Apr 2021 23:07:54 +0000 (01:07 +0200)]
Avoid raising unexpected floating point exceptions in libm

When using clang with x86_64 CPUs that support AVX, some floating point
transformations may raise exceptions that would not have been raised by
the original code. To avoid this, use the -fp-exception-behavior=maytrap
flag, introduced in clang 10.0.0.

In particular, this fixes a number of test failures with ctanhf(3) and
ctanf(3), when libm is compiled with -mavx. An unexpected FE_INVALID
exception is then raised, because clang emits vdivps instructions to
perform certain divides. (The vdivps instruction operates on multiple
single-precision float operands simultaneously, but the exceptions may
be influenced by unused parts of the XMM registers. In this particular
case, it was calculating 0 / 0, which results in FE_INVALID.)

If -fp-exception-behavior=maytrap is specified however, clang uses
vdivss instructions instead, which work on one operand, and should not
raise unexpected exceptions.

Reported by: olivier
Reviewed by: arichardson
PR: 254911
Differential Revision: https://reviews.freebsd.org/D29686

(cherry picked from commit 3b00222f156dca5700c839d73e36daf479fa640c)

Only use -fp-exception-behavior=maytrap on x86, for now

After 3b00222f156d, it turns out that clang only supports strict
floating point semantics for SystemZ and x86 at the moment, while for
other architectures it is still experimental.

Therefore, only use -fp-exception-behavior=maytrap on x86 for now,
otherwise this option results in "error: overriding currently
unsupported use of floating point exceptions on this target
[-Werror,-Wunsupported-floating-point-opt]" on other architectures.

Fixes: 3b00222f156d
PR: 254911

(cherry picked from commit bae9fd0b33462e9506c3ac3400089c6dbc4aee8f)

3 years agoAvoid -pedantic warnings about using _Generic in __fp_type_select
Dimitry Andric [Thu, 8 Apr 2021 11:13:15 +0000 (13:13 +0200)]
Avoid -pedantic warnings about using _Generic in __fp_type_select

When compiling parts of math.h with clang using a C standard before C11,
and using -pedantic, it will result in warnings similar to:

bug254714.c:5:11: warning: '_Generic' is a C11 extension [-Wc11-extensions]
  return !isfinite(1.0);
          ^
/usr/include/math.h:111:21: note: expanded from macro 'isfinite'
                    ^
/usr/include/math.h:82:39: note: expanded from macro '__fp_type_select'
                                      ^

This is because the block that enables use of _Generic is conditional
not only on C11, but also on whether the compiler advertises support for
C generic selections via __has_extension(c_generic_selections).

To work around the warning without having to pessimize the code, use the
__extension__ keyword, which is supported by both clang and gcc. While
here, remove the check for __clang__, as _Generic has been supported for
a long time by gcc too now.

Reported by: yuri
PR: 254714

3 years agopowernv: Include NUMA locality information in the CPU topology
Mark Johnston [Thu, 1 Apr 2021 14:25:57 +0000 (10:25 -0400)]
powernv: Include NUMA locality information in the CPU topology

ULE uses this topology to try and preserve locality when migrating
threads between CPUs and when performing work stealing.  Ensure that on
NUMA systems it will at least take the NUMA topology into account.

Reviewed by: bdragon, jhibbits (previous version)
Tested by: bdragon
Differential Revision: https://reviews.freebsd.org/D28580

(cherry picked from commit cb5f8694a522ab9a80f9f0bd321d8f3ed818dd9b)

3 years agoAdd GPT PREP-boot type to mkimg(1) from geom_gpt.
Nathan Whitehorn [Wed, 24 Feb 2021 15:31:44 +0000 (10:31 -0500)]
Add GPT PREP-boot type to mkimg(1) from geom_gpt.

This partition type can be used to boot some PowerKVM VMs. We don't
support it well because of some limitations in SLOF, but it's worth at
least have feature parity in geom and mkimg.

(cherry picked from commit f7aebfbe5c0ab63dbb3d134d143ccff2c2b278bb)

3 years agoDelete memstick images for PowerPC.
Nathan Whitehorn [Wed, 24 Feb 2021 03:17:20 +0000 (22:17 -0500)]
Delete memstick images for PowerPC.

These images only ever worked on Apple Powermacs, which are now a very
old platform, and did so only for a very loose definition of "worked"
(they booted on a small subset of supported machines). Moreover, all
the machines they *did* boot on also would boot from a memstick made
by dd'ing an CD image to a flash drive. Since a flash drive prepared
in this way would also boot all the newer systems we support, the
memstick images were strictly less functional than the CD images, even
for booting from memory sticks.
Reviewed by: jhibbits
MFC after: 1 week

(cherry picked from commit 1af48800c20fadb07acca2ab930bb3bccd363edb)

3 years agom4(1): Add a SEE ALSO section and reference an AT&T manual
Gordon Bergling [Thu, 8 Apr 2021 19:16:54 +0000 (21:16 +0200)]
m4(1): Add a SEE ALSO section and reference an AT&T manual

Obtained from: OpenBSD

(cherry picked from commit 97fa288a663dfae192c471ec5cbfdf0d2f45367e)

3 years agosed(1): Add a reference for a 4.4BSD manual document
Gordon Bergling [Thu, 8 Apr 2021 18:57:14 +0000 (20:57 +0200)]
sed(1): Add a reference for a 4.4BSD manual document

Obtained from: OpenBSD

(cherry picked from commit 9048d9a933f57991ee042618ab89dd49d8cbad89)

3 years agoRemove more remnants of sio(4)
Mark Johnston [Wed, 7 Apr 2021 18:21:07 +0000 (14:21 -0400)]
Remove more remnants of sio(4)

Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29626

(cherry picked from commit 0f07c234ca1d3ccce158bb68c03829a266942c6e)

3 years agolibnv: Allow use in non-sleepable contexts
Kristof Provost [Thu, 25 Mar 2021 12:59:14 +0000 (13:59 +0100)]
libnv: Allow use in non-sleepable contexts

44c125c4cebc2fd87c6260b90eddae11201f5232 switched the nvlist allocations
to be M_WAITOK, but this precludes the use in non-sleepable contexts.
(E.g. with a nonsleepable lock held).

All callers for these allocation functions already cope with memory
alloation failures, so there's no reason to allow sleeping during
allocations.

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

(cherry picked from commit ab8d25880ebc9ddca1ae6af938680036349edf3f)

3 years agopf tests: make synproxy and nat work correctly even if inetd is running
Kurosawa Takahiro [Wed, 7 Apr 2021 06:17:51 +0000 (08:17 +0200)]
pf tests: make synproxy and nat work correctly even if inetd is running

tests/sys/netfil/pf/synproxy fails if inetd has been running
outside of the jail because pidfile_open() fails with EEXIST.
tests/sys/netfil/pf/nat has the same problem but the test succeeds
because whether inetd is running is not so important.

Fix the problem by changing the pidfile path from the default
location.

Reviewed by: kp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29622

(cherry picked from commit 5a5623397c73e46b206289d32d1d6b9de420da9c)

3 years agoAdd IDs for ASMedia ASM116x PCIe 3.0 AHCI controllers.
Alexander Motin [Wed, 7 Apr 2021 19:03:36 +0000 (15:03 -0400)]
Add IDs for ASMedia ASM116x PCIe 3.0 AHCI controllers.

MFC after: 1 week

(cherry picked from commit 5a8d32b53b919d82d6a3aa9f155bd2a00fb51dc2)

3 years agofreebsd-update: improve mandoc db generation
Ed Maste [Sun, 4 Apr 2021 00:57:26 +0000 (20:57 -0400)]
freebsd-update: improve mandoc db generation

freebsd-update compares the dates on man pages with mandoc.db, and if
any newer pages are found it regenerates mandoc.db.

Previously, if mandoc.db did not already exist the check failed and
freebsd-update then failed to create one.  Now, check that mandoc.db
exists before performing the check for newer pages.

Reported by: bdrewery (in D10482)
Reviewed by: gordon
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29575

(cherry picked from commit 741223a65cd1752360c44341b762295f633e21cf)

3 years agousr.sbin/services_mkdb: plug memory leak when line was blank.
Xin LI [Tue, 30 Mar 2021 22:21:37 +0000 (15:21 -0700)]
usr.sbin/services_mkdb: plug memory leak when line was blank.

Reviewed by: bapt
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D29370

(cherry picked from commit 18f3c5fe9207fbd19360b8ddb23ba10a5ad3df68)

3 years agosysctl.conf(5): Mention sysctl.conf.local in the sysctl.conf(5) manual page
Gordon Bergling [Fri, 9 Apr 2021 15:28:18 +0000 (17:28 +0200)]
sysctl.conf(5): Mention sysctl.conf.local in the sysctl.conf(5) manual page

The possibility of using a sysctl.conf.local on a machine that has a shared
sysctl.conf(5) isn't documented. So mention the sysctl.conf.local in the
manual page.

PR: 254901
Submitted by: Jose Luis Duran <jlduran at gmail dot com>
Reported by: Jose Luis Duran <jlduran at gmail dot com>
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D29673

(cherry picked from commit 46c99528078ad478f50910110a933abef0b89cde)

3 years agoFix vlan creation for the older ifconfig(8) binaries.
Alexander V. Chernikov [Sun, 11 Apr 2021 16:47:03 +0000 (17:47 +0100)]
Fix vlan creation for the older ifconfig(8) binaries.

Reported by: allanjude
MFC after: immediately

(cherry picked from commit afbb64f1d85b7d8c2938031c3567946b5d10da4f)

3 years agoTweak language involving ZFS installation; no content changes.
Nathan Whitehorn [Mon, 5 Apr 2021 14:23:00 +0000 (10:23 -0400)]
Tweak language involving ZFS installation; no content changes.

(cherry picked from commit b8639a1098a70e8ca8ec5880d2337fed04e4243a)

3 years agoAdd some general notes about scripted installations.
Nathan Whitehorn [Mon, 5 Apr 2021 14:10:34 +0000 (10:10 -0400)]
Add some general notes about scripted installations.

(cherry picked from commit 3b20b988e0f14740eb135ad5d56520b8cb94f429)

3 years agoInclude examples of how to build script-install media.
Nathan Whitehorn [Mon, 22 Mar 2021 14:20:29 +0000 (10:20 -0400)]
Include examples of how to build script-install media.

(cherry picked from commit c8923d191dd3e56b8e1113b4a94da3193600c110)
(cherry picked from commit 9f88bee14659c9e5920372c53106e666b502b3cd)

3 years agoImprove example install scripts, making them simpler and more robust.
Nathan Whitehorn [Mon, 22 Mar 2021 14:08:55 +0000 (10:08 -0400)]
Improve example install scripts, making them simpler and more robust.

In particular:
- There is no need to do anything with gpart (the installer does that
  for you).
- There is no need to specify the network interface, since we have
  an option for defaults.

(cherry picked from commit f91026bf462f9a636735cafafd29a1232b2a525b)

3 years agoClarify that scripted installations don't require specification of boot
Nathan Whitehorn [Fri, 19 Mar 2021 13:44:30 +0000 (09:44 -0400)]
Clarify that scripted installations don't require specification of boot
partitions, as there seems to be widespread confusion on this point.

MFC after: 1 day

(cherry picked from commit e8b4c5a6226b6bde304380de51c347851680b7ed)

3 years agolibc: Fix the WITH_HESIOD build
Mark Johnston [Mon, 5 Apr 2021 20:23:18 +0000 (16:23 -0400)]
libc: Fix the WITH_HESIOD build

Reported by: Daniel Braniss <danny@cs.huji.ac.il>

(cherry picked from commit 3b666932d409ad79c527c026abacd4d327df5b46)

3 years agoqat: Make prototypes consistent with the implementation
Mark Johnston [Mon, 5 Apr 2021 20:23:22 +0000 (16:23 -0400)]
qat: Make prototypes consistent with the implementation

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 843d16436d3388c1b46d37fca4e86885612d0e64)

3 years agonfsv4 client: replace while loops with LIST_FOREACH() loops
Rick Macklem [Mon, 29 Mar 2021 21:14:51 +0000 (14:14 -0700)]
nfsv4 client: replace while loops with LIST_FOREACH() loops

This patch replaces a couple of while() loops with LIST_FOREACH() loops.
While here, declare a couple of variables "bool".
I think LIST_FOREACH() is preferred and makes the code more readable.
This also prepares the code for future changes to use a hash table of
lists for open searches via file handle.

This patch should not result in a semantics change.

(cherry picked from commit fdc9b2d50fe905b54afd773a2fc7fb9947508ddf)

3 years agonfsv4.1/4.2 client: fix handling of delegations for "oneopenown" mnt option
Rick Macklem [Mon, 29 Mar 2021 19:09:19 +0000 (12:09 -0700)]
nfsv4.1/4.2 client: fix handling of delegations for "oneopenown" mnt option

If a delegation for a file has been acquired, the "oneopenown" option
was ignored when the local open was issued. This could result in multiple
openowners/opens for a file, that would be transferred to the server
when the delegation was recalled.
This would not be serious, but could result in more than one openowner.
Since the Amazon/EFS does not issue delegations, this probably never
occurs in practice.
Spotted during code inspection.

This small patch fixes the code so that it checks for "oneopenown"
when doing client local opens on a delegation.

(cherry picked from commit e61b29ab5d2d9afd41d9fa06bb1f4cad4e9d0650)

3 years agonfsd: do not implicitly bind the back channel for NFSv4.1/4.2 mounts
Rick Macklem [Tue, 30 Mar 2021 21:31:05 +0000 (14:31 -0700)]
nfsd: do not implicitly bind the back channel for NFSv4.1/4.2 mounts

The NFSv4.1 (and 4.2 on 13) server incorrectly binds
a new TCP connection to the back channel when first
used by an RPC with a Sequence op in it (almost all of them).
RFC5661 specifies that only the fore channel should be bound.

This was done because early clients (including FreeBSD)
did not do the required BindConnectionToSession RPC.

Unfortunately, this breaks the Linux client when the
"nconnects" mount option is used, since the server
may do a callback on the incorrect TCP connection.

This patch converts the server behaviour to that
required by the RFC.  It also makes the server test/indicate
failure of the back channel more aggressively.

Until this patch is applied to the server, the
"nconnects" mount option is not recommended for a Linux
NFSv4.1/4.2 client mount to the FreeBSD server.

(cherry picked from commit 01ae8969a9eed652fbd894faa5b31b1593079ed8)

3 years agonfsv4 client: fix forced dismount when sleeping in the renew thread
Rick Macklem [Tue, 23 Mar 2021 20:04:37 +0000 (13:04 -0700)]
nfsv4 client: fix forced dismount when sleeping in the renew thread

During a recent NFSv4 testing event a test server caused a hang
where "umount -N" failed.  The renew thread was sleeping on "nfsv4lck"
and the "umount" was sleeping, waiting for the renew thread to
terminate.

This is the second of two patches that is hoped to fix the renew thread
so that it will terminate when "umount -N" is done on the mount.

This patch adds a 5second timeout on the msleep()s and checks for
the forced dismount flag so that the renew thread will
wake up and see the forced dismount flag.  Normally a wakeup()
will occur in less than 5seconds, but if a premature return from
msleep() does occur, it will simply loop around and msleep() again.
The patch also adds the "mp" argument to nfsv4_lock() so that it
will return when the forced dismount flag is set.

While here, replace the nfsmsleep() wrapper that was used for portability
with the actual msleep() call.

(cherry picked from commit 82ee386c2afb42388804c1189751b83048953433)

3 years agohid: add opt_hid.h to modules that use HID_DEBUG
Vladimir Kondratyev [Wed, 3 Mar 2021 22:21:15 +0000 (01:21 +0300)]
hid: add opt_hid.h to modules that use HID_DEBUG

Submitted by: Greg V <greg_AT_unrelenting_DOT_technology>
Reviewed by: imp, wulf
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D28995

(cherry picked from commit 6241b57131a60bc2bd0eda41c145aa9659c2886b)

3 years agoig4: Add PCI IDs for Intel Gemini Lake I2C controller.
Vladimir Kondratyev [Tue, 23 Feb 2021 22:20:36 +0000 (01:20 +0300)]
ig4: Add PCI IDs for Intel Gemini Lake I2C controller.

Submitted by: Dmitry Luhtionov
MFC after: 2 weeks

(cherry picked from commit bbacb7ce72956a41c0daeefe875e5209d87c11ba)

3 years agoepoll: Store epoll_event udata member in ext member of kevent.
Vladimir Kondratyev [Sun, 7 Feb 2021 23:46:14 +0000 (02:46 +0300)]
epoll: Store epoll_event udata member in ext member of kevent.

Current epoll implementation stores udata fields of epoll_event
structure in special dynamically-sized table rather than in udata field
of backing kevent structure because of 2 reasons:
1. Kevent's udata size is smaller than epoll's on 32-bit archs.
2. Kevent's udata can be clobbered on execution EPOLL_CTL_ADD as kqueue
   modifies existing event while epoll returns error in this case.

After r320043 has introduced four new 64bit user data members (ext[]),
we can store epoll udata in one of them and drop aforementioned table.
According to kqueue_register() source code ext members are not updated
when existing kevent is modified that fixes p.2.

As a side effect the patch fixes PR/252582.

Reviewed by: trasz
MFC after: 1 month
Differential revision: https://reviews.freebsd.org/D28169

(cherry picked from commit b3c6fe663bb90240f8bda6b5ba9c6a761f09f078)

3 years agoRemove tmpfs size and properly format generated fstab for arm
Daniel Engerg [Wed, 17 Mar 2021 14:00:57 +0000 (15:00 +0100)]
Remove tmpfs size and properly format generated fstab for arm

Remove tmpfs size limitation, this breaks make installworld and installation of some packages
Format generated fstab using tabs to make it consistent and readable

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

(cherry picked from commit 5bffdafd6c5f2a8279a57172ab760ea66ed3d7d5)

3 years ago[PowerPC] Fix NUMA checking for powernv
Brandon Bergren [Sun, 28 Mar 2021 01:41:45 +0000 (20:41 -0500)]
[PowerPC] Fix NUMA checking for powernv

At this point in startup, vm_ndomains has not been initialized. Switch
to checking kenv instead.

Fixes incorrect NUMA information being set on multi-domain systems like
Talos II.

Submitted by: jhibbits

(cherry picked from commit bd94c8ab29c3162bbb43973ee77ce245fe157fef)

3 years ago[tcp] Fix ECN on finalizing sessions.
Richard Scheffenegger [Thu, 8 Apr 2021 12:50:34 +0000 (14:50 +0200)]
[tcp] Fix ECN on finalizing sessions.

A subtle oversight would subtly change new data packets
sent after a shutdown() or close() call, while the send
buffer is still draining.

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

(cherry picked from commit 9f2eeb02623d6a847a90da68a5892c25b14ce2d4)

3 years agostruct mount uppers: correct locking annotations
Konstantin Belousov [Thu, 8 Apr 2021 22:03:06 +0000 (01:03 +0300)]
struct mount uppers: correct locking annotations

(cherry picked from commit 5af1131de7fc18c795ed28e69d9393f78875d3e5)

3 years agoAdd sysctl debug.uma_reclaim
Konstantin Belousov [Sun, 4 Apr 2021 16:28:14 +0000 (19:28 +0300)]
Add sysctl debug.uma_reclaim

(cherry picked from commit 89619b747bcff379dca98e975a98865a45366417)

3 years ago[bc] Update to version 4.0.0
Stefan Eßer [Tue, 6 Apr 2021 08:44:52 +0000 (10:44 +0200)]
[bc] Update to version 4.0.0

This version fixes an issue (missing pop of top-of-stack value in the
"P" command of the dc program).

This issue did not affect the bc program, since it does not use dc as
an back-end to actually perform the calculations as was the case with
the traditional bc and dc programs.

The major number has been bumped due to Windows support that has been
added to this version. It does not correspond to a major change that
might affect FreeBSD.

(cherry picked from commit b55a927bc884d7780d65a508572023b0dc2dede9)

3 years agocache: temporarily drop the assert that dvp != vp when adding an entry
Mateusz Guzik [Sat, 27 Feb 2021 22:23:23 +0000 (22:23 +0000)]
cache: temporarily drop the assert that dvp != vp when adding an entry

Historically it was allowed for any names, but arguably should never be
even attempted. Allow it again since there is a release pending and
allowing it is bug-compatible with previous behavior.

Reported by: otis

(cherry picked from commit 1239a722214c245e642733fdea2b1348101598af)

3 years agoamd64: import asm strlen into libc
Mateusz Guzik [Sun, 21 Feb 2021 21:20:04 +0000 (21:20 +0000)]
amd64: import asm strlen into libc

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

(cherry picked from commit 7f06b217c53c3f5e4ac81eb11125adfb71359ac6)

3 years agoamd64: implement strlen in assembly, take 2
Mateusz Guzik [Sat, 10 Apr 2021 13:52:49 +0000 (13:52 +0000)]
amd64: implement strlen in assembly, take 2

Tested with glibc test suite.

The C variant in libkern performs excessive branching to find the zero
byte instead of using the bsfq instruction. The same code patched to use
it is still slower than the routine implemented here as the compiler
keeps neglecting to perform certain optimizations (like using leaq).

On top of that the routine can be used as a starting point for copyinstr
which operates on words intead of bytes.

The previous attempt had an instance of swapped operands to andq when
dealing with fully aligned case, which had a side effect of breaking the
code for certain corner cases. Noted by jrtc27.

Sample results:

$(perl -e "print 'A' x 3"):
stock:  211198039
patched:338626619
asm:    465609618

$(perl -e "print 'A' x 100"):
stock:   83151997
patched: 98285919
asm:    120719888

Reviewed by: jhb, kib
Differential Revision: https://reviews.freebsd.org/D28779

(cherry picked from commit 5fa12fe0cd203efcbb2ac21e7c3e3fb9b2f801ae)

3 years agoifconfig: fix UBSan signed shift error
Alex Richardson [Tue, 19 Jan 2021 11:35:21 +0000 (11:35 +0000)]
ifconfig: fix UBSan signed shift error

Use 1u since UBSan complains about 1 << 31.

(cherry picked from commit 94ac312a71683a3a1a928c6adfe927d6bb45044f)