So far test cases in TCP test suite were represented by magic numbers.
With the increasing size of this test suite, it started to become
troublesome to follow, which number represents which test case or what
number can a new test case get.
Introduce a new enum for the test suite, which can be used to represent
individual test case. It simplifies adding new test cases (test case ids
are now defined in a single place, so easier to extend), and also
improves code readability.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Verify, that when TCP stack received FIN packet containing data bytes,
the data is provided to the application and respective seq/ack counters
are updated respectively.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Instead of having a single config specifying the memory pool size for
variable-sized net buffers, have a separate one for TX and RX for better
configuration granularity when optimizing memory usage of the
application.
Deprecate the old configuration but use its value as a default (for now)
for the new configs. This will need to change when the config is
deleted.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Make the retransmission timer much shorter so that the test
is run faster (about 50% faster test run in qemu_x86).
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Make sure the connection is closed by the timer if the final
ack is lost in closing state.
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>
Add TCP test case which verifies that if RST+ACK packet is received
during TCP handshake, the connection is brought down and
net_context_connect() fails.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Implemented testcase to check if the retransmitted FIN packet
from the FIN1 state has the correct sequence number.
Also fix the endianness conversion of sequence numbers in the
tests to use 32-bit as it should instead of 16-bit.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
After the TCP socket has been closed, it should not accept any new data
and send a RST packet if it does receive some.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Fixing the bug with shadowed ret variable (and hence not returning
timeout error) reveled another bug in TCP server tests. Here, the
listening context was incorrectly used to receive new data, and since it
never arrived, the function timed out.
This commits fixes that issue, and limits the retransmission timeout to
ensure that Nagle's algorithm impact does not affect test timings.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Due to more strict checking of the sequence numbering in the FIN_WAIT_1
state in the tcp stack, the test broke. Fix the sequence numbering
for sending the FIN and FIN ACK messages.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Twister now supports using YAML lists for all fields that were written
as space-separated lists. Used twister_to_list.py script. Some artifacts
on string length are due to how ruamel dumps content.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
In this test suite, the actual peer interacting with the TCP stack is
the test suite itself, therefore all test cases should take care to
finalize the underlying TCP connection before ending, not to interfere
with other test cases.
This was not the case for test_server_out_of_order_data(), which
although released the underlying context on their side, did not finalize
the connection at the TCP level, i. e. did not reply for the FIN packet
etc.
As it seems to be unnecessary overhead to implement the full connection
teardown for the test case, simply send a RST packet to abort the
connection at the TCP level before releasing the context.
This was causing occasional failures in this test suite, as the FIN
packets retransmitted by the TCP stack could interfere with other test
cases logic.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The net_context recv callback used by the test suite did not release the
net_pkt provided, causing packet leak. Since the test suite allocated
plenty of packets, it wasn't visible, however could become a problem if
more tests are added.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The net_context-based TCP tests required some adjustments/fixes:
* seq number was not incremented for the final ACK after FIN
* accepted net_context was not dereferenced (with net_context_put())
* net_context_put() should be used instead of net_tcp_put(), as it's the
net_context that is allocated in the test (with net_context_get())
* out of order tests depend on each other, therefore it must be assured
they're executed in the correct order
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
After several fixes of the re-ordering logic in TCP, the receive queue
works as intended and cleans itself up properly. Previously the default
timeout was 100 ms, which pretty much disables it for real applications.
Increase the timeout to 2 seconds to actually enable it for in practice.
This should help pass much more of the Maxwell Pro tests.
This is the first step before removing the timeout completely.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
CONFIG_NET_BUF_VARIABLE_DATA_SIZE option had not test coverage at all,
making in vulnerable for regressions. There is no dedicated test suite
to verify this option, but at least we can enable it in a few test
suites to make sure the configuration is functional.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
When all the data of the new packet is already present in the
queue_recv_data, make sure the packet is discarded.
This commit adds a test line that reproduces the issue and implements a
fix.
Also in appending the packet, call the official net_buf_frag_add function
instead of updating the last net_buf pointer, since the net_pkt_remove_tail
called in between, might have removed the last net_buf.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
TCP is a streaming protocol, this means it can set the packet boundary
at an arbitrary location. Therefor a re-transmitted packet may have the
packet boundary at a different location from the original missing segment.
The reordering logic should be able to deal with this situation and
throw away the overlapping data. This fix clears the out of order queue
when the queued data is not relevant.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
TCP is a streaming protocol, this means it can set the packet boundary
at an arbitrary location. Therefor a re-transmitted packet may have the
packet boundary at a different location from the original missing segment.
The reordering logic should be able to deal with this situation and
throw away the overlapping data. Now also for data that needs to be added
to the existing queue
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
TCP is a streaming protocol, this means it can set the packet boundary
at an arbitrary location. Therefor a re-transmitted packet may have the
packet boundary at a different location from the original missing segment.
The reordering logic should be able to deal with this situation and
throw away the overlapping data.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
To provide more fine grained testing on out of order acknowledgements
restructure the testcase to use a list with expected in and outputs.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
The stack acknowledges out of order packets right now, update the
test_server_recv_out_of_order_data test to properly validate this
behavior.
Out of order packets should be acknowledged using sequence number of
the last correctly received byte.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Add a bunch of missing "zephyr/" prefixes to #include statements in
various test and test framework files.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
It can happen that two similar stacks enter a retransmission cycle
due to a packet collision. If the transmission timeout is the same
both stacks will retry at the same moment resulting in another
collision.
By introducing a randomized retry timeout, the chance of
a second collision is reduced and it reduces furter the more
retransmissions occur.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
In order to bring consistency in-tree, migrate all tests to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
TCP2 is no longer needed as it is the unique implementation since the
legacy one has been removed.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Remove legacy TCP stack as it is replaced by the new TCP2 stack.
The TCP2 stack has been the default stack since 2.4 release.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.
A coccinelle rule is used for this:
@r_const_dev_1
disable optional_qualifier
@
@@
-struct device *
+const struct device *
@r_const_dev_2
disable optional_qualifier
@
@@
-struct device * const
+const struct device *
Fixes#27399
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
... because it is (required).
This makes a difference when building with CMake and forgetting
ZEPHYR_BASE or not registering Zephyr in the CMake package registry.
In this particular case, REQUIRED turns this harmless looking log
statement:
-- Could NOT find Zephyr (missing: Zephyr_DIR)
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- ...
-- ...
-- ...
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:8 (target_sources):
Cannot specify sources for target "app" which is not built by
this project.
... into this louder, clearer, faster and (last but not least) final
error:
CMake Error at CMakeLists.txt:5 (find_package):
Could not find a package configuration file provided by "Zephyr" with
any of the following names:
ZephyrConfig.cmake
zephyr-config.cmake
Add the installation prefix of "Zephyr" to CMAKE_PREFIX_PATH or set
"Zephyr_DIR" to a directory containing one of the above files. If
"Zephyr" provides a separate development package or SDK, be sure it
has been installed.
-- Configuring incomplete, errors occurred!
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Use the appropriate K_SECONDS() or K_MSEC() macros to pass a timeout to
k_sleep() and other kernel APIs.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Using find_package to locate Zephyr.
Old behavior was to use $ENV{ZEPHYR_BASE} for inclusion of boiler plate
code.
Whenever an automatic run of CMake happend by the build system / IDE
then it was required that ZEPHYR_BASE was defined.
Using ZEPHYR_BASE only to locate the Zephyr package allows CMake to
cache the base variable and thus allowing subsequent invocation even
if ZEPHYR_BASE is not set in the environment.
It also removes the risk of strange build results if a user switchs
between different Zephyr based project folders and forgetting to reset
ZEPHYR_BASE before running ninja / make.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
By changing the various *NET_DEVICE* macros. It is up to the device
drivers to either set a proper PM function or, if not supported or PM
disabled, to use device_pm_control_nop relevantly.
All existing macro calls are updated. Since no PM support was added so
far, device_pm_control_nop is used as the default everywhere.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Assignments have no effect on promptless symbols. Flagged by
https://github.com/zephyrproject-rtos/zephyr/pull/20742.
(There doesn't seem to be any way to enable this symbol, because it's
not being select'ed either.)
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
The seasonal overhaul of test identifiers aligning the terms being used
and creating a structure. This is hopefully the last time we do this,
plan is to document the identifiers and enforce syntax.
The end-goal is to be able to generate a testsuite description from the
existing tests and sync it frequently with the testsuite in Testrail.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This is bad practice and may conceal issues on platforms
not in the whitelist.
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move misc/printk.h to sys/printk.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>