Commit graph

1717 commits

Author SHA1 Message Date
Chris Friedt 12cc7bbd8a net: sockets: use z_finalize_typed_fd() to identify as sockets
Fill-in the mode field of the fd_entry so that the
implementation can be made aware that the specific file
descriptors created are sockets.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-06-15 07:47:12 -04:00
Rubin Gerritsen 8799ab1ec2 test: Apply semantic patch file ztest_strcmp.cocci
This patch file updates the use of assertion macros
comparing strings.

Command line used:
```
./scripts/coccicheck --mode=patch \
--cocci=scripts/coccinelle/ztest_strcmp.cocci tests/
```

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-06-14 19:25:42 +02:00
Adam Wojasinski 56338de16a net: pkt: Add flags to indicate the pkt should be timestamped
This is the first commit from the set of patches that brings to the
Zephyr, SO_TIMESTAMPING socket level option. This enables to pass to
the network driver information whether given network packet should
be timestamped or not.

Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
2024-06-13 05:40:41 -04:00
Jukka Rissanen 2b4e137656 tests: net: socket: Avoid macro error with zsock_sendto
The preprocessor gives this error when calling zsock_sendto
in user mode when there is a mismatch with amount of parameters
to the sendto wrapper call.

  tests/net/socket/udp/src/main.c: In function ‘comm_sendto_recvfrom’:
  tests/net/socket/udp/src/main.c:125:46: error: macro "zsock_sendto" \
                                 requires 6 arguments, but only 5 given
  125 |                             0, &addr, addrlen);
      |                                              ^
  In file included from include/zephyr/net/socket.h:1381,
                 from tests/net/socket/udp/src/main.c:15:
  include/generated/zephyr/syscalls/socket.h:266: note: \
                      macro "zsock_sendto" defined here
  266 | #define zsock_sendto(sock, buf, len, flags, dest_addr, addrlen)

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-06-10 15:03:20 -05:00
Georges Oates_Larsen 976e0a49e4 test: net: conn_mgr: Add IPv4/IPv6 notif test coverage
Modify the test cycle routines to verify recently added IPv4- and
IPv6-specific events.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2024-06-10 00:59:34 -07:00
Robert Lubos f3d6324bca tests: net: all: Enable IPv4 ACD in the test suite
Make sure ACD is enabled in the build-all configuration.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-06-10 00:59:28 -07:00
Seppo Takalo 80385a1180 tests: lwm2m: Allow server address to be changed
Allow changing the target server address on interoperability
tests.
This allows running same testcases against public Leshan
instance. It is a first requirement to run same tests
on a real HW.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-06-07 15:05:09 +02:00
Seppo Takalo 21d4d49925 test: lwm2m: Increase FDS for native_sim
After last refactoring of POSIX Kconfig options
default is again dropped below what we need.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-06-05 17:39:57 -05:00
Chris Friedt 487a8756c3 posix: eventfd: fix dependency cycle between net and posix
Until recently, the posix api was purely a consumer of the
network subsystem. However, a dependency cycle was added as
a stop-gap solution for challenges with the native platform.

Specifically,

1. eventfd symbols conflict with those of the host
2. eventfd was excluded from native libc builds via cmake

If any part of the posix were then to select the network
subsystem (which is a legitimate use case, given that networking
is a part of the posix api), we would get a build error due to
the Kconfig dependency cycle.

As usual, with dependency cycles, the cycle can be broken
via a third, mutual dependency.

What is the third mutual dependency? Naturally, it is ZVFS
which was planned some time ago. ZVFS will be where we
collect file-descriptor and FILE-pointer APIs so that we can
ensure consistency for Zephyr users.

This change deprecates EVENTFD_MAX in favour of
ZVFS_EVENTFD_MAX.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-06-04 16:27:12 -05:00
Chris Friedt bc4374b5fe posix: deprecate POSIX_MAX_FDS and add POSIX_DEVICE_IO
The POSIX_MAX_FDS option does not correspond to any standard
POSIX option. It was used to define the size of the file
descriptor table, which is by no means exclusively used by
POSIX (also net, fs, ...).

POSIX_MAX_FDS is being deprecated in order to ensure that
Zephyr's POSIX Kconfig variables correspond to those defined in
the specification, as of IEEE 1003.1-2017. Namely,
POSIX_OPEN_MAX. CONFIG_POSIX_MAX_OPEN_FILES is being deprecated
for the same reason.

To mitigate any possible layering violations, that option is
not user selectable. It tracks the newly added
CONFIG_ZVFS_OPEN_MAX option, which is native to Zephyr.

