Commit graph zephyr/subsys
Author SHA1 Message Date
Jukka Rissanen
c0e9cf04a1 net: quic: Reject TLS KeyUpdate as a protocol violation
A received TLS KeyUpdate (handshake type 24) fell into the
unknown-message default of process_handshake_message and was silently
ignored, which can desync the connection against a peer whose stack
emits one.

RFC 9001 Section 6 prohibits the TLS KeyUpdate message in QUIC (QUIC
does its own key update via the packet key phase bit). Reject it with
-EPROTO, which surfaces as a PROTOCOL_VIOLATION CONNECTION_CLOSE. Add a
unit test.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-24 09:44:52 +02:00
Jukka Rissanen
ef5a55d720 net: quic: Send client SNI (server_name)
The TLS 1.3 client never sent the server_name (SNI) extension, so a
standard QUIC/TLS peer that requires SNI or virtual-hosts on it could
not be reached.

Implement the previously stubbed ZSOCK_TLS_HOSTNAME setsockopt by
storing the hostname on the TLS context options, and emit the
server_name extension (RFC 6066) in the ClientHello when a hostname is
configured. When no hostname is set nothing is emitted. A single-cert
server needs no cert selection and already tolerates the extension via
the ignore-unknown path, so no server change is required.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-24 09:44:52 +02:00
Jukka Rissanen
5fbd66da09 net: quic: Offer x25519 and secp256r1 client key shares
The TLS 1.3 client offered only a secp256r1 key_share and
supported_groups entry, and parse_server_hello hard-rejected any group
other than secp256r1. Standard QUIC/TLS stacks prefer x25519, so a
Zephyr client could only complete a handshake with a peer configured to
accept secp256r1, and had no way to use x25519 at all.

Offer both x25519 (preferred) and secp256r1 in supported_groups and
key_share. Generate two ephemerals up front: the x25519 primary in
ecdh_key_id and the secp256r1 alternative in ecdh_key_id2. When the
ServerHello selects a group, keep the matching ephemeral, destroy the
other, and drive the ECDH with it. parse_server_hello now accepts
either group.

The server side already accepted both groups, so no server change is
needed. generate_ecdh_keypair is refactored into a group-parameterized
helper reused for both offers. The unselected offer is also destroyed
on handshake teardown to avoid leaking a PSA key.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-24 09:44:52 +02:00
Yangbo Lu
95c3056eb5 net: shell: improve PTP clock capability description
PTP clock is term from IEEE 1588, while IEEE 802.1AS gPTP is
just a profile of IEEE 1588. We should specify IEEE 1588 PTP
clock capability here. It can be used for gPTP or any other
profiles.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-07-23 21:05:55 -07:00
Jukka Rissanen
f24fcb8831 net: shell: Add "net udp dplpmtud_server" responder command
Add a companion to "net udp dplpmtud" for the responder side: bind a UDP
net_context to a local address/port, register a receive callback and enable
DPLPMTUD. On an unconnected (bound) socket this turns on the responder role
only, echoing each received Request (REQ) token back in a Response (RES)
option; no probing is started as there is no fixed destination. Together
with the prober command this allows a full prober<->responder round trip to
be exercised between two instances from the shell.

Usage:
  net udp dplpmtud_server <addr> <port>

Only compiled in when CONFIG_NET_UDP_OPTIONS_DPLPMTUD is enabled.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-23 18:02:33 -04:00
Jukka Rissanen
707eb603bf net: udp: Raise DPLPMTUD ceiling to the link cap when enabling
net_context_set_udp_dplpmtud() called net_dplpmtud_init_path() with the
local link capability, but init_path only records it as the per-path
limit; the shared per-destination entry stays at BASE_PLPMTU. As a result
net_dplpmtud_get_path_probe_size() returned 0 and the prober never sent a
probe (the socket effectively acted as a responder only).

