Commit graph zephyr/subsys
Author SHA1 Message Date
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
Jordan Yates
099dd4509f lorawan: services: update fragmented transport parsing
Update the fragmented data transport parsing to always consume complete
control messages, regardless of any validation errors. Simplify the
implementation of this by defining the packets as packed structures.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-04-07 08:31:51 -05:00
Jordan Yates
25c395b066 lorawan: services: frag_transport: define status bits
Define status bits as enumerations, instead of using `BIT` directly in
the code.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-04-07 08:31:51 -05:00
Ashirwad Paswan
38763c33d1 fs: ext2: fix incorrect write length in ext2_inode_write
This commit fixes the bug by ensuring `to_write` is properly bounded.
It is now calculated as the minimum of the remaining requested bytes
(`nbytes - written`) and the remaining space in the current block
(`block_size - block_off`).

Fixes #106276

Signed-off-by: Ashirwad Paswan <ashi06712@gmail.com>
2026-04-04 10:59:13 -05:00
David J. Leach, Jr.
e3645486d1 net: ocpp: replace RPC type magic numbers with symbolic constants
Replace the hardcoded WAMP RPC type values used when encoding OCPP
messages with their corresponding symbolic constants.

- Replace '2' with OCP_WAMP_RPC_REQ
- replace '3' with OCP_WAMP_RPC_RESP

This removes magic numbers and improves human readability.

Signed-off-by: David J. Leach, Jr. <tasmar@gmail.com>
2026-04-04 10:55:08 -05:00
David J. Leach, Jr.
a1585cd5e9 net: ocpp: Protect against static analysis issue generation
Static analysis has a difficult time tracing whether a call to
ocpp_send_to_server() needs to initialize sndlock and rspsig because
the message type is set very much earlier in the program logic flow.
Note that coverity is creating a single issue for sndlock and for rspsig
in each function that calls ocpp_send_to_server() without initializing
them.

Adding a NULL test will prevent future static analysis false positives.

Fixes #100026
Fixes #100025
Fixes #100024
Fixes #100017
Fixes #100015
Fixes #100013
Fixes #100011
Fixes #100010
Fixes #100008
Fixes #100006

Signed-off-by: David J. Leach, Jr. <tasmar@gmail.com>
2026-04-04 10:55:08 -05:00
Nikhil Namjoshi
41082f40fc net: Initialize chksum variable to avoid clang build errors
This addresses clang build failure seen in
https://github.com/zephyrproject-rtos/zephyr/runs/69856219528

after PR #106578 was merged.

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-03 14:58:06 -05:00
Zafer SEN
5f01a3d236 lwm2m: remove redundant NULL check in _INIT_OBJ_RES_INST
Drop the unnecessary _ri_ptr NULL check, as multi-instance resources
always provide a valid instance array when _ri_count > 0. This
simplifies the initialization logic and prevents compile time warrning
messages/noice.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-04-03 14:56:14 -05:00
Taha Benderli
517cfd37d8 net: l2: ethernet: fix order of address check
ethernet_update_tx_stats checks the multicast address first and then the
broadcast which causes the broadcast address to be treated as multicast
and not counted correctly.Fix this by checking broadcast address first,
followed by the multicast address.

Signed-off-by: Taha Benderli <taha.benderli@analog.com>
2026-04-03 23:18:26 +09:00
Nikhil Namjoshi
c12f7b566c net: Add net_pkt_skip error handling
There are several areas in the networking stack where this is missing.
So make sure we add it.

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-03 23:14:47 +09:00
Nikhil Namjoshi
f98624455c net: Update net_calc_chksum to return err code on failure
`net_calc_chksum` is designed to return uint16_t checksum.
Its current behavior is to return 0 checksum on error
(or on an empty payload) and a valid non zero checksum for non empty
payloads. 0 could be a valid checksum for empty payload.

So update the `net_calc_chksum` and its wrapper's definition to
return error codes.

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-03 23:14:47 +09:00
Nikhil Namjoshi
86fd0944c5 net: tcp: Fix potential underflow in tcp data length
tcp_options_len calculation in tcp_data_len can underflow
if th_off(th) is less than 5. This can lead to a huge
tcp_options_len value and subsequently a wrong data length calculation.
Add the checks in tcp_recv() which is a top API, so that the checks
are covered at the entry point.

