2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-26 11:57:52 +00:00

167 Commits

Author SHA1 Message Date
Pavel Emelyanov
f27c83c70c sockets: Off by one in fake address preparation
The fake bind name is trimmed on 1 char.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-10 16:06:39 +04:00
Pavel Emelyanov
82a8a8ff95 sockets: Decode kernel dev_t into stat's one
Unix diag and stat report dev_t-s in different formats. Cast one to
another when comparing in unix dumping.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-08 16:11:27 +04:00
Pavel Emelyanov
02c8793c6e sockets: Fix file-bound sockets check
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-08 12:55:21 +04:00
Pavel Emelyanov
5b8c7bbf84 sockets: Helper for scheduling acc job
There's only one place with this, but the helper makes the code look
almost perfectly.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:28:08 +04:00
Pavel Emelyanov
bc9089e57e sockets: Use RW API in bind sk helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:27:58 +04:00
Pavel Emelyanov
57eea3d3fd sockets: Helper for binding unix socket
This one reads a name from image, does preparations for bind and calls bind.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:27:51 +04:00
Pavel Emelyanov
e1ed063f79 sockets: Merge dgram and stream listeners
They fully coincide now, just need to distinguish them by socket type.
Thus, add the type member on the unix_sk_listen and merge two hashes.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:27:43 +04:00
Pavel Emelyanov
2d9873e051 sockets: Helper for scheduling conn job
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:27:31 +04:00
Pavel Emelyanov
b845fa3424 sockets: Merge dgram and stream conn jobs
Structure used is the same, logic of connection is the same, and the
infrastructure is ready for this.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:27:24 +04:00
Pavel Emelyanov
23cf6f84d9 sockets: Replace sockets conn job flags with type
Required for simpler future patching.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:27:16 +04:00
Pavel Emelyanov
8f70115461 sockets: Factor dgram conn job structures more
The unix_dgram_peer coincides with the unix_conn_job.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:27:09 +04:00
Pavel Emelyanov
5bff96f758 sockets: Factor dgram conn job structures
The unix_dgram_bound fully coincides with the unix_sk_listen.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:27:01 +04:00
Pavel Emelyanov
fe598403df sockets: Delay dgram connection
By the time we try to resolve datagram socket connection name the other
end may not yet be on the hash. Move the address resolution into the
conn job.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:26:52 +04:00
Pavel Emelyanov
aeabf03133 sockets: Datagram connection fix
The address length should be the real length, not the buffer size.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-07 17:26:43 +04:00
Cyrill Gorcunov
6f589a4f6e sockets: Fix a few problems if compiled with DEBUG=1
sockets.c: In function ‘show_one_inet_img’:
sockets.c:151:2: error: format ‘%d’ expects argument of type ‘int’, but argument 9 has type ‘char *’ [-Werror=format]
sockets.c: In function ‘open_unix_sk_stream’:
sockets.c:925:10: error: unknown escape sequence: '\C' [-Werror]

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-02-01 17:23:44 +04:00
Cyrill Gorcunov
229defc928 Make sure no uninitialized values are used
I've got it if -O2 compilation option used.

 | cr-restore.c:1069:5: error: ‘ret’ may be used uninitialized in this function [-Werror=uninitialized]
 | sockets.c:1145:7: error: ‘sk’ may be used uninitialized in this function [-Werror=uninitialized]

In first case 'ret' indeed might be uninitialized, and
in second case "goto err" was called too early. Fix them both.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-01 15:24:39 +04:00
Kir Kolyshkin
6c9d6a86a4 sockets.c: fix printf format warnings
sockets.c: In function ‘try_dump_socket’:
sockets.c:366:3: error: format ‘%d’ expects type ‘int’, but argument 4 has type ‘__ino_t’

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-31 15:57:25 +04:00
Kir Kolyshkin
0b237ae9f2 pr_perror(): print error at the end of line
This is a standard convention to print error message (i.e. strerror(errno))
at the end of line, like this:

        Cannot remove file: Permission denied

