Commit graph

21541 commits

Author SHA1 Message Date
Sayooj K Karun
273d60164d net: sockets: IPv6_MULTICAST_LOOP Support
Add support for the IPV6_MULTICAST_LOOP socket option.
This option allows enabling or disabling the consumption of multicast
packets by the sender. By default, the socket option will be enabled.

Co-authored-by: Pieter De Gendt <pieter.degendt@gmail.com>

Signed-off-by: Sayooj K Karun <sayooj@aerlync.com>
2025-03-21 14:19:08 +01:00
Robert Lubos
a61287e876 net: lib: tls_credentials: Rename TLS_CREDENTIAL_SERVER_CERTIFICATE
TLS_CREDENTIAL_SERVER_CERTIFICATE credential type is misleading, as in
fact it just represents a public certificate, it does not matter if the
certificate belongs to a server or a client. And actually, it was
already used in-tree for clients as well, for example in LwM2M.

Therefore rename the credential type to a more generic
TLS_CREDENTIAL_PUBLIC_CERTIFICATE and deprecate the old one.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-03-21 14:18:52 +01:00
Jukka Rissanen
82b43d50ea net: l2: dummy: Update sent statistics
Update dummy interface sent statistics as that was missing.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-21 14:18:25 +01:00
Jukka Rissanen
5076f5eee0 net: l2: virtual: Handle the packet if no attached interfaces
If there are no virtual interfaces attached to this virtual
interface, check if there is a RX handler for this virtual
interface and pass data to it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-21 14:18:25 +01:00
Cla Mattia Galliard
799742a77b net: sockets_service: Always clear old events when registering
Clear all previous events when register is called a second time. This is
the same behavior as before, if the call happens with `len` equal or
greater then the previous call but in the case if `len` is less then the
first call, now, all events are cleared. This is more predictable behavior.

Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
2025-03-21 14:18:08 +01:00
Mark Wang
e5742b2405 bluetooth: avdtp: avoid that the ret and err exist together
Keep the err in code as it is convention in Bluetooth code, remove ret,
change error_code as avdtp_err_code for avdtp protocol error.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-03-21 09:53:49 +01:00
Jukka Rissanen
2f1a134f81 net: core: Free packet properly if TTL/hop limit is 0
We drop the packet if TTL or hop limit is 0, but we should
also unref the packet in this case because we return 0 to
the caller which is not then able to free the packet because
it thinks that the packet was sent properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-21 09:53:44 +01:00
Jukka Rissanen
fc16c42bf7 net: core: Do IPv4/6 packet checks only for those packet types
The check_ip() in net_core.c did not check that the packet
Ethernet type is either IPv4 or IPv6. This meant that we for
example checked TTL also for ARP packets which is pointless as
those are not IPv4 packets.

Fix this by checking the link layer protocol type of the packet
to be either IPv4 or IPv6 before doing L3 checks.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-21 09:52:42 +01:00
Johan Hedberg
0837ad5be8 Bluetooth: Host: Remove unused include
There's no need for scan.h in direction.c.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-03-20 21:58:44 +01:00
Jukka Rissanen
410bd4b0be net: utils: Add helper to parse ip address string with a mask len
Adding a helper to parse one or more IPv4/6 strings with optional
netmask or prefix length.

Example of the string:

   2001:db8::1/64,192.0.2.1,2001:db8::2,192.0.2.2/24

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-20 17:16:10 +01:00
Troels Nilsson
35371e8db1 Bluetooth: Controller: Fix possible unaligned read for ISO timestamp
Use net_buf_pull_le32() to avoid alignment issues for the ISO timestamp

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-03-20 17:15:48 +01:00
Jukka Rissanen
cd1091bc0a net: shell: conn: Print all connection information
All connection information was printed only if connection debugging
was enabled which then did not print information about Wireguard or
DHCP handlers. Limiting the printouts like this is not really needed
so print all connection information with "net conn" command.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-20 17:15:36 +01:00
Jukka Rissanen
0341d6bf0c net: shell: iface: Allow user to set the default interface
It is useful in testing to allow user to change the default
network interface by "net iface default <index>".
Also print out the default interface for "net iface" and
"net iface default" commands.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-20 17:15:36 +01:00
Jukka Rissanen
62963396e0 net: shell: iface: Print low level information if iface dbg is enabled
Sometimes it is useful to view low level network interface information
in the network shell. Enable such prints if network interface debugging
is enabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-20 17:15:36 +01:00
Krzysztof Chruściński
4026daa42e arch: riscv: Add support for CPU load measuring
Add sys_trace_idle_exit to RISCV cpu_idle functions and allow
enabling CPU_LOAD module for RISCV and disable it for SMP.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-03-20 17:14:52 +01:00
Emil Gydesen
d19abff476 Bluetooth: CSIP: Add support for dynamically setting set size
The set size can now be dynamically set and notified.
The rank is added as a argument in the case that changing
the set size, also affects the device's rank, as ranks
in a coordinated set needs to be continuous.

