Commit graph

21541 commits

Author SHA1 Message Date
Jukka Rissanen
65a3b5a68e net: tcp2: Do not close connection if we run out of memory
Usually the out-of-memory situation will clear itself eventually,
so if that happens in TCP, then keep the connection running and
let the user to decide what to do next.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-09-18 22:07:53 -04:00
Jukka Rissanen
69d9eb6c94 net: socket: Wait new buffers when sending
If we run out of network buffers and cannot send data, and if
we have a blocking socket, then wait until new buffers are
available before returning. As this might lead to deadlock,
wait only max 10 seconds and return ENOMEM if we cannot get
buffers in a reasonable amount of time.

Fixes #28216

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-09-18 22:07:53 -04:00
Jukka Rissanen
80d04616de net: tcp2: Honor TCP retry count limit from Kconfig file
Instead of hardcoded value of 3, use the value from Kconfig file
so that user can tweak the TCP retry count.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-09-18 22:07:53 -04:00
Jukka Rissanen
28177dad6f net: conn: Use safe slist macro when searching connection
Try to catch simultaneous insert to/delete from list when
searching the connection.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-09-18 22:07:53 -04:00
Jukka Rissanen
6dfb11c781 net: tcp2: Use safe version of slist macro in conn search
Use SYS_SLIST_FOR_EACH_CONTAINER_SAFE() macro when searching
the connection list so that we notice if new entries are added
or removed in the list.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-09-18 22:07:53 -04:00
Jukka Rissanen
54d05efb34 net: tcp2: Use pointer to slist node
Instead of forcing the slist node to be first in the tcp struct,
use the pointer to node when accessing the slist. This way we
can change the ordering of fields in tcp struct.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-09-18 22:07:53 -04:00
Thomas Stenersen
b7336616b2 Bluetooh: Host: Fix wrong buffer in acl_total_len calc
To be squashed.

Co-authored-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
2020-09-18 20:24:46 +03:00
Thomas Stenersen
3d57cdb7c3 Bluetooth: host: Use C89-style
To be squashed after review.

Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
2020-09-18 20:24:46 +03:00
Thomas Stenersen
e28fdbb9df Bluetooth: host: Fetch L2CAP length directly
This commit will be squashed after review.

Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
2020-09-18 20:24:46 +03:00
Thomas Stenersen
8bc00f5ead Bluetooth: host: Refactor bt_conn_recv
Re-structures the `bt_conn_recv()` to support more generic appending of
new ACL data. This also handles the possibility of receiving 0-length
ACL_START and ACL_CONT fragments, whilst maintaining existing
error-checking functionality.

Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
2020-09-18 20:24:46 +03:00
Thomas Stenersen
a8f47a1110 Bluetooth: host: Support fragmented L2CAP header
Fixes issue #26900.

A controller may fragment an L2CAP SDUs in any way it sees fit,
including fragmenting the L2CAP header. Likewise, the receiving
controller may send the fragmented header as ACL data to the host.

The Zephyr host assumed that a `BT_ACL_START` was at least 2 bytes long,
and consequently read the two-byte length field from the buffer without
length checks.

This commit allows the `BT_ACL_START` to be less than two bytes,
updating the `conn->rx_len` onces the `BT_ACL_CONT` with the remaining
part of the length field has been received.

Signed-off-by: Thomas Stenersen <thomas.stenersen@nordicsemi.no>
2020-09-18 20:24:46 +03:00
Joakim Andersson
cccfea24c1 Bluetooth: controller: Fix Kconfig dependencies for PHY options
Fix Kconfig dependencies for enabling the controller PHY options
for LE 2M Phy  and LE Coded Phy. These options should be selectable
without connections enabled when extended advertising has been enabled.

