Commit graph

21541 commits

Author SHA1 Message Date
Ingar Kulbrandstad
b32eb0d2b2 Bluetooth: Mesh: Fix out of bounds write
Fix of the subnet bridging table function to only
compact the table if elements has been removed, and
fixing the compact function to compact the table if
several elemnts has been removed at the same time.

Fixes zephyrproject-rtos#78794

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2024-10-08 18:09:57 -04:00
Johann Fischer
47c8815253 modbus: fix support for floating point values
The Modbus protocol object types are either single-bit or 16-bit word.
Other types are not defined in the specification. Types such as float
are typically mapped to two 16-bit registers. Current implementaiton
does not maps correctly to the 16-bit word addresses. On the client
side, the implementation must take into account that the number of
requested registers (Quantity of Registers) is double that of a "float"
register.  The server side should not treat "Quantity of Registers" and
"Byte count" differently for addresses reserved for floating values,
only in the user callback the two 16-bit registers are mapped to a float
value but still aligned to 16-bit register addresses.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-10-08 17:01:19 +02:00
Robert Lubos
c6498bb68d net: ipv6: Make Multicast Listener Discovery API public
IPv6 MLD API was so far defined in an internal header. This does not
seem correct though, as application code should be able to join/leave
multicast groups, hence the API should be exposed in a public header,
just as it is done for its IPv4 countepart - IGMP.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-10-08 17:00:06 +02:00
Robert Lubos
c6cc87c526 log: net: Fix build warning with IPv6 disabled
Building the net logger backend with IPv4 only gives the following
warning:

log_backend_net.c:116:31: warning: array subscript 'struct sockaddr[0]'
is partly outside array bounds of 'struct sockaddr_in[1]'
[-Warray-bounds] local_addr->sa_family = server_addr.sa_family;

hence assign the address family directly to sockaddr_in/6 structs.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-10-08 16:58:20 +02:00
Robert Lubos
5c6b003554 net: dns: dispatcher: Don't use uninitialized entries
In case CONFIG_DNS_RESOLVER_MAX_SERVERS is larger than the actual number
of DNS servers configured, some server entries may be left
uninitialized. The dispatcher needs to take this into account, otherwise
it may cause memory corruptions.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-10-08 16:58:20 +02:00
Emil Gydesen
b2e61ef355 Bluetooth: BAP: Fix bad check in bt_audio_valid_qos_pref
The checks did not properly take into account
that the pref_pd_min and pref_pd_max could have valid
0 values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-10-08 16:58:09 +02:00
Krzysztof Chruściński
8fc0aba4ae logging: Add log_source_id helper function
There are many places where source_id is retrieved and it
depends on runtime filtering being enabled. So far it was
all exposed but lets encapsulate that into a helper function.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-10-08 16:57:59 +02:00
Pisit Sawangvonganan
88374b0738 fs: nvs: streamline rc return logic
Streamline the `rc` return logic in `nvs_flash_wrt_entry()`, `nvs_gc()`
by directly returning `rc`, as the redundant conditional check and
explicit return of 0 were unnecessary.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-10-08 16:57:49 +02:00
Aleksander Wasaznik
8cfad44852 Bluetooth: Deprecate adv auto-resume
The host-based adv auto-resume function has both a problematic
implementation and disagreement in the community around how it should
behave. See the issue linked resolved below for details.

This patch makes the deprecation visible to the user. The user will be
better served by a auto-resume tailored their applications use case,
based on more primitive host API like `conn_cb.recycled`, which has
obvious behavior that is unlikely to change.

Resolves: https://github.com/zephyrproject-rtos/zephyr/issues/72567

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-10-08 16:57:01 +02:00
Adrian Friedli
98289e594d net: lib: coap: make ACK random factor runtime configurable
Extend the `coap_transmission_parameters` struct with the field
`ack_random_percent`. This was the last remaining CoAP transmission
parameter that was not configurable at runtime.

