Commit graph zephyr/subsys
Author SHA1 Message Date
Jukka Rissanen
628e4e1384 net: ethernet: bridge: Delete every FDB entry of a removed port
eth_bridge_fdb_del_iface() is documented to delete the FDB entries of an
interface and is called when a port leaves the bridge, but the loop
stopped after the first entry it removed. Every other entry for that
port stayed in the table, so frames for those addresses were still
handed to a port that is no longer part of the bridge, and the slab
blocks were never returned.

The debug message also read the entry after k_mem_slab_free() had
returned it to the slab.

Walk the list with the _SAFE iterator, keep prev on the last entry that
stays in the list, and log before freeing.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-15 20:35:08 +02:00
Mohamed Moawad
476f3bbf5d posix: lib: widen time_t arithmetic and use safe timeout conversion
Fix potential overflows when converting timespec and timeval values
by ensuring tv_sec is promoted to 64-bit before scaling in ts_to_ns()
and ts_to_ms(). Additionally, replace manual select() timeout
calculations with timespec_to_timeout().

This avoids 32-bit intermediate overflows on toolchains where time_t
is 32-bit, preventing incorrect POSIX timeout and select() behavior.

Signed-off-by: Mohamed Moawad <melhosar@gfoundries.com>
2026-10-15 20:33:52 +02:00
Johan Hedberg
42b48e4787 Bluetooth: Controller: Initialize the advertising random delay
ticker_update_rand() asks for four random bytes in interrupt context
and ignores how many it got. The pool for that context can have fewer:
the first request after advertising has started got one byte on
nrf52_bsim. The other three bytes of the delay were whatever the stack
had, so the time of the second advertising event depended on the image
and on nothing else, and a simulation gave other results after an
unrelated change.

Start from zero, which leaves a delay of fewer random bits in that
case.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-15 16:47:54 +02:00
Johan Hedberg
927dcaaf53 Bluetooth: Controller: Do not start a CONNECT_IND past the scan window
An initiator checks that the CONNECT_IND for an ADV_IND will be over
before its time slot ends. The scan window is closed by a ticker
EVENT_OVERHEAD_START_US before that, and the radio is disabled there:
a CONNECT_IND that the check let through could be cut off in the
middle. The connection has been given to the ULL by then, so the Host
got an LE Connection Complete event for a connection that the peer
never saw and that was lost six connection events later.

Check against the time at which the window is closed as well. An
ADV_IND that comes too late for that is left unanswered, as one that
comes too late for the time slot is.

It took a scan window that is shorter than the scan interval, and an
ADV_IND in the last few hundred microseconds of what was answered.

Tested with tests/bsim/bluetooth/host/central on nrf52_bsim, with the
advertising delay forced to values that put the ADV_IND around that
time: the CONNECT_IND is sent in full or not at all, where it was cut
off at the end of the window before. Not run on hardware.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-15 16:47:54 +02:00
Robert Lubos
3b586fd805 net: mqtt: Return the websocket error code from the write transport
websocket_send_msg() reports failures through its return value and does
not set errno, so mapping a failure to -errno in
mqtt_client_websocket_write() returned a stale value or 0, and a failed
send was treated as a successful one. Pass the return value on, as
mqtt_client_websocket_write_msg() already does.

Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-10-15 16:42:33 +02:00
Robert Lubos
9b74cc8008 net: websocket: Make the send timeout independent of the socket
websocket_send_msg() wrote the underlying socket with a blocking
sendmsg(), so with a full send window the call blocked for as long as
the socket let it, by default forever, no matter which timeout the
caller passed. When that sendmsg() did return EAGAIN, the deadline for
the retry had been computed with K_MSEC(SYS_FOREVER_MS), which clamps
to no wait at all, so a "forever" send gave up at once.

Write the socket without blocking and let the poll() for writability
run against the caller's deadline alone: a finite timeout is honoured
and SYS_FOREVER_MS waits for as long as it takes. A non-blocking write
is refused with ENOBUFS instead of waiting when the stack is short of
buffers, so back off and retry in that case until the deadline, giving
up after CONFIG_NET_SOCKET_MAX_SEND_WAIT of continuous shortage as the
socket layer does.

