Following errors occuring after enabling debug logs:
log: argument 2 in source net_hostname log message "%s: (%s): \
Hostname set to %s" missinglog_strdup().
log: argument 2 in source net_hostname log message "%s: (%s): \
New hostname %s" missinglog_strdup().
Fix that by printing CONFIG_NET_HOSTNAME directly in the first case and
using log_strdup() in the second.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
If user has enabled TCP debugging, print detailed internal TCP2
information too when user gives "net conn" command. This is useful
to have when debugging.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Comment out TCP1 specific stuff when TCP2 is enabled. This means
shuffling the code around a bit so that common code is placed at
the end. Introduce also net_tcp_foreach() function to TCP2 so that
it can be used from net-shell.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The data length is already calculated in tcp_in() so no need
to do it again in tcp_data_get(). Just pass the length to the
tcp_data_get() function.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This change enables support for DNS service discovery
(RFC 6763) in the mdns_responder service and sample app.
Fixes#29429
Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
This change adds support for DNS Service Discovery (DNS-SD)
as described in RFC 6763.
Fixes#29099
Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
This change adds net_context_port_in_use(), which is a simple
wrapper around net_context_check_port() and is used to check
if a particular socket is bound to a given IP address.
Fixes#29649
Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
Do not send the original pkt in 6lo based networks as in those
the IPv6 header is mangled and we would not be able to do any
resends of the original pkt. So for 6lo networks, clone the
pkt and send it to peer. The original pkt is kept in sent list
in case we need to resend to peer.
Fixes#29771
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Track the number of dropped TCP data segments and number of dropped
TCP packets in network statistics. It is useful to see these
numbers separately.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Add a simple backoff mechanism between consecutive registration attempts
in case of registration failures. Finally, notify the application in
case the registration failed several times.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Refactor the boostrap regstration procedure, by splitting the message
creation and sending into a separate function, in similar manner as
it's done with regular registration.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Currently, when socket errors occur during receive, the LwM2M engine
restarts the state machine and registers again to the server. While this
works in simple use case (only RD client socket open), it's not a valid
approach when more sockets are open (FW update socket).
Fix this by introducing socket fault callback, which is registered by
the LwM2M engine users. This way, a proper socket owner is notified on
error and can pertake appropriate action.
For RD socket errors the behaviour remains the same - the state machine
is reset and the client registers again to the server. For FW update
socket, handle the error by reopening the socket and retransmitting the
last request. This allows to resume the download from the point the
error occured, w/o a need to start from scratch.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Call mbedtls_ssl_conf_max_frag_len() on created TLS context
configuration, so that Maximum Fragment Length (MFL) will be sent to
peer using RFC 6066 max_fragment_length extension. MFL value is
automatically chosen based on MBEDTLS_SSL_OUT_CONTENT_LEN and
MBEDTLS_SSL_IN_CONTENT_LEN mbed TLS macros.
This extension is mostly useful for TLS client side to tell TLS server
what is the maximum supported receive record length.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
This commit corrects the maximum allowed amount of children to
match Thread specification.
Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
If the peer ACKs data when it closes the connection, update
our sequence number accordinly. The connection would eventually
be terminated but this will avoid extra resends by the peer.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
When a connection is being closed, it is possible that the application
will have a lock to net_context and TCP2 connection lock. If we then
receive a final TCP2 ACK and close the connection, the locking order
get switched and TCP2 will first try to get its own lock and then the
net_context lock. This will lead to deadlock as the locking ordering
is now mixed.
The solution is to unref the TCP connection after releasing the
connection lock. The TCP connection unref function will anyway get the
lock so no need to do double locking.
Fixes#29444
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If there are enough tls_context objects in the system (configured by
CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS), but there are not enough file
descriptors (configured by CONFIG_POSIX_MAX_FDS) to create underneath
TCP/UDP socket, then TLS socket creation fails with leaked tls_context.
Call tls_release() in ztls_socket() error path whenever underneath
TCP/UDP socket creation fails.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
According to LwM2M specfication v1.0.2, par. 5.3.2, the LwM2M client
MUST send an “Update” operation to the LwM2M Server whenever the
lifetime parameter of the Server object changes the server). The same
applies for the object instances created/deleted. The changes in objects
seem to already be handled, but the lifetime was not.
Additionally, the "Update" message shall only contain these parameters
which changed since the last update (including objects). As it's
straightforward to determine if the liftime changed but it's not easy
to tell if there were updates in the object instances, add an
additional parameter to the engine_trigger_update() function, indicating
that new object information shall be sent in the "Update" message.
Eventually add a proper error checking in `sm_send_registration` as the
function is reworked anyway.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The memset on firmware_ctx during PULL FW update initialization will
set the socket descriptor to a valid value of 0. This leads to an error
if parsing of the URI provided by the server fails, and the firware_ctx
is closed - the socket with a descriptor 0 will be accidently closed.
Fix this by invalidating the socket FD after the memset on
initialization.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
It shouldn't be optional to handle separate response, as it's a
mandatory requirement according to the RFC7252:
"The protocol leaves the decision whether to
piggyback a response or not (i.e., send a separate response) to
the server. The client MUST be prepared to receive either."
Therefore, remove the flag as separate responses are handled now
properly.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Separate response handling implemented in the engine was faulty. The
separate response was not acknowledged by the client, resulting in
spurious retransmissions from the server side.
Also, the pending CON message was retransmitted by the client even after
it was acknowledged by an empty ACK, but the respnse haven't arrived
yet. Fix this by adding a new `acknowledged` flag to the `lwm2m_message`
structure. Once acknowledged, the flag is set and the confirmable
message is no longer retransmitted. We keep the message on the pending
list in order to timeout properly in case separate response does not
arrive in time.
Finally, prevent the reply callback from being called twice in case
the response is transmitted separately from ACk. The callback should
only be called on the actual reply, not the empty ACK.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
So far this function existed as a static function in LwM2M PULL FOTA
module. Since such functionality will be needed in other places, make it
an internal API function.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
using CONFIG_NET_BUF_POOL_USAGE monitor avail_count,
this variable should be protect.
Protecting it by using atomic variable
Signed-off-by: Ehud Naim <ehudn@marvell.com>
Some LWM2M backends/servers, such as emxq, expect the sequence numbers
to begin on 0.
This change is in line with how other lwm2m clients, such as Anjay and
Wakama, starts the notification sequence.
Signed-off-by: Viktor Sjölind <viktor.sjolind@endian.se>
The commit 93e5181f ("net: context: Add locking for concurrent
access") added net_context locking to only IPv4 sockets.
That is not enough and we need locking also to other supported
socket address families like IPv6, SocketCAN and packet socket.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Prior to this commit, the LwM2M stack would TLV-encode integers
depending on their internal storage size. An integer with value 5 stored
in an int8_t would be encoded with length 1, but an integer stored in an
int32_t would be encoded as "00 00 00 05" with length 4.
This commit checks if the value is castable to a smaller int and encodes
it as such if so. This is cascading, so even a 64 bit integer with value
5 will be encoded with length 1.
Note that this does not seem to be required by the specification, but
this is how Anjay and the other LwM2M stack seem to do it.
Signed-off-by: Benjamin Lindqvist <benjamin.lindqvist@endian.se>
When we are sending ICMPv6 error message, we need to store the
link local addresses of the received packet somewhere in order
to know where to send the new error message.
Easiest is to store the ll addresses is to the error message
itself, just before where the sent packet will start in memory.
We cannot use the original pkt to store the ll addresses
as that packet might get overwritten if we receive lot of packets.
Fixes#29398
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Currently, there is a case for net_config_init function that for
timeout==0 and when iface is already up, the ip setup is not proceed
and the error message "Timeout while waiting network..." is logged.
This commit fixes it.
Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
Adds the socket option TLS_ALPN_LIST for SOL_TLS sockets
Passes the configured alpn list to the mbedtls config
on mbedtls init
Signed-off-by: Emil Hammarstrom <emil.hammarstrom@assaabloy.com>
If we are sending data directly, we already have TCP lock so
there is no need to do any locking. But when data is re-sent,
the work queue handler is doing the sending so we need to lock
the TCP connection.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
When receiving data that needs to be passed the data to application,
queue it for short time so that we do not have TCP connection lock
held. This way if the application wants to send data, there is no
possibility that the connection lock would prevent sending data.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Release the context lock before passing data to the application
socket as that might cause deadlock if the application is run
before the RX thread and it starts to send data and if the RX
thread is never able to run (because of priorities etc).
Fixes#29347
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
These defines are leftover of old platform settings implementation
and are not used any more.
Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
net_icmp4_input() may net_pkt_unref() a packet. The header mustn't be
accessed after this or the system may crash.
Signed-off-by: Oliver Hitz <oliver@net-track.ch>
Existing openthread_api_mutex_lock()/unlock() functions are
crucial to assure thread safety of an application which
needs to use OT API directly, but some applications may also
require a non-blocking version of the former for less critical
OT-related tasks.
Add openthread_api_mutex_try_lock() which never waits and
exits immediately if the mutex is held by another thread.
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
If there are more than one RX or TX threads, then make the name
of each of them unique so that it is easier to figure them out
in "kernel stacks" command.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The name of the connection manager thread (conn_mgr_thread) was
unnecessarily long in "kernel stacks" command. So make the name
to "conn_mgr" which fits nicely to the output of that command.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
If an address was obtained by IPCP, it should always be removed in
ipcp_down(). This commit replaces the predicate with something slightly
more robust.
Signed-off-by: Benjamin Lindqvist <benjamin.lindqvist@endian.se>
Windows 10 sends ECN-Echo and Congestion Window Reduced (CWR) flags
together with SYN flag in the connection establishment but the code
did not ignore these flags and send just SYN back (instead of SYN|ACK).
This caused the connection establishement in application level to
fail as the application was never notified about it.
Fixes#29258
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>