Commit graph

19201 commits

Author SHA1 Message Date
Rubin Gerritsen
c3dd1e8a74 Bluetooth: Host: Fix bt_disable() for IPC giving HCI Reset timeout
Some HCI drivers issue HCI reset when disabling, like the IPC HCI
driver. We need to keep the RX thread running to allow receiving
the command complete.

This commit postpones aborting the RX thread until this is done.
The issue happens started occuring after commit
d0e75ab87c4b53d66008c941c38709a2fca9dbea.

Fixes #76202.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-07-25 09:14:39 +02:00
Joakim Andersson
276850ca02 testsuite: Remove reference to deprecated ztest API
Remove reference to deprecated ztest_test_suite function from API
description.

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
2024-07-23 09:14:04 +02:00
Flavio Ceolin
f9de58efb9 pm: Do not select deprecated symbol
PM_DEVICE_RUNTIME_EXCLUSIVE was deprecated and its behavior
is achived with PM_DEVICE_SYSTEM_MANAGED=n.

Fixes #76037

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-07-22 03:28:54 -04:00
Luis Ubieda
7d9ff8bcb4 rtio: workq: Initialize Work item before using it
As the items come from the memory slab, their initialization state
can't be guaranteed. This is causing some devices triggering an assert
in p4wq where the item's thread is not null (not zero).

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-07-13 10:27:58 -04:00
Jonathan Rico
792ae68165 Bluetooth: host: Use correct user_data size for hci_rx_pool
`struct acl_data` is used even when Host flow control is not enabled.
It is written to through the `acl(buf)` accessor in `conn.c:hci_acl()`.

Hopefully no netbufs were harmed by that :/

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-07-13 10:25:31 -04:00
Pisit Sawangvonganan
10f495e0fd net: lib: fix typo
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within the `subsys/net/lib` directory.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-07-12 09:33:20 -04:00
Pisit Sawangvonganan
d2af60687e net: l2: fix typo
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within the `subsys/net/l2` directory.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-07-12 09:33:20 -04:00
Pisit Sawangvonganan
d1781da2ba net: lwm2m: fix typo
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within the `subsys/net/lib/lwm2m` directory.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-07-12 09:33:20 -04:00
Johann Fischer
108c52c244 usb: device_next: fix typo in property name
Use rx-fifo-size to set RX ringbuffer size.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-07-12 09:13:13 -04:00
Emil Gydesen
1751a7f190 Bluetooth: TBS: Add missing documentation in tbs.h
Add missing documentation for some defintions in tbs.h
Moved some internal definitions to tbs_internal.h

Removed invalid TBS technology BT_TBS_TECHNOLOGY_IP that
doesn't exist.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-12 06:24:39 -04:00
Krzysztof Chruściński
67403ed73d logging: Do not strip strings when LOG_OUTPUT is used
When CONFIG_LOG_OUTPUT is enabled that indicates that logging
strings are used by the runtime logging processing so they should
not be stripped from the binary.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-07-12 06:23:09 -04:00
Anas Nashif
1e20f58c17 ztest: doc: fix doxygen for ztest
Many ztest macros were not indexed correctly as part of the ztest_test
group, for example ZTEST_SUITE was completely missing in the
documentation.

In addition, document a few macros that did not have any documentation.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-07-11 18:58:45 -04:00
Rubin Gerritsen
85eadcfddc Bluetooth: Mark bt_<type>_err_to_str() APIs experimental
It was pointed out in a future PR that they should have
a corresponding experimental Kconfig entry.

See PR #73795.

This updates the APIs added in PR #73826 and PR #74295.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-07-11 13:11:59 -04:00
Robert Lubos
5251533f97 net: lib: http_server: Respect Connection close header
In case no "Connection: close" header is present in the request, the
server should keep the connection open for the client. Hence, after
serving a request, we need to check if the header was present (the
parser sets a flag for it), and only close the connection immediately,
if the client requested it. In case the client remains silent, the
connection will be closed anyway after the inactivity timer kicks in.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-11 13:11:04 -04:00
Robert Lubos
94b1f443ac net: sockets: Allocate FD after receiving connection in accept()
Allocating FD before pulling the new connection from the fifo can lead
to busy looping in certain cases. If the application keeps calling
accept() on a listening socket after failing to allocate new FD for the
incoming connection, it'll start busy looping, as will report POLLIN in
such case (as the new connection is still on the queue), but it'll
consistently fail with ENFILE.

