Commit graph zephyr/subsys
Author SHA1 Message Date
Etienne Carriere
5cf83813d6 settings: use diamond include for non-local header files
Use #include <> instead of #include "" to include a header file which path
is not relative to the directory path of the file emitting the #include
directive.

This change was made running scripts/check_quoted_includes.py script
proposed in https://github.com/zephyrproject-rtos/zephyr/pull/112135
with the Linux shell command below and manually selecting the applicable
changes:
$ find subsys/settings/ -type f -exec \
    ./scripts/check_quoted_includes.py -w {} \;

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2026-07-17 11:53:41 -04:00
Siratul Islam
1c9900f24a authentication: fido2: implement uv for getAssertion
add pin verification to getAssertion command

Signed-off-by: Siratul Islam <siratul.islam@linux.dev>
2026-07-17 11:52:45 -04:00
Siratul Islam
b635024a69 authentication: fido2: implement getAuthTokenPinWithPerms
- implement getPinUvAuthTokenUsingPinWithPermissions subcommand

Signed-off-by: Siratul Islam <siratul.islam@linux.dev>
2026-07-17 11:52:45 -04:00
Siratul Islam
dc8435869a authentication: fido2: implement uv for makecredential
- add uv to makecredential

Signed-off-by: Siratul Islam <siratul.islam@linux.dev>
2026-07-17 11:52:45 -04:00
Siratul Islam
560f023245 authentication: fido2: implement getPinToken
- implement clientPIN getPinToken subcommand

Signed-off-by: Siratul Islam <siratul.islam@linux.dev>
2026-07-17 11:52:45 -04:00
Siratul Islam
d97fe6f02e authentication: fido2: implement setPIN
- implement clientPIN setPIN subcommand

Signed-off-by: Siratul Islam <siratul.islam@linux.dev>
2026-07-17 11:52:45 -04:00
Siratul Islam
b89a50301b authentication: fido2: introduce clientPin
- Add clientPin infrastructure
- implement getPINRetries subcommand
- implement KeyAgreement subcommand

Signed-off-by: Siratul Islam <siratul.islam@linux.dev>
2026-07-17 11:52:45 -04:00
Chaitanya Tata
89b67cfa3d modules: hostap: support a single iface acting as both STA and SAP
When SoftAP is provided via wpa_supplicant
(CONFIG_WIFI_NM_WPA_SUPPLICANT_AP) a single Wi-Fi interface can act as
both a station and a SoftAP. Register the interface as SAP capable in
addition to STA so the Wi-Fi shell and management layer accept AP
requests on it.

To keep a single managed-interface entry per net_if, make
wifi_nm_register_mgd_type_iface() OR the new role into an existing
entry instead of consuming a second slot. Previously registering the
same interface as both STA and SAP created two entries, and
unregistration only removed the first, leaking the second and
confusing type detection.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Assisted-by: Claude:claude-opus-4.8
2026-07-17 11:52:22 -04:00
Jukka Rissanen
3003576743 net: shell: pmtu: Add DPLPMTUD support
Print also DPLPMTUD cache information for "net pmtu" command
like this:

$ net pmtu
PMTU destination cache content:
                          Destination Address   MTU  Age (sec)
[ 1]                                192.0.2.2  1500  14
[ 2]                              2001:db8::2  1500  5
[ 3]                 fe80::200:5eff:fe00:53ff  1500  0
DPLPMTUD destination cache content:
                          Destination Address   PLPMTU  Age (sec)
[ 1]                                192.0.2.2     1200  14
[ 2]                              2001:db8::2     1200  5
[ 3]                 fe80::200:5eff:fe00:53ff     1200  0

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-16 18:10:53 +01:00
Jukka Rissanen
14b3810790 net: ipv6: Seed PMTU cache with the packet interface MTU
net_ipv6_prepare_for_send() seeds the PMTU destination cache with
net_if_get_mtu(iface) for a new destination, mirroring the IPv4 send
path. However, the local iface variable is left NULL when the
destination is reached via the routing branch (try_route -> goto
try_send), which skips the interface-resolution block that would
otherwise set it. net_if_get_mtu(NULL) returns 0, so the PMTU entry for
such destinations was created with an MTU of 0 (visible as a 0 MTU in
the "net pmtu" output).

