[CRIU] [PATCH] libnetlink: Make sure there is no error happened when dumping is done

Cyrill Gorcunov gorcunov at openvz.org
Sat Nov 3 15:36:06 EDT 2012


If the kernel is misconfigured (say UDP diag module is not set)
we should detect such situation and report an error.

This patch adds a test for error code. Note the kernel requires
a patch as well. Without kernel patch this test do not harm
anyway, thus safe to merge.

http://bugzilla.openvz.org/show_bug.cgi?id=2412

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 libnetlink.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/libnetlink.c b/libnetlink.c
index 9a4671c..e852aaa 100644
--- a/libnetlink.c
+++ b/libnetlink.c
@@ -28,8 +28,17 @@ static int nlmsg_receive(char *buf, int len, int (*cb)(struct nlmsghdr *, void *
 	for (hdr = (struct nlmsghdr *)buf; NLMSG_OK(hdr, len); hdr = NLMSG_NEXT(hdr, len)) {
 		if (hdr->nlmsg_seq != CR_NLMSG_SEQ)
 			continue;
-		if (hdr->nlmsg_type == NLMSG_DONE)
+		if (hdr->nlmsg_type == NLMSG_DONE) {
+			int *len = (int *)NLMSG_DATA(hdr);
+
+			if (*len < 0) {
+				pr_err("ERROR %d reported by netlink (%s)\n",
+					*len, strerror(-*len));
+				return -1;
+			}
+
 			return 0;
+		}
 		if (hdr->nlmsg_type == NLMSG_ERROR) {
 			struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA(hdr);
 
-- 
1.7.7.6



More information about the CRIU mailing list