With CONFIG_BT_ATT_RETRY_ON_SEC_ERR a request rejected for insufficient
security stays on its bearer, marked retrying, while the host elevates
security: att_error_rsp() has consumed the error response and stopped
the ATT timeout, and bt_att_encrypt_change() resends or fails the
request once the security procedure completes.
Cancelling such a request left it in that state. bt_att_chan_req_cancel()
parked the cancel placeholder on the bearer, and the encryption change
handler only acts on a retrying request, so neither a response nor a
timeout was left to clear the placeholder. The bearer stayed busy until
disconnect and every request queued for it was never sent, for example
the CCC disable write of a bt_gatt_unsubscribe() that had cancelled its
pending enable write.
Release the bearer immediately when the cancelled request is waiting for
a retry and send the next queued request, as att_handle_rsp() does when
a response arrives.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Without SACK a single lost segment leaves the sender guessing: it sees
duplicate ACKs but not which data arrived behind the hole, so it can
only resend from the hole onwards and wait. On a link with a fraction
of a percent of loss that is enough to keep throughput well below what
the path allows.
The receive side already has what it needs. Data that arrives out of
order is held on conn->queue_recv_data with its sequence number, so an
ACK can carry a block naming it. Offer SACK permitted in the handshake
when the peer does, and attach that one block to the ACKs sent while
the hole is open.
The queue holds a single contiguous run - anything that would not be
sequential with it is dropped - so there is never more than one block
to report, and RFC 2018 allows fewer than four. Nothing here parses
incoming SACK blocks: as a sender this stack still behaves as before.
CONFIG_NET_TCP_SACK switches it, on by default and depending on the
receive queue, with tcp_sack_supported() as the only gate. This changes
what goes on the wire for every connection, so turning it off is the
first thing to try when chasing an interoperability problem.
Queued data is still dropped after CONFIG_NET_TCP_RECV_QUEUE_TIMEOUT,
2 s by default, even once a SACK block has reported it. RFC 2018
section 8 permits that and senders have to cope, but it is what someone
debugging a stall against this stack will want to know first, so the
Kconfig help says it as well.
Measured with samples/net/zperf on an MIMXRT1170-EVK receiving TCP over
a direct 1G link, 0.3% loss on the path, three runs at each offered
rate, receiver-side figures:
offered without with
150M 73.4 129.9 Mbps
300M 64.8 137.6 Mbps
Run to run spread over those measurements falls from more than 4x to
1.1x.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Hashimoto Kenichi <hashimoto.kenichi@genetec.co.jp>
The CCC write handler accepted any value without consulting the
properties of the characteristic the descriptor belongs to, so a client
could enable notifications on an indicate-only characteristic, or
indications on a notify-only one. The subscription was then recorded and
reported by bt_gatt_is_subscribed(), but nothing could ever be sent for
it.
Look up the properties of the nearest preceding characteristic
declaration and reject a configuration the characteristic does not
support with the error the spec reserves for this, Client Characteristic
Configuration Descriptor Improperly Configured. Writes that clear the
configuration are unaffected, since they request nothing.
If the declaration cannot be located or read, a warning is logged and
the write is let through unchanged, so a database that is not built from
the BT_GATT_CHARACTERISTIC macros keeps working as before.
Note that this rejects configurations previously accepted. A server whose
characteristic properties do not match what its clients subscribe to will
now see those subscriptions fail, which is the intended outcome: it makes
a mis-declared database visible instead of silently producing a
subscription that never delivers.
Fixes: #81005
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Assisted-by: Claude:claude-opus-5
Assisted-by: Claude:claude-fable-5
Add an iterator that allows to retrive existing IDs in the storage with
their data length.
Add as well an optional ID filtering support to the iterator API.
- Add zms_iter_init() to initialize an iterator
- Add zms_iter_init_with_config() to initialize an iterator with a
config filter.
- Add zms_iter_next() to retrieve unique ID/len.
- Add zms_iter_next_all() to retrieve all ID/len.
Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Riadh Ghaddab <riadh.ghaddab@nordicsemi.no>
The ssh and sshd commands called the POSIX htons(), which nothing in
the file declares, so the build fails e.g. on native_sim with the host
libc. Use net_htons() like the rest of the network shell.
Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
usbh_req_setup() waits on a single global semaphore with no mutual
exclusion, so two threads can be inside it at once: enumeration runs
on the bus thread while the shell and class drivers call in from
their own. The first completion wakes an arbitrary waiter, which then
reads xfer->err on a transfer that has not finished. Serialize the
request with a mutex so the semaphore has one owner at a time.
Timing out also released the transfer while the controller still
owned it. uhc_ep_dequeue() only requests cancellation: the transfer
stays with the driver until it is returned through the completion
callback, and the driver may still write into its buffer. Callers
such as usbh_req_desc_dev() free that buffer as soon as
usbh_req_setup() returns, so a cancelled transfer could land in a
recycled net_buf. Wait for the completion callback before freeing,
and drop the callback's -ECONNRESET path now that the caller always
owns the transfer.
Signed-off-by: Ofir Shemesh <ofirshemesh777@gmail.com>
net_arp_clear_pending() released the queued packets and zeroed the
entry but left it on the pending list, where it stayed unusable until
the request timeout reclaimed it. With the default table size of two,
two cleared entries left no entry for new destinations and their
packets were dropped for up to ARP_REQUEST_TIMEOUT.
Unlink the entry and put it back on the free list, as the timeout
handler and net_arp_clear_cache() do. The request timer is cancelled
when the pending list becomes empty.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
When sending an ARP request fails, ethernet_send() looked up the
pending entry with NET_IPV4_HDR(pkt)->dst, where pkt is the ARP
request. Its first fragment holds the Ethernet header by then, or the
ARP header if filling it failed, so the address never matched the
request's target and the entry stayed pending until the request
timeout, with the original packet queued behind it.
Save the target from the ARP header before the Ethernet header is
prepended and use that for the lookup. Look the entry up on the
packet's interface rather than the one being sent on: with VLAN the
packet is re-pointed at the VLAN interface during ARP preparation and
the entry is registered on that one.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
net_arp_prepare() returns NET_ARP_PKT_REPLACED both when it queued the
original packet on a pending entry, taking its own reference, and when
it could not queue it because every entry is already pending or the
packet is already queued. ethernet_send() dropped the caller's
reference in both cases, so in the latter the packet was freed before
the ARP request went out. If sending the request then failed, the
error path took a reference on the freed packet and net_if_tx()
released it once more, which can free a packet owned by someone else
if the slot was reused in between.
Hold the caller's reference until the request has been sent and drop
it only on success. On failure the reference is released by
net_if_tx() as for any other send error, and clearing the pending
entry releases only the reference ARP took when queueing. Key the
error path on the packet having been replaced rather than on the
Ethernet type, so a failed raw ARP frame from an AF_PACKET socket no
longer touches the ARP cache.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The pending entry list and each entry's pending queue are otherwise
only touched under arp_mutex. Walking the list and draining the queue
without it races with the request timeout handler and with
net_arp_update() removing the same entry.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
l2cap_br_conf_opt_qos() rejects the whole Configuration Request unless
the QoS bit is set both in the peer's extended feature mask and in
L2CAP_EXTENDED_FEAT_MASK, but the local mask never carried that bit, so
a peer including a QoS option could never complete channel
configuration. The handler was also not spec compliant in two ways: a
Guaranteed request was answered with Unacceptable Parameters while the
service type was echoed back unchanged, leaving the peer without a
usable counter-proposal, and an accepted QoS option was not returned in
the positive Configuration Response.
Add CONFIG_BT_L2CAP_QOS to advertise the QoS bit in the local extended
feature mask, and guard the QoS default values with it since only that
path uses them. Only the Best Effort service type has to be supported
(Core 5.4, Vol 3, Part A, 5.3), so counter-propose Best Effort when the
peer asks for the optional Guaranteed type, and add the agreed option
to the Configuration Response when the option is accepted.
Signed-off-by: Make Shi <make.shi@nxp.com>
send_request() connect()s to the source of whatever datagram arrives
first in response to a request, and the rest of a transfer trusts
whatever the socket hands it afterwards. RFC 1350 identifies each end
of a transfer by its TID and requires that "if a source TID does not
match, the packet should be discarded as erroneously sent from
somewhere else"; Zephyr's client never made that check. An off-path
attacker who can guess or observe the client's ephemeral source port,
or another host on the same LAN, can race the real server's first
response with a forged one and hijack the transfer.
Check the source of every datagram the client receives. The server's
first reply legitimately comes from a freshly allocated TID, so it is
matched on the server's address alone; every datagram after it has to
come from the address and port that first reply arrived from.
Discarding is all the client does with a mismatch. RFC 1350 also asks
for an error packet to be sent back to the offending source, which
would turn every Zephyr client into a reflector an attacker can aim at
a third party. The transfer is left undisturbed either way, which is
the part that protects it.
A discarded datagram costs neither a retransmission nor one of the
transfer's retries: the client keeps waiting for the server's own reply
within the same CONFIG_TFTPC_REQUEST_TIMEOUT. Without that, the check
would hand an off-path attacker a cheaper attack than the one it
prevents, since a datagram per retry would end the transfer.
Add tests/net/lib/tftp, every case over IPv4 and over IPv6: a control
case for the TID port change the protocol requires, an attacker on an
unrelated address, an attacker differing only in the last component of
the address, a degenerate unset server address, a forged block injected
mid transfer from another address and from the server's own address
under a different port, a forged block queued on the socket before
zsock_connect() pins the peer - the one state where the port half of
the check is what rejects it, rather than the stack - and a burst of
forged datagrams larger than the retry budget, which has to leave the
transfer with all of its retries and exactly one request on the wire.
The suite runs its own loopback server and attacker on the loopback
interface, using CONFIG_NET_TEST to turn off the loopback driver's
address swap: by default it mirrors src/dst back at the sender, which
is invisible when both ends share one address but would hide a forged
source entirely. Server and attacker addresses come from the RFC 5737
and RFC 3849 documentation prefixes for IPv4 and IPv6 respectively,
since loopback traffic bypasses the ordinary 127.0.0.0/8 checks and
::2 is not an address an interface will accept; the extra addresses a
case adds to the interface need CONFIG_NET_IF_UNICAST_IPV4_ADDR_COUNT
and its IPv6 counterparts raised accordingly, and CONFIG_NET_IPV6_DAD
is turned off because a case binds to the address it just added and
cannot wait out duplicate address detection first - nothing on a
loopback interface can collide with it anyway.
CONFIG_TFTPC_REQUEST_TIMEOUT is set short so a hung client fails the
test instead of running long, with the retransmit count left at its
default since none of these cases drive retransmission.
Reported-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Signed-off-by: Arkadiusz Grzelka <devitwise@gmail.com>
Currently, synchronous controller functions in media_proxy.c blindly
dereference local player callbacks. This triggers a hard fault if a
local player has not been registered or if it does not implement all
optional callbacks (leaving some function pointers as NULL).
This commit adds validation guards to verify that mprx.local_player.calls
and the individual callback function pointers are not NULL across all
synchronous media control getters and setters. If a callback is
unimplemented, a safe fallback value (e.g., "" for strings, 0U for
integers) is returned instead.
Additionally, it relaxes the check in media_proxy_pl_register to allow
partial implementation of callbacks during player registration, as
allowed by the public contract in media_proxy.h, while still preventing
a completely NULL callback table from being registered.
Signed-off-by: harshit kudhial <harshitkudhial@gmail.com>
Implement CTAP over Bluetooth Low Energy (BLE), including the FIDO
GATT service, message framing, fragmentation, keepalive handling,
cancellation, and connection management.
Assisted-by: ChatGPT:GPT-5.6 Sol
Signed-off-by: Jan Schmale <Jan-Philipp.Schmale@teratron.de>
Pass the transport and channel ID through the receive and cancel
callbacks. Track the active request so cancellation is only applied to
the matching transaction.
Update the USB HID to use the extended callback interface.
Signed-off-by: Jan Schmale <Jan-Philipp.Schmale@teratron.de>
Improve error handling consistency across OBEX client operations by
ensuring proper state recovery on all error paths.
Add `obex_client_restore_active_state()` helper function to restore
client state (`opcode` and `active_client`) on error paths.
Convert early returns to goto failed pattern to ensure cleanup happens
consistently. It is used to ensure internally allocated net buffer is
properly freed on all error paths. And also ensure the changed states
and flags are recovered on all error paths.
The changes ensure that client state is properly restored when
operations fail, preventing state corruption and resource leaks.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
When a mutex is initialized using pthread_mutex_init() with a
non-default type (such as PTHREAD_MUTEX_RECURSIVE or
PTHREAD_MUTEX_ERRORCHECK), its type is stored in posix_mutex_type[bit].
When pthread_mutex_destroy() frees that slot back to
posix_mutex_bitarray, posix_mutex_pool[bit] is reinitialized with
k_mutex_init(), but posix_mutex_type[bit] is left unchanged. In
addition, when a static mutex (PTHREAD_MUTEX_INITIALIZER)
subsequently allocates a slot in to_posix_mutex(),
posix_mutex_type[bit] is never initialized.
Consequently, a PTHREAD_MUTEX_INITIALIZER mutex that reclaims a slot
previously held by a recursive or error-check mutex silently inherits
that type instead of behaving as PTHREAD_MUTEX_DEFAULT (non-recursive).
This allows recursive re-locking by the same thread rather than
blocking or returning EBUSY on pthread_mutex_trylock().
Reset posix_mutex_type[bit] to def_attr.type upon lazy allocation in
to_posix_mutex() and when releasing the slot in pthread_mutex_destroy().
Add a regression test in threads_base to ensure static mutexes retain
default non-recursive attributes after slot recycling.
Fixes#118893
Signed-off-by: harshit kudhial <harshitkudhial@gmail.com>
ZMS confirms an erase and finds empty ATE slots by reading the erase
value back, which fails on flash that decrypts on read.
Use flash_params_erase_value_readable() instead: when the erase value is
not readable, skip the post-erase compare and use the ATE CRC check, as
ZMS already does on devices without explicit erase.
Tested on qemu_x86, no change for existing drivers.
Assisted-by: Copilot:claude-opus-5
Signed-off-by: Sreeram Tatapudi <sreeram.praveen@infineon.com>
Some USB class drivers register filter entries for both device-level
and interface-level descriptors. This causes the probe function to be
called twice for the same device.
Return early after device-level binding succeeds, as interface scanning
is not needed for single-function devices.
Signed-off-by: Aiden Hu <weiwei.hu@nxp.com>
This commit resolves -Wpointer-sign warnings in the logging subsystem
by adding explicit (char *) and (uint8_t *) casts at the text API
boundaries.
This aligns with maintainer feedback for the logging API where text
strings should remain char * but binary buffers remain uint8_t *.
This is part of a larger effort to fix pointer-sign warnings across the
codebase in preparation for dropping -Wno-pointer-sign globally.
Related to #8921
Signed-off-by: harshit kudhial <harshitkudhial@gmail.com>
Linking two pads sets two pointers and cannot fail: a NULL pad is an
assertion, not an error. Yet the function returned 0 and promised a
negative errno, so every caller checked a value that never varied.
Return nothing and let the callers drop the check.
Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
NET_STATISTICS_ETHERNET depends on NET_L2_ETHERNET, so the statistics
code of the Ethernet drivers is never compiled when the drivers are
built with ETH_DRIVER_RAW_MODE, which is how
tests/drivers/build_all/ethernet builds most of them.
The driver side only needs struct net_stats_eth, the get_stats members
of struct ethernet_api and the inline helpers in eth_stats.h, none of
which require the L2. Allow the option with ETH_DRIVER_RAW_MODE as
well so that this code gets build coverage.
Without the L2 there is no network interface and no net_mgmt or shell
consumer, so the counters are not reachable in raw mode other than
through the get_stats driver API.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
update_recv_state_encryption() copied sizeof(recv_state->num_subgroups)
bytes of the subgroups, which is a single byte, instead of the whole
array. The receive state written back when the BIG encryption changed
therefore lost the metadata of every subgroup and kept only one byte of
the BIS sync value of the first subgroup.
Copy the whole array, and check in the BAP broadcast assistant BSIM test
that the metadata is still set when the broadcast code is requested.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Arkadiusz Grzelka <devitwise@gmail.com>
Store the public identity address that the Host hands to the driver's
setup() op also in the common HCI driver data, through the new
bt_hci_set_public_addr() API, before the HCI transport is opened. The
driver reads it with bt_hci_get_public_addr() and can apply it during
open(), i.e. from vendor-specific initialization that does not depend
on the Host's command APIs being available.
bt_hci_get_public_addr() returns BT_ADDR_ANY while no public address
has been set, which is what setup() receives in that case, so a driver
moving from one to the other keeps the check it has, and driver data
that has never been written needs no flag to say so. BT_ADDR_NONE is
the name that suggests itself for this, so the choice is spelled out
where a driver author looks: on both functions, with the check a driver
is expected to make, on the field, on the setup() parameter, which did
not document its value until now, and in the Kconfig help. The test
pins the value.
The channel is set on every bt_enable() and cleared when there is no
public identity, so that an address an earlier enable left behind is
not applied to the controller by a later one.
The setup() path keeps receiving the address as before; both channels
coexist until the drivers implementing setup() have migrated. So that
enabling the new channel no longer pulls in the mechanism it replaces,
BT_HCI_SET_PUBLIC_ADDR stops selecting BT_HCI_SETUP; the drivers that
apply the address in setup() (BlueNRG ACI, STM32WBA, CYW208XX) now
select BT_HCI_SETUP themselves, matching the conditions their setup()
implementations are compiled under.
Both functions are declared unconditionally, as coding guideline rule
A.1 requires of a header, so that their callers can select on the
option with IS_ENABLED() rather than the preprocessor, and defined in
a source file that is compiled only when the option is enabled, so
that a call that is not guarded fails to link rather than quietly
doing nothing. Only the field they work on is conditional, so a driver
that does not announce the capability pays nothing for it.
The driver API group version goes to 0.3.0 for the two functions added
to it.
The host identity test gains a scenario that creates a public identity
before bt_enable() and checks what the driver is handed while the
transport is opened, including that an enable without a public identity
hands it nothing rather than what the previous one left. The scenario
enables the capability through a prompt the test adds to it, since the
option is otherwise selected by drivers only. Its fake driver gains a
close() op, which the test needs in order to cycle the transport.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Resolve a logic error during mount that could result in entry data being
treated as allocation table entries, setting invalid internal state and
leading to data corruption on disk through future writes.
Fixes#119632
Signed-off-by: Jordan Yates <jordan@embeint.com>
Cancel in-flight DNS queries while the resolver context is still valid
during close. This unlinks their timeout work items from the kernel
timeout list before the context is torn down.
Without this, dns_resolve_init_default() can clear a context containing
a still-linked timeout node. A later timeout-list traversal can then
access corrupted list data and fault.
Remove the redundant cancellation from do_dns_resolve_reconfigure() and
add a regression test covering close, context reinitialization, and
prevention of a stale timeout callback.
Signed-off-by: Avishek Ganguly <avishekg@qti.qualcomm.com>
With DHCPv6 + NDP, devices typically need at least three
addresses: a link-local and two global. Set this as the default.
Also bump multicast address count for builds with DHCPv6,
to leave room for the all-nodes address, the solicited-node
groups, and application protocols.
Signed-off-by: Simon Duquennoy <simon.duquennoy@nordicsemi.no>
The reassembly slot timeout handler runs on the system workqueue while
final-fragment completion runs on the RX path, and both modify the same
slot with no synchronization. Completion only issues a non-synchronous
cancel of the slot timer, so a handler that is already running can free
the stored fragments while completion is still using them and crash the
RX thread.
Add a mutex serializing the slot array between the RX path, the timeout
handler and the slot iterator. Nothing that can block runs under it: the
handler detaches the first fragment and sends the ICMPv6 Time Exceeded
after unlocking, and the reassembled packet is handed back to the IP
stack the same way. Slot occupancy is tracked by the timer, so a handler
whose slot was re-armed for a new datagram while it waited for the lock
leaves that datagram alone.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The reassembly slot timeout handler runs on the system workqueue while
final-fragment completion runs on the RX path, and both modify the same
slot with no synchronization. Completion only issues a non-synchronous
cancel of the slot timer, so a handler that is already running can free
the stored fragments while completion is still using them and crash the
RX thread.
Add a mutex serializing the slot array between the RX path, the timeout
handler and the slot iterator. Nothing that can block runs under it: the
handler detaches the first fragment and sends the ICMP Time Exceeded
after unlocking, and the reassembled packet is handed back to the IP
stack the same way. Slot occupancy is tracked by the timer, so a handler
whose slot was re-armed for a new datagram while it waited for the lock
leaves that datagram alone.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
pm_system_resume() ran the resume sweep, and with it every driver's resume
handler, before sys_clock_idle_exit(). A driver is entitled to delay in
that handler -- a reference that has to settle, a converter that has to
recalibrate -- and k_busy_wait() reads the system timer, which
sys_clock_idle_enter() is free to have stopped. With
CONFIG_SYSTEM_TIMER_RESET_BY_LPM, which every SoC whose low-power states
gate the core clock has to set, it is stopped and its count is meaningless,
so the read never advances and the wait never ends: the system hangs on the
way out of a state it entered correctly.
Move the timer restart, and the SoC's own exit hook it depends on, ahead of
the sweep. Nothing between them touches a device, and the timer is what
everything after them relies on, so it belongs first. The hook's own
documentation described the order it used to run in; correct it.
This moves more than the restart. sys_clock_idle_exit() also hands the
kernel the ticks the sleep covered, and an announce runs the timeouts that
came due right there in the idle thread, so those handlers now run ahead of
the devices. A SoC selecting CONFIG_PM_STATE_SET_IRQ_UNLOCKED had its wake
ISR in that window already and sees no change; on the ones that keep
interrupts locked across resume the window was empty until now.
What can run there is bounded. Interrupts are still locked and this is the
idle thread, so only the handler body itself executes: one that readies a
thread does not get that thread scheduled until the idle path unlocks, and
by then the devices are back. That leaves a k_timer expiry function
touching a device directly, which is worth trading against a hang that is
certain.
Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
wifi_shell.c carried a private wifi_freq_to_channel() and the
hwsim driver open coded the same conversion twice, as a plain
(freq - 2407) / 5. Neither matches wifi_utils_chan_to_freq() at
channel 14: 2484 MHz maps back to channel 15, which has no
frequency, so a radio set up from a frequency alone ends up off
the medium.
Add wifi_utils_freq_to_chan() as the inverse of the forward
helper. A candidate channel is only returned once it converts
back to the frequency asked for, so the two directions cannot
drift and a frequency between two channel centers is rejected.
No band argument is needed because a center frequency is unique
across the bands. Drop the shell copy and use the helper in both
places.
The shell copy resolved neither the 5 GHz channels 32, 68 and 96
nor any 6 GHz channel, and printed the raw frequency in the
channel column for those. They now resolve, and a frequency that
belongs to no channel prints as 0 rather than as itself.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Wi-Fi drivers that report a channel list have to turn channel
numbers into center frequencies, and each one open codes the
arithmetic. The copies disagree: one clamps every frequency above
2472 MHz to 2484 MHz, so it maps channel 15 and up onto channel
14, and most handle only the 2.4 GHz band.
Add wifi_utils_chan_to_freq() so there is one place to get this
right, including the channel 14 exception to the 5 MHz spacing,
the 6 GHz band that none of the open coded copies cover, and the
6 GHz channel 2 special case that sits at 5935 MHz on its own
operating class instead of following the 5950 MHz base. The band
has to be supplied because channel numbers are ambiguous between
bands, the same reason wifi_utils_chan_to_band() documents.
The band is switched on first and the per band validator decides
whether the channel is valid, so a band with no mapping returns 0
without going through wifi_utils_validate_chan(), which logs an
error for a band it does not know.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
An in-band NO CARRIER set the dead bit and dropped the carrier, which
tells nobody when the interface is not up. net_if notifies only on a
transition into or out of NET_IF_OPER_UP, so while a PPP interface is
still dormant, as it is until the cellular driver reports registration,
the carrier drop moves it from dormant to down and no NET_EVENT_IF_DOWN
follows. The PPP L2 never learns, so it never changes phase and raises
no NET_EVENT_PPP_PHASE_DEAD, and a driver waiting on that event sees a
live session for as long as it waits.
The L2 cannot cover this window itself, since PPP has not come up and
ppp_change_phase returns early on a phase that is already PPP_DEAD.
Raise the event where the death is detected instead.
Signed-off-by: Paulo Santos <pauloxrms@gmail.com>
Add the base plugin for the mpipe subsystem. This plugin provides
the media-agnostic elements every domain needs:
- caps_filter: constrains the capability of a link
- tee: pushes each buffer to every branch of a graph
- queue: decouples the elements downstream of it onto their own thread
- app_src and app_sink: let the application be one end of a pipeline
Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
The Router Advertisement handler converts the Retrans Timer field to
host byte order, tests the result for being non-zero and then hands the
unconverted field to net_if_ipv6_set_retrans_timer(). On a little-endian
target the interface ends up with a byte-swapped value, 1000 ms turns
into 0xE8030000.
The value is read back by the privacy extension code, where it scales
the regeneration advance of a temporary address. With the swapped value
the advance grows to hours or months, so a prefix with an ordinary
preferred lifetime is taken as too short lived and no temporary address
is created for it.
Pass the converted value, as is already done for the reachable time.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The helper documented that initializing it again restores the initial
command allowance, for a controller that has been reset by other means
than an HCI command. That is not safe: bt_hci_lockstep_init() calls
k_sem_init(), which with CONFIG_OBJ_CORE_SEM links the semaphore's
object core, so initializing the same helper twice links the same
object twice and corrupts the tracking list. No in-tree driver does it
today, the one user initializing the helper from its device
initialization function, so this is a contract that invites the defect
rather than an active one.
Add bt_hci_lockstep_reset(), which restores the allowance and forgets
the outstanding command without re-initializing the semaphore, and
document initialization as the once-only call it has to be. The
transport send function and the caller's timeout survive the reset, so
a driver that resets its controller while opening it does not have to
repeat what it set up at device initialization.
The reset may be called from any context and takes the helper's lock,
so it may run while packets are being fed, and a driver that is fed
from a callback it cannot stop can use it too. It signals the change of
state by giving the helper's semaphore, as feeding does, so a sender
that waits for the controller to allow its command goes ahead.
A driver is expected not to reset its controller while a command is
outstanding, since it cannot be known which side of the reset the
command ended up on. If it does, the command is abandoned: its response
is no longer consumed and its sender fails at its deadline, not
earlier, so that a response which still arrives cannot be taken for
that of a later command with the same opcode. What the reset cannot do
either is tell packets the controller sent before it from the responses
to what follows, so those are not to be fed afterwards, which the
documentation now says.
The helper keeps its view of the command allowance from one opening of
the transport to the next, so the group documentation now says when a
driver has to call the reset.
Five cases are added to the unit test: the allowance is restored after
a command that went unanswered, a repeated reset, which is what a
driver resetting its controller on every open performs, a reset that
releases a sender waiting for the allowance, the same from an ISR, and
a reset with a command outstanding, whose sender must not return before
its deadline.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Add the WEBSOCKET_DEDICATED_HEAP Kconfig option to create a dedicated heap
for the allocations made by websocket_send_msg in the masking path. This
allows separating the websocket allocations from the system heap. The size
of this dedicated heap is controlled by the WEBSOCKET_DEDICATED_HEAP_SIZE
option.
Signed-off-by: Matthias Blankertz <matthias.blankertz@inovex.de>
Let PSA generate the HMAC keys used for RFC 7217 stable and RFC 8981
temporary interface identifiers instead of drawing them with
sys_csrand_get() and importing them on every call. The key material
never lives in application memory, and with TF-M it stays on the secure
side.
The keys are volatile and kept for the lifetime of the system, so each
generator holds one PSA key slot permanently instead of importing and
destroying a key per computation. A shared helper generates a key on
first use under a mutex, since the callers only hold the per-interface
lock and a race between interfaces would otherwise derive addresses
from a key that is then replaced. The stable and temporary generators
keep distinct keys as RFC 8981 requires.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The allocation tracker could keep several free records for one address,
one per earlier life of the slab slot, since a new allocation only
overwrote the first free entry. Once that entry was recycled by an
unrelated allocation, net_pkt_alloc_find() returned an older record and
the double unref report named a function that freed a different packet.
Reuse the free record of the same address on allocation, so at most one
record exists per address and the report names the last free of it.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
ocpp_connect_to_cs() takes the address of addr_buf before filling it
in, which GCC flags as a maybe-uninitialized use on some target and
optimisation combinations and, with -Werror, breaks the build.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
"net arp flush" has been there since the beginning but "net nbr" never
grew the same subcommand, even though the IPv6 side has been able to
clear its cache for a while. Add it, so the two families are reachable
the same way from the shell.
Add "net arp del" as well, to pair with "net arp add". Removing the one
entry that has gone stale is what a user reaching for the flush usually
wants, and it is the only way to take back an entry that "net arp add"
pinned, since the flush now keeps those. "del" is the verb the other net
subcommands use for this.
Point both flushes and the neighbor removal at the public API instead of
the subsystem internals, and show in "net arp" which entries are static,
so the help text saying they survive a flush can be checked.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
A flush is a blunt instrument. When one peer has gone away, or has come
back behind a different hardware address, throwing the whole cache away
punishes every other peer as well, and with the default ARP table size of
two entries that includes the gateway.
Add net_if_ipv4_nbr_rm() and net_if_ipv6_nbr_rm() alongside the flush
pair. They remove a static entry as well as a learned one, which is the
only way to take back an entry that a flush is required to keep, and they
report whether there was anything to remove. As with the flush, a NULL
interface matches any interface.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Both families can already drop the neighbors they have learned, but the
two entry points, net_arp_clear_cache() and net_ipv6_nbr_clear_cache(),
live under subsys/net/ where an application cannot reach them except by
forward declaring them itself. An application that knows its peers have
moved, say after a topology change that the stack cannot observe, has no
supported way to say so.
Add net_if_ipv4_nbr_flush() and net_if_ipv6_nbr_flush(), following the
shape net_if_nbr_reachability_hint() already uses in this header: a thin
per-interface wrapper over the private function, with an inline no-op
when the family is disabled. A NULL interface flushes every interface.
The IPv4 one is named after the family rather than after ARP. ARP is how
Ethernet resolves an IPv4 next hop, not how every link layer does, and
net_if.h is above that distinction; naming it for the protocol would put
an Ethernet detail into an API that other link layers can grow into. The
documentation says which cache it is on an Ethernet link.
Neither wrapper takes the interface lock. The caches have locks of their
own, the interface lock cannot be taken when no interface is named, and
net_if.c already goes out of its way to clear the IPv6 cache after
dropping that lock rather than while holding it.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
net_arp_init() walks the entry array and prepends every entry to the free
list, but it never empties that list first. The production code calls it
once from net_init(), so this has gone unnoticed, but a second call links
each entry into the list it is already on and turns it into a ring: the
node that used to be the head becomes reachable from itself.
Nothing detects that at the time, because entries are only ever taken off
the head of the free list. It surfaces much later, when the same entry is
handed out twice and ends up in the ARP table more than once, at which
point any walk of the table never terminates.
The ARP test suite calls net_arp_init() to get a clean cache, so the
corruption is one test away. Initialise the three lists before filling
the free one.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
net_ipv6_nbr_clear_cache() was written for the link-down path, so it only
ever needed the entries of one interface and treated a NULL interface as
a value that matches nothing. The ARP side has always taken NULL to mean
every interface, and the public API being built on top of the two needs
them to agree.
Accept NULL as "every interface" here as well, and pass the interface the
neighbor was found on to net_ipv6_nbr_rm() rather than the one the caller
asked about, which is now not necessarily the same thing.
net_ipv6_nbr_rm() itself has the same gap. Its lookup and its route
cleanup both take NULL to mean any interface, but the removal event was
still notified against whatever the caller passed, so the shell, which
has always called it with NULL, emitted NET_EVENT_IPV6_NBR_DEL with no
interface. Report the removal against the interface the neighbor was
found on.
The reference count test in the same condition is spelled out too.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>