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 <jukka.rissanen@nordicsemi.no>
diff --git a/subsys/net/ip/net_core.c b/subsys/net/ip/net_core.c
index 982fc413..fe37c75 100644
--- a/subsys/net/ip/net_core.c
+++ b/subsys/net/ip/net_core.c
@@ -549,6 +549,8 @@
 {
 	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 853e502..cb4c32c 100644
--- a/subsys/net/ip/net_private.h
+++ b/subsys/net/ip/net_private.h
@@ -71,6 +71,12 @@
 
 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 d74de6a..5805eb7 100644
--- a/subsys/net/lib/sockets/Kconfig
+++ b/subsys/net/lib/sockets/Kconfig
@@ -143,11 +143,6 @@
 	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 185a753..1c1d106 100644
--- a/subsys/net/lib/sockets/sockets_service.c
+++ b/subsys/net/lib/sockets/sockets_service.c
@@ -314,4 +314,7 @@
 	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 c433e1f..78bf100 100644
--- a/subsys/shell/backends/Kconfig.backends
+++ b/subsys/shell/backends/Kconfig.backends
@@ -470,7 +470,7 @@
 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 473f58e..64afba9 100644
--- a/subsys/shell/backends/shell_telnet.c
+++ b/subsys/shell/backends/shell_telnet.c
@@ -787,10 +787,6 @@
 	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)