This can be avoided by trying to allocate new file descriptor only after
new connection has been pulled from the fifo. That way, if we fail to
allocate the file descriptor, the incoming connection will be dropped,
which seems correct given we don't have enough resources to service it.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-11 13:11:04 -04:00
Robert Lubos
0e601d4103 net: lib: http_server: Add restart delay
In case there were active connections when restarting the server, it
can't be re-initialized immediately, as binding to the server port will
fail. We need to wait for the TCP connection teardown, as even with
REUSEADDR socket option set, binding will fail if the sockets are not in
TCP TIMED_WAIT state (i. e. connections are active).

Because of this, add a configurable delay when restarting the server.
Additionally, make server initialization failures non-fatal, i. e. try
to restart the server again after the delay if the initialization fails.
It's been observed with Chromium, that it tends to keep connections open
even after closing them on the server side (socket lingers in FIN_WAIT_2
state), so the server re-initialization may fail even with delay, so
it's beneficial in  such case to keep retrying the server
re-initialization.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-11 13:11:04 -04:00
Robert Lubos
fc10a94683 net: lib: http_server: Close sockets on server core errors
In case of fatal errors (during poll() or when handling listening
socket), the server operation is restarted. It was missed however, that
sockets opened for the server should be closed in such case.

Additionally, in case there were active client connections, it's needed
to cleanup related resources, otherwise running timers may trigger a
crash.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-11 13:11:04 -04:00
Robert Lubos
be7175351a net: lib: http_server: Fix HTTP1 POST request handling
In previous batch of fixes it was overlooked that streams are
HTTP2-specific concept. While for HTTP2 we need to track headers reply
state for each individual stream, at HTTP1 level we need to track this
at the client level. Hence, reintroduce respective flags to track
headers reply state, but only for HTTP1.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-11 13:10:09 -04:00
Luca Burelli
f257c997b5 doc: llext: improve Doxygen comments
Review and improve comments in source code to better describe the API
and the functionality provided by the llext library.

No actual code changes are performed in this commit.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-07-11 16:17:52 +02:00
Dmitrii Golovanov
5d80e253b7 ztest: shell: Fix memory leaks processing test arguments
Fix Ztest shell memory leaks when it process test arguments.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-07-11 16:16:28 +02:00
Mark Wang
64f38fc348 Bluetooth: A2DP: Fix mistake parameter
After configuration, the stream instance is valid and stream's
local_ep valid. bt_a2dp_stream_establish's parameter is stream
too. So in bt_a2dp_stream_establish, stream->local_ep should be
used to tell lower level (AVDTP) the sep.
set_config_param is used by copy-paste mistake.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2024-07-11 16:16:09 +02:00
Lyle Zhu
f3a1cf2782 Bluetooth: SDP: Fix stack override issue
Check the remaining space of the local variable
`filter` to avoid stack override issue.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-07-11 16:15:53 +02:00
Chris Friedt
3b54d2b4b9 fs: fcb: rename variables differently than struct tag
Even just making minor edits to fcb, warnings are triggered
from Coding Guidelines of the form

Violation to rule 5.7 (Tag name should be unique) tag: fcb

Rename pointer variable names to fcbp.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-07-11 16:14:55 +02:00
Emil Gydesen
c4840462bf Bluetooth: BAP: Scan delegator: Add log if actionable CBs are not set
If the callbacks are not set, then we cannot do the requested actions
from the broadcast assistant. Since this is a significant issue,
that may prevent the role from working as intended,
LOG_WRN is used other LOG_DBG.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-11 16:13:55 +02:00
Emil Gydesen
2761204957 Bluetooth: BAP: Fix notifying recv state for bonded devices
The scan_delegator_security_changed function had a few issues
that were addressed:
1) It used an internal field to check level rather than the
   value provided by the API
2) It did not treat bt_addr_le_is_bonded as a boolean return value
3) It did not properly truncate the recv state (fixed by using the
   proper function bass_notify_receive_state)

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-11 12:40:21 +02:00
Jamie McCrae
0d6532d27c mgmt: mcumgr: smp: Initialise variable
Seemingly newer versions of gcc wrongly detect a variable is used
when it is not set, this is not the case the compiler is wrong,
add a default set to null to prevent the fake warning appearing
as an error in CI

