Commit graph zephyr/subsys
Author SHA1 Message Date
Jordan Yates
d58eec05fa kconfig: depends on FLASH_PAGE_LAYOUT
`FLASH_PAGE_LAYOUT` is a symbol with its own dependencies, it should not
be selected by subsystems that with to use it. The symbol is already
enabled by default when `FLASH_HAS_PAGE_LAYOUT`, so this change won't
silently change any enabled symbols. The `depends on` ensures that the
user is not enabled if the feature is not available.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-06-29 22:18:24 -04:00
Michael Zimmermann
e10af22991 tree-wide: replace usages of k_work_q thread with thread_id
The `thread` field is not initialized, if it's being animated via
k_work_queue_run instead of k_work_queue_start.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2026-06-29 22:17:45 -04:00
Zafer SEN
a2c066b1ce subsystem: modem: chat: add raw RX logging option
Add an optional modem chat debug mode for logging raw received modem
lines before tokenized response logging changes their shape.

When CONFIG_MODEM_CHAT_LOG_RAW_RX is enabled, preserve separator bytes
seen during parsing and rebuild the received line for debug output. This
keeps empty fields and separators visible exactly as they were received
from the modem, which helps debug AT responses and URCs with sparse or
ambiguous fields.

Keep the existing parsed logging path as the default, and gate the raw
logging support behind modem debug logging so normal builds are
unchanged.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-06-29 13:55:36 -05:00
Krzysztof Chruściński
6a68a214a9 logging: frontends: stmesp_demux: Increase robustness
Increase robustness but not assuming that input data is reliable.
Return -EBADMSG error if any unexpected data is found.

Fix log_frontend_stmesp_demux_reset by resetting the current packet
and setting skip to true. When skip is set to true all data is
skipped until new Major+Channel are found.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-06-29 13:48:33 -05:00
Krzysztof Chruściński
bca09fa822 debug: mipi_stp_decoder: Add option to detect unexpected stream content
Extend callback to return a bool which indicates if decoded data is
valid. It may be valid from STP protocol perspective but decoded data
may be unexpected which indicates that data stream is corrupted. If
callback indicates invalid data decoder changes state to out of sync
and starts searching for ASYNC.

Adapted test and debug_nrf_etr module which is using the decoder with
stream from the ETR buffer.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-06-29 13:48:33 -05:00
Krzysztof Chruściński
e3c6b5340d logging: frontend: stmesp: Add flag indicating presence of hexdump data
Add flag which indicates that hexdump data is present. Flag helps to
identify and discard corrupted logging message.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-06-29 13:48:33 -05:00
Emil Gydesen
db44a526c9 Bluetooth: CAP: Ini: Compare cfg/qos in get_next_proc_param
Compare the actual values of the codec configuration
or qos configuration when in the codec configured state,
the QoS configured state or the enabling state.

In the case that the stream is one of the these states
and the parameters to set differ from what is already there,
the appropriate actions should be taken to set the right
values, even if it does not mean an actual state change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-29 13:45:36 -05:00
Emil Gydesen
78f2cdc47c Bluetooth: BAP: Fix bugs with codec configuration
This commit fixes 2 bugs:
1) Bad/missing err return from bt_bap_stream_reconfig
2) Missing handle of codec_cfg fields that are not part of the
ASCS notifcations: path_id, ctlr_transcode, target_latency and
target_phy.

To be able to set these, we need to store them somewhere, and it
makes sense to attach the ep->codec_cfg earlier so that we can store
them in there.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-29 13:45:36 -05:00
Jordan Yates
33aedc2b15 net: wifi: shell: add --pbkdf2 support
Add support for testing the `psk_is_pbkdf2` option in the shell. Instead
of requiring the user to compute the key offline and type it in, compute
the value from the provided SSID and PSK.

