Commit graph zephyr/subsys
Author SHA1 Message Date
Egill Sigurdur
448a21da12 net: dns: fix string read out of bounds
Fix issue that would be trapped by the address sanitizer, would always
read 7 bytes even though ptr might be shorter, and would therefore
read out of bounds if e.g. the string ".org" was passed.

Signed-off-by: Egill Sigurdur <egill@egill.xyz>
2026-05-06 07:09:41 +02:00
Tim Pambor
4127e0c97d net: zperf: udp uploader: Include FIN packet in packet count
The FIN packet was not counted in the number of packets sent.
This behavior differs from iperf2, which counts the FIN packet
as well. Previously, the statistics reported by iperf2 were
off by one compared to zperf, which was confusing.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2026-05-06 07:07:04 +02:00
Tim Pambor
0380604454 net: zperf: udp uploader: start packet IDs at one
In iperf2, the first packet of a session has ID 1.
Change the UDP uploader to start packet IDs at one,
so that the behavior is the same as iperf2.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2026-05-06 07:07:04 +02:00
Tim Pambor
cb2324d3e2 net: zperf: udp receiver: include final packet in statistics
In Zperf UDP receiver mode, the final packet of a session
was not included in the session statistics, which caused the
results to differ from those reported by iperf2.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2026-05-06 07:07:04 +02:00
Tim Pambor
92f59f5f6d net: lib: zperf: fix incorrectly reported lost packet
In Zperf UDP receiver mode, the first packet of a new session
was always counted as lost due to only initiating a new session
but not processing the packet as part of the new session.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2026-05-06 07:07:04 +02:00
Christoph Busold
88278fb59f drivers: entropy + random: Add implementations for ARM64 RNG
Add new implementations for entropy driver and random subsystem
based on ARM64 RNDRRS and RNDR instructions.

Signed-off-by: Christoph Busold <cbusold@qti.qualcomm.com>
2026-05-06 07:05:12 +02:00
Christoph Busold
dad5096f85 drivers: entropy: Add support for architectural entropy drivers
Add new inline function entropy_get_default_device which returns
the "zephyr,entropy" device or the architectural entropy device,
if the former is not set, and use that in all places to query the
entropy device.

This allows using architectural drivers which do not have a DT
node.

Signed-off-by: Christoph Busold <cbusold@qti.qualcomm.com>
2026-05-06 07:05:12 +02:00
Mikolaj Klikowicz
8afa8f1b5a tracing: ctf: use 64-bit timestamps
Changes CTF events to use 64bit timestamp. This enables tracing of
longer
execution as 32bit timestamps overflows after ~4s.

Signed-off-by: Mikolaj Klikowicz <mklikowicz@antmicro.com>
2026-05-05 14:07:47 -05:00
Cristian Bulacu
07fc65330d net: dns: Add support for DNS private RR types
This PR implements support for DNS Private Resource Records (RR)
as defined in RFC 6895, enabling applications to query and
handle DNS records in the private use range (type codes 65280-65534).
This feature is not enabled by default,
CONFIG_DNS_RESOLVER_PRIVATE_RR_SUPPORT is used to enable it.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2026-05-05 14:06:23 -05:00
Rithic Chellaram Hariharan
6b71a4dce3 net: http: client: fix timeout rounding
Use k_ticks_to_ms_ceil32 instead of k_ticks_to_ms_floor32 to prevent
premature zero-ms timeouts when remaining ticks round down to zero.

Signed-off-by: Rithic Chellaram Hariharan <gr8rithic@gmail.com>
2026-05-05 14:05:55 -05:00
Rithic Chellaram Hariharan
bceb910286 net: http: client: make send buffer size configurable via Kconfig
Replace hard-coded MAX_SEND_BUF_LEN (192) with a new Kconfig option
CONFIG_HTTP_CLIENT_SEND_BUF_SIZE so applications can tune the
stack-allocated send buffer size based on their memory constraints.

Signed-off-by: Rithic Chellaram Hariharan <gr8rithic@gmail.com>
2026-05-05 14:05:55 -05:00
Jamie McCrae
a64883ef5d mgmt: mcumgr: grp: os_mgmt: Fix MPSTAT invalid map
Fixes wrongly having an extra map entry for this response

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-05-05 14:05:44 -05:00
Emil Gydesen
382e2efd33 Bluetooth: BAP: Shell: rm unused right_ring_buf_fail_cnt
The right_ring_buf_fail_cnt field was never read.
Remove the dead field.

