If mDNS resolver is enabled but mDNS responder is not, then
mDNS multicast address group is not joined. This would prevent
the mDNS resolver to receive the responses. Fix this by
joining the mDNS multicast group if mDNS responder is not
enabled (because the responder will join the group itself).
Fixes#86477
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
There is a deadlock issue when calling stop using address conflict
detection. This is due to the fact that some net_mgmt events are fired
and trigger the dhcpv4_acd_event_handler() with lock held even if they
are of no interest for this callback.
Therefore, before acquiring the lock, make sure the event we received
is one we are expecting.
Also, do the same for dhcpv4_iface_event_handler().
Signed-off-by: Mathieu Anquetin <mathieu.anquetin@groupe-cahors.com>
Add compression support using the accept-encoding
header to the http server static filesystem resource.
Signed-off-by: Carlo Kirchmeier <carlo.kirchmeier@zuehlke.com>
http_server_http2.c does not guard check if file system is available
or not before using file system api. This PR will add guard for that
Signed-off-by: bac phan <phanhaibac98@gmail.com>
Rename this driver to eth_native_tap, including renaming all its
options.
The old options remain until v4.4, but as deprecated.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
The CONFIG_POSIX_C_LIB_EXT will get support for fnmatch() function.
The old CONFIG_FNMATCH is deprecated.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
When we receive piggybacked Ack, it means that we have
received all information for this request.
There is no need to track exchange lifetime anymore.
Once we reset the internal request, it is free to be used
for the application. So if we only have few requests allocated,
it would be slow to send those as get_free_request() only
gives request structures that don't have a lifetime left.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
- Add possibility to choose implementation of OpenThread L2 and
set it to Zephyr's by default
- Remove unused `OPENTHREAD_SECURITY_INTERNAL` Kconfig
- Add missing choice names for logging and coprocessor
Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
Use the newly added timeout in various send functions from within
net_context_sendto.
Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
Allows to send with different timeouts to not block caller in some
situations. Stable API is kept and just calls `try`-variant with a timeout
of `K_FOREVER`.
Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
The coap_client has a static/internal function, has_ongoing_exchange(),
which can be an useful addition to the public API. This would provide
a mechanism to determine when it is safe to close a socket gracefully.
Signed-off-by: Povilas Selevicius <povilas.selevicius@quadigi.com>
Add a variant of the SNTP API that does not block while waiting for a
response from the SNTP server. Instead it takes advantage of
`CONFIG_NET_SOCKETS_SERVICE` to read the response asynchronously when
the response is received.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Extract the SNTP query send logic out of `sntp_query` so that it can be
used by functions that don't synchronously wait for the response.
Signed-off-by: Jordan Yates <jordan@embeint.com>
When a TCP connection is refused during zsock_connect, errno is set
to -ENOTCONN, but errno should be set to -ECONNREFUSED. This change
causes the ECONNREFUSED status to be propagated from tcp_in to
net_tcp_connect, which eventually causes errno to be set
to -ECONNREFUSED.
Signed-off-by: Noah Olson <noah@wavelynx.com>
The root cause of this issue is a modification of `struct ring_buf` in
3075a7d9. Even though all the fields of the struct are marked as
internal, the LwM2M code is using some of them to roll back the state of
the ring buffer on failure.
Signed-off-by: Etienne de Maricourt <edmecomemail@gmail.com>
In order to avoid any mutex deadlocks between iface->lock and
TX lock, release the interface lock before calling a function
that will acquire TX lock. See previous commit for similar issue
in RS timer handling. So here we create a separate list of ACD
addresses that are to be started when network interface comes up
without iface->lock held.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
In order to avoid any mutex deadlocks between iface->lock and
TX lock, release the interface lock before calling a function
that will acquire TX lock. See previous commit for similar issue
in RS timer handling. So here we create a separate list of multicast
addresses that are to be rejoined when network interface comes up
and then rejoin the groups without iface->lock held.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
In order to avoid any mutex deadlocks between iface->lock and
TX lock, release the interface lock before calling a function
that will acquire TX lock. See previous commit for similar issue
in RS timer handling.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The net_if.c:rs_timeout() is sending a new IPv6 router solicitation
message to network by calling net_if_start_rs(). That function will
then acquire iface->lock and call net_ipv6_start_rs() which will try
to send the RS message and acquire TX send lock.
During this RS send, we might receive TCP data that could try to
send an ack to peer. This will then in turn cause also TX lock
to be acquired. Depending on timing, the lock ordering between
rx thread and system workq might mix which could lead to deadlock.
Fix this issue by releasing the iface->lock before starting the
RS sending process. The net_if_start_rs() does not really need to
keep the interface lock for a long time as it is the only one sending
the RS message.
Fixes#86499
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Fix handling of poll setting socket error flag.
In this case errno is no set, so should not be the return value either.
Instead retrieve the socket error for SOCKERR and return EBADF for
SOCKNVAL.
Signed-off-by: Joakim Andersson <joerchan@gmail.com>
Queueing packets should be possible from the ISR context, recent changes
prevented that. Therefore add extra checks in
net_tc_submit_to_tx/rx_queue() to make them ISR friendly again.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Building with clang warns:
subsys/net/l2/ethernet/ethernet.c:178:18: error: unused function
'ethernet_check_ipv4_bcast_addr' [-Werror,-Wunused-function]
enum net_verdict ethernet_check_ipv4_bcast_addr(struct net_pkt *pkt,
^
ethernet_check_ipv4_bcast_addr is called by ethernet_ip_recv, which only
exists when CONFIG_NET_IPV4 or CONFIG_NET_IPV6 is defined.
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
The ARP protocol handler cannot directly access the Ethernet header
because the caller has removed the header already when the handler
is called. So change net_arp_input() and pass source and destination
MAC address there instead of bogus pointer that was pointing to ARP
header instead of Ethernet header. This requires changes to ARP tests.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
When run the Zperf UDP throughput with '-a' (Asynchronous call),
zperf_work_q thread will generate and send the packets to tx_q thread.
When zperf_work_q and tx_q threads have same priority, if zperf_work_q
fails to take the semaphore of fifo_slot, it will not wait and directly
drop the net_pkt. Then it will allocate new net_pkt, repeat, and always
occupy the CPU, which leads to extreme low throughput.
For TX, when take the semaphore of fifo_slot, setting a wait time of
K_FOREVER to let other thread to process and free these packets.
For RX, when failed to take the semaphore of fifo_slot, yield the CPU
to let the thread of data path with same priority to run to reduce
dropping packets.
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
In rare occasions when sending DAD NS packet fails, we should still
setup the DAD timer, unless we implement some kind of more advanced
retry mechanism. If we don't do that, the IPv6 address added to the
interface will never be usable in such cases.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
DAD creates an entry in the neighbor cache for the queried (own)
address. In case the address is removed from the interface while DAD is
still incomplete, we need to remove the corresponding cache entry (just
like in case of DAD timeout) to avoid stale entries in the cache.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Calling coap_client_cancel_requests() clears the internal request
context only for active requests (i. e. not replied yet). However,
if there are any pending request context monitoring ACK duplicates,
those would still make the corresponding client socket being monitored
by poll(). In result, when application closes the socket, the polling
thread will throw POLLNVAL error for the socket.
Fix this, by resetting all request contexts unconditionally. The request
callback will only be called for the active requests.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Remove the CONFIG_WIFI_NM_WPA_SUPPLICANT_WNM macro in L2 shell level
to make 11v BTM query support embedded supplicant.
Signed-off-by: Rex Chen <rex.chen_1@nxp.com>
According to RFC 4861, ch. 7.2.5:
"If the Override flag is set, or the supplied link-layer address
is the same as that in the cache, or no Target Link-Layer Address
option was supplied, the received advertisement MUST update the
Neighbor Cache entry as follows
...
If the Solicited flag is set, the state of the entry MUST be
set to REACHABLE"
This indicates that Target Link-Layer Address option does not need to be
present in the received solicited Neighbor Advertisement to confirm
reachability. Therefore remove `tllao_offset` variable check from the
if condition responsible for updating cache entry. No further changes in
the logic are required because if TLLA option is missing,
`lladdr_changed` will be set to false, so no LL address will be updated.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
According to RFC 4861, ch. 7.3.3:
"Upon entering the PROBE state, a node sends a unicast Neighbor
Solicitation message to the neighbor using the cached link-layer
address."
Zephyr's implementation was not compliant with behavior, as instead of
sending a unicast probe for reachability confirmation, it was sending a
multicast packet instead. This commit fixes it.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
When Router Advertisement with Source Link-Layer Address option is
received, host should register a new neighbor marked as STALE
(RFC 4861, ch. 6.3.4). This behavior was broken however, because
we always added a new neighbor in INCOMPLETE state before processing
SLLA option. In result, the entry was not updated to the STALE state,
and a redundant Neighbor Solicitation was sent.
Fix this by moving the code responsible for adding neighbor in
INCOMPLETE state after options processing, and only as a fallback
behavior if the SLLA option was not present.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This condition can happen if there is MDNS activity on the network that is
either not according to specifications or not supported by Zephyr.
Lowering the log level from ERR to DBG, since this does not indicate an
error in the Zephyr application.
Signed-off-by: Helge Juul <helge@fastmail.com>
We need to make sure that within Zephyr different users of the PSA APIs
don't interfere with each other because of using the same numerical IDs
for persistent assets.
This takes care of the PSA key IDs when using persistent keys through
the PSA Crypto API.
See the comments in `<zephyr/psa/key_ids.h>` for more information.
This removes the recently-introduced Kconfig options that allowed changing
the base IDs subsystems were using for their persistent keys.
Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
Implement support for DNS Recursive Name option and use obtained
information to configure DNS resolver.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
There's nothing in RFC 2131 or RFC 8415 that would mandate the DHCP
server to reply with a source port set to the IANA assigned one, and
some servers seem to send responses with some arbitrary source port set.
Therefore, make Zephyr's DHCP client implementation more permissive,
accepting packets with a source port set to a different port than the
IANA assigned server port.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In ap enable cmd, channel set to 0 means ACS mode.
Remove hostapd AP macro for this case to make ACS mode
available for public usage.
Signed-off-by: Fengming Ye <frank.ye@nxp.com>
When writing to a time resource, the logic was incorrect when validation
was enabled for the resource - when determining the actual underlying data
type we should compare against the data buffer length and not the
validation buffer length.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
If an IP address already exists when it is tried to be added to the
network interface, then just return it but update ref count if it was
not updated. This could happen if the address was added and then removed,
but for example an active connection was still using it and keeping the
ref count > 0. In this case we must update the ref count so that the IP
address is not removed if the connection is closed.
Fixes#85380
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The mDNS probing is described in RFC 6762 chapter 8.1.
The code will send an unsolicited mDNS query to network and
will check if there are existing hosts with the same name.
If there are, then the mDNS responder will not respond to
queries it is configured to use.
Fixes#84333
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Allow user to specify the network interface where the query should
be sent, but only if the user has supplied the DNS servers in sockaddr
list. If user has specified a DNS servers in a string list, then the
possible network interface is taken from the string.
The reason for this is that it is not possible to add network interface
to the sockaddr list so an extra parameter is needed.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Allow user to specify socket service struct and port number so
that DNS servers specified in Kconfig etc are not used. This way
we can send a DNS query to arbitrary address without it affecting
the system configuration.
This is used in mDNS probing so that that mDNS responder can send
probe message and not change / configure system global DNS config.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Introduce dns_resolve_name_internal() that allows resolving a name
and not use DNS cache if caching is enabled.
This is needed in mDNS probing (RFC 6762 chapter 8.1) which needs
to send a mDNS query and not get any results from cache.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>