files: add one more operation post_create

It will be used for restoring inet sockets. An inet socket is created with
the option REUSEADDR, because the restore logic requires this.
The origin value can be restored only when all sockets were restored.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
sk-inet: restore option REUSEADDR (v2)

All sockets are created with SO_REUSEADDR, it's needed for restoring.
E.g.: A listen socket is created after a connected socket. Both of them
are binded to one port.

So SO_REUSEADDR should be restored, when all sockets on a port were created.

This code creates a structure for each port of one type of sockets
and accounts a number of sockets, which are not restored yet.

Sockets have a hook post_open(), in which it waits when all sockets for
a defined port would be created and then it will restore SO_REUSEADDR.

struct port contains a type (udp, tcp, etc) and a port number.
It doesn't contain family or addr, because it's extra loads of logic,
which doesn't bring a significant profits.

v2: fix according with comments from Pavel

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
sk-unix: connect unix sockets in post_open

Move logic from run_unix_connections to post_open().

I don't fix indents in this patch for easy reviewing.
They are fixed in the next patch.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
sk-unix: fix indents

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
unix: Remove conn-jobs

After previous rework (513dde00) they are no longer needed.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
inet: Factor out sockaddr-s preparations

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
inet: Sanitize ii->ie mass dereference in inet sk restore

Just save the ii->ie on stack and do s/ii->ie/ie/ over the fn.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
inet: Remove is_bound fn

It's now quite simple. It's better to open-code one.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: rework logging

* Delete internal buffer, all data are written immediately in a log file
* Add timestamp and pid in a message
* All processes write log messages in one file

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: add ability to create an external tasks

It will be used for checking tcp connections, external unix sockets, etc

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: check external sockets

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm.sh: logfd can be closed when crtools already detached (v2)

So try to check on extra descriptors a few times

v2: move save_fds in a loop

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
protobuf: use pretty output for unix sockets

New custom specificator:

'S': output as string (unprintable characters replaced by dots)

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
protobuf: add generic support for "bytes" field

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
show: Add pretty output for fdinfo

fd is shown in %d
flags are shown in %#o

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
show: Show unix inodes and peers both in hex

Currently peer is %d, but this is wrong. It should be paired
with inode easily.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
show: Show netdevice indices with %d

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
parasite: Report negative value from parasite_execure

The value in eax is positive on error. Callers expect it to
be negative to report error.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
scm: Check for cmsg not to be truncated when receiving fds

Otherwise we can get stuck waiting for more data in vain.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
fds: Optimize fds draning (mem + cpu)

* Don't dumplicate array when sending to parasite
* Allocate necessary space in cr-dump for local fds/flags

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>