Resetting the connect semaphore from tcp_conn_unref() prevents the
ref/unref mechanism from being used freely when needed. Therefore, move
the code responsible for resetting pending connection to
tcp_conn_close() (called only when the connection is being closed on
behalf of the TCP stack, for instance due to RST being received) and to
net_tcp_put() (connection closed on behalf of the application).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
It is possible that TCP connect() will fail if for example network
interface does not have IP address set. In this case we close
the connection during net_tcp_connect() but do not set the return
code properly. This looks in the application like the connection
succeeded even if it was not.
As the tcp_in() call in net_tcp_connect() might close the connection,
we just take extra ref count while calling tcp_in(). Otherwise we
might access already freed connection.
Before the fix:
net_tcp_connect: context: 0x80757c0, local: 0.0.0.0, remote: 192.0.2.2
net_tcp_connect: conn: 0x8087320 src: 0.0.0.0, dst: 192.0.2.2
tcp_in: [LISTEN Seq=1604170158 Ack=0]
tcp_conn_close_debug: conn: 0x8087320 closed by TCP stack (tcp_in():3626)
tcp_conn_close_debug: LISTEN->CLOSED
tcp_conn_unref: conn: 0x8087320, ref_count=1
net_tcp_connect: conn: 0x8087320, ret=0
After the fix:
net_tcp_connect: context: 0x80757c0, local: 0.0.0.0, remote: 192.0.2.2
net_tcp_connect: conn: 0x8087320 src: 0.0.0.0, dst: 192.0.2.2
tcp_conn_ref: conn: 0x8087320, ref_count: 2
tcp_in: [LISTEN Seq=1604170158 Ack=0]
tcp_conn_close_debug: conn: 0x8087320 closed by TCP stack (tcp_in():3626)
tcp_conn_close_debug: LISTEN->CLOSED
tcp_conn_unref: conn: 0x8087320, ref_count=2
net_tcp: tcp_conn_unref: conn: 0x8087320, ref_count=1
net_tcp: net_tcp_connect: conn: 0x8087320, ret=-128
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The IPv6 branch of net_tcp_endpoint_copy() was accidentally made
conditional on CONFIG_NET_IPV4 rather than CONFIG_NET_IPV6.
Signed-off-by: Ben Wolsieffer <benwolsieffer@gmail.com>
Evaluate CONFIG_LINKER_ITERABLE_SUBALIGN in CMake instead of in the
linker script.
It cannot be assumed that a linker generator implementation is
pre-processed and therefore Kconfig settings cannot be used in those
but must be evaluated in CMake.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
If DNS statistics is enabled in Kconfig, then start to collect it.
This is useful in order to see how many DNS requests/responses
received or sent, and also see the amount of dropped DNS packets.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The size_t type may vary from machines. Current snprintk code was
causing below build issue on arm64.
error: format '%x' expects argument of type 'unsigned int', but argument
4 has type 'size_t' {aka 'long unsigned int'} [-Werror=format=].
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
In order to reduce confusion regarding interface count
the respective warning was adjusted to better reflect
the actual state of the system.
Signed-off-by: Carlo Kirchmeier <carlo.kirchmeier@zuehlke.com>
Make sure we check the checksum offloading capabilities correctly
for VLAN interfaces. Use the real Ethernet interface when doing the
check.
Fixes#78724
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
User can set CONFIG_NET_SHELL_SHOW_DISABLED_COMMANDS=n to prevent
unused net-shell commands from showing. This can save flash as
the disabled commands will not be shown in net-shell listing.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
It is useful to know the currect status of DHCPv6 client when
printing the interface information.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Allow "net virtual" command to attach or detach virtual
interfaces. This is useful for device management.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
It shouldn't be needed to enable native networking to be able to
add/delete IP addresses on network interfaces.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
IPv4 Kconfig options which only affect native IPv4 stack should be
dependent on NET_NATIVE_IPV4, similarly as it's done for IPv6.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
After introduction of struct http_response_ctx, the dynamic resource
data buffer is no longer needed for transferring data between the
application callback and the server. It is therefore removed to avoid
unnecessary copying of data.
Signed-off-by: Matt Rodgers <mrodgers@witekio.com>
Add tests covering new method of providing a response for dynamic
resources.
Tests cover the application sending response codes and headers,
overriding "default" headers, and sending various combinations of
headers and body data. Each case is tested for HTTP1 & HTTP2, both POST
and GET methods.
Signed-off-by: Matt Rodgers <mrodgers@witekio.com>
Allow the application to send headers and response codes from a dynamic
resource callback by filling out a response context structure.
This also allows simple requests to be completed in a single execution
of the callback, by setting the final_chunk flag.
Signed-off-by: Matt Rodgers <mrodgers@witekio.com>
Running IPv6 on STM32H743 using eth_stm32_hal I had to extend
the timeout between the attempts to send Router Solicitation packets
from 1 second to 2 seconds. Else it looked liked the packet never
got sent (checked using tcpdump).
Signed-off-by: Stefan Petersen <spe@ciellt.se>
For code clarity, this commit adjusts the use of `return` statements
in functions with a void return type as follows:
- Transform `return foo();` into separate statements:
`foo();`
`return;`
- Remove unnecessary `return` statements when
they don't affect control flow.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
For code clarity, unified switch-case usage in `dhcpv6_enter_state` to
use `break` instead of `return`.
Typically, a `break` is used in switch-case statements unless an early
return is necessary, in which case `return` is appropriate.
In this scenario, the `break` statement is the more suitable choice.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Ensure that the output certificates directory is created, where
generated certificates will be placed. This fixes a build error seen
when using `make` to build samples/net/wifi for the rd_rw612_bga board,
where the output directory for generated certificates did not exist at
build time.
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
The L2 function `ieee802154_decipher_data_frame()` relied on upper layer
LL address fields which breaks encapsulation.
Also fixes a bug introduced in another fix that went overboard (#53734).
Fixes: #78490
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Found a few variable declarations that were not yet moved to the top of
the function/block. Doing this before actually fixing #78490 so that the
fix becomes more readable.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
When an incoming PAN ID does not match or when an error occurs while
sending association requests, then locks were not properly released.
Fixes: #78495
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
In case peer goes down or we disconnect from the network during the
TLS handshake, the TLS socket may block indefinitely during
connect()/accept(), waiting for data from the peer. This should be
avoided, hence use the preconfigured timeout for the TLS handshake,
same as we use for TCP-level handshake.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Deadloop happens when CONFIG_NET_ROUTING and VLAN are enabled.
In function net_ipv6_prepare_for_send(), pkt->iface will be
updated with net_pkt_set_iface(pkt, iface) in 2 scenarios:
1. ip_hdr->dst is onlink
2. check_route or nbr_lookup
VLAN is virtual-iface which attaches to a physical-iface. Each
time a packet being sent to a VLAN port will invoke twice of
the net_send_data(). The 1st time, pkt->iface is set to virtual
iface and the 2nd time to physical iface.
However in above 2 scenarios, at the 2nd time of calling the
net_send_data(), the pkt-iface will be changed back to virtual
iface. The system runs into a deadloop. This can be proved by
enabling CONFIG_NET_ROUTING with the VLAN sample.
The main purpose for net_ipv6_prepare_for_send() is to set the
right ll_dst address. If the ll_dst address is already set, then
no need to go through it again. If the packet has done with the
forwarding and set the ll_dst, then no need to check_route again.
And, the pkt->iface will not be changed back to virtual iface.
Fixes: #77402
Signed-off-by: Shrek Wang <shrek.wang@nxp.com>
Increased variable to the mandatory amount of commands, since the
comment of SHELL_SUBCMD_ADD states
"Number of mandatory arguments including command name"
but net suspend takes the interface number to suspend
Signed-off-by: Emil Lindqvist <emil@lindq.gr>
For composite operations, we should always check whether the TLV header
is present. Otherwise, all blocks are assigned to one resource.
Signed-off-by: Simon Walz <simon.walz@autosen.com>
The Block1 context for composite operations is not found, as all path
levels are compared. The incoming path level should therefore always be
taken into account.
Signed-off-by: Simon Walz <simon.walz@autosen.com>
When using sendmsg() and if CONFIG_NET_IPV4_MAPPING_TO_IPV6 is
enabled, then the addr4 variable was set too late which was causing
null pointer access.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
GCC complains about struct sockaddr accesses due to the various
address-family-specific variants being of differing sizes. Let's not
mess with code (which looks correct), just silence the compiler.
Signed-off-by: Keith Packard <keithp@keithp.com>
We do not need promiscuous mode setting in host side when testing
bridging with native-sim, so just ignore errors in this case.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
According to Mbed TLS changelog this feature was set default ON
since 3.1.0 release, so the build symbol is no more available.
This commit removes it from Zephyr.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
this adds the option to have the clock periodically resynced with
the time from the sntp server, instead of just syncing at startup.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
If the dispatcher is muxing the connection i.e., so there are two
services for the same port, then mark service socket descriptor
of the service with the socket number so that "net sockets" shell
command can show a proper value for it.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The socket services API has a limitation where the user data is shared
between file descriptors described in the same service.
This can cause problem in DNS dispatcher where each listened socket
needs to have their own dispatcher struct set as user data so that we
can map between dispatcher context and socket. Solve this by always
have a dispatcher table as user data, and then have the actual mapping
done via the dispatcher table when receiving data to the dispatcher socket.
Fixes#78146
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Fixing the regression caused by 3949873886 ("Allow service to be
created with NULL host"). If the host parameter is null when creating
the HTTP service, the IPv6 socket is created by default. This can cause
issues if both IPv4 and IPv6 are enabled, like in HTTP server sample,
and the HTTP client connection is done by IPv4.
To fix this, we need to enable IPv4-to-IPv6 mapping in order to allow
IPv6 socket to serve a IPv4 connection. Allow also user to override this
if needed.
Fixes#78112
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The code was checking IPv4 address instead of IPv6.
Print also IPv6 address when rejoining the group.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
LwM2M 1.1 specification mentions that the enabler version format was
specified wrongly in LwM2M 1.0 specification, and servers only "may"
accept the old format, which no longer seems to be the case for Leshan.
The URI reference ("</>;") before the enabler version is now mandatory,
if it's missing the bootstrap discovery fails with Leshan. Another
problem are quotes around the enabler version, which seems to be
conditionally accepted only for LwM2M version 1.0. Therefore, keep the
quotes only for that version, to prevent any potential issues with other
servers.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Since the `_impl` naming convention is intended for internal use only,
renaming these functions to the `shell_fprintf_xxx` variant is
more suitable for calls outside the module:
- `shell_info_impl` to `shell_fprintf_info`
- `shell_print_impl` to `shell_fprintf_normal`
- `shell_warn_impl` to `shell_fprintf_warn`
- `shell_error_impl` to `shell_fprintf_error`
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
As the allocation is run in system workqueue context, it can
cause problems if waiting forever when allocating net_pkt.
Fixes#77935
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>