Commit graph zephyr/subsys
Author SHA1 Message Date
Jukka Rissanen
89cdafde07 net: http: Fix H3 uni stream poll registration
Distinguish accepted HTTP/3 streams that should be ignored from
accepted streams that still need polling.

accept_h3_stream() can accept a peer unidirectional stream before
enough data is available to identify its type. The poll loop treated
that -EAGAIN path as "no stream queued" and returned without adding
the accepted fd to the poll set.

Add a separate ignored-stream return code and register accepted
streams whenever a valid fd is returned. This keeps peer control and
QPACK streams in the poll set while preserving the existing handling
for server-initiated, push, and unknown unidirectional streams.

This prevents accepted peer uni stream fds from being left open and
untracked.

Assisted-by: GitHub Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-13 13:41:46 +01:00
Jukka Rissanen
e2834a29e4 net: shell: http: Print supported protocol version
When printing http services, show also what HTTP protocol
version is supported for that service.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-13 13:41:46 +01:00
Jukka Rissanen
1ebb30909e net: sockets: tls: Set default ALPN list count
If ALPN list is enabled, and if HTTP/3 is enabled, then the
default ALPN list might be too small. ALPN is mandatory
for HTTP/3 so we need to increase the max limit.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-13 13:41:46 +01:00
Jukka Rissanen
9fd5a6e520 net: lib: http: Refactor http_server_run()
The http_server_run() function is very large and hard to read,
refactor it into smaller pieces. There is no functionality
changes by this commit.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-13 13:41:46 +01:00
Jukka Rissanen
5313e06eb1 net: lib: http: Fix possible workqueue deadlock
Use non-blocking cancellation when cancelling client inactivity
timer. This will avoid possible workqueue deadlock.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-13 13:41:46 +01:00
Jukka Rissanen
177644c4a6 net: http: Send optional Alt-Svc header if HTTP/3 is enabled
The server can send Alt-Svc header to tell the client that HTTP/3
support is enabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-13 13:41:46 +01:00
Jukka Rissanen
848e978c23 net: quic: HTTP server needs more resources from quic
Increase HTTP server quic limits

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-13 13:41:46 +01:00
Jukka Rissanen
bd1ffd3958 net: http: server: Print more info for setsockopt error
Print information what failed for setsockopt calls. This
way it is easier to try to solve the issue.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-13 13:41:46 +01:00
Jukka Rissanen
d9c8ac48bf net: http: Add HTTP/3 support to the server
Add HTTP/3 support HTTP server library.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-13 13:41:46 +01:00
Jukka Rissanen
7640b89173 net: http: Warn if user wants to use disabled HTTP version
If user wants to use HTTP/2 but it is disabled, then give
a warning. The condition is ignored atm.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-13 13:41:46 +01:00
Seppo Takalo
ecf68f7c3e modem: chat: Allow re-attach without side effects
When modem_chat_attach() is called with same pipe,
do not reset the parser state.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2026-05-13 13:41:31 +01:00
Seppo Takalo
c44bc42759 modem: chat: Check NULL pointer for modem_chat_run_script_async()
It is easier just check the NULL pointer in Chat module, so
the modem_cellular.c does not need to check the existence of
periodic scripts.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2026-05-13 13:41:31 +01:00
Jukka Rissanen
6e119a636a net: utils: Fix possible overflow in IPv6 address parsing
Make sure we will not overflow the ipaddress buffer if
port number is given.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-13 13:40:23 +01:00
Jukka Rissanen
1c8d19a51f net: utils: Fix possible overflow in IPv4 address parsing
Make sure we will not overflow the ipaddress buffer if
port number is given.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-13 13:40:23 +01:00
Jukka Rissanen
6d8bb28dc9 net: wireguard: Add checks for max incoming packet length
When we linearize the incoming packet (when doing decryption),
we need to check that we are not receiving larger packet than
what is being configured in the system.

This is mainly concerning the case where user has lowered the
default value of CONFIG_WIREGUARD_BUF_LEN (1500 bytes) and we
are receiving data in Ethernet (MTU is 1500 bytes).

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-13 10:39:50 +02:00
Dwij Patel
87cde7e89a lorawan: frag_transport: fix BlockAckDelay units (s vs ms)
The ans_delay for FRAG_TRANSPORT_CMD_FRAG_STATUS was calculated in
seconds but lorawan_services_schedule_uplink() expects milliseconds.