Seed from net_pkt_iface(pkt) instead, which is always set and equals the
resolved egress interface on the onlink/neighbor paths, matching what
net_ipv4_prepare_for_send() already does.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-16 18:10:53 +01:00
Jukka Rissanen
4145436395 net: ipv4: Skip ARP packets when seeding the PMTU cache on send
net_ipv4_prepare_for_send() seeds the PMTU destination cache using the
destination address taken from the packet's IPv4 header
(NET_IPV4_HDR(pkt)->dst).

ARP packets are created with net_pkt family AF_INET (their L2 protocol
type is NET_ETH_PTYPE_ARP), so they satisfy the AF_INET check in
net_if_send_data() and reach net_ipv4_prepare_for_send() as well. Their
payload is an ARP header, not an IPv4 header, so reading the "destination
address" out of it returns bytes from the ARP sender/target addresses.
That produced bogus PMTU entries, e.g. 0.0.0.0 from ARP probes and
2.1.0.0 from a gratuitous ARP announcing 192.0.2.1. The bad entries also
propagated into the DPLPMTUD cache via net_dplpmtud_sync_from_pmtu() and
were visible in "net pmtu" output.

Only seed the PMTU cache for genuine IPv4 datagrams, identified by an L2
protocol type of NET_ETH_PTYPE_IP.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-16 18:10:53 +01:00
Anas Nashif
cd441e3891 testsuite: coverage: don't index tagged per-test gcda dumps
With CONFIG_REBOOT enabled, gcov_coverage_dump_tagged() appended the
reboot dump index to the gcda name before appending the per-test tag,
producing "<canonical>.gcda.<idx>@@<suite>.<test>". As the per-test ztest
rule dumps once per test, the index was bumped on every test.

The host side matches tagged dumps on "<canonical>.gcda@@<tag>", so it
discovered no tests at all, and --coverage-per-test silently produced no
per-test data on any board with reboot support (e.g. mps2/an385).

A tag already makes the dump path unique, so skip the reboot index (and
its increment) for tagged dumps; it only serves to separate successive
untagged dumps.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-16 10:49:47 -04:00
Chaitanya Tata
baf59d175f net: wifi: Support 64-bit TWT interval range
The Wi-Fi TWT interval is a uint64_t, but the shell parsed it with the
long-based parse_number() and bounded it by WIFI_MAX_TWT_INTERVAL_US =
LONG_MAX - 1, capping requests at ~35 min on 32-bit targets. The shell
also derived the (mantissa, exponent) encoding via a millisecond-scaled
frexp(), which pinned the mantissa near ~1000, used only ~10 of its 16
bits and rounded to milliseconds.

Add a 64-bit parse helper (parse_number_u64) and integer-based
conversion helpers that encode the interval directly in micro-seconds,
using the full 16-bit mantissa and 5-bit exponent. Set
WIFI_MAX_TWT_INTERVAL_US to the true encodable maximum
(UINT16_MAX * 2^WIFI_MAX_TWT_EXPONENT us) so the shell can request the
complete IEEE 802.11 range with exact micro-second resolution, and drop
the floating-point math.

The over-the-air encoding (mantissa * 2^exponent us) is unchanged, so
this stays wire-compatible with all drivers.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Assisted-by: Claude:claude-opus-4.8
2026-07-16 10:45:36 -04:00
Etienne Carriere
50bcf6db60 fs: use diamond include for non-local header files
Use #include <> instead of #include "" to include a header file which path
is not relative to the directory path of the file emitting the #include
directive.

