]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
Avoid infinite loop in ip addr flush.
authorDaniel Silverstone <daniel.silverstone@ubuntu.com>
Fri, 19 Oct 2007 11:32:24 +0000 (13:32 +0200)
committerStephen Hemminger <stephen.hemminger@vyatta.com>
Wed, 23 Apr 2008 17:56:05 +0000 (10:56 -0700)
Fix "ip addr flush" the same way "ip neigh flush" was previously fixed,
by bailing out if the flush hasn't completed after MAX_ROUNDS (10) tries.

ip/ipaddress.c

index 59c71c83cfbecf3e18ff327662910e0cd5bef8b3..373312f2c4e128c29478a9282e0c0df3d8922a98 100644 (file)
@@ -35,6 +35,8 @@
 #include "ll_map.h"
 #include "ip_common.h"
 
+#define MAX_ROUNDS 10
+
 static struct
 {
        int ifindex;
@@ -684,7 +686,7 @@ static int ipaddr_list_or_flush(int argc, char **argv, int flush)
                filter.flushp = 0;
                filter.flushe = sizeof(flushb);
 
-               for (;;) {
+               while (round < MAX_ROUNDS) {
                        if (rtnl_wilddump_request(&rth, filter.family, RTM_GETADDR) < 0) {
                                perror("Cannot send dump request");
                                exit(1);
@@ -711,6 +713,8 @@ static int ipaddr_list_or_flush(int argc, char **argv, int flush)
                                fflush(stdout);
                        }
                }
+               fprintf(stderr, "*** Flush remains incomplete after %d rounds. ***\n", MAX_ROUNDS); fflush(stderr);
+               return 1;
        }
 
        if (filter.family != AF_PACKET) {