[CRIU] [PATCH] inet: increase socket buffers for restoring queues

Andrey Vagin avagin at openvz.org
Wed Oct 31 05:53:12 EDT 2012


Sizes of send and recv buffers are set to maximum to restore queues,
after that sizes of buffers are restored.

O_NONBLOCK is set to a socket to prevent blocking during restore.

https://bugzilla.openvz.org/show_bug.cgi?id=2411

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 sk-inet.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/sk-inet.c b/sk-inet.c
index 6382bd5..fc3c7fa 100644
--- a/sk-inet.c
+++ b/sk-inet.c
@@ -435,6 +435,32 @@ static int post_open_inet_sk(struct file_desc *d, int sk)
 	return 0;
 }
 
+static int rst_prep_inet_sk(int sk)
+{
+	int flags;
+
+	/* In kernel a bufsize has type int and a value is doubled. */
+	u32 maxbuf = INT_MAX / 2;
+
+	if (restore_opt(sk, SOL_SOCKET, SO_SNDBUFFORCE, &maxbuf))
+		return -1;
+	if (restore_opt(sk, SOL_SOCKET, SO_RCVBUFFORCE, &maxbuf))
+		return -1;
+
+	/* Prevent blocking on restore */
+	flags = fcntl(sk, F_GETFL, 0);
+	if (flags == -1) {
+		pr_perror("Unable to get flags for %d", sk);
+		return -1;
+	}
+	if (fcntl(sk, F_SETFL, flags | O_NONBLOCK) ) {
+		pr_perror("Unable to set O_NONBLOCK for %d", sk);
+		return -1;
+	}
+
+	return 0;
+}
+
 static int open_inet_sk(struct file_desc *d)
 {
 	struct inet_sk_info *ii;
@@ -465,6 +491,9 @@ static int open_inet_sk(struct file_desc *d)
 		return -1;
 	}
 
+	if (rst_prep_inet_sk(sk))
+		return -1;
+
 	if (ie->v6only) {
 		if (restore_opt(sk, SOL_IPV6, IPV6_V6ONLY, &yes) == -1)
 			return -1;
-- 
1.7.11.7



More information about the CRIU mailing list