Assisted-by: Claude:claude-sonnet-4.6

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-05-05 16:03:42 +01:00
Emil Gydesen
8fc67e6e31 Bluetooth: Audio: add ARG_UNUSED to unused function parameters
Apply ARG_UNUSED() to unused function arguments as per the Zephyr
coding guidelines

A few functions were modified to remove unused parameters
or to actually use the parameters.

Assisted-by: GitHub Copilot

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-05-04 22:08:33 +02:00
Fin Maaß
22947e1019 usb: host: shell: fix level of printed messages
fix level of printed messages.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-05-04 22:08:01 +02:00
Emil Gydesen
44c50815e6 Bluetooth: MCC: Shell remove unused MCC track segments cache
Remove unused field

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-05-04 22:07:39 +02:00
Emil Gydesen
f1d872ebf4 Bluetooth: BAP: BA: remove unused scanning field
The scanning field was set to false in broadcast_assistant_reset() but
never read anywhere. The scanning state is tracked via the
BAP_BA_FLAG_SCANNING atomic bit; the bool field is leftover dead code.

Assisted-by: Claude:claude-sonnet-4.6

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-05-04 22:07:31 +02:00
Bhavin Umatiya
29cbe1d5b8 Bluetooth: Controller: Introduce timer tick conversion define
Introduce HAL_EVENT_TIMER_US_TO_TICKS macro to explicitly map the 1 MHz
hardware timer resolution to the radio configuration, preventing unintended
unit mixing between microseconds and hardware ticks.

Fixes #105085

Signed-off-by: Bhavin Umatiya <umatiyabhavin@gmail.com>
2026-05-04 21:55:03 +02:00
Jukka Rissanen
7d0ba33997 net: shell: dns: The list sub-command was giving wrong advice
User must enable CONFIG_DNS_SD option to enable the "list"
sub-command for the "dns" command.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 15:03:30 +02:00
Jukka Rissanen
57ce922032 shell: Check return code from api read()
Make sure to check the return code from sh->iface->api->read()
and bail out if there is an error. The issue was noticed in ssh
client testing where the ssh shell was terminated which then caused
a forever loop.

Signed-off-by: Grant Ramsay <grant.ramsay@hotmail.com>
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 15:00:15 +02:00
Emil Gydesen
2b7eaa153b Bluetooth: BAP: remove unused broadcast_sink from bt_bap_ep
The broadcast_sink pointer was written in three places (set and
cleared) in bap_broadcast_sink.c but never read or dereferenced
anywhere in the codebase. Remove the field, its three write sites,
and the now-unneeded forward declaration of struct bt_bap_broadcast_sink
in bap_endpoint.h.

Assisted-by: Claude:claude-sonnet-4.6

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-05-04 14:59:29 +02:00
Jukka Rissanen
81f336adac net: quic: Move PSA key import into private key setup
Refactor the QUIC TLS credential path so private-key parsing and PSA
signing-key import happen in tls_set_private_key().

The previous flow parsed the certificate in tls_add_own_cert(), parsed
the private key in tls_set_private_key(), and then called
quic_tls_set_own_cert() later from init and credential refresh paths
even though that helper no longer installed the certificate. Its real
work was importing the private key into PSA, which made the control
flow harder to follow and duplicated private-key parsing.

Move the signing-key import into tls_set_private_key(), remove the
misleading follow-up quic_tls_set_own_cert() calls, and drop the now
unused raw-key bookkeeping from the TLS context. This keeps
certificate handling in the certificate loader and private-key
handling in the private-key loader while preserving the existing
handshake behavior.

Assisted-by: Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 14:57:59 +02:00
Jukka Rissanen
06dcd3e48a net: quic: Clarify STREAM protocol-error handling
Add a dedicated STREAM frame error helper and use it at both STREAM
dispatch sites in quic_packet.c.

STREAM handling already uses -EPROTO to mean that a specific transport
close was attempted by the lower-level handler, for example on stream
limit or receive-side flow-control violations. The previous open-coded
special case worked, but it left that contract implicit and routed the
other STREAM errors differently from the rest of the frame handlers.

Make the contract explicit in one helper: keep -EPROTO as the
close-already-sent path for STREAM, and continue mapping malformed
STREAM frames through the generic frame-encoding error handling.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 14:57:59 +02:00
Jukka Rissanen
3d63d37eb0 net: quic: Harden anti-amplification budget check
Avoid adding the requested send size directly to the tracked
anti-amplification TX count when checking whether an unvalidated
server endpoint may transmit.

The tracked counters are small in practice, but the helper accepts a
size_t byte count and the previous uint64_t addition could wrap for a
very large input on 64-bit builds. Rework the check to compare the
requested size against the remaining budget instead.

