From 077b52c6f86964a9998f9a5562ff4a867d51783a Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Sat, 14 Mar 2020 11:52:47 +0200 Subject: [PATCH] net: lib: config: Timeout when network interface is down If the network interface is down, we should timeout properly and let the application to handle the situation. Signed-off-by: Jukka Rissanen --- subsys/net/lib/config/init.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/subsys/net/lib/config/init.c b/subsys/net/lib/config/init.c index 1748be7ae9a..d7d2a0b389e 100644 --- a/subsys/net/lib/config/init.c +++ b/subsys/net/lib/config/init.c @@ -376,6 +376,14 @@ int net_config_init(const char *app_info, u32_t flags, s32_t timeout) #endif } + if (count == 0) { + /* Network interface did not come up. We will not try + * to setup things in that case. + */ + NET_ERR("Timeout while waiting network %s", "interface"); + return -ENETDOWN; + } + if (flags & NET_CONFIG_NEED_IPV6) { need++; } @@ -402,7 +410,7 @@ int net_config_init(const char *app_info, u32_t flags, s32_t timeout) } if (!count && timeout) { - NET_ERR("Timeout while waiting setup"); + NET_ERR("Timeout while waiting network %s", "setup"); return -ETIMEDOUT; }