Commit graph

24,075 commits

Author SHA1 Message Date
Pieter De Gendt
139e2f269d net: lib: coap: client: Calculate next resend timeout
Instead of waiting the full socket poll period, calculate the next timeout
to resend messages.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-04-14 22:37:40 -04:00
Pieter De Gendt
76c7c84daf net: lib: coap: client: Reset canceled requests instead of release
Clear the request slot if we cancel them. release_internal_request is
wrong for cancel: Its purpose is to keep token/MID data so late responses
can be matched. But handle_response just silently drops responses for
released slots anyway.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-04-14 22:37:40 -04:00
Szymon Janc
97a39757e2 Bluetooth: Shell: Fix crash in connect command
When address type was not provided calling bt_do_connect_le
leads to crash due to reading argv[2].

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2026-04-14 22:36:10 -04:00
Jedrzej Czykier
ac3eb6d478 instrumentation: kconfig: disable dynamic trigger by default
INSTRUMENTATION_DYNAMIC_TRIGGER currently always defaults to 'y', which
forcefully selects RETAINED_MEM and related drivers. This causes
Kconfig warnings on boards lacking the required `zephyr,retained-ram`
devicetree nodes.

Since this feature relies on specific hardware configurations, it
should be enabled by default only if such configuration is present.

Signed-off-by: Jedrzej Czykier <jczykier@antmicro.com>
2026-04-14 22:35:54 -04:00
Andrii Chmutov
c02bf19bfd instrumentation: kconfig: select UART_CONSOLE
Select `UART_CONSOLE` when instrumentation is enabled. Similarly to
`UART_INTERRUPT_DRIVEN`, this option is required for host-device
communication via UART.

Signed-off-by: Andrii Chmutov <achmutov@antmicro.com>
2026-04-14 22:35:54 -04:00
Egill Sigurdur
50cf2ba410 net: sockets: support FIONWRITE ioctl for TCP
Add support for getting the number of bytes queued for TCP TX
that have not yet been acknowledged. Follows FreeBSD's API.

Signed-off-by: Egill Sigurdur <egill@egill.xyz>
2026-04-14 22:34:42 -04:00
Guðni Már Gilbert
04ab47f24d build: avoid including unnecessary directories
Folders which have menuconfig can be conditionally included

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2026-04-14 22:32:15 -04:00
Nikhil Namjoshi
d619f4e501 net: Add net_pkt_set_data API return error handling
There some more instances of net_pkt_set_data API
whose return code is not being checked.

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-14 22:31:56 -04:00
Nikhil Namjoshi
87bab421db net: Add net_pkt_write API return error handling
There some more instances of net_pkt_write API
whose return code is not being checked.

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-14 22:31:56 -04:00
Nikhil Namjoshi
79f363da92 net: Add net_pkt_acknowledge_data API return error handling
There some more instances of net_pkt_acknowledge_data
API whose return code is not being checked.

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-14 22:31:56 -04:00
Nikhil Namjoshi
2a055077dc net: Add net_pkt_skip API return error handling
There some more instances of net_pkt_skip API whose
return code is not being checked.

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-14 22:31:56 -04:00
Yangbo Lu
bb599be0b3 net: ptp: handle GRAND_MASTER state properly in state machine
In IEEE 1588 standard, there was actually no GRAND_MASTER port state.
We should treat GRAND_MASTER as same as MASTER state (TIME_TRANSMITTER)
in code.

So, added the case PTP_PS_GRAND_MASTER handling same with
PTP_PS_TIME_TRANSMITTER. Otherwise port entering PTP_PS_GRAND_MASTER
won't go out of the state. Also removed switching PTP_PS_TIME_TRANSMITTER
to PTP_PS_GRAND_MASTER which was useless.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-04-14 22:30:42 -04:00
Tomi Fontanilles
6b1d0f010b secure_storage: its_transform: aead: enable PSA_CRYPTO
This implementation relies on PSA Crypto. Make sure it's enabled.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2026-04-14 22:30:32 -04:00
Maochen Wang
8afc59276f random: select CONFIG_PSA_CSPRNG_GENERATOR if ENTROPY_NEEDS_PRNG
MCUX TRNG triggers hardware errors (TRNG_MCTL_ERR) when used as
continuous random source via HARDWARE_DEVICE_CS_GENERATOR, causing
sys_csrand_get() assertion failures.
On platforms where CONFIG_ENTROPY_NEEDS_PRNG is set 'sys_csprng_get()'
cannot poll directly the entropy device, but it needs to apply some
PRNG on top of it. Therefore enable CONFIG_PSA_CSPRNG_GENERATOR.
Fixes #107087

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
2026-04-14 22:30:25 -04:00
Martin Stumpf
10989f9702 settings: runtime: fix nullpointer dereference in settings_runtime_set
When `h_set` is unset in the handler (which is allowed according to the
docs), then this function causes a nullpointer dereference because
it has no check for this.

