]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agolibnetmap: add support for the offset features
Vincenzo Maffione [Mon, 29 Mar 2021 16:38:37 +0000 (16:38 +0000)]
libnetmap: add support for the offset features

The companion libnetmap changes for the "offsets" kernel support added
in a6d768d845c173823785c. This includes code to parse the "@offset=NNN"
option that can be appended to the port name by any nmport_* application.
Example:
   # pkt-gen -i 'netmap:em0@offset=16'

3 years agonetmap: monitor: add a flag to distinguish packet direction
Vincenzo Maffione [Mon, 29 Mar 2021 16:32:54 +0000 (16:32 +0000)]
netmap: monitor: add a flag to distinguish packet direction

The netmap monitor intercepts any TX/RX packets on the monitored
port. However, before this change there was no way to tell
whether an intercepted packet was being transmitted or received
on the monitored port.
A TXMON flag in the netmap slot has been added for this purpose.

3 years agonetmap: add kernel support for the "offsets" feature
Vincenzo Maffione [Mon, 29 Mar 2021 16:22:48 +0000 (18:22 +0200)]
netmap: add kernel support for the "offsets" feature

This feature enables applications to ask netmap to transmit or
receive packets starting at a user-specified offset from the
beginning of the netmap buffer. This is meant to ease those
packet manipulation operations such as pushing or popping packet
headers, that may be useful to implement software switches,
routers and other packet processors.
To use the feature, drivers (e.g., iflib, vtnet, etc.) must have
explicit support. This change does not add support for any driver,
but introduces the necessary kernel changes. However, offsets support
is already included for VALE ports and pipes.

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
MFC after: 3 weeks
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D29156

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
MFC after: 3 weeks
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D29155

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
MFC after: 3 weeks
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D29155

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
MFC after: 3 weeks
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D29155

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
MFC after: 3 weeks
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D29155

3 years agonetmap: iflib: add nm_config callback
you@x [Mon, 29 Mar 2021 09:26:12 +0000 (11:26 +0200)]
netmap: iflib: add nm_config callback

This per-driver callback is invoked by netmap when it wants
to align the number of TX/RX netmap rings and/or the number of
TX/RX netmap slots to the actual state configured in the hardware.
The alignment happens when netmap mode is switched on (with no
active netmap file descriptors for that netmap port), or when
collecting netmap port information.

MFC after: 1 week

3 years agosh(1): autocomplete commands
Piotr Pawel Stefaniak [Sun, 28 Mar 2021 09:58:20 +0000 (11:58 +0200)]
sh(1): autocomplete commands

Without this patch, sh can autocomplete file names but not commands from
$PATH. Use libedit's facility to execute custom function for autocomplete,
but yield to the library's standard autocomplete function when cursor is
not at position 0.

Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D29361

3 years agoReduce chance of RCU deadlock in the LinuxKPI by implementing the section
Hans Petter Selasky [Sun, 28 Mar 2021 07:36:48 +0000 (09:36 +0200)]
Reduce chance of RCU deadlock in the LinuxKPI by implementing the section
feature of the concurrency kit, CK.

Differential Revision: https://reviews.freebsd.org/D29467
Reviewed by: kib@ and markj@
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agolibedit: vendor import libedit 2021-03-28
Baptiste Daroussin [Mon, 29 Mar 2021 08:05:18 +0000 (10:05 +0200)]
libedit: vendor import libedit 2021-03-28

It contains changes pushed by pstef@ when working on improving the
completion for /bin/sh

3 years agolibedit: vendor import snapshot 2021-03-28
Baptiste Daroussin [Mon, 29 Mar 2021 08:01:41 +0000 (10:01 +0200)]
libedit: vendor import snapshot 2021-03-28

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

3 years agoFix panic when using BOOTP to resolve root path.
Brandon Bergren [Sun, 28 Mar 2021 00:18:51 +0000 (19:18 -0500)]
Fix panic when using BOOTP to resolve root path.

When loading a direct-boot kernel, a temporary route is being installed,
the NFS handle is acquired, and the temporary route is removed again.

This was being done inside a net epoch, but since the krpc code is written
using blocking APIs, we can't actually do that, because sleeping is not
allowed during a net epoch.

Exit and reenter the epoch so we are only in the epoch when doing the
routing table manipulation.

Fixes panic when booting my RB800 over NFS (where the kernel is loaded
using RouterBOOT directly.)

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

3 years agogvinum: add deprecation notice
Ed Maste [Fri, 26 Mar 2021 15:26:22 +0000 (11:26 -0400)]
gvinum: add deprecation notice

Vinum is a Logical Volume Manager that was introduced in FreeBSD 3.0,
and for FreeBSD 5 was ported to geom(4) as gvinum. gvinum has had no
specific development at least as far back as 2010, and has a number of
known bugs which are unlikely to be resolved.

Add a deprecation notice to raise awareness but state that vinum "may
not be" available in FreeBSD 14.  Either it will be removed and the
notice will be updated to "is not" available, or someone will step up
to fix issues and maintain it and we will remove the notice.

Reviewed by: imp (earlier version)
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29424

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

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

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

3 years agopkgbase: make only vital packages vital, not their sub-packages
Mina Igalic [Sun, 28 Mar 2021 10:16:45 +0000 (12:16 +0200)]
pkgbase: make only vital packages vital, not their sub-packages

make "vital" a replaceable, which defaults to "false" and only set it for
the main clib, utilities and runtime packages, not their sub-packages

PR: 254174
Differential Revision: https://reviews.freebsd.org/D29224

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
MFC after: 2 weeks

3 years agolibctf: Adjust logic to match upstream after 410556f1f
Mark Johnston [Sun, 28 Mar 2021 00:36:44 +0000 (20:36 -0400)]
libctf: Adjust logic to match upstream after 410556f1f

No functional change intended.

Suggested by: jrtc27
MFC after: 1 week