While this doesn't provide any speed improvements for the shell (as the
key is computed on each connection), it shows the option works and
provides code as a starting point for caching the value. Timing the
computation shows the possible gains from caching the value.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-06-29 13:44:41 -05:00
Liu Qian
8863b8f293 profiling: perf: delegate stack unwinding to arch_stack_walk
Rewrite perf_riscv.c and add perf_arm64.c to delegate stack
unwinding to arch_stack_walk() instead of duplicating the logic.
The arch walker provides stricter validation (alignment, USERSPACE
bounds, is_address_mapped) and any future fix automatically benefits
perf.

RISC-V: recover ESF from irq_stack - 16, call arch_stack_walk().
Change Kconfig dependency from THREAD_STACK_INFO +
FRAME_POINTER to ARCH_STACKWALK.

ARM64: recover ESF from irq_stack - 16 (z_arm64_enter_exc builds a
full esf before _isr_wrapper), emit esf->elr and esf->lr explicitly
(the walker does not emit these), then call arch_stack_walk().

Add README.md documenting why Cortex-M, Cortex-A/R, and x86/x86_64
cannot yet follow the same pattern.

Signed-off-by: Liu Qian <liuqian.andy@picoheart.com>
2026-06-29 11:26:46 +02:00
Jukka Rissanen
3dc794a272 net: wireguard: Use 64-bit delta in replay-window check
wg_replay_check() computed the distance between the incoming counter and
the stored replay counter into a uint32_t, even though both counters are
64-bit. A delta larger than 2^32 was therefore truncated before being
compared against the 32-bit window size:

  - On a forward jump of 2^32 + k the truncated delta (k) looked like a
    small in-window step, so the window was shifted by k and stale bits
    were kept instead of resetting the window. Those stale bits alias
    unrelated counters and can make a never-seen packet look like a
    replay.
  - On a backward gap of 2^32 + k an ancient counter looked in-window
    and could be accepted instead of rejected as too old.

Widen the delta to uint64_t so the comparison against the window size
uses the full distance. The bitmap shift amounts are only evaluated when
the delta is below the window size, so they remain in range.

Add replay-window unit tests covering a forward jump and a backward gap
larger than 2^32; both fail with the truncated delta and pass with the
64-bit one.

Tested with native_sim: tests/net/lib/wireguard.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-06-29 09:17:36 +02:00
Jukka Rissanen
efa9d7ddf7 net: wireguard: Guard transport RX address parsing by IP family
wg_ctrl_recv() parses the outer UDP/IP header into a local
net_sockaddr_storage and, in the IPv6 branch, casts that storage to
struct net_sockaddr_in6 via net_sin6(). The size of net_sockaddr_storage
follows NET_SOCKADDR_MAX_SIZE, which is the largest *enabled* address
family. In an IPv4-only build (CONFIG_NET_IPV6=n) the storage is sized
for net_sockaddr_in, but the IPv6 branch is still compiled and
type-checked, so the net_sin6() accesses read past the object and GCC
rejects the file with -Werror=array-bounds.

The branch is dead code at runtime in that configuration (no AF_INET6
packets can arrive), so gate both family branches on
IS_ENABLED(CONFIG_NET_IPV4)/IS_ENABLED(CONFIG_NET_IPV6). When a family is
disabled the corresponding branch is compile-time eliminated before the
bounds analysis runs, matching how the TX path (select_target_iface(),
create_packet()) already guards its IPv6 handling.

The mismatch is asymmetric: an IPv6-only build is unaffected because
net_sockaddr_storage is then sized for the larger net_sockaddr_in6 and
the IPv4 cast fits.

Tested with native_sim by building tests/net/lib/wireguard with
CONFIG_NET_IPV6=n and with CONFIG_NET_IPV4=n under
CONFIG_COMPILER_WARNINGS_AS_ERRORS=y; both compile cleanly now.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-06-29 09:17:36 +02:00
Jukka Rissanen
6603c77a43 tests: net: wireguard: Add replay and transport security tests
Add ztests covering the transport anti-replay window and the two recent
fixes: replayed transport packets must not mutate peer state, and
unauthenticated 16-byte payloads must not be treated as keepalives.

