]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
16 months agonetlink: make nlattr_add_in[6]_addr inline
Alexander V. Chernikov [Mon, 27 Mar 2023 11:53:34 +0000 (11:53 +0000)]
netlink: make nlattr_add_in[6]_addr inline

MFC after: 2 weeks

16 months agonetlink: remove forgotten debug message in handle_rtm_getroute().
Alexander V. Chernikov [Mon, 27 Mar 2023 10:49:40 +0000 (10:49 +0000)]
netlink: remove forgotten debug message in handle_rtm_getroute().

MFC after: 2 weeks

16 months agonetlink: ensure genetlink control family always registers under the same ID.
Alexander V. Chernikov [Mon, 27 Mar 2023 10:48:24 +0000 (10:48 +0000)]
netlink: ensure genetlink control family always registers under the same ID.

MFC after: 2 weeks

16 months agopci: expose intel_graphics_stolen as sysctl
Corvin Köhne [Mon, 27 Mar 2023 08:21:37 +0000 (10:21 +0200)]
pci: expose intel_graphics_stolen as sysctl

The Intel graphics stolen memory is used by the Intel GOP driver on
boot. When using bhyve with GPU passthrough, it's also used by the guest
GOP driver at guest boot. For that reason, bhyve needs to know the
address and size of this region to inform the guest about this region.
Exposing the variables as sysctl allows bhyve to easily read them.

16 months agopci: add tunable hw.pci.enable_mps_tune
Corvin Köhne [Mon, 6 Feb 2023 09:26:33 +0000 (09:26 +0000)]
pci: add tunable hw.pci.enable_mps_tune

If the tunable is set to 0, the tuning of the MPS (maximum payload size)
is disabled and the default MPS values set by the BIOS are used. In this
case the system may use a lower speed or operate in a less optimized
state, but it can resolve issues with stability and compatibility. With
specific devices the tuning of the mps, can lead to a complete freeze of
the system.

Reviewed by: manu
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D38397

16 months agobhyve: add config option to modify LPC IDs
Corvin Köhne [Tue, 23 Nov 2021 12:14:41 +0000 (13:14 +0100)]
bhyve: add config option to modify LPC IDs

The Intel GOP driver checks the LPC IDs to detect the platform it's
running on. The GOP driver only works on the platforms it's written for.
Maybe other Intel driver have the same behaviour. For that reason, we
should use the LPC IDs of the FreeBSD host for GPU passthrough to work
properly.

We don't know if setting different LPC IDs have any side effect.
Therefore, don't use the host LPC IDs by default on Intel system. Give
the user the opportunity to modify the LPC IDs.

Reviewed by: jhb
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D28280

16 months agobhyve: make use of helper to read PCI IDs from bhyve config
Corvin Köhne [Mon, 6 Feb 2023 10:13:56 +0000 (11:13 +0100)]
bhyve: make use of helper to read PCI IDs from bhyve config

For compatibilty reasons, the old config values are still supported.

Reviewed by: jhb
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D38403

16 months agobhyve: add helper to read PCI IDs from bhyve config
Corvin Köhne [Mon, 6 Feb 2023 10:43:49 +0000 (11:43 +0100)]
bhyve: add helper to read PCI IDs from bhyve config

Changing the PCI IDs is valuable in some situations. The Intel GOP
driver requires that some PCI IDs of the LPC bridge are aligned with the
physical values of the host LPC bridge. Another use case are oracles
virtio driver. They require different subvendor ID than the default one.
For that reason, create a helper which makes it easy to read PCI IDs
from bhyve config. Additionally, this helper ensures that all emulation
devices are using the same config keys.

Reviewed by: jhb
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D38402

16 months agorarpd(8): Fix a typo in a source code comment
Gordon Bergling [Mon, 27 Mar 2023 06:45:30 +0000 (08:45 +0200)]
rarpd(8): Fix a typo in a source code comment

- s/combinataion/combination/

Obtained from: NetBSD
MFC after: 3 days

16 months agoping tests: Add a regression test
Jose Luis Duran [Sun, 26 Mar 2023 03:11:50 +0000 (20:11 -0700)]
ping tests: Add a regression test

Test regression fixed in 4630a3252ac8. Add two tests that do not
use the verbose flag, so the code path in question can be reached:

1. Respond with a proper ICMP destination host unreachable packet.
2. Respond with a doctored ICMP destination host unreachable packet,
   that has the ICMP Identifier field modified (+1 bit).

Reviewed by: cy
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D39244

16 months agoarm64: cpu_switch: don't zero out pcb_onfault
Kyle Evans [Sun, 26 Mar 2023 18:48:22 +0000 (13:48 -0500)]
arm64: cpu_switch: don't zero out pcb_onfault

Previously this would zero out x18 in the pcb, now it's attacking the
innocent pcb_onfault -- drop it entirely.

This technically fixes
e605b87a9e7 ("Save only callee-saved registers in pcb"), but it's
harmless until the below commit trims down pcb_x.

Reported by: mmel
Reviewed by: andrew, mmel
Fixes: 1c1f31a5e517 ("Remove unused registes from the arm pcb")
Differential Revision: https://reviews.freebsd.org/D39277

16 months agoroute: fix RTF_HOST & non-empty mask handling in netlink translation.
Alexander V. Chernikov [Sun, 26 Mar 2023 18:06:34 +0000 (18:06 +0000)]
route: fix RTF_HOST & non-empty mask handling in netlink translation.

16 months agotftp tests: Fix a typo in the makefile
Mark Johnston [Sun, 26 Mar 2023 16:54:59 +0000 (12:54 -0400)]
tftp tests: Fix a typo in the makefile

Fixes: 64c2a712d661 ("tftp: Add tests.")

16 months agoroute(8): convert to netlink
Alexander V. Chernikov [Sun, 26 Mar 2023 09:13:50 +0000 (09:13 +0000)]
route(8): convert to netlink