Call net_dplpmtud_set_path_max_plpmtu() right after init_path to raise the
shared entry's ceiling to the link capability so the search can proceed
above the base size, mirroring the QUIC DPLPMTUD driver.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-23 18:02:33 -04:00
Jukka Rissanen
01e0dad812 net: dplpmtud: Reopen the PLPMTU search when the path ceiling grows
The DPLPMTUD search never probed above BASE_PLPMTU. A per-destination
entry is created with max_plpmtu = BASE_PLPMTU, and the only place
search_high is opened to the ceiling is at entry init. Two issues kept it
pinned at base afterwards:

- sync_search_bounds_locked() computed search_high as
  MIN(search_high, max_plpmtu), so raising max_plpmtu never widened the
  search window, only PTB-style reductions could narrow it. This
  contradicts the documented intent in sync_entry_from_pmtu_cache()
  ("Raise the search ceiling when the PMTU cache reports a larger path
  limit").

- net_dplpmtud_set_path_max_plpmtu() only stored the per-path limit and
  left the shared entry's max_plpmtu at base, so get_path_limit() (the
  MIN of the two) stayed at base and get_path_probe_size() returned 0.

Track the ceiling in both directions in sync_search_bounds_locked(), and
grow the shared entry's ceiling from net_dplpmtud_set_path_max_plpmtu()
(never shrink it, since another path/transport to the same destination may
support more; get_path_limit() still clamps each probe to the calling
path's own limit). With this, a freshly enabled prober actually emits
probes above the base size.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-23 18:02:33 -04:00
Jukka Rissanen
091ee5f733 net: shell: Add "net udp dplpmtud" probe command
Add a shell command to start DPLPMTUD (RFC 9869) probing over UDP options
towards a given host, so the feature can be exercised interactively.

The command creates a connected UDP net_context to the destination,
registers a receive callback (so probe Response (RES) echoes are seen) and
enables DPLPMTUD via net_context_set_option(NET_OPT_UDP_OPT_DPLPMTUD). On a
connected context this makes the prober emit an initial BASE_PLPMTU probe
(a DF-set, REQ-bearing datagram padded through the options surplus area)
immediately and continue probing upward on its timer. The discovered size
is visible with "net pmtu"; "net udp close" stops probing.

Usage:
  net udp dplpmtud <host> <port>

Only compiled in when CONFIG_NET_UDP_OPTIONS_DPLPMTUD is enabled.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-23 18:02:33 -04:00
Jukka Rissanen
de226c9354 net: udp: Add DPLPMTUD prober and probe timer
Implement the RFC 9869 prober role for UDP sockets. When DPLPMTUD is
enabled on a connected UDP context, the stack drives the generic
DPLPMTUD engine:

- net_context_set_udp_dplpmtud() initialises the engine path for the
  connected peer (bounded by the interface MTU), arms a k_work_delayable
  probe timer and launches the first probe.
- Each probe is a payload-less UDP datagram carrying a REQ option with a
  fresh random token, padded through the surplus area to the target size
  and sent with the Don't Fragment bit set.
- A returned RES matching the outstanding token confirms that probe
  (net_dplpmtud_on_path_probe_acked) and launches the next; a probe not
  answered before the timer expires is declared lost
  (net_dplpmtud_on_path_probe_lost). -EALREADY (another transport probing
  the shared per-destination entry) and -EMSGSIZE are handled by backing
  off and clamping the search respectively.

Confirmed PLPMTU values are written to the PMTU cache by the engine, so
applications read the result via getsockopt(IP_MTU / IPV6_MTU).

The explicit BASE_PLPMTU connectivity confirmation from RFC 9869 is not
yet performed; the engine's base floor and downward search cover the
common cases, matching the existing QUIC DPLPMTUD driver.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-23 18:02:33 -04:00
Jukka Rissanen
ed057f3371 net: udp: Support padding the UDP options surplus area
Add a transmit-only pad_to_surplus field to struct net_udp_opt_info.
When set, net_udp_opt_append() pads the surplus area with an End of
Options List (EOL) option followed by trailing zeroes so that it reaches
the requested size, and net_udp_opt_surplus_len_with_opts() reports the
padded length. The padding is covered by the OCS and ignored by a
receiver (post-EOL zeroes are already accepted), per RFC 9868/9869.

This is the mechanism used to inflate a DPLPMTUD probe datagram to a
target size. It is inert (pad_to_surplus == 0) for all existing callers.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-23 18:02:33 -04:00
Jukka Rissanen
46b0792296 net: udp: Auto-echo DPLPMTUD REQ as RES (responder)
Implement the RFC 9869 responder role: when DPLPMTUD is enabled on a UDP
context and a received datagram carries a Request (REQ) option, echo the
four-byte token back to the source in a Response (RES) option, unless the
application has opted to handle the echo itself
(ZSOCK_UDP_OPT_DPLPMTUD_APP_RESPOND).

The reply reuses the normal sendmsg path with a synthetic
ZSOCK_UDP_OPT_CMSG_RES control message and no user payload, and is sent
directly from the receive path, mirroring how the stack already emits TCP
ACKs and ICMP echo replies. Per RFC 9869 the stack does not echo until
DPLPMTUD has been enabled on the socket.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-23 18:02:33 -04:00
Jukka Rissanen
0ac59d41df net: udp: Add DPLPMTUD over UDP options config and socket API
Add the configuration, per-socket state and socket-option surface for
DPLPMTUD (RFC 8899) over UDP options (RFC 9869). This commit only adds
the plumbing; the probing and responder behaviour follow in later
commits.

- New Kconfig NET_UDP_OPTIONS_DPLPMTUD (depends on NET_UDP_OPTIONS and
  NET_PMTU_DPLPMTUD) plus probe-timeout and raise-timer tunables.
- Per-socket DPLPMTUD state in net_context: a net_dplpmtud_path handle,
  a probe/retransmit k_work_delayable timer, the outstanding probe
  token and size, and the enabled / app_respond / base_confirmed flags,
  all behind the new option.
- New socket options ZSOCK_UDP_OPT_DPLPMTUD and
  ZSOCK_UDP_OPT_DPLPMTUD_APP_RESPOND with setsockopt/getsockopt handlers,
  and a net_context_set_udp_dplpmtud() enable API.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-23 18:02:33 -04:00
Jukka Rissanen
cc1b6ca97c net: udp: Add UDP options support (RFC 9868)
UDP options are carried in the "surplus area" of an IP datagram: the
space between the end of the UDP payload (as given by the UDP Length
field) and the end of the IP payload. Because it lies beyond the UDP
Length, that area is ignored by receivers that do not understand
options, which keeps the extension backwards compatible.

Add sending and receiving of UDP options:

  - On transmit, net_udp_opt_append() writes the option area (alignment
    padding, the Option Checksum (OCS) and the enabled TLV options) after
    the UDP user data, and net_udp_opt_finalize_ocs() fills in the OCS.
    The UDP Length field keeps covering only the header and user data.
  - On receive, net_udp_opt_parse() locates the surplus area, validates
    the OCS and parses the TLV options into a result structure.
  - net_calc_chksum() now scopes the UDP checksum to the UDP Length bytes,
    so the surplus area (protected separately by the OCS) is excluded, as
    required by RFC 9868.

The OCS, APC (Additional Payload Checksum, carried transparently for the
application), MDS, MRDS, REQ/RES (Echo Request/Response) and TIME
(Timestamp) options are handled. Unknown options in the SAFE range are
ignored; an option in the UNSAFE range or a known option with an invalid
length causes all options in the datagram to be discarded. A datagram
with a valid UDP checksum is still delivered to the application even when
the OCS fails; only the options are dropped.

Applications configure options per socket with setsockopt()/getsockopt()
(ZSOCK_UDP_OPT*) and per datagram with sendmsg()/recvmsg() control messages
(ZSOCK_UDP_OPT_CMSG_*).

The feature is guarded by CONFIG_NET_UDP_OPTIONS and disabled by default.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-23 18:02:33 -04:00
Fin Maaß
5950810b0e net: ethernet: gptp: use net_pkt_set_tx_timestamping
use net_pkt_set_tx_timestamping to
enable timestamping for that packet.
Only timestamp these packets with
GPTP_SYNC_MESSAGE or
GPTP_PATH_DELAY_RESP_MESSAGE
as only these have callbacks registered with
net_if_register_timestamp_cb().

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-07-23 18:15:38 +02:00
Fin Maaß
92e491317e net: lib: dns: remove dns_dispatcher_init()
remove dns_dispatcher_init, as
it is no longer needed.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-07-23 16:24:35 +02:00
Fin Maaß
29be07c590 net: conn_mgr: use NET_MGMT_REGISTER_EVENT_HANDLER
use NET_MGMT_REGISTER_EVENT_HANDLER,
so we no longer need to init that part during
runtime. As these are now registered during
build we also no longer have to check the state
of the ifaces before registering the event handlers.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-07-23 16:20:14 +02:00
Siddhant Modi
258cac4b9d net: dhcpv4: add net_dhcpv4_set_reboot_hint()
Add a public API to seed the DHCPv4 client with a previously leased
address, for example one restored from non-volatile storage, so that
the next start begins in INIT-REBOOT state and requests the address
directly instead of performing a full discovery.

Signed-off-by: Siddhant Modi <siddhant.modi@gmail.com>
2026-07-23 16:11:45 +02:00
Siddhant Modi
553a739f19 net: dhcpv4: restart configuration on NAK in INIT-REBOOT state
A NAK received in INIT-REBOOT state was compared against
request_server_addr, which is only populated when a REQUEST is sent
from the REQUESTING state. An INIT-REBOOT REQUEST carries no server
identifier, so the NAK was treated as coming from a non-requesting
server and ignored. The client kept retransmitting the REQUEST until
all attempts were exhausted before falling back to discovery.

Per RFC 2131 3.2, a rebooting client that receives a DHCPNAK cannot
reuse its remembered address and must restart the configuration
process. Accept the NAK in INIT-REBOOT state and restart discovery
immediately.

Signed-off-by: Siddhant Modi <siddhant.modi@gmail.com>
2026-07-23 16:11:45 +02:00
Rodrigo Peixoto
a4c436128b zbus: Fix message subscribers net buf isolated pools usage
The net buf isolated pools feature definition inside the channel was wrong.
That was causing a false sensation that the feature was set up correctly,
but it was never set. It was forcing the developer to set an isolated pool
to all the msg subscribers, which is a wrong behavior.

This commit fixes that by adjusting the configuration usage, adding the
`CONFIG_` prefix, and placing the initialization in the proper place (the
`zbus_channel_data`, instead of the `zbus_channel` directly). It also
adapts the test to capture the issue and avoid regressions.

Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
2026-07-23 16:10:52 +02:00
Yangbo Lu
8374e000a5 net: gptp: drop lots of CONFIG_NET_GPTP_CLOCK_ACCURACY_* options
The clock accuracy value in IEEE 802.1AS is Enumeration8 from 0
to 255. Some reserved values may be also defined to use as standard
evolves. We don't have to define Kconfig option for each of them.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-07-23 16:08:43 +02:00
Yangbo Lu
0cc2102567 net: move net_gptp_init declaration to gptp header file
Moved net_gptp_init declaration to gptp header file.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-07-23 16:08:43 +02:00
Yangbo Lu
3e7b667a23 net: ethernet: drop unused gptp header including
Dropped unused gptp header including.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-07-23 16:08:43 +02:00
Krzysztof Chruściński
dc78cbe292 ipc: ipc_service: backends: icbmsg: Align to the API return values
Return values as states in the API contract:
- ipc_service_send_nocopy shall return number of bytes that were sent
- ipc_service_drop_tx_buffer returns -EALREADY if buffer is not
allocated.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-07-23 16:08:37 +02:00
Benjamin Cabé
5dc4ca7bc4 net: conn: Reject non-matching connections with the cheapest test first
The per-packet connection lookup loop checked the interface binding
first, which requires following two pointers into the connection's
context, before the protocol comparison that is a single byte compare.
Since a mixed UDP/TCP system always has connections of the other
protocol registered, do the protocol check first so most non-matching
connections are rejected with a single comparison.

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-07-22 17:09:30 -04:00
Robert Rozelle
14876e5ac9 net: mdns_responder: fix v4_svc/v6_svc undersized for probe's resolver
v4_svc/v6_svc are shared between the per-interface listener dispatch
(needs one fd per interface) and, when CONFIG_MDNS_RESPONDER_PROBE is
enabled, send_probe()'s temporary DNS resolve context (needs
DNS_RESOLVER_MAX_POLL fds for its own server list -- 3 with IPv4+IPv6
mDNS both enabled). They were sized only for the listener-dispatch use
(MDNS_MAX_IPV4/6_IFACE_COUNT, i.e. the interface-count Kconfigs,
default 1), so any probe attempt failed
net_socket_service_register()'s capacity check with -ENOMEM and every
probe silently timed out -- init_listener() never ran.