3 years agopowerpc: Fix powerpcspe WRT FPSCR
Justin Hibbits [Sun, 28 Mar 2021 00:24:59 +0000 (19:24 -0500)]
powerpc: Fix powerpcspe WRT FPSCR

Summary:
Since powerpcspe doesn't have a traditional FPU, there's no FPSCR, and
no FPRs.  Attempting to use them triggers an illegal instruction trap.
Fix this unconditional cleanup of FPSCR by conditionalizing it on the
FPU being used in the outgoing thread.

Reviewed By: bdragon
Differential Revision: https://reviews.freebsd.org/D29452

3 years agoichsmb: Add PCI IDs for Intel Comet Lake and Tiger Lake
Neel Chauhan [Sat, 27 Mar 2021 21:08:34 +0000 (14:08 -0700)]
ichsmb: Add PCI IDs for Intel Comet Lake and Tiger Lake

Reviewed by: manu
Differential Revision: https://reviews.freebsd.org/D27859
MFC after: 2 weeks

3 years agovm_fault: handle KERN_PROTECTION_FAILURE
Konstantin Belousov [Sat, 27 Mar 2021 11:08:52 +0000 (13:08 +0200)]
vm_fault: handle KERN_PROTECTION_FAILURE

pmap_enter(PMAP_ENTER_LARGEPAGE) may return KERN_PROTECTION_FAILURE due to
PKRU inconsistency.  Handle it in the call place from vm_fault_populate(),
and in places which decode errors from vm_fault_populate()/
vm_fault_allocate().

Reviewed by: jah, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D29442

3 years agolibctf: Fix an out-of-bounds read in ctf_lookup_by_name()
Domagoj Stolfa [Sat, 27 Mar 2021 18:04:12 +0000 (14:04 -0400)]
libctf: Fix an out-of-bounds read in ctf_lookup_by_name()

When prefixes such as struct, union, etc. are compared with the current
type (e.g. struct foo), a comparison is made with the prefix.  The code
currently assumes that every type is a valid C type with a prefix,
however at times, garbage ends up in this function causing an
unpredictable crash with DTrace due to the isspace(*p) call or
subsequent calls. An example that I've seen of this is the letter 's'
being passed in, comparing true with struct as the comparison size was
(q - p) == 1, but then we increment p with the length of "struct",
resulting in an out of bounds read.

Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29435

3 years agovfs: Add an assertion around name length limits
Mark Johnston [Sat, 27 Mar 2021 17:42:48 +0000 (13:42 -0400)]
vfs: Add an assertion around name length limits

Some filesystems assume that they can copy a name component, with length
bounded by NAME_MAX, into a dirent buffer of size MAXNAMLEN.  These
constants have the same value; add a compile-time assertion to that
effect.

Reported by: Alexey Kulaev <alex.qart@gmail.com>
Reviewed by: kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29431

3 years agorelease: amd64: Fix ISO/USB hybrid image
Emmanuel Vadot [Sat, 27 Mar 2021 11:04:51 +0000 (12:04 +0100)]
release: amd64: Fix ISO/USB hybrid image

Recent mkimg changes forces to have partitions given in explicit order.
This is so we can have the first partition starting at a specific offset
and the next ones starting after without having to specify an offset.
Switch the partition in the mkisoimage.sh script so the first one created
is the isoboot one.

PR:    254490
Reported by: Michael Dexter <editor@callfortesting.org
Tested by: Vincent Milum Jr <freebsd@darkain.com>
MFC after: Right now

3 years agolibedit: vendor import snapshot 20200710
Baptiste Daroussin [Mon, 22 Mar 2021 14:29:33 +0000 (15:29 +0100)]
libedit: vendor import snapshot 20200710

3 years agoZero `struct weightened_nhop` fields in nhgrp_get_addition_group().
Alexander V. Chernikov [Sat, 20 Mar 2021 08:26:03 +0000 (08:26 +0000)]
Zero `struct weightened_nhop` fields in nhgrp_get_addition_group().

`struct weightened_nhop` has spare 32bit between the fields due to
 the alignment (on amd64).
Not zeroing these spare bits results in duplicating nhop groups
 in the kernel due to the way how comparison works.

MFC after: 1 day

3 years agozfs: Cherry-pick upstream commit ef977fce6636 to fix macOS/arm64 bootstrap
Jessica Clarke [Sat, 27 Mar 2021 02:23:59 +0000 (02:23 +0000)]
zfs: Cherry-pick upstream commit ef977fce6636 to fix macOS/arm64 bootstrap

Upstream commit message:

  Support running FreeBSD buildworld on Arm-based macOS hosts

  Arm-based Macs are like FreeBSD and provide a full 64-bit stat from the
  start, so have no stat64 variants. Thus, define stat64 and fstat64 as
  aliases for the normal versions.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com>
  Closes #11771

MFC after: 1 week

3 years agocxgbe: Make the TOE TLS stats per-queue instead of per-port.
John Baldwin [Fri, 26 Mar 2021 22:05:44 +0000 (15:05 -0700)]
cxgbe: Make the TOE TLS stats per-queue instead of per-port.

This avoids some atomics by using counter_u64 for TX and relying on
existing single-threading (single ithread per rxq) for RX.

Reviewed by: np
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D29383

3 years agocxgbe: Add a struct sge_ofld_txq type.
John Baldwin [Fri, 26 Mar 2021 22:05:31 +0000 (15:05 -0700)]
cxgbe: Add a struct sge_ofld_txq type.

This type mirrors struct sge_ofld_rxq and holds state for TCP offload
transmit queues.  Currently it only holds a work queue but will
include additional state in future changes.

Reviewed by: np
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D29382

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

This change serves two purposes.

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

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

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

3 years agosecurity.7: fix typo in sysctl name
Piotr Pawel Stefaniak [Fri, 26 Mar 2021 21:24:06 +0000 (22:24 +0100)]
security.7: fix typo in sysctl name

It is machdep.syscall_ret_flush_l1d.