Signed-off-by: Jamie McCrae <spam@helper3000.net>
2024-07-11 12:39:33 +02:00
Jamie McCrae
f516ee1639 mgmt: mcumgr: transport: Fix SMP header not being packed
Fixes an issue with using SMP on devices that do not support
unaligned memory access e.g. Cortex M0 which would result in a
hard fault

Signed-off-by: Jamie McCrae <spam@helper3000.net>
2024-07-11 12:39:33 +02:00
Jamie McCrae
c769a647fa mgmt: mcumgr: transport: bluetooth: Fix dynamic registration option
Fixes the Kconfig for dynamic service registration to make it depend
on dynamic database support instead of selecting it, which prevents
issues whereby it is not actually selected

Signed-off-by: Jamie McCrae <spam@helper3000.net>
2024-07-11 09:36:14 +02:00
Jonathan Rico
4afe745a1d Bluetooth: host: Add lower bound for CONFIG_BT_BUF_ACL_RX_COUNT
See comment above assert for more.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-07-10 11:47:26 -04:00
Jukka Rissanen
794d7cf3c5 net: sockets: Remove async service support
As found in PR #75525, we should not modify the polled fd array
in multiple places. Because of this fix, the async version of
the socket service could start to trigger while it is being handled
by the async handler. This basically means that the async version
cannot work as intended so remove its support.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-07-10 11:36:59 +02:00
Fin Maaß
f82249c932 net: ethernet: check vlan iface existence
Drop a packet, if it has a VLAN tag, for
that we don't have a VLAN interface.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-07-10 11:35:46 +02:00
Luis Ubieda
3646b63217 rtio: Add RTIO Work-queues service
Adds ability to process synchronous requests in an asynchronous
fashion, relying on dedicated P4WQ's and pre-allocated work items.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-07-09 17:21:05 -04:00
Robert Lubos
9db2dc4aa2 net: lib: http_server: Move stream-specific flags to stream context
The information about replied headers or END_OF_STREAM flag are
stream-specific and not general for a client. Hence, need to move them
to the stream context.

For the upgrade case, we need to allocate a new stream now when HTTP1
request /w upgrade field is received. The stream ID in such case is
assumed to be 1 according to RFC.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-09 15:20:57 -04:00
Robert Lubos
0e1c0a7b6b net: lib: http_server: Fix trailing headers frame processing
In case client decides to send a trailing headers frame, the last data
frame will not carry END_STREAM flag. In result, with current logic
server would not include END_STREAM flag either, causing the connection
to stall. This commit fixes this logic, so that the server replies
accordingly in case END_STREAM flag is present in the trailing headers
frame.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-09 15:20:57 -04:00
Robert Lubos
b4cfee090d net: lib: http_server: Implement proper CONTINUATION frame processing
CONTINUATION frames are tricky, because individual header fields can be
split between HEADERS frame and CONTINUATION frame, or two CONTINUATION
frames. Therefore, some extra logic is needed when header parsing
returns -EAGAIN, as we may need to remove the CONTINUATION frame header
from the stream before proceeding with headers parsing.

This commit implements the above logic and additionally adds more checks
to detect when CONTINUATION frame is expected. Not receiving a
CONTINUATION frame when expect should be treated as a protocol error.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-09 15:20:57 -04:00
Robert Lubos
7e22dd45a0 net: lib: http_server: Fix frame printouts
Frame printouts should not be done from the state handlers, but rather
during state transition, otherwise a single frame can be printed several
times as new data arrive. This also simplifies code a bit, as we just
print the frame in a single place, instead of duplicating code.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-09 15:20:57 -04:00
Robert Lubos
78c2f48091 net: lib: http_server: Remove upper bounds on buffer sizes
There's really no good reason to have an upper bound on the buffer sizes
and this limits testing in some cases, so just remove them.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-09 15:20:57 -04:00
Robert Lubos
ccf2e9b025 net: lib: http_server: Implement proper RST_STREAM frame processing
In case RST_STREAM frame is received it should not be ignored, but the
corresponding stream should be closed.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-09 15:20:57 -04:00
Robert Lubos
b98edfd951 net: lib: http_server: Fix parsing of HTTP2 header frames with priority
In case priority flag is present in the HTTP2 headers frame header, we
should expect additional priority fields before the actual frame
content.

