Commit graph

21541 commits

Author SHA1 Message Date
Florian Weber
b55b9ae72b rtio: workq: bugfix of memory allocation
This commit fixes the bug that the memory of the work request is
freed up in the work handler, before it is not needed anymore by the p4wq.
This is fixed now, by using the new done_handler in the p4wq
for freeing up that memory.

Signed-off-by: Florian Weber <Florian.Weber@live.de>
2025-02-12 16:03:17 +01:00
Vinayak Kariappa Chettimada
a8065926ac Bluetooth: Controller: Fix to release aux context stored in node rx
Fix to release aux context stored in node rx, and not in the
superior scan or sync context as the one in the superior scan
or sync context could be reset or have a different new aux
context when multiple advertising chain reception is used.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-12 12:24:52 +01:00
Vinayak Kariappa Chettimada
3263729020 Bluetooth: Controller: Fix assertion terminating Periodic Sync
Fix assertion due to changes introduced to support multiple
advertising chain reception.

Auxiliary context association with the Periodic Sync context
was not cleared due to which when terminating a Periodic
Synchronization triggered an assertion check, under race
conditions, detecting that the auxiliary context was already
released.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-12 12:24:52 +01:00
Vinayak Kariappa Chettimada
2461552e19 Bluetooth: Controller: Fix Periodic Sync for multiple chain reception
Fix regression introduced in Periodic Advertising
Synchronization due to change related to multiple
Advertising chain reception.