So pr_perror is fixed to follow this convention (using GNU extension
%m helps a lot here). Unfortunately, due to this we have to make
pr_perror() print a new line character, too, so we had to strip it
from the all pr_perror() invocations.

That (appending a newline) also makes pr_perror() a black sheep
in the herd of pr_* helpers, but what can we do? Worst case scenario
is an extra newline after an error message, not too harmful.

An alternative approach (stripping the newline from the passed format
string and re-adding it) was discussed thoroughly, and it was decided
that such a hack looks a bit too dirty.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-31 15:49:15 +04:00
Cyrill Gorcunov
29bda9aae5 sockets: Restore in-flight unix stream sockets
It's done in two steps

 - On checkpoint we find which icons are present
   over all sockets and setup peer number to
   appropriate listening socket

 - On restore we collect listening sockets and once
   we find in-flight connection we search for appropriate
   listening socket name and use it to call connect() then

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-27 23:21:06 +04:00
Cyrill Gorcunov
f974de9c49 sockets: Add SK_HASH_LINK helper
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-27 23:21:06 +04:00
Cyrill Gorcunov
641844c349 sockets: Allow to dump unix sockets with inflight connections
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-27 23:21:06 +04:00
Cyrill Gorcunov
b21c2c8c1d sockets: Print icons numbers in debug printing
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-27 23:21:06 +04:00
Cyrill Gorcunov
b0e4a2edcd sockets: Add nr_icons member to track number of icons instead of zero ended array
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-27 23:21:06 +04:00
Cyrill Gorcunov
ff83500f5c sockets: sockest: Show collected socket once they get hashed
Otherwise debug printing has no inode number in report.
Not really it's that important but very convenient
if you need detailed output.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-27 23:21:06 +04:00
Cyrill Gorcunov
9b2e191392 sockets: Nitpick on error printing in open_inet_sk
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-27 20:19:01 +04:00
Cyrill Gorcunov
9d913b6551 sockets: Fix freeing dgram sockets data
Otherwise use-after-free error happens.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-27 02:33:32 +04:00
Cyrill Gorcunov
b0467f2d8c sockets: Report relative name itself
This is more informative to know which exactly name failed.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-25 16:55:36 +04:00
Pavel Emelyanov
164ccc095f crtools: R/W API rewrite
Kill all the macros for reading/writing image parts. New API looks like

* write_img_buf/write_img
  Write an object into an image. Reports 0 for OK, -1 for error. The _buf
  version accepts object size as an argument, the other one uses sizeof()

* read_img_buf/read_img
  Reads an object from image. Reports 0 for OK, -1 for error or EOF.

* read_img_buf_eof/read_img
  Reads an object from image. Reports 1 for OK, 0 for EOF and -1 for error.
  This is not symmetrical with the previous one, but it was done deliberately
  to make it possible to write code like

  ret = read_img_bug_eof();
  if (ret <= 0)
	return ret; /* 0 means OK, all is done, -1 means error was met */.

  ... /* 1 means object was read, can proceed */

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-23 01:43:10 +04:00
Cyrill Gorcunov
4184d2f6a6 sockets: Rename struct inet_diag_req to inet_diag_req_v2
There was API change in linux kernel 3.2 -> 3.3 transition

 | commit c8991362a0d3cf317dfbfb6cb946607870654e6d

