[PATCH 6/6] net: ping: do not retry endlessly

Wolfram Sang w.sang at pengutronix.de
Wed Apr 4 12:04:44 EDT 2012


Signed-off-by: Wolfram Sang <w.sang at pengutronix.de>
---
 net/ping.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/net/ping.c b/net/ping.c
index 4aa10f8..bc6cf2e 100644
--- a/net/ping.c
+++ b/net/ping.c
@@ -56,6 +56,7 @@ static int do_ping(int argc, char *argv[])
 {
 	int ret;
 	uint64_t ping_start;
+	unsigned retries = 0;
 
 	if (argc < 2)
 		return COMMAND_ERROR_USAGE;
@@ -94,6 +95,12 @@ static int do_ping(int argc, char *argv[])
 			ret = ping_send();
 			if (ret)
 				goto out_unreg;
+			retries++;
+		}
+
+		if (retries > PKT_NUM_RETRIES) {
+			ret = -ETIMEDOUT;
+			goto out_unreg;
 		}
 	}
 
-- 
1.7.9.1




More information about the barebox mailing list