The few internal entry points the tests need (the replay-window helper,
peer lookup, keypair destroy, the PSA chacha import/encrypt helpers and
the transport receive handler) are exported with ZTESTABLE_STATIC: they
stay static in normal builds and only gain external linkage for ztest
builds. The replay-window logic is factored into a pure wg_replay_check()
helper in wg_crypto.c so it can be exercised directly. All of the test
scaffolding (synthetic session install, packet injection, state accessors)
lives in the test tree under tests/net/lib/wireguard.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-06-29 09:17:36 +02:00
Jukka Rissanen
87c520a55f net: wireguard: Authenticate keepalive transport-data messages
wg_process_data_message() treated any transport-data message whose
payload was exactly 16 bytes (an empty plaintext plus a bare Poly1305
tag, i.e. a keepalive) as valid and returned immediately, emitting
NET_EVENT_VPN_CONNECTED and bumping the keepalive RX stat. This happened
before wg_decrypt_packet(), so the Poly1305 tag was never verified. The
only preceding gates were a cleartext receiver-index lookup and a
non-cryptographic key validity/expiry check.

An attacker who observed (or brute-forced) the cleartext receiver index
of an active session could therefore send a type-4 message with 16 bytes
of garbage to the WireGuard port and make the management layer observe a
spoofed VPN-CONNECTED signal without possessing the session key.

Remove the unauthenticated early return and let the 16-byte payload flow
through wg_decrypt_packet(), which verifies the tag over the empty
plaintext. Only after a successful decrypt and the anti-replay check is
the message recognised as a keepalive (decrypted length 0); at that
point liveness/roaming has already been updated and there is nothing to
deliver to the network stack.

Tested by building samples/net/wireguard for native_sim.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-06-29 09:17:36 +02:00
Jukka Rissanen
260c32ef9a net: wireguard: Check anti-replay before mutating peer state
In the transport-data receive path, after AEAD decryption succeeded the
code updated the peer endpoint (update_peer_addr), refreshed the
liveness timers (keypair->last_rx/peer->last_rx), rotated next->current
keypair via keypair_update() and evaluated the rekey trigger, all before
calling wg_check_replay(). A captured transport packet re-injected from
an arbitrary source address authenticates correctly under AEAD, so every
one of those state mutations committed; the replay check then rejected
the packet but nothing was rolled back.

This let an attacker redirect subsequent outbound traffic to a spoofed
endpoint (roaming hijack), prematurely destroy the prev keypair, and
keep the RX liveness timer fresh, purely by replaying one valid
ciphertext.

Move wg_check_replay() to immediately after a successful decrypt and
before any peer-state mutation, matching the WireGuard specification and
the Linux reference implementation, where counter validation precedes
endpoint update and keypair promotion.

Tested by building samples/net/wireguard for native_sim.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-06-29 09:17:36 +02:00
Fengming Ye
4912ec6192 net: wifi: add roaming retry count
Add roaming retry count to fall back roaming method to next one.
Roaming 11K/11V may fail because AP does not carry right candidate.
In this case we can jump to next method when we receive signal change
event again.

Signed-off-by: Fengming Ye <frank.ye@nxp.com>
2026-06-29 09:17:09 +02:00
Fengming Ye
619a34dfe3 net: wifi: optimize 11R roaming case
Deprecate explicit 11R roaming api.
11R is not a way of getting candidate. It is a way of getting keys.
So it can combine with 11K/11V/legacy roaming method
and controlled by wifi_connect -R param.

