From 260759dfdebe774aba6866bf49c2928b2242bb7e Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen@networkplumber.org>
Date: Tue, 26 Mar 2013 22:15:35 +0100
Subject: callback: fix missing handling of NLM_F_DUMP_INTR

Propagate the error to the user-space application, that should retry.

[ I have mangled this patch to document EINTR in mnl_cb_run. --pablo ]

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 src/callback.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/callback.c b/src/callback.c
index 6337acc..f023401 100644
--- a/src/callback.c
+++ b/src/callback.c
@@ -65,6 +65,12 @@ __mnl_cb_run(const void *buf, size_t numbytes, unsigned int seq,
 			return -1;
 		}
 
+		/* dump was interrupted */
+		if (nlh->nlmsg_flags & NLM_F_DUMP_INTR) {
+			errno = EINTR;
+			return -1;
+		}
+
 		/* netlink data message handling */
 		if (nlh->nlmsg_type >= NLMSG_MIN_TYPE) { 
 			if (cb_data){
@@ -117,7 +123,8 @@ out:
  * This function propagates the callback return value. On error, it returns
  * -1 and errno is explicitly set. If the portID is not the expected, errno
  * is set to ESRCH. If the sequence number is not the expected, errno is set
- * to EPROTO.
+ * to EPROTO. If the dump was interrupted, errno is set to EINTR and you should
+ * request a new fresh dump again.
  */
 int
 mnl_cb_run2(const void *buf, size_t numbytes, unsigned int seq,
-- 
cgit v1.2.3