If we couldn't send all (or any data) via the socket,
invoke poll instead of blindly retrying and flooding the socket.
Respect timeout through http_client_req
Signed-off-by: Andrey Dodonov <Andrey.Dodonov@endress.com>
If CONFIG_NET_MGMT_EVENT_DIRECT is enabled and CONFIG_NET_MGMT_EVENT_INFO
disabled it does not build because mgmt_push_event writes to non existing
struct members
Signed-off-by: Benjamin Bigler <benjamin.bigler@securiton.ch>
Fix system workqueue block caused by mgmt_event_work_handler
when CONFIG_NET_MGMT_EVENT_SYSTEM_WORKQUEUE is enabled.
Signed-off-by: Benjamin Bigler <benjamin.bigler@securiton.ch>
Some public API functions do not modify the net_buf instances and can
declare these arguments as const.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
In case underlying TCP/TLS connection is already down, the
websocket_disconnect() call is expected to fail, as it involves
communication. Therefore, mqtt_client_websocket_disconnect() should not
quit early in such cases, as it could lead to an underlying socket leak.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This reverts commit 93973e2ead.
PR #73978 introduced a regression.
Unfortunately this PR cannot be reverted without reverting also
Let's revert both PRs to stabilize main again towards the 3.7 release.
For more details on the issue see
https://github.com/zephyrproject-rtos/zephyr/issues/75205
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This reverts commit 49ac1912b2.
PR #73978 introduced a regression.
Unfortunately this PR cannot be reverted without reverting also
Let's revert both PRs to stabilize main again towards the 3.7 release.
For more details on the issue see
https://github.com/zephyrproject-rtos/zephyr/issues/75205
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Make sure to check return values of mbedtls hmac APIs so that
the digest is calculated properly.
Fixes#75259Fixes#75260Fixes#75261
Coverity-CID: 366271
Coverity-CID: 366277
Coverify-CID: 366279
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If we have configured the DNS dispatcher to be only as a
responder but receive a query response, or if we are only
as a resolver but receive a query, then the dispatcher just
ignores the packet and returns -ENOENT.
Unfortunately we print an error message in this case
[00:10:18.818,000] <err> net_dns_dispatcher: DNS recv error (-2)
which is totally unnecessary and causes confusion so do not
print an error message in this case.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add cast to NSEC_PER_SEC macro to correctly check offset.
Prior to this commit, the would eval to true incorrectly.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The sscanf() is not available for minimal libc so it cannot be used.
Use the net_bytes_from_str() that is provided for this purposes.
Fixes#75029
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
In case of thread failure, fix the registrations by properly managing
the synchronization i.e. use conditional wait only if thread is being
initialized or will be initialized, else check for success or failure
without waiting for conditional variables.
Fixes#73523.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Removed the declaration and assignment of `eth_ctx` variable from
`net_if_get_wifi_sta` and `net_if_get_wifi_sap` functions since
it was not being used.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Delay an ACK in case no PSH flag is present in the data packet. as
described in RFC 813. This allows to reduce the number of ACK packets
we send and thus improve the TCP download throughput.
The results achieved on `nucleo_h723zg` board and the zperf sample
are as follows:
Before: 77.14 Mbps
After: 93.14 Mbps
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Move the implementation of zsock_select() to zvfs_select(). This
allows other types of file descriptors to also make use of
select() functionality even when the network subsystem is not
enabled.
Additionally, it partially removes a dependency cycle between
posix and networking by moving functionality into a mutual
dependency.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Move the implementation of zsock_poll to zvfs_poll. This allows
other types of file descriptors to also make use of poll()
functionality even when the network subsystem is not enabled.
Additionally, it partially removes a dependency cycle between
posix and networking by moving functionality into a mutual
dependency.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
OpenThread interfaces were not considered when default interface name
is assigned, so they ended up with a generic "netX" name. Since it
useful to have an option to identify interface easily by name, assign an
unique "threadX" name for OpenThread interfaces, just like it's done for
other interface types.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Mask the DNS_CLASS_FLUSH value when checking if the DNS_CLASS_IN
is set when unpacking a query.
Fixes#74829
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Coverity reported that a formula used to calculate the next expected
block in case the block size from the request differs our own block size
has a bug. The expression used to calculate the block size diff would
evaluate to an unsigned integer, giving (wrongly) enormous results in
case block size from the request is smaller than the Zephyr's default.
It turns out however, that this formula is no longer needed at all.
Since commit d3081e2f30, Zephyr's LwM2M
implementation will no longer negotiate the block size in case of write
operation, but simply comply with the block size included in the
request. This means that calculating the diff makes no longer sense and
can be safely removed - the next expected block number should be simply
increased by 1.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case packet read fails for any reason, there's no point proceeding or
printing the byte, just break the loop in such case.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
vec->iov_len is of type size_t, so the comparison was always true.
Additionally, doing the memcpy() when iov_len was 0 did not really make
sense, so do it only when the actual length is larger than 0.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
For each of the fdtable.h functions listed below, convert the
z_ prefixed semi-private functions to use the zvfs_ prefix.
ZVFS stands for Zephyr Virtual File System and
is intended to be a common library used by the C library,
POSIX API, Networking, Filesystem, and other areas.
There are already a few functions in fdtable.h that use the
zvfs_ prefix, so this change is mostly about unifying them in
a way that uses a suitable prefix ("namespace") so that it can
be considered a public API.
- z_alloc_fd
- z_fdtable_call_ioctl
- z_finalize_fd
- z_finalize_typed_fd
- z_free_fd
- z_get_fd_obj
- z_get_fd_obj_and_vtable
- z_get_obj_lock_and_cond
- z_reserve_fd
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Partial conditional compilation within tcpv4/6_init_isn() caused
errors in coverity, as hash variable seemed to be used w/o
initialization.
As those functions are not really used at all if
CONFIG_NET_TCP_ISN_RFC6528 is disabled, we can just conditionally
compile entire functions to avoid confusion.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within the `subsys/net/ip` directory.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Add a note about the thread priority requirements in the help string of
the Kconfig option enabling net_mgmt sockets.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The minimum length for the network interface buffer is 2 so that we
can have terminating null there.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The network interface name that is copied to if_req struct might
be missing terminating null.
Fixes#74795
Coverity-CID: 368797
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The zsock_close() is not needed as the fd is always <0 so
the close is never called.
Fixes#74791
Coverity-CID: 366273
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Tests showed that mDNS responder needs slightly more stack on certain
platforms, hence increase the default for such case.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
A few issues were identified with DNS_SD segment buffers, making it work
"by chance" (depending on memory layout):
- size check in dns_sd_query_extract() did not take NULL termination
into account, and in result could overflow provided buffer
- the proto_buf in send_sd_response() can either be used to parse
protocol or domain, depending on number of segments in the query.
It should therefore be large enough to hold either.
- Similarily, instance_buf should be able to hold
DNS_SD_INSTANCE_MAX_SIZE, not DNS_SD_SERVICE_MAX_SIZE.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The family variable was not initialized and could potentially
be left like that. This could only affect error printout.
Fixes#74796
Coverity-CID: 368799
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This file uses strnlen() but the C library
is not require to expose its prototype unless
_POSIX_C_SOURCE is defined.
So let's define it to avoid an implicit function
declaration warning.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
In case of TCP upload error, zperf would leak a socket when running in
asynchronous mode. The upload work have to release the socket it
allocated in any case, regardless of the session result.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
During socket setup, if one of the setsockopt() calls failed, the
function would return an error w/o closing the socket. That's wrong, as
in case of errors the function should clean up any resources it
allocated, the socket file descriptor is lost otherwise and resources
are leaked.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
We should return the errno value in such case, as ret will always be -1
on failure, which might misleading, as it does not give any hint on what
failed.
Also bump the log level of the error message, so the failure is visible
w/o needing to enable debug logs. Such a failure is fatal for the DNS
subsystem, so error level is justified here.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The `dns_data` buffer, allocated by the DNS dispatcher was dereferenced
twice - once in registered DNS handler, second time in the dispatcher
itself.
Since the buffer was allocated by the dispatcher, and it's not really
guaranteed that the buffer will be freed in the registered handler (this
depends on the processing outcome, the function may return early w/o
freeing the net buf in case of errors), it makes most sense for the
dispatcher to keep ownership of the buffer. Hence, the registered
handlers will no longer release the buffer provided in any case, and the
dispatcher will free it on exit.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In ethernet_recv(), it will call ethernet_update_length() to check for
ipv4 or ipv6 packet if it needs to get rid of the padding in the
packets. But for EAPOL packets, no need to do this, which may modify
the packet length of EAP type packet wrongly and leads to EAPoL
packets dropped in supplicant.
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
Split wifi interface into station mode and soft-AP mode, as there may be
station and soft-AP two interfaces that work concurrently.
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
Generally, we should avoid using reserved names in global
contexts.
subsys/net/lib/ptp/clock.c:58:25: \
error: 'clock' redeclared as different kind of symbol
58 | static struct ptp_clock clock = { 0 };
/opt/toolchains/zephyr-sdk-0.16.8/arm-zephyr-eabi/picolibc/ \
include/time.h💯12: \
note: previous declaration of 'clock' with type 'clock_t(void)' \
{aka 'long unsigned int(void)'}
100 | clock_t clock (void);
subsys/net/lib/ptp/clock.c:58:25: \
error: 'clock' defined but not used [-Werror=unused-variable]
58 | static struct ptp_clock clock = { 0 };
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>