A send that fails after its deadline expired leaves the stream in a
state the caller cannot know: TCP may have accepted part of the frame,
and a TLS socket may hold an encrypted record it flushes on the next
write. Anything sent afterwards would be parsed as the rest of that
frame. Mark the connection broken when a non-zero timeout expires or
when part of a frame was accepted: further sends fail with -EPIPE and
websocket_disconnect() closes the fd without a CLOSE frame. A zero
timeout that got nothing out is a poll and leaves the connection usable.

Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-10-15 16:42:33 +02:00
Robert Lubos
eceb4d4f4f net: websocket: Do not drop the context reference on a received CLOSE
A CLOSE frame with the FIN bit clear made websocket_recv_msg() run the
full disconnect, releasing the context reference that belongs to the
websocket fd. The application's websocket_disconnect() then released it
again, the refcount went negative and the slot stayed marked as used, so
every later websocket_connect() failed with -ENOENT. In between, the
slot could be handed to a new connection while the stale fd still
pointed at it.

Report such a frame to the application the same way a final CLOSE is
reported, and leave the context alone. The application answers it by
closing the websocket, which sends the CLOSE reply and releases the
context, so the reply is never sent from the receive path with an
unbounded timeout or concurrently with another thread's send.

Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-10-15 16:42:33 +02:00
Julien Racki
e6c0c1382c net: ipv6: avoid DAD deadlock during interface bring-up
Start link-local DAD without holding the interface lock. DAD checks
addresses across interfaces and can deadlock during concurrent bring-up.

Assisted-by: Claude Sonnet 5.5
Signed-off-by: Julien Racki <julien.racki-ext@st.com>
2026-10-15 16:40:45 +02:00
Aleksandr Khromykh
84d24de3c1 bluetooth: mesh: dfd_srv: record self-target apply outcome
The self-target applies its image after the Confirm Update On Target
Nodes procedure, which therefore never sets its Retrieved Update Phase
to Apply Success or Apply Failed (MshDFUv1.0 Section 7.1.2.9). After an
in-place apply its receiver entry kept reporting Applying Update in
Firmware Distribution Receivers Status, also once the distribution had
completed or failed.

Set the entry to Apply Success when the local apply completes, and to
Apply Failed when the deferred apply cannot start.

Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2026-10-15 16:39:40 +02:00
Aleksandr Khromykh
5a29ead7fc bluetooth: mesh: blob_cli: exclude skipped targets from broadcasts
A skipped target is never sent to, but it was still counted in
tx.pending, so an acknowledged broadcast that included one only completed
when the retry timer found nothing left to send, one retry interval
later. The Distributor skips its own target during the Transfer step of
a self-update, so every acknowledged BLOB broadcast in the transfer paid
this delay.

Count only the targets that take part in the broadcast. targets_reset()
still counts all active targets, since the transfer-start paths use it to
check that a valid target remains.

A skipped target can still receive a group-addressed message, for example
when the Distributor's own BLOB Transfer Server is subscribed to the
group, and it answers with an error since it expects no transfer. Ignore
such responses when looking the target up, before they can drop it or
change the transfer state, and keep them out of the pending count.

Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2026-10-15 16:38:38 +02:00
Aleksandr Khromykh
fa0af885ef bluetooth: mesh: dfu_cli: send Firmware Update Cancel to skipped targets
The Transfer step skips targets that do not need the transfer, such as a
Firmware Update Server on the client's own node, which verifies the
image without one. Cancelling during the transfer left the skip flags
set, so the Cancel broadcast never reached those targets and they stayed
in Verification Succeeded.

Clear the skip flags before broadcasting Firmware Update Cancel.

Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2026-10-15 16:38:06 +02:00
Firas Sammoura
a06858bd11 mgmt: ec_host_cmd: usb: rename EP_INT_SIZE_SIZE to EP_INT_SIZE
The macro holds the interrupt endpoint packet size; the doubled _SIZE
suffix reads like a typo. Rename it to EP_INT_SIZE to match
EP_BULK_SIZE. No functional change.

Signed-off-by: Firas Sammoura <fsammoura@google.com>
2026-10-15 14:32:28 +02:00
Firas Sammoura
c63867943a mgmt: ec_host_cmd: usb: drop unneeded NULL initializers
These pointers are always assigned before they are read, so the NULL
initializers are dead stores. In ec_host_cmd_request(), initialize bi
directly from udc_get_buf_info() instead. No functional change.