The issue affects out-of-tree controllers that wish to use the
BT_CTLR_PHY_CODED and BT_CTLR_PHY_2M options.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-09-18 18:11:35 +02:00
Joakim Andersson
4cc6098af8 Bluetooth: controller: Select controller features from SoC capabilities
Select the controller feature support for data length and LE 2M PHY
based on the SoC hardware capabilities instead of relying on SoC
family.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-09-18 18:11:35 +02:00
Siddharth Chandrasekaran
2b4ca51c85 mgmt/osdp: Fix osdp_build_ctx(); Add NULL check on ctx
osdp_build_ctx() was returning fixed NULL and the subsequent code did
not check if ctx was NULL due to osdp_build_ctx() failures. Fix both
these issues.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-09-18 17:36:02 +02:00
Luiz Augusto von Dentz
6f20e072f1 Bluetooth: ISO: Fix unbalanced reference count
When disconnecting chan->conn is set to NULL without unrefing.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-09-18 15:24:17 +02:00
Luiz Augusto von Dentz
a76c804d07 Bluetooth: ISO: Fix crash when bt_iso_chan_bind fails
When attempting to bind a channel if it fails the code will attempt to
cleanup calling bt_iso_cleanup which expects connections of
BT_CONN_TYPE_ISO.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-09-18 15:24:17 +02:00
Luiz Augusto von Dentz
a177dfdd93 Bluetooth: ISO: Fix missing break after bt_iso_cleanup
ISO connection does not initialize its tx_complete_work nor it uses for
anything so calling into tx_notify will likely cause a crash.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-09-18 15:24:17 +02:00
Lingao Meng
b667ba997f Bluetooth: Mesh: Fix RPL not check by proxy configuration
Fixes proxy configuration not check by replay.
Fixes secure beacon iv update not store new RPL.

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2020-09-18 15:18:18 +02:00
Jakub Rzeszutko
04903452f9 shell: add argc range in Kconfig
This commits adds a range to maximum number of arguments that can
build a command.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordisemi.no>
2020-09-18 15:18:07 +02:00
Jakub Rzeszutko
bf5cf84191 shell: fix Tab crashing issue
Commit 770f232a67 removes an array
termination from the shell_make_argv function. This function was
called from two functions: execute and tab_handle. In the mentioned
commit termination was added only in the execute function.
As a result calling tab_handle function was causing a segmentation
fault. This fix adds array termination to the tab_handle function.

Fixes #28434

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordisemi.no>
2020-09-18 15:18:07 +02:00
Vinayak Kariappa Chettimada
17c4396ed4 Bluetooth: controller: Fix cond. compilation for broadcaster
Fix conditional compilation for extended advertising
without peripheral support.

This fixes missing initialization of buffer for generating
advertising terminate event.

Fixes #28325.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-09-18 10:28:57 +02:00
Pascal Brogle
32f053403f net: lwm2m: remove special handling for message id 0
Change so that the caller of lwm2m_init_message is
responsible for generating a message id and remove message id generation
from lwm2m_init_message. Prevents generating a new id when the caller's
intent is to init a message with id 0.

Fixes #28283

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2020-09-17 13:34:19 -05:00
Pascal Brogle
18a51a0bf6 net: lwm2m: use defines for message id and token generation
message id 0 and token 0 have special semantics in the lwm2m engine,
they are used to request generation of new id, mark them as such.

Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
2020-09-17 13:34:19 -05:00
Carles Cufi
121937e071 Bluetooth: controller: Make RX prio thread stack configurable
Now that CONFIG_BT_CTLR_RX_PRIO_STACK_SIZE defines a stack size, allow
for it to be configurable from a .conf file just like the rest of the
threads in Bluetooth.

Fixes #27768.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2020-09-17 18:08:21 +02:00
Trond Einar Snekvik
d7e0d8135f Bluetooth: Mesh: Use #ifdef for provisioner build
Replaces the current zero length array for provisioner data with
ifdefs, to silence new gcc 10 warnings about array element access.

Fixes #28371.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-09-17 11:51:13 +03:00
NavinSankar Velliangiri
dd8f135e2c mgmt: hawkbit: Fix NULL pointer dereferences
Coverity spots that null pointer is passing to flash_img_buffered_write.
This patch fixes the problem.

