Commit graph

24,075 commits

Author SHA1 Message Date
Krzysztof Chruściński
aaf5bba2a0 shell: Move hexdump printing to shell_utils
In preparation for remote shell support, move hexdump printing to
the shell_utils.c file. Main shell.c file is not compiled for remote
shell client.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-04-29 09:56:21 +02:00
Krzysztof Chruściński
b5c9f03553 shell: Add compile time guards
Do not compile shell_help() implementation if CONFIG_SHELL_HELP=n.
In that case, empty inline function is implemented in the shell
header and it may fail to compile.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-04-29 09:56:21 +02:00
Krzysztof Chruściński
c61dfc6856 shell: backends: dummy: Add RX notification
When input buffer is written, notify the shell. It will wake the
shell thread which will process the input buffer.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2026-04-29 09:56:21 +02:00
Kyra Lengfeld
9f245e68f0 bluetooth: host: enable extended advertising to use spec range of intervals
Core spec defines the range of adv intervals for extended advertising to
0x0020 to 0xFFFFFF, but the code currently only allows up to 0x4000.
This change enables the full range of intervals for extended advertising

Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
2026-04-28 22:07:30 +02:00
Robert Lubos
095f064c94 net: ipv6: Fix ND packets validation on input
The checks validating RA, NS and NA packets content on input were not
correct - packets should be dropped in case any of those checks failed,
however current logic was invalid, causing other checks to be ignored as
long as the ICMPv6 code was correct (i. e. 0).

Apart from fixing the logic, split the single convoluted if condition
into separate if checks for better readability.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-04-28 17:53:24 +02:00
Johann Fischer
babe3f55ab usb: device_next: return EBUSY instead of ALREADY if USB device is enabled
Replace EALREADY return values of the functions that modify or set USB
device attributes to EBUSY. EBUSY seems to be more appropriate for the
case when a user tries to change the attributes of an operational
device.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2026-04-28 15:25:22 +02:00
Lyle Zhu
cd8c5ccd76 bluetooth: host: goep: Set MTU to configured maximum large
Remove the logic that silently clamps the MTU to valid ranges and
instead return an error if the configured MTU is below the minimum
required size.

The MTU is now always set to the maximum value that the configuration
can support, rather than conditionally using a default only when
set to 0.

Change log level from WRN to ERR for the minimum MTU check since
this now represents a fatal configuration error.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2026-04-28 15:23:28 +02:00
Emil Gydesen
531837b499 Bluetooth: ISO: Improve validate_send for conn state
ISO connections basically have 2 connection states:
1 for the `bt_iso_chan`, and one for the underlying
`bt_conn`. Due to how hci_disconn_complete_prio works,
these may be out of sync while disconnecting, and
bt_iso_chan_send could return 0 after we have received
a disconnect event from the controller. In this case
the number of pending SDUs in the host for the ISO
channel could be non-0, which could cause issues.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-28 15:21:19 +02:00
Sebastiaan Merckx
cf8980f0f7 net: dns: fix unpack of DNS record with multiple questions
The first issue is that the query offset was not properly updated.