This change was made running scripts/check_quoted_includes.py script
proposed in https://github.com/zephyrproject-rtos/zephyr/pull/112135
with the Linux shell command below and manually selecting the applicable
changes:
$ find subsys/fs/ -type f -exec \
    ./scripts/check_quoted_includes.py -w {} \;

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2026-07-16 14:29:44 +02:00
Chaitanya Tata
992ee38a9e net: l2: ethernet: validate MAC after driver start
Commit 481035cf8e ("net: ethernet: check mac address when bringing a
eth iface up") validated the link address before eth->start() was
called. That broke Wi-Fi interfaces whose MAC is learnt from firmware
during bring-up (e.g. nRF70 reads it from OTP once the companion
firmware boots), leaving them unable to admin-up and preventing WPA
supplicant from registering them. The offending commit was reverted in
d8065e9f87 to unblock nRF Wi-Fi.

Reintroduce the validation, but run eth->start() first so that drivers
which populate their address during bring-up have a valid link address
by the time it is checked. This keeps the useful diagnostic for
misconfigured MACs while supporting drivers that only know their
address after start.

A failure of the post-start validation is terminal: net_if_up() fails
and the interface is left unusable, the same as if eth->start() itself
had failed. Return -EINVAL directly rather than rolling back with
eth->stop(), so the behaviour is consistent for drivers that do not
implement a stop op.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Assisted-by: Claude:claude-opus-4.8
2026-07-16 14:27:17 +02:00
Siddhant Modi
7f9d8ee32b net: sockets: tls: serialize access to the client session cache
The client session cache is shared between all TLS contexts, but was
only ever accessed under the per-socket context lock, so concurrent
socket operations could race on the cache entries, including freeing
an entry's session buffer while another thread was reading it.

Add a dedicated mutex for the cache. The race was already possible
with connect-time session stores, but is more exposed now that TLS 1.3
tickets are stored whenever they arrive during recv() or poll().

Signed-off-by: Siddhant Modi <siddhant.modi@gmail.com>
2026-07-15 19:03:34 -04:00
Siddhant Modi
6b4a03f334 tests: net: socket: tls_configurations: verify TLS 1.3 ticket caching
Add a test scenario that enables the TLS session cache and verifies
that a session containing a ticket is cached after exchanging data
with a TLS 1.3 server that issues session tickets.

The cache content is inspected through a new CONFIG_NET_TEST helper,
ztls_get_cached_session(), following the pattern of the existing
test-only ztls accessors.

Signed-off-by: Siddhant Modi <siddhant.modi@gmail.com>
2026-07-15 19:03:34 -04:00
Siddhant Modi
d4ea7f91f7 net: sockets: tls: store TLS 1.3 session when ticket is received
In TLS 1.3, session tickets are delivered in NewSessionTicket messages
after the handshake completes, so storing the session at connect() time
cached a session without a ticket, making TLS_SESSION_CACHE ineffective
for TLS 1.3 connections.

Store the session when mbedtls_ssl_read() reports
MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET instead, both in the recv()
path and in the poll() data check, and skip the connect-time store for
TLS 1.3. Each received ticket overwrites the previous cache entry for
the peer, so the freshest ticket is used for resumption.

Signed-off-by: Siddhant Modi <siddhant.modi@gmail.com>
2026-07-15 19:03:34 -04:00
Anas Nashif
3b2f7aaee1 sd: sdio: reject zero max_blk_size before byte-I/O loop
sdio_io_rw_byte_extended() used MIN(remaining, func->cis.max_blk_size)
as the per-iteration size. With max_blk_size == 0 the result is always 0,
remaining never decreases, and the function spins forever while holding
the SDIO mutex. Return -EIO when max_blk_size is 0.

Assisted-by: Claude:opus-4.8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-15 19:01:53 -04:00
Jukka Rissanen
1ee4796e3d net: shell: Check local bound net_context
The "net conn" command will show currently bound ports for
the created net_context. It is possible that the local port is
not yet bound in which case the local address pointer is still NULL.
Check this condition and print "<not bound>" for those net_context
instead of crashing. This affects only the net-shell "conn" command.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-15 14:40:27 +01:00
Jukka Rissanen
961d3b67db net: llmnr: Rejoin IPv6 multicast group when interface comes back up
The LLMNR responder joins both the IPv4 (224.0.0.252) and IPv6
(ff02::1:3) multicast groups when it starts, but its NET_EVENT_IF_UP
handler only rejoined the IPv4 group. When an interface was brought
fully down and back up (for example by the connection manager after an
Ethernet cable was removed and reattached), the stack removed the
groups and the responder only restored the IPv4 one. IPv6 LLMNR queries
were then dropped at the IPv6 input as being destined to an unjoined
multicast address and went unanswered.

Rejoin both the IPv4 and IPv6 groups in the NET_EVENT_IF_UP handler
using net_ipv4_igmp_rejoin() / net_ipv6_mld_rejoin() (falling back to a
join if the group was removed while the interface was down), so that a
fresh membership report is always emitted and no multicast address
reference is leaked. Only join a group when the interface has the
matching IP family enabled.

Add a regression test that verifies the responder is still a member of
both LLMNR multicast groups after an interface down/up cycle.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-15 14:40:27 +01:00
Jukka Rissanen
47b5b61dd3 net: dns: Rejoin mDNS multicast groups when interface comes back up
When the mDNS responder is disabled and only the resolver is used, the
resolver joins the mDNS multicast groups itself in
dns_postprocess_server(), but only once when the server list is
configured. There was no interface event handling, so when an interface
was brought fully down and back up (for example by the connection
manager after an Ethernet cable was removed and reattached), the stack
removed the multicast groups and never rejoined them. Multicast mDNS
responses were then dropped at the IP input as being destined to an
unjoined multicast address, and name resolution stopped working.

Register a NET_EVENT_IF_UP handler (only when the responder is not
enabled) that rejoins the IPv4 and IPv6 mDNS multicast groups on the
interface that came back up. Use net_ipv4_igmp_rejoin() /
net_ipv6_mld_rejoin() (falling back to a join if the group was removed)
so that a fresh membership report is always emitted and no multicast
address reference is leaked across link bounces. Select NET_MGMT and
NET_MGMT_EVENT for MDNS_RESOLVER so the handler is available.

Add a regression test that verifies the resolver is still a member of
the mDNS groups after an interface down/up cycle.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-15 14:40:27 +01:00
Jukka Rissanen
5845135e61 net: mdns: Rejoin multicast groups when interface comes back up
When a network interface is brought fully down (for example by the
connection manager after an Ethernet cable is removed) the network
stack leaves the mDNS multicast groups. When the interface comes back
up the stack only rejoins groups that are still marked in use, so the
mDNS groups are not restored automatically.

The NET_EVENT_IF_UP handler only rejoined the IPv4 IGMP group, and did
so using a fragile net_if_get_by_iface() - 1 index into the per-family
context array. The IPv6 MLD group (ff02::fb) was never rejoined, so
after a link down/up cycle the responder stopped receiving queries and
the incoming packets were dropped at the IPv6 input as being destined
to an unjoined multicast address.

Rejoin both the IPv4 and IPv6 mDNS groups on NET_EVENT_IF_UP using
net_ipv4_igmp_rejoin() / net_ipv6_mld_rejoin(), falling back to a join
when the group was fully removed while the interface was down. Rejoin is
used rather than join so that a fresh IGMP/MLD membership report is
always emitted (a plain join is a no-op when the group is still locally
marked as joined, which would leave a multicast-snooping switch without
a report), and so that repeated link bounces do not leak multicast
address references. The well-known group addresses are constant, so
construct them directly with create_ipv4_addr()/create_ipv6_addr()
instead of indexing the context array.

Also initialize the per-interface responder socket to -1 in
pre_init_listener() so that an announce triggered before the listener is
created (e.g. by a DHCP bound event when CONFIG_MDNS_RESPONDER_PROBE is
enabled) does not act on a not-yet-created socket.

Add regression tests that cycle the interface down/up and carrier
off/on, and verify the responder still answers, that a fresh membership
report is emitted on recovery, and that the multicast address reference
count does not leak.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-15 14:40:27 +01:00
Robert Lubos
d2ca0adc29 net: ipv6: Compare BaseReachableTime when handling RA
RFC 4861 hosts update BaseReachableTime from Router Advertisements,
not the randomized ReachableTime. Compare the base value when deciding
whether to apply a new RA reachable time.

Assisted-by: Cursor:Composer 2.5
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-07-15 15:28:09 +02:00
Robert Lubos
251079ed50 net: if: Avoid zero IPv6 reachable time calculation
Small BaseReachableTime values from Router Advertisements could make
net_if_ipv6_calc_reachable_time() return 0 due to integer division,
triggering assertions or broken ND timers.

Assisted-by: Cursor:Composer 2.5
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-07-15 15:28:09 +02:00
Aleksandr Khromykh
4416ad1367 bluetooth: mesh: clamp solicitation PDU length before decryption
The encrypted Solicitation PDU is defined by Mesh Protocol 1.1.1
section 6.9.1 as a fixed 17-octet Network PDU (CTL=1, TTL=0, empty
TransportPDU, 8-octet NetMIC).

The mesh scan callback in adv.c restores its snapshot of the
advertising buffer before dispatching, so buf->len passed into
bt_mesh_sol_recv() may still cover trailing AD structures beyond the
Solicitation Service Data.

Trim buf->len to the expected 17 octets after consuming the
Solicitation Service Data Identification Type byte, and drop the PDU
early if fewer octets remain. This aligns the input handed to
sol_pdu_decrypt() with the specification.

The outer parsing loop is unaffected because the scan callback takes
its own net_buf_simple_save/restore snapshot around the dispatch.

Gated by CONFIG_BT_MESH_OD_PRIV_PROXY_SRV.

Assisted-by: GitHub Copilot:claude-opus-4.7
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2026-07-15 15:27:50 +02:00
Fangwei Que
d9b78cda6b ipc: rpmsg: make shmem reset init priority configurable
The RPMsg static vrings backend currently hard-codes the
shared memory reset SYS_INIT priority to 1.

Some platforms need this reset to run later within PRE_KERNEL_1
because the shared memory region depends on earlier platform
initialization. Add a dedicated Kconfig option so platforms can
override the priority without modifying the backend code.

The default value remains 1, so existing behavior is preserved.

Signed-off-by: Fangwei Que <15259288389@163.com>
2026-07-15 15:26:10 +02:00
Ajay Srivastava
539fec76a3 logging: widen raw timestamp format to full uint width
The unformatted log timestamp uses [%08lu] for 32-bit and [%016llu] for
64-bit. Both widths are narrower than the max digit count of the
underlying type (10 for uint32_t, 20 for uint64_t), so the bracket
column grows once uptime crosses 1e8 (32-bit) or 1e16 (64-bit) ticks,
breaking alignment for log readers and parsers that assume a
fixed-width prefix.

Widen the format strings to %010lu / %020llu so the bracket width is
stable across the full range of the timestamp type. Update the matching
expected strings in tests/subsys/logging/log_timestamp and
tests/subsys/logging/log_output.

Signed-off-by: Ajay Srivastava <ajaysriv3@gmail.com>
2026-07-15 15:20:39 +02:00
Jukka Rissanen
5e1ec3f554 net: route: Make nexthop const
As the IPv4/6 route API function do not modify the nexthop parameter,
make it const.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-15 10:49:25 +02:00
yi chen
857cb80394 fs: ext2: reject sub-1024 block_size in ext2_format() before it underflows
validate_config() only substitutes ext2_default.block_size when
cfg->block_size is 0; it never enforces a minimum. ext2_format() then
computes:

    uint8_t block_log_size = find_msb_set(cfg->block_size) - 11;

find_msb_set() returns an unsigned int, so for any block_size whose
most-significant-bit index is less than 11 (i.e. block_size < 1024,
including the very plausible mistake of passing the sector size, 512),
the subtraction underflows and block_log_size wraps to a large
garbage value (e.g. 512 -> 255, 256 -> 254, 100 -> 252, 1 -> 246).
That truncated value is written straight into the on-disk superblock
field s_log_block_size, so ext2_format() reports success while
silently producing a corrupt, unmountable file system instead of
failing cleanly at format time.

Extend validate_config() to reject any nonzero block_size that is not
a power of two >= 1024, and propagate the error from ext2_format()
before the shift-count calculation is reached. block_size == 0 keeps
resolving to the documented default, and all currently-legal values
(1024/2048/4096/...) are unaffected.

Fixes #84678

Assisted-by: Claude:claude-sonnet-5

Signed-off-by: yi chen <94xhn1@gmail.com>
2026-07-15 10:48:46 +02:00
Muhammed Hasan Güçlü
a271a52581 net: ptp: fix 32-bit overflow in foreign clock record time window
foreign_clock_cleanup() computes the record aging timeout in 32-bit
arithmetic before storing it into an int64_t. For positive
log_msg_interval values the product 4 * 2^log * NSEC_PER_SEC wraps
around: with log_msg_interval = 1 the 8 second window becomes about
3.7 seconds, so announce messages still inside the window are aged
out prematurely and the port can wrongly lose its foreign time
transmitter records. The non-positive branch evaluates
4 * NSEC_PER_SEC in unsigned 32-bit as well, just below UINT32_MAX.

Cast the first factor to int64_t in both branches so the whole
expression is evaluated in 64-bit arithmetic.

Verified with west twister -T tests/net/ptp on native_sim; a
regression test for the wrapped window is added in the follow-up
commit.

Coverity-CID: 487738
Fixes #84696

Assisted-by: Claude:claude-fable-5
Signed-off-by: Muhammed Hasan Güçlü <guclumhg@gmail.com>
2026-07-15 10:47:02 +02:00
Nicholas Cadieux
f2474064e0 usb_c: prl: avoid unconditional poll of tcpc rx fifo
The prl_run function unconditionally called
prl_rx_wait_for_phy_message on every cycle, including wakeups
caused by TCPC_ALERT_TRANSMIT_MSG_SUCCESS. This allowed stale
data in the TCPC RX buffer to be read and forwarded to the
Policy Engine as a real message.

Add PRL_FLAGS_RX_COMPLETE (bit 10) to prl_rx->flags. The flag is
set in alert_handler when TCPC_ALERT_MSG_STATUS is received,
which the TCPC driver fires only for real non-GoodCRC messages.
prl_run now gates prl_rx_wait_for_phy_message on this flag, so
the RX path is only entered when the TCPC has explicitly
signaled a message is available.

Signed-off-by: Nicholas Cadieux <ncadieux@qti.qualcomm.com>
2026-07-15 10:42:17 +02:00
Nicholas Cadieux
b8bc6d0fde usb_c: prl: use atomic_clear to reset protocol layer flags
The PRL flag fields are reset with plain stores
(flags = ATOMIC_INIT(0)), which race with atomic_set_bit() calls
made from alert_handler on the TCPC driver's workqueue thread. A
concurrent set can be lost, dropping a message or reset
notification. Use atomic_clear() so the reset is race-safe.

Signed-off-by: Nicholas Cadieux <ncadieux@qti.qualcomm.com>
2026-07-15 10:42:17 +02:00
Sylvio Alves
d6bb4dc64b net: if: add public net_if_ipv4_route_add()
Add a public wrapper for net_route_ipv4_add() so a route can be installed
without including the private route_ipv4.h header. It mirrors the public
net_if_ipv4_router_add() and returns an errno.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-07-14 20:08:42 -04:00
Michael Zimmermann
5d1781cf9e net: mqtt_sn: allow small publish buffer size
I assume, that this is a copy&paste mistake, because I see no reason why
publish buffers should be at least 255 bytes in size.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2026-07-14 20:08:18 -04:00
Georgios Vasilakis
1e2ade68aa tracing: Add existed object check in SYS_TRACK_LIST_PREPEND
The SYS_TRACK_LIST_PREPEND unconditionally prepends an object in
the list without checking if the object is already in the list.

This is problematic and will corrupt the list if an object
is initiallized multiple times.

For example if you define an event with the macro:
K_EVENT_DEFINE(my_event)

and then you also initialize the object in code:
k_event_init(&my_event)

This will corrupt the list. Even though you don't need to run
the k_event_init after you statically define the event it is
not explicitely forbitten either so it should not corrupt
anything.

To fix that I updated the SYS_TRACK_LIST_PREPEND to check
if an object is already in the list and only prepend it
if it does not exist.

Signed-off-by: Georgios Vasilakis <georgios.vasilakis@nordicsemi.no>
2026-07-14 20:06:56 -04:00
Emil Gydesen
ffdb0c6749 Bluetooth: VCP: Shell: print location as hex
Modify the print of the location as hex instead of base 10.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-07-14 18:00:11 +02:00
Emil Gydesen
dbb5535b91 Bluetooth: BAP: Allow resetting streams with bt_bap_stream_release
If the stream has an endpoint associated with it from calling
bt_bap_stream_config but where this may have been rejected
by the peer, then the stream->ep will remain, but where the
state of the endpoint will be idle.

bt_bap_stream_release can be used to resetting this and
setting stream->ep to NULL.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-07-14 17:58:32 +02:00
Emil Gydesen
a90179cfa2 Bluetooth: BAP: Remove role assert in bap_stream_valid_ase_op
In the case that the function is called for e.g. a central and
CONFIG_BT_BAP_UNICAST_CLIENT=n, then it should not assert, as that
is possibly if the build supports both central and peripheral, but
only has CONFIG_BT_BAP_UNICAST_SERVER=y.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-07-14 17:58:32 +02:00
Emil Gydesen
3a15c34e8c Bluetooth: BAP: Use bap_stream_valid_ase_op for all ASCS ops
The release and disable operations did not use the function,
but instead had their own switches. Changes to use the
appropriate function.

Additionally modified some of the other calls so that they
appear more similar, and avoid unncessary `struct bt_bap_ep *ep`
variables but also add `struct bt_conn *conn;` variables to
avoid doing `stream->conn` more often than what is needed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-07-14 17:58:32 +02:00
Krzysztof Chruściński
c8d930acf8 testsuite: ztest: ztress: Use cpu_load if possible
When CONFIG_CPU_LOAD=y use cpu_load API which is more accurate
than thread stats.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-07-14 17:58:12 +02:00
yi chen
fabc488d5b mgmt: mcumgr: fix heap leak on settings access hook rejection
settings_mgmt_read()/_write()/_delete() each allocate key_name (and
data, for read) from the heap when CONFIG_MCUMGR_GRP_SETTINGS_
BUFFER_TYPE_HEAP is enabled, then optionally call an application
access hook via mgmt_callback_notify(). When that hook returns
MGMT_CB_ERROR_RC, the handler does 'return ret_rc;' directly,
bypassing the 'end:' label where key_name/data would otherwise be
freed. Every other status/return path in these functions does go
through 'end:' (or frees explicitly) and is not affected.

Free the heap-allocated buffers before returning on this specific
path, matching what the 'end:' label already does for the other
paths in the same functions.

Fixes #112782

Signed-off-by: yi chen <94xhn1@gmail.com>
2026-07-14 09:56:09 -04:00
Emil Gydesen
f44eeb862d Bluetooth: Host: shell: handle invalid args in adv cmds
Three argument parsers in bt.c silently ignored invalid or unknown
arguments, allowing the underlying operation to proceed as if no
bad input was given.

cmd_adv_start: the two keyword checks ("timeout", "num-events") were
written as independent if-blocks. An unknown argument (including
"--help") falls through both checks without error and advertising
starts. Convert to if/else-if/else and change fail_show_help to return
SHELL_CMD_HELP_PRINTED, consistent with the rest of the file.

cmd_per_adv_param: the expression (argc > 3 && !strcmp(argv[3],
"tx-power")) silently discards any other value for the fourth
argument. Split the condition so that a non-empty argv[3] that is not
"tx-power" is rejected with help.

cmd_fal_connect: the if/else-if chain for "on"/"off" had no else
branch; an unrecognised action fell through and returned 0 as if it
succeeded. Add an else branch that shows help and returns
SHELL_CMD_HELP_PRINTED.

Assisted-by: Claude:claude-sonnet-4.6
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-07-14 09:53:40 -04:00
Emil Gydesen
b4fc363a24 Bluetooth: MPL: Add workaround for OTS failures and MCS
If we fail to add any objects, then MCS would not work
correctly and would cause NULL pointer accesses thus
causing fatal errors.
Changed the error checking to asserts to catch this in
a more direct manner that is easier to debug, rather
than leaving MCS wrongly initiated and hope for no
runtime fatal errors later on.

Changed the check from media_proxy_pl_register to an assert
as it will always return 0 with the current implementation.

This is a workaround to handle the fatal error and instead
allow invalid behavior in MCS if there is a failure. A proper
fix should be done, but at the time of this commit, there are
another pending change that significantly refactors all this
code, and fixing the real issue before the refactor would
result in a massive re-write.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-07-14 09:52:50 -04:00
Emil Gydesen
96c9d927a5 Bluetooth: BAP: Shell: Handle delete of CAP group
If the is_cap boolean is set, the group was not automatically
deleted when all the streams were relased. CAP instead had
a different way of deleting the group, but in the case of
an error in CAP unicast start, that group was not deletable.

This change make it so that the user can always delete the unicast
group, as BAP or CAP, by releasing all the streams, regardless of
what procedures have failed or succeeded, or even been cancelled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-07-14 09:52:10 -04:00
Lyle Zhu
0b8ee7f541 bluetooth: classic: l2cap: fix retransmit flag race condition
The `l2cap_br_retransmit_i_frames()` function was using
`atomic_test_and_set_bit()` to check and set the
`L2CAP_FLAG_RET_I_FRAMES` flag simultaneously. This caused the flag
to be set even when the outstanding PDU queue was empty, leading to
a state where the flag remained set without any frames to retransmit.

Fix the issue by only setting the flag `L2CAP_FLAG_RET_I_FRAMES`
after marking frames for retransmission, and only if there are
actually outstanding PDUs in the queue.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2026-07-14 09:43:40 +02:00
Rupesh Kadam
684555f480 bluetooth: audio: vocs_client: dynamically discover CCC handle
Currently, the VOCS client subscribes to characteristics by hardcoding
the CCC handle offset to attr->handle + 2. While common, this layout
is not strictly guaranteed by the Bluetooth specification and can fail
if a server structures its GATT table differently.

This commit updates the characteristic discovery callback to use the
CONFIG_BT_GATT_AUTO_DISCOVER_CCC feature to dynamically locate the CCC.

To support concurrent CCC discoveries safely, dedicated discovery
parameter structures are added to the VOCS client instance. This
prevents in-flight characteristic discoveries from clobbering each
other's memory state. Additionally, the auto-discovery boundary is
corrected to use the end of the service, rather than prematurely
shrinking to the characteristic value handle.

The hardcoded fallback and conditional compilation directives have
been removed, as VOCS inherently relies on CCC auto-discovery being
enabled via Kconfig.

Assisted-by:  Gemini:gemini-3.1-pro
Fixes zephyrproject-rtos/zephyr#81132

Signed-off-by: Rupesh Kadam <rupesh.kadam1510@gmail.com>
2026-07-14 09:36:56 +02:00
Emil Gydesen
8a2ba780e6 Bluetooth: Shell: Add _to_str functions for ext and per adv states
Add functions to return human-readable versions of the state values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-07-13 16:18:17 -05:00
Michael Zimmermann
bd21e954c3 net: mqtt_sn: Fix removing non responsive gateway
The return value of SYS_SLIST_PEEK_HEAD_CONTAINER was not used. Thus, `gw`
stayed NULL and the code that follows caused undefined behavior and
crashes.

This code path is actually tested in test_mqtt_sn_handle_advertise, but due
to the nature of the bug, it is only triggered with the right platform,
compiler and optimizations.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2026-07-13 16:18:05 -05:00
Michael Zimmermann
810ef0bb94 net: mqtt_sn: rename list "gateway" to "gateways"
This makes more sense for a list, which contains gateways.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2026-07-13 16:18:05 -05:00