The current implicit MAC payload length algorithm (based on
an otherwise irrelevant footer pointer) produces invalid
(non-standard) values for beacon and command frames.
This change produces standard-conforming MAC payload length
values and simplifies access to payload length.
It would have been possible to fix the current footer pointer
based approach but there are arguments in favor of the new
approach:
- The footer pointer is used nowhere in the current code
base and makes length calculations rather non-obvious.
- The new approach does not use more memory and is easier
to understand and use.
- This change is a first step to support of IEEE 802.15.4
information element (IE) support. At a later stage the
distinction between MAC payload length and frame payload
length will be introduced and become relevant to
distinguish between header and payload IEs. At that point
the current implicit length calculation algorithm will
break down anyways.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
This change introduces integration test coverage for the
stack's scan shell command including the underlying net
management and command handling methods.
Later changes will build on this test to ensure that
changes to command handling will not break backwards
compatibility
This is also the reason why a separate test suite and
test file are being introduced already as further tests
will be added later on. We avoid having to move code
and thereby loose history.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Add tests for the option callback API. The test uses a previously unused
option already contained in the sample offer.
Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
Until now iterable sections APIs have been part of the toolchain
(common) headers. They are not strictly related to a toolchain, they
just rely on linker providing support for sections. Most files relied on
indirect includes to access the API, now, it is included as needed.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This change splits the IEEE 802.15.4 test into two separate
test profiles, one with and one without sockets enabled to ensure
that both configurations work correctly.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
IEEE 802.15.4-2020 introduces a sequence number suppression feature.
This change covers sequence number handling to ensure that future
changes will not break sequence number handling when introducing
the sequence number suppression feature.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
This refactoring dries up duplicate code required to configure
the socket address structure used in tests.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Additional test cases introduced in later commits will re-use
an existing test frame that requests acknowledgement. It is
therefore extracted into a function.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Additional test case that covers reception of AF_SOCKET/SOCK_DGRAM
packages via socket API.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
When changing IEEE 802.15.4 security settings or setting security
to 'none' then the previous session must be cleaned up to avoid
resource leaks.
This change introduces proper clean-up of the security session.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Security set-up and clean-up is extracted into functions
to enable re-use by test cases introduced in later commits.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
Improves inline documentation of binary IEEE 802.15.4 frames
to ease future maintenance. In this case the frame required
for testing raw sockets.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
This is a purely syntactical change that makes test case
expectations configuration more readable.
This is required as later commits will introduce further
expectations.
Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
In the FIN_WAIT_1 any incoming data is dropped, but anknowledged. Add a
check to see if the data is already acknowleged to prevent double
acknowledging of the data and bringing the acknowlegde counter out of
sync. When the acknowledge counter gets out of sync, the connection will
never properly terminate any more.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
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>
Rather than raise error on connect if iface is down, just take the iface
up.
Rather than raise error on disconnect if iface is down, just ignore the
disconnection request.
Adjust tests and documentation accordingly.
This should make the API easier to use for applications and is more in
line with the original L2 agnostic connectivity RFC.
Also replace some instances of net_if_flag_is_set with
net_if_is_admin_up, which is cleaner and identical in function.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Relocate conn_mgr_if_get_binding to conn_mgr_private.h so that it
can be used by test suites.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Provide an extra struct net_if * iface parameter to
net_if_ipv*_maddr_join/leave functions, so that the corresponding
interface context, the mcast address belong to, can be locked for the
operation.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
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>
The arm-clang compiler/linker does not optimize away unused function
symbols and thus will error if symbols that are referenced are not
defined. To fix this add needed ifdef'ry.
Build various network samples that utilize ethernet but don't have
CONFIG_NET_PROMISCUOUS_MODE will get a link error for:
Error: L6218E: Undefined symbol
net_mgmt_NET_REQUEST_ETHERNET_SET_PROMISC_MODE
(referred from ethernet.o).
Fix by adding ifdef protection around promisc code.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
As the test uses iterable sections, we need to utilize
zephyr_iterable_section for targets that need linker script
generation like arm-clang.
So add zephyr_iterable_section() for the ROM sections that the
testcases utilizes.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
conn_mgr events cannot be used due to mistake in event definitions.
Fix these definitions so that events can be used.
Also patch hole in test coverage that allowed this in the first
place.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Remove all init functions that do nothing, and provide a `NULL` to
*DEVICE*DEFINE* macros.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Set explicit loopback MTU for TCP tests for clarity,
and to avoid breaking tests if changed elsewhere.
Signed-off-by: Kenny Johansson <wirehell@gmail.com>
Some utility functions belong to lwm2m_util.c.
Block contexts belong to lwm2m_message_handling.c
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Many areas of Zephyr divide and round up without using the DIV_ROUND_UP
macro. Make use of it, so that we make use of a tested system macro and
at the same time we make code more readable.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
If server or bootstrap writes a lifetime value less than
configured default lifetime, client will automatically overwrite
the value with default one.
This gives better control for the application where client
behaviour is fine tuned on the Kconfig, but default values
from bootstrap server cannot be fine-tuned.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
This function had only one use in SenML CBOR formatter and it
contained some specific tweaks, so move the function to be a
static member of that module.
Fixes#53674
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Instead of passing the test parameters to the websocket function, by
casting the pointer to integer (which may not work on 64-bit platform
due to int/pointer size mismatch), let the test allocate a file
descriptor, and initialize it with test context. The tested functions
expect a file descriptor as an argument anyway, so it's a more intuitive
approach.
The conditional test code within WS implementation can retrieve the test
context by using FD APIs to obtain the object represented by the FD.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
TC_START is used to evaluate output of tests and is used internally by
ztest when a test starts, no need to call this manually here.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
TC_START is used to evaluate output of tests and is used internally by
ztest when a test starts, no need to call this manually here.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
TC_START is used to evaluate output of tests and is used internally by
ztest when a test starts, no need to call this manually here.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The websocket library uses int for pointers for testing and does not
work reliably on 64 bit architectures.
Exclude the test so it does not block other unrelated PRs.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Add new test cases for SO_RCVBUF/SO_SNDBUF which verify that setting
those options actually affects the RX/TX window sizes at the TCP level.
Existing tests only verified whether the options can be set/read
correctly.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Adds dummy link layer for offloaded ifaces, allowing
ifaces to directly receive l2_enable calls
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Previously, `socketpair()` tests had pulled in the native
`fcntl()` implementation instead of using the Zephyr version
when being run under `native_posix_64`.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
This adds set of unit tests for simple network buffers.
The suite is based of the test cases that are already defined for
network buffers.
Those test_net_buf_byte_order test case have been split to
smaller tests testing one functionality at a time.
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
This drops using the environmental part when referencing ZEPHYR_BASE
as the environment value does not have to be set and, in most cases,
is no longer set at all.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
This test runs fine on native_posix_64. The exclude was added long time
ago and seems to not apply anymore.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Move net/socket/websocket tests to use new ztest API
TEST=twister -T tests/net/socket/websocket
Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Handle RA RDNSS and use the first DNS server fetched. This is needed
when building IPv6 only without static DNS server IP addresses.
This implementation does not handle the lifetime, because the current
resolve logic does not have support for a DNS server lifetime.
Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
There is no reason why the default size should be 2,
because an event is only a combination of
{uint32_t + void*} + info
Using 2 as default causes a high risk of loosing events,
setting the default to a more sensible value of 5 still
restricts memory usage but keeps it more safe.
Signed-off-by: Jeroen van Dooren <jeroen.van.dooren@nobleo.nl>
The `fcntl()` call (`zsock_fcntl()`) does not seem to work
properly (specifically with `CONFIG_ARCH_POSIX`). This will
be resolved in subsequent work harmonizing the networking
subsystem and POSIX library.
Signed-off-by: Chris Friedt <cfriedt@meta.com>
Previously, the test was only run for configurations that used
the Newlib C library. However, socketpair runs equally well
under the minimal libc, and picolibc, as well as the native
libc.
Signed-off-by: Chris Friedt <cfriedt@meta.com>
* do not define `read`, `write`, as different symbols
* use `recv`, and `send` as defined by
`CONFIG_NET_SOCKETS_POSIX_NAMES`
* do not specify `(2)` as manual-page sections are
somewhat irrelevant
Note: we use `CONFIG_NET_SOCKETS_POSIX_NAMES` here, and
`CONFIG_POSIX_API` in `samples/` to show that the socketpair
API is available in both configurations.
Signed-off-by: Chris Friedt <cfriedt@meta.com>
Wow, this testsuite was really celebrating some redundancy
before.
While that is sometimes a good thing, it's also sometimes
better to be more concise.
Signed-off-by: Chris Friedt <cfriedt@meta.com>
The `test_socketpair_` prefix was leftover from the old ztest
framework.
It is also redundant, so remove it.
Signed-off-by: Chris Friedt <cfriedt@meta.com>
The declarations of extern test functions were leftover from
the old ztest framework.
They are unnecessary now.
Signed-off-by: Chris Friedt <cfriedt@meta.com>
Update unit tests for lwm2m_rd_client.c after adding new event
LWM2M_RD_CLIENT_EVENT_REG_UPDATE.
Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
Add a test case, which reproduces a scenario, where packet before IPHC
exceeds 802154 MTU, but after header compression, in fits.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Move net/socket/tls_ext tests to use new ztest API
TEST=west build -p -b native_posix tests/net/socket/tls_ext
Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
Not all toolchains support newlib so tests that require newlib need
to have a filter to we don't try and build those tests on those
testcases. Add the following to testcase.yaml to handle the issue:
filter: TOOLCHAIN_HAS_NEWLIB == 1
Fixes#54440
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
we have 1 IPv4 net_if addresses but 2 network interfaces
we must increase CONFIG_NET_IF_MAX_IPV4_COUNT value.
Signed-off-by: Marc Desvaux <marc.desvaux-ext@st.com>
For socket families that are niether INET/INET6 e.g., PACKET, we cannot
estimate header length, so, if the payload is zero as well, networking
stack drop the packet.
Instead, allow for zero header + payload packets and let L2 take care of
handling them, for some L2's this is still a valid frame.
E..g, In case of Wi-Fi this is sent as 802.11 Header + LLC Header
(no payload).
Add unittests for both AF_INET + Zero payload and AF_PACKET + Zero
payload.
Signed-off-by: Krishna T <krishna.t@nordicsemi.no>
The test checks if options are added to a CoAP buffer correctly.
It should eventually check if opstions can be added out of order
e.g. not in increasing order of option codes.
Signed-off-by: Lukas Woodtli <lukas.woodtli@husqvarnagroup.com>
The IGMP test cases are designed to use DUMMY L2 and not on real
hardware. Add an "platform_allow" filter to only run on qemu
platforms.
Fixes#54087
Signed-off-by: David Leach <david.leach@nxp.com>
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>
These tests test the basic functionality of creating
object and resource instances, setting buffers, writing
and reading to and from resources, and setting and triggering
callbacks.
Signed-off-by: Jarno Lämsä <jarno.lamsa@nordicsemi.no>
This directory has existing LwM2M tests and tests/net/lib
has other protocols as well, so keep all in one place.
Signed-off-by: Seppo Takalo <seppo.takalo@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>
There is a test case which verifies that no new packets show up on the
interface, assuming that the only source of the packets is TCP stack.
ND protocol could interfere with that assumption, sending
advertisements.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Disables allowing the python argparse library from automatically
shortening command line arguments, this prevents issues whereby
a new command is added and code that wrongly uses the shortened
command of an existing argument which is the same as the new
command being added will silently change script behaviour.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Not all toolchains support newlib so tests that require newlib need
to have a filter to we don't try and build those tests on those
testcases. Some newer tests are missing:
filter: TOOLCHAIN_HAS_NEWLIB == 1
so add that to testcases that needed.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
This commit updates all in-tree code to use `CONFIG_CPP` instead of
`CONFIG_CPLUSPLUS`, which is now deprecated.
Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
Issue #53630 proved that we didn't have sufficient test coverage for
L2/L3 package handover on the RX side. This commit creates additional
test coverage to reproduce the problem found in #53630 and avoid future
regressions.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
under certain conditions the current implementation did not maintain
the desired sort order.
Signed-off-by: Pascal Brogle <pascal.brogle@husqvarnagroup.com>
warning: format '%d' expects argument of type 'int', but argument 3
has type 'size_' {aka 'long unsigned int'} [-Wformat=]
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
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>
The `fcntl.h` header has never been a part of ISO C so move it to
`include/zephyr/posix`.
To ensure a smooth migration, a header was left in
`lib/libc/minimal/include` that prints a deprecation warning.
Users should either include `<zephyr/posix/fcntl.h>` or switch to
`CONFIG_POSIX_API=y`.
Signed-off-by: Chris Friedt <cfriedt@meta.com>
The old random timer test was not random-looking
enough on some platforms.
Replace with new test which is psuedo-xoshiro.
The generator is still deterministic
and does not depend on entropy at all,
but should look more random for testing.
Change name of generator tree-wide also.
Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Fix all comments-indentation errors detected by yamllint:
yamllint -f parsable -c .yamllint $( find -regex '.*\.y[a]*ml' ) | \
grep '(comments-indentation)'
This checks that the comment is aligned with the content.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
RD-Client is essential part of LwM2M specification and it can't
be disabled from LwM2M engine. This commit deprecates Kconfig
variable CONFIG_LWM2M_RD_CLIENT_SUPPORT and removes
all usages if it.
Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
Clean up occurrences of "#if IS_ENABLED(CONFIG_FOO)" an replace
with classical "#if defined(CONFIG_FOO)".
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
websocket_recv_msg() is reworked with using fsm. Now the function
return 0 when payload is empty, -ENOTCONN if socket close. Receiving
empty ping and sending empty pong were added in tests.
Fixes#52327
Signed-off-by: Grixa Yrev <grixayrev@yandex.ru>
integration_platforms help us control what get built/executed in CI and
for each PR submitted. They do not filter out platforms, instead they
just minimize the amount of builds/testing for a particular
tests/sample.
Tests still run on all supported platforms when not in integration mode.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Add CONFIG_CRC for building CRC related routines.
CRC routines are now being built for each application, whether used or
not and are add in the build system unconditionally.
Keep CONFIG_CRC enabled by default for now and until all users have
converted to use the new option.
Partial fix for #50654
Signed-off-by: Anas Nashif <anas.nashif@intel.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>
net_pkt_get_frag() and a few other functions did not specify the
allocated fragment length, incorrectly assuming that fixed-sized
buffers are always used.
In order to make the function work properly also with variable-sized
buffers, extend the function argument list with minimum expected
fragment length parameter. This allows to use net_buf_alloc_len()
allocator in variable buffer length configuration, as well as verify if
the fixed-sized buffer is large enough to satisfy the requirements
otherwise.
Update the existing codebase to provide the expected fragment length,
based on the context.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Fix some problems with test_recv_ipv6_fragment test case:
* net_pkt_ipv6_hdr_prev was not set, in result reassembly logic
overwritten wrong part of the IPv6 header
* Wrong checksum was set in the first fragment
Add more verification to the test_recv_ipv6_fragment test case:
* Actually register ICMPv6 Echo Reply handler so that the reassembled
packet can be analyzed
* Verify that IPv6, ICMPv6 headers and data are correct
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add test case which verifies that IPv6 fragmentation and reassembly
works correctly in loopback scenario. The test case verfies that:
* IPv6 packet is fragmented correctly in the send handler
* IPv6 packet is reassembled correctly in UDP receive handler.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The test cases which make use of wait_data semaphore incorrectly fed the
semaphore after processing the first fragment, instead of waiting for
all of the expected fragments to be processed. Adittionally, the test
cases did not really fail if the semaphore timeout occured (hence if for
example last fragment was lost, it wouldn't be detected by the test).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The second interface was not really used by the testsuite and only
obfuscated the testsuite content, hence remove it.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Validate that basic lifecycling and usage of the MQTT-SN client
work correctly by providing a mocked MQTT-SN transport. Connection
setup and state changes are tested.
Signed-off-by: René Beckmann <rene.beckmann@grandcentrix.net>
Validate that the encoding and decoding part of the MQTT-SN library
work correctly using prepared byte arrays of messages.
Signed-off-by: René Beckmann <rene.beckmann@grandcentrix.net>
This adds a test for the new ipv4_fragment feature. This test suite
checks TCP and UDP messages are correctly fragmented and reassembled,
checks that an ICMP error is sent if not all fragments were received
and checks that packets with the do not fragment bit are not
fragmented.
Signed-off-by: Jamie McCrae <spam@helper3000.net>
Added support for handle case when all data is not possible to
add in 1 message for Send and Observed Notification.
Notification continuous pending timeseries data is triggred
by iMIN attribute.
Send Operation generate continuous message in multiple lwm2m
message.
Normal Read by server only report back latest stored data.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
These tests turn on mbedtls and require ajusting min flash
requirements to prevent twister from trying to build them on
platforms without required amount of flash.
Fixes: #51421
Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
DNS SD test suite does not really make use of IP connectivity, so
there's no need to configure IP addresses.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
As the UDP test suite is mostly intended to run over loopback, use
loopback addresses and skip configuration of other addresses.
For the test cases that use fake Ethernet iterface the configuration
is done manually anyway, so just rename the symbols to avoid
collission.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
As the TLS test suite is intended to run over loopback interface, use
loopback addresses and skip configuration of other addresses.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
As the TCP test suite is intended to run over loopback interface, use
loopback addresses and skip configuration of other addresses.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
As the test suite is intended to run over loopback interfce, use
loopback address and skip configuration of other addresses.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
As the test suite is intended to run over loopback interfce, use
loopback address and skip configuration of other addresses.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The test suite already configured the dummy interfaces manually, so it's
only needed to provide respective address strings, no need to involve
NET_CONFIG_SETTINGS.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The can_frame and can_filter structs support a number of different flags
(standard/extended CAN ID type, Remote Transmission Request, CAN-FD format,
Bit Rate Switch, ...). Each of these flags is represented as a discrete bit
in the given structure.
This design pattern requires every user of these structs to initialize all
of these flags to either 0 or 1, which does not scale well for future flag
additions.
Some of these flags have associated enumerations to be used for assignment,
some do not. CAN drivers and protocols tend to rely on the logical value of
the flag instead of using the enumeration, leading to a very fragile
API. The enumerations are used inconsistently between the can_frame and
can_filter structures, which further complicates the API.
Instead, convert these flags to bitfields with separate flag definitions
for the can_frame and can_filter structures. This API allows for future
extensions without having to revisit existing users of the two
structures. Furthermore, this allows driver to easily check for unsupported
flags in the respective API calls.
As this change leads to the "id_mask" field of the can_filter to be the
only mask present in that structure, rename it to "mask" for simplicity.
Fixes: #50776
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Validate the faster IP checksum algorithm against the straightforward
implemation using a variety of packet length and contents.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Updated lwm2m_enigen_set/get_time API for support time_t.
Updated LwM2M engine set/get resource time to time resource support
time_t and uint32_t input.
LwM2M engine put and get time API update to use time_t.
Time series data cache entry have own type for time resource.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Move net icmpv4 tests to use new ztest API
1. Add teardown, remove addr
2. Fix a packet release bug in test_send_echo_req_bad_opt
3. Combine send_echo_req/rep, as they should be run in sequence
Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
The default ztest stack size was not large enough for the test suite to
execute on certain platforms (noticed on x86, cortex-m4). Therefore
increase the CONFIG_ZTEST_STACK_SIZE for the suite to prevent stack
overflow.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
CONFIG_MBEDTLS_TEST enables mbed TLS self-test routines, which require
rand() function. As this function is not available by default with
minimal libc, it caused build warning on certain platforms.
As this feature is not really needed for 802.15.4 tests, simply remove
it from the project file to fix the issue.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Given that DHCP input packet is now released after
dhcpv4_handle_reply() function is called (and potentially new message
allocated/sent) the test needs more net buffers to work.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add test which verifies that interface operational state changes
correctly when carrier and dormant status is updated.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add test that verifies if a virtual interface state is updated properly
when an underlying real interface is brought down/up.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit updates the `getaddrinfo` test to use the newlib nano
variant when available because it can run out of RAM with the newlib
full variant on the platforms with a small RAM.
Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
This change implements part two of the program laid out in the TSCH RFC,
see #50336#issuecomment-1250250154 :
> Consolidate IEEE 802.15.4 options in net_pkt
This change improves decoupling of generic net core code from
IEEE 802.15.4 internals. It also simplifies IEEE 802.15.4
attribute cloning and thereby makes it easier to maintain and less
error prone (and probably even faster as individual bits are no longer
copied over separately).
This enables us to extend and design IEEE 802.15.4 L2 attributes inside
the package in isolation from the net core code which will no longer
have to be changed when introducing changes or additions to the flags.
This flexibility will be built upon in later change sets to model the
IEEE 802.15.4 attributes closer to the spec.
The solution is inspired by Linux's sk_buff->cb attribute which addresses
the same concern as the attribute introduced in this change set:
https://elixir.bootlin.com/linux/v6.0.1/source/include/linux/skbuff.h#L871
As the inline comment says: The cb attribute can be made a union or even a
uint8[something] in the future, if further L2s need a control block, too.
Right now such full indirection would make the code overly abstract, so
I chose to compromise with maintainability in mind.
Care has been taken to ensure that this changes does not introduce
additional padding into the net package. To maintain zero-padding, future
changes to the net packet struct will have to ensure that the
IEEE 802.15.4 struct is 4-byte aligned (iff the IEEE 802.15.4 struct
continues with max uint32_t scalar members) which is no deviation from
the previous implementation.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
The net packet structure contains pointers to link-layer source and
destination addresses. Usually, these structures do not point to
separately allocated memory but directly into the packet's data buffer.
In case of a deep package clone (which includes copying the buffer) the
copy of the ll addresses continued to point into the old package
(contrary to a rather misleading inline comment). This was proven by an
additional failing unit test assertion.
As the original package may be unreferenced while the cloned package is
still being accessed, the ll address pointers of the cloned package may
become invalid.
The fix consists of two parts:
* First it is determined whether a given ll address actually points into
the buffer and if so at which logical cursor offset it is located.
* If the address points into the package buffer then the cursor API is
used to determine the corresponding physical memory location in the
cloned package. The ll address of the cloned package is then patched
to point to the cloned buffer.
Additional assertions were introduced to the existing unit test to ensure
that the newly generated address points to the correct content of the
cloned package.
The solution is implemented in a generic way so that the previously
redundant implementations were consolidated into a single one. The code
includes a check that ensures that the ll address check and manipulation
will be skipped in case of shallow package copies.
The change also addresses problems related to the "overwrite" flag of the
package:
* Package cloning assumes the overwrite flag to be set. Otherwise it
will not work correctly. This was not ensured inside the clone method.
* Package cloning manipulates the overwrite flag of the cloned package
but does not reset it to represent the same state as the original
package.
The change introduces a fix and unit test assertions for both problems.
Fixes: #51265
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
These were never being initialized by the test, leaving an embedded
k_mutex as bare memory. That used to work (I guess?), it doesn't with
k_zync.
Signed-off-by: Andy Ross <andyross@google.com>
Several attributes in the ieee802154_context struct may potentially be
accessed from different threads and/or ISR context. Only some of these
attributes were properly guarded against race conditions.
This may not have been to problematic in the past but as other changes
in this PR introduce additional attributes and mutate several attributes
in a single atomic transaction, leaving such changes unprotected seems
dangerous.
This change therefore introduces systematic locking of the
ieee802154_context structure.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
IEEE 802.15.4 short address support is incomplete in several places.
This change improves short address support without claiming to fix
it everywhere. Future iterations will have to continue where this change
leaves off.
The purpose of this change was to:
* use the short address returned by association responses,
* automatically bind IEEE 802.15.4 datagram sockets to the short
address if available,
* use the short address in outgoing packages where applicable,
* improve validation of association/disassociation frames,
* model association more closely to the spec by tying it to the
existence of a short address in the MAC PIB thereby removing
redundancy in the PIB (which makes race conditions less probable),
* keep both, the short and extended addresses, of the coordinator.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
This changes fixes several bugs and inconsistencies in the IEEE 802.15.4
L2 implementation. These bugs were revealed while documenting intended
endianness of driver, IP, socket and L2 attributes (see previous
changes).
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
Some minor housekeeping prior to adding an http server
implementation. There are already a number of http headers
and that number will likely increase with subsequent work.
Moving them into a common directory cleans up the
`include/net` directory a bit.
Signed-off-by: Christopher Friedt <cfriedt@meta.com>
Adding tests to test the case where an invalid request code is
received. coap_handle_request() should return with -ENOTSUP.
Signed-off-by: Sagar Shah <sagar.shah@legrand.us>
Align the struct socketcan_frame to most recent Linux kernel.
Compatibility with legacy can frames is maintained because the DLC is
equal to payload length for up to 8 bytes. Only the data buffer is
extended, resulting in larger size when CAN FD is enabled.
Signed-off-by: Martin Jäger <martin@libre.solar>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.
The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.
NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@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>
When the NO_DELAY option is enabled, the retransmitted packets
will likely be differently broken down from the packets transmitted
initially. This provides a nice stress test for the out or order
reception logic.
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>
Instead of waiting for the retransmit timeout, retransmit as soon as
missing data is deduced based on a triple-duplicate ACK.
Increase the number of buffers in the testcase, to allow for at least 4
packets in flight to trigger the triple-duplicate ACK.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
This change introduces test coverage for IEEE 802.15.4 AF_PACKET support
and IEEE 802.15.4 security operation.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
Zephyr IEEE 802.15.4 drivers and L2 stack use the same constant names
for different MTU definitions. The intent of this change is to introduce
a consistent MTU definition which can be used everywhere in zephyr to
avoid confusion, bugs and name conflict.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
Move net igmp tests to use new ztest API
1. Add teardown, delete callback and remove addr
2. Combine join/leave
Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
Move net ipv6 tests to use new ztest API
1. Add rm_neighbor/rm_max_neighbors
2. Add a setup function including:
add ifaddr_record to record ifaddr for teardown use
add neighbor operations
3. Add a teardown fuction including:
remove neighbor operations
remove maddr
set ifaddr_record to not used
4. add k_yield after rs message, so that ra_message can start receive
5. add leave_group, to restore to the original state after join_group
6. restore the mac address to original in test_change_ll_addr()
7. remove the addr/maddr to restore original in necessary test cases
Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
Move net iface tests to use new ztest API
1. Add teardown, remove addr and interface down
2. Add pkt unref
3. Combine interface up/down, promisc off/on, addr add/rm
Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
Move net/ethernet_mgmt tests to use new ztest API
1. Combine the tests of the same kind
2. To make the test be able to run multiple times
set back "auto neg" to original state(true) when test is done.
set back linkspeed to original 10Mbps when the test is done.
set back duplex to original state(true) when test is done.
Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
Move net content_json tests to use new ztest API
Split all the test cases into 3 test suites, each test suite has
its own before function.
Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
Move net content_link_format tests to use new ztest API
Split all the test cases into 2 test suites, each test suite has
its own before function.
Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
Move net content_oma_tlv tests to use new ztest API
Split all the test cases into 3 test suites, each test suite has
its own before function.
Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
Move net content_plain_text tests to use new ztest API
Split all the test cases into 3 test suites, each test suite has
its own before function.
Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
Move net content_raw_cbor tests to use new ztest API
Split all the test cases into 3 test suites, each test suite has
its own before function.
Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
Many device pointers are initialized at compile and never changed. This
means that the device pointer can be constified (immutable).
Automated using:
```
perl -i -pe 's/const struct device \*(?!const)(.*)= DEVICE/const struct
device *const $1= DEVICE/g' **/*.c
```
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Fix test to not assume anymore that:
- credential iteration buffer has the same pointer as the buffer
used in credential_add, now compare the length & content.
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Decouple the zephyr/net/socketcan.h and zephyr/drivers/can.h header files
by moving the SocketCAN utilities to their own header.
This is preparation for including the SocketCAN types defined in
socketcan.h in a native posix (Linux) SocketCAN driver context without name
clashes.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
SocketCAN does not support CAN-FD data lengths of up to 64 bytes
payload. Decouple the maximum supported SocketCAN data length from the
maximum supported CAN controller data length.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Rename the SocketCAN header from socket_can.h to socketcan.h to better
match the naming of the functionality.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Rename the SocketCAN utility functions to reflect the new naming of the CAN
controller API and SocketCAN API data types.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Remove the "z" prefix from the public CAN controller API types as this
makes them appear as internal APIs.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Rename the SocketCAN data types to "socketcan_*" in preparation of renaming
the low-level CAN controller API data types.
This breaks the naming compatibility with the similar SocketCAN data types
from the Linux kernel, but Zephyr and Linux SocketCAN are not 100%
compatible anyways (only the structure fields are compatible, extended
functionality such filtering, error reporting etc. are not).
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
Move the SocketCAN tests from tests/drivers/can/utilities to
tests/net/socket/can to match the location of the code under test.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
There are several test cases that create fake ethernet devices and
expect the fake device to be the only ethernet device enabled. Some
tests handle this be explicitly disabling actual ethernet drivers,
but this doesn't scale well.
Change drivers/ethernet/Kconfig to utilze a menuconfig option that
wraps all the drivers. This allows us for those test cases that
don't want any actual ethernet drivers to disable them with a
simple CONFIG_ETH_DRIVER=n.
Note, the fake ethernet devices utilize CONFIG_ETH_INIT_PRIORITY so
we have it outside of the 'if ETH_DRIVER' block.
Signed-off-by: Kumar Gala <galak@kernel.org>
Remove NET_CONFIG_IEEE802154_DEV_NAME in favor of DT based choice using
zephyr,ieee802154.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
All IEEE 802.15.4 tests use internal fake devices, so use native_posix
platform to run them as they are not meant to test IEEE 802.15.4 on
hardware.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Disable unstable tests cases for mps2_an385, which fail sporadically
due to timer stability issues on that platform (see #48608).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Loosen some timing constraints in order to hack arond spurious
failures in upstream Zephyr's CI while working on an unrelated task.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
6LoWPAN fragmentation is not related to IEEE 802.15.4 proper but is just
part of its IPv6-specific L3-adaptation layer. To make this more obvious
we rename all resources related to 6LoWPAN fragmentation.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
This change decouples the IEEE 802.15.4 (L2) layer from all IPv6 (L3)
concerns.
Applications may now choose to set CONFIG_NET_6LO=n and
CONFIG_NET_L2_IEEE802154=y at the same time.
Setting CONFIG_NET_6LO=n will build a vanilla IEEE 802.15.4-2006 specs
compliant L2 layer without any reference to 6LoWPAN or IPv6. This allows
application developers to design custom non-IP protocols on top of
IEEE 802.15.4-2006 and thereby makes the L2 layer much more re-usable.
Fixes#48585.
Signed-off-by: Florian Grandel <jerico.dev@gmail.com>
Use Devicetree to describe the UART UPIPE IEEE 802.15.4 driver. This
allows to remove usage of IEEE802154_UPIPE_DRV_NAME in preparation for
the removal of NET_CONFIG_IEEE802154_DEV_NAME.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Use Devicetree to describe the radio and IEEE 802.15.4. This allows to
remove usage of IEEE802154_NRF5_DRV_NAME in preparation for the
removal of NET_CONFIG_IEEE802154_DEV_NAME.
All SoC files have been updated with the addition of an ieee802154 node
(disabled and only on those SoCs that define ieee802154-supported. The
peripheral has been enabled in the nRF52840DK board (used for testing
ieee802154).
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Use Devicetree to describe the radio and IEEE 802.15.4. This allows to
remove usage of IEEE802154_KW41Z_DRV_NAME in preparation for the removal
of NET_CONFIG_IEEE802154_DEV_NAME.
KW41Z files have been updated with the addition of radio and an
ieee802154 nodes The peripheral has been enabled in the frdm_k41z board
(used for testing ieee802154).
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The crypto driver is used internally, so there's no real need to expose
its name as a Kconfig option. Just drop it in favor of a plain string
with the same previous value.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Use Devicetree to describe the radio and IEEE 802.15.4. This allows to
remove usage of IEEE802154_CC1200_DRV_NAME in preparation for the removal
of NET_CONFIG_IEEE802154_DEV_NAME.
In this case, the driver already had bindings, however, it was still
using NET_DEVICE_INIT.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit disables the `net.socket.tcp.preempt` test on the
`mps2_an385` platform because it fails very frequently due to the
system timer stability issues.
For more details, refer to the issue zephyrproject-rtos/zephyr#48608.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
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>
Apply an exponentially increasing wait time between tcp retries. This
is a good balance between reacting fast to single lost packets and reduce
the network load when an outage takes a little longer. It also allows the
connection to survive a longer interruption with less retransmissions.
Update the test to accommodate for the increased socket closure timeout
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Previously the test waited for the worst case time till all sockets
where closed, this causes the test to wait for a long unnecessary time.
Secondly it does not ensure the sockets are actually closed before
starting the next tests.
For tests that are not conducted in user mode, wait until all the contexts
are close for a maximum time. If the contexts are not closed in time raise
an explicit assertion.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Move af_packet_ipproto_raw tests to use new ztest API
TEST=twister -T tests/net/socket/af_packet_ipproto_raw/
Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
Move driver to use {NET_}DEVICE_DT_INST_DEFINE. This lets us
remove the IEEE802154_CC2520_DRV_NAME Kconfig symobl.
We also update the ieee802154 build_all test to actually enable
the CC2520 driver.
Signed-off-by: Kumar Gala <galak@kernel.org>
Any project with Kconfig option CONFIG_LEGACY_INCLUDE_PATH set to n
couldn't be built because some files were missing zephyr/ prefix in
includes
Re-run the migrate_includes.py script to fix all legacy include paths
Signed-off-by: Tomislav Milkovic <milkovic@byte-lab.com>
Following zephyr's style guideline, all if statements, including single
line statements shall have braces.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
COAP_DEFAULT_MAX_RETRANSMIT and COAP_DEFAULT_ACK_RANDOM_FACTOR
should be configurable to determine the max transmission
timeout of a CoAP packet.
Signed-off-by: Andreas Chmielewski <andreas.chmielewski@grandcentrix.net>
Logging v1 has been removed and log_strdup wrapper function is no
longer needed. Removing the function and its use in the tree.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Increase threads stack sizes from 2k to 3k, so that it will pass without
stack overflow on qemu_x86 platform when SHA384 support will be reenabled.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
Integrated updated JSON library to LwM2M 1.0 JSON.
Removed Old Json format default choice.
Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
Checks that taking a shallow of a packet does not leak buffers after the
packet and its clone are unreffed.
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
Datagrams should either be fully sent or not sent at all if networking
buffers or network interface MTU does not allow that.
Verify that by trying to send MTU+1 bytes in case of IPv4 (as IP level
fragmentation is not implemented) and IPv6 (should fail when IPv6
fragmentation support is not enabled and succeed otherwise). In case of
IPv6 try to send "total number of network buffers + 1", so that even with
IPv6 fragmentation enabled requested datagram will not be sent. In all
tested cases when datagram is too big, check that ENOMEM error code is set.
NOTE: Tested behavior is not 100% compliant with Linux, as on Linux
EMSGSIZE error code is set when trying to send datagram bigger than MTU,
when manually disabling IP fragmentation (by setting IP_MTU_DISCOVER to
IP_PMTUDISC_DO). However, it is not trivial to implement such
behavior (EMSGSIZE error due to MTU) now and there is always a risk of
running out of buffers (and getting ENOMEM), so for now implemented tests
just assume the latter case to always happen.
Add 3rd testcase, which enables IPv6 fragmentation support, so that UDP
socket behavior can be tested in that context.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
A reproducible case to the behavior when during a connection
the link gets broken and all data is lost, the TCP connection
should properly terminate.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Fix the existing DGRAM packet socket test. The test will now specify
LL destination address and protocol type. Also, update the fake ethernet
device send handler, so that it sets the packet network interface
corretly, so that the packet is not rejected at Ethernet L2.
Additionally, add two additional test cases verifying datagram packet
sockets. Fist test will exchange packet between RAW and DGRAM socket,
making sure that net stack forwards/removes L2 header correctly. The
second test verifies that it's possible to recieve a packet on both RAW
and DGRAM socket, making sure the received data has correct format.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The net cases failed to run on sam_e70b_xplained
platform because failed to reserve data net buffers,so
adjusting the memory buffer to fix this.
Fixes#42857
Signed-off-by: NingX Zhao <ningx.zhao@intel.com>
Datagrams (for DTLS connection) need to be sent using single API call to
mbedTLS and should not result in sending each fragment in a separate
datagram. Check if that is the case, so allow only single fragment data to
be sent and expect an error when multiple fragments were passed to
sendmsg().
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
When there is no response from the server, a client side close
is obstructed, it should terminate and clean the context. This
tests breaks the connection after the accept and validates
this behavior.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
The test suite is failing on qemu_cotext_a9 due to stack overflow.
Apparently this issue can also be observed on main after enabling
STACK_SENTINEL, however the test only started crashing after TCP
changes.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Remove NET_TCP_BACKLOG_SIZE from KConfig and from test,
because it's not present anymore in current version of TCP stack.
Signed-off-by: Andrey Dodonov <Andrey.Dodonov@endress.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>
The close function on a TCP socket can return before the complete
socket has been closed, as there might be packets still in flight.
Add a wait at the end of the test so we are sure all sockets have
been closed before the next test starts.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
The close function on a TCP socket can return before the complete
socket has been closed, as there might be packets still in flight.
Modify the test to wait briefly (less then the retransmit time), before
counting the number of still open net_contexts. This makes the test
outcome not dependent on the scheduling order of the different tasks.
Secondly the test actually checks the number of open contexts to be zero
so there is no need to wait for any open contexts to still close.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
When there is no response from the server, a client side connect
should return a ETIMEOUT. This tests breaks the connection and validates
this behavior.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
DAD timeout was wrongly checking the reply order. The code will always
assign sequentially the reply to 0-2 with the current uptime. This means
that we will always have dad[0] < dad[1] < dad[2]. Check it is useless.
Instead, let just check if we got all replies.
The test checking the time between the first and last request is to
fragile. It is testing a constant independently of the tested platform
failing in several of them. Just remove it.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Add unit tests for socket dispatcher module. The tests verify that:
* a socket is automatically dispatched to a regular socket on any
first socket call, if the socket was not bound already before
(according to the default priority rules)
* a socket is correctly dispatched to an offloaded/native socket
implementation after a SO_BINDTODEVICE call
* a socket is correctly dispatched to a native TLS socket, with an
underlying native/offloaded socket, if TLS_NATIVE and SO_BINDOTODEVICE
socket options are used
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
A reproducible case to see what happens when the TCP stack runs out
of buffers. It transfers a block, bigger then the number of buffers
available.
Also test by introducing packet loss in the loopback driver.
Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
Some names of the test cases are duplicated within the project.
This commit contains the proposed names of the test scenarios.
Signed-off-by: Katarzyna Giadla <katarzyna.giadla@nordicsemi.no>
Since the loopback driver makes use of the RX packet pool now, adjust
the packet count for the test.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The ARRAY_SIZE macro uses sizeof and thus the return
type should be an unsigned value. size_t is typically
the type used for sizeof and fits well for the
ARRAY_SIZE macro as well.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Even though bash is commonly available as /bin/bash there are
exceptions (e.g NixOS). This commit allow the use of the scripts in my
environment and is generic.
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
In case an individual resource is being discovered, the LwM2M client
should not only fill the attributes assinged at the resource level, but
also the ones inherited from the object and object instance levels.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The device already has a DT compatible (and uses DT properties).
Instantiate the device using the DT-based macros and remove hardcoded
name.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
A common pattern here was to take the work item as the subfield of a
containing object. But the contained field is not a k_work, it's a
k_work_delayable.
Things were working only because the work field was first, so the
pointers had the same value. Do things right and fix things to
produce correct code if/when that field ever moves within delayable.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Update test to ensure that any file can be tranfered,
not only files that are aligned with the packet size.
Signed-off-by: Efrain Calderon <efrain.calderon@aquarobur.com>
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add support for the gateway object [EXPERIMENTAL] used by the
MG100, BT510, and BT610 LwM2M demo.
Signed-off-by: Andrew Hedin <andrew.hedin@lairdconnect.com>
In order to align with macros used to obtain a device reference (e.g.
DEVICE_DT_GET), align the PM macros to use "GET" instead of "REF". This
change should have low impact since no official release has gone out yet
with the "REF" macros.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This provides the infrastructure to create network packet filter rules
and to apply them to the RX and TX packet paths. Rules are made of
simple condition tests that can be linked together, creating a facility
similarly to the Linux iptables functionality.
A couple of generic and Ethernet-specific condition tests are also
provided.
Additional tests can be easily created on top of this.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Verify that Route Info data received in Router Advertisment creates a
route and correctly populates the net_route_entry structure.
Additionally, extend the MTU on the test interface, to accomodate the
extended Router Advertisement message.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Implement a concept of Route Preference, as specified in RFC 4191. The
Zephyr host will prefer routes with higher preference, if they lead to
the same prefix through different neighbours.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Arduino compatible boards should have a working UART on pin 0 & 1.
On frdm_k64f this is handled by uart3
Unfortunately pinmuxing of uart3 was destroyed when enabling NETWORKING,
because the uart3 RX/TX pins was reconfigured for 1588 timers.
1588 timers are enabled by the enet child node, ptp which by some reason
is enabled by default.
1588 timers aren't needed in most cases when ethernet is being used,
so this fix ensures ptp is by default disabled. Likewise pinmuxing of
the 1588 timer functionality is now dependant of ptp being active
Signed-off-by: Kim Bøndergaard <kim.boendergaard@escoglobal.com>
Add some basic custom 802154 L2 tests, verifying that a custom L2 can be
integrated with Zephyr properly.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The device PM subsystem _depends_ on device, not vice-versa. Devices
only hold a reference to struct pm_device now, and initialize this
reference with the value provided in Z_DEVICE_DEFINE. This requirement
can be solved with a forward struct declaration, meaning there is no
need to include device PM headers.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Replace unpacked in6_addr structures with raw buffers in packed icmpv6
structs, to prevent compiler warnings about unaligned access.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Replace unpacked in6_addr structures with raw buffers in net_ipv6_hdr
struct, to prevent compiler warnings about unaligned access.
Remove __packed parameter from `struct net_6lo_context` since the
structure isn't really serialized.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Replace unpacked in_addr structures with raw buffers in net_ipv4_hdr
struct, to prevent compiler warnings about unaligned access.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Replace unpacked in_addr/in6_addr structures with raw buffers in
net_arp_hdr struct, to prevent compiler warnings about unaligned
access.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Since drivers implement a callback based on action and not the state,
we should be using the API based on the action instead of the one based
on the state.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Update the macro prototype to explicitly require the length of the
desired user data. Update all in-tree usage of this macro.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Update the macro prototype to explicitly require the length of the
desired user data. Update all in-tree usage of this macro.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Update the macro prototype to explicitly require the length of the
desired user data. Update all in-tree usage of this macro.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
The print specifier for `atomic_t` should be updated
to `%ld`, `%lu`, or `%lx` to account for the type
change of `atomic_t` to `long`.
Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
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>
Previous timeouts values were done when local TCP replies wourd occur
within sender's thread. This was a known behavior: no context switch,
shorter timings for sending packets (locally only) thus shorter
timeouts.
Such behavior changed when local replies had to go through TCP's work
queue. See commit 798588e709Fixes#40129
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Client thread might run before the server gets to put itself on accept.
Leading to the server waiting forever.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
TCP work queue is of higher priority so k_yield should do the trick, and
the test will not be affected by any timing.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Due to the previous change on when to send TCP packet on local IP, pkt
may be held in a queue which is to run on a k_work. This changes the
scheduling, and due to that one of the test is failing to allocate a
RX net_pkt at the time it wants to. (previous TCP connection is not yet
fully closed and still own PKT that new connection cannot get then).
Of course all those waiting paquets require buffers so raising them.
It was verified that there is no leak, adding net_pkt_print() at
tcp_conn_unref() shows that when all tcp connection are finally unrefed:
all net_pkt get freed as well.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
The PM callback is no longer referenced as "pm_control" but
"pm_action_cb", so reflect this new naming on the callbacks.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
LwM2M was not covered by networking build all test, leaving an opening
for possible regression in modules that are not enabled by default in
the sample.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Some net_pkt functions in `test_net_pkt_headroom_copy()` did not have
their return values verified, causing coverity complains.
CID: 240661
Fixes#39841
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
When creating a socket, all of the registered socket implementation are
processed in a sequence, allowing to find appropriate socket
implementation for specified family/type/protocol. So far however,
the order of processing was not clearly defined, leaving ambiguity if
multiple implmentations supported the same set of parameters.
Fix this, by registering socket priority along with implementation. This
makes the processing order of particular socket implementations
explicit, giving more flexibility to the user, for example when it's
neeed to prioritze one implementation over another if they support the
same set of parameters.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
As per #38352, we would like to start building out PTP (IEEE 1588)
support for superset of gPTP functionality in Zephyr. This is the first
step to abstract away some key interfaces from NET_GPTP umbrella to
NET_L2_PTP.
Signed-off-by: Alex Sergeev <asergeev@carbonrobotics.com>
Fixes: #38403
Adding NET_DRIVERS menuconfig so that network drivers are grouped
together in its own menu entry under drivers, similar to most other
drivers.
This further has the advantages that `CONFIG_NET_DRIVERS` can be used
for testing to determine if network drivers has been selected.
This changed revealed a dependency loop where both `select` (for SLIP)
and `depends` (for PPP) which both depends on NET_DRIVERS` where in use
in the dependency tree for Qemu networking, especially NET_SLIP_TAP.
This is handled by defaulting `NET_DRIVERS` to `y` when building for a
Qemu target.
`SLIP` had a dependency to `!QEMU_TARGET || NET_QEMU_SLIP`. This is
changed so that SLIP prompt depends on `!QEMU_TARGET` which provides
full user control in hardware but makes the symbol promptless on Qemu
targets.
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
ptp_clock_test was failing when trying to access the ptp clock from user
mode. This was due to an arbitrary initialization priority between the
virtual PTP clock devices created by the ptp clocking test and the
physical PTP clock on the frdm_k64f board. Since the ptp test
initializes the virtual clock with the same device name as the physical
clock, if the physical clock was initialized first this test would
incorrectly reference the physical device during testing, instead of the
virtual one.
This fix simply defines the virtual ptp clock with a custom name, so
that the test will always locate the correct ptp clock.
Fixes#38731
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Move to CMake 3.20.0.
At the Toolchain WG it was decided to move to CMake 3.20.0.
The main reason for increasing CMake version is better toolchain
support.
Better toolchain support is added in the following CMake versions:
- armclang, CMake 3.15
- Intel oneAPI, CMake 3.20
- IAR, CMake 3.15 and 3.20
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
Instead of passing target states, use actions for device PM control.
Actions represent better the meaning of the callback argument.
Furthermore, they are more future proof as they can be suitable for
other PM actions that have no direct mapping to a state. If we compare
with Linux, we could have a multi-stage suspend/resume. Such scenario
would not have a good mapping when using target states.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
- Return -ENOTSUP if the requested state is not supported
- Remove redundant "noop style" functions.
- Use switch everywhere to handle requested state (not necessary in all
drivers, but better take off with consistency in place after current
changes).
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The verb tense for the suspended state was not consistent with other
states. The likely reason: state was being used as a command/action.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Since the state is no longer modified by the device PM callback, just
use the state value.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The callback is now invoked to set the device PM state in all cases, so
the usage of ctrl_command is redundant.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This is accomplished with 3 fake ethernet interfaces hooked to a
common bridge, simulating incoming packets and controlling each
interface's transmission product.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Introduce a helper function for being able to remove any arbitrary
length from tail of packet. This is handy in cases when removing
unneeded data, like CRC once it was verified.
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
The test ocassionally fails on the mps2_an385 platform in the CI, due
to strict timing requirements of the test.
Relax the timeouts and acceptable fuzz time a bit, to prevent the
failures in the future.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The callback is not used anymore, so just delete it from the pm_control
callback signature.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
the device PM callback is not used anymore by the device PM subsystem,
so remove it from all drivers/tests using it.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Convert CoAP unit tests to ztest API.
Additionally, replace dynamic memory allocation with a static one, to
prevent memory leaks with ztest.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
If the test is run in a board that has a network interface
enabled, then the tests might select and use wrong network interface
that is needed for the test. So this commit makes sure that
we always use the simulated network interface for the
Ethernet management tests.
Fixes#36419
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Move all PM_DEVICE_STATE_* definitions to an enum. The
PM_DEVICE_STATE_SET and PM_DEVICE_STATE_GET definitions have been kept
out of the enum since they do not represent any state. However, their
name has not been changed since they will be removed soon.
All drivers and tests have been adjusted accordingly.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Add unit tests which verifies that poll() function is signalled
correctly if called after data was written/read to/from a socket.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Network test cases are designed for emulated
environments so add platform_allowed filter to
only allow qemu platforms.
Fixes: #36418
Signed-off-by: David Leach <david.leach@nxp.com>
Simple tests that verify that TXTIME parameters can be passed from
application code into the driver and vice versa.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Simple tests that verify that Qbu parameters can be passed from
application code into the driver and vice versa.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Simple tests that verify that Qbv parameters can be passed from
application code into the driver and vice versa.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The timings were too tight for TLS tests executing on nRF52840 with
hardware entropy source enabled. Increase the timings to make tests
pass.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Fixed mutli-IP DNS resolution as previously the same IP address was
used to populate all AI entries and added DNS_RESOLVER_AI_MAX_ENTRIES
config entry to define max number of IP addresses per DNS name to be
handled.
Signed-off-by: Ievgen Glinchuk <john.iceblink@gmail.com>
This commit increases the newlib heap size to 2048, which is the
recommended minimum required to ensure proper operation of the newlib
nano used by test (see #35799).
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
If the tests/net/socket/getaddrinfo is run in a board that has
Ethernet controller, then it is possible that it will interfere
the test if the Ethernet cable is connected. As the test only
needs loopback support to run, disable the Ethernet as it is
not needed by the test.
Fixes#34923
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The context parameter used across device power management is
actually the power state. Just use it and avoid a lot of
unnecessary casts.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>