net_socket_service_register() fully replaces the previously registered
descriptor set on every call rather than accumulating (see
cleanup_svc_events() in sockets_service.c), so the two uses never need
their capacities summed, just sized to cover whichever is larger.

Size both off MAX(interface count, DNS_RESOLVER_MAX_POLL) when probing
is enabled; unchanged otherwise, to avoid wasting static memory on
non-probing builds.

Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Robert Rozelle <rwrozelle@gmail.com>
2026-07-22 17:09:21 -04:00
Fin Maaß
756eed14d0 net: ethernet: lldp: use NET_MGMT_REGISTER_EVENT_HANDLER
use NET_MGMT_REGISTER_EVENT_HANDLER for
registering the event at compile time. With that the
lldp init is no more nessesary.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-07-22 19:07:21 +01:00
Benjamin Cabé
bb1888d8b9 net: Avoid redundant packet length walks in the hot path
net_pkt_get_len() walks the whole fragment chain. It is called for
every packet in net_rx() and net_queue_rx() even though the result is
only used for statistics and debug logging, and in dummy_send() after
the packet has already been handed over to the driver.

Only compute the length when statistics or debug logging actually
consume it, and in dummy_send() get the length before sending: with a
loopback driver the RX path may consume (and shorten) the packet as
soon as it has been handed over.

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-07-22 19:06:23 +01:00
Benjamin Cabé
c08d6af1a4 net: utils: Speed up checksum calculation on 64-bit targets
On 64-bit targets, process the bulk of the checksummed data 8 bytes at
a time, accumulating into two independent 128-bit accumulators. This
doubles the bytes moved per load, needs no carry handling inside the
loop, and the two accumulators let the additions execute in parallel,
unlike an end-around-carry chain which serializes on the carry of
every addition.