3 years agoRemove more terminfo entries after 16d3faad099a
Dimitry Andric [Sat, 20 Mar 2021 22:07:23 +0000 (23:07 +0100)]
Remove more terminfo entries after 16d3faad099a

Otherwise, several directories under /usr/share/terminfo will not be
cleaned up.

Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D29355

3 years agobsdinstall: Drop vestigial bsdinstall-esps cleanup
Ryan Moeller [Fri, 26 Mar 2021 18:12:18 +0000 (14:12 -0400)]
bsdinstall: Drop vestigial bsdinstall-esps cleanup

This is not needed after 0b7472b3d8d2f1e90fade5236b44fd98d8e396c2.

MFC after: 3 days
Sponsored by: iXsystems, Inc.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D29325

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

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

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

3 years agocxgbe: remove unused linux headers
Bjoern A. Zeeb [Fri, 26 Mar 2021 16:10:25 +0000 (16:10 +0000)]
cxgbe: remove unused linux headers

Remove unused #includes of LinuxKPI headers noticed while trying to
solve LinuxKPI struct net_device and related functions.
Neither netdevice.h nor inetdevice.h nor notifier.h seem to be needed.
This takes cxgbe(4) out of the picture of D29366.

Sponsored-by: The FreeBSD Foundation
MFC-after: 2 weeks
Reviewed-by: np
X-D-R: D29366 (extracted as further cleanup)
Differential Revision: https://reviews.freebsd.org/D29432

3 years agoqlnxr: remove netdevice.h
Bjoern A. Zeeb [Fri, 26 Mar 2021 17:17:10 +0000 (17:17 +0000)]
qlnxr: remove netdevice.h

Remove unused #includes of a LinuxKPI header noticed while trying to
solve LinuxKPI struct net_device and related functions.
This takes qlnxr out of the picture of D29366.

Sponsored-by: The FreeBSD Foundation
MFC-after: 2 weeks
X-D-R: D29366 (extracted as further cleanup)

3 years agoobsoletefiles: also remove the terminfo directory along with the db
Baptiste Daroussin [Fri, 26 Mar 2021 16:58:06 +0000 (17:58 +0100)]
obsoletefiles: also remove the terminfo directory along with the db

3 years agomlx4: remove no longer needed header
Bjoern A. Zeeb [Fri, 26 Mar 2021 15:28:24 +0000 (15:28 +0000)]
mlx4: remove no longer needed header

Remove linux/inetdevice.h as neither of the two inline functions there
are used here.

Sposored-by: The FreeBSD Foundation
MFC-after: 2 weeks
Reviewed-by: hselasky
X-D-R: D29366 (extracted as further cleanup)
Differential Revision: https://reviews.freebsd.org/D29428

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

3 years agoce: unifdef NPCI also
Ed Maste [Thu, 25 Mar 2021 23:39:49 +0000 (19:39 -0400)]
ce: unifdef NPCI also

After f9839a42ee5d NPCI is always 1.

Reported by: imp

3 years agoLinuxKPI: netdevice notifier callback argument
Bjoern A. Zeeb [Sun, 21 Mar 2021 21:18:34 +0000 (21:18 +0000)]
LinuxKPI: netdevice notifier callback argument

Introduce struct netdev_notifier_info as a container to pass
net_device to the callback functions.
Adjust netdev_notifier_info_to_dev() to return the net_device field.

Add explicit casts from ifp to ni->dev even though currently
struct net_device is defined to struct ifnet.  This is needed in
preparation for untangling this and improving the net_device compat
code.

Obtained-from: bz_iwlwifi
Sponsored-by: The FreeBSD Foundation
MFC-after: 2 weeks
Reviewed-by: hselasky
Differential Revision: https://reviews.freebsd.org/D29365

3 years agoLinuxKPI: add net_ratelimit()
Bjoern A. Zeeb [Tue, 23 Mar 2021 17:00:22 +0000 (17:00 +0000)]
LinuxKPI: add net_ratelimit()

Add a net_ratelimit() compat implementation based on ppsratecheck().
Add a sysctl to allow tuning of the number of messages.

Sponsored-by: The FreeBSD Foundation
MFC-after: 2 weeks
Reviewed-by: hselasky
Differential Revision: https://reviews.freebsd.org/D29399

3 years agopci: enhance printf for leaked MSI[-X] vectors
Bjoern A. Zeeb [Tue, 23 Mar 2021 15:47:24 +0000 (15:47 +0000)]
pci: enhance printf for leaked MSI[-X] vectors

When debugging leaked MSI/MSI-X vectors through LinuxKPI I found
the informational printf unhelpful.  Rather than just stating we
leaked also tell how many MSI or MSI-X vectors we leak.

Sponsored-by: The FreeBSD Foundation
Reviewed-by: jhb
MFC-after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D29394

3 years ago[iwn] Flip over to use VAP flags rather than ic flags for things
Adrian Chadd [Mon, 22 Mar 2021 16:47:43 +0000 (09:47 -0700)]
[iwn] Flip over to use VAP flags rather than ic flags for things

net80211 changed a while back to support per-VAP config for things
rather than it being global.  This is to support firmware NICs that
support per-VAP flags and configuration where the firmware will figure
out how to combine them.

However, it introduced a fun timing issue - those changes used to happen
to the shared ic state before newstate() was called, but now they're
also tasks and they can happen /after/.

This isn't a problem for ath(4), but it exposed some interesting
timing and config bugs here.  Notably, I saw short slot NOT being
configured in 5GHz mode during some associations, so 5GHz stuff
would hang or behave poorly.  Other times the follow-up auth has
the right config, so it didn't hang.

So for now, just flip this over to using the per-VAP flags which
are correct when newstate() is called.  net80211 should also have
those flags synch'ed to the global ic state before newstate() runs
and that can come in a subsequent commit.

Whilst here also fix plcp to be consistently logged as a hex value.

Tested:

