[CRIU] [PATCH 1/2] tcp: move locking connections to dump_one_tcp

Andrey Vagin avagin at openvz.org
Thu Nov 15 14:47:45 EST 2012


It will be used by the next patch

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 sk-tcp.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/sk-tcp.c b/sk-tcp.c
index 9e01a08..cc1af80 100644
--- a/sk-tcp.c
+++ b/sk-tcp.c
@@ -67,22 +67,13 @@ static int tcp_repair_establised(int fd, struct inet_sk_desc *sk)
 		goto err1;
 	}
 
-	if (!(opts.namespaces_flags & CLONE_NEWNET)) {
-		ret = nf_lock_connection(sk);
-		if (ret < 0)
-			goto err2;
-	}
-
 	ret = tcp_repair_on(sk->rfd);
 	if (ret < 0)
-		goto err3;
+		goto err2;
 
 	list_add_tail(&sk->rlist, &cpt_tcp_repair_sockets);
 	return 0;
 
-err3:
-	if (!(opts.namespaces_flags & CLONE_NEWNET))
-		nf_unlock_connection(sk);
 err2:
 	close(sk->rfd);
 err1:
@@ -301,10 +292,18 @@ int dump_one_tcp(int fd, struct inet_sk_desc *sk)
 	if (sk->state != TCP_ESTABLISHED)
 		return 0;
 
+	if (!(opts.namespaces_flags & CLONE_NEWNET)) {
+		int ret;
+
+		ret = nf_lock_connection(sk);
+		if (ret < 0)
+			return -1;
+	}
+
 	pr_info("Dumping TCP connection\n");
 
 	if (tcp_repair_establised(fd, sk))
-		return -1;
+		goto err;
 
 	if (dump_tcp_conn_state(sk))
 		return -1;
@@ -314,6 +313,10 @@ int dump_one_tcp(int fd, struct inet_sk_desc *sk)
 	 * closed and the connection is silently terminated
 	 */
 	return 0;
+err:
+	if (!(opts.namespaces_flags & CLONE_NEWNET))
+		nf_unlock_connection(sk);
+	return -1;
 }
 
 static int set_tcp_queue_seq(int sk, int queue, u32 seq)
-- 
1.7.11.7



More information about the CRIU mailing list