Signed-off-by: NavinSankar Velliangiri <navin@linumiz.com>
2020-09-16 13:51:55 -05:00
Peter Bigot
611263921a usb: add optional work queue
The USB infrastructure currently uses the system work queue for
offloading transfers, CDC-ACM UART transmission/reception, and device
firmware activities.  This causes problems when the system work queue
is also used to initiate some activities (such as UART) that normally
complete without requiring an external thread: in that case the USB
infrastructure is prevented from making progress because the system
work queue is blocked waiting for the USB infrastructure to provide
data.

Break the dependency by allowing the USB infrastructure to use a
dedicated work queue which doesn't depend on availability of the
system work queue.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-09-16 13:32:22 -05:00
Peter Bigot
2c105e8f0d usb: clean CMakeLists conditions
Use the helper function to conditionally include source files.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-09-16 13:32:22 -05:00
Peter Bigot
692449d6c7 usb: fix header language linkage
The block that introduced a C linkage region was not closed in the
header as it should be.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-09-16 13:32:22 -05:00
Peter Bigot
2e99f3b652 usb: cdc_acm: fix formatting specifiers in log messages
The z length modifier must be applied to avoid build errors when the
format is verified by the compiler on systems where size_t is larger
than int.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-09-16 13:32:22 -05:00
Emil Obalski
da93a9e50f usb: cdc_acm: Do not change rx/tx_irq_ena flags on RESET and CONFIGURED
Both tx_irq_ena and rx_irq_ena flags shall be updated only
by using UART API. Those flags are used to let the device
start sending or receiving data. Changing those flags without
awareness of the user may lead to errors.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-09-16 13:25:12 -05:00
Emil Obalski
d6dba72502 usb: cdc: Semaphore per CDC_ACM instance.
Usage of `pool_wait_sem` was incorrect. The semaphore shall be
dependent on context it was called for. In case of many CDC_ACM
devices one could possibly block others. This fixes an issue by
making semaphore a part of the internal CDC_ACM device structure.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-09-16 13:21:49 -05:00
Flavio Ceolin
e28d3404eb mgmt: hawkbit: Fix resources leakage
Coverity spots that memory allocated for addr was leaking, but the
code was also leaking the socket file descriptor in the error path.
This patch fixes both problems.

Fixes #28172

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-09-16 12:05:21 +02:00
Eduardo Montoya
a136f2f695 net: openthread: fix initialization with link raw enabled
Fix the OpenThread initialization to prevent the IPv6 interface to
be enabled when `CONFIG_OPENTHREAD_RAW` is set.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2020-09-16 12:05:07 +02:00
chao an
e611b10fde Bluetooth: host: free the adv instance if start legacy advertise fail
the adv instance should be delete correctly if advertise fail,
Otherwise the instance will unable to allocate if start the legacy again

Signed-off-by: chao an <anchao@xiaomi.com>
2020-09-16 11:29:09 +03:00
Ievgenii Meshcheriakov
aac3174677 shell: Fix typo in a comment
Typo: s/badckends/backends/.

Signed-off-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@nordicsemi.no>
2020-09-15 09:44:42 -05:00
Ievgenii Meshcheriakov
b00170436b shell: Make shell UART backend initialization priority configurable
Closes: #28331

Configurable initialization priority is useful when using CDC ACM
serial device, for example.

Signed-off-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@nordicsemi.no>
2020-09-15 09:44:42 -05:00
Dominik Ermel
4e76da8ab1 storage: flash_map: Fix checking unsigned for negative value
The unsigned size_t type variables have been checked for having
negative values.

