net: lwip: add restart support to ping
authorJerome Forissier <jerome.forissier@linaro.org>
Tue, 15 Apr 2025 21:17:38 +0000 (23:17 +0200)
committerJerome Forissier <jerome.forissier@linaro.org>
Wed, 23 Apr 2025 08:02:49 +0000 (10:02 +0200)
Use net_start_again() in do_ping() to determine if a failed ping should
be restarted on a different interface.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
net/lwip/ping.c

index 542ef2c..d8042ce 100644 (file)
@@ -168,11 +168,13 @@ int do_ping(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
        if (!ipaddr_aton(argv[1], &addr))
                return CMD_RET_USAGE;
 
-       if (net_lwip_eth_start() < 0)
-               return CMD_RET_FAILURE;
-
-       if (ping_loop(eth_get_dev(), &addr) < 0)
-               return CMD_RET_FAILURE;
+restart:
+       if (net_lwip_eth_start() < 0 || ping_loop(eth_get_dev(), &addr) < 0) {
+               if (net_start_again() == 0)
+                       goto restart;
+               else
+                       return CMD_RET_FAILURE;
+       }
 
        return CMD_RET_SUCCESS;
 }