The second issue is more complex and relates to the use of message
compression in domain names
(https://datatracker.ietf.org/doc/html/rfc1035#section-4.1.4). The
pointers can be nested (i.e. a first pointer pointing to a label with
another pointer)
For example: _http._tcp.local can be represented via:
'_http' + (pointer to a '_tcp' label + (pointer to a 'local' label).
This was not properly implemented, only single-pointers were supported.

Signed-off-by: Sebastiaan Merckx <sebastiaan.merckx@verhaert.com>
2026-04-28 11:24:37 +02:00
Muhammad Waleed Badar
e2a5686f38 net: ip: guard multicast APIs against NULL args
Add NULL checks for iface and addr in IPv4/IPv6 maddr add/rm
to prevent potential dereferences.

Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
2026-04-28 11:23:28 +02:00
Maximilian Zimmermann
451cfb77b1 Bluetooth: CSIP: make size,lock and rank characteristic optional
Make the Coordinated Set Size, Set Member Lock and Set Member Rank
characteristic optional by adding three new Kconfig options
BT_CSIP_SET_MEMBER_SIZE_SUPPORT, BT_CSIP_SET_MEMBER_LOCK_SUPPORT and
BT_CSIP_SET_MEMBER_RANK_SUPPORT. Also updates the existing examples
and tests to compile correctly.

Signed-off-by: Maximilian Zimmermann <gitmz@posteo.de>
2026-04-28 11:19:29 +02:00
Emil Gydesen
0601cc8c42 Bluetooth: CAP: Shell: Reorder code in cap_handover
Reorder some of the large and complex shell command
functions, to make each function simpler to follow.
This also makes the code pass the Sonarcloud complexity
rule.

This also contain a few other various fixes and updates.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-28 11:18:50 +02:00
Emil Gydesen
2945c0be98 Bluetooth: CAP: Shell: Share args between modules
Instead of defining the same arguments in all 3 CAP files,
we declare them in audio.h and initiate them in either
the initiator or commander, depending on their use.

The reason for this change, is that the CAP Handover API
require several of the parameter to be globally/statically
allocated, and cannot just rely on stack allocated parameters.
By doing this, we can use the same argument among the
CAP shell modules, while keeping the memory usage down.
This has the additional postive effect that we do not allocate
some of these arrays, which can be quite larger, on the stack.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-28 11:18:50 +02:00
Emil Gydesen
700d3d5d49 Bluetooth: CAP: Shell: Implement cmd_cap_handover_broadcast_to_unicast
Implement the shell command for handing over broadcast to
unicast. The command supports various configurations.

It is currently limited to cases with
- 1 connection and multiple streams
- Multiple connections and 1 stream
- Equal amount of streams and connections

Cases with e.g. 3 connections and 2 streams,
or vice versa, are not support given the complexity
of these cases.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-28 11:18:50 +02:00
Emil Gydesen
531ed72256 Bluetooth: CAP: Shell: Add handover u->b shell command
Add shell command for unicast to broadcast for the CAP handover
procedures.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-28 11:18:50 +02:00
Chaitanya Tata
fb69902ff4 net: shell: Display raw packet socket statistics
Display raw packet socket statistics (recv, sent, drop, bytes) in the
"net stats" shell command output. This follows the same display format
as the existing UDP and TCP statistics sections.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Assisted-by: Cursor:opus-4.6
2026-04-27 19:04:28 +01:00
Chaitanya Tata
33d6ac9271 net: stats: Add raw packet socket statistics
Add statistics tracking for raw/packet sockets (AF_PACKET), following
the same pattern as existing UDP and TCP statistics. This tracks packet
counts (sent, received, dropped) and byte counts for raw socket traffic.

The new CONFIG_NET_STATISTICS_RAW Kconfig option is enabled by default
when CONFIG_NET_SOCKETS_PACKET is active. Statistics are updated in the
AF_PACKET send path (net_context.c) and the packet socket delivery path
(connection.c).

Includes NET_MGMT user API support, periodic output, and Prometheus
metrics integration.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Assisted-by: Cursor:opus-4.6
2026-04-27 19:04:28 +01:00
Emil Gydesen
78d9b474e5 Bluetooth: BAP: BA: Remove start and end handles
The two cached handles did not provide anything useful
and can be removed, thus freeing up some memory.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-27 17:28:17 +02:00
Emil Gydesen
0f0fff91b9 Bluetooth: BAP: BA: Minor fix for disc_params.uuid
Instead of allocating a generic uuid and copying the BASS UUID
to it for each discovery, we can just use declare and use it
as a constant as it won't change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-27 17:27:22 +02:00
Lyle Zhu
dfac5224ab bluetooth: classic: sdp: Fix buffer length check in attribute parsing
Fix insufficient buffer length validation in bt_sdp_parse_attribute().
The original check only verified space for the type byte and attribute
ID, but did not account for the type variable itself that is read from
the buffer immediately after the check.

This could lead to a buffer over-read if the buffer contains exactly
sizeof(uint8_t) + sizeof(attr->id) bytes but not enough for the
additional type field.

Add sizeof(type) to the length check to ensure all required data is
present before parsing.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2026-04-27 17:25:52 +02:00
Emil Gydesen
028634623f Bluetooth: Audio: Add checks for UTF when getting broadcast name
Add checks to verify the valid length of broadcast names
in codec_cfg and codec_cap, both in terms of size in octets,
but also in terms of length in characters.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-27 17:22:20 +02:00
Emil Gydesen
a259ad8311 Bluetooth: Audio: Add checks for UTF when setting broadcast name
Add checks to verify the valid length of broadcast names
in codec_cfg and codec_cap, both in terms of size in octets,
but also in terms of length in characters.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-27 17:22:20 +02:00
Emil Gydesen
6548ed48af Bluetooth: CCP: Client: Add support for get bearer uci
Add support for getting the remote bearer UCI.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-27 17:21:17 +02:00
Emil Gydesen
7097c3ee0d Bluetooth: Audio: replace implicit integer-to-boolean checks
MISRA-C requires essentially boolean type in control flow.
Convert all if/while conditions using err or ret
as implicit booleans to explicit comparisons:

- if (err)  -> if (err != 0)
- Same rules applied to while statements and ret variable

Assisted-by: GitHub Copilot

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-27 14:22:32 +02:00
Tomi Fontanilles
e02ccae566 net: wireguard: link to mbedTLS when builtin version is used
Without this we can have scenarios where PSA Crypto headers are not
found under certain configurations.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2026-04-27 14:21:14 +02:00
Jamie McCrae
6f363ec6f7 mgmt: mcumgr: transport: Fix resetting invalid buffer
Fixes an issue whereby the buffer was not checked to be valid
before resetting it

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-04-27 14:20:21 +02:00
Lyle Zhu
4de2676eb7 bluetooth: classic: avrcp: Move initialization to callback registration
Move the AVRCP cover art initialization from bt_avrcp_init() to
bt_avrcp_tg_register_cb(). This ensures that cover art is initialized
only when the target callback is registered, aligning with the
initialization flow of other AVRCP target features.

Additionally, add a check in bt_avrcp_tg_cover_art_init() to prevent
re-initialization if the PSM is already set, returning success if
cover art is already initialized.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2026-04-27 14:15:45 +02:00
Emil Gydesen
01ad11b5f7 Bluetooth: BAP: Require security before discovery
The bt_bap_unicast_client_discover and
bt_bap_broadcast_assistant_discover functions now require security
to have already been done before any operations are done.

The BAP require a specific security level and properties,
and checking the security earlier will prevent any unncessary
operations if the expected security requirement cannot be met.

Additionally, ensuring that there is an appropriate pairing with
the provided connection, ensures that we can rely on CONFIG_BT_MAX_PAIR
for soem arrays in the future.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-25 08:21:49 +02:00
Ederson de Souza
593d63c897 subsys/pmci/mctp: New Kconfig CONFIG_MCTP_MAX_MESSAGE_SIZE
Newer version of libmctp allocates a buffer to reassembly messages that
has `MCTP_MAX_MESSAGE_SIZE` size. By default, this size is 64Kb, which
may be too big for Zephyr applications.

This patch adds CONFIG_MCTP_MAX_MESSAGE_SIZE - default 1024 - to allow
Zephyr applications to tune the value used by libmctp.

Also update CONFIG_MCTP_HEAP_SIZE to note it needs to be big enough to
hold CONFIG_MCTP_MAX_MESSAGE_SIZE, on top of other allocations.

Assisted-by: GitHubCopilot:claude-sonnet-4.6
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2026-04-25 08:21:06 +02:00
Ederson de Souza
f31fb53d42 pmci: mctp: Update mctp_set_alloc_ops
Newer version on libmctp has a different signature for
`mctp_set_alloc_ops`:

    mctp_set_alloc_ops(alloc, free, msg_alloc, msg_free)

This patch updates mctp_memory.c to provide the new wrappers for
msg_alloc and msg_free and use new signature for `mctp_set_alloc_ops`.

While at it, remove old usages of `mctp_set_alloc_ops` that existed in
the samples: `mctp_memory.c` should take care of everything.

Finally, libmctp doesn't deallocate packets sent to its RX bus: it's now
for the caller to do so. So this patch also adds the corresponding
`mctp_pktbuf_free` calls.

Assisted-by: GitHubCopilot:claude-sonnet-4.6
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2026-04-25 08:21:06 +02:00
Jordan Yates
18f005b347 portability: cmsis_rtos: select POLL not depends on
Move the `depends on POLL` Kconfig depenedency to `select POLL`. Mixing
`select` and `depends on` with the same symbol is the primary cause of
Kconfig dependency loops, and every other `POLL` "dependency" uses
`select`.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-04-25 08:19:28 +02:00
Fin Maaß
c2de1feb28 net: ethernet: bridge: set iface in data during build
set iface in data during build. So we don't have to set it later in
the iface init. Due to the fact that we already set the id of the data
structure during build, it is already in the data section of the linker
and not the bss section, so that it doesn't increase the size of the
binary. At the same time we save some code and instructions to set the
iface in the data structure during init.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-04-24 15:32:55 -04:00
Fin Maaß
abf3172e41 net: ethernet: bridge: remove is_init
the iface init only happens once,
no need to protect it from happening again.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-04-24 15:32:55 -04:00
Jay Beavers
255bccc1ba usb: device_next: cdc_ncm: Check usbd_ep_enqueue() return value
The cdc_ncm_send() function ignores the return value from
usbd_ep_enqueue(). If the enqueue fails, the code proceeds to block
forever on k_sem_take() waiting for a completion callback that will
never arrive, causing a deadlock.

This was discovered by comparing the CDC-NCM implementation with
CDC-ECM, which correctly checks the return value:

    ret = usbd_ep_enqueue(c_data, buf);
    if (ret) {
        LOG_ERR("Failed to enqueue net_buf for 0x%02x", ep);
        net_buf_unref(buf);
        return ret;
    }

The NCM driver was missing this error handling, leading to potential
hangs if usbd_ep_enqueue() fails for any reason (e.g., endpoint not
ready, USB disconnected, buffer issues).

Fix by checking the return value and properly cleaning up (freeing
the buffer) before returning the error code to the caller.

Signed-off-by: Jay Beavers <jay@tolttechnologies.com>
2026-04-24 10:29:15 -04:00
Cristian Bulacu
5287851640 net: openthread: border_router: Fix multicast forwarding on ethernet
Add call to 'net_if_mcast_monitor' to inform ENET layer to join or leave
a multicast group.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2026-04-24 10:28:15 -04:00
Andrea Gilardoni
1149d843df net: ethernet: differentiate ethernet from wifi if
Definining the functions counterpart for cabled ethernet to operate on
the list of interfaces and differentiate them from the 802.11 based ones

Signed-off-by: Andrea Gilardoni <a.gilardoni@arduino.cc>
2026-04-24 10:28:06 -04:00
Cristian Bulacu
217a5ac0ca net: dns: Enhance DNS packet forwarding mechanism
There are situations where internal DNS resolver will reject the packet,
and in this case, query index is not calculated.
This may break forwarding mechanism;
If DNS packet forwarding is enabled, and internal validation fails, some
checks are done and an attempt to calculate query index is performed, so
the packet can be forwarded and used.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2026-04-24 13:02:39 +02:00
Henrik Brix Andersen
4c8760ca81 modules: canopennode: remove support for the optional CANopenNode module
Remove in-tree support for the optional CANopenNode module. This will be
provided as an external module instead, as there are no bindings from
Zephyr towards this module.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2026-04-24 12:59:39 +02:00
Emil Gydesen
a0a513667b Bluetooth: BAP/CAP: Make qos param const
Make the qos parameter of the BAP can CAP APIs const,
as they are now only used as one-time parameters, and not stored.
This also means that any uses of this can place the qos
parameter in the stack, rather than static memory.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-24 12:58:57 +02:00
Emil Gydesen
be842dfd31 Bluetooth: BAP: Make bt_bap_stream.qos const
The pointer represent the qos configuration
for a stream based on the ASE or broadcast configuration,
and serves as a read-only value. Changing it to `const` makes
this more clear.

Some minor changes were done to existing code to help
support this change.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-24 12:58:57 +02:00
Emil Gydesen
52f25c903f Bluetooth: BAP: Fix issues with qos pointers
In some cases the stream->qos pointer pointed to the
qos argument, and sometimes it pointed to the ep->qos.

Now all qos arguments are copied to ep->qos, and
stream->qos always points to stream->ep.qos.

Some modules had some refactoring done to properly store
the QoS. The unicast client had some additional checks
done or redone, and some now-unused code removed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2026-04-24 12:58:57 +02:00
Steven Friedman
1405595e0f net: http: remove hardcoded localhost hostname
Remove the hardcoded setsockopt(TLS_HOSTNAME, "localhost") which
prevents server-side peer certificate verification from working: the
hostname check compares "localhost" against the client cert's CN/SAN,
which will never match a real client certificate.

Signed-off-by: Steven Friedman <friedman@ionq.co>
2026-04-24 10:56:14 +02:00
Gaetan Perrot
1cb9840462 bluetooth: shell: bt: unify bt_conn_get_info error handling
Standardize error handling for bt_conn_get_info()
across the Bluetooth shell.

- Use a local 'err' variable instead of inline calls
- Check for (err != 0) consistently
- Include error code in all error messages
- Improve log messages for better debugging context

This ensures consistent behavior and more
informative diagnostics when retrieving connection
information fails.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2026-04-24 10:55:21 +02:00
Gaetan Perrot
b919d61559 bluetooth: shell: bt: report bt_conn_get_info() error code
Use shell_error() instead of shell_print() when
bt_conn_get_info() fails and include the returned
error code in the log.

This makes failures easier to diagnose.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2026-04-24 10:55:21 +02:00
Gaetan Perrot
680a38a366 bluetooth: shell: bt: fix unchecked return value in disconnected
Coverity (CID 525133) reported that the return
value of bt_conn_get_info() was not checked in
disconnected(), which could lead to use of
uninitialized data.

Fix this by validating the return value before
using the connection info structure.

If retrieving the information fails, fall back to
using the generic connection type to preserve the
existing behavior.

This prevents undefined behavior while maintaining
the original logic.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2026-04-24 10:55:21 +02:00
Gaetan Perrot
8020b4c594 bluetooth: shell: bt: fix unchecked return value of bt_conn_get_info
Coverity (CID 333394) reported that the return
value of bt_conn_get_info() was not checked in
remote_info_available(), which could lead to use
of uninitialized data.

Fix this by checking the return value and aborting
early in case of error, ensuring that the
connection info structure is valid before use.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2026-04-24 10:55:21 +02:00
Fin Maaß
17fafb4933 net: vlan: simplify name assignment for detached interfaces
net_virtual_set_name already makes sure,
that the string ends with 0, therefore
we can directly provide the constant string.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-04-23 18:24:12 -04:00
Fin Maaß
130969990f net: vlan: change bit-fields to regular bool
because these 2 bools are after a uint16_t, that itself is after
a pointer, there should be space for 16 bit, so we can have the
bools regular instead of bit-fields.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-04-23 18:24:12 -04:00
Fin Maaß
6932a89a8e net: vlan: remove init_done
the iface init only happens once,
no need to protect it from happening again.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-04-23 18:24:12 -04:00
Fin Maaß
be4d1f460a net: vlan: set iface in data during build
Set iface in data during build. This simplifies the code and
reduces code size.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-04-23 18:24:12 -04:00