According to the LoRa Alliance Fragmented Data Block Transport spec,
the actual delay SHALL be rand() * 2^(BlockAckDelay+4) seconds.
The correct fix computes the full window in milliseconds using
MSEC_PER_SEC and proper bracket ordering to avoid operator precedence
issues with the shift operator:

  ans_delay_ms = sys_rand32_get() %
                 ((1U << (ctx.block_ack_delay + 4)) * MSEC_PER_SEC);

The variable is also renamed from ans_delay to ans_delay_ms to make
the unit explicit and help avoid similar bugs in the future.

Without this fix, the delay window for e.g. BlockAckDelay=0 is 0-16ms
instead of 0-16s, causing all devices in a multicast group to respond
nearly simultaneously and defeating the collision avoidance mechanism.

Signed-off-by: Dwij Patel <dwijpatel7@gmail.com>
2026-05-13 05:14:16 +02:00
Aiden Hu
4b87a8f161 usb: host: fix root device lifecycle management
Move ctx->root assignment and clearing from event handlers
into usbh_device_connect() and usbh_device_disconnect().
This avoid dangling pointer issue.

Signed-off-by: Aiden Hu <weiwei.hu@nxp.com>
2026-05-13 05:12:09 +02:00
Lyle Zhu
366d130101 Bluetooth: Classic: RFCOMM: Refactor overhead size calculation
Introduce BT_RFCOMM_OVERHEAD_SIZE macro to calculate the RFCOMM frame
overhead, which includes the maximum header size, FCS size, and
credits size.

This refactoring:
- Defines BT_RFCOMM_CREDITS_SIZE (1 byte) as a public constant
- Consolidates overhead calculation in a single macro
- Updates all MTU calculations to use BT_RFCOMM_OVERHEAD_SIZE
- Removes redundant credits size adjustment in rfcomm_dlc_connected()
  since the overhead is now accounted for upfront in session MTU
  calculation
- Simplifies code in GOEP by using the new macro instead of manual
  header size calculations
- Change the range of BT_GOEP_RFCOMM_MTU to [265, BT_RFCOMM_L2CAP_MTU]

The change ensures consistent MTU calculations across RFCOMM and
dependent profiles (HFP, GOEP) and accounts for the credits field in
CFC-supported scenarios from the start.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2026-05-13 05:11:54 +02:00
Aiden Hu
f938d67e91 usb: device_next: cdc_acm: make buffer pool size configurable
Add Kconfig option USBD_CDC_ACM_BUF_POOL_SIZE to allow
configuring the CDC ACM buffer pool size instead of
using the fixed MPS value.

Signed-off-by: Aiden Hu <weiwei.hu@nxp.com>
2026-05-13 05:10:30 +02:00
Josuah Demangeon
608d1b2bec usb: device_next: cdc_acm: update if0_cm.bDataInterface
The bDataInterface field is expected to contain the interface to use
for sending the data payloads, containing the BULK IN and OUT endpoints.
It is having a default value of 1 which fits USB descriptors at startup,
but once the stack renumbers the interfaces, it needs to be updated
with the numbers the host assigned.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2026-05-12 22:27:56 +02:00
Nicolas Pitre
ff9e951ac4 demand_paging: eviction: restrict LRU to always-resident kernel builds
The LRU eviction algorithm tracks page access by transiently clearing
the Present bit on the page at the head of the eviction queue and
letting the next access trap. The fault handler then re-sets P and
moves the page back to the tail. This works only as long as no
memory that the exception dispatch path itself touches can ever be
at the head of the queue.

Under Zephyr's selective-pinning model
(CONFIG_LINKER_GENERIC_SECTIONS_PRESENT_AT_BOOT=n), only sections
explicitly tagged __pinned_* are guaranteed resident at runtime; the
rest — crucially including thread stacks allocated via
K_THREAD_STACK_DEFINE, which sit in the .user_stacks arena — is free
to be paged out and, on the way there, to be LRU-access-tracked.