Signed-off-by: Firas Sammoura <fsammoura@google.com>
2026-10-15 14:31:47 +02:00
Firas Sammoura
5eea06e52e mgmt: ec_host_cmd: usb: use += to accumulate the received length
Use a compound assignment instead of repeating ctx->rx_ctx->len on
both sides. No functional change.

Signed-off-by: Firas Sammoura <fsammoura@google.com>
2026-10-15 14:31:12 +02:00
Firas Sammoura
fded107f8c mgmt: ec_host_cmd: usb: use %zu to log size_t values
rx_ctx->len and expected_len are size_t but were logged with %d,
which expects an int. On 64-bit targets the types differ, and
-Wformat reports all three arguments wherever log format strings are
type-checked.

Signed-off-by: Firas Sammoura <fsammoura@google.com>
2026-10-15 14:30:58 +02:00
Firas Sammoura
0dca09e083 mgmt: ec_host_cmd: usb: fix initialized typo in log messages
Fix the misspelling of "initialized" in the two "Host Commands not
initialized" error messages.

Signed-off-by: Firas Sammoura <fsammoura@google.com>
2026-10-15 14:30:46 +02:00
Firas Sammoura
8d6079980c mgmt: ec_host_cmd: usb: remove redundant request length check
expected_request_len() returns 0 for an invalid header. rx_ctx->len
and expected_len are both size_t, so rx_ctx->len >= expected_len is
then always true and the separate expected_len == 0 test is redundant.
Mention in the comment that the first check covers invalid headers.

Signed-off-by: Firas Sammoura <fsammoura@google.com>
2026-10-15 14:30:11 +02:00
Firas Sammoura
9b305041b2 mgmt: ec_host_cmd: usb: remove unused EC_HOST_CMD_SEND_TIMEOUT_MS
EC_HOST_CMD_SEND_TIMEOUT_MS is not referenced anywhere; the response
timeout is IN_TRANSFER_TIMEOUT_MS.

Signed-off-by: Firas Sammoura <fsammoura@google.com>
2026-10-15 14:29:58 +02:00
Firas Sammoura
f4c4f658af mgmt: ec_host_cmd: usb: remove unused includes
Nothing from <assert.h>, <stdarg.h>, <string.h>, <zephyr/device.h> or
<zephyr/devicetree.h> is used by the USB backend: __ASSERT() and
BUILD_ASSERT() come in through <zephyr/kernel.h>, and the backend has
no device or devicetree references.

Signed-off-by: Firas Sammoura <fsammoura@google.com>
2026-10-15 14:29:45 +02:00
Jukka Rissanen
62f05dec64 net: ptp: Limit the messages kept in foreign timeTransmitter records
Every foreign timeTransmitter record keeps up to three received
Announce messages, and a port has at least five records. The messages
come from the pool that is also used to receive and to send, which
holds ten messages by default. Announce messages from five different
source port identities are therefore enough to take every message, and
the sender does not have to be a better clock for that. The port then
cannot receive, and each failed reception resets it.

Count the messages kept in the records of all ports and let them take
at most half of the pool. When the limit is reached, a record gives up
its oldest message for the new one, so it still follows the latest
Announce message. A record without a message gets none, except for the
record of the current timeTransmitter, which then takes the place of a
message of another record of the same port.

The Announce message is now compared with the previous one before the
record is changed, since the previous one may be released to make room.

The foreign timeTransmitter unit test compiles port.c on its own, so it
gets the pool size option it now needs.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-15 14:28:21 +02:00
Jukka Rissanen
cf34a95251 net: ptp: Do not wait forever for a message
ptp_msg_alloc() takes a message from a memory slab with K_FOREVER.
All callers handle a NULL return, but it can never happen: when the
slab is empty the PTP thread blocks in the allocation, and since it is
the only thread that releases messages, it never continues.

Messages are held for longer than one receive: Announce messages are
kept in the foreign timeTransmitter records, and the last Sync,
Delay_Req and Pdelay messages are kept by the port. The slab can
therefore run empty during normal reception.