Signed-off-by: Fengming Ye <frank.ye@nxp.com>
2026-06-29 09:17:09 +02:00
Dominik Ermel
b69832497b fs: fcb: Fix compliance with CG 109
Remove usage of variable-length arrays.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2026-06-26 22:29:25 -04:00
Anas Nashif
0d2d7ae32a lorawan: multicast: validate McGroupSetupReq payload length
The MC_GROUP_SETUP handler read 29 bytes (1 id + 4 McAddr + 16 McKeyE +
4 FCountMin + 4 FCountMax) from the downlink buffer without checking
that at least 29 bytes remained after the command byte.

Assisted-by: Claude Code:claude-opus-4.8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-27 00:45:04 +02:00
Anas Nashif
237309ea7c lorawan: frag_transport: validate downlink length before struct cast
Two gaps in frag_transport_service_handler():
1. The FRAG_SESSION_SETUP case cast rx_buf + rx_pos to struct
   frag_transport_setup_req (10 bytes) without checking remaining bytes.
2. The DATA_FRAGMENT case passed rx_buf[rx_pos] to the decoder without
   confirming that len - rx_pos >= ctx.frag_size.

Add remaining-length guards before each access.

Assisted-by: Claude Code:claude-opus-4.8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-27 00:45:04 +02:00
Anas Nashif
3d57806765 lorawan: clock_sync: validate AppTimeAns payload length
The APP_TIME handler read 5 bytes (4-byte time correction + 1-byte token)
without checking that at least 5 bytes remained in the receive buffer,
allowing a short or crafted downlink to read past the end.

Assisted-by: Claude Code:claude-opus-4.8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-27 00:45:04 +02:00
Philipp Steiner
9803584f97 net: ptp: make PI servo gains configurable
Add Kconfig symbols for the PTP PI servo proportional and integral
gains. Express the values in thousandths because Kconfig does not
support floating-point values.

Keep the existing 0.7 and 0.3 gains as defaults and add unit coverage
for non-default gain values.

Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
2026-06-27 00:44:55 +02:00
Anas Nashif
de98c3721a net: ptp: validate TLV length for MGMT_TIME before timestamp access
The PTP_MGMT_TIME case in tlv_mgmt_post_recv() read mgmt_tlv->data as a
struct ptp_timestamp (10 bytes) without first checking that length >=
sizeof(struct ptp_timestamp), allowing a short management TLV to access
out-of-bounds data.

Assisted-by: GitHub Copilot:claude-opus-4.6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-27 00:44:16 +02:00
Anas Nashif
0af8313b31 net: dhcpv6: prevent uint16_t underflow in nested-option loops
Four nested-option while-loops subtracted (sublen + 4) from the uint16_t
length counter without first checking that sublen + 4 <= length. A server-
supplied oversized sublen wraps the counter, causing an infinite loop or
out-of-bounds packet reads.

Add the guard before each subtraction.

Assisted-by: GitHub Copilot:claude-opus-4.6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-27 00:44:16 +02:00
Anas Nashif
54db343acc net: dns: fix LLMNR reply space check arithmetic
create_answer() checked available space with:
  (net_buf_max_len(query) - query->len) < (... + addr_len + query->len)
The RHS included query->len a second time, which underestimated the free
space and could allow the subsequent memmove/memcpy to overflow the buffer.

Remove the second query->len from the RHS.

Assisted-by: GitHub Copilot:Claude Sonnet 4.6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-27 00:44:16 +02:00
Anas Nashif
e9e307b762 net: dns: fix LLMNR hostname match to require exact length
The hostname comparison used strncasecmp bounded by hostname_len without
requiring result->len == hostname_len, so a query for a prefix (e.g.
"host") would match "hostname". Require an exact length match and bound
the compare by MIN(hostname_len, result->len) to avoid reading past
result->data for short labels.

Assisted-by: GitHub Copilot:Claude Sonnet 4.6
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-27 00:44:16 +02:00
Anas Nashif
9c0f869da0 fs: ext2: reject s_blocks_count exceeding single-group bitmap capacity
The block bitmap validation passed
 fs_blocks = s_blocks_count - s_first_data_block