This change applies the behavior of `settings_runtime_get` to
`settings_runtime_set` to catch this case as expected.

Signed-off-by: Martin Stumpf <finomnis@gmail.com>
2026-04-14 22:29:31 -04:00
Jordan Yates
2bdcf37f99 modem: cellular: fix dormant state control
According to the networking documentation:

> The network association status is represented with NET_IF_DORMANT flag

Therefore, the flag should be set at any time that the network is not
associated with. This is achieved by setting the flag at boot, and only
controlling the dormant state at entry/exit from the `REGISTERED` state.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-04-14 22:28:46 -04:00
Nicholas Lowell
9369f96a6c ipc: open-amp: make vring alignment configurable
allow for configurable vring alignment for better system
flexibility instead of hard-coded 16 byte alignment
which could be unacceptable for cache-managed systems of different
cache-line sizes

Signed-off-by: Nicholas Lowell <Nicholas.Lowell@lexmark.com>
2026-04-14 22:28:37 -04:00
Ofir Shemesh
cd85e0e890 net: tcp: fix use-after-free in net_tcp_foreach()
net_tcp_foreach() drops tcp_lock before the callback and re-acquires
it afterwards. A concurrent tcp_conn_release() can free the next
node cached by SYS_SLIST_FOR_EACH_CONTAINER_SAFE during this window,
causing the iterator to follow a dangling pointer on the next
iteration.

Move context teardown in tcp_conn_release() inside the tcp_lock
critical section and keep tcp_lock held across the callback in
net_tcp_foreach(). No current callback acquires tcp_lock.

Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
2026-04-14 22:28:30 -04:00
Johan Hedberg
f9745c72b7 Bluetooth: Host: Fix missing responder address type
One of the branches in the Enhanced Connection Complete HCI event handler
was only partly setting the responder address, i.e. setting the address
value but not the address type. The comment above indicates that the code
expected the Advertising Set Terminated event handler to take care of the
rest, but it's still not ideal that in the intermediate state this field
doesn't contain a valid address (it would indicate a public address type
but with the RPA value).

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-04-14 22:28:21 -04:00
Johan Hedberg
4228c796e3 Bluetooth: Controller: shell: Use inline string conversion helper
Take advantage of the new inline address to string conversion helper,
since it eliminates the need to explicitly declare a buffer variable on
the stack.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-04-14 22:24:10 -04:00
Johan Hedberg
a3e1e6a69e Bluetooth: audio: Take advantage of the new inline string helpers
Take advantage of the new string conversion helpers to avoid having to
declare explicit on-stack variables.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-04-14 22:24:10 -04:00
Johan Hedberg
7b7c746cd5 Bluetooth: Host: Take advantage of the new inline string helpers
Take advantage of the new string conversion helpers to avoid having to
declare explicit on-stack variables.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-04-14 22:24:10 -04:00
Johan Hedberg
0a59ae3155 Bluetooth: Host: Add inline string conversion helper for connections
Add a helper API to convert inline (on the stack) the peer address of a
connection to a string.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-04-14 22:24:10 -04:00
Johan Hedberg
9197132047 Bluetooth: Introduce public address to string inline APIs
The Bluetooth stack has until now had private helpers to return an inline
pointer to a string - something which can be useful e.g. as part of
printk()/printf() call parameters. The reason these were never made public
is that they are not safe when a format string contains more than one
invocation of these.