Correctness verified against the existing implementation with 200000
randomized buffers covering all alignments (0-7), lengths 0-2000 and
initial sums, plus the tests/net/utils suite.

In isolation the checksum runs 1.1x faster for 256 byte buffers and up
to 1.75x faster for large buffers on x86-64.

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-07-22 19:06:12 +01:00
Jukka Rissanen
40ce6fc854 net: dhcpv6: Fix comment in Kconfig about server support
The comment in the top of the Kconfig file claimed IPv4 server
support, but it should have said IPv6 client support.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-22 19:04:46 +01:00
Jukka Rissanen
b66c5e6e6e net: dhcpv6: Support information-request exchange
Allow the DHCPv6 client to start in information-only mode when no
address or prefix is requested. Send Information-request messages, handle
valid Reply messages, and complete the exchange without configuring IA_NA
or IA_PD leases.

Use INF_MAX_RT for Information-request retransmissions. Once the exchange
completes, schedule a refresh of the received configuration as required
by RFC 8415, ch. 18.2.6: honor the server provided Information Refresh
Time option (ch. 21.23) clamped to IRT_MINIMUM, fall back to IRT_DEFAULT
when it is absent, and treat the 0xffffffff value as no refresh. When the
refresh timer expires the client re-enters the Information-requesting
state.