directly to ext2_bitmap_count_set() without checking whether it exceeds
the bitmap's capacity of block_size × 8 bits. A crafted image could
trigger a ~512 MB bitmap scan with a heap over-read.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-26 13:02:58 -04:00
David Brown
eba36f8ed6 net: ocpp: guard second strtok_r return before atoi
ocpp_process_server_msg() guards the first strtok_r(uid, "-", &tmp)
result but then calls atoi() on the second strtok_r(NULL, "-", &tmp)
result without the same check. When the CALLRESULT uid has a first
token but no second '-'-delimited token, strtok_r returns NULL and
atoi(NULL) is undefined behaviour.

Return -EINVAL when the second token is absent, matching the first.

Signed-off-by: David Brown <david.brown@linaro.org>
Assisted-By: Claude:opus-4.8
2026-06-26 13:02:48 -04:00
Jakub Topic
27cfd15888 shell: backends: uart: disable RX on async_uninit
async_uninit() was a no-op, so when the shell UART transport was
uninitialized, UART RX stayed enabled and the device remained active.
Call uart_rx_disable() in async_uninit to match async_init's rx_enable(),
so the UART is fully disabled on uninit.

Signed-off-by: Jakub Topic <jakub.topic@anitra.cz>
2026-06-26 13:01:42 -04:00
Fin Maaß
7b135c3f12 net: context: remove setting rx_timestamping on tx
setting net_pkt_set_rx_timestamping on a
packet that is going to be send is wrong.

net_pkt_set_rx_timestamping is rather used
by a ethernet driver to indecate that the
timestamp is valid.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-06-26 07:48:45 -04:00
Philipp Steiner
704c7d3073 net: zperf: handle socket hangup events
Treat POLLHUP as a terminal socket event in the TCP and UDP zperf
receivers. Also avoid interpreting a missing or zero SO_ERROR value as
success when poll already reported an error-style event.

This prevents zperf receiver sockets from staying registered after a
terminal poll event, which can otherwise cause repeated socket-service
wakeups and starve other network work.

Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
2026-06-26 07:48:05 -04:00
Dominik Ermel
ea9ee3ee3a fs: fcb: Fix fcb_init failing to do unaligned write
Fix problem where fcb_init was failing due to fcb_sector_hdr_init
attempting to write flash without taking write alignment into account.

Fixes #111886

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2026-06-26 07:46:45 -04:00
Appana Durga Kedareswara rao
cbd8063d8a debug: coredump: add UDP logging backend and generic IRQ hook fallback
Add CONFIG_DEBUG_COREDUMP_BACKEND_LOGGING_UDP, a new coredump backend
that sends the raw coredump byte stream over UDP while optionally
mirroring the standard #CD: hex lines through the logging subsystem.

Each buffer segment is transmitted as a self-describing UDP datagram
with a 16-byte header: 4-byte magic "ZCDU", 32-bit byte offset in the
reassembled stream, 16-bit payload length, 16-bit flags (bit 0 = END),
and a 32-bit sequence number for diagnostics. The host-side
coredump_udp_receiver.py reassembles datagrams by offset and writes a
raw .bin file for coredump_gdbserver.py.

Peer destination is CONFIG_DEBUG_COREDUMP_LOGGING_UDP_HOST, a string
parsed by net_ipaddr_parse() supporting both IPv4 (192.0.2.1:17777)
and IPv6 ([2001:db8::1]:17777). Port 17777 is used when omitted.
UART mirroring can be suppressed with
CONFIG_DEBUG_COREDUMP_LOGGING_UDP_MIRROR_TO_LOG=n; the logging
subsystem is not selected when mirroring is disabled.

Also adds the generic weak fallback for arch_coredump_fatal_irq_unlock/
lock (delegates to arch_irq_unlock/lock) under
CONFIG_DEBUG_COREDUMP_FATAL_UNLOCK_IRQS. Architectures with independent
IRQ masking must override these — see arch/arm64/core/coredump_fatal_irq.c.