This change converts all kernel rtsock interactions in route(8)
 to Netlink.

Based on the WITHOUT_NETLINK_SUPPORT src.conf(5) variable, route(8)
 now fully operates either via Netlink or via rtsock/sysctl.
The default (compile-time) is Netlink.

The output for route delete/add/get/flush is targeted to be exactly
 the same (apart from some error handling cases).
The output for the route monitor has been changed to improve
 readability and support netlink models.

Other behaviour changes:
* exact prefix lookup (route -n get a.b.c.d/e) is not yet supported.
* route monitor does not show the change originator yet.

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

16 months agonetlink: restrict default userland switch to netlink to i386/amd64.
Alexander V. Chernikov [Sun, 26 Mar 2023 11:05:21 +0000 (11:05 +0000)]
netlink: restrict default userland switch to netlink to i386/amd64.

16 months agonetlink: add standrard ifaddr/neigh parsers to snl(3).
Alexander V. Chernikov [Sun, 26 Mar 2023 09:04:41 +0000 (09:04 +0000)]
netlink: add standrard ifaddr/neigh parsers to snl(3).

MFC after: 2 weeks

16 months agonetlink: add NETLINK/NETLINK_SUPPORT userland options.
Alexander V. Chernikov [Sun, 26 Mar 2023 08:56:49 +0000 (08:56 +0000)]
netlink: add NETLINK/NETLINK_SUPPORT userland options.

Make userland tools such as netstat, route, arp and ndp use
 either netlink or rtsock interfaces based on the NETLINK_SUPPORT
 options.
Both NETLINK and NETLINK_SUPPORT options are turned on by default.

Reviewed By: eugen
Differential Revision: https://reviews.freebsd.org/D39148

16 months agonetlink: allow netlink sockets in non-vnet jails.
Alexander V. Chernikov [Sun, 26 Mar 2023 08:42:51 +0000 (08:42 +0000)]
netlink: allow netlink sockets in non-vnet jails.

This change allow to open Netlink sockets in the non-vnet jails, even for
 unpriviledged processes.
The security model largely follows the existing one. To be more specific:
* by default, every `NETLINK_ROUTE` command is **NOT** allowed in non-VNET
 jail UNLESS `RTNL_F_ALLOW_NONVNET_JAIL` flag is specified in the command
 handler.
* All notifications are **disabled** for non-vnet jails (requests to
 subscribe for the notifications are ignored). This will change to be more
 fine-grained model once the first netlink provider requiring this gets
 committed.
* Listing interfaces (RTM_GETLINK) is **allowed** w/o limits (**including**
 interfaces w/o any addresses attached to the jail). The value of this is
 questionable, but it follows the existing approach.
* Listing ARP/NDP neighbours is **forbidden**. This is a **change** from the
 current approach - currently we list static ARP/ND entries belonging to the
 addresses attached to the jail.
* Listing interface addresses is **allowed**, but the addresses are filtered
 to match only ones attached to the jail.
* Listing routes is **allowed**, but the routes are filtered to provide only
 host routes matching the addresses attached to the jail.
* By default, every `NETLINK_GENERIC` command is **allowed** in non-VNET jail
 (as sub-families may be unrelated to network at all).
 It is the goal of the family author to implement the restriction if
 necessary.

Differential Revision: https://reviews.freebsd.org/D39206
MFC after: 1 month

16 months agorouting: add public rt_is_exportable() version to check if
Alexander V. Chernikov [Sun, 26 Mar 2023 08:19:56 +0000 (08:19 +0000)]
routing: add public rt_is_exportable() version to check if
 the route can be exported to userland when jailed.

Differential Revision: https://reviews.freebsd.org/D39204
MFC after: 2 weeks

16 months agodevd.conf.5: Fix a typo in the manual page
Gordon Bergling [Sun, 26 Mar 2023 07:43:58 +0000 (09:43 +0200)]
devd.conf.5: Fix a typo in the manual page

- s/deteted/detected/

MFC after: 5 days

16 months agoshare/misc/committers-*: Document my mentors
Cy Schubert [Sun, 26 Mar 2023 03:29:37 +0000 (20:29 -0700)]
share/misc/committers-*: Document my mentors

Document my ports and src mentors.

16 months agovnode_pager_input: return runningbufspace back
Konstantin Belousov [Fri, 24 Mar 2023 21:12:21 +0000 (23:12 +0200)]
vnode_pager_input: return runningbufspace back

Both vnode_pager_input_smlfs() and vnode_pager_generic_getpages()
increment runningbufspace, but also both delegate io completion handling
on the pbuf to either plain bdone() or filesystem-specific strategy
routine. Accidentally, for e.g. UFS it is g_vfs_strategy()/g_vfs_done().
The later calls bufdone() which handles runningbufspace reclamation.

For plain bdone() io done handler, nothing would return
accounted b_runningbufspace back. Do it in the new
helper vnode_pager_input_bdone(), as well as in
vnode_pager_generic_getpages_done() explicitly.

Note that potential multiple calls to runningbufwakeup() for the same
pbuf or buf completion are safe. runningbufwakeup() clears accounting
for the buffer, so second and later calls are nop.

The problem was found due to tarfs using small vnode pager input but not
g_vfs_strategy().

Reported by: des
Reviewed by: markj, sjg
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D39263

16 months agovm: add unlocked page lookup before trying vm_fault_soft_fast
Mateusz Guzik [Sat, 25 Mar 2023 14:40:55 +0000 (14:40 +0000)]
vm: add unlocked page lookup before trying vm_fault_soft_fast

Shaves a read lock + tryupgrade trip most of the time.

Stats from doing a kernel build (counters not present in the tree):
vm.fault_soft_fast_ok: 262653
vm.fault_soft_fast_failed_other: 41
vm.fault_soft_fast_failed_no_page: 39595772
vm.fault_soft_fast_failed_page_busy: 1929
vm.fault_soft_fast_failed_page_invalid: 22183

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