On architectures that reach a thread stack during exception dispatch
— which is the norm: the CPU loads the privileged stack on a ring
3 -> ring 0 transition, or continues on the current kernel stack for
a ring 0 -> ring 0 fault — this is fatal. The LRU machinery flips a
stack page to P=0 while the thread is not running, the thread is
next scheduled, the very first stack access from inside the
exception entry cannot be completed, the CPU raises a second fault
while still dispatching the first, and the architecture escalates
(Double Fault on x86, nested abort elsewhere). Observed on
qemu_x86_tiny under LRU with kernel.memory_protection and
kernel.semaphore suites.

This is not specific to any one architecture. Any arch where the
exception handler touches memory that can be in the evictable pool
is vulnerable; only the mechanism of escalation differs. NRU
statistically avoids the issue because it never clears P and
hot stacks are always marked "recently used" by hardware at
eviction-select time, so they're never actually chosen as victims.
LRU makes the transition deterministic rather than fortuitous.

The principled fix is a dedicated per-CPU exception dispatch stack
(IST on x86-64, task gate on x86-32, dedicated SP_EL1 on ARM64),
which localises pinning to one stack per CPU rather than every
thread's privileged stack. That is a substantial architectural
change, out of scope for this commit.

In the meantime, gate EVICTION_LRU on
LINKER_GENERIC_SECTIONS_PRESENT_AT_BOOT. In that mode every kernel
page is resident at boot, __pinned_* tagging is effectively a no-op,
and the evictable pool contains only explicitly anonymously-mapped
pages — none of which are reached by exception dispatch. Under
selective pinning, the eviction choice falls back to NRU, which
matches the pre-LRU behaviour.

Also add an explicit depends on ARCH_SUPPORTS_EVICTION_TRACKING for
EVICTION_LRU so that the algorithm is hidden on platforms that do
not implement the tracking hooks, and fold the two ARM64/X86 choice
defaults into one expression driven by capability rather than by
architecture name.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-05-12 22:16:56 +02:00
Nicolas Pitre
b488151896 arch/x86: mmu: support LRU eviction algorithm for demand paging
The LRU eviction algorithm needs to catch the first access to a loaded
page in order to call k_mem_paging_eviction_accessed() and move that
page to the tail of the queue. On ARM64 this is done with the MMU's
Access Flag: clearing AF causes a distinct fault on the next access.

On x86 there is no access-flag fault. The Accessed bit (PTE bit 5) is
set by hardware on access but never traps. The only way to force a
fault is to clear the Present bit, which already encodes the
"paged out" state — so a new state is needed:

   PTE == 0                         -> unmapped
   P=0, A=1, upper=location         -> paged out
   P=0, G=1, upper=PFN              -> LRU-tracked (new)
   P=1                              -> normally mapped

Bit G (Global, bit 8) is never set by Zephyr on x86 (CR4.PGE is not
used), so it is free to use as a private marker when P=0. No existing
PTE state needs to be displaced. This stays out of the way of the
KPTI path (which uses the PAT bit) and of the permission-backup bits
(IGNORED0..2) used for memory domain handling.

arch_page_info_get(addr, NULL, clear_accessed=true) is overloaded
under CONFIG_EVICTION_LRU to both query the prior flags and transition
the page to the LRU-tracked state via a new helper that updates all
domain ptables. arch_page_location_get() recognizes the tracked state
as paged-in so the core demand-paging code treats the page as resident.

The page fault handler intercepts LRU-tracking faults in-line before
k_mem_page_fault() dispatch: restore P, clear the tracking bit, and
call k_mem_paging_eviction_accessed() directly. This avoids the risk
of recursing through do_page_fault() with z_mm_lock held.

KPTI co-exists with demand paging but its PTE encoding is not yet
wired up to the LRU state, so tracking is gated on !X86_KPTI for now.

Fixes: #75132

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-05-12 22:16:56 +02:00
Andre Heinemans
f0835deab0 net: shell: qbv: fix help example
Both set_gc entries use row=0 which will result in the first entry being
overwritten and the configuration being deactivated. Activation takes
place only after the last entry has been configured.