Add regression coverage that passes SIZE_MAX to the helper and
verifies the request is rejected rather than wrapping into an allowed
send.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 14:57:59 +02:00
Jukka Rissanen
8b1adba5a4 net: quic: Skip close on synthetic rx endpoints
Guard the flow-control error close paths in quic_stream_receive_data()
so they only send CONNECTION_CLOSE for socket-backed endpoints.

The Quic unit tests exercise receive-side flow-control handling with
synthetic endpoints that set sock = -1 and do not initialize recovery
state. Sending CONNECTION_CLOSE from those paths can reach recovery
shutdown and touch an uninitialized lock even though no transport
packet can be sent.

Keep returning -EPROTO for the protocol violation, but skip the close
when the endpoint is not fully usable for transport I/O. Add coverage
for the RX buffer overflow path and assert that synthetic endpoints do
not enter recovery shutdown on these fatal receive errors.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 14:57:59 +02:00
Jukka Rissanen
d9698f5143 net: quic: Handle version checks before Initial validation
Process Version Negotiation and unsupported-version long headers before
applying Quic v1 Initial-specific checks in process_long_header().

Version Negotiation packets randomize the long-header type bits, so
they can look like Initial packets during early parsing. Checking the
Initial DCID minimum length first can therefore reject Version
Negotiation packets, or other unsupported versions, before they reach
the correct version-handling path.

Move the version check ahead of the Initial DCID length validation and
add regression coverage for Version Negotiation and unsupported-version
packets whose type bits decode as Initial.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 14:57:59 +02:00
Jukka Rissanen
92b9a43849 net: quic: Require peer certificates when verification is enabled
Reject empty TLS Certificate messages when peer verification is
required, instead of accepting them and continuing without a captured
peer certificate.

Also add a defensive check in the Finished path so a peer cannot
complete the handshake without ever providing a certificate when the
effective verify policy requires one.

Add focused regression coverage for both cases: an empty Certificate
message and a Finished message received without any peer certificate.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 14:57:59 +02:00
Jukka Rissanen
73de51b9cf net: quic: Clarify RX flow-control offset accounting
Rename the per-stream RX flow-control counter to fc_bytes_received
to make it clear that the value tracks consumed flow-control credit,
not only contiguous payload bytes delivered to the application.

Document in quic_stream_receive_data() that Quic RX flow control is
based on absolute byte offsets. When a newly received frame advances
the highest received offset on a stream, any gap up to that offset
also consumes flow-control credit, while duplicate data must not be
counted twice.

Add regression coverage for gap accounting. The new test verifies
that out-of-order data consumes stream and connection flow-control
credit up to the new highest offset, that later filling the gap does
not double-count, and that further extension past the limit is
rejected.

Assisted-by: Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 14:57:59 +02:00
Jukka Rissanen
b9c3f4b138 net: quic: Reject unbufferable out-of-order stream data
When quic_stream_receive_data() cannot buffer a new out-of-order
STREAM segment, it currently returns -EAGAIN. The packet is then
treated as valid and ACKable even though the data was dropped and
not counted toward stream or connection flow control.

Treat queue-full and oversized out-of-order segments as
FLOW_CONTROL_ERROR instead. Keep duplicate already-buffered segments
non-fatal, but stop ACKing new data that could not be retained.

Add regression coverage for duplicate, queue-full, and oversized
out-of-order receive cases.

Assisted-by: Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 14:57:59 +02:00
Jukka Rissanen
5d7bf7f25c net: quic: Refresh TLS credentials after sec_tag update
Reload TLS credentials when ZSOCK_TLS_SEC_TAG_LIST is updated on an
already initialized Quic TLS context, and make the Quic test helper
apply the configured security tags through setsockopt().

This keeps certificate configuration consistent between server and
client paths and avoids stale credential state when TLS options are
set after endpoint creation.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 14:57:59 +02:00
Jukka Rissanen
ee347805b4 net: quic: Harden CRYPTO frame reassembly
Compare overlapping CRYPTO data against buffered bytes and fail
closed on mismatches.

Map CRYPTO reassembly overflow to CRYPTO_BUFFER_EXCEEDED, stop
silently ignoring out-of-order reassembly bookkeeping failures, and
add compile-time guards for the current metadata widths.

Add tests for duplicate overlap, conflicting overlap, and buffer
overflow handling.

Assisted-by: Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 14:57:59 +02:00
Jukka Rissanen
75d86867df net: quic: Fix PTO / recovery concurrency
Recovery state is now serialized with a per-endpoint mutex.

PTO runs on a private QUIC recovery workqueue instead of
k_sys_work_q, and endpoint teardown / connection close now use
synchronous PTO cancellation.

