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>
When printing http services, show also what HTTP protocol
version is supported for that service.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
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>
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>
Use non-blocking cancellation when cancelling client inactivity
timer. This will avoid possible workqueue deadlock.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
`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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Add a list command that can show information about active
client and server ssh connections.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
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>
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>
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>
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>