Signed-off-by: Appana Durga Kedareswara rao <appana.durga.kedareswara.rao@amd.com>
2026-06-25 22:18:57 +01:00
Jordan Yates
896ec54dc5 testsuite: ztest: disable ZTEST_NO_YIELD for SEMIHOSTING
Disable `ZTEST_NO_YIELD` when `COVERAGE_SEMIHOST` is enabled, otherwise
the coverage dump upon leaving `main` never runs.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-06-25 10:29:05 -07:00
Robert Lubos
8d0dbf14bd net: if: Drop net_if_lock around solicited node mcast join
rejoin_ipv6_mcast_groups() joined the solicited node multicast groups via
join_mcast_nodes() while holding net_if_lock(). That transmits MLD reports,
whose TX path locks other interfaces, so two interfaces coming up
concurrently could still deadlock (ABBA) - the same issue that commit
774ab25267d9 fixed for the rest of the operational state notification.
Collect the addresses under the lock and perform the join after dropping
it.

Assisted-by: Cursor:Claude Opus 4.8
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-06-25 10:27:34 -07:00
Robert Lubos
ace49c03d5 net: if: Run oper state notifications without net_if_lock held
notify_iface_up()/notify_iface_down() transmit packets (RS, MLD join)
and enable/disable stacked virtual interfaces, which locks other
interfaces. Running that under net_if_lock() could deadlock (ABBA) when
two interfaces were brought up concurrently.

Keep the NET_IF_RUNNING flag update and the NET_EVENT_IF_UP/DOWN events
under the lock, but drop net_if_lock() around the parts that transmit
packets and lock other interfaces, re-acquiring it afterwards. This
fixes the deadlock while keeping the notifications synchronous, so the
interface L3 setup (multicast group join, RS, DAD) is complete by the
time net_if_up()/net_if_carrier_on() returns.

Assisted-by: Cursor:Claude Opus 4.8
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-06-25 10:27:34 -07:00
Andre Heinemans
0ec8d0faee net: gptp: fix path trace length validation
Path trace length is increased by GPTP_CLOCK_ID_LEN (=8) for every clock
id added to the list. But the check only accounted for 1 unit per clock
id which resulted in false-positive errors.

Update the length check to correctly account for the full
GPTP_CLOCK_ID_LEN per clock ID.

Signed-off-by: Andre Heinemans <andre.heinemans@nxp.com>
2026-06-25 10:27:18 -07:00
Fuyu Fei
5c3e8d2ecb net: tcp: ACK at least every second full-sized segment
The stack only sent an immediate ACK when the received segment had the
PSH flag set and the receive window was not short; otherwise the ACK was
delayed by a hardcoded 100 ms timeout. RFC 1122 section 4.2.3.2 requires
an ACK to be sent for at least every second full-sized segment. Without
that rule a bulk sender filling a modest receive window stalls waiting
for the delayed ACK to reopen the window, throttling throughput.

Track the bytes received since the last ACK and send an immediate ACK
once it reaches 2 * MSS, in addition to the existing RFC 813 PSH
heuristic. This keeps the window open during bulk transfers without
ACKing every single segment.

Also make the delayed-ACK timeout configurable through
CONFIG_NET_TCP_ACK_DELAY (default 100 ms preserves the existing
behaviour), following the other TCP timeout options in Kconfig.tcp.

On a 100BASE-TX target with a 24 KB receive window, the 2 * MSS rule
raised single-stream TCP receive throughput from ~53 to ~76 Mbit/s
(board-side ACK-per-segment ratio 0.12 -> 0.50, matching RFC 1122) with
no regression at larger windows. The default build is functionally
unchanged.