Allocate with K_NO_WAIT. When no message is available for reception the
port reports a fault, as the existing code intended. Handling the fault
closes the transport and releases the foreign timeTransmitter records
of the port, which returns their messages, so the port recovers when
the fault is cleared.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-15 14:28:21 +02:00
Jukka Rissanen
34a773a604 net: ptp: Do not wait forever for a TLV container
ptp_tlv_alloc() takes a container from a memory slab with K_FOREVER,
so it never returns NULL and the error handling of its callers is dead
code. When the slab is empty the caller blocks instead, and the caller
is the PTP thread, which is also the only thread that returns
containers to the slab. The thread then never runs again.

The receive path allocates one container for every TLV of a message
before anything else about the message is checked, so a single
received message with more TLVs than there are free containers is
enough to stop PTP until the next reboot.

Allocate with K_NO_WAIT. A message that needs more containers than are
available is now rejected by the existing -ENOMEM handling and dropped,
and its containers are returned when the message is released.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-15 14:28:21 +02:00
Robert Lubos
7f7549639b net: ipv6: Do not relay foreign packets unless forwarding is enabled
net_ipv6_input() hands every unicast packet that is not addressed to
the receiving interface to ipv6_route_packet(), which re-sends it when
the destination has a route, is on-link or a default router is known.
This only needs CONFIG_NET_IPV6_ROUTE, which is enabled by default with
the neighbor cache, so a plain host relays foreign unicast packets,
also across interfaces. The forwarding flag, and with it the hop limit
decrement, is only set when the packet changes interface, so a relay
back out the ingress interface keeps the original hop limit and a
packet can loop between two hosts indefinitely.

Build ipv6_route_packet() only with CONFIG_NET_IPV6_FORWARDING so a
host drops what is not for it, never route the unspecified
destination, and mark every packet re-sent from the receive path as
forwarded, also when it leaves through the ingress interface, so the
hop limit is decremented on every hop. The shared on-link helper now
treats both families alike. The per-interface address check stays so
a forwarder keeps routing packets addressed to its other interfaces.

The fragment send test addressed its packet to the host itself, so
net_send_data() looped it back with the addresses swapped and the
fragments were only produced because the host then relayed the packet
to a neighbor. Send it to the neighbor directly, with the extension
length the frame actually has.

Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-10-15 14:26:50 +02:00
Robert Lubos
f6b7e5d9d1 net: ipv4: Do not relay foreign packets unless forwarding is enabled
net_ipv4_input() hands every packet that is not addressed to this host
to ipv4_route_packet(), which re-sends it whenever the destination is
on-link, has a route or a default router is known. This only needs
CONFIG_NET_IPV4_ROUTE, which is enabled by default with ARP, so a plain
host relays foreign unicast packets, also across interfaces, and sends
TCP addressed to a broadcast address back out on the same link. The
forwarding flag, and with it the TTL decrement, is only set when the
packet changes interface, so these relays keep the original TTL and
two hosts on one LAN bounce a single crafted broadcast frame forever.

Build ipv4_route_packet() only with CONFIG_NET_IPV4_FORWARDING so a
host drops what is not for it, never route broadcast or unspecified
destinations, and mark every packet re-sent from the receive path as
forwarded, also when it leaves through the ingress interface, so the
TTL is decremented on every hop. The IPv6 on-link path keeps its
cross-interface rule.

IPv4 NAT rewrites addresses in the receive filter and relies on this
path to send the translated packet on, which is forwarding, so make it
depend on CONFIG_NET_IPV4_FORWARDING and leave the TTL decrement to
the forwarding path instead of doing it a second time.

Make the on-link input test expect a drop without forwarding and a
decremented TTL with it.

Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-10-15 14:26:50 +02:00
Johan Hedberg
aa0d4a21a5 Bluetooth: Host: Fix PSA keys leaking when ECC operations fail
The work handlers that generate the public key and the DH key put a
volatile key into the PSA key store and destroy it once they are done
with it. When exporting the generated key failed, or the key agreement,
they left without destroying it, and the key kept its slot until
reboot. The small builds have five slots, so a few such failures were
enough to make every later key operation fail.

Destroy the key on those paths as well.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-15 14:18:07 +02:00
Johan Hedberg
1dcd0f23b5 Bluetooth: Host: Fix writing a long command response past the buffer
The response to a command is copied from the event into the command's
own buffer, which is as large as the events that the Host is configured
to receive (CONFIG_BT_BUF_EVT_RX_SIZE, 68 bytes by default). The event
itself arrives in a buffer that takes any Command Complete, up to 255
bytes of parameters, and the copy did not look at the length. A longer
response, to a vendor command for instance, was caught by an assertion
at best and written past the command buffer otherwise.

