[CRIU] [PATCH 2/2] net: Don't fail on missing icmp entries

Cyrill Gorcunov gorcunov at openvz.org
Fri May 8 05:43:40 PDT 2015


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, 20 insertions(+), 2 deletions(-)

diff --git a/net.c b/net.c
index 4acb1e5bcdce..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,11 +107,14 @@ 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 = 0;
+		req[ri].flags = flags;
 		req[ri].status = 0;
 		ri++;
 	}
@@ -114,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