16 months agovfs cache: always assert on ndp->ni_resflags
Mateusz Guzik [Thu, 23 Mar 2023 23:27:54 +0000 (23:27 +0000)]
vfs cache: always assert on ndp->ni_resflags

16 months agoi386: ansify
Dmitry Chagin [Sat, 25 Mar 2023 20:21:03 +0000 (23:21 +0300)]
i386: ansify

Reported by: clang 15

16 months agoCONTRIBUTING.md: Suggest using checkstyle9.pl
Warner Losh [Tue, 21 Mar 2023 08:08:12 +0000 (02:08 -0600)]
CONTRIBUTING.md: Suggest using checkstyle9.pl

16 months agocheckstyle9.pl: Perl script to check if a change is approximately style(9)
Warner Losh [Tue, 14 Mar 2023 21:28:05 +0000 (15:28 -0600)]
checkstyle9.pl: Perl script to check if a change is approximately style(9)

This code is adapted from the QEMU checkpatch.pl script. It can check
either a patch, a file or a git branch. It tries to warn about things
that I believe might be style(9) violations. It's experimental, since I
heavily hacked on the qemu version to get it to not complain (much)
about iconic code in the tree. At the moment, it's use should be
considered expermental. It will likely miss violations, and complain
about code that's perfectly fine.  It's offered as an experiment
and to make it easier for contributors to submit patches.

16 months agosecure_getenv: Improve documentation wording
Warner Losh [Tue, 14 Mar 2023 17:02:07 +0000 (11:02 -0600)]
secure_getenv: Improve documentation wording

Improve the documentation wording to be more consistent with FreeBSD
manual pages.

Suggested by: mjg (though reworded)
Sponsored by: Netflix

16 months agosecure_getenv: Add () around return values
Warner Losh [Tue, 14 Mar 2023 15:25:04 +0000 (09:25 -0600)]
secure_getenv: Add () around return values

Style only change, no functional change intended.

Sponsored by: Netflix

16 months agoprocfs: Add manual page cross references.
Joseph Koshy [Sat, 25 Mar 2023 06:44:03 +0000 (06:44 +0000)]
procfs: Add manual page cross references.

Approved by: gnn (mentor)
Differential Revision: https://reviews.freebsd.org/D39264

16 months agoLRO: Add missing checks for invalid IP addresses
Andrew Gallatin [Sat, 25 Mar 2023 15:51:51 +0000 (11:51 -0400)]
LRO: Add missing checks for invalid IP addresses

LRO bypasses normal ip_input()/tcp_input() and lacks several checks
that are present in the normal path.  Without these checks, it
is possible to trigger assertions added in b0ccf53f2455

Reviewed by: glebius, rrs
Sponsored by: Netflix

16 months agopwd_mkdb: Sort options and update usage message.
Dag-Erling Smørgrav [Sat, 25 Mar 2023 14:15:40 +0000 (14:15 +0000)]
pwd_mkdb: Sort options and update usage message.

Sponsored by: Klara, Inc.
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D39266

16 months agovfs: trylock vnode requeue
Mateusz Guzik [Tue, 21 Mar 2023 04:23:15 +0000 (04:23 +0000)]
vfs: trylock vnode requeue

The quasi-LRU still gets in the way for example when doing an
incremental bzImage build, with vnode_list lock being at the
top of the profile. Further damage control the problem by trylocking.

Note the entire mechanism desperately wants to be reaped out in favor
of something(tm) which both scales in a multicore setting and provides
sensible replacement policy.

With this change everything vfs almost disappears from the on CPU
flamegraph, what is left is tons of contention in the VM.

16 months agovfs: flip deferred_inact to atomic
Mateusz Guzik [Sat, 25 Mar 2023 13:31:17 +0000 (13:31 +0000)]
vfs: flip deferred_inact to atomic

Turns out it is very rarely triggered, making a per-cpu
counter a waste.

Examples from real life boxes:
uptime counter
135 days 847
138 days 2190
141 days 1

16 months agovfs: replace some spelled out VNASSERTs with VNPASS
Mateusz Guzik [Sat, 25 Mar 2023 13:20:02 +0000 (13:20 +0000)]
vfs: replace some spelled out VNASSERTs with VNPASS

nfc

16 months agomakefs: emit NM records for all directory entries
Ed Maste [Fri, 24 Mar 2023 17:53:59 +0000 (13:53 -0400)]
makefs: emit NM records for all directory entries

We previously attempted to emit Rock Ridge NM records only when the name
represented by the Rock Ridge extensions would actually differ. We would
omit the record for an all-upper-case directory name, however Linux (and
perhaps other operating systems) map names with no NM record to
lowercase.

This affected only directories, as file names have an implicit ";1"
version number appended and thus always differ.  To solve, just emit NM
records for all entries other than DOT and DOTDOT .

We could continue to omit the NM record for directories that would avoid
mapping (for example, one named 1234.567) but this does not seem worth
the complexity.

PR: 203531
Reported by: Thomas Schmitt <scdbackup@gmx.net
Reviewed by: kevans
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39258

16 months agolinsysfs(4): Keep Linux compatible sysfs the same as Ubuntu
Vico Chen [Sat, 25 Mar 2023 10:41:04 +0000 (13:41 +0300)]
linsysfs(4): Keep Linux compatible sysfs the same as Ubuntu