Fail the command when its response does not fit.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-15 14:17:50 +02:00
Johan Hedberg
c14bdb32b1 Bluetooth: Host: Clear buffer pointers at queue handover
A buffer put into a FIFO or list belongs to the queue from then on, and
the thread or work item on the other side may process and free it
before the call returns. Passing net_buf_take(&buf) clears the caller's
pointer in the same expression, so code added after the handover
cannot use the buffer by mistake.

Convert the insertions in ATT, L2CAP, HCI core, HCI raw and the L2CAP
shell where the put is the last use of the pointer. bt_hci_cmd_send()
still uses its pointer after queueing, to take a command back from a
closed transport, so it stays as it is.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2026-10-15 14:17:17 +02:00
Phi Bang Nguyen
13c7d78f6a mpipe: Use ASSERT instead of NULL check for programming errors
Use ASSERT to catch the leftover programming error instead of NULL
check.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2026-10-15 14:15:05 +02:00
Phi Bang Nguyen
def66d0483 mpipe: buffer: Call the configure hook's capability what it is
The pool's configure hook and mpipe_buffer_pool_configure() take the
negotiated capability, not a pool config, so the parameter is named
caps rather than config, which is the name of the pool's config field.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2026-10-15 14:15:05 +02:00
Phi Bang Nguyen
bda05b42fe mpipe: Name the transform modes and two caps fields consistently
The transform mode enumerators now carry their enumeration's name, and
the two caps fields that ran words together are spelled like the rest:

  MPIPE_MODE_PASSTHROUGH   -> MPIPE_TRANSFORM_MODE_PASSTHROUGH
  MPIPE_MODE_INPLACE       -> MPIPE_TRANSFORM_MODE_INPLACE
  MPIPE_MODE_NORMAL        -> MPIPE_TRANSFORM_MODE_NORMAL
  MPIPE_CAPS_BITWIDTH      -> MPIPE_CAPS_BIT_WIDTH
  MPIPE_CAPS_NUM_OF_CHANNEL -> MPIPE_CAPS_NUM_CHANNELS

The pad id macros the base sources define for themselves lose the MPIPE
prefix, since they are file-local and differ from file to file.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2026-10-15 14:15:05 +02:00
Phi Bang Nguyen
359bf305e8 mpipe: Rename the pad's chain function to process_fn
The hook processes the buffer it is given and hands the result back; it
does not push it to the next element, mpipe_push_buffer() does that as
it walks the graph. "Chain" described a recursion that does not exist
here, so the hook, the transform client's remote counterpart and the
elements' implementations are named for what they do:

  chain_fn     -> process_fn
  chain_fn_rpc -> process_fn_rpc

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2026-10-15 14:15:05 +02:00
Phi Bang Nguyen
cc3724cbc5 mpipe: bin: Refuse to add an element to a second bin
Appending an element already on a bin's list corrupts that list. Refuse
it with -EBUSY, and say that the elements before a refused one stay
added. An unknown transition is an error rather than a logged success.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2026-10-15 14:15:05 +02:00
Phi Bang Nguyen
a9b7a67050 mpipe: structure: Reject a field identifier that does not fit a byte
mpipe_structure_init_fields() narrowed each identifier to uint8_t before
checking it, so 256 passed as field 0. Check the value first.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2026-10-15 14:15:05 +02:00
Phi Bang Nguyen
f7cd940d08 mpipe: thread: Claim thread stacks atomically
Two threads created at the same time could find the same free stack.
Claim a slot with an atomic test-and-set and release it with an atomic
clear.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2026-10-15 14:15:05 +02:00
Phi Bang Nguyen
a7a9ce1d37 mpipe: Do not lose the last end-of-stream message
zbus runs the channel validator before it takes the channel lock, and
the pipeline validator counts an end-of-stream there. A post that then
found the channel busy failed with -EBUSY on K_NO_WAIT, and the last
end-of-stream of a graph with several sinks was counted but never
delivered. Wait for the channel outside ISR context.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2026-10-15 14:15:05 +02:00
Phi Bang Nguyen
34df138282 mpipe: object: Stop reading past the end of a property list
mpipe_object_set_properties() and mpipe_object_get_properties() read the
value argument before checking the key for the list terminator, so every
call read one variadic argument that was never passed. Read the key,
stop on the terminator, and only then read the value. The terminator is
an unsigned value like the keys it is compared with.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2026-10-15 14:15:05 +02:00
Phi Bang Nguyen
55168bfacb mpipe: Keep element names behind their own option
The element name exists for the debugging tools that print one, and it
was gated on the dump's option, so the framework depended on a utility.

