[CRIU] [PATCH 17/19] unix: Move dump_sk_queue() before peer resolution

Kirill Tkhai ktkhai at virtuozzo.com
Tue Jan 30 18:43:23 MSK 2018


When we allow unix sockets sent over unix sockets,
dump_sk_queue() may dump and resolve some peers.
So, we need run it firstly and avoid linking our
peer_node to peer's peer_list.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/sk-unix.c |   24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index fa9efd167..10ef327cc 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -347,6 +347,18 @@ static int dump_one_unix_fd(int lfd, u32 id, const struct fd_parms *p)
 
 	sk_encode_shutdown(ue, sk->shutdown);
 
+	/*
+	 * If a stream listening socket has non-zero rqueue, this
+	 * means there are in-flight connections waiting to get
+	 * accept()-ed. We handle them separately with the "icons"
+	 * (i stands for in-flight, cons -- for connections) things.
+	 */
+	if (sk->rqlen != 0 && !(sk->type == SOCK_STREAM &&
+				sk->state == TCP_LISTEN)) {
+		if (dump_sk_queue(lfd, id))
+			goto err;
+	}
+
 	if (ue->peer) {
 		peer = (struct unix_sk_desc *)lookup_socket(ue->peer, PF_UNIX, 0);
 		if (IS_ERR_OR_NULL(peer)) {
@@ -444,17 +456,6 @@ static int dump_one_unix_fd(int lfd, u32 id, const struct fd_parms *p)
 	if (dump_socket_opts(lfd, skopts))
 		goto err;
 
-	/*
-	 * If a stream listening socket has non-zero rqueue, this
-	 * means there are in-flight connections waiting to get
-	 * accept()-ed. We handle them separately with the "icons"
-	 * (i stands for in-flight, cons -- for connections) things.
-	 */
-	if (sk->rqlen != 0 && !(sk->type == SOCK_STREAM &&
-				sk->state == TCP_LISTEN))
-		if (dump_sk_queue(lfd, id))
-			goto err;
-
 	pr_info("Dumping unix socket at %d\n", p->fd);
 	show_one_unix("Dumping", sk);
 
@@ -478,6 +479,7 @@ static int dump_one_unix_fd(int lfd, u32 id, const struct fd_parms *p)
 
 		if (write_unix_entry(psk))
 			return -1;
+		psk->sd.already_dumped = 1;
 	}
 
 	return 0;



More information about the CRIU mailing list