nd6: Add support for Optimistic DAD (RFC 4429)
Implement optimistic address based on RFC 4429.
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D55229
acpica: Fix SRAT memory region insertion sort
The SRAT table can list memory regions in any order, but we need them
sorted. There is an insertion sort to accomplish this when building
the mem_info array, but instead of inserting the new region before
the *first* higher-base-address region, it was inserting the new
region before the *last* higher-base-address region; i.e. if the array
already held "1 3 4" then inserting "2" would produce "1 3 2 4".
Break out of the insertion-location-finding loop when we find the right
spot to insert the new memory region into the list, rather than looking
further.
Reviewed by: jhb
Fixes: dd540b46236b ("Add a parser for the ACPI SRAT table...")
MFC after: 1 day
Sponsored by: Amazon
Tested on: c5n.9xlarge, c6a.24xlarge, c6a.metal, c7a.metal-48xl
c7i.metal-24xl, c7i.metal-48xl, c8a.metal-24xl
[3 lines not shown]
ipfw.8: document the skipto cache
Since 4a77657cbc01 the skipto cache can be turned on and off at run
time with "ipfw enable|disable skipto_cache", and its state is shown
by the read-only net.inet.ip.fw.skipto_cache sysctl. The manual page
lists the keyword only in the SYNOPSIS, and the skipto action refers
to SYSCTL VARIABLES for details that are not there.
Describe the cache with the skipto action: what it speeds up, that it
is off by default and per VNET, and how much memory it takes. Add
net.inet.ip.fw.skipto_cache to SYSCTL VARIABLES.
Reviewed by: ae
Co-authored-by: Claude Opus 5.5
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D62029
LinuxKPI: Add in_compat_syscall()
Return true when the current process is a 32-bit process running on a
64-bit kernel, matching the Linux semantics. On native 32-bit kernels
there is no compat ABI, so always return false.
Reviewed by: wulf
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61900
usb: Disentangle SMC and SMSC
In the 1990s Standard Microsystems Corporation used the name SMC and
produced complete NICs like the SMC EtherEZ 8416BTA. It appears this
part of the business became SMC Networks and was later acquired by
Accton Technology.
By the early 2000s Standard Microsystems Corporation sold network ICs
(not complete NICs) and exclusively used the short name SMSC. SMSC was
acquired by Microchip in 2012.
We originally obtained usbdevs from NetBSD, and this update matches the
SMC / SMSC IDs currently in NetBSD.
Reviewed by: bz, adrian
Differential Revision: https://reviews.freebsd.org/D61724
kern_linker: Fix struct version mismatch
The kldstat(2) syscall supports two different structures, identified by
their size, which the application stores in the version field before the
call. Since one is a prefix of the other, instead of calling different
functions to fill each one in like modstat(2) does, we fill in the
larger of the two and simply don't copy out the extra fields if the
smaller one was requested. As a side effect, we failed to fill out the
version field in either case. This causes application code that sets
the version field once and calls kldstat(2) repeatedly to fail since the
version field is now incorrect for subsequent calls, whereas the same
pattern works fine for modstat(2) because it copies the same version
value back out. Fix this by setting the version field immediately
before copying the struct out.
While here, amend the manual pages for both kldstat(2) and modstat(2) to
clarify that the version field is unchanged on return and remove bad
advice about rebuilding world if either syscall returns EINVAL.
[3 lines not shown]
usr.bin/lockf/tests: Add require.progs="kdump"
This test requires kdump to function today. kdump can be omitted from
the system though via the build knob `MK_KDUMP != 0.
Add the require.progs constraint to check for kdump, so catch this
particular scenario and react accordingly.
MFC after: 1 week
Revision URI: https://reviews.freebsd.org/D62041
dummynet: do not log when a listing fills the buffer
When userland lists a range of objects, dummynet_get() sizes the
buffer from the request, and ipfw(8) and dnctl(8) retry with a bigger
one if the reply may be truncated. copy_obj() and copy_obj_q() still
log every stop as an error, so "ipfw queue N show" with many dynamic
queues prints "copy_obj_q ERROR ... have 16 need 96" although the
listing is complete.
Keep the error for a bad object and log the full buffer only at debug
level 3 and above.
PR: 290420
Reported by: dimka at dz.dn.ua
Reviewed by: kp
Sponsored by: Advanced Micro Devices, Inc.
Signed-off-by: Osvaldo Janeri Filho <ojanerif at amd.com>
Differential Revision: https://reviews.freebsd.org/D61964
pf: protect against the ethernet rule going away during DIOCGETETHRULE
We release the rules lock during DIOCGETETHRULE, but wait to clear the
counters until after we've unlocked. This risks the rule being freed at
the point where we reset the counters. Move the counter clearing to be
covered by the lock.
Reported by: llm-postcr
Fixes: 30087aa2e00a ("pf: Support clearing ether counters")
Sponsored by: Rubicon Communications, LLC ("Netgate")
pf: hold PF_RULES_xLOCK when calling pf_find_keth_ruleset()
The ethernet rules are protected entirely by the PF_RULES_LOCK, not by
epoch. Update DIOCGETETHRULESETS, DIOCGETETHRULESET, DIOCADDETHRULE and
DIOCGETETHRULES to account for this.
Fixes: c5131afee39b ("pf: add anchor support for ether rules")
Sponsored by: Rubicon Communications, LLC ("Netgate")
bnxt: fix an out-of-bounds write in bnxt_copy_maddr()
bnxt_copy_maddr() copies link-layer multicast addresses into the
BNXT_MAX_MC_ADDRS-entry list given to the firmware, but only skips the
copy when cnt == BNXT_MAX_MC_ADDRS. The callback returns 1 for every
address, so with 18 or more addresses it writes past the end of the
list. bnxt_multi_set() switches to ALL_MCAST when there are more than
BNXT_MAX_MC_ADDRS addresses, so the extra entries are never used, but
on amd64 the list sits at the start of a 4 KB allocation, and with 683
or more addresses the writes go past it.
Skip the copy for every cnt >= BNXT_MAX_MC_ADDRS.
Fixes: dbf9bf044c6e ("Convert to if_foreach_llmaddr() KPI.")
MFC after: 2 weeks
Sponsored by: E-CARD LTD.
Sponsored by: Klara, Inc.
Reviewed by: sef, gallatin
Differential Revision: https://reviews.freebsd.org/D61950
bnxt: don't fail init when out of VLAN L2 filters
bnxt_hwrm_set_filter() allocates an L2 filter for every configured
VLAN and fails the init if any allocation fails. A port has a fixed
number of L2 filters (509 on a BCM57416), so with enough VLANs every
init fails with RESOURCE_ALLOC_ERROR and the port stays down until
VLANs are removed.
The port's MAC filter does not match on VLAN, so the per-VLAN filters
are not needed to receive tagged traffic ( VLANs added while the port
is running already work without one until the next init). Treat
ENOMEM from the VLAN filter allocations as non-fatal (leave the
remaining tags without a filter and log their count, once per init).
Any other error still fails the init.
Append new tags in bnxt_vlan_register() instead of prepending them, so
the oldest VLANs keep their filters and the most recently added ones
beyond the ports capabilities do not get a filter.
[7 lines not shown]
bnxt: reset VLAN filter IDs in bnxt_clear_ids()
bnxt_clear_ids() resets the firmware IDs the driver caches, including
vnic_info.filter_id, but not the per-VLAN filter IDs added in
91fcacc35597. On pre-P5 chips, bnxt_init_hw() and bnxt_stop() free
the filters in firmware with HWRM_FUNC_RESET and leave tag->filter_id
set. Once the VLAN filters have been allocated, the next init (for
example from ifconfig down/up or an MTU change) fails in
bnxt_hwrm_set_filter() with "Attempt to re-allocate l2 ctx filter",
and the port stays down until its VLANs are removed.
Reset tag->filter_id along with vnic_info.filter_id.
Fixes: 91fcacc35597 ("if_bnxt: Add support for VLAN on Thor")
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: E-CARD LTD.
Reviewed by: sef
Differential Revision: https://reviews.freebsd.org/D61945
imgact_elf: Pass program headers to the sv_protect hook
We handle program headers beyond the first page of the file, but
arm64_exec_protect() wasn't updated to handle this. Pass the program
header array directly to the sv_protect hook.
Also fix a pre-existing bug: imgp->et_dyn_addr isn't the right base
address to use for the SV_INTERP case.
Reported by: alc
Reviewed by: alc, kib
Fixes: 804daf166406 ("imgact_elf: read program headers if not contained in the first page")
Fixes: 670af174e27b ("arm64: Enable BTI in the kernel ELF loader")
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61999
netipsec: Apply the rest of a bundle when the PMTU check finds no SA
ipsec{4,6}_check_pmtu() looks up the SA of the last request of a policy to
learn the path MTU. When that request is at level "use" and no SA is
found for it, the lookup returns EJUSTRETURN, and ipsec4_common_output1()
and ipsec6_common_output() took that to mean that the packet needs no
IPsec processing. That holds for a policy with one request. For a bundle
it also skipped the requests before the last one, for example the ESP
tunnel request of "esp/tunnel/A-B/require ah/transport//use", and the
packet was sent without their transforms.
The lookup finds no SA when none is installed, and also when the last
request is a transport request that follows a tunnel request, as in the
example. The lookup fills in the empty addresses of a transport request
from the packet as it is before any transform, while the transform applies
the request after the tunnel request, to the outer header, and the SA is
installed for the addresses of the tunnel. So the bundle above was sent
without its transforms even with an AH SA from A to B in place.
[21 lines not shown]
acpi: Tasks: Ensure taskqueue is running before allowing to drain
In AcpiOsWaitEventsComplete(), fix the test controlling whether to call
taskqueue_drain_all(): That must happen only if threads to process the
taskqueue have been created.
In the initial code, there is a very small window where
'acpi_boot_tasks_nb' could be 0 but some task was concurrently enqueued
(e.g., by an interrupt), leading to a call to taskqueue_drain_all()
which would wait forever in the absence of threads processing the
taskqueue.
Reported by: llm-postcr
Sponsored by: The FreeBSD Foundation
acpi: Tasks: Always enqueue in the taskqueue right away
There is no need for delaying enqueuing ACPI tasks until the taskqueue's
threads have started. Taskqueues perfectly support that, as once
taskqueue threads are started, they will pick up enqueued tasks
naturally.
Remove this mechanism, which allows a number of simplifications:
- Remove the now-useless ACPI_TASK_ENQUEUED flag.
- Remove an atomic manipulation to set ACPI_TASK_ENQUEUED on each task
enqueue in the common case.
- Simplify AcpiOsWaitEventsComplete() by using taskqueue_drain_all()
directly, and make it print a warning when called before the taskqueue
threads have started.
While here, use atomic functions to operate on 'acpi_taskq_started'.
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61548
acpi: Tasks: Remove the now-redundant 'acpi_task_count'
That number is used only up to the moment when the ACPI taskqueue's
threads are started to print the number of tasks queued so far. This is
now redundant with 'acpi_boot_tasks_nb'. So use the latter and remove
it, with the benefit that no more useless updates are performed at task
creation and end, which could create contention.
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61547
acpi: Tasks: Count task slots used during boot separately
During boot, tasks can be enqueued by drivers before the scheduler is up
and the ACPI taskqueue threads running. Such tasks pile up in the task
queue until they can actually be processed. This makes the number
reported by the 'debug.acpi.tasks_hiwater' sysctl(8) knob less useful,
as if it is representative of the maximum amount of storage needed, it
does not allow to understand the degree of task concurrency at run-time,
which itself can be useful to size the queue and/or the number of
processing threads.
Create a separate counter for tasks queued at boot, and update it
instead of the already existing one before the taskqueue starts being
processed. Export it via the new 'debug.acpi.boot_tasks_nb' sysctl(8)
knob. The existing counter is now updated only after this phase.
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61546
TMP461 sensor: Fix temperature reading in extended range mode
In extended range mode, the temperature's integral part is stored as an
unsigned byte offset by 64, not as a signed byte. Stop treating it as
a signed value in this case, in particular sign extending it. Doing so
would cause temperatures above 128°C (and in particular nearing the
maximum operating point of 150°C) to be treated as negative ones, as the
sign extension happened after substracting the offset. In the original
commit introducing the driver, sign extension was done before, in which
case the problem manifested as soon as 64°C. It may have been noticed
while introducing support for ADT7461, but was not completely fixed at
that time.
While here, fix typos in two comments.
Reported by: llm-postcr
Reviewed by: manu
Fixes: f89f6f9581bd ("TMP461: Add thermal sensor driver")
Fixes: 6665c7a62839 ("TMP461: Add support for ADT7461 sensor")
[3 lines not shown]
TMP461 sensor: Fix UB when reading the temperature
Left shifting a potentially negative number is undefined behavior
according to the C standard (still in C23, although that's probably
a mistake for this one).
Shift left the just-read data first, as it is of an unsigned type
(uint8_t), and then sign-extend the result with the new sign_extend32().
Reviewed by: manu
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61763
tests/sys/kern/procdesc: test the reaper's own PD_NOWAITPID child
Check that the reaper can waitpid(2) for its PD_NOWAITPID child after
closing the last process descriptor, untraced, detached, or with the
tracing reaper exiting.
Based on reproducers provided by Laam Alif <laamalif at proton.me>.
PR: 301072
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D61975
procdesc_close(): grant waitpid(2) when the reaper is already the parent
When the process is already a child of its reaper, proc_reparent()
returns early and does not re-enable waitpid(2), so after the last
process descriptor was closed nobody could reap the zombie. If the
reaper was also tracing the process, it was additionally linked onto
the reaper's own orphan list, and after PT_DETACH it stayed there
untraced, again without a waitpid(2) reference.
PR: 301072
Reviewed by: kib, markj
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D61975
libc/powerpc64: save v20-v31 in setjmp
setjmp and its variants save the non-volatile GPRs and FPRs, but not the
non-volatile vector registers v20-v31, so after a longjmp they hold
whatever the code that jumped left in them. Julia runs into this when it
switches tasks with sigsetjmp/siglongjmp: the compiler keeps vector values
in v20-v31 and they come back from another task.
jmp_buf has had room for them all along. Add setjmp entry points that save
them and pick those with ifuncs when the CPU has Altivec, so the same libc
still works on CPUs without it, like the e5500. They note in the buffer
where the registers went, and longjmp loads them back only if the note is
there.
rtld can't use ifuncs, so it builds its own sigsetjmp that checks hwcap
when it's called. It needs the registers saved too: when it restarts a
symbol lookup to upgrade its lock, it longjmps out of functions that use
v31, and a lazily bound call came back with v31 zeroed.
[3 lines not shown]
bhyve: e82545: allow access to the last receive address register
The model exposes 16 receive address register pairs, but both accessors
asserted that the index was below 15. Use E82545_RAR_MAX as the last
valid index for the register ranges and accessors. Size the address
array from the same limit and use its length when clearing valid bits.
Signed-off-by: Wanpeng Qian <wanpengqian at gmail.com>
MFC after: 2 weeks
Sponsored by: keelos.dev
Differential Revision: https://reviews.freebsd.org/D60219
Co-authored-by: Kevin Bowling <kbowling at FreeBSD.org>