Add tests for message format, stable transaction IDs, Reply handling, the
full Information-request exchange (including that a refresh is scheduled),
and that SOL_MAX_RT/INF_MAX_RT are applied from a Reply carrying a failure
Status Code.

Assisted-by: Cursor:GPT-5.5
Assisted-by: Claude:Opus 4.8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-22 19:04:46 +01:00
Jukka Rissanen
0d646c18dc net: dhcpv6: Handle max retransmission time options
Parse SOL_MAX_RT and INF_MAX_RT options from DHCPv6 server responses and
store the learned values in the client context. Validate server-provided
values against the RFC-defined range before converting them to
milliseconds, and ignore out-of-range values.

Per RFC 8415, ch. 21.24 and 21.25, a client MUST honor these options even
when the message carries a Status Code option indicating a failure (the
common case being an Advertise with NoAddrsAvail that also lowers
SOL_MAX_RT to slow the client down). Process the options right after the
message is validated, before any status/preference/IA based early return,
and ignore a missing/malformed/out-of-range option instead of discarding
the whole message.

Use the learned SOL_MAX_RT value when calculating Solicit retransmission
timeouts. Add tests that verify both max retransmission options are
accepted from Advertise and Reply messages.

Assisted-by: Cursor:GPT-5.5
Assisted-by: Claude:Opus 4.8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-22 19:04:46 +01:00
Jukka Rissanen
6eefbac591 net: dhcpv6: Keep transaction ID stable on retransmit
Generate the DHCPv6 transaction ID when entering a new exchange instead
of every time a packet is encoded. This keeps retransmissions tied to the
same transaction ID as the original message.

