The ARP cache can only be flushed as a whole. IPv6 has had per-address
removal since the neighbor cache was written, net_ipv6_nbr_rm(), and the
same primitive is the one an application actually wants when a single
peer has gone away: throwing the whole table away to re-resolve one
address punishes every other peer, and with the default table size of two
that includes the gateway.
Add net_arp_entry_rm(). It removes a resolved entry whatever its kind,
so it is also the way to take back a static entry, and it falls back to
the pending list so that removing an address that is still being resolved
drops the packets queued on it instead of leaving them to time out.
A NULL interface now matches an entry on any interface in
arp_entry_find(), which is what the callers of the new function want and
what net_arp_clear_cache() already does with its own loop.
The remove-and-return-to-the-free-list sequence was written out three
times, so collect it in arp_entry_release() and use that from the flush
as well.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The IPv6 neighbor cache distinguishes entries the user installed from the
ones learned off the wire: net_ipv6_nbr_clear_cache() skips
NET_IPV6_NBR_STATE_STATIC. The ARP cache has no such marker, so every
entry is equally disposable even though "net arp add" has always told the
user it was adding a static entry.
Add an is_static flag to struct arp_entry and honour it in the three
places where it matters. A cache flush leaves such an entry alone. The
LRU no longer evicts one, so it can now legitimately find nothing to give
back, which the caller in net_arp_prepare() already handles by dropping
the packet. An ARP message received from the network no longer rewrites
the hardware address of an entry the user pinned; an entry that any host
on the segment can overwrite is not static in any useful sense.
Setting the flag needs a way in, so add net_arp_add_static() and use it
for "net arp add". Both it and the force path of net_arp_update() need
to allocate an entry, so move the open-coded allocation out of
net_arp_update() into an arp_entry_add() helper.
The DHCPv4 server also inserts an entry with force set, but that one is
deliberately left dynamic: it exists only so a reply can be unicast to a
client that does not have its address yet, and the server drops it again
once the exchange is over.
Note that CONFIG_NET_ARP_TABLE_SIZE defaults to 2, so pinning entries has
a real cost on a small system: every static entry is one slot that
dynamic resolution can no longer use.
The interface comparison in net_arp_clear_cache() is spelled out in both
of its loops, since the conditions there are being rewritten anyway.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The reply to a SOCKS5 CONNECT carries a bound address and port behind its
four byte header, and how long that is depends on the address type. The
response callback read the header only and then released the packet, so
the rest of the reply was never taken off the stream.
That works as long as the whole reply arrives in one packet and the proxy
sends nothing else in it, which is the common case but not a guarantee:
- If the proxy writes the header and the bound address separately, the
address arrives in a later packet. The handshake is finished by then,
so those bytes are handed to the application as if they were relayed
data.
- If the proxy packs relayed data in behind the reply, that data is
released together with the packet and is lost.
Parse the reply incrementally instead. Keep receiving until all of it,
including the bound address that is not needed for anything, has been
consumed, and pass a packet that still holds data on to the socket layer
so that it can be queued ahead of whatever arrives next.
A reply whose address type is neither IPv4, IPv6 nor a domain name is now
rejected with -EPROTO. The end of such a reply cannot be located, so
nothing following it can be trusted either. Before, the rest of the reply
was ignored and the connection was reported as successful.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Previously audio.conf was a standalone configuration file, but
has now been changed to work as an extra_conf_file instead.
The purpose of this is to avoid having too many duplicate
configs in the shell application.
Additionally the LE audio tests in tests.yaml has been changed
to use YAML anchors to reduce the amount of duplicated
configurations in that file too, keep each test case simpler.
Some of these changes exposed some existing surpressed warnings
that were similarly fixed.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Nothing stops smp_send_security_req() from running again while a
Security Request is still unanswered. SMP_FLAG_PAIRING is only set once
the peer replies, and the required_sec_level check in
bt_conn_set_security() only filters a repeat at the same level, so an
escalation or BT_SECURITY_FORCE_PAIR gets through. A second request puts
another PDU on air and re-runs smp_init(), which discards the nonce
generated for the request already in flight.
Claim SMP_FLAG_SEC_REQ with atomic_test_and_set_bit() and return
-EALREADY if it was already set, so two threads calling
bt_conn_set_security() cannot both start the procedure. smp_init()
clears smp->flags, so it now keeps that bit while clearing the rest. A
save and restore would not do: the bit would still read as clear for
the duration of the memset, which is enough for a concurrent caller to
pass the test.
bt_conn_set_security() overwrites required_sec_level and FORCE_PAIR
before calling in, so a rejected second call would lower the level the
in-flight request is held to. Restore both on -EALREADY and document it
in conn.h. Documenting the new return value is a backwards compatible
API change, so the bt_conn group patch version moves to 1.0.1.
Signed-off-by: Zhijie Zhong <zhongzhijie1@xiaomi.com>
Assisted-by: Kiro:claude-opus-5
smp_send_security_req() sets SMP_FLAG_SEC_REQ and allows
BT_SMP_CMD_PAIRING_REQ only after bt_l2cap_send_pdu() returns.
bt_l2cap_send_pdu() only queues the PDU, and the Pairing Request that
answers it is handled by bt_smp_recv() on the Bluetooth RX thread, not on
the thread that called bt_conn_set_security(). The answer can therefore be
processed before the two atomic_set_bit() calls have run, in which case the
allowed_cmds check in bt_smp_recv() drops it without even sending a Pairing
Failed and the peer waits for a response that never comes.
Publish the state before handing the PDU to L2CAP, and roll it back if the
send fails.
Signed-off-by: Zhijie Zhong <zhongzhijie1@xiaomi.com>
Assisted-by: Kiro:claude-opus-5
When syslog formatting is enabled and an ISR generates a log message,
the tid is NULL. The strstr validation check incorrectly evaluated
k_thread_name_get(tid) blindly, crashing the kernel before reaching
the safety fallback.
This safely evaluates the thread name or uses the irq fallback before
performing any string validation, preventing the crash.
Signed-off-by: harshit kudhial <harshitkudhial@gmail.com>
When the Controller resolves a Resolvable Private Address to an identity
address, it signals this by setting bit 1 of the Address_Type field in
the relevant HCI LE event (e.g. LE Enhanced Connection Complete, LE
Advertising Report, LE Scan Request Received). Previously the default
case of the address-type switch in bt_addr_le_to_str() printed the raw
type byte, so the resolved bit was preserved (as 0x02 or 0x03) in log
output.
With the move to the prefix-based string format bt_addr_le_to_str()
formats such values by their base type, so this information would be
silently dropped from logs. Print a " (resolved)" suffix at the
affected log sites so the indication remains visible in the log message
without leaking the HCI-specific extended type into the public API.
Use the existing bt_addr_le_is_resolved() helper from addr_internal.h
rather than introducing a new helper.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Replace the "XX:XX:XX:XX:XX:XX (type)" string representation of LE
addresses with a compact form that carries the address type as a
single-character prefix:
- "P:XX:XX:XX:XX:XX:XX" for public addresses
- "R:XX:XX:XX:XX:XX:XX" for random addresses
The address and its type are now one whitespace-free token, which makes
shell input trivial to parse and lets an address be pasted from log or
shell output straight into a command.
bt_addr_le_to_str() produces the new format. Address type values that
carry HCI-level extension bits, such as the Controller-resolved
identity types, are formatted by their base type, and the unresolved-RPA
and anonymous sentinels as random addresses; the extra information has
to be conveyed separately by the caller. BT_ADDR_LE_STR_LEN shrinks from
30 to 20 bytes.
bt_addr_le_from_str() loses its separate type argument and accepts only
the new format, with the prefix, like the hexadecimal digits, accepted
in either case. Neither the old output nor the old two-token input form
is retained: the string representation was never documented as a
stable format, and the Bluetooth Working Group agreed to switch to the
new one directly rather than carry a deprecation period.
All shell commands taking an LE address (bt connect, disconnect,
select, info, clear, directed-adv, adv-create/adv-param directed,
per-adv-sync-create, oob-remote, fal-add, fal-rem, id-create, id-reset,
gatt resubscribe, bap_broadcast_assistant add_src, bap_scan_delegator
add_src and cap_commander broadcast_reception_start) now take the
address as a single argument. Their argument counts, positional
argument indices, help strings and shell documentation are updated
accordingly. While at it, bap_scan_delegator add_src is fixed to
reference the right argv slots in its error messages and metadata
parsing, and id-create no longer proceeds with an uninitialized address
after failing to parse its argument.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Implementation of SNTP server functionality (RFC 5905).
The server listens on UDP port 123 on every enabled address family and
answers client requests from the system clock. It is driven by the socket
service, so it needs no thread of its own. The application sets the system
clock and then describes its clock source to the server with
sntp_server_clock_source(). Until it does, the replies carry the leap
indicator "clock not synchronized" and stratum 16, so that clients discard
the timestamps instead of trusting an unset clock.
Requests that are not in client mode are dropped, otherwise two servers
that see each other's replies would answer each other forever, and a
datagram claiming an NTP version outside 1..4 is dropped as well.
The Kconfig symbols are split so that the client and the server can be
enabled independently. CONFIG_SNTP keeps its meaning of "SNTP client", the
new CONFIG_SNTP_SERVER enables the server, and both select the hidden
CONFIG_SNTP_LIB which builds the packet handling they share. The library
directory is now added to the build for CONFIG_SNTP_LIB rather than for
CONFIG_SNTP, otherwise a server only build would compile nothing at all.
Co-authored-by: Benjamin Cabé <benjamin@zephyrproject.org>
Co-authored-by: Fin Maaß <info@finmaass.de>
Signed-off-by: Lothar Felten <lothar.felten@gmail.com>
MAX_VIRT_NAME_LEN capped the buffer at
CONFIG_NET_L2_VIRTUAL_MAX_NAME_LEN, whose range starts at 8, but the
snprintk() writes "VLAN to " plus an interface index, which needs up
to 20 bytes. At the minimum setting the call can never fit and
-Werror=format-truncation rejects it. Size the buffer for what it
formats and let net_virtual_set_name() truncate as it already does.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
RFC 4861 sets the minimum ICMP length of a Neighbor Advertisement to 24
octets and of a Router Advertisement to 16 octets, the fixed header only.
The input length checks also required room for one option header, so
valid option-free NA and RA packets were dropped. This broke NUD against
peers answering a unicast NS without a TLLAO option and ignored RAs that
carry only the fixed header.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
If the remote device is requesting BT_BAP_BIS_SYNC_NO_PREF
then the scan delegator will no longer make a choice on whether this
counts like a new request, as that choice is left to the
higher layers.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
There is an issue found that when both Bluetooth Classic and LE audio
are enabled, the LE audio driver may cause an assertion when a Classic
connection notification occurs because it doesn't check the connection
type.
Add `bt_conn_is_type()` checks to Bluetooth audio subsystem callback
functions to ensure they only process LE connections. This prevents
potential issues when BR/EDR or other connection types trigger these
callbacks.
The checks are added early in callback functions before accessing
LE-specific connection fields or performing LE-specific operations.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Defer the script completion callback until after all internal state has
been reset. This allows the callback itself to start another script
without having to start the next operation from another context.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Update the type definition of `modem_chat_script_callback` to take a
pointer to a context variable. This context variable holds additional
internal information about the script that the callback might be
interested in.
The goal is to remove any need for the callback itself to query internal
state of the `modem_chat`, because anything it needs it has already
been given. Eventually, this will lead to callbacks being able to queue
a new script directly from the callback of the previous script.
Breaking API change.
Signed-off-by: Jordan Yates <jordan@embeint.com>
net_socks5_connect() takes the address of an uninitialized
net_sockaddr_storage and passes it to net_sad(), which GCC reports as
-Werror=maybe-uninitialized because net_context_get_option() need not
fill it. Zero it at declaration, as the other net_sockaddr_storage
users do.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
The state update on DAD completion and on a lifetime update ran without
the interface lock, so it raced the demotion done by a concurrent
removal and could leave a removed address preferred.
Take the interface lock around both. The public lifetime update and the
address expiry find the interface owning the address with a new helper
that returns with the interface lock held, so the IPv6 config cannot be
released in between. Callers that already hold the interface lock, the
add path and the privacy extension code, use a variant that skips the
lookup, so no other interface lock is taken while one is held. The
interface lock is taken before the global lock, the order the add and
remove paths already use.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
net_if_ipv6_addr_update_lifetime() marked the address preferred even
while DAD was still running for it, which ended duplicate detection
early. Leave a tentative address alone, DAD completion sets the final
state.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
A removed address stayed PREFERRED while references kept it alive, so
new connections kept picking it as source and could postpone the actual
removal indefinitely.
Demote the address to DEPRECATED on a deferred removal and undo the
demotion when it is added again. DAD, ACD and lifetime updates promote
a removed address to DEPRECATED instead of PREFERRED. An address still
in DAD or ACD stays tentative across removal and re-add.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
A deferred removal leaves a referenced address in place and marks it as
not added. A second net_if_ipv4_addr_rm() or net_if_ipv6_addr_rm() call
on such an address still decremented the count, consuming a reference
that belongs to a user of the address, so the address could be freed
while still in use.
Look the address up first and return false without touching the
reference count when it is already marked as removed.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
ipv6_addr_rm_all() and ipv4_addr_rm_all() called the address removal
until the slot was freed, which relies on every call consuming one
reference. Drop the remaining references directly so that the release
does not depend on how the removal treats a referenced address.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
After dropping the oldest pending packet, the timeout handler took the
next one off the queue and ran it through net_ipv6_prepare_for_send()
without releasing the queue reference. The packet was queued again
holding three references and one of them was never released. With
more packets queued it was appended without a new NS and with send_ns
cleared, so the handler skipped the neighbor from then on and its
packets were never freed. If the neighbor had gained a link address in
the meantime, the packet was neither sent nor released.
Send a new NS without attaching a packet, so the remaining packets
stay queued in their original order and keep their references. If the
neighbor got resolved, send them all. Release the neighbor whenever it
ends unresolved with nothing queued, including when the NS itself
cannot be sent.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
An RA carries the source link-layer address option only optionally.
When it is absent and the router already has an INCOMPLETE entry with
queued packets, the RA handler sent them anyway. Each send found the
neighbor unresolved and queued the packet again, so the loop never
saw an empty queue and spun with the neighbor lock held, sending an
NS per iteration. Leave the packets queued until the neighbor resolves
or the NS reply timeout drops them.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The NA handler had its own copy of the pending queue drain. A packet
that failed to send was popped first, so nbr_clear_ns_pending() no
longer covered it and it stayed allocated with both references. The
failure also cleared packets that were never attempted, and send_ns
stayed set on success. Use the shared helper, which releases the
queue reference of every packet it takes, tries each of them and
clears send_ns when done.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The RA handler pops each pending packet before sending it, so the
trailing nbr_clear_ns_pending() no longer finds them and the reference
taken when the packet was queued was never released. Move the loop
into a helper that releases that reference for every packet it takes
off the queue.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
A packet on the neighbor pending queue holds the reference handed over
by the sender and one taken when it was queued. nbr_clear_ns_pending()
dropped only one of them, leaking the packet whenever a neighbor with
queued packets was freed or its NS could not be sent.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
net_ipv6_send_ns() releases the packet when it cannot send the NS, and
on success the packet belongs to the neighbor pending queue, where the
RX thread may send and release it at any time. net_ipv6_prepare_for_send()
still read the packet for its debug output after the call. Log before
handing the packet over.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Fixes various issues with Kconfigs, including:
- Using the wrong indentation
- Not having [EXPERIMENTAL] in the prompt, or not having it at
the end
- Wrongly stating the CONFIG_EXPERIMENTAL is needed to enable
an experimental Kconfig
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Fixes various issues with Kconfigs, including:
- Redundent `default n` on bools
- Not select deprecated on supposed deprecated symbols
- Using the wrong indentation
- Not having [DEPRECATED] in the prompt, or not having it at the
end
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
In gptp_set_md_sync_receive the cumulativeScaledRateOffset field is
an int32_t, but it was decoded with net_ntohl(), which returns a uint32_t.
That unsigned value was then assigned directly into the double
rate_ratio, so the sign of any negative CSRO was lost.
And that negative rate offset got decoded incorrectly.
That corrupted value then overflowed when re-encoded and was forwarded
from device 3 to device 4 in the chain, causing device 4 to lose
synchronization.
Fixed it by preserving the sign before the conversion to double.
Signed-off-by: Youri Tils <youri.tils@nxp.com>
When starting a set of sink streams only, the callback for the
start subprocedure was not called, because the subproc_initiated
was not set.
When we are starting sink streams only, there is also a race
condition between the CIS connected event and the ASE GATT
notification that was unhandled.
When get_next_proc_param returns NULL, we now check if that is the
case, and if all streams are already in the streaming state,
we can finish the procedure directly, or fail if they are not.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adds option to continue instrumentation sample gathering
when buffer fills, by dumping the buffer instead of stopping
instrumentation.
Signed-off-by: Eryk Szpotanski <eszpotanski@antmicro.com>
The command bodies inside if(CONFIG_NET_OFFLOAD) and if(CONFIG_NET_NATIVE)
in subsys/net/ip/CMakeLists.txt start at column zero, while the CMake style
guidelines ask for two spaces per block level. The file has been like this
for years and nothing complained, because the CMakeStyle compliance check
only reports issues on the lines a change touches.
Removing the JSON test protocol deleted a line from the middle of the
CONFIG_NET_NATIVE block, and a deletion makes the check look at the two
lines that now close over the gap - which were never indented either. Fix
the whole file rather than the two lines that happened to be reported, so
the next change in here does not run into the same thing.
Whitespace only, no functional change.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
CONFIG_NET_TEST_PROTOCOL let a TTCN-3 suite drive the TCP stack over a
JSON channel on UDP 4242: open a connection, send, receive, close, read
back the connection's internal state, adjust the retransmission timeout
and window, and stop and continue at breakpoints.
Nothing in the tree has ever enabled it. Because nothing enabled it, no
CI job compiled it, and it stopped compiling years ago: a stale
enumerator, a variable declared twice in one scope, a call whose
signature had changed and a clobbered payload length had all
accumulated. Its last intentional change was in 2020. The suites that
drove it, and the tool that bridged them to Zephyr, were archived by
their author in 2023.
Removing it also removes what it asked of the stack: a build with it
enabled did not randomise initial sequence numbers and did not wait for
a connection to come up, so it was not the TCP that ships. A protocol
test that has to alter the protocol to run tells you about the altered
one.
None of this forecloses TTCN-3 testing. What it forecloses is testing
through a private channel into the stack's internals, which is the part
that has to be maintained in step with the stack and that nobody was
maintaining.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The JSON test protocol reached into the TCP stack in three ways, and all
three cost something whether or not it was enabled.
It swapped the allocators. tcp_malloc, tcp_calloc, tcp_free,
tcp_pkt_clone and tcp_pkt_unref each had two definitions, and conn_seq
and conn_ack turned every sequence and acknowledgement update into a
tracked call. That is fifteen call sites in tcp.c reading as function
calls when they are additions, to feed leak and sequence tracking that
CONFIG_NET_BUF_POOL_USAGE and the heap listeners already cover.
It weakened TCP. Initial sequence numbers were not randomised, and
net_tcp_connect() returned without waiting for the connection, so a
build with the test protocol in it did not behave like the one that
ships. Testing that build tells you little about this one.
And it carried its own input path: a raw connection callback on TCP port
4242 that built a net_context by hand and bypassed sockets, an echo
callback spliced into the receive path through a global function
pointer, and a JSON command interpreter on UDP 4242. Around two hundred
and sixty lines, none of it reachable from anything in the tree.
Remove all three. CONFIG_NET_TEST is a different option and stays: the
tests under tests/net/tcp need a predictable initial sequence number.
tcp_send_cb stays too, for the same reason.
tcp.c gains an include of sys/types.h, which it had been getting through
tp.h.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
sip_svc_open() used a k_timer living on the caller's stack to track its
polling deadline. Kernel object tracking (CONFIG_OBJ_CORE_TIMER, object
tracking) registers timers passed to k_timer_init(), leaving the
tracking lists referencing dead memory once the function returns.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Assisted-by: Claude:claude-fable-5
Add bt_id_reset_irk(uint8_t id, uint8_t *irk) to replace the local
Identity Resolving Key for an identity without changing its identity
address.
The caller can provide an IRK, or pass NULL or an all-zero buffer to
have the stack generate one and return it in the buffer.
Reject the operation when the stack is not ready, any advertising set
is active, the identity has a created extended advertising set, the
default identity is used for scanning or initiating, or bonds exist.
Bonds must be removed with bt_unpair() before resetting the IRK.
Persist the new IRK when CONFIG_BT_SETTINGS is enabled.
Invalidate the current RPA state and the cached per-identity RPA
after a successful reset.
The API is available when CONFIG_BT_PRIVACY is enabled.
Preserve -ENOTSUP when random generation is unsupported and map other
random generation failures to -EIO.
Assisted-by: Augment:GPT-5.6
Signed-off-by: Sharon Lin <slin@atmosic.com>
Fix modbus async transmission not aborted when calling modbus_disable(),
which would result in the async callback re-enabling reception and
lead to further problems.
Signed-off-by: Jonathan Deneault <jxd47@acuitysso.com>
decode_payload_length() pulled the 16-bit extended length after the 0x01
prefix octet without checking that two octets remain, so a truncated
message read past the end of the receive buffer and underflowed buf->len.
Reject such a message with -EPROTO before the pull.
Assisted-by: Claude:claude-fable-5.1
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add an error log when conn_track_create() fails to allocate a new
NAT entry, e.g. when the NAT table is full. This makes it easier to
diagnose dropped connections caused by NAT table exhaustion.
Signed-off-by: Humphrey Chiramba <humphrey@plentify.co.za>
Mark the custom, non-HCI stack selection as deprecated. The option
dates from the early days of the subsystem, when a product offloaded
the whole Bluetooth Host behind the Zephyr Bluetooth API. Nothing in
the tree selects it, the placeholder for custom drivers under it has
been empty since it was added, and HCI transports are regular device
drivers today. Out-of-tree stacks add their own entry to the choice,
which stays as that extension point; only this entry goes after the
deprecation period.
A build with the option enabled has not compiled since commit
d382fca6ff ("Bluetooth: Controller: Fix HCI command buffer allocation
failure"), which added a static assertion on HCI-only buffer options to
a header the common code includes, and nobody reported it.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Enabling CONFIG_BT restricts SYSTEM_WORKQUEUE_PRIORITY to the
cooperative range for every build, but the requirement comes from the
individual components that submit work to the system workqueue, not
from Bluetooth being enabled.
An application that asks for a preemptible system workqueue therefore
cannot build with Bluetooth enabled at all, even when no Bluetooth
code uses that queue. Running the system workqueue below every other
thread is a common way to service a watchdog only while the whole
system is still making progress.
Add BT_SYSTEM_WORKQUEUE_COOP and apply the range only when it is set.
The components that need the system workqueue to stay cooperative
select the option themselves, so the requirement is recorded next to
the code that has it and a new work item cannot slip past it: the
host stack, the H:5 and STM32WB0 drivers, the NXP wake-on-BT LED
blink option, and BT_CTLR_PRIVACY when the split link layer builds
ull_filter.c.
Mesh, Audio and the other Host users need the Host, so they are
covered by its select; they get their own when the Host drops it.
No in-tree configuration changes behavior: SYSTEM_WORKQUEUE_PRIORITY
already defaults to -1, and no Bluetooth test or sample overrides it.
Signed-off-by: Wai-Hong Tam <waihong@google.com>
Add info-level "Received" logs in SLAAC autonomous prefix handling
so SLAAC address assignment has parity with DHCPv4 and DHCPv6 logs.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
The 11k branch of the roaming fallback dereferences
bss_support_neighbor_rep() without a NULL check, unlike the
bss_ext_capab() and legacy_roam() branches next to it. The op is
optional, so a driver that offers BSS transition but not radio
measurement traps on the first roaming request instead of falling
through to the 11v and legacy methods.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Adds support for using Bluetooth Low Energy with transport
management, to allowing bridging (both incoming and outgoing)
connections to/from other MCUmgr transports
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Signed-off-by: Jamie McCrae <spam@helper3000.net>
Refactors the code to make it more concise and easier to extend
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Signed-off-by: Jamie McCrae <spam@helper3000.net>
tcp_pkt_linearize() is used by th_get() when a received TCP header is
not contiguous in a single net_buf.
Issue:
While removing header bytes from the following fragments, the loop
called net_buf_unref() on each emptied net_buf without detaching its
frags pointer first. net_buf_unref() walks and frees the entire frag
chain, so payload buffers still linked from that fragment were freed
as well. The freed pointer was then installed back into the packet
(buf->frags = second), leading to use-after-free / double-free during
later packet teardown on the RX path.
A second problem in the same loop always advanced to second->frags
even when the current buffer was not empty after pulling the remaining
header bytes. If header remainder and payload shared one net_buf, that
leftover payload was orphaned and dropped from the packet.
Fix:
- Save next = second->frags, set second->frags = NULL, then unref so
only the emptied header fragment is freed.
- Advance to the next fragment only when second->len == 0; if data
remains, keep that buffer as the start of the payload chain.
This matches the usual net_buf ownership pattern used elsewhere in the
stack (detach before unref) and preserves payload that follows a split
TCP header.
Signed-off-by: Swamidas Nampalli <Swami.Das@silabs.com>
Duplicate address detection asks the link whether an address is already
in use and takes the silence that follows as the answer. When the
solicitation cannot be sent, the silence is not an answer to anything,
but the timer that fires next cannot tell the two apart: it marks the
address preferred and announces that detection succeeded. The address
then goes into use having never been asked about.
RFC 4862 5.4 requires detection on every unicast address before it is
assigned, and a query that never left the interface is not that. Sending
one takes a buffer and an entry in the neighbour cache, which it needs
even though the address being asked about is the interface's own, so the
send fails exactly on the small devices where a duplicate is least
likely to be noticed by anything else.
Remember that nothing was asked, and ask again from the same timer. An
address whose solicitation goes out on a later attempt is used as
before. One whose solicitation cannot be sent at all is left tentative,
so it is not used, and says so at error level rather than passing
silently.
A solicitation that got as far as the neighbour cache before failing
leaves its entry there, and nothing reclaims an incomplete one: only
stale entries are evicted, and the reply timer is armed only for a
solicitation that has a packet pending behind it. Every failed attempt
now drops the entry it may have left, or a failure would cost a cache
slot for good - and a cache with no slot left is one of the two ways
the send fails to begin with.
The retry runs from the timer with the lock released, and by then the
entry has left the list that an address removal looks on, so the address
can be taken away while the entry waits. Check that the slot is still in
use before working on it, rather than putting a freed one back on the
timer list.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>