From 75be843cddada59b5e72fcc1035102fe6cf8fdf9 Mon Sep 17 00:00:00 2001 From: Kirill Tkhai Date: Tue, 30 Jan 2018 18:43:32 +0300 Subject: [PATCH] files: Allow to send unix sockets over unix sockets Everything is ready. Message queue restores are in the second stage of open for all types of unix sockets. We just need to make scm wait before restore_unix_queue() and allow to dump such scm context. Signed-off-by: Kirill Tkhai Signed-off-by: Andrei Vagin --- criu/sk-queue.c | 9 --------- criu/sk-unix.c | 12 ++++++------ 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/criu/sk-queue.c b/criu/sk-queue.c index 7f5aa1d58..b5fb6b76c 100644 --- a/criu/sk-queue.c +++ b/criu/sk-queue.c @@ -100,15 +100,6 @@ static int dump_scm_rights(struct cmsghdr *ch, SkPacketEntry *pe) if (dump_my_file(fds[i], &scme->rights[i], &ftyp)) return -1; - - /* - * Unix sent over Unix are tricky and not supported - * for now. (XXX -- todo). - */ - if (ftyp == FD_TYPES__UNIXSK) { - pr_err("Can't dump send %d (unix/epoll) fd\n", ftyp); - return -1; - } } i = pe->n_scm++; diff --git a/criu/sk-unix.c b/criu/sk-unix.c index 4b3a47036..6ce42ff92 100644 --- a/criu/sk-unix.c +++ b/criu/sk-unix.c @@ -1123,6 +1123,9 @@ static int post_open_standalone(struct file_desc *d, int fd) BUG_ON((ui->flags & (USK_PAIR_MASTER | USK_PAIR_SLAVE)) || (ui->ue->uflags & (USK_CALLBACK | USK_INHERIT))); + if (chk_restored_scms(ui)) + return 1; + peer = ui->peer; if (!peer || ui->is_connected) goto restore_sk_common; @@ -1292,6 +1295,9 @@ static int post_open_interconnected_master(struct unix_sk_info *ui) fle_peer = file_master(&peer->d); BUG_ON(fle->task != fle_peer->task); /* See interconnected_pair() */ + if (chk_restored_scms(ui) || chk_restored_scms(peer)) + return 0; + if (restore_unix_queue(fle->fe->fd, peer)) return -1; @@ -1563,12 +1569,6 @@ static int open_unix_sk(struct file_desc *d, int *new_fd) ui = container_of(d, struct unix_sk_info, d); - /* FIXME -- only queue restore may be postponed */ - if (chk_restored_scms(ui)) { - pr_info("scm: Wait for tgt to restore\n"); - return 1; - } - if (inherited_fd(d, new_fd)) { ui->ue->uflags |= USK_INHERIT; ret = *new_fd >= 0 ? 0 : -1;