By checking Ubuntu, there is no `/sys/subsystem' in sysfs. To compatible
with Ubuntu, delete the 'subsystem' creation in Linux compatible module.

On the other hand, the sysfs `/sys/subsystem' cause failure for some
Linux udev cases. In Linux udev source code, there is a function named
`scan_devices_all', and it will scan `/sys/subsystem' if it is existed,
but now there are nothing in /sys/subsystem `, and it returns empty
to cause some use cases failed.

Reviewed by: dchagin
Differential Revision: https://reviews.freebsd.org/D38885
MFC after: 1 month
XMFC with: ifAPI

16 months agolinsysfs(4): Reimplement listnics() using ifAPI
Dmitry Chagin [Sat, 25 Mar 2023 10:40:41 +0000 (13:40 +0300)]
linsysfs(4): Reimplement listnics() using ifAPI

Handle if arrival/departure events.

Reviewed by: melifaro (early version)
Differential Revision: https://reviews.freebsd.org/D38901
MFC after: 1 month
XMFC with: ifAPI

16 months agoshare/misc/committers-doc.dot: Add myself
Lorenzo Salvadore [Fri, 24 Mar 2023 11:58:35 +0000 (12:58 +0100)]
share/misc/committers-doc.dot: Add myself

Add myself as a doc committer, mentored by carlavilla and dbaio.

Approved by: carlavilla (mentor)
Differential Revision: https://reviews.freebsd.org/D39254

16 months agolocal-unbound-setup: Disable the libc subscriber.
Dag-Erling Smørgrav [Fri, 24 Mar 2023 20:45:24 +0000 (21:45 +0100)]
local-unbound-setup: Disable the libc subscriber.

This is the correct way to prevent resolvconf from updating resolv.conf.

Reviewed by: cy
Differential Revision: https://reviews.freebsd.org/D39262

16 months agoRemove libvmmapi.so.5 after the shlib version was bumped to 6.
John Baldwin [Fri, 24 Mar 2023 20:42:18 +0000 (13:42 -0700)]
Remove libvmmapi.so.5 after the shlib version was bumped to 6.

16 months agobhyve: Remove vmctx member from struct vm_snapshot_meta.
John Baldwin [Fri, 24 Mar 2023 18:49:06 +0000 (11:49 -0700)]
bhyve: Remove vmctx member from struct vm_snapshot_meta.

This is a userland-only pointer that isn't relevant to the kernel and
doesn't belong in the ioctl structure shared between userland and the
kernel.  For the kernel, the old structure for the ioctl is still
supported under COMPAT_FREEBSD13.

This changes vm_snapshot_req() in libvmmapi to accept an explicit
vmctx argument.

It also changes vm_snapshot_guest2host_addr to take an explicit vmctx
argument.  As part of this change, move the declaration for this
function and its wrapper macro from vmm_snapshot.h to snapshot.h as it
is a userland-only API.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D38125

16 months agolibvmmapi: Add a struct vcpu and use it in most APIs.
John Baldwin [Fri, 24 Mar 2023 18:49:06 +0000 (11:49 -0700)]
libvmmapi: Add a struct vcpu and use it in most APIs.

This replaces the 'struct vm, int vcpuid' tuple passed to most API
calls and is similar to the changes recently made in vmm(4) in the
kernel.

struct vcpu is an opaque type managed by libvmmapi.  For now it stores
a pointer to the VM context and an integer id.

As an immediate effect this removes the divergence between the kernel
and userland for the instruction emulation code introduced by the
recent vmm(4) changes.

Since this is a major change to the vmmapi API, bump VMMAPI_VERSION to
0x200 (2.0) and the shared library major version.

While here (and since the major version is bumped), remove unused
vcpu argument from vm_setup_pptdev_msi*().

Add new functions vm_suspend_all_cpus() and vm_resume_all_cpus() for
use by the debug server.  The underyling ioctl (which uses a vcpuid of
-1) remains unchanged, but the userlevel API now uses separate
functions for global CPU suspend/resume.

Reviewed by: corvink, markj
Differential Revision: https://reviews.freebsd.org/D38124

16 months agopmcstat: Warn about text output format stability.
Joseph Koshy [Fri, 24 Mar 2023 09:39:08 +0000 (09:39 +0000)]
pmcstat: Warn about text output format stability.

The formats for pmcstat(8)'s human-readable output are not part of its
user interface definition, and may change in the future.  Highlight
this in its manual page.

Approved by: gnn (mentor)
Differential Revision: https://reviews.freebsd.org/D39249

16 months agofdesc_lookup(): drop fdropped
Konstantin Belousov [Thu, 23 Mar 2023 19:30:04 +0000 (21:30 +0200)]
fdesc_lookup(): drop fdropped

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D39207

16 months agofdesc_lookup(): the condition to use vn_vget_ino() is always true
Konstantin Belousov [Thu, 23 Mar 2023 19:28:08 +0000 (21:28 +0200)]
fdesc_lookup(): the condition to use vn_vget_ino() is always true

The ix number for the fdescfs root is 1, while any fd vnode has the ix
value at least 3.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D39207

16 months agofdesc_lookup(): no need to vhold the dvp vnode
Konstantin Belousov [Wed, 22 Mar 2023 13:36:00 +0000 (15:36 +0200)]
fdesc_lookup(): no need to vhold the dvp vnode

It is already referenced by the VOP_LOOKUP() caller, otherwise vdrop()
after vn_lock() is invalid anyway.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D39207

16 months agofdesc_allocvp(): fix potential use after free
Konstantin Belousov [Tue, 21 Mar 2023 21:24:06 +0000 (23:24 +0200)]
fdesc_allocvp(): fix potential use after free

Just owning the interlock is not enough for vget() to operate on the
vnode race-free with vgone(), the vnode should be held.  Use
vget_prep()/vget_finish() to avoid vholding the vnode explicitly, and
drop LK_INTERLOCK.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D39207

16 months agofdescfs: remove useless XXX comment, unwrap line
Konstantin Belousov [Tue, 21 Mar 2023 21:28:16 +0000 (23:28 +0200)]
fdescfs: remove useless XXX comment, unwrap line

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D39207

16 months agorc: Chase bfb202c4554a and remove ifconfig down/up for wpa_supplicant
Cy Schubert [Fri, 24 Mar 2023 14:32:41 +0000 (07:32 -0700)]
rc: Chase bfb202c4554a and remove ifconfig down/up for wpa_supplicant

bfb202c4554a addresses the CTRL-EVENT-SCAN-FAILED. Upstream d807e289d
caused FreeBSD regression in driver_bsd.c, which this rc.d patch
worked around. As of bfb202c4554a this workaround is no longer needed.

Reviewed by: bz (for wireless)
MFC after: 10 days
X-MFC with: bfb202c4554a
Differential Revision: https://reviews.freebsd.org/D39257

16 months agoinfiniband: Bring back M_ASSERTVALID() check in infiband_bpf_mtap()
Justin Hibbits [Wed, 15 Mar 2023 19:40:24 +0000 (15:40 -0400)]
infiniband: Bring back M_ASSERTVALID() check in infiband_bpf_mtap()

Reported by: rpokala
Fixes: adf62e83631

16 months agoinet6: Include if_private.h in one more netstack file
Justin Hibbits [Mon, 6 Mar 2023 21:29:24 +0000 (16:29 -0500)]
inet6: Include if_private.h in one more netstack file

ip6_input() and ip6_destroy() both directly reference ifnet members.
This file was missed in 3d0d5b21

Fixes: 3d0d5b21 ("IfAPI: Explicitly include <net/if_private.h>...")
Sponsored by: Juniper Networks, Inc.

16 months agoMechanically convert qlnx(4) to IfAPI
Justin Hibbits [Fri, 23 Sep 2022 15:27:39 +0000 (11:27 -0400)]
Mechanically convert qlnx(4) to IfAPI

Reviewed By: zlei
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D37856

16 months agoofed: Mechanically convert to IfAPI
Justin Hibbits [Thu, 9 Feb 2023 02:31:24 +0000 (21:31 -0500)]
ofed: Mechanically convert to IfAPI

Summary:
Because of the intricacies of this code it wasn't purely scripted, but
instead hand-mechanical.

Reviewed by: hselasky
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D38560

16 months agolagg: Various style fixes
Zhenlei Huang [Fri, 24 Mar 2023 09:55:15 +0000 (17:55 +0800)]
lagg: Various style fixes

MFC after: 1 week

16 months agopf: ignore ip6_output() return value in pf_refragment6()
Kristof Provost [Fri, 24 Mar 2023 05:39:01 +0000 (06:39 +0100)]
pf: ignore ip6_output() return value in pf_refragment6()

We can't do anything if ip6_output() fails, other than discard the
packet which ip6_output() already does for us.
Mark the return value as ignored.

Reported by: emaste, Coverity
Sponsored by: Rubicon Communications, LLC (Netgate)

16 months agoifconfig: free memory allocated by getaddrinfo()
Kristof Provost [Fri, 24 Mar 2023 05:25:28 +0000 (06:25 +0100)]
ifconfig: free memory allocated by getaddrinfo()

Reported by: emaste, Coverity
Sponsored by: Rubicon Communications, LLC (Netgate)

16 months agoice(4): Restore old conditional overwritten by last update
Eric Joyner [Fri, 24 Mar 2023 07:01:01 +0000 (00:01 -0700)]
ice(4): Restore old conditional overwritten by last update

Commit 8923de590543 ("ice(4): Update to 1.37.7-k", 2023-02-13)
unintentionally overwrote the change made in commit 52f45d8acee9 ("net:
iflib: let the drivers use isc_capenable", 2021-12-28).

Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Reported by: jhibbits@
MFC after: 3 days
Sponsored by: Intel Corporation

16 months agoping: Fix an uninitialized variable
Jose Luis Duran [Fri, 24 Mar 2023 04:53:54 +0000 (21:53 -0700)]
ping: Fix an uninitialized variable

The variable oicmp, which holds the original ("quoted packet") ICMP
packet in a structured way, did not have a copy of the original ICMP
packet obtained from the raw data.

The code was accidentally removed in 20b41303140e. Bring it back.

Reported by: Coverity Scan, cy
Reviewed by: cy
CID: 1506960 (UNINIT)
Fixes: 20b41303140eee4dfb896558fb83600c5f013d39
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D39233

16 months agocontrib/tzdata: import tzdata 2023b
Philip Paeps [Fri, 24 Mar 2023 04:45:24 +0000 (12:45 +0800)]
contrib/tzdata: import tzdata 2023b

Changes: https://github.com/eggert/tz/blob/2023b/NEWS

MFC after:      1 day

16 months agoImport tzdata 2023b
Philip Paeps [Fri, 24 Mar 2023 04:44:47 +0000 (12:44 +0800)]
Import tzdata 2023b

16 months agokasan.9: Update to note arm64 support
Mark Johnston [Fri, 24 Mar 2023 00:37:41 +0000 (20:37 -0400)]
kasan.9: Update to note arm64 support

16 months agocommitters-doc.dot: Add myself; late entry
Danilo G. Baio [Fri, 24 Mar 2023 00:15:53 +0000 (21:15 -0300)]
committers-doc.dot: Add myself; late entry

16 months agoWPA: driver_bsd.c: backout upstream IFF_ change and add logging
Bjoern A. Zeeb [Thu, 23 Mar 2023 22:37:12 +0000 (22:37 +0000)]
WPA: driver_bsd.c: backout upstream IFF_ change and add logging

This reverts the state to our old supplicant logic setting or clearing
IFF_UP if needed.  In addition this adds logging for the cases in which
we do (not) change the interface state.

Depending on testing this seems to help bringing WiFi up or not log
any needed changes (which would be the expected wpa_supplicant logic
now).  People should look out for ``(changed)`` log entries (at least
if debugging the issue; this way we will at least have data points).

There is a hypothesis still pondered that the entire IFF_UP toggling
only exploits a race in net80211 (see further discssussions for more
debugging and alternative solutions see D38508 and D38753).
That may also explain why the changes to the rc startup script [1]
only helped partially for some people to no longer see the
continuous CTRL-EVENT-SCAN-FAILED.

It is highly likely that we will want further changes and until
we know for sure that people are seeing ''(changed)'' events
this should stay local.  Should we need to upstream this we'll
likely need #ifdef __FreeBSD__ around this code.

[1] 5fcdc19a81115d975e238270754e28557a2fcfc5 and
    d06d7eb09131edea666bf049d6c0c55672726f76

Sponsored by: The FreeBSD Foundation
MFC after: 10 days
Reviewed by: cy, enweiwu (earlier)
Differential Revision: https://reviews.freebsd.org/D38807

16 months agoarm64: add KASAN support
Kyle Evans [Thu, 23 Mar 2023 21:26:06 +0000 (16:26 -0500)]
arm64: add KASAN support

This entails:
- Marking some obvious candidates for __nosanitizeaddress
- Similar trap frame markings as amd64, for similar reasons
- Shadow map implementation

The shadow map implementation is roughly similar to what was done on
amd64, with some exceptions.  Attempting to use available space at
preinit_map_va + PMAP_PREINIT_MAPPING_SIZE (up to the end of that range,
as depicted in the physmap) results in odd failures, so we instead
search the physmap for free regions that we can carve out, fragmenting
the shadow map as necessary to try and fit as much as we need for the
initial kernel map.  pmap_bootstrap_san() is thus after
pmap_bootstrap(), which still included some technically reserved areas
of the memory map that needed to be included in the DMAP.

The odd failure noted above may be a bug, but I haven't investigated it
all that much.

Initial work by mhorne with additional fixes from kevans and markj.

Reviewed by: andrew, markj
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D36701

16 months agoarm64: add a GENERIC-KASAN config
Mitchell Horne [Thu, 23 Mar 2023 21:26:06 +0000 (16:26 -0500)]
arm64: add a GENERIC-KASAN config

Reviewed by: andrew, markj
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D36702

16 months agomakefs: correct El Torito bood record
Ed Maste [Thu, 23 Mar 2023 17:02:44 +0000 (13:02 -0400)]
makefs: correct El Torito bood record

The boot catalog pointer is a DWord, but we previously populated it via
cd9660_bothendian_dword which overwrote four unused bytes following it.
See El Torito 1.0 (1995) Figure 7 for details.

PR: 203531
Reported by: Coverity Scan
Reported by: Thomas Schmitt <scdbackup@gmx.net>
Reviewed by: kevans
CID: 977470
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39231

16 months agoktls: Drop all the INET and INET6 compile-time guards.
John Baldwin [Thu, 23 Mar 2023 21:29:07 +0000 (14:29 -0700)]
ktls: Drop all the INET and INET6 compile-time guards.

Consistent with 9fd0d9b16e93ff2a3bd375a98763dca0150dcee0, KERN_TLS is
not supported on kernels without any INET support.

Reviewed by: gallatin, hselasky
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D39232

16 months agoacpi(4): Fix a typo in a kernel message
Gordon Bergling [Thu, 23 Mar 2023 21:03:31 +0000 (22:03 +0100)]
acpi(4): Fix a typo in a kernel message

- s/enitialization/initialization/

MFC afer: 5 days

16 months agoImprove chance of finding an alternate superblock in sbsearch(3).
Kirk McKusick [Thu, 23 Mar 2023 20:03:20 +0000 (13:03 -0700)]
Improve chance of finding an alternate superblock in sbsearch(3).

When requesting a superblock read for the sole purpose of getting
the parameters needed to find if backup parameters have been stored,
specify UFS_NOCSUM as only the base superblock is needed. This
change reduces the number of checks that the superblock must pass.

MFC after:    1 week

16 months agovfs cache: return ENOTDIR for not_a_dir/{.,..} lookups
Mateusz Guzik [Thu, 23 Mar 2023 19:19:48 +0000 (19:19 +0000)]
vfs cache: return ENOTDIR for not_a_dir/{.,..} lookups

Reported by: Oliver Kiddle
PR: 270419
MFC: 3 days

16 months agoMark the arm64 PSR register fields with UL
Andrew Turner [Wed, 22 Mar 2023 16:46:25 +0000 (16:46 +0000)]
Mark the arm64 PSR register fields with UL

These are for a 64 bit register. Make them 64 bit values on arm64.

Sponsored by: Arm Ltd

16 months agoBump __FreeBSD_version for changing spsr on arm64
Andrew Turner [Wed, 22 Mar 2023 11:59:36 +0000 (11:59 +0000)]
Bump __FreeBSD_version for changing spsr on arm64

This changed a few structures, bump __FreeBSD_version for kgdb and
userspace consumers.

Sponsored by: Arm Ltd

16 months agoRemove unused registes from the arm pcb
Andrew Turner [Wed, 22 Mar 2023 12:33:05 +0000 (12:33 +0000)]
Remove unused registes from the arm pcb

These were kept for ABI reasons. Remove them and bump __FreeBSD_version
so debuggers can be updated to use the new layout.

Reviewed by: jhb
Sponsored by: Arm Ltd
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35378

16 months agoAdd compat support for struct reg on arm64
Andrew Turner [Mon, 20 Mar 2023 17:38:39 +0000 (17:38 +0000)]
Add compat support for struct reg on arm64

The size of the spsr field in struct reg has changed. Mask the bits
that userspace doesn't know about out as they may be invalid.

While here add a comment why we don't need compat support in set_regs.

Sponsored by: Arm Ltd

16 months agoarm64: add fault address to trapframe
Zachary Leaf [Thu, 2 Mar 2023 14:15:54 +0000 (14:15 +0000)]
arm64: add fault address to trapframe

It was previously possible for the fault address register to get
clobbered before it was saved. This small window occurred when an
additional exception was encountered inside the exception handler,
overwriting the previous value.

Commit f29942229d24 ("Read the arm64 far early in el0 exceptions")
patched this issue, but avoided changing the trapframe since this could
be considered a KBI change in FreeBSD 13.

Revert the above fix and save the fault address in the trapframe
instead. This saves the fault address even earlier in the exception
handling process, and is a more robust and simple fix.

Reviewed by: andrew, jhb, jrtc27
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D38984

16 months agoarm64: extend ESR/SPSR registers to 64b
Zachary Leaf [Fri, 24 Feb 2023 08:35:08 +0000 (08:35 +0000)]
arm64: extend ESR/SPSR registers to 64b

For the Exception Syndrome Register, ESR_ELx, the upper 32b were
previously unused, but now may contain additional exception info as of
Armv8.7 (FEAT_LS64).

Extend ESR from u32->u64 in exception handling code to support this. In
addition, also extend Saved Program Status Register SPSR_ELx in the same
way to allow for future extensions.

Reviewed by: andrew
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D38983

16 months agolibpmc: Use LIB_CXX instead of explicit LDADD to link a C++ library.
John Baldwin [Thu, 23 Mar 2023 16:31:29 +0000 (09:31 -0700)]
libpmc: Use LIB_CXX instead of explicit LDADD to link a C++ library.

This uses the C++ compiler as the linker instead of the C compiler
letting the compiler driver pick the right libraries.  This is a no-op
on main and stable/13 but matters for stable/12 where the current
logic breaks for external GCC since it tries to use a non-existent
libstdc++.

Reviewed by: emaste
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D39197

16 months agoIfAPI: Add iterator to complement if_foreach()
Justin Hibbits [Thu, 16 Mar 2023 20:24:56 +0000 (16:24 -0400)]
IfAPI: Add iterator to complement if_foreach()

Summary:
Sometimes an if_foreach() callback can be trivial, or need a lot of
outer context.  In this case a regular `for` loop makes more sense.  To
keep things hidden in the new API, use an opaque `if_iter` structure
that can still be instantiated on the stack.  The current implementation
uses just a single pointer out of the 4 alotted to the opaque context,
and the cleanup does nothing, but may be used in the future.

Reviewed by: melifaro
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D39138

16 months agomakefs: add missing break for 'g' case in tarfs test
Ed Maste [Thu, 23 Mar 2023 13:08:48 +0000 (09:08 -0400)]
makefs: add missing break for 'g' case in tarfs test

Reported by: Coverity Scan
CID: 1506954
Fixes: 6cb78fa479c7 ("tarfs: Repeat tests using GNU tar if available.")
Sponsored by: The FreeBSD Foundation

16 months agomakefs: correct iso9660 Rock Ridge NM values
Ed Maste [Thu, 23 Mar 2023 12:35:34 +0000 (08:35 -0400)]
makefs: correct iso9660 Rock Ridge NM values

These are not actually used by makefs (yet), but ought to match the
spec.

See RRIP 4.1.4 Description of the "NM" System Use Entry for details.

PR: 203531
Sponsored by: The FreeBSD Foundation

16 months agomakefs: correct iso9660 Rock Ridge TF timestamps
Ed Maste [Wed, 22 Mar 2023 23:42:45 +0000 (19:42 -0400)]
makefs: correct iso9660 Rock Ridge TF timestamps

The bit definitions for the TF_* timestamp bits (TF_MODIFY, etc.) were
incorrect, and timestamps were written in the wrong order.

See RRIP 4.1.6 Description of the "TF" System Use Entry for details.

PR: 203531
Reported by: Thomas Schmitt <scdbackup@gmx.net>
Reviewed by: jrtc27, kevans
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39221

16 months agodaemon: reformat longopts
Kyle Evans [Thu, 23 Mar 2023 02:39:10 +0000 (21:39 -0500)]
daemon: reformat longopts

Use a single tab instead of eight spaces, these aren't line
continuations.

16 months agodaemon: decouple init logic from main loop
Ihor Antonov [Thu, 23 Mar 2023 02:37:12 +0000 (21:37 -0500)]
daemon: decouple init logic from main loop

main() func contained both initialization and main loop logic.
This made certain operations like restarting problematic and
required dirty hacks in form of goto jumps.

This commit moves the main loop logic into daemon_eventloop(),
cleans up main, and makes restart logic clear: daemon_mainloop()
is run in a loop with a restart condition checked at the end.

Reviewed by: kevans
Pull Request: https://github.com/freebsd/freebsd-src/pull/699

16 months agocontrib/tzdata: import tzdata 2023a
Philip Paeps [Thu, 23 Mar 2023 01:33:45 +0000 (09:33 +0800)]
contrib/tzdata: import tzdata 2023a

Changes: https://github.com/eggert/tz/blob/2023a/NEWS

MFC after: 1 day

16 months agoLinuxKPI: remove now implemented dummy headers.
Bjoern A. Zeeb [Thu, 23 Mar 2023 01:15:53 +0000 (01:15 +0000)]
LinuxKPI: remove now implemented dummy headers.

Both iommu.h and kconfig.h now exist in the common code.
There is no need for the duplicate (empty) headers anymore.

16 months agoImport tzdata 2023a
Philip Paeps [Thu, 23 Mar 2023 01:14:52 +0000 (09:14 +0800)]
Import tzdata 2023a

16 months agortw89: fix -Wunused-but-set-variable
Bjoern A. Zeeb [Thu, 23 Mar 2023 00:29:38 +0000 (00:29 +0000)]
rtw89: fix -Wunused-but-set-variable

Fix a -Wunused-but-set-variable warning by adding the field to the
debug logging as is done for other versions handler functions.

MFC after: 3 days

16 months agoifconfig: ifieee80211: print bssid name
Bjoern A. Zeeb [Tue, 21 Mar 2023 21:25:28 +0000 (21:25 +0000)]
ifconfig: ifieee80211: print bssid name

In certain setups (e.g., autonomous APs) it is extremly helpful to have
a way to map the BSSIDs to names for both normal status output as well
as the scan list.  This often allows a quicker overview than remembering
(or manually looking up) BSSIDs.
Call ether_ntohost() on the bssid and consult /etc/ethers
and print "(name)" after the bssid for the status output and "(name)"
at the end of the line after the IE list.

MFC after: 10 days
Reviewed by: adrian, cy
Differential Revision: https://reviews.freebsd.org/D39192

16 months agovfs: decouple freevnodes from vnode batching
Mateusz Guzik [Tue, 21 Mar 2023 07:27:25 +0000 (07:27 +0000)]
vfs: decouple freevnodes from vnode batching

In principle one cpu can keep vholding vnodes, while another vdrops
them. In this case it may be the local count will keep growing in an
unbounded manner. Roll it up after a threshold instead.

While here move it out of dpcpu into struct pcpu.

Reviewed by: kib (previous version)
Differential Revision: https://reviews.freebsd.org/D39195

16 months agoRewrite function definitions with identifier lists.
Kirk McKusick [Wed, 22 Mar 2023 22:57:26 +0000 (15:57 -0700)]
Rewrite function definitions with identifier lists.

A few functions snuck in with K&R style definitions.

Also add some missing memory frees.

MFC after:    1 week

16 months agomisc/organization: add bofh as a new portmgr member
Rene Ladan [Wed, 22 Mar 2023 20:26:35 +0000 (21:26 +0100)]
misc/organization: add bofh as a new portmgr member

Hat: portmgr-secretary

16 months agosys: Retire OPENZFS_CWARNFLAGS now that it is empty.
John Baldwin [Wed, 22 Mar 2023 19:35:30 +0000 (12:35 -0700)]
sys: Retire OPENZFS_CWARNFLAGS now that it is empty.

Reviewed by: markj, emaste
Differential Revision: https://reviews.freebsd.org/D39217

16 months agosys: Stop enabling -Wnested-externs.
John Baldwin [Wed, 22 Mar 2023 19:35:09 +0000 (12:35 -0700)]
sys: Stop enabling -Wnested-externs.

clang doesn't implement this warning, so violations are only caught by
GCC.  It is also no longer a common practice to use this as it was in
the original BSD code, so the need for the warning is not as important
as when it was used to do cleanups 20 years ago.  A recent commit
(c3179891f897d840f578a5139839fcacb587c96d) triggers this warning on
GCC, but that commit uses nested externs purposefully.

Reviewed by: markj, emaste
Differential Revision: https://reviews.freebsd.org/D39214

16 months agobhyve: Don't return -ENOMEM from qemu_fwcfg_add_file.
John Baldwin [Wed, 22 Mar 2023 19:34:56 +0000 (12:34 -0700)]
bhyve: Don't return -ENOMEM from qemu_fwcfg_add_file.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D39212

16 months agobhyve: Accept a variable-length string name for qemu_fwcfg_add_file.
John Baldwin [Wed, 22 Mar 2023 19:34:34 +0000 (12:34 -0700)]
bhyve: Accept a variable-length string name for qemu_fwcfg_add_file.

It is illegal (UB?) to pass a shorter array to a function argument
that takes a fixed-length array.  Do a runtime check for names that
are too long via strlen() instead.

Reviewed by: markj
Reported by: GCC -Wstringop-overread
Differential Revision: https://reviews.freebsd.org/D39211

16 months agolibpfctl: Don't pass stack garbage to free.
John Baldwin [Wed, 22 Mar 2023 19:33:59 +0000 (12:33 -0700)]
libpfctl: Don't pass stack garbage to free.

GCC 9 on stable/12 reports a -Wmaybe-uninitialized error for the call
to free in _pfctl_clear_states.

Reviewed by: mjg
Differential Revision: https://reviews.freebsd.org/D39198

16 months agoarpa: garbage collect ns_newmsg/ns_rdata decls
Val Packett [Mon, 6 Feb 2023 19:03:58 +0000 (16:03 -0300)]
arpa: garbage collect ns_newmsg/ns_rdata decls

These were brought in by the libbind import, but these functions were
never actually implemented anywhere, only header declarations and symbol
map entries were imported.

Fixes: 046c3635cdb2 ("Bring final version of libbind:")
Fixes: e45764721aed ("Update our stub resolver to final version of ...")
Reported by: ld.lld 16 being --no-undefined-version by default
Sponsored by: https://www.patreon.com/valpackett
Reviewed by: emaste
Pull request: https://github.com/freebsd/freebsd-src/pull/700
Differential Revision: https://reviews.freebsd.org/D38407

16 months agoamd64: reduce header pollution in _stdint.h
Brooks Davis [Wed, 22 Mar 2023 16:23:57 +0000 (16:23 +0000)]
amd64: reduce header pollution in _stdint.h

In 38d1ac34ff82bd2aeb308b52a65b686060e52873 SIGATOMIC_{MIN,MAX} were
defined in terms of LONG_{MIN,MAX}.  Later, they were switched to
__LONG_{MIN,MAX} in 78fe75bc280264e7471b3069e148cae32e8ae211 where an
include of machine/_limits.h was added.  Switch to using fixed width
INT64_{MIN,MAX} and remove the header pollution.

No functional change.

Reviewed by: theraven, emaste
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D39196

16 months agoriscv: Fix sig_atomic_t limit definitions
Brooks Davis [Wed, 22 Mar 2023 16:23:22 +0000 (16:23 +0000)]
riscv: Fix sig_atomic_t limit definitions

sig_atomic_t is defined as a long and thus is 64-bit on arm64.  For some
reason its limit was incorrectly specified as a 32-bit number.  This had
the unfortunate side effect of causing gnulib to override most of the
definitions in stdint.h.  On CheriBSD this breaks all software that uses
gnulib in annoying and hard to debug ways.

Technically updating the limits might be an ABI change, but these
defines are largely unused (the only use in tree is in the libc++ test
suite where it's use an assertion that will fail due to this bug).
Further, since the underlying type remains the same, we're just
increasing the range of values a paranoid program might use.

Reviewed by: emaste
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D39194