Reported-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-20 16:40:56 +04:00
Pavel Emelyanov
2a76c6409c socket: Don't request extensions from inet diag
This eats response skb mem, but we don't need it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-19 22:41:24 +04:00
Pavel Emelyanov
381559a7f6 socket: Ignore collection errors for now
We can do it since we may not want to dump the missed sockets.
But later, when we will start dumping containers, we'll better
fail here, rather than in the dump stage.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-19 22:41:15 +04:00
Pavel Emelyanov
a722abce77 socket: Use read_ptr_safe_eof
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-18 18:32:20 +04:00
Pavel Emelyanov
379dde63f5 sockets: Clean usk_img dereference
There's no need in img fd pointer in opening functions.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-18 18:31:42 +04:00
Stanislav Kinsbursky
dd0f72f220 restore: IPv4 listening sockets restore support
This patch adds support for restoring IPv4 listening sockets.
Based on unix sockets restore.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-18 12:39:08 +04:00
Stanislav Kinsbursky
7fc6561c0c show: inet sockets dump parsing support added
Nothing to comment there.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-18 12:39:04 +04:00
Stanislav Kinsbursky
f3253a40d2 checkpoint: IPv4 listening sockets dumping support 2012-01-18 12:38:58 +04:00
Stanislav Kinsbursky
654216c1df checkpoint: generalize netlink requests code
This is a precursor patch. Netlink request code is mostly the same for any
kind of sockets. Only 2 places differs: request creation and callback address.
This patch parametrizes netlink call function with a pointer to a request
structure, request size and receive callback, which replaces hard-coded unix
sockets parts.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-18 12:38:54 +04:00
Cyrill Gorcunov
9792a860b3 dump: Fix arguments types in printing
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-13 23:04:20 +04:00
Cyrill Gorcunov
1c96c5cff0 Merge branch '@xemul' into dev
* @xemul:
  crtools: Collect dumping fd parameters into one place
  crtools: Toss dump_one_fd args around
  crtools: Rename fd to lfd in dump_one_fd
  crtools: Sanitize pstree construction
  crtools: Remove unused printk_registers and co
  crtools: Deduplicate file info showing code
  crtools: Merge pstree collecting into showing
  crtools: Remove unused and wrong arrays from pstree image
  crtools: Remove lseeks after prep_cr_ calls
  crtools: Cleanup collect_pstree in cr-show

Conflicts:
	cr-dump.c
	include/sockets.h
	sockets.c

The conflicts are mostly because of commit
995ef5eca3b8d74cf192e41c307f5329d93f9795

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-13 21:39:14 +04:00
Cyrill Gorcunov
995ef5eca3 Use openat() helper intensively when opening /proc/pid/X files
This allows us to get rid of open-coded "/proc/pid/X".

Based-on-patch-from: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-13 18:29:18 +04:00
Stanislav Kinsbursky
7eec5a9e0c Sockets: replace macroses concatenation with single one for netlink requests
NLM_F_DUMP is already defined as (NLM_F_ROOT|NLM_F_MATCH)

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-13 16:38:10 +04:00
Cyrill Gorcunov
3bba868e92 sockets: Allow to reuse fd in run_accept_jobs
Sockets are special and we reuse fds in accept jobs.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-13 13:26:39 +04:00
Pavel Emelyanov
1b247eb6b4 crtools: Toss dump_one_fd args around
Make the dump_one_fd fn accept local fd and integer target fd values
instead of target fd dir and target fd string name.

This saves couple of atoi-s (done once) and makes the next patch simpler.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-12 22:09:59 +04:00
Cyrill Gorcunov
6030463122 sockets: Fix memory leak on relative bind path
In case if relative bind path found we skip such
socket but forget to free previously allocated
memory.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-12 19:28:46 +04:00
Andrey Vagin
49074a98c4 socket: skipe unsupported sockets (v2)
We collect all unix sockets in the current net namespace, but
a target process uses a few of them, so we may skip unsupported sockets
and if it is used by a target process, lookup_socket returns error.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-12 19:04:56 +04:00
Pavel Emelyanov
15209d3fe9 crtools: Make fdset be an array of file descriptors
Path is not needed there -- we can call the get_image_path() in prep_cr_fdset_
routines and in parasite-syscall.c when required.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-12 18:51:06 +04:00
Pavel Emelyanov
e710c5c5ef crtools: anitize showing funtions
Remove unneeded path argument (we do know the file data is read from) and
actually bogus show_header boolean.

Also introduce two helpers for showing header and tail.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-12 18:50:59 +04:00
Cyrill Gorcunov
dffaab578d sockets: Restore dgram sockets
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-01-10 17:38:55 +04:00
Cyrill Gorcunov
930432f161 sockets: Make socket name printing similar to vmas
Use same format as we do for VMA names.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 17:26:51 +04:00
Cyrill Gorcunov
1a1979cc88 sockets: Show backlog length in "show" procedure
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 17:26:51 +04:00