This commit introduces replacement APIs which allocate an on-stack buffer,
thereby allowing arbitrary number of calls within the parameters of an
output formatting call. The new APIs are defines, since the solution uses
an encapsulating struct to force an on-stack copy, which then requires a
translation to access the struct-internal string member variable.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-04-14 22:24:10 -04:00
Muhammad Waleed Badar
ab32cd6fb8 net: shell: add HTTP client shell commands
Add HTTP client shell commands under the 'net http' subcommand group.
Supports GET, POST, PUT, and DELETE methods.

Commands:
  net http get <url>
  net http post <url> <body>
  net http put <url> <body>
  net http delete <url>

Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
2026-04-14 22:22:41 -04:00
Emil Gydesen
f1320a331e Bluetooth: Services: Replace CHECKIF with if
The usage of CHECKIF has been replaced with a regular
if. The reason for this is that higher layer may depend
on some of the checks defined by the API, and the higher
layers cannot do that properly if the checks can be
removed via a Kconfig option.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-14 22:21:26 -04:00
Savo Saicic
10d7d7ddd5 net: lwm2m: add IPSO Time object support
This Object allows an LwM2M server to read and synchronize the device
current time.

Signed-off-by: Savo Saicic <savo.saicic@gmail.com>
2026-04-14 22:20:52 -04:00
Kai Cheng
7f6ef32400 Bluetooth: Shell: Add write-eir-name command for BR/EDR
Add a new bt write-eir-name shell command to set the Extended
Inquiry Response (EIR) name for BR/EDR connections.

Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
2026-04-14 22:14:25 -04:00
Kai Cheng
c515cfc862 Bluetooth: Classic: add extended inquiry response support
Add bt_br_write_eir() API to set the extended inquiry response (EIR)
data for BR/EDR device discovery. EIR allows remote devices to
obtain more information during the inquiry process without needing
to establish a connection.

Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
2026-04-14 22:14:25 -04:00
Johann Fischer
8d2cc34ecf usb: device_next: allow cdc_acm_poll_in() to receive
Allow cdc_acm_poll_in() to receive when CDC ACM function gets enabled,
but only when the IRQ API is not already used.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2026-04-14 22:08:22 -04:00
Emil Gydesen
8fce7382ba Bluetooth: BAP: Broadcast: Add assert for subgroup == NULL
Add an initial assign and check for subgroup == NULL before
calling  SYS_SLIST_PEEK_NEXT_CONTAINER as some compilers
consider subgroup otherwise considers it uninitialized:

In function ‘z_snode_next_peek’,
    inlined from ‘sys_slist_peek_next_no_check’ at
	/__w/zephyr/zephyr/include/zephyr/sys/slist.h:281:1,
    inlined from ‘sys_slist_peek_next’ at
	/__w/zephyr/zephyr/include/zephyr/sys/slist.h:292:1,
    inlined from ‘bt_bap_broadcast_source_reconfig’ at
	/__w/zephyr/zephyr/subsys/bluetooth/audio/bap_broadcast_source.c:1008:15:
/__w/zephyr/zephyr/include/zephyr/sys/slist.h:213:20: error:
	‘subgroup’ may be used uninitialized [-Werror=maybe-uninitialized]
  213 |         return node->next;
      |                ~~~~^~~~~~
/__w/zephyr/zephyr/subsys/bluetooth/audio/bap_broadcast_source.c:
	In function ‘bt_bap_broadcast_source_reconfig’:
/__w/zephyr/zephyr/subsys/bluetooth/audio/bap_broadcast_source.c:975:43:
	note: ‘subgroup’ was declared here
  975 |         struct bt_bap_broadcast_subgroup *subgroup;

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-14 22:08:12 -04:00
Emil Gydesen
9969e524ad Bluetooth: BAP: Make codec_cfg param const
Make the codec_cfg parameter of the BAP can CAP APIs const,
as they are now only used as one-time parameters, and not stored.
This also means that any uses of this can place the codec_cfg
parameter in the stack, rather than static memory.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-14 22:08:12 -04:00
Emil Gydesen
b1c2d5450e Bluetooth: BAP: Make bt_bap_stream.codec_cfg const
The pointer represent the codec configuration
for a stream based on the ASE or broadcast configuration,
and serves as a read-only value. Changing it to `const` makes
this more clear.

Some minor changes were done to existing code to help
support this change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-14 22:08:12 -04:00
Emil Gydesen
0f400e0c1e Bluetooth: BAP: Fix issues with codec_cfg pointers
In some cases the codec_cfg pointer pointed to the
codec_cfg argument, and sometimes it pointed to the ep->codec_cfg.

