Add test case verifying that send() returns an error when called after
TLS session has been closed.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
A growing number of CAN controllers do not have support for individual RX
hardware filters based on the Remote Transmission Request (RTR) bit. This
leads to various work-arounds on the driver level mixing hardware and
software filtering.
As the use of RTR frames is discouraged by CAN in Automation (CiA) - and
not even supported by newer standards, e.g. CAN FD - this often leads to
unnecessary overhead, added complexity, and worst-case to non-portable
behavior between various CAN controller drivers.
Instead, move to a simpler approach where the ability to accept/reject RTR
frames is globally configured via Kconfig. By default, all incoming RTR
frames are rejected at the driver level, a setting which can be supported
in hardware by most in-tree CAN controllers drivers.
Legacy applications or protocol implementations, where RTR reception is
required, can now select CONFIG_CAN_ACCEPT_RTR to accept incoming RTR
frames matching added CAN filters. These applications or protocols will
need to distinguish between RTR and data frames in their respective CAN RX
frame handling routines.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Make sure that the SO_DOMAIN is a read only value and it
returns correct socket domain (AF_INET or AF_INET6) in the
tests.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If CONFIG_POSIX_API is enabled, then the socket.h is found under
zephyr/posix/sys/socket.h etc. This allows one to compile the
socket test applications without error prints.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
One of the tests closed the underlying TCP connection right after
establishing one. This caused a certain race between incoming TLS
handshake data and entering FIN1 state (experienced on nrF52840), where
the TLS handshake data could be received after the FIN1 state was
entered, causing the server side to send RST packet. This disrupted the
test flow, as graceful TCP connection teardown was expected.
Fix this, by adding a small delay for such case to avoid the race.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add after() function for the test suite, which does cleanup on still
open sockets. Otherwise, an individual test case failure affects all
other test cases, blurring the test suite results.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Due to unresolved bug (see #61129 for details) building TLS tests fails
on vmu_rt1170 platform. Therefore disable this platform for this test
suite.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
A first batch of tests for TLS sockets, covering expected socket
behaviors:
* Verify that blocking/non-blocking tx/rx work as expected
* Verify that timeouts on tx/rx are calculated properly
* Verify proper behaviors when interacting with a socket from
different threads (close/shutodown/send).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Move the code responsible for TLS connection establishment to a helper
function, as it'll be needed as well in other test cases.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
SO_TYPE and SO_PROTOCOL test cases does not really establish connection,
so teardown delay at the end is not needed.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Fix build for nrf5340dk_nrf5340_cpuapp_ns.
Test takes up almost all of the flash, leaving no room for the image
to be signed. Disable the bootloader to free up flash-usage.
Fixes: #66469
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Verify that TCP keep alive options can be set properly and that TCP
connections time out correctly when keep-alive probes fail to get
replies.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The default ztest stack size was too small to run new UDP tests on
certain platforms (nrf52840 in this particular case), therefore increase
teh stack size in prj.conf.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Make sure that statistics is properly update for dropped
packets when IPv4 TTL is 0 or IPv6 hop limit is 0.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add extra checks that make sure that msg_iov is set
as we cannot receive anything if receive buffers are
not set.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Since the TCP context (and thus net_context) is not dereferenced
directly from the test thread anymore, add a small delay so that TCP
work queue have a chance to run, before checking net_context count or
reusing the port on new allocation.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Set separate option getters for bool, uint8_t and uint16_t
values. Use those generic getters when fetching the desired
option value.
Noticed mixed usage (bool vs int) for txtime option. Changed
the code to use int type like in other options.
The uint16_t option getter gets the value from uint16_t variable
but returns int value to the caller, and also expects that user
supplies int value.
For uint8_t value, it is expected that uint8_t value is supplied
instead of int.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Make sure recvmsg() is able to return IPv4 IP_PKTINFO and
IPv6 IPV6_RECVPKTINFO ancillary data to the caller.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The optlen parameter passed to getsockopt() should be of (socklen_t *)
type. Using int produced build errors on 64 bit platforms.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Recently added tests require more stack on certain platforms
(nrf52840dk_nrf52840 in this case), hence increase the ZTEST stack size.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Instead of forcing use of NEWLIB_LIBC, select any available complete C
library implementation. Add CONFIG_REQUIRES_FLOAT_PRINTF where needed.
Signed-off-by: Keith Packard <keithp@keithp.com>
This checks that if connect() timeouts, we check TCP pointer
properly in select() and poll() in order to catch the situation.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The sent pkt must be removed after we have cloned it
in the simulated driver otherwise there is a memory leak.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The IPV6_V6ONLY option is only checked if
CONFIG_NET_IPV4_MAPPED_TO_IPV6 option is set.
By default the IPV6_V6ONLY option is set.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Split the conversion of the RTR frame flags from the data contents test as
RTR frames do not carry any data.
Replace a couple of direct DLC assignments with proper use of
can_bytes_to_dlc().
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
rand32.h does not make much sense, since the random subsystem
provides more APIs than just getting a random 32 bits value.
Rename it to random.h and get consistently with other
subsystems.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
A little refactoring that simplifies dealing with nanosecond timestamp
values in packets and further decouples calling code from PTP:
Benefits:
- simplifies calling code by removing redundant conversions.
- prepares for removing PTP dependencies from net_pkt.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
net_context_foreach() is not a systemcall, therefore should not be used
from userspace threads. Usage of this API made SO_REUSADDR/SO_REUSEPORT
userspace tests unfunctional (crashing).
Fix this by using CONFIG_NET_TCP_TIME_WAIT_DELAY instead for tests that
involve TCP connections. Other tests don't really need to wait as
there's no teardown delay on UDP or unconnected TCP contexts.
Additionally, remove the platform exclude for qemu_x86 platform, as this
was the sole reason the tests were crashing on that platform.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit adds unit tests for the SO_REUSEPORT sockets option. It also
fixes some bugs in other tests triggered by the new features.
Signed-off-by: Tobias Frauenschläger <t.frauenschlaeger@me.com>
This commit adds unit tests for the SO_REUSEADDR socket option to test
the different possible scenarios for the option to work correctly.
There is also a fix for the TCP testsuite to make a now failing test
pass again due to a TIME_WAIT socket.
Signed-off-by: Tobias Frauenschläger <t.frauenschlaeger@me.com>
In low memory conditions, its possible for socketpair memory allocation
to fail and then the socketpair is freed but after that the remote
semaphore is released causing a crash.
Fix this by freeing the socketpair after releasing the semaphore. Add a
test case to induce low memory conditions (low HEAP and high socketpair
buffer size), with the fix issue is not seen.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Make sure we use the network interface name (if configured)
instead of device name when binding to certain network
interface.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add tests which verify that getsockname() function works as expected.
Additionally, add a teardown delay in tests involving TCP, to make sure
all resources are released before the test ends, not to interfere with
other tests.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>