Signed-off-by: Fuyu Fei <810060436@qq.com>
Co-authored-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-06-25 10:26:12 -07:00
Emil Gydesen
029dffd02d Bluetooth: CAP: Shell: Fix chan alloc for CAP bsrc AC commands
The commands did not properly set the channel allocation for the
broadcast source.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-25 10:25:22 -07:00
Emil Gydesen
8d8c1938ff Bluetooth: GMAP: Shell: Register cap specific for GMAP
Instead of using the "regular" BAP codec capabilities for GMAP,
`gmap init` will now register its own capabilities.
This makes it more clear that for the gaming context we only
support the frequencies and frame sizes defined by GMAP
(e.g. no 8KHz for gaming audio, or 155 frame sizes).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-25 10:24:55 -07:00
Pavel Vasilyev
f82ab84fa6 net: sockets: tls: support PSA-resident private keys
Add a TLS_CREDENTIAL_PRIVATE_KEY_PSA credential type so a private key
already resident in PSA can be referenced by its psa_key_id_t instead
of being supplied as exported key material.

When this credential type is used, the TLS socket builds an opaque
Mbed TLS PK context with mbedtls_pk_wrap_psa() rather than parsing raw
key bytes. As a result the private key never leaves PSA: handshake
signatures are performed through psa_sign_hash(). This enables flows
where the key is generated on-device (non-exportable, stored in ITS)
and used for TLS client authentication without ever exporting it.

The credential buffer holds a psa_key_id_t; the public certificate is
still registered as TLS_CREDENTIAL_PUBLIC_CERTIFICATE and paired with
the opaque key by sec tag, unchanged.

Assisted-by: Claude:claude-opus-4.8
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2026-06-25 15:24:55 +02:00
Pavel Vasilyev
66bdd8cc32 net: tls_credentials: lazily load protected storage ToC
The protected storage backend read its Table of Contents (ToC) from a
SYS_INIT hook at POST_KERNEL priority 0. With TF-M, Protected Storage is
provided by the secure domain and is available that early, so this
worked. Without TF-M the backend is layered on Zephyr's Secure Storage,
and the ToC read then runs far too early in the boot sequence:

  - The RRAM/MRAM (non-volatile memory) flash drivers initialize at
    POST_KERNEL, KERNEL_INIT_PRIORITY_DEVICE (priority 50).
  - On top of that, the Secure Storage PSA ITS settings store mounts the
    settings subsystem (settings_subsys_init()) from its own SYS_INIT at
    APPLICATION level.
  - Only after that is psa_ps_get()/psa_ps_set() actually backed by
    persistent storage.

credentials_init() at POST_KERNEL/0 therefore ran before storage was
usable: psa_ps_get() returned "does not exist", the ToC was treated as
empty, and the first credential write then overwrote the persisted ToC,
dropping all previously stored credentials across reboot.

Simply moving the SYS_INIT to APPLICATION level only swaps one fragile
ordering for another: it would have to run after Secure Storage's own
APPLICATION-level settings mount, at the same init priority, making
correctness depend on link order. That priority coupling is the wrong
way to express the dependency.

Instead, drop the boot-time SYS_INIT and load the ToC lazily on first
access:

  - credentials_ensure_loaded() runs credentials_init() exactly once,
    under credential_lock, and records the result in credentials_loaded.
  - The public API (tls_credential_add/get/delete) calls it and returns
    -EACCES if storage is still not usable, so callers get a real error
    instead of silently operating on an empty ToC.
  - credentials_lock() also calls it. The internal iteration API used by
    the TLS handshake (credential_get(), credential_next_get(),
    credential_next_tag_get()) returns a pointer / sec_tag and has no way
    to report an error, so it cannot trigger or surface a failed load on
    its own. Performing the load in credentials_lock() - which
    sockets_tls takes before iterating - is what guarantees the ToC is
    loaded for that path; the getters additionally log a warning and
    return empty if it is somehow still not loaded.

The inability of the internal getter API to return an error is a
pre-existing limitation, also implemented downstreams; changing its
signature is left for a follow-up so this change stays self-contained.

