[CRIU] [PATCH] unix: Add support for restoring unix receive queue for DGRAM sockets
Andrew Vagin
avagin at odin.com
Thu Nov 26 03:31:35 PST 2015
On Thu, Nov 26, 2015 at 01:41:23PM +0300, Kirill Tkhai wrote:
> Restore a receive queue in cases of:
>
> 1)socketpair with closed second end;
> 2)peer-less "listening" socket, who is a peer for others.
>
> The only hack we use here is the connect with AF_UNSPEC family,
> which clears peer of restoring socket. See unix_dgram_connect()
> for the details.
>
> This also makes socket_close_data test working.
so we need to delete test/zdtm/live/static/socket_close_data.desc
The following command should run the test
python test/zdtm.py run -T zdtm/live/static/socket_close_data
And I think we need to check a case when a dgram socket is bond to an
address and another socket is connected to it.
>
> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
> ---
> sk-unix.c | 22 ++++++++++++++++++++++
> 1 file changed, 22 insertions(+)
>
> diff --git a/sk-unix.c b/sk-unix.c
> index 91e4263..011739d 100644
> --- a/sk-unix.c
> +++ b/sk-unix.c
> @@ -1133,6 +1133,28 @@ static int open_unixsk_standalone(struct unix_sk_info *ui)
>
> close(sks[1]);
> sk = sks[0];
> + } else if (ui->ue->type == SOCK_DGRAM && !ui->ue->peer) {
> + struct sockaddr_un addr;
> + int sks[2];
> +
> + if (socketpair(PF_UNIX, ui->ue->type, 0, sks) < 0) {
> + pr_perror("Can't create socketpair");
> + return -1;
> + }
> +
> + sk = sks[0];
> + addr.sun_family = AF_UNSPEC;
> +
We need a comment here which explains why we need this connect.
> + if (connect(sk, &addr, sizeof(addr.sun_family))) {
> + pr_perror("Can't clear socker peer");
> + return -1;
> + }
> +
> + if (restore_sk_queue(sks[1], ui->ue->id)) {
> + pr_perror("Can't restore socket queue");
> + return -1;
> + }
> + close(sks[1]);
> } else {
> if (ui->ue->uflags & USK_CALLBACK) {
> sk = run_plugins(RESTORE_UNIX_SK, ui->ue->ino);
>
More information about the CRIU
mailing list