Fixes https://github.com/zephyrproject-rtos/zephyr/issues/106657

Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
2026-04-03 23:13:33 +09:00
Jordan Yates
07f1481906 storage: stream: stream_flash: check size overflow
Add an initialisation time check for stream flash that the requested
offset and size does not overflow `size_t`. This in turn ensures that
`inspect_device` doesn't erroneously return `0` if the addition would
have overflowed.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-04-03 23:11:34 +09:00
Yangbo Lu
dbdc3939e6 net: qbv_shell: fix variable without initialization
Some variables were used without initialization causing
command failure. Fixed them.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-04-03 23:10:23 +09:00
Artur Dobrynin
eeef8ad2b1 Bluetooth: Host: rotate NRPA
NRPA should be rotated every TGAP(private_addr_int)
according to spec, which is also checked in PTS.

Signed-off-by: Artur Dobrynin <artur.dobrynin@nordicsemi.no>
2026-04-01 15:12:17 -05:00
Zafer SEN
54de0d3d0f lwm2m: connmon: add Link Utilization resource support
Introduce the CONNMON_LINK_UTILIZATION resource to the Connection
Monitoring object. Add backing storage, initialize it during instance
creation, and register it in the resource table.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-04-01 11:52:48 -05:00
Trond F. Christiansen
3aa3b96a93 zbus: proxy agent: Remove unused code
Remove unused code related to zbus_proxy_agent_backend_desc and run-time
backend registration left over from early development.

Signed-off-by: Trond F. Christiansen <trond.christiansen@nordicsemi.no>
2026-04-01 11:49:39 -05:00
Jani Hirsimäki
a85db98380 net: iface: longest-prefix match for net_if_ipv6_addr_onlink()
Select the interface whose on-link prefix has the greatest length when
multiple prefixes match the same address. Fixes wrong iface selection
when a host has several interfaces whose on-link prefixes overlap (e.g.
a shorter prefix on one link and a longer, more specific prefix on
another). Callers that pass iface == NULL still get a boolean only; no
interface pointer is written.

Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
2026-04-01 09:18:32 -05:00
Jukka Rissanen
97e96f2957 net: Remove experimental status from pre-emptive network threads
The support for running network TX/RX threads in pre-emptive way
was introduce in 2020. The experimental status is no longer valid
as the feature has been there for quite some time and it is being tested
also regularly by CI.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-04-01 09:17:53 -05:00
Nicholas Cadieux
4e5cb31d32 usb_c: pe: fix PE state on DRS sender response timeout
When the SenderResponseTimer expires in PE_DRS_SEND_SWAP, PE was
unconditionally transitioning to PE_SNK_READY. This is incorrect when
the port is operating as a Source, as it should return to PE_SRC_READY.

Replace pe_set_state(dev, PE_SNK_READY) with pe_set_ready_state(dev),
which selects the correct ready state based on the current power role.

Signed-off-by: Nicholas Cadieux <ncadieux@qti.qualcomm.com>
2026-03-31 18:24:46 -05:00
Alexander Wachter
a03080b002 usb: usb_c: fix level of vbus check in Attached.SNK
The transition from Attached.SNK to Unattached.SNK is currently
triggered if vbus is < vSafe5V.
USB-Type C Spec R2.4 Table 4-3 defines vSinkDisconnect as
the voltage to be used for the transition from
Attached.SNK to Unattached.SNK
This commit changes the check to use the correct voltage level.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2026-03-31 18:22:17 -05:00
Ederson de Souza
d723a996eb subsys/pmci/mctp: Avoid possible race when enabling MCTP over I3C
Callback for IBI (In-Band Interrupt) was being set after enabling IBI -
which could be an issue if an IBI would be asserted in between enabling
IBI and setting the callback. This patch simply sets the callback before
enabling IBI.

Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2026-03-31 14:58:06 -04:00
Ederson de Souza
5609406614 subsys/pmci/mctp: Allow unregistering I2C target
Add a `mctp_i2c_gpio_target_unregister`, which basically calls I2C
`i2c_target_unregister`. While libmctp binds are only "started", with
no cleanup, this will be useful for tests, allowing a sequence of them.

Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2026-03-31 14:58:06 -04:00
Ederson de Souza
a8b6717816 subsys/pmci/mctp: Block on UART transfer
When sending "big messages", libmctp queues a series of packets and
calls the binding in a loop to transmit all messages. If previous
message was still being sent, transmission would fail with -EBUSY, but
libmctp wouldn't handle it.

This patch makes the UART TX blocking, so it only returns after
completion, allowing next TX to just work.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2026-03-31 14:58:06 -04:00
Mikhael Skvortsov
01586032e4 net: wireguard: fix PSA slot leak
Free any leftover ephemeral key from a previous unanswered initiation.

Signed-off-by: Mikhael Skvortsov <mikhael.skvortsov@gmail.com>
2026-03-31 13:55:23 -05:00