Add MPIPE_ELEMENT_NAME, a promptless option, which is selected by the
dump to avoid dependency inversion.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2026-10-15 14:15:05 +02:00
Phi Bang Nguyen
63b4de1651 mpipe: Tidy Kconfig, CMake and test metadata
- Tidy Kconfigs and test metadata
- Add range to some Kconfigs
- Move CONFIG_MPIPE_DUMP from the framework to utils

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2026-10-15 14:15:05 +02:00
Phi Bang Nguyen
7b44291ab4 mpipe: Make file-local symbols static
Make local symbols static.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2026-10-15 14:15:05 +02:00
Phi Bang Nguyen
d8aa75ae9b mpipe: Tighten source comments
Cut the comments down to the fact they carry and drop the ones that
restate the code.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2026-10-15 14:15:05 +02:00
Madhab Sharma
72c53ef21d net: l2: wifi: zeroize cert buffers before freeing
zeroize cert buffers before freeing using mbedtls_platform_zeroize().

Signed-off-by: Madhab Sharma <madhabsharma94@gmail.com>
2026-10-15 00:58:37 +02:00
Guillaume Gautier
2e3fc723a3 crc: fix crc7_be hardware result
Fixes the computation of the CRC7-BE by left-shifting the result by 1.
This fixes issue #119761 where the communication with the SD card failed
due to a wrong CRC when using the SoC hardware CRC block.
This change aligns the results between the HW and SW versions of the
crc7_be function.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2026-10-15 00:57:59 +02:00
Jukka Rissanen
a30ecd650d net: quic: Hold the endpoint while a stream is closed or shut down
A stream's endpoint pointer is cleared, and the endpoint released,
when the connection goes away. That happens in the QUIC threads, for
example when the peer closes the connection, at any moment as seen
from a socket call.

close(), shutdown(), quic_send_stream_fin() and quic_stream_unref()
checked stream->ep and then read it again several times with nothing
held. When the connection was torn down in between, a later read
returned NULL and was dereferenced, so a peer could crash the thread
closing a stream by closing its connection at the right time.

Add quic_stream_endpoint_get(), which reads the pointer under
contexts_lock and returns the endpoint with a reference held. Each of
these calls now gets the endpoint once and uses that one throughout.
shutdown() returns 0 when the connection is gone already.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-15 00:56:13 +02:00
Jukka Rissanen
65e30a2516 net: http3: Close a peer unidirectional stream rejected at accept
When the type of a peer unidirectional stream is already readable at
the time the stream is accepted, handle_accepted_stream() identifies
it right away. If that fails, for example for a second control stream,
the error was returned with the accepted socket still open. Nothing
tracks that socket, so accept_h3_stream() and its caller could not
close it either. The connection was then torn down around it, and the
socket kept its QUIC stream and connection state allocated for good.

Close the socket where the stream is rejected.

A stream that is closed or reset before its type arrives was handled
as such an error too and took the whole connection down. RFC 9114
ch. 6.2 requires a receiver to tolerate this, so only drop the stream
in that case and keep the connection.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-15 00:55:18 +02:00
Jukka Rissanen
679bdbe339 net: http3: Do not pass the body of a 405 request to the resource
When a request for a dynamic resource uses a method the resource does
not allow, it is answered with 405, but the resource stayed attached
to the request. A request body that followed the headers was then
passed to the callback of the resource as if the request had been
accepted.

