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 <root@stephanos.io>
This commit is contained in:
Stephanos Ioannidis 2020-02-18 15:41:44 +09:00 committed by Maureen Helm
commit 5aa62369d4

View file

@ -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");