Assisted-by: Claude:claude-opus-4.8
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2026-06-25 15:24:35 +02:00
Pavel Vasilyev
ed889e577b net: tls_credentials: allow protected storage backend on Secure Storage
The protected storage credentials backend only uses the PSA Protected
Storage API (psa_ps_*), which Zephyr's Secure Storage subsystem provides
without TF-M. Allow selecting the backend when SECURE_STORAGE is enabled,
not only with TF-M, so secure-only builds (for example nRF54L cpuapp) can
persist TLS credentials across reboot instead of being limited to the
volatile backend.

The backend builds storage UIDs that use the full 64-bit range (see
tls_credential_get_uid()). TF-M's Protected Storage supports that
natively, but Zephyr's Secure Storage defaults to a 30-bit UID, which
makes psa_ps_set() reject the credential UIDs (observed as -EIO). Select
SECURE_STORAGE_64_BIT_UID when using Secure Storage so the backend works.

Assisted-by: Claude:claude-opus-4.8
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2026-06-25 15:24:35 +02:00
Yangbo Lu
a7033b23e6 net: l2: use NET_L2_PTP_TIMESTAMPING
Renamed NET_L2_PTP Kconfig option to NET_L2_PTP_TIMESTAMPING,
to make its function clear to user. Also made it depend on
PTP_CLOCK which was more reasonable.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-06-25 15:23:45 +02:00
Yangbo Lu
9d18ae0de9 net: ip: improve NET_PKT_TIMESTAMP kconfig description
Current description for NET_PKT_TIMESTAMP and NET_PKT_TIMESTAMP_THREAD
kconfig options was hard to understand.
Let's give them clear and general description for what they do.
If any specific networking protocol wants to describe the utilizing of
them, it can be done in its own Kconfig option.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-06-25 15:23:45 +02:00
Emil Gydesen
9231a416a6 Bluetooth: CAP: Handover: Shell: Use unicast_to_broadcast_created
Use the unicast_to_broadcast_created callback to properly handle
the creation and potentional deletion of the broadcast source.

Additionally since this exposes the broadcast source before
the procedure is completed, additional checks for whether
the handover is in progress has been added.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-25 15:19:41 +02:00
Emil Gydesen
ed972d4588 Bluetooth: Audio: Fix malformed forloops
MISRRA 14.2 does not allow modifying the iterator inside
for loops. Modify the loops to while where appropriate
and add or modify additional checks for length before
incrementing the iterator.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-25 15:18:39 +02:00
Pieter De Gendt
c1865c4c64 net: Cleanup Kconfig files
Fix Kconfig style issues in the networking subsystem: add blank lines
around top-level if/endif, fix help text indentation and wrap overly
long help lines.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Assisted-by: Claude Code:claude-opus-4.8
2026-06-25 15:18:04 +02:00
Emil Gydesen
e4cb57e103 Bluetooth: Host: Fix RPA expire issues for adv
This commit fixes 2 things:
1) If an advertising set is not enabled, the rpa_expired callback
   is no longer called. Since we pause the adv set to update the RPA
   we need to use BT_ADV_RPA_UPDATE instead of BT_ADV_ENABLED to check
   whether it is "active".
2) If we do not have an active advertising set, not scanning or
   not initiating a connection, the RPA timer is stopped. The
   timer is started again whenever any action that uses RPA is
   started again.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-25 06:18:09 -04:00
Emil Gydesen
8e733660cd Bluetooth: OTS: Change BT_OTS_MAX_OBJ_CNT to int from hex
Providing a number of objects as decimal (e.g. 48) is
more intuitive than hex (e.g. 0x30) for humans.

Additionally the max number of objects when the directory
listing object is support has also been changed to more
accurate depict the actual maximal number of objects based on
CONFIG_BT_OTS_OBJ_MAX_NAME_LEN instead of using the absolute
max value. Since Kconfig does not support such calculations,
this maximum has been moved to a BUILD_ASSERT.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-06-25 06:17:48 -04:00