Signed-off-by: Adrian Friedli <adrian.friedli@husqvarnagroup.com>
2024-10-08 06:00:56 -04:00
Firas Sammoura
6f072ba774 Ztest: Including the missing C standard library header
The ztest.c calls atoi, which is provided by the C standard library.
Remove the conditional inclusion of the C standard library with the
definition of CONFIG_ZTEST_SHUFFLE.

Signed-off-by: Firas Sammoura <fsammoura@google.com>
2024-10-08 06:00:45 -04:00
Benedek Kupper
a6b911f195 usb: device_next: USB reset clears remote wakeup permission
Verbatim from USB 2.0 specification:
The Remote Wakeup field indicates whether the device is currently enabled
to request remote wakeup. The default mode for devices that support
remote wakeup is disabled. If D1 is reset to zero, the ability of the
device to signal remote wakeup is disabled. If D1 is set to one,
the ability of the device to signal remote wakeup is enabled.
The Remote Wakeup field can be modified by the SetFeature() and
ClearFeature() requests using the DEVICE_REMOTE_WAKEUP feature selector.
This field is reset to zero when the device is reset.

Signed-off-by: Benedek Kupper <kupper.benedek@gmail.com>
2024-10-08 05:59:29 -04:00
Paul He
c2911af78e fs: littlefs: get block_cycles value from dts
Property "block-cycles" is required for node "zephyr,fstab,littlefs",
but source code did not get the value from dts file, now add it.

Additionally correct the wrong description of property "block-cycles"
in binding file.

Signed-off-by: Paul He <pawpawhe@gmail.com>
2024-10-07 18:43:05 +02:00
Gerard Marull-Paretas
b2031aa20d bluetooth: controller: ll_sw: nordic: align to nrfx 3.7.0
Some enums have been renamed:

- NRF_CCM_EVENT_ENDCRYPT -> NRF_CCM_EVENT_END
- NRF_CCM_TASK_CRYPT -> NRF_CCM_TASK_START

Also adjust some TX power level settings (26/28dBm not always available
depending on the SoC revision).

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2024-10-07 18:42:14 +02:00
Abram Early
583f4956dc modbus: reset wait semaphore before tx
A response returned after a request times out would increment the
semaphore and stay until the next request is made which will immediately
return when k_sem_take is called even before a response is returned. This
will once again have the same problem when the actual response arrives.
So the wait semaphore just needs to be reset before transmitting.

Signed-off-by: Abram Early <abram.early@gmail.com>
2024-10-07 17:12:44 +01:00
Chaitanya Tata
1da74ef705 net: wifi: Fix DPP disabled build
In case WPA supplicant disabled DPP, we need to compile out the
corresponding DPP code in Wi-Fi shell too.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-10-07 17:12:16 +01:00
Xudong Zheng
e8c4867806 usb: cdc_acm: disable logging if used for shell with logging
This prevents recursive logging loop when USB CDC ACM is used for shell
with logging.

Change affects both USB stacks.

Signed-off-by: Xudong Zheng <7pkvm5aw@slicealias.com>
2024-10-07 17:11:44 +01:00
Vinayak Kariappa Chettimada
c334ed515b Bluetooth: Controller: Fix multiple Extended Adv chain reception
Fix assertion when enabling simultaneous multiple Extended
Advertising chain reception that is enabled by increasing
supported auxiliary scan contexts.

ULL sets the association of aux context to scan and sync
context, and LLL resets the association; this is safer
compared to earlier implementation where ULL did both the
association and reset which caused aux context memory
leak.

Supported auxiliary scan contexts can be increased using
CONFIG_BT_CTLR_SCAN_AUX_SET value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-10-07 13:39:53 +02:00
Tomi Fontanilles
bf0e6d7c83 secure_storage: introduce the secure storage subsystem
Implements RFC https://github.com/zephyrproject-rtos/zephyr/issues/75275.