Signed-off-by: Andre Heinemans <andre.heinemans@nxp.com>
2026-05-12 17:19:09 +02:00
Pieter De Gendt
7d8d36a466 net: lib: sockets: Set errno on TCP option error
Make sure all paths set errno and return -1.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-05-12 17:17:08 +02:00
Philipp Steiner
89d53dce59 net: shell: ptp: add ptp protocol type
adds protocol type to ptp shell

Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
2026-05-12 17:16:56 +02:00
Måns Ansgariusson
282fe99042 testsuite: ztest: benchmark: require setup/teardown arguments
Drop ZTEST_BENCHMARK_SETUP_TEARDOWN and
ZTEST_BENCHMARK_TIMED_SETUP_TEARDOWN and fold their signature into
ZTEST_BENCHMARK / ZTEST_BENCHMARK_TIMED. The no-hook variants set a bad
precedent: a meaningful benchmark should isolate the code under test from
surrounding state, so setup/teardown are now required at every call site.
Pass NULL when a benchmark genuinely needs neither.

Signed-off-by: Måns Ansgariusson <mansgariusson@gmail.com>
2026-05-12 17:12:50 +02:00
Måns Ansgariusson
bb515812d0 testsuite: ztest: benchmark: namespace generated linker symbols
Add identifier builders and route the ZTEST_BENCHMARK*() macros through
them. Suite, benchmark and wrapper-function symbols are now prefixed and
qualified by suite name, preventing collisions between identically-named
benchmarks in different suites and keeping user identifiers out of the
global symbol space.

Signed-off-by: Måns Ansgariusson <mansgariusson@gmail.com>
2026-05-12 17:12:50 +02:00
Liu Qian
c7f69b220f subsys/profiling: use ipicall to support perf smp
before perf use timer to call sample in one core.
and donot support smp.
after ipi support new feature k_ipi_work.so we
can use timer to send ipicalls to other cpus,then
active sample in other cores.

Signed-off-by: Liu Qian <liuqian.andy@picoheart.com>
2026-05-12 17:10:36 +02:00
Emil Gydesen
0cd61589ff Bluetooth: BAP: BA: Move att_buf to inst
Since the Broadcast Assistant implementation may have a
pending request _per_ instance, each instance needs its own
buffer to accomodate that, otherwise we may risk overwriting
data between instances. This follows the design used in the
BAP Unicast Client

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-05-12 11:17:40 +02:00
Petr Hlineny
4f33728ffe net: l2: ppp: misc: add missing net_log.h include
`subsys/net/l2/ppp/misc.c` uses NET_DBG() inside
`validate_phase_transition()`, which is compiled only when
CONFIG_NET_L2_PPP_LOG_LEVEL is at LOG_LEVEL_DBG. The macro is
declared in <zephyr/net/net_log.h>, which the file does not include.

At log level INF (default) the function body is a no-op stub
(ARG_UNUSED), so the missing macro goes unnoticed. At log level DBG
the file fails to build:

  misc.c: implicit declaration of function 'NET_DBG'
          [-Wimplicit-function-declaration]

Other files in the same directory (e.g. `link.c`) include
<zephyr/net/net_log.h> correctly; only `misc.c` is missing it.

Signed-off-by: Petr Hlineny <development@hlineny.cz>
2026-05-12 09:14:23 +02:00
Jukka Rissanen
a2ec996a55 net: ssh: Remove unused function
The ssh_mbedtls_rand() is not used so can be removed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-12 09:11:43 +02:00
Philipp Steiner
e38681e526 net: ptp: rename UDP IP Kconfig symbols
Rename the PTP UDP IPv4/IPv6 protocol Kconfig symbols to use
consistent all-uppercase IP version naming.

Signed-off-by: Philipp Steiner <philipp.steiner1987@gmail.com>
2026-05-12 09:07:42 +02:00
Zhaoxiang Jin
a24c4e27d2 cpu_freq: pressure: use CPU_ID macro for current CPU id
Replace the broken `_kernel.cpus[cpu].current` reference (which used
an undefined `cpu` variable) and the open-coded `arch_curr_cpu()->id`
pattern with the standard `CPU_ID` macro from `<zephyr/kernel_structs.h>`.

Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
2026-05-12 08:59:55 +02:00
Zhaoxiang Jin
c480a17642 cpu_freq: pressure: avoid divide-by-zero in pressure normalization
When no runnable threads contribute to the pressure accumulator,
max_pressure stays at zero and the subsequent division would trigger
undefined behavior. Return a normalized pressure of 0 in that case.

Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
2026-05-12 08:59:55 +02:00
Jukka Rissanen
d3dfbfb3d3 shell: aliases: Do not enable by default
As the aliases support will increase stack usage, turn the
feature off by default in order to avoid surprises with
tests and samples.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-12 08:57:40 +02:00
Fin Maaß
e164455d68 net: net_if: don't zero the iface name
the name inside of struct net_if_config, that is
part of struct net_if does not need to be zeroed,
as that is already the initial value.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-05-11 15:32:47 +01:00
Kristoffer Skøien
a03b6d540a usb: uac2: Adjust log level
The ECONNABORTED occurs on host stop and start.
Lowered the log level.

