]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
libnetlink: check flag NLM_F_DUMP_INTR during dumps
authorNicolas Dichtel <nicolas.dichtel@6wind.com>
Fri, 22 Mar 2013 06:34:02 +0000 (06:34 +0000)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 28 Mar 2013 21:44:41 +0000 (14:44 -0700)
When this flag is set, it means that dump was interrupted and result may be
inconsistent.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
lib/libnetlink.c

index f262959299fdbfda1ba62650a8a25400a4e4319a..04201cdc751a3c581ed1d2edd36be90aeb211654 100644 (file)
@@ -194,6 +194,7 @@ int rtnl_dump_filter_l(struct rtnl_handle *rth,
                .msg_iovlen = 1,
        };
        char buf[16384];
+       int dump_intr = 0;
 
        iov.iov_base = buf;
        while (1) {
@@ -230,6 +231,9 @@ int rtnl_dump_filter_l(struct rtnl_handle *rth,
                                    h->nlmsg_seq != rth->dump)
                                        goto skip_it;
 
+                               if (h->nlmsg_flags & NLM_F_DUMP_INTR)
+                                       dump_intr = 1;
+
                                if (h->nlmsg_type == NLMSG_DONE) {
                                        found_done = 1;
                                        break; /* process next filter */
@@ -254,8 +258,12 @@ skip_it:
                        }
                }
 
-               if (found_done)
+               if (found_done) {
+                       if (dump_intr)
+                               fprintf(stderr,
+                                       "Dump was interrupted and may be inconsistent.\n");
                        return 0;
+               }
 
                if (msg.msg_flags & MSG_TRUNC) {
                        fprintf(stderr, "Message truncated\n");