The set coordinator implementation has been updated
to support receiving the new set size, and providing
this information to the upper layers.

This commit adds a babblesim test for the new API,
as well as a shell command.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-20 14:23:40 +01:00
Troels Nilsson
30df4762e7 Bluetooth: Controller: Fix overhead check in ull_scan_aux for SLOT_AGNOSTIC
The current overhead check needlessly flushes some events for
CONFIG_BT_TICKER_SLOT_AGNOSTIC resulting in some lost or incomplete
advertising events; Use a lower overhead value for this configuration
to avoid that

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-03-20 14:23:21 +01:00
Troels Nilsson
b6d32b94a0 Bluetooth: Controller: Fix missing initialization of expire_info_id
The scanner doesn't use the expire_info_id feature, so it needs to
be set to TICKER_NULL

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-03-20 14:22:38 +01:00
Troels Nilsson
d028532fe9 Bluetooth: Controller: Select TICKER_LAZY_GET for PAST sender
BT_CTLR_SYNC_TRANSFER_SENDER does not work without BT_TICKER_LAZY_GET;
Add a select to the config

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-03-20 12:17:02 +01:00
Vineeta S Narkhede
fc974e36b0 net: mdns: Add support for iOS.
The query type used by iOS is HTTPS-65,
Adding HTTPS query type to support iOS.

Signed-off-by: Vineeta S Narkhede <VineetaSNarkhede@Eaton.com>
2025-03-20 12:16:43 +01:00
Troels Nilsson
334764d2fa Bluetooth: Controller: Use event_offset = 2 for large CIG Sync Delays
For a CIG with a CIG Sync Delay larger than a SDU interval, we cannot
be sure that we can target the very next ISO event when the CIG event
is ongoing; Only reduce event_offset if CIG Sync Delay is smaller
than an SDU interval

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-03-20 09:33:40 +01:00
Lyle Zhu
11fc9642c0 Bluetooth: Classic: Add a function bt_conn_get_dst_br()
Add a function `bt_conn_get_dst_br()` to get the peer address of the
classic connection.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-19 09:01:51 -04:00
Lyle Zhu
773298893f Bluetooth: BR: Shell: clang-format
Clang-format subsys/bluetooth/host/classic/shell/bredr.c

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-19 08:52:07 -04:00
Lyle Zhu
0e792d4271 Bluetooth: BR: Shell: L2CAP mode support
Add more parameters to command `connect` and `register`, including mode,
mode_optional, extended_control, and hold_credit.

Add command `credits` to give the rx credit.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-19 08:52:07 -04:00
Lyle Zhu
bba7efa941 Bluetooth: BR: Shell: Add L2CAP basic function commander
Add a sub-command set `l2cap` for command set `br`.

Move command `l2cap-register` to sub-command set. And rename it to
`register`.

Add command `connect`, `disconnect`, and `send` for command set
`l2cap`.

Remove original net buffer pool from `data_pool` to `data_rx_pool`.
Add a net buffer pool `data_tx_pool` for command `send`.

Do not wait anymore if no net buffer can be allocated from
`data_rx_pool`.

Dump all received data in L2CAP data received callback.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-19 08:52:07 -04:00
Lyle Zhu
5fd98e10bd Bluetooth: L2CAP_BR: Sending multiple SDU at same time
Improve the retransmission and flow control to support sending
multiple SDU at the same time if the TX windows is not full.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-19 08:52:07 -04:00
Lyle Zhu
88bd18b6cd Bluetooth: L2CAP_BR: Add mode optional support
Add mode optional support for BR l2cap connect initiator role.

If `chan->rx.optional` is true, set the mode to basic mode instead of
return error code `-ENOTSUP`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-19 08:52:07 -04:00
Lyle Zhu
d2a10833dd Bluetooth: L2CAP_BR: Enable Retransmission and Flow control
Enable signaling channel configuration for retransmission and Flow
control feature.

