The shell commands parse zero-based indexes and then use them directly as
array subscripts. Reject ARRAY_SIZE as well as larger values so the upper
bound cannot address one element past the array.
Signed-off-by: Old Ding <ai.neo.ae86@gmail.com>
Using the port_idx value obtained from the reg property of the device
node corresponding to the switch port works well so long as there is
only a single switch connected. If multiple switches are connected,
however, this approach results in clashes causing net_if_set_name to
fail with -EALREADY.
Use a static counter to ensure each DSA interface gets a unique swpX
name.
Signed-off-by: Vilhelm Engström <vilhelm.engstrom@tuta.io>
C++ extensions referencing a thread-local symbol such as errno emit
R_AARCH64_TLSLE_ADD_TPREL_HI12/_LO12_NC relocations and carry the
symbol in an SHF_TLS section. Loading such an extension currently
fails twice over: the .tbss section collides with .bss ("Multiple
SHT_NOBITS") and the relocation types are unknown to the arm64
relocator.
An extension has no TLS block of its own; it executes in one of the
loader's threads and shares that thread's TLS block. Skip SHF_TLS
sections in llext_map_sections() since they are never mapped as
runtime regions, and resolve the two local-exec relocations in the
arm64 relocator with tpoff = st_value + addend + TCB size, per the
AArch64 variant I TLS layout.
Add a C++ test extension (scenario llext.tls) that defines errno in
.tbss at the loader's offset and round-trips a value through the
loading thread's errno slot.
Signed-off-by: Jonathan E. Peace <jep@alphabetiq.com>
Dropped redundant net_pkt_ref for timestamped packets, because
this had already been maintained in net_if driver to make sure
pkt not released during callback handling.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Dropped redundant correction field initialization during sending
PTP packets, because it had been initialized during preparing
packets.
The correction field initialization in gptp_send_pdelay_resp()
was overriding the value initialized in gptp_prepare_pdelay_resp().
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Extend the `SEMIHOST` data dump function with support for multiple dumps
per application run, such as when the test application is intentionally
testing reboot paths.
Instead of the final `filename.gcda` file being overwritten on each
boot, create a unique `filename.gcda.{X}` file per boot, which are then
merged back into `filename.gcda` by `coverage.py`. The merging step is
required as the coverage tools expect specific paths for the GCDA files
derived from the source filename, they are not searching through the
folders for any filenames containing 'gcda'.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Respect the exclusion path set by `COVERAGE_DUMP_PATH_EXCLUDE` when
dumping with `COVERAGE_SEMIHOST`. This is less critical than for the
console dump method, but can still reduce the amount of unused binary
files created on disk.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Always close the opened file descriptor after dumping the data to the
file, not just on the very last loop iteration.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Per documentation, the `module-str` variable used by the logging Kconfig
template should NOT contain strings, but instead the bare (unquoted)
name of the module.
Clean up Kconfig files in the Bluetooth subsystem which used quotes
where they shouldn't have, resulting in inconsistent option prompts
compared to all other logging options in tree.
Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
Add support for selecting eMMC HS400 Enhanced Strobe (HS400ES) when
supported by both the card and host.
Track enhanced strobe state in sdhc_io so hosts can apply it through
sdhc_set_io(). Add the corresponding host capability and devicetree
property, and decode STROBE_SUPPORT from EXT_CSD[184].
Enter HS400ES directly from HS timing using 8-bit DDR with the strobe bit
set, then configure HS400 signaling with enhanced strobe in the host I/O
state. Clear residual enhanced-strobe state during SDHC I/O initialization.
Signed-off-by: Piter Zhang <zhangtdvip@163.com>
Link-Local Multicast Name Resolution (LLMNR, RFC 4795) is being phased
out. Microsoft is retiring the protocol and it is disabled by default on
modern Windows for security reasons. mDNS is the modern replacement and
Zephyr already provides both an mDNS resolver and responder.
Deprecate the LLMNR resolver and responder Kconfig options by selecting
DEPRECATED and marking the prompts with [DEPRECATED]. Enabling either
option now emits a deprecation warning when the Kconfig tree is parsed.
The feature still works during the deprecation period; per the API
lifecycle policy it can be removed after two full releases (5.0 at the
earliest).
Document the deprecation in the 4.5 release notes and migration guide,
pointing users to mDNS (CONFIG_MDNS_RESOLVER / CONFIG_MDNS_RESPONDER).
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If notifications sent in the notify_cb function (system wq)
fails due to e.g. buffer issues, they are now retried, so that
it is ensure that the notification is sent.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
A peer replying to the ESC[6n cursor-position query with ESC[0;0R
causes terminal_size_get() to store terminal_wid = 0. Any later
shell-core helper that divides or moduloes by terminal_wid then
faults with a divide-by-zero.
Validate the parsed coordinates and treat zero as a parsing failure.
cmd_resize() already restores CONFIG_SHELL_DEFAULT_TERMINAL_WIDTH/
HEIGHT on error, so a forged reply now behaves the same as a
terminal-response timeout.
Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
Read-only strings can only be skipped if shell main core has
access to the read only memory of the remote core. By default
assume that it has not access.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Add CONFIG_NET_IPV6_UNSOLICITED_NA. When enabled, the node multicasts an
unsolicited Neighbor Advertisement (RFC 4861 chapter 7.2.6) to the
all-nodes address, with the Override flag set and the target set to the
address, when one of its unicast addresses is added or passes Duplicate
Address Detection. This is the IPv6 counterpart of gratuitous ARP: it lets
neighbors that still hold an entry correct a stale link-layer address
without waiting for Neighbor Unreachability Detection. A neighbor that has
already dropped its entry ignores it (RFC 4861 chapter 7.2.5).
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Assisted-by: Claude:claude-opus-4.8
Call net_ipv6_nbr_clear_cache() from the interface-down path so that stale
IPv6 neighbor entries are dropped when the link goes down and re-resolved
once it is back.
The IPv6 test suite needs an update as the test cases are stateful and the
neighbor needs to be added for the reachability hint.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Assisted-by: Claude:claude-opus-4.8
Add net_ipv6_nbr_clear_cache, which removes all non-static IPv6 neighbor
cache entries of an interface. It is meant to be called when the interface
link goes down so that the entries are re-resolved on link-up;
the re-resolution Neighbor Solicitation carries the Source Link-Layer
Address option (RFC 4861 chapter 7.2.2), letting a peer that dropped
its entry for this node relearn it. This is the IPv6 counterpart of
clearing the ARP cache on link down.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Assisted-by: Claude:claude-opus-4.8
Reorder the track_1_x and track_2_x entries so the longer track
set comes first and the segment navigation flow matches the
expected test sequence. Also change segment durations to be one
third of the track duration, so the segment layout scales with
the track data.
Signed-off-by: Alex Ciascai <alexandru.ciascai@nordicsemi.no>
virtiofs_read() validated only error/used_len but passed expected_len=-1
to virtiofs_validate_response(), skipping the length check. The host-
supplied out_header.len was then used to compute the return value; a
value smaller than sizeof(out_header) underflowed, and a value larger
than the read buffer would misrepresent the bytes read.
Guard against both cases before returning.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
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/pmci/ -type f -exec \
./scripts/check_quoted_includes.py -w {} \;
Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
Some toolchains (e.g. Clang) merge the symbol string table and the
section header name table into a single ELF section, so STRTAB and
SHSTRTAB end up referring to the same file region. This is valid ELF,
but the file-offset overlap check in llext_map_sections() rejects it
with -ENOEXEC.
Skip the overlap check for the STRTAB<->SHSTRTAB pair only. All other
overlap combinations continue to be rejected as before.
Assisted-by: Claude:Claude Opus 4.8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Cast ELF section size fields to size_t in LOG_ERR format arguments to
match %zu and avoid -Wformat warnings on 64-bit targets.
Assisted-by: Claude:Claude Opus 4.8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Make llext_find_tables() independent from section scan order.
Clang can emit .strtab before .symtab/.dynsym, while the previous
logic only discovered the linked symbol string table if it appeared
later in the scan. That left important tables unresolved and caused
LLEXT loads to fail during important table discovery.
Resolve this by recording the symbol table index and linked strtab
index during the scan, then assigning both tables after the loop.
This keeps behavior unchanged for GCC and fixes LLVM failures on ARM
LLEXT tests such as llext.dynamic_heap and related variants.
Emit a warning during section discovery when the ELF object contains no
symbol table (SHT_SYMTAB/SHT_DYNSYM), which typically means the object was
stripped. The subsequent missing-section check still fails the load with
-ENOEXEC, but the warning gives a clearer reason for the failure.
The string table index is taken verbatim from the symbol table's sh_link
field. A malformed or malicious ELF can set this to an index past the end
of the section header array. Turn an out-of-bounds index into an
explicit -ENOEXEC with a descriptive error.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Clang generates different ELF layouts than GCC, which was causing LLEXT
module loading failures.
Init array validation was too strict:
- Clang may set sh_entsize to 0 (variable) while GCC uses sizeof(void *)
- Both are valid. Accept both values and only validate size divisibility
when sh_entsize is non-zero.
Assisted-by: Claude:Claude Opus 4.8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Commit ca3d07f70e ("timing: add timing_timestamp_get() for monotonic
timestamps") added a public timing_timestamp_get() to
<zephyr/timing/timing.h>. The app_kernel and latency_measure benchmarks
already define a local userspace syscall of that name to read the raw
timing counter from user threads, and they include timing.h, so the
declarations now collide:
error: static declaration of 'timing_timestamp_get' follows non-static
declaration
Rename the newly added API to timing_ns_get(). Besides resolving the
clash, the name better reflects that it returns a monotonic nanosecond
value, not the raw timing_t counter that the benchmarks' helper returns.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
New Kconfig option, `LIBMCTP_CONTROL_HANDLER_ENABLED` which matches
libmctp `MCTP_CONTROL_HANDLER_ENABLED`. When set, libmctp will handle
control messages before the application can get them. This behaviour of
libmctp can cause problems for applications that want to handle those
messages themselves. With this option, applications can have a choice.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
Some libmctp functions, namely `mctp_message_tx_request` take ownership
of the buffer passed to them. So this buffer needs to come from the same
heap libmctp has access to. This patch makes the allocation/deallocation
functions public, so they can be used by applications.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
zsock_accept() included some obsolete code related to the old TCP stack
behavior, which caused that incoming TCP connections that were already
closed generated an error instead of having FD assigned. This made the
server side unreliable, as it prevented the server from reading out data
received on such connections in case of late accept().
Also the accepted/closed net context flags are not set/checked anywhere
else in the network stack, so there's no need to use them at the socket
layer anymore.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
If a network device is not ready, e.g. the device failed to init,
do not call init on its iface as this might cause a crash.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
timing_counter_get() may be backed by a counter narrower than 64 bits
that wraps. Consumers wanting an absolute time reference rather than the
duration between two readings (the CTF trace timestamp, the
instrumentation timestamp) computed the interval from a fixed zero, which
simply returns the raw counter and so jumps backwards on every wrap.
Add timing_timestamp_get(), which accumulates the interval since its
previous reading into a 64-bit total before converting to nanoseconds, so
the result stays monotonic across wraps. Each interval is non-negative, so
the value is monotonic no matter how often the function is called; it is
also accurate as long as no more than one wrap occurs between consecutive
calls, beyond which it undercounts the elapsed time but still only
advances. The accumulator is not seeded on the first call, so timestamps
are offset by the counter value at that point rather than starting from
zero, just like the previous version did; this only shifts the origin and
avoids a first-call test on every subsequent call. A spinlock keeps the
shared accumulator consistent on SMP, where the callers' irq_lock does
not.
Use it from both consumers, which previously open-coded the zero-based
form. The cost stays on this absolute-timestamp path; consumers that
measure intervals between two explicit readings are unaffected.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
The interface link-local address is generated as a side effect of
net_if_start_dad(), which only runs when DAD is enabled. With
CONFIG_NET_IPV6_DAD disabled an interface therefore came up without any
link-local address, breaking IPv6 on it.
Extract the link-local generation into iface_ipv6_lladdr_add() and call it
from net_if_start_dad() (which no longer duplicates the IID generation)
and, when DAD is disabled, from iface_ipv6_start().
Adapt the net.iface and net.ip-addr tests, which run with DAD disabled and
relied on interfaces not autoconfiguring a link-local address.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Assisted-by: Claude:claude-opus-4.8
After this option was merged enabled by default, multiple
samples and tests failed to build.
Let's leave it disabled by default.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Added option CONFIG_LOG_PRINTK_STATIC which redirects printk's to
logging macro which creates message during compilation by examining
argument types using _Generic keyword. When this option is enabled
printk format string is not accessed in runtime so it can be removed
(e.g. in dictionary based logging). When this option is enabled printk
is much faster. Option is implied when dictionary based logging is
enabled.
The only condition that must be met to use build time message creation
macros is that format string is a string literal and not a variable.
That is the case for printk because it is using __printf_like gcc
extension to validate that.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
The DPLPMTUD cache entries live in a fixed array and are reclaimed with
an LRU policy in net_dplpmtud_get_or_create_entry(). The path API and
net_dplpmtud_sync_from_pmtu() previously resolved an entry under the
module lock, released it, and then re-acquired the lock to read or
update that entry. In the window between the two lock holds another
thread (for example the RX path handling an ICMP "packet too big")
could create a new entry, evict this one as the LRU victim, and reuse
it for a different destination. The pending read or update would then
be applied to the wrong peer's probe / flow-control state.
Hold the module lock across both the lookup and the subsequent read or
update so an entry cannot be evicted and reused in between. The
per-operation helpers also take the lock, but k_mutex is recursive so
the nested acquisition is a no-op while the wrapper holds it. There is
no cross-module deadlock: the PMTU cache calls into DPLPMTUD without
holding its own lock, and DPLPMTUD only calls the non-recursive
net_pmtu_update_mtu_from_dplpmtud() variant.
Tested with tests/net/pmtu on qemu_x86 (78/78) and tests/net/lib/quic
on native_sim (68/68, including the packet-loss test_340).
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Drop duplicate probe_size, probe_in_flight, and probe_pending fields
from QUIC endpoints. Probe scheduling and PTO handling now query the
shared DPLPMTUD path cache through net_dplpmtud_get_path_probe_size()
and net_dplpmtud_path_probe_in_flight().
Assisted-by: Cursor:Auto
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Reserve probe state in the generic DPLPMTUD core before transmitting
the QUIC probe packet. If the send fails, report probe loss so core
and endpoint state stay aligned.
Assisted-by: Cursor:Auto
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
net_dplpmtud_get_path_mtu() and net_dplpmtud_get_path_probe_size() no
longer create per-destination state or pull from the PMTU cache on
read. Only net_dplpmtud_init_path() and probe-send reporting establish
or refresh path state.
Assisted-by: Cursor:Auto
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Apply PMTU destination-cache updates through net_dplpmtud_sync_from_pmtu()
so ICMP PTB reductions below the base PLPMTU trigger black-hole fallback.
Write the resulting validated PLPMTU back into the shared PMTU cache and
document the transport-facing black-hole API.
Assisted-by: Cursor:Auto
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
When a probe is acknowledged, record the validated PLPMTU in the
shared PMTU destination cache so other stack users see the discovered
path size. Skip the PMTU-to-DPLPMTUD sync on that update so the search
ceiling is not clamped to the newly validated size, and only apply
PMTU-cache ceiling changes that raise max_plpmtu or reflect PTB-style
reductions below the validated PLPMTU.
Assisted-by: Cursor:Auto
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Refactor QUIC to use the generic DPLPMTUD subsystem for path MTU
search state, probe bookkeeping, and validated payload size
management. QUIC keeps transport-specific responsibilities such as
building PING+PADDING probes and confirming them through ACK and loss
processing.
This change also keeps the peer's max_udp_payload_size limit separate
from the currently validated send size so QUIC can apply transport
limits without duplicating the DPLPMTUD state machine.
Assisted-by: Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Extend the existing no-fragment socket and packet handling so UDP
transports can request no-fragment behaviour on a per-datagram basis.
This avoids transport code having to toggle socket state around probe
sends and provides a cleaner foundation for generic DPLPMTUD probes.
The new path is transport-agnostic and is intended for RFC 8899 probe
datagrams that must be sent at an exact size without local IP
fragmentation.
Assisted-by: Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add a transport-facing API for the generic DPLPMTUD subsystem.
Transports can now create a path handle, query the current validated
PLPMTU, request probe sizes, and report probe sent, probe acked, and
probe lost events back to the core.
The subsystem continues to own only RFC 8899 state management. Probe
packet construction and transport-specific confirmation remain with
the transport consumer.
Assisted-by: Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Connect the new DPLPMTUD core to the existing PMTU cache so path
state can be seeded from cached PMTU data and adjusted by PTB-driven
reductions. Validated DPLPMTUD results are also fed back into the
shared PMTU cache.
This keeps PMTU cache handling and RFC 8899 probing consistent across
IPv4 and IPv6 without adding any transport-specific logic yet.
Assisted-by: Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add a generic Datagram Packetization Layer PMTU Discovery core in
subsys/net/ip/dplpmtud.[ch]. The new code keeps per-path DPLPMTUD
state such as the validated PLPMTU, probe size, retry counters, and
search bounds required by RFC 8899.
This change only introduces the core state and internal helpers. It
does not yet connect the subsystem to PMTU cache handling, generic
UDP send support, or any transport consumer.
Assisted-by: Copilot:gpt-5.4
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The device-lock policy references no pm_device_* API; enum pm_state and
the constraint helpers come from <zephyr/pm/state.h>. Remove the unused
<zephyr/pm/device.h> include.
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
All output in the PM shell goes through shell_print()/shell_error()
from <zephyr/shell/shell.h>; no stdio symbols are used. Remove the
unused <stdio.h> include.
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
pm.c uses no string/memory functions (<string.h>), registers no SYS_INIT
handler (<zephyr/init.h>), and calls no pm_device_runtime_* API
(<zephyr/pm/device_runtime.h>). Remove these three unused includes.
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
Expose a new le_param_update_rejected callback in bt_conn_cb that is
invoked when a connection parameter update request is rejected, covering
both the HCI Connection Parameter Request (CPR) procedure and the L2CAP
Connection Parameter Update Procedure (CPUP) fallback.
The feature is gated by the new Kconfig option BT_USER_CONN_PARAM_REJECT.
When enabled, le_conn_update_complete() reports a rejection only for
application-initiated updates that finally failed, i.e. not while a
host-initiated (auto) update is still being retried and not for the
auto-initiated updates themselves, matching the documented scope of the
callback. The L2CAP fallback path reports a rejection using the synthetic
BT_HCI_ERR_L2CAP_CPUP_REJECTED (0xFF) code so applications can distinguish
an L2CAP fallback rejection from a real HCI CPR rejection error code.
As part of this, le_param_updated() is no longer called when an update
fails (previously it was called unconditionally, reporting the unchanged
parameters with no error indication). This behaviour change is documented
in the migration guide.
Add release note and migration guide entries and a bsim test under
tests/bsim/bluetooth/host/misc/conn_param_update_reject that exercises both
the application-initiated rejection path and that a rejected host-initiated
(auto) update does not trigger the callback.
Signed-off-by: Sharon Lin <slin@atmosic.com>