The PTO handler no longer drops the endpoint reference from inside
the running work item. On excessive PTO it marks recovery closed,
notifies streams, and defers final unref through separate work so
the embedded delayable is not freed while active.

Recovery tracking is also gated once shutdown begins, and a new test
verifies that shutdown suppresses new in-flight tracking.

Assisted-by: Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 14:57:59 +02:00
Jukka Rissanen
b84cb2f8bb net: quic: Harden frame parsing
Make quic_put_varint() return an error when the destination buffer
is too small and update callers to validate the result.

Validate frame types by packet number space so forbidden frames
close with PROTOCOL_VIOLATION and unknown or malformed frames close
with FRAME_ENCODING_ERROR.

Also harden malformed CONNECTION_CLOSE parsing and add direct tests
for the new parser behavior.

Assisted-by: Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 14:57:59 +02:00
Jukka Rissanen
bc06869cbb net: quic: Adjust peer cert verification defaults
Peer certificate verification follows the same default policy as
Zephyr TLS sockets: clients require successful peer verification
by default, while servers default to not verifying client
certificates unless ZSOCK_TLS_PEER_VERIFY is explicitly enabled.
A client that does not load a CA certificate therefore fails the
handshake by default; applications that deliberately skip server
authentication must opt out by setting
ZSOCK_TLS_PEER_VERIFY = MBEDTLS_SSL_VERIFY_NONE.

Assisted-by: Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 14:57:59 +02:00
Jukka Rissanen
27d7693af9 net: quic: Notify application if handshake fails
Wake any client-side stream_open() waiters that are still blocked on
the handshake outcome.

Assisted-by: Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 14:57:59 +02:00
Jukka Rissanen
9d0daecd81 net: quic: Receive-side flow control enforcement
A receiver advertises two credits, per-stream
(initial_max_stream_data_*, updated by MAX_STREAM_DATA) and
per-connection (initial_max_data, updated by MAX_DATA). An
endpoint MUST NOT allow the largest received byte offset on a
stream to exceed the stream limit (§4.1), MUST NOT allow the sum of
received offsets across streams to exceed the connection limit (§4.1),
and MUST close with FLOW_CONTROL_ERROR (0x03, §11.2) on
violation. The check is on wire offsets, not on what fits locally.

The code did not do the checks properly for RX data.

Assisted-by: Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 14:57:59 +02:00
Jukka Rissanen
9666457921 net: quic: Document unsupported token handling
Clarify in the public API and Kconfig help that server mode can send
Version Negotiation and enforce anti-amplification, but Retry and
NEW_TOKEN-based address-validation tokens are not yet implemented.

Also warn when an Initial packet carries a token that the current
implementation does not process.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 14:57:59 +02:00
Jukka Rissanen
abc450c7ff net: quic: Enforce initial minimum DCID length
Initial packet DCID must be >= 8 bytes long. Enforce that
and test it too.

Assisted-by: Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 14:57:59 +02:00
Jukka Rissanen
3f849e3cf9 net: quic: Add version negotiation support
Make sure we send proper version negotiation packet if
we receive a Quic version packet that we do not support.

Add tests that make sure version negotiation works ok.

Assisted-by: Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 14:57:59 +02:00
Jukka Rissanen
bbcc739095 net: quic: Add server anti amplification support
Enforce RFC 9000 Section 8.1 by limiting server transmission to
three times the bytes received from an unvalidated client address.

Gate the behavior behind CONFIG_QUIC_SERVER_ANTI_AMPLIFICATION_LIMIT
to preserve feature-testing scenarios that intentionally bypass the
limit.

Add tests that verify the anti-amplification budget handling.

Assisted-by: Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-04 14:57:59 +02:00
Fin Maaß
93c9f62c65 net: if: simplify NET_IF_INIT and NET_IF_OFFLOAD_INIT macros
NET_IF_MAX_CONFIGS is always 1, therefore the NET_IF_INIT and
NET_IF_OFFLOAD_INIT macros can be simplified by removing the array and
using a single struct net_if and struct net_if_dev instead.

This also removes the use of designated initializers with ranges, which
is a GNU extension.
https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-05-04 14:55:03 +02:00
Fin Maaß
1bb2215a45 net: wifi: also add struct net_if to struct wifi_mgmt_ops
as the ethernet api already includes
struct net_if as a argument for its
functions also add it to struct wifi_mgmt_ops.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-05-04 14:55:03 +02:00
Fin Maaß
db984ee196 net: l2: ethernet: add struct net_if to arguments
add struct net_if to arguments

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-05-04 14:55:03 +02:00
Alexios Lyrakis
1cf1de81a1 arch: riscv: add Supervisor-mode (S-mode) support
Introduce CONFIG_RISCV_S_MODE to select Supervisor-mode execution.
Add depends on !RISCV_S_MODE to RISCV_PMP since PMP CSRs are
inaccessible from S-mode.

