Support for packet's msg_name in receive queue of promiscous DGRAM sockets

Submitted by Kirill Tkhai on April 29, 2016, 2:34 p.m.


Reviewer None
Submitted April 29, 2016, 2:34 p.m.
Last Updated June 17, 2016, 12:27 a.m.
Revision 5

Cover Letter

DGRAM packet, received using recvmsg, have msghdr populated:

recvmsg(int sockfd, struct msghdr *msg, int flags)

struct msghdr {
        void            *msg_name;
        int             msg_namelen;

msg_name and msg_namelen contain the name of the sender of packet,
which the sender is bound to.

Currently, we do not support this. We restore the whole queue with
the only sender (the receiver is peer for it, but there may be several
senders), or with empty sender. This series adds support for "promiscous"
receive queues and restore them correct.

To do that, we determine sockets, which queues have several senders, and
senders, who are involved there. Sender's fds are sent to receives,
and receivers restore their queues it correct order and with correct

This patchset ill have a sequel, which introduces "ghost sockets",
that are not supported there. Their packets are restored as having
noname senders now.

v2: restore_promisc_queue(): preserve foreign sockets names
    Use find_used_fd() instead of doing new realization
    Add test socket_snd_addr01
v3: Change high limit of find_unused_fd(). And refactor it.
    Merge fd_is_used() to find_used_fd().
    Do not store sender_ino of sockets
v4: Synchronization in test
v5: Rewrite socket transfer using fle. Kill USK_EMPTY_Q.


Kirill Tkhai (11):
      unix: Add find_unix_sk_by_name()
      packets: Add sender_ino to packet proto
      sk-queue: Allow to dump a skb sender
      unix: Dump DGRAM packets and sockets senders
      files: Add fd_open_state::finalize method()
      files: Make dup_fle() return newly allocated fle
      unix: Export packets_list and struct packet
      unix: Resolve senders of packets in receive queue of DGRAM socket
      sk-queue: Use sendto() to restore socket queue
      unix: Correctly restore DGRAM promiscuos queue
      zdtm: Add socket_snd_addr01 test

 criu/autofs.c                        |    2 
 criu/files.c                         |   28 +++-
 criu/include/files.h                 |    9 +
 criu/include/sk-queue.h              |   23 +++
 criu/sk-queue.c                      |   70 +++++++--
 criu/sk-unix.c                       |  256 ++++++++++++++++++++++++++++++++--
 images/sk-packet.proto               |    1 
 test/zdtm/static/Makefile            |    1 
 test/zdtm/static/socket_snd_addr01.c |  177 ++++++++++++++++++++++++
 9 files changed, 517 insertions(+), 50 deletions(-)
 create mode 100644 test/zdtm/static/socket_snd_addr01.c

Signed-off-by: Kirill Tkhai <>