Now all codec_cfg arguments are copied to ep->codec_cfg, and
stream->codec_cfg always points to stream->ep.codec_cfg.

This also fixes a bug where metadata updates initiated
by the server was not properly stored by the client.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-14 22:08:12 -04:00
Mark Wang
040c811210 bluetooth: avdtp: Rename avdtp_tx_signal to avdtp_tx_single
The function name `avdtp_tx_signal` is misleading as it is used to
transmit single-fragment packets, not specifically signal packets.
Rename it to `avdtp_tx_single` to better reflect its actual purpose
and improve code clarity. Rename `avdtp_tx_frags` as `avdtp_tx_multi`
because AVDTP spec use `multi`.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2026-04-14 22:07:18 -04:00
Emil Gydesen
656d29b799 Bluetooth: MCS: Protect resources by mutex
Some resources in MCS were accessed (both read and write) by
multiple threads without any thread protection.

This commit adds a mutex to ensure thread safety.
Since the flags were previously using atomic to
prevent race condition between threads, and since there is
now a mutex, those flags have been modified to be simple
boolean values instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-14 22:07:07 -04:00
Marcus Penate
b9d3344fd4 net: coap: add support for CoAP over reliable transports
Add CoAP over TCP/TLS framing, parsing, and client support as
specified in RFC 8323. This includes:

- TCP message framing with variable-length header encoding
- CSM (Capabilities and Settings Message) exchange
- Signaling codes: Ping/Pong, Release, Abort
- CoAP TCP client with blockwise transfer support
- New Kconfig options under CONFIG_COAP_OVER_RELIABLE_TRANSPORT
- Documentation update for CoAP client API

Signed-off-by: Marcus Penate <marcus.penate@ellenbytech.com>
2026-04-14 22:06:34 -04:00
Kai Cheng
943d7f4e62 Bluetooth: Classic: add write supervision timeout feature
Add bt_conn_br_set_supervision_timeout() API to configure the
link supervision timeout for a BR/EDR connection via the HCI
Write Link Supervision Timeout command.

Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
2026-04-14 22:05:26 -04:00
Kai Cheng
647c650eae Bluetooth: Classic: add read supervision timeout feature
Add bt_conn_br_get_supervision_timeout() API to read the current
link supervision timeout value for a BR/EDR connection via the
HCI Read Link Supervision Timeout command.

Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
2026-04-14 22:05:26 -04:00
Anas Nashif
b474cfc2b6 posix: move posix to subsys/portability
Posix is not a library per the definition of libraries in Zephyr. It
always has been a portability layer and shall reside with other
portability layers under subsys/portability.

Addresses #99250

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-04-14 22:03:46 -04:00
Benjamin Cabé
ac64436ff8 testsuite: ztest: benchmark: document CSV output column names
Expand the ZTEST_BENCHMARK_OUTPUT_CSV Kconfig help text to describe the
two CSV row formats (sampled and timed) so that users don't have to
reverse engineer them by looking at the code.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-04-13 11:07:02 -05:00
Javier Romera
5184eac621 logging: fix starvation caused by uncommitted message
Fix a scenario where the logging thread can enter an infinite
loop and starve lower-priority threads when encountering an
uncommitted log message.

If a lower-priority thread is preempted before committing a
message, and a higher-priority thread triggers log processing,
the logging thread may repeatedly attempt to claim it. Since the
message is pending but not committed, z_log_msg_claim() returns
NULL while z_log_msg_pending() remains true, resulting in a
livelock.

Update the log processing logic to avoid looping on uncommitted
messages, allowing lower-priority threads to resume and complete
the commit.

Fixes #101401

Signed-off-by: Javier Romera <lromerajdev@gmail.com>
2026-04-11 10:19:17 -04:00
Li Jie
f1541d3b25 logging: avoid self-deadlock in immediate mode with clean output
When CONFIG_LOG_MODE_IMMEDIATE and CONFIG_LOG_IMMEDIATE_CLEAN_OUTPUT
are enabled, log messages are processed synchronously and serialized
across CPUs using a global spinlock (process_lock).