Add tests that verify repeated sends for Solicit, Request, Confirm,
Renew, and Rebind preserve the transaction ID.

Assisted-by: Cursor:GPT-5.5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-22 19:04:46 +01:00
Jukka Rissanen
b48fddfacf net: dhcpv6: Reject replies from unselected server
When processing Reply messages for Request and Renew exchanges, verify
that the Server ID matches the server selected by the client. Replies
from other servers must be discarded for these exchanges, while Confirm
and Rebind can still accept replies from any server.

Add DHCPv6 tests that cover mismatched Server ID handling for Request,
Renew, Confirm, and Rebind replies.

Assisted-by: Cursor:GPT-5.5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-22 19:04:46 +01:00
Jukka Rissanen
08594f5180 net: dhcpv6: Reject oversized DUID link addresses
Add bounds checking when generating the client DUID-LL from the
interface link address. The DUID buffer size is configurable, and some
link-layer address lengths can exceed the available storage, so fail the
DHCPv6 start path instead of copying past the buffer.

Generate the client DUID before any observable side effects in
net_dhcpv6_start() (before emitting NET_EVENT_IPV6_DHCP_START and
appending the interface to the tracked list), so that a generation
failure leaves the interface untouched. Otherwise a failed start would
leave the interface registered in DISABLED state, and a subsequent start
would append its list node a second time and corrupt the list.

Cover the oversized link-address case in the DHCPv6 unit tests.

