From b305be037c4c9db36a3213a8509bd44b1bd59683 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Thu, 23 May 2024 12:44:34 +0300 Subject: [PATCH] net: Start socket service thread by net core init Do not depend on init level but start the socket service already in net core init because DNS init code depends on socket service API to be ready to serve. And we call DNS init at the net core init. Signed-off-by: Jukka Rissanen --- subsys/net/ip/net_core.c | 2 ++ subsys/net/ip/net_private.h | 6 ++++++ subsys/net/lib/sockets/Kconfig | 5 ----- subsys/net/lib/sockets/sockets_service.c | 5 ++++- subsys/shell/backends/Kconfig.backends | 2 +- subsys/shell/backends/shell_telnet.c | 4 ---- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/subsys/net/ip/net_core.c b/subsys/net/ip/net_core.c index 982fc413f03..fe37c75d97c 100644 --- a/subsys/net/ip/net_core.c +++ b/subsys/net/ip/net_core.c @@ -549,6 +549,8 @@ static inline int services_init(void) { int status; + socket_service_init(); + status = net_dhcpv4_init(); if (status) { return status; diff --git a/subsys/net/ip/net_private.h b/subsys/net/ip/net_private.h index 853e50228d9..cb4c32c3a28 100644 --- a/subsys/net/ip/net_private.h +++ b/subsys/net/ip/net_private.h @@ -71,6 +71,12 @@ extern int net_icmp_call_ipv6_handlers(struct net_pkt *pkt, extern struct net_if *net_ipip_get_virtual_interface(struct net_if *input_iface); +#if defined(CONFIG_NET_SOCKETS_SERVICE) +extern void socket_service_init(void); +#else +static inline void socket_service_init(void) { } +#endif + #if defined(CONFIG_NET_NATIVE) || defined(CONFIG_NET_OFFLOAD) extern void net_context_init(void); extern const char *net_context_state(struct net_context *context); diff --git a/subsys/net/lib/sockets/Kconfig b/subsys/net/lib/sockets/Kconfig index d74de6aee16..5805eb7e4c8 100644 --- a/subsys/net/lib/sockets/Kconfig +++ b/subsys/net/lib/sockets/Kconfig @@ -143,11 +143,6 @@ config NET_SOCKETS_SERVICE_STACK_SIZE help Set the internal stack size for the thread that polls sockets. -config NET_SOCKETS_SERVICE_INIT_PRIO - int "Startup priority for the network socket service" - default 90 - depends on NET_SOCKETS_SERVICE - config NET_SOCKETS_SOCKOPT_TLS bool "TCP TLS socket option support" imply TLS_CREDENTIALS diff --git a/subsys/net/lib/sockets/sockets_service.c b/subsys/net/lib/sockets/sockets_service.c index 185a75359f8..1c1d1062409 100644 --- a/subsys/net/lib/sockets/sockets_service.c +++ b/subsys/net/lib/sockets/sockets_service.c @@ -314,4 +314,7 @@ static int init_socket_service(void) return 0; } -SYS_INIT(init_socket_service, APPLICATION, CONFIG_NET_SOCKETS_SERVICE_INIT_PRIO); +void socket_service_init(void) +{ + (void)init_socket_service(); +} diff --git a/subsys/shell/backends/Kconfig.backends b/subsys/shell/backends/Kconfig.backends index c433e1f1013..78bf1001ebd 100644 --- a/subsys/shell/backends/Kconfig.backends +++ b/subsys/shell/backends/Kconfig.backends @@ -470,7 +470,7 @@ if SHELL_BACKEND_TELNET config SHELL_TELNET_INIT_PRIORITY int "Initialization priority" default 95 - range NET_SOCKETS_SERVICE_INIT_PRIO 99 + range 0 99 help Initialization priority for telnet shell backend. This must be higher than socket service initialization priority, as socket service has to diff --git a/subsys/shell/backends/shell_telnet.c b/subsys/shell/backends/shell_telnet.c index 473f58e36ee..64afba96e12 100644 --- a/subsys/shell/backends/shell_telnet.c +++ b/subsys/shell/backends/shell_telnet.c @@ -787,10 +787,6 @@ static int enable_shell_telnet(void) return shell_init(&shell_telnet, NULL, cfg_flags, log_backend, level); } -BUILD_ASSERT(CONFIG_SHELL_TELNET_INIT_PRIORITY > CONFIG_NET_SOCKETS_SERVICE_INIT_PRIO, - "CONFIG_SHELL_TELNET_INIT_PRIORITY must be higher than " - "CONFIG_NET_SOCKETS_SERVICE_INIT_PRIO"); - SYS_INIT(enable_shell_telnet, APPLICATION, CONFIG_SHELL_TELNET_INIT_PRIORITY); const struct shell *shell_backend_telnet_get_ptr(void)