According to RFC793 chapter3.5 with the 'Reset Processing' part,
"In the SYN-SENT state (a RST received in response to an initial
SYN), the RST is acceptable if the ACK field acknowledges the SYN."
So, in the net_tcp_reply_rst() we should use 'ack++' if no ACK
flag but have SYN flag.
And, all the RST packet should use net_tcp_reply_rst() instead of
tcp_out().
Signed-off-by: Shrek Wang <inet_eman@outlook.com>
Commit fixes bug when advertisements were disabled and stopped
during suspending without unreferencing allocated advertisements.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Previously, the interval was only checked for non-zero. Now it is
validated to be within the allowed range (BT_HCI_LE_INTERVAL_MIN
to BT_HCI_LE_INTERVAL_MAX) to avoid invalid values.
Signed-off-by: Babak Arisian <bbaa@demant.com>
Fix assertion observed establishing subsequent Peripheral
ISO connection due to a race between the new CIS context
being acquired into a CIG and LLL getting a CIS sorted by
CIS offset in that CIG. Get only active CISes from the CIG
in the LLL prepare.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix max tx octets value used as given to the Host by the
LE Read Buffer Size command response.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix missing removal of redundant ISO Rx size in ACL Rx PDU
allocation size.
Related to commit 7c89f1fe9f ("Bluetooth: controller:
Support for separate ISO RX data path").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Connection manager enforces non-blocking disconnect() behavior, yet in
case CONN_MGR_IF_NO_AUTO_DOWN flag is not set, it'd put the interface
down right after, disrupting the disconnect process.
As putting the interface down can be handled in the corresponding event
handler as well, when the interface is actually disconnected, remove the
conn_mgr_conn_if_auto_admin_down() call from conn_mgr_if_disconnect().
To make this work with persistence flag, introduce a new internal flag
indicating that the interface is in active disconnect.
Finally, since it isn't really necessary that disconnect() API call is
non-blocking, remove that requirement.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Fix regression introduced by #88747 that breaks linking
with zperf server enabled but TCP or UDP disabled.
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
Add missing curly braces in if/while/for statements.
This is a style guideline we have that was not enforced in CI. All
issues fixed here were detected by sonarqube SCA.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
BASS server need to notify that both BIS and PA are no longer synced by
setting all required fields to 0 after client stops BIS by sending a
BIG control PDU with a BIG TERMINATED indication.
meanwhile BIG_Encryption in the notification should also be reset to be
BT_BAP_BIG_ENC_STATE_NO_ENC when BIS is not synced anymore.
Signed-off-by: Ping Wang <pinw@demant.com>
Fix missing nRF CCM disable on connection event abort.
There can be a problem on nRF SoC for example when a S8
"encrypted" reception is aborted, and a 2M "cleartext"
reception starts; slow CCM (that is not stopped as part of
radio disable) will corrupt a fast received "cleartext" when
the same current free rx buffer is reused in the Controller.
This is not a problem when the connection being abort-ee is
on a faster PHY than the abort-er.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use the macro NSEC_PER_SEC defined in sys_clock.h for nanoseconds per
second when updating write stats.
Signed-off-by: Alex Apostolu <apostolu240@gmail.com>
A previous PR merged (to remove runtime observers' dependency with heap)
added inconsistencies and compatibility breaks to the zbus. This commit
improves that by removing the inconsistencies and still attending to the
features requested by the community.
Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
if the provided name in argument is not null this could lead to un
undefined behavior.
Use strnlen to make this safe
Signed-off-by: Riadh Ghaddab <rghaddab@baylibre.com>
Add a function to get the value's length of a Key. If it doesn't exist
returns 0.
Add ZMS implementation for csi_get_val_len() and a default implementation
for the other storage systems.
Add some functional tests to verify it.
Signed-off-by: Riadh Ghaddab <rghaddab@baylibre.com>
When a power off happens after writing the settings name and before
writing the linked list node we cannot write the settings name again in
the future.
Fix this by writing the linked list node before writing the name.
When loading all settings, we already delete linked list node that do
not have any name or value written.
Adds as well a recover path if a power down happens in the middle of
unlinking an LL node after a delete.
Signed-off-by: Riadh Ghaddab <rghaddab@baylibre.com>
Add a a function settings_load_one that allows to load only one settings
entry instead of a complete subtree.
Add as well its implementation for ZMS backend.
This will allow a faster return if the Settings entry doesn't exist in
the persistent storage.
Signed-off-by: Riadh Ghaddab <rghaddab@baylibre.com>
Increase the load performance by adding an optional cache for the linked
list hashes.
This is used only when the settings_load is called with NULL parameter
and we need to load all Settings that exist in the persistent storage.
Cache is enabled using SETTINGS_ZMS_LL_CACHE and the size of the cache
is set using SETTINGS_ZMS_LL_CACHE_SIZE.
Each cache entry will add 8 bytes of RAM usage.
Signed-off-by: Riadh Ghaddab <rghaddab@baylibre.com>
If the subtree argument is not NULL in the settings_load function, load
only the setting entry that corresponds to that subtree.
If the subtree argument is NULL or it is not found in the storage, load
all the existing entries in the storage.
Signed-off-by: Riadh Ghaddab <rghaddab@baylibre.com>
Settings subsystem is storing the name ID and the linked list node ID
with only one bit difference at BIT(0).
Settings subsystem is also storing the name ID and the data ID in two
different ZMS entries at an exact offset of ZMS_DATA_ID_OFFSET.
Using the regular lookup function could result in many cache misses.
Therefore, to assure the least number of collisions in the lookup cache,
the BIT(0) of the hash indicates whether the given ZMS ID represents a
linked list entry or not, the BIT(1) indicates whether the ZMS ID is a
name or data and the remaining bits of the hash are set to a truncated
part of the original hash generated by Settings.
Signed-off-by: Riadh Ghaddab <rghaddab@baylibre.com>
When the CONFIG_ZMS_NO_DOUBLE_WRITE is not enabled there is no need to
search in the cache for matching ID
Signed-off-by: Riadh Ghaddab <rghaddab@baylibre.com>
When deleting a settings entry the linked list is updated by removing
the deleted node. This operation is time consuming and add some delays.
For applications that use almost the same set of Setting entries, add an
option to make this operation faster at a cost of having some empty
nodes in the linked list.
These empty nodes can be used later when the deleted entry is written
again.
Each empty node occupies 16B of storage.
Signed-off-by: Riadh Ghaddab <rghaddab@baylibre.com>
The NULL-pkt parameter for tcp_in() was designed for generating
a SYN packet to start the 1st TCP handshake. It is only used
in net_tcp_connect() and tp_input().
To simplify the tcp_in() code logic and make it better under-
standable, a tcp_start_handshake() is added for net_tcp_connect()
and tp_input() to use. Thus, the tcp_in() only handles the in-
coming TCP packets.
Signed-off-by: Shrek Wang <inet_eman@outlook.com>
Fix MIC failure when 2 or more CISes in Peripheral is active
and any CIS before the last CIS does not have reception that
lead to the event count and payload count being incorrect.
Add the missing flush implementation when switching between
CISes in the CIG event.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Adds support for using img mgmt in firmware loader mode, to allow
for loading an update image to a device
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Ensure `pm_state_force` returns `false` when it fails to retrieve or set
the desired power state. This change improves error handling and ensures
the function's behavior aligns with its intended purpose.
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
https://github.com/zephyrproject-rtos/zephyr/actions/runs/\
15014534061/job/42189411225
We were seeing a linker error of the form
```
picolibc/x86_64-zephyr-elf/lib/32/libc.a(libc_time_time.c.o): \
in function `time':
time.c:(.text.time+0x11): undefined reference to `gettimeofday'
```
Update the dependency from CONFIG_POSIX_TIMERS to
CONFIG_XSI_SINGLE_PROCESS for gettimeofday().
Note: this is really only a workaround. The proper solution would
be to have libc functions not depend on POSIX functions.
Specifically, here
https://github.com/zephyrproject-rtos/picolibc/blob/\
51a8b32857e75345c37652a80b5cda98b28d69e5/newlib/libc/time/\
time.c#L54
and here
https://github.com/zephyrproject-rtos/zephyr/blob/\
3a4e12899c2ae5962a64055f4739f774fb7262e5/lib/libc/common/\
source/time/time.c#L17
Also mentioned in #89068
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
In current implementation, if the MITM flag of both sides is disabled,
the pairing method is incorrect.
Such as, the IOCAP of both sides is `display_yesorno`, the pairing
method is `PASSKEY_CONFIRM`. But actually, it should be `JUST_WORKS`
in this case.
Fix the issue by setting the pairing method to `JUST_WORKS` if the
MITM flag of both sides is false.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
The Kconfig option has not been in use for anything for
a long time, and can safely be removed.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit prevents ATT request APIs from blocking waiting on the
req_slab pool on the system work queue. The API will instead return
-ENOMEM.
This aligns with commit 05b16b971b, which
establishes that the GATT request APIs are non-blocking on the system
work queue. That commit makes GATT request APIs fail with -ENOMEM when
they fail to allocate a buffer for the ATT PDU on the system work queue.
There is no reason to make this distinction between the two resources,
and this makes the API more consistent.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
For the control point operations, add/modify/
remove source, callbacks are added so that Application
can decide whether to accept/reject the control point
operations.
Signed-off-by: Nithin Ramesh Myliattil <niym@demant.com>
Validate that the file descriptor is not a negative number before
writing to the `dispatch_table` `ctx` field. Setting file descriptors
to `-1` is the standard "not in use" value, and in fact the entire array
of `fds` is set to this value in `dns_resolve_init_locked`. This
resolves memory corruption of whichever variable is unfortunate to exist
just before `dispatch_table` in memory.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Keep Alive timeout is represented by 2-byte unsigned integer, however
the corresponding Kconfig option was limited to UINT8_MAX only.
Also, similarly to regular MQTT, allow to disable the Keep Alive
functionality by specifying the Keep Alive value to 0.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
When PPP net_if is changed to dormant, the PPP connection
is terminated asynchronously. This is used so that the driver
can terminate the PPP connection gracefully.
Note: net_if_down() is not used as it would require synchronous
operation which would block the system workqueue thus causing
deadlock.
Signed-off-by: Markus Lassila <markus.lassila@nordicsemi.no>
Turn the MBEDTLS_RSA_FULL selects into depends on.
This is how the other MBEDTLS_KEY_EXCHANGE_* Kconfig options are defined.
This is done to avoid circular dependencies.
At the same time update uses of the affected MBEDTLS_KEY_EXCHANGE_*
Kconfig options to enable/disable the dependencies which used to be
automatically handled.
Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
Error checking of otIp6AddUnicastAddress() and
otIp6SubscribeMulticastAddress() was added recently, however it wasn't
taken into account that those APIs return an error on attempt to
register an IPv6 address that is already present on the OT interface.
Therefore, add more specific error checks, to return silently in case
address was already present.
As those two APIs are not very consistent, and otIp6AddUnicastAddress()
returns OT_ERROR_INVALID_ARGS in such cases, add an extra check if the
address is already present before attempting to register the address.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>