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>
This commit is contained in:
Jukka Rissanen 2024-05-14 17:19:30 +03:00 committed by Johan Hedberg
commit 9a40066b4f
22 changed files with 286 additions and 110 deletions

View file

@ -17,3 +17,4 @@ CONFIG_NET_ARP=n
CONFIG_PRINTK=y
CONFIG_ZTEST=y
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_NET_SOCKETS_POLL_MAX=5

View file

@ -5,6 +5,9 @@ common:
depends_on: netif
min_ram: 16
timeout: 600
platform_exclude:
- native_posix
- native_posix/native/64
tests:
net.dns.addremove:
min_ram: 21

View file

@ -6,6 +6,9 @@ common:
depends_on: netif
integration_platforms:
- native_sim
platform_exclude:
- native_posix
- native_posix/native/64
tests:
net.dns.cache:
build_only: false

View file

@ -1,5 +1,8 @@
tests:
net.dns:
platform_exclude:
- native_posix
- native_posix/native/64
min_ram: 16
tags:
- dns

View file

@ -29,3 +29,5 @@ CONFIG_PRINTK=y
CONFIG_ZTEST=y
CONFIG_MAIN_STACK_SIZE=1344
CONFIG_NET_SOCKETS_POLL_MAX=9
CONFIG_POSIX_MAX_FDS=5

View file

@ -348,7 +348,7 @@ ZTEST(dns_resolve, test_dns_query_server_count)
continue;
}
if (!ctx->servers[i].net_ctx) {
if (ctx->servers[i].sock < 0) {
continue;
}
@ -369,7 +369,7 @@ ZTEST(dns_resolve, test_dns_query_ipv4_server_count)
continue;
}
if (!ctx->servers[i].net_ctx) {
if (ctx->servers[i].sock < 0) {
continue;
}
@ -399,7 +399,7 @@ ZTEST(dns_resolve, test_dns_query_ipv6_server_count)
continue;
}
if (!ctx->servers[i].net_ctx) {
if (ctx->servers[i].sock < 0) {
continue;
}

View file

@ -5,6 +5,9 @@ common:
depends_on: netif
timeout: 600
min_ram: 21
platform_exclude:
- native_posix
- native_posix/native/64
tests:
net.dns.resolve:
extra_configs:

View file

@ -3,6 +3,9 @@ common:
- dns
- net
depends_on: netif
platform_exclude:
- native_posix
- native_posix/native/64
tests:
net.dns.sd:
min_ram: 21

View file

@ -6,6 +6,9 @@ common:
- socket
- getaddrinfo
- userspace
platform_exclude:
- native_posix
- native_posix/native/64
tests:
net.socket.get_addr_info:
min_ram: 21

View file

@ -85,7 +85,6 @@ ZTEST(net_socket_poll, test_poll)
tstamp);
zassert_equal(res, 0, "");
/* Send pkt for s_sock and poll with timeout of 10 */
len = zsock_send(c_sock, BUF_AND_SIZE(TEST_STR_SMALL), 0);
zassert_equal(len, STRLEN(TEST_STR_SMALL), "invalid send len");
@ -151,9 +150,6 @@ ZTEST(net_socket_poll, test_poll)
zassert_equal(res, 1, "");
zassert_equal(pollout[0].revents, ZSOCK_POLLOUT, "");
/* Let the network stack run */
k_msleep(10);
res = zsock_close(c_sock_tcp);
zassert_equal(res, 0, "close failed");

View file

@ -3,7 +3,10 @@ common:
# FIXME: This test fails very frequently on mps2/an385 due to the system
# timer stability issues, so keep it disabled until the root cause
# is fixed (GitHub issue zephyrproject-rtos/zephyr#48608).
platform_exclude: mps2/an385
platform_exclude:
- mps2/an385
- native_posix/native/64
- native_posix
tests:
net.socket.poll:
min_ram: 21

View file

@ -14,6 +14,7 @@ LOG_MODULE_REGISTER(net_test, CONFIG_NET_SOCKETS_LOG_LEVEL);
#include <zephyr/net/socket.h>
#include <zephyr/net/net_ip.h>
#include <zephyr/net/net_if.h>
#include "../../socket_helpers.h"

View file

@ -7,6 +7,7 @@ CONFIG_NET_IPV4=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETPAIR=y
CONFIG_NET_SOCKETPAIR_BUFFER_SIZE=64
CONFIG_POSIX_MAX_FDS=10
# Network driver config
CONFIG_TEST_RANDOM_GENERATOR=y

View file

@ -5,19 +5,22 @@ common:
- userspace
depends_on: netif
min_ram: 21
platform_exclude:
- native_posix/native/64
- native_posix
# See #61246 for info about these next two excludes
- vmu_rt1170/mimxrt1176/cm7
- mimxrt1160_evk/mimxrt1166/cm7
tests:
net.socket.socketpair:
platform_exclude: vmu_rt1170/mimxrt1176/cm7 mimxrt1160_evk/mimxrt1166/cm7 # See #61246
net.socket.socketpair: {}
net.socket.socketpair.newlib:
filter: CONFIG_FULL_LIBC_SUPPORTED
extra_configs:
- CONFIG_REQUIRES_FULL_LIBC=y
platform_exclude: vmu_rt1170/mimxrt1176/cm7 mimxrt1160_evk/mimxrt1166/cm7 # See #61246
net.socket.socketpair.picolibc:
filter: CONFIG_PICOLIBC_SUPPORTED
extra_configs:
- CONFIG_PICOLIBC=y
platform_exclude: vmu_rt1170/mimxrt1176/cm7 mimxrt1160_evk/mimxrt1166/cm7 # See #61246
net.socket.socketpair.high_mem:
min_ram: 64
extra_configs:
@ -25,4 +28,3 @@ tests:
# fail due to insufficient memory. So, use high buffer sizes.
- CONFIG_NET_SOCKETPAIR_BUFFER_SIZE=4096
- CONFIG_HEAP_MEM_POOL_SIZE=32768
platform_exclude: vmu_rt1170/mimxrt1176/cm7 mimxrt1160_evk/mimxrt1166/cm7 # See #61246

View file

@ -9,6 +9,7 @@ LOG_MODULE_REGISTER(net_test, CONFIG_NET_SOCKETS_LOG_LEVEL);
#include <zephyr/ztest_assert.h>
#include <zephyr/posix/fcntl.h>
#include <zephyr/net/net_context.h>
#include <zephyr/net/socket.h>
#include <zephyr/net/loopback.h>