Send I-frame and S-frame. Support retransmission and Flow control for
sending.
Receive and handle I-frame and S-frame.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-19 08:52:07 -04:00
Lyle Zhu
18b0ac9b9a Bluetooth: conn: Make bt_conn_lookup_addr_br() public
Move the declaration of the function `bt_conn_lookup_addr_br()` from
`conn_internal.h` to `conn.h`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-19 10:58:29 +01:00
Maochen Wang
cb65dfbd2b net: lib: zperf: improve UDP RX throughput
The original flow of socket_service thread handling the Zperf UDP RX
packets is: zsock_poll() polls all sockets for events, if ctx->recv_q
of Zperf is not empty, it will call trigger_work() -> udp_recv_data()
-> zsock_recvfrom() to read only one UDP packet from ctx->recv_q, then
go back to zsock_poll() and run the same process again, which is
inefficient.
The alternative solution is, in udp_recv_data(), it should exhaust all
the packets in the current ctx->recv_q, and then go back to
zsock_poll() to run the same process again.
In our Wi-Fi test case, for WPA3 security mode of 5GHz, the STA UDP RX
throughput can be improved from 91.48 Mbps to 99.87 Mbps, the SAP UDP
RX throughput can be improved from 85.97 Mbps to 96.00 Mbps.

Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
2025-03-19 10:58:16 +01:00
Michał Stasiak
32a4c9cb79 bluetooth: controller: remove select of ENTROPY_NRF_CRACEN_CTR_DRBG
ENTROPY_NRF_CRACEN_CTR_DRBG symbol is based on devicetree
node with compatible nordic,nrf-cracen-ctrdrbg. It does not
have to be selected explicitly.

Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
2025-03-19 10:57:18 +01:00
Emil Gydesen
065dca7e92 Bluetooth: ISO: Make setting ISO data explicit
The stack will no longer implicitly set the data path
for ISO channel, and the responsibility for doing that is
now for the upper layers/applications.

This provides additional flexibility for the higher layers
as they can better control the values and timing of the data
path, as well as support removing and even reconfiguring the
data path at will.
This also removes some complexity from the stack.

This commit also fixed a inconsistency in the disconnected
handler. CIS for centrals as well as BIS were still valid
bt_iso_chan channels in the disconnected callback,
but CIS for peripherals were completely cleaned up at this
point. This issue is fixed by moving the disconnected callback
handling to before the code to cleanup the channel for
peripherals.

Since there is a difference in how you remove data paths
depending on the GAP role (central/peripheral), the
iso_info struct type has been expanded to be more
concise of which type of CIS it is.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-19 10:56:57 +01:00
Pieter De Gendt
1d62d835ac net: ip: Configurable IPv4 MTU
Allow to configure the initial IPv4 MTU needed to support packets without
fragmentation.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-03-19 03:34:26 +01:00
Luca Burelli
681c7da7c8 llext: fix fixed-length name buffer usage
This was inspired by the detection of 2 instances of the warning:

   warning: 'strncpy' specified bound 16 equals destination size
            [-Wstringop-truncation]

The current code is already safe with regards to overflows, because
fixed-length string functions are used in the call tree. However, when
given a name 16 chars or larger, the current compare in llext_by_name()
will not work as expected because the stored extension name is truncated
to a max of 15.

Define a global LLEXT_MAX_NAME_LEN constant to simplify all this logic
and also implement name checks in the shell before calling llext_load().

Finally, using strlen() instead of strnlen() gets the real length of the
hex string passed as a parameter, which is important for the next safety
check.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-03-19 01:23:59 +01:00
Troels Nilsson
48fd8874e9 Bluetooth: Host: Fix missing endianness conversion for ISO ts
The timestamp was missing an endianness conversion

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-03-18 19:54:24 +01:00
Robert Lubos
20faa0e114 net: l2: ppp: Make PPP L2 work with packet sockets
Currently, the L2 PPP won't work with AF_PACKET socket family as it only
supports packets from AF_INET/AF_INET6 families. Because of this, it's
not possible to use AF_PACKET RAW or DGRAm sockets with PPP interfaces,
as the packets they generate have family field set to AF_PACKET.

Fix this, by verifying the LL protocol field in the PPP L2 before
passing the packet the respective PPP driver. If the AF_PACKET packet is
received, and the protocol field is set to IP/IPv6, update the packet
family to AF_INET/AF_INET6 accordingly.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-03-18 16:45:53 +01:00
Johan Hedberg
81e7569fa1 Bluetooth: Host: Fix format specifier warnings
Use %zu for size_t and %zd for ssize_t, and don't use those specifiers for
any other type. Also make sure that field width specifiers get typecast to
the expected int type.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-03-18 16:45:29 +01:00
Dong Wang
3fac83151d logging: Assign IDs to log backends early during log_core_init
This commit moves the assignment of backend IDs from the 'z_log_init'
function to the earlier 'log_core_init' function. This ensures that
backend IDs are assigned before they are used in the 'log_backend_enable'
function, preventing incorrect settings of log dynamic filters.