In this configuration, if a fatal exception (e.g. stack overflow
triggering a PMP fault on RISC-V) occurs while the current context
already holds process_lock, the fatal error handler may attempt to
log diagnostic messages. This leads to a recursive attempt to acquire
the same spinlock from the same CPU, resulting in a self-deadlock.

This issue is not limited to a specific architecture. It can occur on
any platform where logging is invoked from a fatal or exception context
while the lock is already held.

Fix this by introducing a lightweight owner tracking mechanism for
process_lock. The current CPU ID is stored when the lock is acquired,
and if the same CPU attempts to acquire the lock again, the lock
operation is bypassed to avoid self-deadlock.

This preserves strict log ordering across CPUs during normal operation,
while ensuring that logging remains safe and non-blocking in fatal or
exception contexts.

Signed-off-by: Li Jie <lijie.1996@picoheart.com>
2026-04-07 15:36:25 -04:00
Nicolas Pitre
1c9955a060 pm: shell: hold sys_clock_lock() around timer driver calls
sys_clock_set_timeout() and sys_clock_elapsed() are now documented
as requiring the system clock lock to be held by the caller. Wrap
the calls in subsys/pm/pm.c, soc/nxp/rw/power.c and the kernel
shell thread list command with sys_clock_lock()/sys_clock_unlock().

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-04-07 11:40:49 -05:00
Robert Lubos
8588b08808 net: tcp: Fix TCP context cleanup during async handshake
In case socket is closed during an async TCP handshake, the TCP context
should be closed immediately, otherwise the connection could be
established after the socket was closed, causing TCP context leak.
To avoid race between socket close and resend timer (i.e. socket being
closed at the same time as the retransmission limit is reached), add
extra state checks before attempting to close the TCP context.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-04-07 11:38:18 -05:00
Vytautas Virvičius
1ea30bf774 net: http_client: Fix body_frag_len overcounting with chunked TE
body_frag_len was computed using a raw buffer offset formula:

  body_frag_len = data_len - (body_frag_start - recv_buf)

This is correct for Content-Length responses: the recv buffer contains
only decoded body bytes after the headers, so the offset arithmetic
gives the exact body byte count.

It is broken for Transfer-Encoding: chunked.  RFC 7230 §3.3.2 makes
the two mutually exclusive, so chunked TE never comes with a
Content-Length.  With chunked TE, the recv buffer contains both the
decoded body bytes and the chunk framing bytes (chunk-size line, CRLF
body-terminator, terminal chunk "0\r\n\r\n") side by side.  The
formula counts everything from body_frag_start to the end of the
buffer fill, so it includes the framing bytes that follow the body,
causing body_frag_len to overcount.

http_parser already knows the exact decoded body byte count: it passes
it as the length argument to on_body(). Use that instead.

Add a regression test that sends a single chunked 206 response from a
raw loopback TCP server in one write, so the chunk terminator and
terminal chunk land in the same recv buffer as the body.  The test
asserts body_frag_len equals the decoded body size, not body size + 7
framing bytes.

Signed-off-by: Vytautas Virvičius <vytautas@virvicius.dev>
2026-04-07 11:37:19 -05:00
Maximilian Zimmermann
93411b3a23 Bluetooth: TBS: replace GTBS/TBS instance locks with global lock
Remove separate instance locks and replace all locking
and unlocking with a single global lock.

Signed-off-by: Maximilian Zimmermann <gitmz@posteo.de>
2026-04-07 11:33:13 -05:00
Cristian Bulacu
2952c2478d net: dns: Forward all DNS packets if callback is installed
This PR enables the DNS packet forwarding without taking into account
the return value of `dns_validate_msg` function.
This is to accomodate scenarios like where ANCOUNT is set to 0, or other
cases in which internal DNS implementation will not validate the
message.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2026-04-07 08:41:50 -05:00
Jamie McCrae
e6b27b3492 dfu: img_util: Fix partition detection
Fixes the logic in detecting which partition is being executed
from, also fixes a test for this feature

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-04-07 08:32:23 -05:00
Jordan Yates
c010567673 lorawan: services: LITTLE_ENDIAN dependency
Add a `LITTLE_ENDIAN` dependency to `LORAWAN_FRAG_TRANSPORT` due to the
use of bitfields and packed structures in decoding on-air payloads.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-04-07 08:31:51 -05:00