* iwn(4) Intel 6205, STA mode, both 2GHz and 5GHz

Differential Revision: https://reviews.freebsd.org/D29379
Reviewed by: bz

3 years agotcp: Use PRR for ECN congestion recovery
Richard Scheffenegger [Fri, 26 Mar 2021 01:05:22 +0000 (02:05 +0100)]
tcp: Use PRR for ECN congestion recovery

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

3 years agotcp: Refactor PRR code
Richard Scheffenegger [Thu, 25 Mar 2021 22:58:46 +0000 (23:58 +0100)]
tcp: Refactor PRR code

No functional change intended.

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

3 years agotcp: Perform simple fast retransmit when SACK Blocks are missing on SACK session
Richard Scheffenegger [Thu, 25 Mar 2021 22:18:06 +0000 (23:18 +0100)]
tcp: Perform simple fast retransmit when SACK Blocks are missing on SACK session

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

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

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

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

3 years agocxgbe(4): Allow a T6 adapter to switch between TOE and NIC TLS mode.
Navdeep Parhar [Wed, 24 Mar 2021 01:01:01 +0000 (18:01 -0700)]
cxgbe(4): Allow a T6 adapter to switch between TOE and NIC TLS mode.

The hw.cxgbe.kern_tls tunable was used for this in the past and if it
was set then all T6 adapters would be configured for NIC TLS operation
and could not be reconfigured for TOE without a reload.  With this
change ifconfig can be used to manipulate toe and txtls caps like any
other caps.  hw.cxgbe.kern_tls continues to work as usual but its
effects are not permanent any more.

* Enable nic_ktls_ofld in the default configuration file and use the
  firmware instead of direct register manipulation to apply/rollback
  NIC TLS configuration.  This allows the driver to switch the hardware
  between TOE and NIC TLS mode in a safe manner.  Note that the
  configuration is adapter-wide and not per-port.

* Remove the kern_tls config file as it works with 100G T6 cards only
  and leads to firmware crashes with 25G cards.  The configurations
  included with the driver (with the exception of the FPGA configs) are
  supposed to work with all adapters.

Reported by: Veeresh U.K. at Chelsio
MFC after: 2 weeks
Sponsored by: Chelsio Communications
Reviewed by: jhb@
Differential Revision: https://reviews.freebsd.org/D29291

3 years agopf: remove obsolete reference to ndis(4) in a comment
Ed Maste [Thu, 25 Mar 2021 18:43:55 +0000 (14:43 -0400)]
pf: remove obsolete reference to ndis(4) in a comment

3 years agondis: remove leftover sys/modules/ndis
Ed Maste [Thu, 25 Mar 2021 18:30:11 +0000 (14:30 -0400)]
ndis: remove leftover sys/modules/ndis

Reported by: cognet
Fixes: bfc99943b04b ("ndis(4): remove as previous announced")

3 years agoce: remove long-obsolete FreeBSD version compatibility
Ed Maste [Thu, 25 Mar 2021 02:48:50 +0000 (22:48 -0400)]
ce: remove long-obsolete FreeBSD version compatibility

Mechanical change via unifdef.

3 years ago[PowerPC64] Clear low-order bits of ARPN
Leandro Lupori [Thu, 25 Mar 2021 16:30:56 +0000 (13:30 -0300)]
[PowerPC64] Clear low-order bits of ARPN

PowerISA 2.07B says that the low-order p-12 bits of the real page number
contained in ARPN and LP fields of a PTE must be 0s and are ignored
by the hardware (Book III-S, 5.7.7.1), where 2^p is the actual page size
in bytes, but we were clearing only the LP field.

This worked on bare metal and QEMU with KVM, that ignore these bits,
but caused a kernel panic on QEMU with TCG, that expects them to be
cleared.

This fixes running FreeBSD with HPT superpages enabled on QEMU
with TCG.

MFC after: 2 weeks
Sponsored by: Eldorado Research Institute (eldorado.org.br)

3 years ago[PowerPC64] Port optimized strcpy to PPC64LE
Leandro Lupori [Thu, 25 Mar 2021 16:14:00 +0000 (13:14 -0300)]
[PowerPC64] Port optimized strcpy to PPC64LE

Submitted by:           Bruno Larsen <bruno.larsen@eldorado.org.br>
Reviewed by:            luporl, bdragon (IRC)
MFC after:              1 week
Sponsored by:           Eldorado Research Institute (eldorado.org.br)
Differential Revision:  https://reviews.freebsd.org/D29067

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

3 years ago[PowerPC64] Enforce natural alignment in bcopy
Leandro Lupori [Thu, 25 Mar 2021 14:54:06 +0000 (11:54 -0300)]
[PowerPC64] Enforce natural alignment in bcopy

POWER architecture CPUs (Book-S) require natural alignment for
cache-inhibited storage accesses. Since we can't know the caching model
for a page ahead of time, always enforce natural alignment in bcopy.
This fixes a SIGBUS when calling the function with misaligned pointers
on POWER7.

