Handle case wher non-root user runs ip flush.
Timeout after attempts to delete fail.
(Logical change 1.14)
diff --git a/ip/iproute.c b/ip/iproute.c
index 404f8e0..48cd075 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -21,6 +21,7 @@
#include <syslog.h>
#include <fcntl.h>
#include <string.h>
+#include <time.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -1133,6 +1134,7 @@
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 @@
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);