Related commit c334ed515b ("Bluetooth: Controller: Fix
multiple Extended Adv chain reception"), and
commit da792a9e17 ("Bluetooth: Controller: Fix interleaved
extended scanning assert").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-12 12:24:52 +01:00
Emil Gydesen
571f26cf1a Bluetooth: Rename BLE to Bluetooth (LE) where applicable
The BLE acronym is not an official description of Bluetooth
LE, and the Bluetooth SIG only ever refers to it as Bluetooth
Low Energy or Bluetooth LE, so Zephyr should as well.

This commit does not change any board or vendor specific
documentation, and the term BLE may still be used in those.
It will be up to the vendors to update it if they want,
since many of them are using the term BLE in their
products.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-12 12:24:18 +01:00
Vinayak Kariappa Chettimada
8ebc4f3384 Bluetooth: Controller: Fix sync_delay and latency in LE BIG Complete
Fix missing sync_delay and transport_latency information in HCI
LE BIG Complete event.

Relates to commit 1a640e4711 ("Bluetooth: controller:
Included transport latency in LE_Big_Established").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-12 12:23:51 +01:00
Fengming Ye
826f445c69 wifi: shell: add ACS case in ap enable cmd
In ap enable cmd, channel set to 0 means ACS mode.
Remove hostapd AP macro for this case to make ACS mode
available for public usage.

Signed-off-by: Fengming Ye <frank.ye@nxp.com>
2025-02-12 12:23:35 +01:00
Vinayak Kariappa Chettimada
83e2ec3c9b Bluetooth: Controller: Fix device address in Periodic Adv Sync
Fix incorrect device address reported in the LE Periodic
Advertising Sync Established event when using Periodic
Advertiser List.

During Extended Scanning there can be an ADV_EXT_IND PDU
received between currently being received ADV_EXT_IND PDU
and AUX_ADV_IND PDU; if the one received between has an
address match then incorrectly the Periodic Synchronization
was established to the device whos AUX_ADV_IND PDU is being
received. Fix by storing the auxiliary context that has the
address match and compare with it when matching the SID in
SyncInfo of AUX_ADV_IND PDU being received prior to creating
the synchronization.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-12 12:22:52 +01:00
Vinayak Kariappa Chettimada
5119896c7d Bluetooth: Controller: Fix BT_CTLR_LOW_LAT_ULL conditional code
Fix BT_CTLR_LOW_LAT_ULL conditional compilation code by
decoupling it from BT_CTLR_LOW_LAT code.

BT_CTLR_LOW_LAT_ULL makes ULL execution context to tailchain
in comparison to continuously process in a while loop.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-12 12:22:18 +01:00
Emil Gydesen
49d9b4cb69 Bluetooth: PACS: Remove BAP infix for pacs_register_param
Since the PACS service is not part of the bt_bap API it should
not use the bt_bap prefix, and instead just be bt_pacs like the
rest of the PACS API.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-12 09:41:49 +01:00
Robert Lubos
558e2a5556 net: lwm2m: Fix time resource validation
When writing to a time resource, the logic was incorrect when validation
was enabled for the resource - when determining the actual underlying data
type we should compare against the data buffer length and not the
validation buffer length.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-02-12 09:41:35 +01:00
Jukka Rissanen
ae05221762 net: Update IP address refcount properly when address already exists
If an IP address already exists when it is tried to be added to the
network interface, then just return it but update ref count if it was
not updated. This could happen if the address was added and then removed,
but for example an active connection was still using it and keeping the
ref count > 0. In this case we must update the ref count so that the IP
address is not removed if the connection is closed.

Fixes #85380

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-02-12 09:41:24 +01:00
Jukka Rissanen
908cfacd85 net: mdns_responder: Add announce support
After probing, send two unsolicited mDNS response messages
for our name.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-02-12 09:40:15 +01:00
Jukka Rissanen
9e79184f7e net: mdns_responder: Implement probing support
The mDNS probing is described in RFC 6762 chapter 8.1.
The code will send an unsolicited mDNS query to network and
will check if there are existing hosts with the same name.
If there are, then the mDNS responder will not respond to
queries it is configured to use.

Fixes #84333

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-02-12 09:40:15 +01:00
Jukka Rissanen
8d601a0cc2 net: dns: Allow creating context with specific interface
Allow user to specify the network interface where the query should
be sent, but only if the user has supplied the DNS servers in sockaddr
list. If user has specified a DNS servers in a string list, then the
possible network interface is taken from the string.

The reason for this is that it is not possible to add network interface
to the sockaddr list so an extra parameter is needed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-02-12 09:40:15 +01:00
Jukka Rissanen
82ef524777 net: dns: Allow creating context with specific svc and port
Allow user to specify socket service struct and port number so
that DNS servers specified in Kconfig etc are not used. This way
we can send a DNS query to arbitrary address without it affecting
the system configuration.

This is used in mDNS probing so that that mDNS responder can send
probe message and not change / configure system global DNS config.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-02-12 09:40:15 +01:00
Jukka Rissanen
af758e51a2 net: dns: Introduce resolver function that avoids using the cache
Introduce dns_resolve_name_internal() that allows resolving a name
and not use DNS cache if caching is enabled.

This is needed in mDNS probing (RFC 6762 chapter 8.1) which needs
to send a mDNS query and not get any results from cache.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-02-12 09:40:15 +01:00
Johan Hedberg
90367c8dd1 Bluetooth: Host: Classic: Fix allocated PSM comparison
The code for checking for allocated BR/EDR PSMs was potentially resulting
in an integer overflow, due to doing a <= UINT16_MAX (0xffff) comparison
on a uint16_t variable. To avoid this, use a uint32_t variable internally.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-02-12 02:26:57 +01:00
Tom Hughes
d811760779 net: lib: coap: Remove unused function
Building with clang warns:

subsys/net/lib/coap/coap_link_format.c:39:20: error: unused function
'append_be16' [-Werror,-Wunused-function]
static inline bool append_be16(struct coap_packet *cpkt, uint16_t data)

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-02-12 02:25:53 +01:00
Tom Hughes
1f653ae295 net: lib: http_server: Remove unused function
Building with clang warns:

subsys/net/lib/http/http_hpack.c:21:20: error: unused function
'http_hpack_key_is_dynamic' [-Werror,-Wunused-function]
static inline bool http_hpack_key_is_dynamic(uint32_t key)
                   ^

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-02-12 02:25:41 +01:00
Tom Hughes
d2bf3ae905 net: ipv6: Remove unused function
Building with clang warns:

subsys/net/ip/ipv6_nbr.c:137:31: error: unused function
'get_nbr_from_data' [-Werror,-Wunused-function]
static inline struct net_nbr *get_nbr_from_data(struct net_ipv6_nbr_data
                              ^                 *data)

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-02-12 02:23:07 +01:00
Johann Fischer
7ffa6203e1 usb: device_next: allow CDC ACM UART to be initialized and enabled at boot
There are some boards and samples in the tree that use the CDC ACM UART
as the default serial backend, just like a real UART controller would.
The new device stack requires more detailed configuration than the old
one. In order to use the CDC ACM UART as the serial backend with the new
device stack in the same way as with the legacy stack, we need to
provide a solution to initialise and enable the CDC ACM UART at boot
time. We cannot use snippets as they do not support Kconfig files or
source code. Shields would be an option, but they cannot be used for
virtual devices such as the CDC ACM UART. The remaining solution is to
put the code and Kconfig file for it in the subsys directory.

Allow CDC ACM UART instance and USB device stack to be initialized and
enabled at boot time and to use it as serial backend for logging or
shell.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-02-12 02:22:18 +01:00
Johann Fischer
7b344567be usb: device_next: fix cdc_acm_send_notification()
Fix "warning: 'cdc_acm_send_notification' defined but not used"
when Kconfig option UART_USE_RUNTIME_CONFIGURE is not used and
properly handle enqueue error.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-02-12 02:22:18 +01:00
Emil Gydesen
b67d291207 Bluetooth: Host: Add type check for bt_conn API
Added a new function, bt_conn_is_type, that returns whether
the provided conn object is of the provided type.

This check is then used to ensure that the conn objects
supplied to other bt_conn function are of the right type.
The right type has also been documented for these functions.

This is an initial commit for a larger change in the BT Host,
as similar checks should be added to the L2CAP, GATT, ISO,
Audio and possibly Mesh APIs.

The type check could have been implemented by using the
bt_conn_get_info function, but that requires additional
function calls as well as memory allocation and copy.
Since bt_conn_is_type is designed to be widely used, it
was suited for its own function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-11 22:04:51 +01:00
Aleksandr Khromykh
4bb595718d Bluetooth: Mesh: remove double cdb node storing
Commit removes the double cdb node entry storing
into the settings if device was reprovisioned over
nppi interface.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2025-02-11 18:56:37 +01:00
Emil Gydesen
788486b972 Bluetooth: ISO: Add range to BT_ISO_MAX_BIG
If BT_ISO_BROADCAST is enabled, then we shall support
at least 1 BIG and at most BT_EXT_ADV_MAX_ADV_SET since
each BIG requires its own advertising set.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-11 15:42:03 +01:00
Robert Lubos
d6792494b7 net: coap_client: Fix build with cpp projects
The coap_client.h header won't build if included from c++ file:

error: expected primary-expression before ‘.’ token
  .value[0] = coap_bytes_to_block_size(CONFIG_COAP_CLIENT_BLOCK_SIZE),

Therefore move the actual function implementation to the library C file
to prevent this.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-02-11 15:41:37 +01:00
Luca Burelli
802156c0cb logging: improve log_flush() robustness
The 'log_flush()' function is used to wait for all pending log messages
to be processed by the background thread. This is performed by polling
the 'log_data_pending()' function, which scans all available buffers.

The log core already provides a 'buffered_cnt' variable that keeps track
of the number of pending messages. This variable is updated atomically
and could be a more efficient implementation for that check.

This commit moves the 'buffered_cnt' decrement _after_ the message
processing and buffer release, to ensure that the variable reflects
the number of pending messages at any moment in time.

The 'log_data_pending()' function is then replaced with a direct check
of the 'buffered_cnt' variable.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-02-11 15:39:29 +01:00
Qingling Wu
159332d591 net: wifi: hostap: add CA certificate used or skipped support
Added new parameter "A" in wifi connect command to support
CA certificate used or CA certificate skipped for
EAP-TTLS-MSCHAPV2 and EAP-PEAP-MSCHAPV2.

Signed-off-by: Qingling Wu <qingling.wu@nxp.com>
2025-02-11 15:38:58 +01:00
Lingao Meng
f5bd2170d1 tests: bsim: Add testcase for bluetooth mesh extended advertiser
Add some configuration for test adv_ext.c

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2025-02-11 15:38:35 +01:00
Lingao Meng
2ebdcfa963 Bluetooth: Mesh: Remove START_PENDING flags
Remove START_PENDING flag, and replace with
bt_mesh_adv_is_empty_by_tag

not only make adv_ext.c more readable, but also enhancement

In previous implementation, after proxy started, will check
this flag, and when the flag is true, will direct stop proxy
and re-enter schedule, but has one problem, this flag set true,
but buf will be empty, such as when sending mesh relay messages
will for-each every sets, until find not-active, but also set
previous set START_PENDING flags, so will cause proxy advertising
started->stop->started.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2025-02-11 15:38:35 +01:00
Lingao Meng
bcac572ab4 Bluetooth: Mesh: Remove ADV_FLAG_PROXY_START, due to meanless
The first why introduce ADV_FLAG_PROXY_START
see here(https://github.com/zephyrproject-rtos/zephyr/pull/58826)

The main core change is to mark ADV_FLAG_PROXY as moving to the last
enabled proxy instead of before.

But introducing the ADV_FLAG_PROXY_START flag seems meaningless.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2025-02-11 15:38:35 +01:00
Jakub Witowski
05ab017774 net: coap: fix uninitialized usage of option struct
option struct was uninitialized in insert_option() function
during encode_options() call when the while loop wasn't
executed before.

Signed-off-by: Jakub Witowski <jakub.witowski9302@gmail.com>
2025-02-11 11:45:05 +00:00
Jakub Witowski
828f5e8b23 net: coap: fix uninitialized usage of hdr_len
The hdr_len was uninitialized when none of if-else
conditions were met in decode_delta() function.

Signed-off-by: Jakub Witowski <jakub.witowski9302@gmail.com>
2025-02-11 11:45:05 +00:00
Rene Beckmann
cc33491265 net: mqtt-sn: Wait for register & subscribe to complete
From the MQTT-SN spec:

6.5 Topic Name Registration Procedure

...
At any point in time a client may have only one
REGISTER message outstanding, i.e. it has to wait
for a REGACK message before it can register another
topic name.
...

6.9 Client’s Topic Subscribe/Un-subscribe Procedure

...
As for the REGISTER procedure, a client may have only
one SUBSCRIBE or one UNSUBCRIBE transaction open at a time.
...

Until now, the library did not comply with these requirements.
An additional "waiting" state for topics was introduced:
REGISTER, SUBSCRIBE and UNSUBSCRIBE as an extra step before
switching to REGISTERING, SUBSCRIBING and UNSUBSCRIBING. The
library now makes sure that only one topic can be REGISTERING
and only one topic can be in either SUBSCRIBING or UNSUBSCRIBING.
Additionally, requesting to UNSUBSCRIBE is now denied if the topic
is not yet SUBSCRIBED, to avoid weird race conditions.

Also, added two tests that verify this behavior.

This fixes #84644

Signed-off-by: Rene Beckmann <rene.bckmnn@gmail.com>
2025-02-11 11:44:52 +00:00
Rene Beckmann
b7c404738f net: mqtt-sn: Add comments
Add some comments to static functions and variables.

Signed-off-by: Rene Beckmann <rene.bckmnn@gmail.com>
2025-02-11 11:44:52 +00:00
Rene Beckmann
91f99fcec5 net: mqtt-sn: Rename internal 'find' functions
Add word 'by' to function names to clarify which is the thing that
is found and which is the thing that is searched for. For example,
mqtt_sn_topic_find_name was renamed to mqtt_sn_topic_find_by_name
because the function does not find the name but finds a topic by
its name.

Signed-off-by: Rene Beckmann <rene.bckmnn@gmail.com>
2025-02-11 11:44:52 +00:00
Robert Lubos
9a00bc69b7 net: http_client: Ignore message body on 101 Switching Protocols reply
When HTTP 101 Switching Protocols response is received, force the HTTP
parser to ignore any potential message body payload (which should
already belong to the new protocol).

This is usually not an issue, as Switching Protocols reply should
contain headers only, however it's been observed that some servers
specify chunked transfer-encoding header which tricks the parser
to wait for payload event though it never arrives.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-02-11 10:11:41 +01:00
Guennadi Liakhovetski
a2a587ae20 llext: fix symbol exporting for ET_REL
When building relocatable extensions, exported symbol names might end
up in a separate section (in my case ".rodata.str1.1") for which
storage address don't match section address. To access those names
addresses have to be relalculated.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2025-02-11 10:11:31 +01:00
Tom Hughes
8218bf6b0a Bluetooth: TBS: Fix -Wsometimes-uninitialized warning
Building bluetooth.shell.audio.only_gtbs with clang warns:

subsys/bluetooth/audio/tbs.c:1646:6: error: variable 'ret' is used
uninitialized whenever 'if' condition is false
[-Werror,-Wsometimes-uninitialized]
        if (param->gtbs) {
            ^~~~~~~~~~~
subsys/bluetooth/audio/tbs.c:1667:9: note: uninitialized use occurs here
        return ret;
               ^~~
subsys/bluetooth/audio/tbs.c:1646:2: note: remove the 'if' if its
condition is always true
        if (param->gtbs) {
        ^~~~~~~~~~~~~~~~~
subsys/bluetooth/audio/tbs.c:1626:9: note: initialize the variable 'ret'
to silence this warning
        int ret;
               ^
                = 0

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-02-11 03:07:39 +01:00
Emil Gydesen
9fca7ee3a5 Bluetooth: Controller: Fix casting in radio_aa_set for BASE0
We have previously fixed an issue with shifting and
assigning the value without a cast, but coverity
is still complaining about aa[1] and aa[0] with:

"Casting narrower unsigned aa[1] to wider signed type
int effectively tests its lower bound."

Using the common function, sys_get_le24, should fix this issue.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-11 03:07:27 +01:00
Pavel Vasilyev
b7f16f1041 bluetooth: mesh: delayable_msg: cast to avoid truncation issue
Explicitly cast Kconfig option value to avoid truncation issue reported
by Coverity.

Fixes #84697
Coverity-CID: 487737

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-02-10 22:26:31 +01:00
Pavel Vasilyev
038173acda bluetooth: mesh: proxy_msg: check that att mtu is big enough
This commit checks that ATT MTU value returned by `bt_gatt_get_mtu` is
greater or equal to 3 to prevent integer overflow.

Fixes #84693
Coverity-CID: 487743

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-02-10 22:26:31 +01:00
Pavel Vasilyev
fcf09dd0ad bluetooth: mesh: pb_adv: ensure that bitwise NOT doesn't result in 0
Ensure that ~(link.rx.seg) & SEG_NVAL doesn't result in 0.

Fixes #84804
Coverity-CID: 393090

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-02-10 22:26:31 +01:00
Emil Gydesen
446ad0948d Bluetooth: PACS: Test and fix PACS Kconfig combinations
Add unit tests for all possible PACS combinations and
fix issues found.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-10 22:25:47 +01:00
Emil Gydesen
e7b6fd0b4b Bluetooth: PACS: Fix several issues with pacs_register
Fixed the following issues:
1) Missing guard before accessing parameters
2) Fixed bad sizeof when resetting
3) Fixed several bad offsets when removing attributes

Added tests to verify that it works now.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-10 22:25:47 +01:00
Jamie McCrae
0e8cc3e52d dfu: Add support for new MCUboot swap using offset mode
Allows using this newly introduced MCUboot algorithm

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-02-10 19:05:25 +01:00
Jamie McCrae
6d35cc5e85 kconfig: Add new Kconfig for MCUboot swap using move
Adds a new Kconfig for selecting swap using move in MCUboot which
aligns with the proper MCUboot symbol and allows for adding
additional mode Kconfigs

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-02-10 19:05:25 +01:00
Emil Gydesen
09fb5338f8 Bluetooth: ATT: Disconnect ATT and ACL when receiving inval rsp
When we receive a response from a server we do not have an
outstanding request with, we disconnect the connection
rather than just ignoring it.

The reason for this is that the remote server is
not ensuring correct ATT flow control, which means
that we cannot trust future responses from the
server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-10 15:56:34 +00:00
alperen sener
22de0b3732 bluetooth: host/crypto: fix the psa crypto init for host
psa_crypto_init was bounded to CONFIG_BT_HOST_CRYPTO_PRNG and
used to be called under prng_init. Updating the ifdef condition
and appropriating the function name for crypto init.

Also it is better to make sure psa_crypto_init called by host.

Signed-off-by: alperen sener <alperen.sener@nordicsemi.no>
2025-02-10 14:33:24 +01:00