Assisted-by: Cursor:GPT-5.5
Assisted-by: Claude:Opus 4.8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-22 19:04:46 +01:00
Anas Nashif
e0f04c2847 Revert "kernel: timeout: add sys_clock_idle_enter() for low-power idle handoff"
This reverts commit 7d0bb85adc.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-07-22 10:27:24 -04:00
Tomi Fontanilles
9530967d84 secure_storage: turn CMake error into fatal one
For better visibility and understandability, make the error a fatal
one. Otherwise it's easy to miss it and linker errors are more
confusing.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2026-07-22 14:14:01 +01:00
Tomi Fontanilles
dcb0242fbf secure_storage: warn against 64-bit UID incompatibility
Make it clear in the help text of CONFIG_SECURE_STORAGE_64_BIT_UID
that compiling with and without it results in incompatible entries.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2026-07-22 14:14:01 +01:00
Tomi Fontanilles
aceb9c24aa net: lib: tls_credentials: rename backend source files
To more descriptive and accurate names.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2026-07-22 14:14:01 +01:00
Tomi Fontanilles
c430804fdc net: lib: tls_credentials: define a PSA PS UID range
Officially define the PSA PS UID range the TLS credentials PS backend
has been using.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2026-07-22 14:14:01 +01:00
Maochen Wang
4ca79bf16a net: pkt: use net_pkt_frag_unref in pull and trim paths
net_pkt_pull() and net_pkt_trim_buffer() release consumed net_buf
fragments using net_buf_unref(), which does not call
net_pkt_alloc_del(). This leaves stale entries in the net_pkt_allocs
tracking table, causing the "net allocs" shell command to incorrectly
show freed buffers as still in use.

Replace net_buf_unref() with net_pkt_frag_unref() in both paths so
that the alloc tracker is properly updated when the last reference is
dropped.

Assisted-by: WChat:Claude
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
2026-07-22 11:13:04 +01:00
Maochen Wang
2b138a4849 net: pkt: fix alloc tracking for net_buf fragments
When CONFIG_NET_DEBUG_NET_PKT_ALLOC is enabled, net_pkt_alloc_add() was
only called under CONFIG_NET_PKT_LOG_LEVEL >= LOG_LEVEL_DBG for buffer
fragments allocated in pkt_alloc_buffer(), and under NET_LOG_LEVEL >=
LOG_LEVEL_DBG for net_pkt in pkt_alloc(). This caused the "net allocs"
shell command to miss tracking many allocations.

Fix by moving net_pkt_alloc_add() calls outside the log-level guards
so they execute whenever CONFIG_NET_DEBUG_NET_PKT_ALLOC is enabled.

Also:
- Clear func_free/line_free in net_pkt_alloc_add() when reusing a slot
  to avoid displaying stale free information from a previous cycle.
- Use net_pkt_frag_unref() on the error path in pkt_alloc_buffer() so
  that alloc tracking entries are properly cleaned up on failure.
- Guard the non-fixed-data-size path with a NULL check to prevent
  dereference and tracking table pollution when net_buf_alloc_len()
  fails.

Assisted-by: WChat:Claude
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
2026-07-22 11:13:04 +01:00
Jordan Yates
231d7a9702 modem: cmux: log size of overflowing frames
When a frame can't be received because of `CONFIG_MODEM_CMUX_MTU`,
include the failing size and the current limit in the error message.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-07-22 11:04:22 +01:00
Emil Gydesen
ff354ff643 Bluetooth: BAP: Fix fake uninitialized pd var
Some compilers would give the following warning:

subsys/bluetooth/audio/bap_broadcast_source.c:513:9:
warning: 'pd' may be used uninitialized [-Wmaybe-uninitialized]
  513 |         net_buf_simple_add_le24(buf, pd);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Even though the assignment `subgroup_count = 0U;`
and later check `if (subgroup_count == 0U) {` would
ensure that `pd = stream->ep->qos.pd;` is always performed.

Add a initialization of the variable to avoid any
warnings.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-07-22 11:01:36 +01:00
Jukka Rissanen
c0605a4a21 net: lib: dns: Clear pair back-reference on dispatcher unregister
When a resolver and responder share a port they are paired, with the
existing dispatcher's pair pointer set to the newcomer. On unregister
that back-reference was left dangling: a surviving dispatcher kept a
pair pointer to the removed context and would delegate a message to it
via dispatcher->pair->cb, dereferencing a context whose socket is
closed and which may be reused, once the reworked unregister keeps the
shared socket service alive after a single close.