The stream priority signalling has been deprecated by RFC 9113, however
we should still be able to handle this in case some implementation
(nghttp for instance) sends them.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-09 15:20:57 -04:00
Robert Lubos
2e288aed08 net: lib: http_server: Fix handling of HTTP2 frames with padding
Data and header frames can contain padding - we need to take this into
account when parsing them, otherwise the stream is broken.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-09 15:20:57 -04:00
Robert Lubos
245b8351f4 net: lib: http_server: Unify HTTP2 header flags checking
Instead of multiplying function to check header flags, just have a
single one, with flag mask as parameter.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-09 15:20:57 -04:00
Robert Lubos
adfdc54434 net: lib: http_server: Update HTTP2-specific structs/enums naming
For HTTP2-specific structures and enums, use "http2_" prefix to clearly
indicate the distinction from the generic HTTP stuff.

Additionally, some structures/enums describing HTTP2 protocol details
had "server" in the name, while in reality they describe nothing
server-specific. Hence, drop the "server" part where applicable.

Remove unused macros.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-09 15:20:57 -04:00
Robert Lubos
e1e50bdda9 net: lib: http_server: Simplify HTTP2 frame header parsing
* Remove unneeded variable.
* Use system utilities to read big endian numbers instead of parsing
  manually.
* Remove `payload` member from the http_frame structure. It's not used
  for anything useful, and could actually be misleading, as in case of
  large frames, where not entire frame is parsed at once it will point
  to incorrect location.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-09 15:20:57 -04:00
Chaitanya Tata
a63a96428e wifi_nm: Fix Wi-Fi interface backward compatibility
If newly introduced interface type is unset then return the first Wi-Fi
interface as a fallback, this fixes backward compatibility.

Also, add NM APIs and use them for type checks, rather than directly
using the type enumeration.

Fixes #75332.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-07-09 13:07:11 -04:00
Emil Gydesen
bbf599a3de Bluetooth: TBS: Remove BT_TBS_TECHNOLOGY_IP
BT_TBS_TECHNOLOGY_IP is not a valid technology value
for TBS since it's not defined by the spec.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-07-09 19:06:29 +02:00
Luca Burelli
3cc452c92f llext: consistently use "regions" for memory areas
The term "section" has a very specific meaning in the ELF file format.
After 709b2e4 ("llext: automatically merge sections by type"), some of
the code that was originally dealing with ELF sections is now handling
"memory regions" made of multiple ELF sections of the same type.

Make sure to use the term "region" consistently in the code and
log messages to avoid confusion with the original ELF sections.

Notable exception to this is the "ldr->sect" array, which is actively
used outside Zephyr and will need to be phased out in the future.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-07-09 19:04:06 +02:00
Luca Burelli
2e085ba29a llext: harmonize error codes
This patch changes the error codes returned by the ELF subsystem to be
more consistent with the standard error descriptions. In particular:

- issues with the ELF file are now reported as -ENOEXEC;
- valid but unsupported edge cases are reported as -ENOTSUP;
- failures in searching for an entry are reported as -ENOENT.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-07-09 19:04:06 +02:00
Luca Burelli
9450240419 llext: fix table count check
llext_load() included a check to ensure that the ELF file contains all
the necessary tables, but it was not functional. Add the missing check
and rename the variable to avoid confusion with the total section count.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-07-09 19:04:06 +02:00
Pisit Sawangvonganan
9b2ab20f23 bluetooth: fix typo in (include/zephyr/bluetooth, subsys/bluetooth/)
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within the `include/zephyr/bluetooth` and `subsys/bluetooth`

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-07-09 17:20:38 +02:00
Robert Lubos
e5d67adf80 net: sockets: services: Don't modify pollfd array from other threads
pollfd array used with zsock_poll() should not be modified while inside
zsock_poll() function as this could lead to unexpected results. For
instance, k_poll already monitoring some kernel primitive could report
an event, but it will not be processed if the monitored socket file
descriptor in the pollfd array was set to -1. In result,
zsock_poll() may unexpectedly quit prematurely, returning 0 events, even
if it was requested to wait infinitely.

The pollfd arrays used by zsock_poll() (ctx.events) is reinitialized
when the service thread is restarted so modifying it directly when
registering/unregistering service is not really needed. It's enough if
those functions notify the eventfd socket used to restart the services
thread.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-07-09 17:19:12 +02:00