With this deprecation, we introduce the following Kconfig
options that map directly to standard POSIX Option Groups by
simply removing "CONFIG_":

* CONFIG_POSIX_DEVICE_IO

Similarly, with this deprecation, we introduce the following
Kconfig options that map directly to standard POSIX Options by
simply removing "CONFIG":

* CONFIG_POSIX_OPEN_MAX

In order to maintain parity with the current feature set, we
introduce the following Kconfig options.

* CONFIG_POSIX_DEVICE_IO_ALIAS_CLOSE
* CONFIG_POSIX_DEVICE_IO_ALIAS_OPEN
* CONFIG_POSIX_DEVICE_IO_ALIAS_READ
* CONFIG_POSIX_DEVICE_IO_ALIAS_WRITE

Gate open(), close(), read(), and write() via the
CONFIG_POSIX_DEVICE_IO Kconfig option and move
implementations into device_io.c, to be conformant with the
spec.

Lastly, stage function names for upcoming ZVFS work, to be
completed as part of the LTSv3 Roadmap (e.g. zvfs_open(), ..).

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-06-04 16:27:12 -05:00
Jukka Rissanen 8363b8cfd9 samples: net: Increase CONFIG_NET_SOCKETS_POLL_MAX to pass checks
The number of suitable network IPv6/4 configurations in interfaces
affect the number of pollable sockets. So need to increase the value
from the default value of 3.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-06-03 09:49:01 +02:00
Fengming Ye a3034d1802 tests: net: socket: af_packet: fix TSN socket recv IP pkt
test_packet_sockets_dgram create ETH_P_TSN sockets but
send and recv ETH_P_IP packet.

Fix it by sending ETH_P_TSN packet.

Signed-off-by: Fengming Ye <frank.ye@nxp.com>
2024-06-03 09:48:32 +02:00
Seppo Takalo 85b60fcc12 Revert "test: lwm2m: Raise POSIX_MAX_FDS for native_sim"
This reverts commit 9473f60b80.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-06-01 10:24:03 +02:00
Tomi Fontanilles c1342b3aa9 modules: mbedtls: remove the default enabling of features
In an effort to shave off code size, remove out-of-the-box
enabling of crypto features (except SHA-256).

Configurations are adjusted to enable what they need.

Bonuses:

- When enabled, AES now defaults to using a smaller version
(`CONFIG_MBEDTLS_AES_ROM_TABLES` isn't default enabled anymore,
and if enabled, `CONFIG_MBEDTLS_AES_FEWER_TABLES` defaults to y).

- Conditions around Mbed TLS Kconfig options have been improved
to reflect the reality of the dependencies.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2024-05-31 16:33:06 -05:00
Jukka Rissanen ffbe0f2928 tests: net: http_server: Add wildcard resource path tests
Add tests that verify that wildcards in resource path strings
are matched correctly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-31 09:57:22 -05:00
Seppo Takalo 9473f60b80 test: lwm2m: Raise POSIX_MAX_FDS for native_sim
LwM2M interoperability test binary requires a bit
more file descriptors than the default 4.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-30 02:59:29 -07:00
Wilfried Chauveau 5d5c13feae samples: tfm: Remove old 'tfm' tag & update relevant boards
The 'tfm' tag was removed from the samples in in
7c80473e0a but it remained in use in other
parts of the project.
This change brings back consistency through out the project.

Signed-off-by: Wilfried Chauveau <wilfried.chauveau@arm.com>
2024-05-29 10:49:31 -07:00
Jukka Rissanen 48aaa1ff40 tests: net: ieee802154: Remove extra newlines from prints
As the logger will add newlines to printed strings, do not
add them in the tests.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-29 10:48:34 -07:00
Jukka Rissanen 99693bee5f net: socket: Change the protocol field for AF_PACKET sockets
In order to be compatible with Linux AF_PACKET socket calls, the
protocol field needs to be in network byte order.
So for example, if user wants to receive all packets, then the
protocol field needs to be set as "htons(ETH_P_ALL)".
See Linux manual page at
https://www.man7.org/linux/man-pages/man7/packet.7.html
for details.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-29 10:48:34 -07:00
Seppo Takalo b76683e4cb net: lwm2m: Allow setting RD context without starting
When tests control the LwM2M client entirely through
shell, we should be able to set the RD client context
from the application without causing RD client to
start registration.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-29 10:47:57 -07:00
Valerio Setti 979ede8889 test: net: socket: do not enable USE_PSA and all PSA features
This commit fixes #73337.

