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

Cyrill Gorcunov gorcunov at gmail.com
Tue May 12 02:37:56 PDT 2015


On Tue, May 12, 2015 at 12:34:36PM +0300, Cyrill Gorcunov wrote:
>  
> +/*
> + * Some entries might be missing mark them as optional.
> + */
> +#define CTL_FLAGS_OPTIONAL	1
> +#define CTL_STATUS_ENOENT	1

CTL_STATUS_ENOENT is a leftover from series squashing. Update attached.
Sorry for inconvenience
-------------- next part --------------
>From 787c67d8df897be9532e8b1d1039796c9e533903 Mon Sep 17 00:00:00 2001
In-Reply-To: <5551C25A.4010102 at parallels.com>
References: <5551C25A.4010102 at parallels.com>
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Fri, 8 May 2015 15:43:39 +0300
Subject: [PATCH 1/2] sysctl: Make CTL_READ nonfatal

Some entries might be missing and that should not cause
CRIU to stop dumping when we know the entries are safe
to unuse.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 include/sysctl.h | 6 ++++++
 net.c            | 1 +
 sysctl.c         | 2 ++
 3 files changed, 9 insertions(+)

diff --git a/include/sysctl.h b/include/sysctl.h
index 3d7b182e862f..610fbf6d6e3e 100644
--- a/include/sysctl.h
+++ b/include/sysctl.h
@@ -5,6 +5,7 @@ struct sysctl_req {
 	char	*name;
 	void	*arg;
 	int	type;
+	int	flags;
 };
 
 extern int sysctl_op(struct sysctl_req *req, size_t nr_req, int op);
@@ -30,4 +31,9 @@ enum {
 #define CTL_LEN(t)	((t) >> CTL_SHIFT)
 #define CTL_TYPE(t)	((t) & ((1 << CTL_SHIFT) - 1))
 
+/*
+ * Some entries might be missing mark them as optional.
+ */
+#define CTL_FLAGS_OPTIONAL	1
+
 #endif /* __CR_SYSCTL_H__ */
diff --git a/net.c b/net.c
index 034793029eb2..5d531d4ad05e 100644
--- a/net.c
+++ b/net.c
@@ -104,6 +104,7 @@ static int ipv4_conf_op(char *tgt, int *conf, int op, NetnsEntry **netns)
 		req[ri].name = path[i];
 		req[ri].arg = &conf[i];
 		req[ri].type = CTL_32;
+		req[ri].flags = 0;
 		ri++;
 	}
 
diff --git a/sysctl.c b/sysctl.c
index 5c3a01f25ac8..b0591408fcb6 100644
--- a/sysctl.c
+++ b/sysctl.c
@@ -137,6 +137,8 @@ static int __sysctl_op(int dir, struct sysctl_req *req, int op)
 
 	fd = openat(dir, req->name, flags);
 	if (fd < 0) {
+		if (errno == ENOENT && (req->flags & CTL_FLAGS_OPTIONAL))
+			return 0;
 		pr_perror("Can't open sysctl %s", req->name);
 		return -1;
 	}
-- 
2.1.0



More information about the CRIU mailing list