Commit graph

21541 commits

Author SHA1 Message Date
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
Andrey Dodonov
a4123a8ea2 net: lib: websocket: call socket poll for websocket
If we couldn't send all (or any data) via the socket,
invoke poll instead of blindly retrying and flooding the socket

Signed-off-by: Andrey Dodonov <Andrey.Dodonov@endress.com>
2024-07-09 14:04:29 +02:00
Andrey Dodonov
15ead53ad9 net: lib: http: call socket poll for http_client send
If we couldn't send all (or any data) via the socket,
invoke poll instead of blindly retrying and flooding the socket.
Respect timeout through http_client_req

Signed-off-by: Andrey Dodonov <Andrey.Dodonov@endress.com>
2024-07-09 14:04:29 +02:00
Pieter De Gendt
9d8881816e zbus: Use section iterator for observations
Iterating the observations can be simplified to a struct iterator instead
of first getting the count and looping afterwards.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-07-09 14:03:33 +02:00
Pieter De Gendt
990c5e13cb zbus: Static channel data initialization
Init the channel data semaphore and observer list statically.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-07-09 14:03:33 +02:00
Zihao Gao
6ebb65d163 Bluetooth: fix compiling issue when either A2DP SRC or SNK are not enabled
Some of the A2DP interfaces are not defined if the corresponding feature
is not enabled, and therefore shall not be initialized.
This patchs include the interfaces/variables by the configurations to
go through the compiling stage.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2024-07-09 14:03:07 +02:00
Krzysztof Chruściński
347eeababf logging: Fix runtime filtering when frontend and userspace is used
When userspace is used and frontend was used for logging then runtime
filtering was failing because in user context filtering data was
accessed and filtering data is in the kernel space. Fixing that and
adding runtime filtering to the pre frontend function which is
already executed in the kernel space and filter data can be
accessed.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-07-09 14:01:56 +02:00
Krzysztof Chruściński
8ed29a625a logging: Fix UART dictionary frontend configuration
Logging string stripping depends on LOG_DICTIONARY_SUPPORT being
enabled and it was not set in UART dictionary frontend.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-07-09 14:01:56 +02:00
Krzysztof Chruściński
9876075de1 logging: Allow runtime filtering for frontend only case
Log frontend supports runtime filtering so it should be
allowed to enable it even when only frontend is used with
no backends.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-07-09 14:01:56 +02:00
Luca Burelli
5ce6a750a5 llext: add explicit cast to fix Coverity CID: 392507
From https://mails.dpdk.org/archives/dev/2021-December/231212.html:

    Downcasting a void* to struct aesni_gcm_session* caused the session
    data to be treated as tainted. Removing the void* temporary variable
    and adding a cast avoids this issue.

Try the same approach here to prevent the ldr->sect_hdrs pointer from
being treated as tainted.

May fix #74817.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-07-09 11:51:29 +02:00
Benjamin Bigler
1db356e35c net: mgmt: Fix build error when event direct enabled without event info
If CONFIG_NET_MGMT_EVENT_DIRECT is enabled and CONFIG_NET_MGMT_EVENT_INFO
disabled it does not build because mgmt_push_event writes to non existing
struct members

Signed-off-by: Benjamin Bigler <benjamin.bigler@securiton.ch>
2024-07-09 11:49:47 +02:00