Before #72243 Mbed TLS was not using
USE_PSA and all PSA features were not enabled. After #72243
if BUILD_WITH_TFM is set:
- USE_PSA in Mbed TLS is enabled by default and
- all PSA features are enabled.

This commits reverts both changes for net.socket.register.tls
test case.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-05-29 10:47:37 -07:00
Tomi Fontanilles 3efdbe6c0c modules: mbedtls: rename CONFIG_MBEDTLS_MAC_*_ENABLED and rm duplicates
Remove the `_MAC` part because those Kconfig options enable only hash
algorithms, nothing MAC-related, and the `_ENABLED` part to align the
naming to the Mbed TLS defines (plus we don't need such a part).

As a bonus, enabling SHA-256 does not automatically enable SHA-224
anymore.

See the migration guide entries for more details on the practical
changes.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2024-05-29 08:39:26 +02:00
Jukka Rissanen 6465e73825 tests: net: dns_resolve: Increase the number of socket descriptors
The test needs couple of more socket/file descriptors to work because
CONFIG_POSIX_API creates three more file descriptors namely the
stdin, stdout and stderr descriptors.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-28 17:49:59 +02:00
Jukka Rissanen 5248657f57 tests: net: dns_resolve: Fix resolver tests
The compilation was failing if IPv4 was disabled.
Also fix the IPv6 test so that they pass properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-27 05:01:28 -07:00
Robert Lubos 48230f21c9 tests: net: socket: getaddrinfo: Increase ztest stack size
The ztest stack was to low to execute tests on some platforms (spotted
on nrf52840dk/nrf52840), hence increase it.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-23 07:47:18 -04:00
Reto Schneider 1bedf6209b tests: net: net_pkt: Fix typo
This fixes what seems to be a copy and paste error.

Signed-off-by: Reto Schneider <reto.schneider@husqvarnagroup.com>
2024-05-23 07:46:17 -04:00
Robert Lubos ec0e2d6308 tests: net: lib: http_server: Bump min_ram requirements
The values set as a min_ram requirement were far from the actual RAM
usage reported during build, make them more realistic.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-21 11:51:39 +01:00
Robert Lubos 9c8ed2dca7 tests: net: ipv6: Add more test cases involving iface state changes
Add tests verifying valid IPv6 ND behaviors on interface state changes,
specifically:
* Verify RS is sent, and upon RA reception prefix and autoconf address
  added accordingly.
* DAD is triggered for autoconf, static and LL IPv6 addresses.
* IPv6 address is not used upon DAD conflict.
* IPv6 neighbor discovery works as expected.
* Multicast transmission/reception is functional after interface state
  changes.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-20 14:26:24 +03:00
Robert Lubos b9f7ffe79d test: net: ipv6: Cleanup Ethernet test interface operation
One of the test interfaces is defined as Ethernet interface, however it
was missing ethernet_init() call, hence for example interface flags were
uninitialized. This can cause issues with multicast tests, as
NET_L2_MULTICAST flag was missing on the interface.

Additionally, Ethernet-type interfaces should use struct
ethernet_context as a base for their context data, otherwise Ethernet L2
will reach to some rubbish memory locations.

Finally, since the interface now defines correct flags, all-nodes
multicast address is now added to the interface automatically as a part
of ND logic. Therefore, skip adding that address manually from
ipv6_setup().

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-20 14:26:24 +03:00
Robert Lubos f33a183936 tests: net: ipv6: Fix packet leak
Receive callback has to unref the packet received, otherwise we leak
packet.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-20 14:26:24 +03:00
Robert Lubos 1d7239d00a tests: net: ipv6: Restore original LL address in test_change_ll_addr
Restore the original LL address on the interface after tests, instead of
generating a new one, to avoid dangling link-local IPv6 on the
interface.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-20 14:26:24 +03:00
Robert Lubos adc8fd8bbc tests: net: mld: Add more test cases involving iface state changes
Add more test cases verifying that MLD events/reports are sent
accordingly when interface state changes.

Introduce separate semaphores for waiting for network events, as having
a single one for transmit and events is ambiguous in tests.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-20 14:26:24 +03:00
Robert Lubos 62a55d03af net: ipv6: Fix RA RDNSS and DNS_RESOLVER interdependencies
A support for RDNSS option should not force DNS subsystem being enabled
in the system, especially that the option is enabled by default. It
should work the other way around - the option is supported only if DNS
was enabled by the user.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-20 14:25:44 +03:00
Jukka Rissanen 6924b0d49a tests: net: Exclude native_posix because of socket service
The native_posix board does not work well with eventfd so disable
it with tests that use socket service API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-20 14:25:44 +03:00
Jukka Rissanen 3770b07a0e tests: net: socketpair: Fix log printing
The LOG_MODULE_REGISTER() was not called anywhere so if one tried
to enable logging, there was a linker error about missing logger
functions.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-20 14:25:44 +03:00
Jukka Rissanen 94433b9ce2 net: mdns_responder: Convert mDNS responder to use socket service API
Instead of using net_context API directly, the mDNS responder is
changed to use the socket service API. This allows DNS access
for offloaded sockets and can lower overall memory consumption.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-20 14:25:44 +03:00
Jukka Rissanen 9a40066b4f net: dns: Convert resolver to use socket service API
Instead of using net_context API directly, the DNS resolver is
changed to use the socket service API. This allows DNS access
for offloaded sockets and can lower overall memory consumption.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-20 14:25:44 +03:00
Marcin Niestroj 3a9ae1878f tests: socket: udp: reduce SO_PRIORITY from 8 to 6 for NSOS compatbility
According to 'man 7 socket' about SO_PRIORITY:

  Setting a priority outside the range 0 to 6 requires the CAP_NET_ADMIN
  capability.

So use 6 instead of 8, in order to make UDP socket tests pass with native
offloaded sockets on native_sim platform.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2024-05-17 11:12:43 +02:00
Seppo Takalo 6257576ce6 test: lwm2m: Enable DTLS Connection ID
Enable connection ID because it is on by default on the
client example as well.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-15 14:58:15 +02:00
Seppo Takalo a9e91af375 test: lwm2m: Add tests for Block-Wise transfers
Block-Wise GET, PUT and SEND

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-15 14:58:15 +02:00
Seppo Takalo 01b57b4999 net: lwm2m: Add offset to post-write callback
When Block-Wise transfer restarts, the post-write callback should
receive some indication that the block is actually a beginning of new,
instead of part of previous transfer.

Fixes #71351

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-15 14:58:15 +02:00
Robert Lubos fab2f97364 tests: net: dhcpv6: Reapply LL address on iface up
The test suite assigns LL address to the interface manually, hence need
to reapply it whenever interface goes up.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-14 18:20:56 -04:00
Robert Lubos f63f508c21 tests: net: sockets: tls: Add missing teardown delays
A few tests involving TCP were missing TCP teardown delay. Adding these
improves tests stability when testing in a loop for longer periods (i.
e. with CONFIG_ZTEST_SHUFFLE enabled).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-13 09:52:29 -05:00
Robert Lubos 8d221a91d0 tests: net: ipv6: Fix RA test
Due to recent changes, as simple k_yield() is not enough on some
platforms (nRF platforms for example), as the entropy subsystem is now
used because of PE, which may block, causing context switch before
entire RA message is processed.

Fix this by adding small delay before checking if RA was processed
properly.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-13 09:37:32 +02:00
Konrad Derda d397aae027 tests: net: mld: update MLDv2 tests after changes
This commit changes the expectations to checking for state transitions
in MLDv2 reports.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2024-05-10 11:44:50 +02:00
Valerio Setti 2e2484b9df test: tls_credentials: relax requirements for test execution
Remove dependency on netif for net.tls_credentials.trusted_tfm
in order to have the test fully built and executed in at least
1 platform (i.e. mps2/an521/cpu0/ns)

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-05-08 22:14:19 -07:00
Robert Lubos f003087e38 tests: net: all: Make sure gratuitous ARP transmission is enabled
Add you config to the build-all net tests, to make sure everything build
properly.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-08 16:09:31 -04:00
Pieter De Gendt db8bb9ef56 cmake: linker: Use kconfig for iterable section subalign
Replace the hard-coded 4 with the Kconfig symbol
CONFIG_LINKER_ITERABLE_SECTION_SUBALIGN .

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-05-07 18:01:37 -04:00
Jukka Rissanen c0b7d8f252 tests: net: coap: Enable loopback interface
There needs to be at least one network interface in order
to avoid this error.

E: There is no network interface to work with!

So enable loopback support which creates a loopback interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 22:50:18 +01:00
Jukka Rissanen d9c985ec67 tests: net: ipv6: Add address selection tests
Make sure the IPv6 source address selection works as expected
when using the IPV6_ADDR_PREFERENCES socket option.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-06 22:50:18 +01:00