From 5aa62369d455bcc63d3bb06476ad63f99453d069 Mon Sep 17 00:00:00 2001 From: Stephanos Ioannidis Date: Tue, 18 Feb 2020 15:41:44 +0900 Subject: [PATCH] net: shell: Handle ENETUNREACH for IPv4 ping This commit updates the the IPv4 ping command to handle the ENETUNREACH error number returned by `net_icmpv4_send_echo_request` function when IPv4 is unavailable. The `net_icmpv4_send_echo_request` function previously returned EINVAL when IPv4 is unavailable and this caused the shell command to report "Invalid IP address" even when the provided IP address is correct; this problem was corrected by returning ENETUNREACH instead of EINVAL in the aforementioned function. Signed-off-by: Stephanos Ioannidis --- subsys/net/ip/net_shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/net/ip/net_shell.c b/subsys/net/ip/net_shell.c index bc3a0657112..762c1bfdb6d 100644 --- a/subsys/net/ip/net_shell.c +++ b/subsys/net/ip/net_shell.c @@ -3155,7 +3155,7 @@ static int cmd_net_ping(const struct shell *shell, size_t argc, char *argv[]) if (IS_ENABLED(CONFIG_NET_IPV4)) { ret = ping_ipv4(shell, host, count, interval); if (ret) { - if (ret == -EIO) { + if (ret == -EIO || ret == -ENETUNREACH) { PR_WARNING("Cannot send IPv4 ping\n"); } else if (ret == -EINVAL) { PR_WARNING("Invalid IP address\n");