Signed-off-by: Kristoffer Skøien <kristoffer.skoien@nordicsemi.no>
2026-05-11 15:32:34 +01:00
Jukka Rissanen
dd3fcffa1c shell: Add support for tab completion for aliased subcommands
Make sure user is able to tab complete aliased subcommands.

Assisted-by: Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-11 15:30:56 +01:00
Jukka Rissanen
363c8a1581 shell: Add aliases support
Allow user to specify a file containing command name aliases.
The format of the file is:

    # This is an example aliases file. The file can have
    # comments on it.
    stacks="kernel thread stacks"
    foo=bar

There is "aliases" shell command that can show the current
list of aliases specified in the system.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-11 15:30:56 +01:00
Sylvio Alves
e744858936 net: ssh: replace removed CONFIG_NET_SOCKETS_POLL_MAX
CONFIG_NET_SOCKETS_POLL_MAX was deprecated in v4.0 and removed in
v4.5 in favour of CONFIG_ZVFS_POLL_MAX. Update the SSH server
BUILD_ASSERT and the sample/test prj.conf files accordingly so the
symbol resolves and the assertion remains effective.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-05-11 15:28:42 +01:00
Jukka Rissanen
85dc4b4904 net: shell: ssh: Close client connection automatically
When the client connection to external peer is terminated,
close the client automatically so that user does not need
to do it manually by "net ssh stop"

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-11 13:40:07 +02:00
Jukka Rissanen
6e3c1b7255 net: shell: ssh: Add kill command to stop ssh server connection
Allow user to kill an active ssh connection. This is useful as
otherwise it is impossible to stop incoming connection without
affecting other incoming connections. It is always possible to
stop the ssh server but then that kills all incoming client
connections and that might not be desired.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-11 13:40:07 +02:00
Jukka Rissanen
ca561c7222 net: shell: ssh: Add list command
Add a list command that can show information about active
client and server ssh connections.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-11 13:40:07 +02:00
Jukka Rissanen
96a2dc957b net: ssh: Add functions to traverse client/server connections
This is used by shell to print client and server connections.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-11 13:40:07 +02:00
Jukka Rissanen
6a47844a18 net: dns: Avoid unused variable warning
If both CONFIG_NET_IPV6 and CONFIG_NET_IPV4 are disabled, then
the addr_len in resolve.c dns_resolve_init_locked() will be
unused which will cause a warning.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-11 13:40:07 +02:00
Jukka Rissanen
743132fe7e net: ssh: server: Print information banner after login
Print information how to exit the shell to remote client.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-11 13:40:07 +02:00
Jukka Rissanen
e22c29c8d4 net: ssh: server: Add multi instance support
Allow multiple incoming SSH connections if we are the server.
This is controlled by CONFIG_SSH_SERVER_SHELL_COUNT option, the
default value is 1 so only one simultaneous ssh connections by
default.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-11 13:40:07 +02:00
Grant Ramsay
18ae068890 net: ssh: connection: Fix incorrect local channel ID
The local channel ID was immediately memset to zero after being set.
This caused issues when allocating multiple channels

Signed-off-by: Grant Ramsay <grant.ramsay@hotmail.com>
2026-05-11 13:40:07 +02:00
Jukka Rissanen
c320e3712b net: config: Add starting of ssh server
If user application calls the new API, then SSH server is
automatically started when the device boots.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-11 13:40:07 +02:00
Jukka Rissanen
ca2871b847 net: shell: Add ssh shell support
Add support for starting a ssh server or connecting to peer using ssh
to net-shell

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-05-11 13:40:07 +02:00