net/core: Initialize network services only after the stack

DNS is not part of L3, but as dhcpv4 or the net shell, it is a services
on top of the network stack. So let's gather all in a dedicated
function.

This also rework the order when starting the DNS service. There was an
issue for offload device: these would be fully initialized in
init_rx_queues() which was called after l3_init. l3_init had already
started dns: which would not be able to bind correctly, proving to be
fully dead afterwards. Instead, starting the dns at the very end
ensures that all is initialized properly from devices to stack.

Fixes #15124

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2019-04-03 09:04:47 +02:00 committed by Anas Nashif
parent eea0f6f8f0
commit 16dd53b5a5

View file

@ -40,9 +40,7 @@ LOG_MODULE_REGISTER(net_core, CONFIG_NET_CORE_LOG_LEVEL);
#include "icmpv4.h"
#if defined(CONFIG_NET_DHCPV4)
#include "dhcpv4.h"
#endif
#include "route.h"
@ -426,15 +424,27 @@ static inline void l3_init(void)
net_route_init();
NET_DBG("Network L3 init done");
}
static inline int services_init(void)
{
int status;
status = net_dhcpv4_init();
if (status) {
return status;
}
dns_init_resolver();
NET_DBG("Network L3 init done");
net_shell_init();
return status;
}
static int net_init(struct device *unused)
{
int status = 0;
net_hostname_init();
NET_DBG("Priority %d", CONFIG_NET_INIT_PRIO);
@ -449,16 +459,7 @@ static int net_init(struct device *unused)
init_rx_queues();
#if CONFIG_NET_DHCPV4
status = net_dhcpv4_init();
if (status) {
return status;
}
#endif
net_shell_init();
return status;
return services_init();
}
SYS_INIT(net_init, POST_KERNEL, CONFIG_NET_INIT_PRIO);