Add an M-mode SBI shim (reset.S + sbi.S) that configures exception
delegation, PMP, and counter access before dropping to S-mode via mret.
The shim handles SBI_SET_TIMER ecalls from S-mode and forwards MTIP to
STIP so the supervisor timer driver works without a full SBI firmware.

Introduce privilege-level abstractions in isr.S (RV_CAUSE, RV_EPC,
RV_STATUS, RV_TVAL, etc.) and update all runtime code that previously
accessed M-mode-only CSRs (mcause, mtval, mstatus, mie, mip) to use the
S-mode equivalents when CONFIG_RISCV_S_MODE is set.

ARCH_EXCEPT in kernel context uses ebreak (cause=3, Breakpoint) instead
of a direct z_riscv_fatal_error() call.  In S-mode, ecall (cause=9) is
kept in M-mode for SBI and never reaches the S-mode exception handler;
a direct call with NULL esf caused the stack unwinder to crash into an
infinite fault loop.  ebreak is delegated to S-mode by our medeleg
configuration; isr.S treats ebreak with t0=RV_ECALL_RUNTIME_EXCEPT the
same way M-mode treats ecall-based ARCH_EXCEPT.

Signed-off-by: Alexios Lyrakis <alexios.lyrakis@gmail.com>
2026-05-04 14:54:52 +02:00
Pieter De Gendt
70634e33e2 net: lib: coap: client: Add deregister for observe requests
If a user created an observe request, that is kept alive, it's not easy to
notify the server to stop the observe.

Add a function that sends a GET with the observer option set to 1 prior
to internal cleanup.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-05-01 16:23:08 -05:00
Alperen Sener
246050f7f9 bluetooth: host: Add missing pending IRK update call for ext adv start
Adds IRK update call to internal bt_le_adv_start_ext. And rename it to
adv_start_ext to prevent confusion with public functions.

There are two paths to start ext advertising:
- bt_le_adv_start can start extended advertising if enabled by calling
internal bt_le_adv_start_ext else it starts legacy advertisements.
- bt_le_ext_adv_start specifically starts extended advertisements.

This commit misses the first path for ext advertisement:
6d137ae015

Signed-off-by: Alperen Sener <alperen.sener@nordicsemi.no>
2026-05-01 16:22:32 -05:00
Johann Fischer
ecbae771d8 usb: host: allow shell to select and use any host context
Add a command to select the USB host context, similar to the select
command in device support. Set the USB host context used by the shell to
the first entry in the section by default. The USB host context defined
in the shell is not necessary anymore and is moved to the sample code.
This has a very small impact on the user. The way the host shell
commands are used has not changed.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2026-05-01 16:21:57 -05:00
Nicolas Pitre
e81266be2b arch: add arch_cpu_irqs_are_enabled() primitive
Introduce an architecture API that reports the calling CPU's current
interrupt-enable state without modifying it. Unlike arch_irq_unlocked()
which inspects a saved key, this one probes the live CPU register, which
lets callers avoid the lock/unlock dance when all they need is to test
whether IRQs are currently masked.

Most arches can serve this from a single register read (DAIF on arm64,
PRIMASK/BASEPRI/CPSR on arm, mstatus on riscv, PS on xtensa, STATUS32
on arc, c0_status on mips, SPR_SR on openrisc, PSW on rx, EFLAGS on
x86). SPARC, POSIX, and riscv with custom SoC IRQ-lock ops have no
direct probe and fall back to a brief arch_irq_lock()/unlock() pair.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-05-01 11:18:04 -05:00
Jordan Yates
ef47bdf328 net: sntp: fix close-while-polling in sntp_close_async
Fix `sntp_close_async` closing the socket while the socket service is
still polling it by deferring the close operation to the socket service.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-05-01 12:41:27 +01:00
Jordan Yates
c0f6730cb5 net: socket_service: API to unregister and close socket
Closing a socket while it is being polled by another thread is
discouraged and should be avoided. This results in a problem when
attempting to unregister a service via `net_socket_service_unregister`,
the caller has no way of knowing when the socket service has stopped
polling on the socket and it is safe to close.

Solve this issue by introducing `net_socket_service_close`, which
signals the socket service to automatically close the sockets associated
with the service when it stops polling them.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-05-01 12:41:27 +01:00