[CRIU] [PATCH cr 09/10] cr-restore: unlock connections at the last moment

Andrey Vagin avagin at openvz.org
Thu Sep 13 09:10:29 EDT 2012


Restore must not fail after unlocking connections.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 cr-restore.c |   37 +++++++++++++++++++++++++++----------
 sk-tcp.c     |    2 --
 2 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index 9fee16f..69c25cd 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -829,6 +829,21 @@ static int restore_task_with_children(void *_arg)
 	return restore_one_task(current->pid.virt);
 }
 
+static int network_unlock_connections()
+{
+	pr_info("Unlock network\n");
+	if  (!(opts.namespaces_flags & CLONE_NEWNET))
+		return tcp_unlock_connections();
+
+	if (opts.unlock_network == NULL)
+		return 0;
+
+	if (system(opts.unlock_network))
+		return -1;
+
+	return 0;
+}
+
 static int restore_root_task(struct pstree_item *init, struct cr_options *opts)
 {
 	int ret;
@@ -896,6 +911,18 @@ static int restore_root_task(struct pstree_item *init, struct cr_options *opts)
 	futex_wait_while_gt(&task_entries->nr_in_progress, 0);
 	ret = (int)futex_get(&task_entries->nr_in_progress);
 
+	futex_set_and_wake(&task_entries->nr_in_progress, task_entries->nr);
+	futex_set_and_wake(&task_entries->start, CR_STATE_RESTORE_SIGCHLD);
+	futex_wait_until(&task_entries->nr_in_progress, 0);
+
+	/* Restore SIGCHLD here to skip SIGCHLD from a network sctip */
+	ret = sigaction(SIGCHLD, &old_act, NULL);
+	if (ret < 0) {
+		pr_perror("sigaction() failed\n");
+		goto out;
+	}
+
+	ret = network_unlock_connections();
 out:
 	if (ret < 0) {
 		struct pstree_item *pi;
@@ -913,16 +940,6 @@ out:
 		return 1;
 	}
 
-	futex_set_and_wake(&task_entries->nr_in_progress, task_entries->nr);
-	futex_set_and_wake(&task_entries->start, CR_STATE_RESTORE_SIGCHLD);
-	futex_wait_until(&task_entries->nr_in_progress, 0);
-
-	ret = sigaction(SIGCHLD, &old_act, NULL);
-	if (ret < 0) {
-		pr_perror("sigaction() failed\n");
-		return -1;
-	}
-
 	pr_info("Go on!!!\n");
 	futex_set_and_wake(&task_entries->start, CR_STATE_COMPLETE);
 
diff --git a/sk-tcp.c b/sk-tcp.c
index 1f64f9e..25f9d66 100644
--- a/sk-tcp.c
+++ b/sk-tcp.c
@@ -547,8 +547,6 @@ int restore_one_tcp(int fd, struct inet_sk_info *ii)
 	if (rst_tcp_socks_add(fd))
 		return -1;
 
-	nf_unlock_connection_info(ii);
-
 	if (restore_tcp_conn_state(fd, ii))
 		return -1;
 
-- 
1.7.1



More information about the CRIU mailing list