code: Remove trailing whitespaces over .c and .h files

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
code: Fix spaced indentation where found

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
code: Fix while ( formatting

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
code: Brush up multi-line comments first line

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
code: Replace 0x%x with %#x in messages

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
log: Replace perror-s with pr_perror-s over code

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
code: Fix checkpatch.pl warnings since v0.1

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
code: A little but more checkpatch fixes over code

There are more in test/ (and checkpatch.pl crashes in the middle =),
but seem to be all.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
sock: Cleanup inet sockets collecing

There is no need in 6 receive callbacks -- we can find out family and protocol
(and thus -- type) out of the inet_diag_req_v2 passed through transparent arg
of nlk request engine.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
fd: Remove per-filetype make_gen_id abstraction

It doesn't makemuch sense in pulling this further. The generic genid generation seems to
be enough for eny file type.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
sk-inet: if a source port isn't zero, a socket should be bound (v2)

Now crtools checks address, but it may be zero. For example,
a listen socket is bound to zero address to accept connections
from any addresses.

v2: add a comment about zero port

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
sk-inet: save the socket option IPV6_V6ONLY (v2)

Most part of services (ssh, httpd, ...) create two separate sockets
one for ipv4 and one for ipv6. If IPV6_V6ONLY isn't dumped, bind() returns
EADDRINUSE

v2: use do_dump_opt and initialize yes = 1

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
sockets: fail if an unsupported socket is in a dumped netns

If netns is dumped, crtools fails if it collects unsupported sockets.

If netns isn't dumped, crtools will fail only
if an unsupported socket should be dumped.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
net: define PACKET_TIMESTAMP

It's required for compiling on RHEL6

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
crtools: write a pid of a root task in a specified file

When we restore a pid namespace the root task will get some unknown pid
in the original (i.e. -- the ns crtools a launched from) one. To find
this pid out one can use this option -- it will make the pid obtained by
the new init to be written into a pid file.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: move all logic about namespaces from test_init in libzdtm

A test will be executed in new set of namespaces if the environment
variable ZDTM_NEWNS is set. A pid of the root task will be written in
$ZDTM_PIDFILE and a root fyle system will be changed on $ZDTM_ROOT.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restore: Don't mess with last_pid when restoring pidns init

When we fork a pidns init there's no need in specifying its pid,
as it will be autogenerated to 1. Clean the code not to mess with
the last_pid sysctl at all in that case, rather than just omitting
the write into it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
make: Add -fno-strict-aliasing

Since we use some kernel tricks for CMSG_FIRSTHDR
some compilers (in particular gcc version 4.4.5
20110214 (Red Hat 4.4.5-6)) do complain about strict
aliasing.

Thus pass -fno-strict-aliasing to be on the same
coast as kernel is.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
make: Build crtools with -O2 by default

Enable debugging only if DEBUG=1 provided.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: fix compile error in case of NEW_IPC_NS is not set

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>