Signed-off-by: Dong Wang <dong.d.wang@intel.com>
2025-03-18 16:42:07 +01:00
Emil Gydesen
fb68b4be7e Revert "Bluetooth: Audio: Use generic count_bits to count bits"
This reverts commit ee335399c1.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-18 16:39:47 +01:00
Marcin Niestroj
7290dd2a57 net: ipv6: set NET_ADDR_PREFERRED before network event if !DAD
Set NET_ADDR_PREFERRED before network event is generated, so that conn_mgr
properly generates NET_EVENT_L4_CONNECTED and NET_EVENT_L4_IPV6_CONNECTED
events.

Fixes: 1a5e13a79b ("net: if: Release the interface lock early when
  starting IPv4 ACD")
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2025-03-18 08:27:06 +01:00
Marcin Niestroj
3fcd25c8f8 net: ipv4: set NET_ADDR_PREFERRED before network event if !ACD
Set NET_ADDR_PREFERRED before network event is generated, so that conn_mgr
properly generates NET_EVENT_L4_CONNECTED and NET_EVENT_L4_IPV4_CONNECTED
events.

Fixes: 1a5e13a79b ("net: if: Release the interface lock early when
  starting IPv4 ACD")
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2025-03-18 08:27:06 +01:00
Emil Gydesen
ee335399c1 Bluetooth: Audio: Use generic count_bits to count bits
Instead of re-implementing or assuming that POPCOUNT is available
we now use the generic function from Zephyr.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-17 21:03:56 -04:00
Vinayak Kariappa Chettimada
0a4480ce61 Bluetooth: Controller: Fix connection update interval_us variables
Fix connection update microsecond interval variable data
type, to use 32-bit so that a value upto 2000 seconds, i.e.
4 seconds interval and 499 peripheral latency can be stored.

Regression in commit abfe5f17a9 ("Bluetooth: Controller:
1 ms connection").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-03-17 20:00:42 +01:00
Luca Burelli
959f1b352d llext: support alignment requirements for sections
This patch adds support for alignment requirements for sections in the
loader. The alignment requirements are taken from the ELF file and
checked when the section is mapped to a memory region and when the
region is copied to memory (or directly used from the ELF buffer).

Supporting a larger alignment requirement than the region's current
alignment is done by adjusting the region's start address. This needs
care to avoid detecting false overlaps with other regions and to ensure
that the region address and size reported by the inspection APIs are
correct. The extra offset needed to re-adjust these values is stored in
the 'sh_info' field of the region descriptor.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-03-17 19:58:15 +01:00
Luca Burelli
1b48f74346 llext: avoid redundant 'ldr_parm' checks
Since commit 0aa6b1c9de, the 'ldr_parm' pointer is guaranteed to be
valid inside all the functions of the llext_load() call tree.

This commit fixes the only exception of llext_copy_strings(), which was
not passed the 'ldr_parm' pointer, and remove the redundant checks.

No functional change is intended by this commit.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-03-17 19:58:15 +01:00
Luca Burelli
c0c8f778f7 llext: refactor llext_copy_region()
This commit adjusts the logic of the LLEXT memory allocation routine by:

 * defining 'align' and 'alloc' variables once and updating them in the
   following code;

 * swapping the condition, converting it to an 'if(IS_ENABLED(...))' and
   using a direct calculation for the size to make the code easier to
   read;

 * updating and extending a few comments.

No functional change is intended.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-03-17 19:58:15 +01:00
Luca Burelli
219cde6621 llext: avoid direct llext_string() usage
Since 3466dab804 the generic llext_symbol_name() function abstracts
the use of llext_string() for (non-section) symbols. Define a similar
llext_section_name() function and replace current occurrences of
llext_string() with the proper abstraction.

By extending llext_symbol_name(), this commit also allows to print the
correct name of sections that are referred to by a symbol.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-03-17 19:58:15 +01:00
Luca Burelli
79a9ff0264 llext: (cosmetic) cleaner region overlap checks
Rewrite the overlap checks in llext_map_sections() to use a pair of
macros to calculate the top and bottom of a region. This makes the
code more readable and less error-prone.

No functional change is introduced in this commit apart from a log
message format change.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-03-17 19:58:15 +01:00
Luca Burelli
8f9ab18ce2 llext: (cosmetic) log uniformity cleanups
Use the more compact %#x format for printing out hexadecimal values in
the LLEXT subsystem. This also uses a clearer wording for the
llext_link() log message that avoids repeating information.

No functional change is introduced by this commit.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-03-17 19:58:15 +01:00
Luca Burelli
111d7c3754 llext: (cosmetic) rename llext_copy_section() to llext_copy_region()
llext_copy_section() is a misnomer, as it is copying a region of memory,
not a section. Rename it to llext_copy_region() and use 'region' in the
internal variables to better reflect their purpose.

No functional change is introduced in this commit.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-03-17 19:58:15 +01:00