[CRIU] [PATCH 1/2] sysctl: Make CTL_READ nonfatal

Cyrill Gorcunov gorcunov at gmail.com
Tue May 5 13:29:15 PDT 2015


On Tue, May 05, 2015 at 11:14:25PM +0300, Cyrill Gorcunov wrote:
> Some entries might be missing and that
> should not cause CRIU to stop dumping
> when we know the entries are safe to unuse.

Missed @status zeroifying. Attached. Looks like it does the trick
from a fast testcase.
-------------- next part --------------
>From a1725173251d256e07052d53ecd865cd4d75516f Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Tue, 5 May 2015 23:12:54 +0300
Subject: [PATCH] net: Don't fail on missing icmp entries

icmp entries are missing on 3.10 kernel
(which is PCS7 default one) so we should
simply skip them on dump and restore.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 net.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/net.c b/net.c
index 034793029eb2..fb5cac104da3 100644
--- a/net.c
+++ b/net.c
@@ -81,13 +81,20 @@ static char *devconfs[] = {
 	"tag",
 };
 
+/*
+ * I case if some entry is missing in
+ * the kernel, simply write DEVCONFS_UNUSED
+ * into the image so we would skip it.
+ */
+#define DEVCONFS_UNUSED        (-1u)
+
 #define NET_CONF_PATH "net/ipv4/conf"
 #define MAX_CONF_OPT_PATH IFNAMSIZ+50
 
 static int ipv4_conf_op(char *tgt, int *conf, int op, NetnsEntry **netns)
 {
 	int i, ri;
-	int ret;
+	int ret, flags = op == CTL_READ ? CTL_FLAGS_OPTIONAL : 0;
 	struct sysctl_req req[ARRAY_SIZE(devconfs)];
 	char path[ARRAY_SIZE(devconfs)][MAX_CONF_OPT_PATH];
 
@@ -100,10 +107,15 @@ static int ipv4_conf_op(char *tgt, int *conf, int op, NetnsEntry **netns)
 			continue;
 		}
 
+		if (op == CTL_WRITE && conf[i] == DEVCONFS_UNUSED)
+			continue;
+
 		snprintf(path[i], MAX_CONF_OPT_PATH, "%s/%s/%s", NET_CONF_PATH, tgt, devconfs[i]);
 		req[ri].name = path[i];
 		req[ri].arg = &conf[i];
 		req[ri].type = CTL_32;
+		req[ri].flags = flags;
+		req[ri].status = 0;
 		ri++;
 	}
 
@@ -112,6 +124,14 @@ static int ipv4_conf_op(char *tgt, int *conf, int op, NetnsEntry **netns)
 		pr_err("Failed to %s %s/<confs>\n", (op == CTL_READ)?"read":"write", tgt);
 		return -1;
 	}
+
+	if (op == CTL_READ) {
+		for (i = 0; i < ri; i++) {
+			if (req[i].status & CTL_STATUS_ENOENT)
+				*(int *)req[i].arg = DEVCONFS_UNUSED;
+		}
+	}
+
 	return 0;
 }
 
-- 
2.1.0



More information about the CRIU mailing list