Submitted by: Bruno Larsen <bruno.larsen@eldorado.org.br>
Reviewed by: luporl, bdragon (IRC)
MFC after: 1 week
Sponsored by: Eldorado Research Institute (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D28776

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

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

This causes a memory overwrite situation when IPOIB_CM is configured.

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

PR: 254474
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

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

Suggested by: Shichun_Ma@Dell.com
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

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

Merge commit '94fa08a4bcdfbb3434b025d67d014af3b18e5380'

3 years agoImport OpenSSL 1.1.1k.
Jung-uk Kim [Thu, 25 Mar 2021 15:05:31 +0000 (11:05 -0400)]
Import OpenSSL 1.1.1k.

3 years agompsutil.8: fix typos in the man page
Alan Somers [Thu, 25 Mar 2021 14:43:40 +0000 (08:43 -0600)]
mpsutil.8: fix typos in the man page

MFC after: 2 weeks
Sponsored by: Axcient

3 years agolib/libc/net/nsdispatch.c: Fix missing unlock and add locking annotations
Alex Richardson [Thu, 25 Mar 2021 11:22:10 +0000 (11:22 +0000)]
lib/libc/net/nsdispatch.c: Fix missing unlock and add locking annotations

The error cases (goto fin) of _nsdispatch were missing the unlock.

This change also drops the checks for __isthreaded since the pthread stubs
are already no-ops if threads are not being used. Dropping those conditionals
allows clang's thread safety analysis to deal with the file and also makes
the code a bit more readable. While touching the file also add a few more
assertions in debug mode that the right locks are held.

Reviewed By: markj
Differential Revision: https://reviews.freebsd.org/D29372

3 years agogit-arc.sh: Make it compatible with Ubuntu 18.04
Alex Richardson [Thu, 25 Mar 2021 11:17:56 +0000 (11:17 +0000)]
git-arc.sh: Make it compatible with Ubuntu 18.04

dash does not allow function names containing a ":", so replace it with
a '_'. Additionally, Ubunutu 18.04 ships git 2.17 which does not support
the `--default false` flag for git config.

Reviewed By: markj
Differential Revision: https://reviews.freebsd.org/D29374

3 years agoFix most shellcheck warnings in git-arc.sh
Alex Richardson [Thu, 25 Mar 2021 11:17:30 +0000 (11:17 +0000)]
Fix most shellcheck warnings in git-arc.sh

Mostly adding quotes and replacing egrep/fgrep with grep -E/grep -F

Reviewed By: markj
Differential Revision: https://reviews.freebsd.org/D29373

3 years agoRISC-V: Fix feenableexcept return value
Alex Richardson [Thu, 25 Mar 2021 11:15:41 +0000 (11:15 +0000)]
RISC-V: Fix feenableexcept return value

The man page says "The feenableexcept(), fedisableexcept(), and
fegetexcept() functions return a bitmap of the exceptions that were
unmasked prior to the call.", so we should return zero not -1.

Reviewed By: mhorne
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D29386

3 years agong_macfilter_test: Skip rather than fail if there is no network
Alex Richardson [Thu, 25 Mar 2021 11:14:46 +0000 (11:14 +0000)]
ng_macfilter_test: Skip rather than fail if there is no network

This should bring the number of Jenkins failures from 4 down to 3.
Locally kyua now prints `skipped: could not find a valid interface  [0.115s]`
when I run it in QEMU without a network device.

Reviewed By: lwhsu
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D29414

3 years agotruss: improved support for decoding compat32 arguments
Alex Richardson [Thu, 25 Mar 2021 11:12:17 +0000 (11:12 +0000)]
truss: improved support for decoding compat32 arguments

Currently running `truss -a -e` does not decode any
argument values for freebsd32_* syscalls (open/readlink/etc.)

This change checks whether a syscall starts with freebsd{32,64}_ and if
so strips that prefix when looking up the syscall information. To ensure
that the truss logs include the real syscall name we create a copy of
the syscall information struct with the updated.

The other problem is that when reading string array values, truss
naively iterates over an array of char* and fetches the pointer value.
This will result in arguments not being loaded if the pointer is not
aligned to sizeof(void*), which can happens in the compat32 case. If it
happens to be aligned, we would end up printing every other value.
To fix this problem, this changes adds a pointer_size member to the
procabi struct and uses that to correctly read indirect arguments
as 64/32 bit addresses in the the compat32 case (and also compat64 on
CheriBSD).

The motivating use-case for this change is using truss for 64-bit
programs on a CHERI system, but most of the diff also applies to 32-bit
compat on a 64-bit system, so I'm upstreaming this instead of keeping it
as a local CheriBSD patch.

Output of `truss -aef ldd32 /usr/bin/ldd32` before:
39113: freebsd32_mmap(0x0,0x1000,0x3,0x1002,0xffffffff,0x0,0x0) = 543440896 (0x20644000)
39113: freebsd32_ioctl(0x1,0x402c7413,0xffffd2a0) = 0 (0x0)
/usr/bin/ldd32:
39113: write(1,"/usr/bin/ldd32:\n",16)  = 16 (0x10)
39113: fork()  = 39114 (0x98ca)
39114: <new process>
39114: freebsd32_execve(0xffffd97e,0xffffd680,0x20634000) EJUSTRETURN
39114: freebsd32_mmap(0x0,0x20000,0x3,0x1002,0xffffffff,0x0,0x0) = 541237248 (0x2042a000)
39114: freebsd32_mprotect(0x20427000,0x1000,0x1) = 0 (0x0)
39114: issetugid()  = 0 (0x0)
39114: openat(AT_FDCWD,"/etc/libmap32.conf",O_RDONLY|O_CLOEXEC,00) ERR#2 'No such file or directory'
39114: openat(AT_FDCWD,"/var/run/ld-elf32.so.hints",O_RDONLY|O_CLOEXEC,00) = 3 (0x3)
39114: read(3,"Ehnt\^A\0\0\0\M^@\0\0\0#\0\0\0\0"...,128) = 128 (0x80)
39114: freebsd32_fstat(0x3,0xffffbd98)  = 0 (0x0)
39114: freebsd32_pread(0x3,0x2042f000,0x23,0x80,0x0) = 35 (0x23)
39114: close(3)  = 0 (0x0)
39114: openat(AT_FDCWD,"/usr/lib32/libc.so.7",O_RDONLY|O_CLOEXEC|O_VERIFY,00) = 3 (0x3)
39114: freebsd32_fstat(0x3,0xffffc7d0)  = 0 (0x0)
39114: freebsd32_mmap(0x0,0x1000,0x1,0x40002,0x3,0x0,0x0) = 541368320 (0x2044a000)

After:
  783: freebsd32_mmap(0x0,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0) = 543543296 (0x2065d000)
  783: freebsd32_ioctl(1,TIOCGETA,0xffffd7b0)    = 0 (0x0)
/usr/bin/ldd32:
  783: write(1,"/usr/bin/ldd32:\n",16)           = 16 (0x10)
  784: <new process>
  783: fork()                                    = 784 (0x310)
  784: freebsd32_execve("/usr/bin/ldd32",[ "(null)" ],[ "LD_32_TRACE_LOADED_OBJECTS_PROGNAME=/usr/bin/ldd32", "LD_TRACE_LOADED_OBJECTS_PROGNAME=/usr/bin/ldd32", "LD_32_TRACE_LOADED_OBJECTS=yes", "LD_TRACE_LOADED_OBJECTS=yes", "USER=root", "LOGNAME=root", "HOME=/root", "SHELL=/bin/csh", "BLOCKSIZE=K", "MAIL=/var/mail/root", "MM_CHARSET=UTF-8", "LANG=C.UTF-8", "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin", "TERM=vt100", "HOSTTYPE=FreeBSD", "VENDOR=amd", "OSTYPE=FreeBSD", "MACHTYPE=x86_64", "SHLVL=1", "PWD=/root", "GROUP=wheel", "HOST=freebsd-amd64", "EDITOR=vi", "PAGER=less" ]) EJUSTRETURN
  784: freebsd32_mmap(0x0,135168,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 541212672 (0x20424000)
  784: freebsd32_mprotect(0x20421000,4096,PROT_READ) = 0 (0x0)
  784: issetugid()                               = 0 (0x0)
  784: sigfastblock(0x1,0x204234fc)              = 0 (0x0)
  784: open("/etc/libmap32.conf",O_RDONLY|O_CLOEXEC,00) ERR#2 'No such file or directory'
  784: open("/var/run/ld-elf32.so.hints",O_RDONLY|O_CLOEXEC,00) = 3 (0x3)
  784: read(3,"Ehnt\^A\0\0\0\M^@\0\0\0\v\0\0\0"...,128) = 128 (0x80)
  784: freebsd32_fstat(3,{ mode=-r--r--r-- ,inode=18680,size=32768,blksize=0 }) = 0 (0x0)
  784: freebsd32_pread(3,"/usr/lib32\0",11,0x80) = 11 (0xb)

Reviewed By: jhb
Differential Revision: https://reviews.freebsd.org/D27625

3 years agobuild.7: Use proper .Dd date from this year
Warner Losh [Thu, 25 Mar 2021 07:48:12 +0000 (01:48 -0600)]
build.7: Use proper .Dd date from this year

3 years agobuild.7: Document SYSDIR variable
Warner Losh [Thu, 25 Mar 2021 07:45:21 +0000 (01:45 -0600)]
build.7: Document SYSDIR variable

Add a description of the SYSDIR variable.

3 years agoFix !VNET build broken by 66f138563becf12d5c21924f816d2a45c3a1ed7a.
Alexander V. Chernikov [Thu, 25 Mar 2021 00:30:41 +0000 (00:30 +0000)]
Fix !VNET build broken by 66f138563becf12d5c21924f816d2a45c3a1ed7a.

3 years agoFix fsck_ffs -R finds unfixed duplicate block errors when rerunning.
Kirk McKusick [Thu, 25 Mar 2021 00:23:33 +0000 (17:23 -0700)]
Fix fsck_ffs -R finds unfixed duplicate block errors when rerunning.

This fixes a long-standing but very obscure bug in fsck_ffs when
it is run with the -R (rerun after unexpected errors).  It only
occurs if fsck_ffs finds duplicate blocks and they are all contained
in inodes that reside in the first block of inodes (typically among
the first 128 inodes).

Rather than use the usual ginode() interface to walk through the
inodes in pass1, there is a special optimized `getnextinode()'
routine for walking through all the inodes. It has its own private
buffer for reading the inode blocks. If pass 1 finds duplicate
blocks it runs pass 1b to find all the inodes that contain these
duplicate blocks. Pass 1b also uses the `getnextinode()' to search
for the inodes with duplicate blocks. Pass 1b stops when all the
duplicate blocks have been found. If all the duplicate blocks are
found in the first block of inodes, then the getnextinode cache
holds this block of bad inodes. The subsequent cleanup of the inodes
in passes 2-5 is done using ginode() which uses the regular fsck_ffs
cache.

When fsck_ffs restarts, pass1() calls setinodebuf() to point at the
first block of inodes. When it calls getnextinode() to get inode
2, getnextino() sees that its private cache already has the first
set of inodes loaded and starts using them. They are of course the
trashed inodes left over from the previous run of pass1b().

The fix is to always invalidate the getnextinode cache when calling
setinodebuf().

Reported by:  Chuck Silvers
Tested by:    Chuck Silvers
MFC after:    3 days
Sponsored by: Netflix

3 years agoPlug nexthop group refcount leak.
Alexander V. Chernikov [Wed, 24 Mar 2021 23:51:45 +0000 (23:51 +0000)]
Plug nexthop group refcount leak.
In case with batch route delete via rib_walk_del(), when
 some paths from the multipath route gets deleted, old
 multipath group were not freed.

PR:    254496
Reported by:   Zhenlei Huang <zlei.huang@gmail.com>
MFC after:     1 day

3 years agortld: fix the man page
Mariusz Zaborski [Wed, 24 Mar 2021 23:49:59 +0000 (00:49 +0100)]
rtld: fix the man page

In f90218886fc8 in man page I used LD_PRELOAD_PATH_FDS instead of
LD_PRELOAD_FDS.

Reported by: rpokala

3 years agoFix fsck_ffs Pass 1b error exit "bad inode number 2 to nextinode".
Kirk McKusick [Wed, 24 Mar 2021 23:50:24 +0000 (16:50 -0700)]
Fix fsck_ffs Pass 1b error exit "bad inode number 2 to nextinode".

Pass 1b of fsck_ffs runs only when Pass 1 has found duplicate blocks.
When starting up, Pass 1b failed to properly skip over the two unused
inodes at the beginning of the filesystem resulting in the above error
message when it tried to read the filesystem root inode.

Reported by:  Chuck Silvers
Tested by:    Chuck Silvers
MFC after:    3 days
Sponsored by: Netflix

3 years agoGeneralize sanitizer interceptors for memory and string routines
Mark Johnston [Wed, 24 Mar 2021 23:43:05 +0000 (19:43 -0400)]
Generalize sanitizer interceptors for memory and string routines

Similar to commit 3ead60236f ("Generalize bus_space(9) and atomic(9)
sanitizer interceptors"), use a more generic scheme for interposing
sanitizer implementations of routines like memcpy().

No functional change intended.

MFC after: 1 month
Sponsored by: The FreeBSD Foundation

3 years agoqlnxr: remove duplicate defines
Bjoern A. Zeeb [Tue, 23 Mar 2021 14:31:37 +0000 (14:31 +0000)]
qlnxr: remove duplicate defines

upper_32_bits() and lower_32_bits() are defined twice in this file.
With the extra conditinal removed on LinuxKPI in 3b1ecc9fa1b5
they are also included from there already.  Use the LinuxKPI version
and remove the two local ones.

Sponsored-by: The FreeBSD Foundation
Reviewed-by: hselasky
MFC-after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D29392

3 years agoLinuxKPI: remove < 5.0 version support
Bjoern A. Zeeb [Tue, 23 Mar 2021 14:24:49 +0000 (14:24 +0000)]
LinuxKPI: remove < 5.0 version support

We are not aware of any out-of-tree consumers anymore
which would need KPI support for before Linux version 5.
Update the two in-tree consumers to use the new KPI.
This allows us to remove the extra version check and
will also give access to {lower,upper}_32_bits() unconditionally.

Sponsored-by: The FreeBSD Foundation
Reviewed-by: hselasky, rlibby, rstone
MFC-after: 2 weeks
X-MFC: to 13 only
Differential Revision: https://reviews.freebsd.org/D29391

3 years agoLinuxKPI: add lockdep_map
Bjoern A. Zeeb [Tue, 23 Mar 2021 16:51:08 +0000 (16:51 +0000)]
LinuxKPI: add lockdep_map

Add stubs for struct lockdep_map and three accessor functions
used by iwlwifi.

Obtained-from: bz_iwlwifi
Sponsored-by: The FreeBSD Foundation
MFC-after: 2 weeks
Reviewed-by: hselasky, emaste
Differential Revision: https://reviews.freebsd.org/D29398

3 years agoLinuxKPI: add pci_ids.h
Bjoern A. Zeeb [Tue, 23 Mar 2021 17:13:15 +0000 (17:13 +0000)]
LinuxKPI: add pci_ids.h

brcm80211 include pci_ids.h directly while historically we were tracking
IDs in pci.h.  Move the current set of IDs from pci.h to pci_ids.h and
while here add IDs for Realtek and Broadcom as well as a network class
as needed by their wireless drivers.

We still include pci_ids.h from pci.h so this should not change anything.

MFC-after: 2 weeks
Reviewed-by: hselasky
Differential Revision: https://reviews.freebsd.org/D29400

3 years agoLinuxKPI: if_ether additions
Bjoern A. Zeeb [Tue, 23 Mar 2021 16:44:56 +0000 (16:44 +0000)]
LinuxKPI: if_ether additions

Add various protocol IDs found in various wireless drivers.
Also add ETH_FRAME_LEN and struct ethhdr.

Obtained-from: bz_iwlwifi
Sponsored-by: The FreeBSD Foundation
MFC-after: 2 weeks
Reviewed-by: hselasky
Differential Revision: https://reviews.freebsd.org/D29397

3 years agoLinuxKPI: add more linux-specific errno
Bjoern A. Zeeb [Tue, 23 Mar 2021 16:37:35 +0000 (16:37 +0000)]
LinuxKPI: add more linux-specific errno

Add ERFKILL and EBADE found in iwlwifi and brcmfmac wireless drivers.
While here add a comment above the block of error numbers above 500 to
document expectations.

Obtained-from: bz_iwlwifi
Sponsored-by: The FreeBSD Foundation
MFC-after: 2 weeks
Reviewed-by: hselasky, emaste
Differential Revision: https://reviews.freebsd.org/D29396

3 years agortld: introduce PRELOAD_FDS
Mariusz Zaborski [Wed, 24 Mar 2021 21:10:33 +0000 (22:10 +0100)]
rtld: introduce PRELOAD_FDS

The new PRELOAD_FDS variable accepts a list of file descriptors
that should be loaded into the process.

This may be used to optimize a loading process - in the case when
we already have a file descriptor to the library; we don't have
to look into multiple PATH to find it.

It may also be used in capability mode to load a single additional
library without the need to open a directory that contains it.

The last use of this functionality t may be a race-free method
of loading libraries.

Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D29334

3 years agortld: style nits
Mariusz Zaborski [Wed, 24 Mar 2021 21:05:39 +0000 (22:05 +0100)]
rtld: style nits

No functional change intended.

Requested by: kib

3 years agoifconfig: 80211, add line break after key info
Bjoern A. Zeeb [Tue, 23 Mar 2021 15:08:46 +0000 (15:08 +0000)]
ifconfig: 80211, add line break after key info

Beauty correction for verbose mode or in case we print multiple key
information to not continue with the next options directly after
as we did so far, e.g.:
AES-CCM 2:128-bit
AES-CCM 3:128-bit powersavemode ...

Sponsored-by: The FreeBSD Foundation
MFC-after: 2 weeks
Reviewed-by: adrian
Differential Revision: https://reviews.freebsd.org/D29393

3 years agoofed/linuxkpi: use proper accessor function
Bjoern A. Zeeb [Sun, 21 Mar 2021 21:07:45 +0000 (21:07 +0000)]
ofed/linuxkpi: use proper accessor function

In the notifier event callback function rather than casting directly
to the expected type use the proper accessor function as the mlx drivers
already do.
This is preparational work to allow us to improve the struct net_device
is struct ifnet compat code shortcut in the future.

Obtained-from: bz_iwlwifi
Sponsored-by: The FreeBSD Foundation
MFC-after: 2 weeks
Reviewed-by: hselasky
Differential Revision: https://reviews.freebsd.org/D29364

3 years agolinuxkpi: add ieee80211_node.h to headers to include before LIST_HEAD
Bjoern A. Zeeb [Thu, 18 Mar 2021 22:23:15 +0000 (22:23 +0000)]
linuxkpi: add ieee80211_node.h to headers to include before LIST_HEAD

ieee80211_node.h uses LIST_HEAD() which LinuxKPI redefines and this
can lead to problems (see comment there).  Make sure the net80211
header file is handled correctly by adding it to the list of files
to include before re-defining the macro.
Also add header files needed as dependencies.

Sponsored-by: The FreeBSD Foundation
MFC-after: 2 weeks
Reviewed-by: philip, hselasky
Differential Revision: https://reviews.freebsd.org/D29336

3 years agonet80211: prefix get_random_bytes() with net80211_
Bjoern A. Zeeb [Thu, 18 Mar 2021 22:15:00 +0000 (22:15 +0000)]
net80211: prefix get_random_bytes() with net80211_

Both linux/random.h and net80211 have a function named
get_random_bytes().  With overlapping files included these collide.
Arguably the function could be renamed in linuxkpi but the generic
name should also not be used in net80211 so rename it there.

Sponsored-by: The FreeBSD Foundation
MFC-after: 2 weeks
Reviewed-by: philip, adrian
Differential Revision: https://reviews.freebsd.org/D29335

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

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

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

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

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

3 years agobhyve hostbridge: Rename "device" property to "devid".
John Baldwin [Wed, 24 Mar 2021 16:29:15 +0000 (09:29 -0700)]
bhyve hostbridge: Rename "device" property to "devid".

"device" is already used as the generic PCI-level name of the device
model to use (e.g. "hostbridge").  The result was that parsing
"hostbridge" as an integer failed and the host bridge used a device ID
of 0.  The EFI ROM asserts that the device ID of the hostbridge is not
0, so booting with the current EFI ROM was failing during the ROM
boot.

Fixes: 621b5090487de9fed1b503769702a9a2a27cc7bb

3 years agoGet rid of i386 ref here as linux64 is a 64-bit module.
Dmitry Chagin [Wed, 24 Mar 2021 15:56:46 +0000 (18:56 +0300)]
Get rid of i386 ref here as linux64 is a 64-bit module.

Reviewed By: emaste, imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29412

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

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

3 years agoipfilter: simplify ipf_proxy_check() return codes
Cy Schubert [Tue, 23 Mar 2021 03:11:58 +0000 (20:11 -0700)]
ipfilter: simplify ipf_proxy_check() return codes

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

MFC after: 1 week

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

Reviewed By: jhb, imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29381

3 years agorandom(9): Restore historical [0,2^31-1] output range and related man
Lawrence Stewart [Wed, 24 Mar 2021 04:25:49 +0000 (15:25 +1100)]
random(9): Restore historical [0,2^31-1] output range and related man
documention.

Commit SVN r364219 / Git 8a0edc914ffd changed random(9) to be a shim around
prng32(9) and inadvertently caused random(9) to begin returning numbers in the
range [0,2^32-1] instead of [0,2^31-1], where the latter has been the documented
range for decades.

The increased output range has been identified as the source of numerous bugs in
code written against the historical output range e.g. ipfw "prob" rules and
stats(3) are known to be affected, and a non-exhaustive audit of the tree
identified other random(9) consumers which are also likely affected.

As random(9) is deprecated and slated for eventual removal in 14.0, consumers
should gradually be audited and migrated to prng(9).

Submitted by: Loic Prylli <lprylli@netflix.com>
Obtained from: Netflix
Reviewed by: cem, delphij, imp
MFC after: 1 day
MFC to: stable/13, releng/13.0
Differential Revision: https://reviews.freebsd.org/D29385

3 years agolibevent1: fix layout of duplicated RB_ENTRY() definition
Kyle Evans [Wed, 24 Mar 2021 04:31:02 +0000 (23:31 -0500)]
libevent1: fix layout of duplicated RB_ENTRY() definition

3a509754ded1 removed the color field from our definition, but libevent1
has a copy of it off to the side to prevent event.h consumers from
*needing* to pull in sys/queue.h and sys/tree.h.

Update the event.h definition so that we don't accidentally end up with
two different views of struct event.

This appears to have no functional effect on anything in tree, but this
came up in a local patch to port if_switch(4) and related components
from OpenBSD.

MFC after: 1 week

3 years agoMakefile.inc1: unbreak bootstrap when kbdcontrol does not exist
Glen Barber [Wed, 24 Mar 2021 00:47:14 +0000 (20:47 -0400)]
Makefile.inc1: unbreak bootstrap when kbdcontrol does not exist

Reviewed by: arichardson
MFC after: 12 hours
MFC target: stable/13, releng/13.0
Differential Review: https://reviews.freebsd.org/D29200
Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agoFix build for non-vnet non-multipath kernels broken by
Alexander V. Chernikov [Tue, 23 Mar 2021 23:35:23 +0000 (23:35 +0000)]
Fix build for non-vnet non-multipath kernels broken by
 a0308e48ec12ae37f525aa3c6d3c1a236fb55dcd.

3 years agoFix panic when destroying interface with ECMP routes.
Alexander V. Chernikov [Tue, 23 Mar 2021 22:00:04 +0000 (22:00 +0000)]
Fix panic when destroying interface with ECMP routes.

Reported by: Zhenlei Huang <zlei.huang at gmail.com>
PR: 254496
MFC after: immediately