divert: Define semantics for SO_REUSEPORT_LB on divert sockets
Allow SO_REUSEPORT_LB to be set on divert sockets. If set, then bind()
will add the socket to a "load-balancing group". When a divert-to rule
matches a port with an associated group, the corresponding state ID is
used to select a specific socket from the group. Packets without an
associated state are simply forwarded to the first socket in the group.
For now I only pass a state ID from pf, as I couldn't see a useful
identifier on the ipfw side.
This implementation is simple but has a caveat, that being that if
sockets are added to the group while flows are being processed, the size
of the group will change and this changes the mapping of state IDs to
sockets. So, to get a consistent mapping, the divert socket application
must bind all of its sockets before any traffic is diverted by the
firewall.
Reviewed by: glebius
MFC after: 1 month
[3 lines not shown]
bhyve/virtio-scsi: Support multiple backends
In order to support multiple backends for virtio-scsi, we should isolate
the core of virtio-scsi from the backend-specific code. The existing
interface to CTL will become the new "CTL" backend for virtio-scsi.
Care has been taken to keep compatibility with previous configurations:
The first backend linked (CTL) will be the default backend if none is
specified, and it does provide a default configuration if no further
options such as targets are explicitly configured.
Reviewed by: markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D53223
bhyve/virtio-scsi: Make all I/O processing parameters configurable
This includes:
- seg_max, the number of segments allowed in a single command
- {ctl,evt,req}_ringsz, the number of descriptors in a queue
- thr_per_q, the number of processing threads per request queue
- num_queues, the number of request queues
Reviewed by: markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D54073
bhyve/virtio-scsi: Implement task management functions
Currently, all I/O requests are queued internally, and a number of
threads will pick I/O requests of the queue and send them to CTL with
a synchronous CTL_IO ioctl. On the other hand, TMF requests are sent
to CTL immediately using the same synchronous ioctl.
Besides being unworkable for non-CTL backends such as for SCSI
passthrough, this simple approach may easily run into situations
where a TMF request operating on a particular I/O request is sent
to CTL while it is still on our queue and thus unknown to CTL.
In addition, for target and/or LUN resets we should really clear
our queue and return all outstanding I/O requests with a proper
status.
Reviewed by: markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D53222
bhyve/virtio-scsi: Support for multiple targets
Currently, virtio-scsi supports only one target with 16383 LUNs, which
fits nicely with what CTL provides. It would be useful to support more
than that, multiple targets each with 16383 LUNs.
While this can be useful with CTL by attaching each target to another
CTL target port, this will be necessary to support SCSI passthrough.
The new syntax for configuring targets will look like this:
-s X,virtio-scsi,target=/dev/foo,target=/dev/bar,target=4:/dev/baz
This will create the following configuration nodes:
pci.0.X.0.device=virtio-scsi
pci.0.X.0.target.0=/dev/foo
pci.0.X.0.target.1=/dev/bar
pci.0.X.0.target.4=/dev/baz
[16 lines not shown]
smartpqi: Add runtime sysctl for debug_level and log device state changes
The smartpqi driver did not log device add/remove or controller events
to syslog, and hw.smartpqi.debug_level could only be set at boot via
loader.conf with no runtime sysctl interface.
Add a read-write sysctl at dev.smartpqi.N.debug_level for runtime
debug level changes. Add device_printf calls for device addition,
removal, and controller events (hotplug, hardware, physical/logical
device, AIO state/config changes) so state changes always appear in
dmesg. Add DBG_DISC logging for discovery state transitions. Fix
spelling errors in strings and comments across the driver.
Bump driver version to 14.4691.1.2000 / 15.2.1.2000.
PR: 294161
Reviewed by: imp
Approved by: imp
MFC after: 2 weeks
[4 lines not shown]
smartpqi: Add runtime sysctl for debug_level and log device state changes
The smartpqi driver did not log device add/remove or controller events
to syslog, and hw.smartpqi.debug_level could only be set at boot via
loader.conf with no runtime sysctl interface.
Add a read-write sysctl at dev.smartpqi.N.debug_level for runtime
debug level changes. Add device_printf calls for device addition,
removal, and controller events (hotplug, hardware, physical/logical
device, AIO state/config changes) so state changes always appear in
dmesg. Add DBG_DISC logging for discovery state transitions. Fix
spelling errors in strings and comments across the driver.
Bump driver version to 14.4691.1.2000 / 15.2.1.2000.
PR: 294161
Reviewed by: imp
Approved by: imp
MFC after: 2 weeks
[4 lines not shown]
acpi: On /dev/power suspend, trigger userspace notifications
On a suspend request via ioctl(), /dev/acpi (and compatible /dev/apm)
both call acpi_ReqSleepState() instead of directly calling
acpi_EnterSleepState(). The former does more checks, returns success if
the machine is already suspending, and notifies user space (via devd(8))
about the impending suspend. In other words, it seems to have been
designed for user consumption more than the latter function.
So, use acpi_ReqSleepState() in place of acpi_EnterSleepState() in
acpi_pm_func(), which is ultimately called by power_pm_suspend(), itself
called by power_ioctl(). Other callers of power_pm_suspend() (such as
the console drivers) are also user-facing facilities, so should also
benefit from this change.
Reviewed by: mhorne, imp
Tested by: mhorne
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57239
snd_hda: Reassign duplicate HDMI/DP pin sequences instead of disabling
Some firmware (e.g. Apple EFI on Sandy Bridge Mac hardware) programs all
HDMI/DP output pins in an association with identical sequence numbers.
The existing code disables the entire association on the first
duplicate, leaving HDMI/DP audio non-functional.
For digital output pins (HDMI/DP) with seq=0 duplicates, search for the
next free sequence slot and reassign the duplicate rather than
disabling.
The seq=0 restriction targets the known Apple firmware pattern; any
other duplicate sequence is more likely a genuine firmware error and the
association is still disabled.
Update first after reassignment so that hpredir is not left pointing at
a stale sequence. Non-digital and input associations retain the existing
disable behaviour.
[6 lines not shown]
snmp_pf: fix refresh
Some refresh functions had two layers of 'do we need to refresh now?'
checks, leading to inconsistent refreshes.
Consolidate them.
PR: 291725
Sponsored by: Rubicon Communications, LLC ("Netgate")
(cherry picked from commit a862e4b5a27c356e2584ee74fd9e211c18b1b125)
snmp_pf: fix refresh
Some refresh functions had two layers of 'do we need to refresh now?'
checks, leading to inconsistent refreshes.
Consolidate them.
PR: 291725
Sponsored by: Rubicon Communications, LLC ("Netgate")
(cherry picked from commit a862e4b5a27c356e2584ee74fd9e211c18b1b125)
universe: emit warning instead of error for bad/missing KERNCONF
When doing a large `make universe` build with multiple KERNCONFS,
it should not be an error when a particular target has a missing
KERNCONF.
In this example,
```
$ make universe TARGETS='arm64 riscv' KERNCONFS='QEMU VIRT'
```
Currently, arm64 does not have a QEMU conf, and riscv
does not have a VIRT conf. However, this command should still
succeed instead of failing with the following message:
```
make[2]: /usr/src/Makefile:767: Target architecture for riscv/conf/VIRT unknown. config(8) likely too old.
in .for loop from /usr/src/Makefile:761 with kernel = VIRT
[15 lines not shown]
hwpmc: Avoid panic on AMD cpus where IBS is not available
The recent IBS work intruduced a bug on older CPUs where the
IBS handler will be called on NMIs even when IBS is not initialized.
Work around this in the IBS handler by checking to see if ibs_pcpu
is NULL before accessing it.
acl_id_to_name.c: Fix printing of uids and gids
uid_t and gid_t are uint32_t (unsigned 32bit integers).
They are printed as signed integers when calling getfacl
(and other tools using the acl_to_text() libc function).
This causes uid/gids larger than 2G (214783648) to print
as negative numbers
- which causes problem with setfacl since the acl_from_text()
libc function fails on negative numbers.
Reviewed by: rmacklem
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D57179
nfs: Fix argument typo to avoid a crash
A typo resulted in the wrong argument for a bytewise
comparison that could result in a crash if
the incorrect argument was not a valid pointer.
This patch fixes the argument.
While investigating this, I noticed that the
correct argument was not being filled in as
required, so this patch fixes that, as well.
Somehow, recovery from a NFSv4.1/4.2 server
crash worked during testing, so this was not
detected. The bug/patch only affects NFS
client mounts using NFSv4.1/4.2.
PR: 294925
Reported by: Jov <amutu at amutu.com>
MFC after: 3 days
Revert "sh/tests: Cut down builtins/read12.0 by 2 seconds"
Dag-Erling Smørgrav does not like this, but I do not understand why.
This reverts commit 1df431576f99c3cc26dd4ceb1a6eda864cc9f196.
lpd: Avoid buffer overflow when sending a job
When forwarding a print job to a remote server, we could overflow the
command buffer if a control or data file had a very long name.
MFC after: 1 week
Reported by: Joshua Rogers <joshua at joshua.hu>
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D57184
lpd: Drop deprecated -p option
This alias for the -s option has been deprecated since 2002. Time to
drop it from the documentation.
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D57183
lpd: Restore ability to specify a port number
This has been broken since IPv6 support was added in 2000. We would
validate the port number (which had to be a port number, but can now
also be a service name) and then ignore it.
MFC after: 1 week
Fixes: 08829865f659 ("IPv6 support for lpr.")
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D57181
ttymsg: Overhaul
* Instead of an error string, return the usual 0 or -1 and let the caller
figure out what, if anything, to tell the user.
* Avoid string manipulations by opening /dev first and using openat()
with O_RESOLVE_BENEATH.
* Add a boolean argument which, if false, causes ttymsg() to return
without sending the message if the tty's group-writable bit is not
set. This saves programs that respect this setting (like syslogd(8))
from having to check before calling ttymsg().
* Update all callers.
The observable effect of this change is minimal except for slightly
different error messages when ttymsg() fails. However, syslogd(8) will
no longer print spurious error messages on the console after trying and
failing to write a log message to an X11 session.
[5 lines not shown]
eventhandler: Fix the NODEBUG build
Reported by: Michael Butler <imb at protected-networks.net>
Fixes: 735b16d490ae ("eventhandler: Fix a race when pruning eventhandlers")
(cherry picked from commit 3d8928114c4fec6cefbb1cd566ef8d1b3d2999e2)