Let go of the resource when the 405 is sent, as the 409 and 425 paths
do.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-15 00:54:41 +02:00
Jukka Rissanen
89d9c8dbb2 net: http3: Finish the stream, not the connection, on 409
A 409 Conflict is returned when a second client requests a dynamic
resource already held by another client. h3_handle_dynamic_resource()
returned through enter_http_done_state(), which closes the whole
connection. During request processing client->fd is the request stream
fd, not the connection fd, so this released the request stream while
leaving the connection fd in the poll table and skipping
h3_client_cleanup(): the same teardown-on-the-wrong-descriptor fault a
GOAWAY frame on a request stream triggers.

409 is a per-request status. End only the offending request stream with
h3_end_response() and leave the connection running, matching the 404,
405 and 425 paths.

The refused request must also let go of the resource, as the 425 path
does. Otherwise the request body that follows the headers is passed to
the callback, which is serving the holder, and the end of the stream
completes the transaction and takes the resource away from the holder.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-15 00:54:41 +02:00
Jukka Rissanen
b9ada8e491 net: http3: Close the connection when a critical stream fails
When reading the peer's control stream or one of its QPACK streams
failed, because the stream was closed or a SETTINGS frame was
malformed, handle_h3_uni_stream() closed the stream socket but left
the connection running. The fd number stayed recorded in the HTTP/3
connection context. File descriptor numbers are reused, so when the
connection was torn down later, h3_client_cleanup() removed from
polling and closed whichever socket had been given that number in the
meantime, for example the connection of another client.

These failures are connection errors: RFC 9114 ch. 6.2.1 and RFC 9204
ch. 4.2 for a closed control or QPACK stream, RFC 9114 ch. 7.2.4 for
invalid SETTINGS. Close the whole connection at once, which also
releases the stream while its fd number still belongs to it.

As for other HTTP/3 errors in the server, the error code itself is not
sent to the peer.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-15 00:53:57 +02:00
Jukka Rissanen
8886c0a24c net: http3: Keep the control stream open after a client GOAWAY
A GOAWAY frame on the client's control stream was reported as an
error of the stream, and the server closed its end of the control
stream while the connection carried on.

A GOAWAY sent by a client only tells the server which pushes the
client still accepts (RFC 9114 ch. 5.2). This server does not push,
and the requests in progress have to be allowed to finish, so there is
nothing to act on. Ignore the frame and keep reading the control
stream.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-15 00:53:57 +02:00
Jukka Rissanen
6a7f43ab2b net: http3: Reject control-only frames on request streams
h3_process_frames() parsed and applied a SETTINGS frame received on a
request stream, and silently skipped CANCEL_PUSH, MAX_PUSH_ID and
PUSH_PROMISE as if they were unknown frame types.

RFC 9114 requires a connection error of type H3_FRAME_UNEXPECTED in
all of these cases: CANCEL_PUSH (ch. 7.2.3), SETTINGS (ch. 7.2.4) and
MAX_PUSH_ID (ch. 7.2.7) are only allowed on the control stream, and a
server must treat any PUSH_PROMISE it receives as this error
(ch. 7.2.5). Handle them together with GOAWAY, which already closes
the connection this way.

As for other HTTP/3 errors in the server, the error code itself is not
sent to the peer.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-15 00:53:57 +02:00
Jukka Rissanen
f6f9e645dc net: http3: Treat GOAWAY on a request stream as a connection error
A GOAWAY frame is only valid on the HTTP/3 control stream. When it
arrived on a request (bidirectional) stream, h3_process_frames() called
enter_http_done_state(), which closes the whole connection. During
request processing client->fd is temporarily the request stream fd, not
the connection fd, so this tore down the wrong descriptor: it released
the request stream, left the connection fd in the poll table and skipped
h3_client_cleanup(). The client slot was then memset with the connection
still polled, so the next event on that fd dereferenced the cleared slot
and crashed the server thread.

RFC 9114 ch. 7.2.6 says that GOAWAY is always sent on the control
stream, and Table 1 in ch. 7.2 does not permit it on a request stream.
Treat it as a connection error of type H3_FRAME_UNEXPECTED (ch. 8.1):
return -H3_FRAME_UNEXPECTED so that handle_h3_bidi_stream() restores
the connection fd before tearing the connection down through the normal
path.

The error code is not sent to the peer. The connection is closed the
same way as for any other HTTP/3 error in the server, and the QUIC
stack does not yet offer a way to close a connection with an
application error code.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2026-10-15 00:53:57 +02:00