Fixes #28171, Coverity-CID: 214224

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-09-15 12:44:13 +02:00
Anas Nashif
6c53e93318 power: fix Kconfig help message
Fix help message of Kconfig, this looks like a copy/paste from the
settings subsystem.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-09-14 21:27:23 -04:00
Siddharth Chandrasekaran
a3d07cda9b mgmt/osdp: Make CP/PD mode selection as first entry in Kconfig
CP/PD mode selection is the most frequently looked-for/changed key in
Kconfig. Making that as the first entry for ease of use.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-09-14 16:00:45 -05:00
Siddharth Chandrasekaran
e6789a82ca mgmt/osdp: Change select SERIAL to imply SERIAL_SUPPORT_INTERRUPT
OSDP subsys was doing a `select SERIAL` in its Kconfig. But this has
other unintended side effects. Change this to
`imply SERIAL_SUPPORT_INTERRUPT`.

Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
2020-09-14 16:00:45 -05:00
Krzysztof Chruscinski
770f232a67 shell: Fix case when too many arguments are provided
Shell was accepting CONFIG_SHELL_ARGC_MAX+1 arguments which lead to
memory corruption and fault. Added error message reported when number
of provided arguments exceeds CONFIG_SHELL_ARGC_MAX.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-09-14 16:05:11 +02:00
Trond Einar Snekvik
61819f23f9 Bluetooth: Mesh: Virtual address memory leak
Fixes a memory leak when a virtual address subscription is added for a
model that either has this VA already, or the model has no more space
for subscription addresses.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-09-12 22:48:20 +03:00
Guillaume Lager
cb91977c48 logging: rtt: Do not retry on error in non blocking mode
Retry in non blocking mode can lead to a quite long (busy) wait.
Refs #28211

Signed-off-by: Guillaume Lager <guillaume.lager@gmail.com>
2020-09-11 09:34:54 -05:00
Vinayak Kariappa Chettimada
c8e23139c1 Bluetooth: controller: Fix addr type in auxiliary PDU
Fix uninitialized transmitter address type being set in the
auxiliary PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-09-10 12:07:57 -05:00
Jukka Rissanen
e15aa4866e net: context: Fix sendmsg() handling in AF_CAN socket
Because the previous commit fixed the destination address check,
we need to handle msghdr (used by sendmsg()) in CAN socket.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-09-10 12:05:48 -05:00
Jukka Rissanen
0c7d2bcd4f net: context: Simplify the param check when sending data
No need to specifically check CAN sockets here. This also means
that SocketCAN will need to support sendmsg() call too. This will
come in following commit.

Fixes #28229

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-09-10 12:05:48 -05:00
Lingao Meng
0023d3f364 Bluetooth: Mesh: Store Krp phase after krp value changed
Store krp phase persistently when this value has been changed.

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2020-09-10 14:12:49 +03:00
Vinayak Kariappa Chettimada
48e791a625 Bluetooth: host: Fix Suggested Default Data Len for QUIRK_NO_AUTO_DLE
Add back call to LE Write Suggested Default Data Length
command so that new connections, receiving Data Length
Update procedure before local device can auto initiate, can
respond with the suggested default data length Tx octets
and Tx time.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-09-10 12:51:27 +02:00
Andrzej Kaczmarek
7a113ea657 Bluetooth: controller: Fix TxAdd setting in auxiliary PDU
When controller is built with extended advertising support but without
LL Privacy build fails due to issue with code that sets TxAdd in aux
PDU:

.../ll_sw/ull_adv_aux.c: In function 'ull_adv_aux_hdr_set_clear':
.../ll_sw/ull_adv_aux.c:502:25: error: 'struct ll_adv_set' has no
                                member named 'own_addr_type'
  502 |   sec_pdu->tx_addr = adv->own_addr_type & 0x1;
      |

We need own_addr_type value if an advertising set with aux but without
AD is created since we cannot get TxAdd value from other PDU.

ull_adv_aux_hdr_set_clear() can now be called with a flag to explicitly
set AdvA field and pass own_addr_type in 'value' parameter. This allows
to set proper TxAdd when creating new advertising set.

On aux updates, we use TxAdd from other PDU:
- if primary PDU has AdvA, we use TxAdd from that PDU
- if previous secundary PDU has AdvA, we use TxAdd from that PDU
In other case we just return an unpsecified error since this should not
happen in any valid scenario.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-09-10 12:40:29 +02:00