Walk the remaining dispatchers and clear any pair that referenced the
removed context, and clear the removed context's own pair so a later
re-register does not inherit a stale partner.

Assisted-by: Claude:Opus 4.8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-22 11:00:31 +01:00
Jukka Rissanen
6d8ff07c31 net: lib: dns: Guard against NULL dispatcher in recv_data
recv_data() looked up the dispatcher via dispatch_table[fd].ctx and
dereferenced it without a NULL check. Since a single server close now
keeps the shared socket service registered (only the closed fd is
removed from the poll set and its dispatch_table slot cleared), a poll
event for a just-closed socket can still be in flight when the slot is
cleared, leaving table[fd].ctx == NULL and crashing on the following
mutex lock.

Drop the event when the dispatch slot has already been cleared.

Assisted-by: Claude:Opus 4.8
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-07-22 11:00:31 +01:00
Robert Lubos
7bc1c58188 net: lib: dns: Keep polling remaining servers on single close
Closing one DNS server unregistered the shared socket service and
cleared dispatch_table entries for every resolver socket. Re-register
the service for surviving dispatchers and remove only the closed fd
from the shared poll array.

Assisted-by: Cursor:Composer 2.5
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-07-22 11:00:31 +01:00
Robert Lubos
81f2c9856e net: lib: dns: Flush datagram when dispatcher buffer alloc fails
When dns_msg_pool allocation fails, recv_data() returned without
reading the socket and left net_pkt buffers pinned in the queue.
Discard the pending datagram so RX buffers are released.

Assisted-by: Cursor:Composer 2.5
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-07-22 11:00:31 +01:00
Robert Lubos
754c9b0ff0 net: lib: dns: Set dispatcher ifindex on resolver registration
The DNS socket dispatcher duplicate check compares ifindex, but the
resolver never set it. Per-interface servers were rejected as
duplicates, leaving the second socket out of the socket service poll.

Assisted-by: Cursor:Composer 2.5
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-07-22 11:00:31 +01:00
Nicolas Pitre
7d0bb85adc kernel: timeout: add sys_clock_idle_enter() for low-power idle handoff
The idle argument of sys_clock_set_timeout() carries a distinct signal:
the CPU is entering low-power idle, here is its wakeup. Only the PM and
SoC power paths produce it (the timeout core always passes false), and
only a few drivers act on it to hand off to a low-power wakeup timer.

Introduce a dedicated sys_clock_idle_enter() hook for that, so the two
idle==true callers (subsys/pm and soc/nxp/rw) call it instead of
sys_clock_set_timeout(). Its weak default just programs the wakeup via
sys_clock_set_timeout(), so a driver with no low-power handling needs
nothing.

The five drivers that acted on idle (cortex_m_systick, esp32, xtensa,
mcux_os, stm32_lptim) move that handling into their own
sys_clock_idle_enter(), keeping their exact behaviour. Where the idle
path was self-contained it moves wholesale (cortex_m_systick, mcux_os,
stm32_lptim); where it shares the timeout programming, idle_enter()
calls set_timeout() first and then does its idle work (esp32), or shares
a small private helper (xtensa). set_timeout() keeps its now-unused idle
argument for the moment; nobody passes idle==true to it any more, which
lets the next change drop the argument entirely.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-07-21 18:02:43 -04:00
Josuah Demangeon
d46a8c1f8f usb: host: avoid double-free of the configuration descriptor
Upon failure to read a configuration descriptor, usbh_req_desc_cfg
ends-up being freed twice: once by usbh_device_set_configuration()
which did allocate it, once by usbh_device_free() as a clean-up measure.

Deduplicate all possible k_heap_free() by setting the pointer to NULL
every time.

Signed-off-by: Josuah Demangeon <josuah.demangeon@nordicsemi.no>
2026-07-21 14:09:40 -04:00