From 33551240de59151b4122ddf8fedc4f1cff0e2ec6 Mon Sep 17 00:00:00 2001 From: "osdl.org!shemminger" Date: Tue, 8 Jun 2004 22:51:46 +0000 Subject: [PATCH] Handle case wher non-root user runs ip flush. Timeout after attempts to delete fail. (Logical change 1.14) --- ip/iproute.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ip/iproute.c b/ip/iproute.c index 404f8e0e..48cd0754 100644 --- a/ip/iproute.c +++ b/ip/iproute.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -1133,6 +1134,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush) if (flush) { int round = 0; char flushb[4096-512]; + time_t start = time(0); if (filter.tb == -1) { if (do_ipv6 != AF_INET6) { @@ -1171,6 +1173,13 @@ static int iproute_list_or_flush(int argc, char **argv, int flush) round++; if (flush_update() < 0) exit(1); + + if (time(0) - start > 30) { + printf("\n*** Flush not completed after %ld seconds, %d entries remain ***\n", + time(0) - start, filter.flushed); + exit(1); + } + if (show_stats) { printf("\n*** Round %d, deleting %d entries ***\n", round, filter.flushed); fflush(stdout);