See also the PR (https://github.com/zephyrproject-rtos/zephyr/pull/76222)
for more information.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2024-10-07 13:38:43 +02:00
Maureen Helm
d022d315d2 tracing: Fix sysview for soc families not subdivided into series
Fixes the systemview tracing backend for soc families, such as max32,
that don't subdivide into soc series and therefore don't define
CONFIG_SOC_SERIES. Use CONFIG_SOC_FAMILY instead in the system
description since it should always be defined.

Signed-off-by: Maureen Helm <maureen.helm@analog.com>
2024-10-06 20:51:27 +01:00
Rex Chen
82ec1d7862 net: wifi: shell: add wps support
Add wps pin and wps pbc L2 layer cmd support.

Signed-off-by: Rex Chen <rex.chen_1@nxp.com>
2024-10-05 14:07:48 -04:00
Pisit Sawangvonganan
7d1953918a net: wifi: shell: enhance consistency in cmd_wifi_dpp_ap_auth_init
The `cmd_wifi_dpp_ap_auth_init` function was added but is not yet
aligned with others.
This update enhances consistency with the following changes:
- Unified the order of declaration for `opt`, `opt_index`,
  `state`, and `long_options`.
- Wrapped lines in the `long_options` declaration to prevent them
  from extending too far to the right.
- Applied `struct option` as `static const`
- Unified the wrapping of `getopt_long` calls, regardless of
  the length of the `options` string.
- Using `getopt_state` to access `optarg` and also `optopt` offers
  a better alternative to direct global access.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-10-05 14:07:33 -04:00
Lyle Zhu
3756429b6c Bluetooth: BREDR: L2CAP: Recover ident when conn is pending
The `ident` of L2CAP BR connection req will be cleared if
function l2cap_br_conn_req_reply called to send L2CAP BR
connection rsp with result `BT_L2CAP_BR_PENDING`.

Then the invalid `ident` (it is zero) will be filled in
the L2CAP BR connection rsp after the ACL connection is
encrypted.

Recover `ident` if the result of the connection rsp is
`BT_L2CAP_BR_PENDING`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-05 14:07:24 -04:00
Lyle Zhu
c7c1f73045 Bluetooth: SSP: Support security level 4
Currently, error code `-ENOTSUP` will be
returned if start security with security
level 4.

For SC supported case, level 4 for ssp
should be supported.

Remove the code limitation to support
security level 4.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-05 14:07:15 -04:00
Lyle Zhu
7e54f13e7b Bluetooth: l2cap_br: Support Multi-Command Packet
Improve L2CAP BR to handle more than one
signaling command in one receiving L2CAP packet.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-05 14:07:09 -04:00
Lyle Zhu
3561540110 Bluetooth: L2CAP_BR: Set flags in CFG RSP
The flags of L2CAP_CONFIGURATION_REQ are set.
But in L2CAP_CONFIGURATION_RSP, all bits of
flags are cleared.

When used in the L2CAP_CONFIGURATION_RSP
packet, the continuation flag shall be set
to one if the flag is set to one in the
Request.

Copy flags from Request to Response if it
is a successful result.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-05 14:07:00 -04:00
Lyle Zhu
b7ab7c9d45 Bluetooth: L2CAP_BR: Process all defined OPTs
Currently, Only configuration opt MTU is handled.

For opt `Flush timeout`, `QOS`, `Retransmission
and Flow Control`, and `FCS`, response wilt
result `BT_L2CAP_CONF_UNACCEPT`.

For opt `extended flow specification` and
`extended windows size`, response wilt result
`BT_L2CAP_CONF_REJECT`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-05 14:06:55 -04:00
Lyle Zhu
c5648044a8 Bluetooth: L2CAP_BR: incorrect result returned if config opt unsupported
The `BT_L2CAP_CONF_SUCCESS` is returned as result for the config
req with supported opt.

Result `BT_L2CAP_CONF_UNKNOWN_OPT` should be returned for this case.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-05 14:06:55 -04:00
Jukka Rissanen
0515bfff7a net: lib: http-client: Use memcpy() to avoid gcc warning
GCC 12.2.0 can give this warning (version 11.4.0 did not), when
CONFIG_SPEED_OPTIMIZATIONS=y

subsys/net/lib/http/http_client.c: In function 'http_send_data.constprop':
subsys/net/lib/http/http_client.c:114:33: warning: 'strncpy' specified
bound depends on the length of the source argument [-Wstringop-truncation]
  114 |                                 strncpy(send_buf + end_of_send,
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  115 |                                         data + end_of_data,
      |                                         ~~~~~~~~~~~~~~~~~~~
  116 |                                         remaining);
      |                                         ~~~~~~~~~~
subsys/net/lib/http/http_client.c:87:41: note: length computed here
   87 |                         remaining_len = strlen(data + end_of_data);
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~

The code properly checks that we do not overwrite the destination
buffer even if we use the source buffer length to determine how much
to copy. One possible fix is to use memcpy() or strcpy(), I opted
to use memcpy() because it has the length option which feels more
natural.

Fixes #79326

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-10-04 13:24:17 -05:00
Seppo Takalo
8068cb2567 net: lwm2m: Add shell command for listing resources
Add shell command for listing multiple objects, resources
or resource instances.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-10-04 16:35:59 +01:00
Olivier Lesage
9ae2e23d34 bluetooth: host: Update text for BT_CHANNEL_SOUNDING kconfig
Include EXPERIMENTAL tag in the kconfig text and remove the word
"support" to align with other options

Signed-off-by: Olivier Lesage <olivier.lesage@nordicsemi.no>
2024-10-04 16:34:45 +01:00
Olivier Lesage
9e3943d13e bluetooth: host: Add CONFIG_BT_CHANNEL_SOUNDING_TEST
Makes it easier to make sure the CS test code is removed if desired.
It should hopefully allow for a clean split in general.

Signed-off-by: Olivier Lesage <olivier.lesage@nordicsemi.no>
2024-10-04 16:34:45 +01:00
Olivier Lesage
a12b869eac bluetooth: host: Add support for processing CS subevent results
Adds support for:
- LE CS Subevent Result event
- LE CS Test End Complete event

For now, recombination of subevent results with more steps than could
fit within a single HCI event is not supported, and such events
are discarded.

Signed-off-by: Olivier Lesage <olivier.lesage@nordicsemi.no>
2024-10-04 16:34:45 +01:00
Emil Gydesen
dc97bbd35f Bluetooth: Audio: Rename bt_audio_codec_qos -> bt_bap_qos_cfg
The QoS structure is not related to a codec, but rather a
stream, and should thus not use the "Codec" name.

The BAP and ASCS specs refer to the QoS as
"QoS configuration" several places, so it is an obvious
choice for a name.

Since the structure is defined and used by BAP, the prefix
was changed from bt_audio to bt_bap.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-10-04 16:34:22 +01:00
Krzysztof Bartnicki
e1cacb3a18 net: dns: Fix DNS resolver cache invalid find call
The size of the output array for the find call in resolver
is invalid: expected array size while overall memory size
provided. As the latter is bigger there is a high probability
of memory overwrite occurring on the stack.

Signed-off-by: Krzysztof Bartnicki <krzysztof.bartnicki@embevity.com>
2024-10-04 10:50:31 +01:00
Erik Brockhoff
670bd3bed2 Bluetooth: controller: fixing issue re. assert on overlapping conn upd proc
If a connection update (from central) overlaps a peripheral initiated
conneection param request, then central rejects peripheral request
and continues central procedure. This lead to an assert in peripheral
On instant there would not be an rx_node for notification, as this
would have been discarded by the reception of the REJECT.

This fix ensures that once an rx_node has been 'accepted' for retention
it will not be discarded/overwritten by future rx_nodes

The test will trigger the assert without the fix in.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2024-10-04 10:46:06 +01:00
Eric Ackermann
5275d44409 llext: Add RISC-V arch-specific relocations
This commit introduces architecture-specific ELF relocations for RISC-V,
in accordance with the RISC-V PSABI specification:
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc
Also, the necessary compiler configurations for compiling LLEXT
extensions on RISC-V are added, and the llext tests are executed on
RISC-V targets.
Calling llext extensions from user threads in RISC-V is still
unsupported as of this commit.

Signed-off-by: Eric Ackermann <eric.ackermann@cispa.de>
2024-10-03 21:59:42 +01:00
Seppo Takalo
73a3438b82 net: lwm2m: Remove hostname_verify flag from context
Use security mode (PSK or X509) to detect if we should
set the socket option to verify hostname.

PSK security mode cannot verify hostnames as this information
is coming in the certificate, so don't set the options.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-10-03 17:09:32 +01:00
Robert Lubos
0c1550dd9f net: sockets: Remove SET_ERRNO() macro
Macros with flow control are discouraged and generate compliance error,
hence remove it and replace the corresponding code with simple errno
assignments.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-10-03 17:08:29 +01:00
Robert Lubos
bdbf7cc620 net: offload: Do not need to enable TC threads for NET_OFFLOAD
Net offloading doesn't need net TC threads to be enabled as they're used
by the native stack. This fixes build if CONFIG_NET_OFFLOAD is enabled
but native stack is disabled.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-10-03 17:08:29 +01:00
Robert Lubos
2e1d89619f net: Avoid compiling native network stack parts w/o NET_NATIVE
In case NET_NATIVE is disabled, certain network stack components do not
need to be compiled. Otherwise, they could throw errors if
--no-gc-sections compiler options is enabled.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-10-03 17:08:29 +01:00
Robert Lubos
404e9c7b88 net: sockets: Split native IP socket implementation from syscalls
Native IP socket implementation need only be build if native IP stack is
enabled. Therefore, split the native IP sockets from the common socket
syscalls shared across all socket implementations.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-10-03 17:08:29 +01:00
Tommi Rantanen
a5aed04b7e net: lib: coap: Initialize response_truncated
Fix the following compilation warning given when using newlibc:
warning: 'response_truncated' may be used
uninitialized [-Wmaybe-uninitialized]

Issue is not seen with picolibc.

The variable was introduced as part of PR #76257

Signed-off-by: Tommi Rantanen <tommi.rantanen@nordicsemi.no>
2024-10-03 17:08:21 +01:00
Yong Cong Sin
52a202309b zephyr: bulk update to DT_NODE_HAS_STATUS_OKAY
Change instances of:

DT_NODE_HAS_STATUS(<node_id>, okay)

to

DT_NODE_HAS_STATUS_OKAY(<node_id>)

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-10-03 17:06:52 +01:00
Adrien Ricciardi
cd76ab3428 fs: nvs: Simplified the initial loop in calc_free_space()
Replaced the initial loop that computes the initial free space
by a simple formula.

Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com>
2024-10-03 11:41:33 +01:00
Dave Rensberger
c0bb9735d7 net: shell: Make stack size for event_mon_stack configurable
The stack size for the event_mon_stack task may need to be larger than the
default 1024 to avoid crashes. It should be configurable through Kconfig
so that source code doesn't need to be modified to increase it.

Signed-off-by: Dave Rensberger <davidr@beechwoods.com>
2024-10-03 11:40:16 +01:00
Pete Skeggs
715b97397b net: lib: coap: Make use of ZSOCK_MSG_TRUNC configurable
Not all offloaded network stacks support this socket option so
control it using a Kconfig CONFIG_COAP_CLIENT_TRUNCATE_MSGS,
and enable it by default.

Signed-off-by: Pete Skeggs <peter.skeggs@nordicsemi.no>
2024-10-02 15:55:00 +02:00
Lyle Zhu
0ed8866eb6 Bluetooth: host: Kconfig: Correct help of BT_BONDABLE
Correct the `help` of the configuration `BT_BONDABLE`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 15:54:30 +02:00
Lyle Zhu
aaab223574 Bluetooth: SSP: Incorrect bonding status notified
The `bonded` flag of the callback `pairing_complete` is always true,
event if the SSP pairing is non-bondable.

Check the bonding status in SSP complete event instead of in link key
notify event.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 15:54:30 +02:00
Lyle Zhu
a00d5089d5 Bluetooth: shell: Add command conn-bondable
Add command `conn-bondable` to enable/disable the pairing bondable
flag of a specific ACL connection.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-10-02 15:54:30 +02:00