Skip to content

Commit 16dd53b

Browse files
Tomasz Bursztykanashif
authored andcommitted
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 <[email protected]>
1 parent eea0f6f commit 16dd53b

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

subsys/net/ip/net_core.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ LOG_MODULE_REGISTER(net_core, CONFIG_NET_CORE_LOG_LEVEL);
4040

4141
#include "icmpv4.h"
4242

43-
#if defined(CONFIG_NET_DHCPV4)
4443
#include "dhcpv4.h"
45-
#endif
4644

4745
#include "route.h"
4846

@@ -426,15 +424,27 @@ static inline void l3_init(void)
426424

427425
net_route_init();
428426

427+
NET_DBG("Network L3 init done");
428+
}
429+
430+
static inline int services_init(void)
431+
{
432+
int status;
433+
434+
status = net_dhcpv4_init();
435+
if (status) {
436+
return status;
437+
}
438+
429439
dns_init_resolver();
430440

431-
NET_DBG("Network L3 init done");
441+
net_shell_init();
442+
443+
return status;
432444
}
433445

434446
static int net_init(struct device *unused)
435447
{
436-
int status = 0;
437-
438448
net_hostname_init();
439449

440450
NET_DBG("Priority %d", CONFIG_NET_INIT_PRIO);
@@ -449,16 +459,7 @@ static int net_init(struct device *unused)
449459

450460
init_rx_queues();
451461

452-
#if CONFIG_NET_DHCPV4
453-
status = net_dhcpv4_init();
454-
if (status) {
455-
return status;
456-
}
457-
#endif
458-
459-
net_shell_init();
460-
461-
return status;
462+
return services_init();
462463
}
463464

464465
SYS_INIT(net_init, POST_KERNEL, CONFIG_NET_INIT_PRIO);

0 commit comments

Comments
 (0)