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
Cyrill Gorcunov
a8840ba721 fowners: Add checkpoint/restore for sockets
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 12:31:33 +04:00
Pavel Emelyanov
13ee53a098 sockets: Save and restore fd flags for sockets
For regfiles this is done at open() time, for pipes thit is done with fcntl. Use
the same fcntl approach for sockets.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-11 13:20:03 +04:00
Pavel Emelyanov
05e3c4d2c9 fd: Handle close-on-exec bits
This bit is not per-file, but per-fd, thus put it on the fdinfo_entry.
Draing these bits from parasite together with the fds themselves, save
into image and restore with fcntl F_SETFD cmd where applicable.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:36:59 +04:00
Pavel Emelyanov
adca8809fd sockets: Pass fd_parms into sockets dumping fns
This is required for proper close-on-exec handling (coming soon) and for fowners (coming soon
as well) and for file flags (yes, yes).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 18:10:19 +04:00
Pavel Emelyanov
6af08c3326 fd: Sanitize fd_parms fd_name field
It used to be ulong, but it can be int now (no mapping addresses there). And the
name fd is better than fd_name (reason is the same).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-10 17:49:39 +04:00
Pavel Emelyanov
43367e2545 fdinfo: Rename fdinfo_entry addr to fd
Now we store only real fdtable entries in this file, so it's
time to name the field properly and change type to u32.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-09 16:18:33 +04:00
Pavel Emelyanov
28a1474779 usk: The INFLIGHT flag is no longer used
It was required before we switched to socketpair restore
scheme. Now it's not required, sockets just connect to
the peer they want to.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 21:43:19 +04:00
Pavel Emelyanov
76c2818b95 files: Factor sending fd to peer via temp unix sk
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 21:20:28 +04:00
Pavel Emelyanov
b16293414b files: Generalize file open, get rid of explicit types switch
Introduce and use generic file_desc ops for this.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 20:39:48 +04:00
Pavel Emelyanov
3c174a885d files: Generalize fd restore, make file_desc common hash
No need in per-type hash tables and search routines. We can
handle it via generic file_desc structure. Some more thoughts
on unixsk and pipe lists are still required :(

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 20:30:48 +04:00
Pavel Emelyanov
527b67b91f files: Generalize fd restore, introduce file_desc
The struct replaces bare list_head on all of the _info-s we've
introduced recently.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 20:08:48 +04:00
Pavel Emelyanov
f89170eaae sockets: Remove unused listen hash
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 19:32:41 +04:00
Pavel Emelyanov
b386751697 sockets: Rework unix sockets onto fdinfo scheme
This is a big change, yes. Dump unix sockets in the same manner
as all the other files are done now. A few notes however.

1. We explicitly drop names for connected stream sockets. This is
   done to avoid conflicts with names -- accepted sockets share their
   names with the listening parent. This can be done later by binding
   a socket to a name, them renaming it to some temporary uniq one
   and at the very very end renaming some back to original.

2. Interconnected sockets are restored via socketpair() call. This is
   correct, but names are dropped. Need to bind() sockets after this
   (yes, this can be done), but for this we need to implement the trick
   with renames described before.

3. FD for socket queues is constantly re-opened not to resolve fd
   conflicts. Need to use service fds engine for this later.

4. Some code cleanup is still required, yes (will follow shortly).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-06 19:27:08 +04:00
Pavel Emelyanov
637a95f8d0 sockets: Check for unix being properly interconnected on dump
Add two checks -- that peer exists and it we will be able to
connect to him somehow on restore.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 18:12:51 +04:00
Pavel Emelyanov
86489a545d sockets: Drop socket name for any bound-to-unlinked case
This maybe not 100% correct in the generic case, but the way unix sockets are
used lets us do this trick.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 17:39:33 +04:00
Pavel Emelyanov
12316c4994 files: Ease the fd collecting
No need in separate per-type fn for doing this. We can just
find the respective fd list and do sorting in the generic code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 16:54:10 +04:00
Pavel Emelyanov
b9f13599a9 files: Simpler regfiles and sockets open
The list_head ptr passed into it can be converted into
the respective _info with container_of, rather than search.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 12:49:34 +04:00
Pavel Emelyanov
eee874e465 files: Rework the way fdinfos are collected
Now fdinfos are collected independently from reg files and
sockets. During tihs collect we effectively create the mirroring
list of both by checking which type-IDs are added first.

Fix this by removing the fdinfo_desc and attaching fds directly
to collected reg files and sockets. Pipes and unix sockets will
be reworked in the same manner soon.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-05 12:45:30 +04:00
Pavel Emelyanov
54c1979c84 unix: Collect unix sockets early on restore
Same as prev 2 patches now for the unix sockets. They are still in per-pid image files, but
this is going to change soon (I hope).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-03 00:58:41 +04:00
Pavel Emelyanov
94a11df0a1 inet: Collect inet sockets early on restore
Same as previous patch -- pull inet sockets in and store in the hash for the same reasons.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-03 00:54:52 +04:00
Cyrill Gorcunov
fca43c1abe sockets: Drop unused variables
Otherwise I get

 | sockets.c: In function ‘dump_socket’:
 | sockets.c:467: error: ‘st.st_ino’ may be used uninitialized in this function

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-02 22:42:01 +04:00
Cyrill Gorcunov
766bbf1631 sockets: Fix compilation on older kernel headers
Since kernel commit 9c501935a3 the sys/socket.h
should be included prior the linux/netlink.h.

Make it so.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-02 22:40:53 +04:00
Pavel Emelyanov
66771c8fbc sockets: Dump socket queus without parasite
Since now we have local copies of a remove FDs we can dump socket queus without entering
a parasite code. This makes the code MUCH simpler.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-29 16:44:15 +04:00
Pavel Emelyanov
bac56b11c0 sockets: Remove statfs and 2nd stat from dump process
The statfs is not required, we now check for fd being a socket with S_IFSOCK.
The 2nd stat is just not needed, the caller provides stat info.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-29 16:40:10 +04:00
Pavel Emelyanov
8ecb454bf7 dump: Rename try_dump_socket
Try meant that it might not be a socket, but with local fds we do know
it for sure.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-29 16:37:49 +04:00
Pavel Emelyanov
40a79dbc98 sockets: Show socket info in human-readable form
IOW, show family, type, state and proto as strings, not bare numbers.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-27 13:11:23 +04:00
Pavel Emelyanov
9b2617353b inet: Rework inet sk dumping on new fdinfo scheme
Now every inetsk fd dump results in a new entry in the fdinfo.img file. Sockets itself are
dumped into inetsk.img global image file. On restore the generic fdinfo redistribution algo
is used and inet sockets are opened only when required.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-27 12:42:59 +04:00
Pavel Emelyanov
c58abfd03d show: Introduce ->show callback for fdset
Each fdset item now has the callback which will show a contents of a magic-described
image file. Per-task and global show code is reworked to walk the respective fdsets
and calling ->show on each file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-27 12:01:14 +04:00
Pavel Emelyanov
bcf9ee3d1c fdset: Helper for getting fd out of a set
This patch does

s/$fdset->fds[$nr]/fdset_fd($fdset, $nr)/

over the code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 22:56:59 +04:00
Pavel Emelyanov
f1429be087 dump: Don't include sk-queues fd in task set
This fd is global, so make it such. It will stop being just a global
variable soon.

Plus, remove the pid arg from format.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-26 22:56:44 +04:00
Pavel Emelyanov
1c12a31893 udp: Restore UDP sockets
Reuse the TCP socket restore, just add connect() and sanity checks
for protocol.

This is OK, since UDP connect doesn't go to network for connection
and (unlike unix sockets) doesn't require peer to be "online". It
just puts the peer's creds on socket and returns.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 15:54:42 +04:00
Pavel Emelyanov
bad126e7a5 sock: Add dst creds to socket structs
These are required for inet sockets, but were not added since listen
sockets do not have them.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 15:54:42 +04:00
Pavel Emelyanov
ba562bc272 show: Fix inet sockets show "loglevel"
Showers should use pr_msg to avoid loglevel issues.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 15:54:42 +04:00
Pavel Emelyanov
b198d76e40 udp: Allow dumping udp sockets
Just a small fixlet in can_dump_inet_sk.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 15:54:42 +04:00
Pavel Emelyanov
625c45ea79 udp: Collect socket with diag
Partially reuse the existing TCP code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-03-02 15:54:42 +04:00
Cyrill Gorcunov
7aa8e4b6e2 log: log-engine slight redesign
The messages are filtered by their type

    LOG_MSG     - plain messages, they escape any (!) log level
                  filtration and go to stdout
    LOG_ERROR   - error messages
    LOG_WARN    - warning messages
    LOG_INFO    - informative messages
    LOG_DEBUG   - debug messages

By default the LOG_WARN log level is used, thus LOG_INFO
and LOG_DEBUG messages will not appear in output stream.

pr_panic helper was replaced with pr_err, pr_warning
shorthanded to pr_warn and old printk if rather pr_msg
now.

Because we share messages between "show" and "dump" actions,
before the "show" action proceed we need to tune up
log level and set it to LOG_INFO.

Also note that printing of VMA and siginfo now
became LOG_INFO messages, it was not that correct
to print them regardless the log level.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-03-02 01:05:43 +04:00
Kinsbursky Stanislav
46535130c6 restore: UNIX sockets queue support
Based on xemul@ patches.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-29 17:42:30 +04:00
Kinsbursky Stanislav
e518c44c7c show: UNIX sockets queue support
Based on xemul@ patches.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-29 17:42:30 +04:00
Kinsbursky Stanislav
131f5a1d49 dump: UNIX sockets queue support
Based on xemul@ patches.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-29 17:42:30 +04:00
Kinsbursky Stanislav
e6f39a41bf restore: socket queues support
This patch was designed to be generic and thus usable for all kinds of
sockets. Not sure, thah this goal has been reached, but at least I tried.

Key ideas:
1) sockets queue dump file have to be readed first and then packets entries
   with offset for it's data in image will be collected in doubly linked list by
   read_sockets_queue() function.

Note: list will contain sockets queues for all (!) the sockets of the task.

2) socket queue can be restored by restore_socket_queue(), which selects
   packets from the list by passed id and use sendfile() top send them to the
   passed socket. It also removes packet from the list and frees it.

Based on xemul@ patches.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-29 17:42:30 +04:00
Kinsbursky Stanislav
c19012326d dump: socket queues support
This patch was designed to be generic and thus usable for all kinds of
sockets. Not sure, thah this goal has been reached, but at least I tried.

Key ideas:
1) On-stack structure for collecting sockets queues and then passing them to
   parasite code.
2) Singly linked list is used for collecting structures, representing sockets
   of any kind (!) with queues.

Based on xemul@ patches.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-29 17:42:30 +04:00
Cyrill Gorcunov
ef97467da9 log: Add log-levels
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-02-20 14:23:28 +04:00
Kir Kolyshkin
76a0186c1c sockets.c: use pr_perror() where appropriate
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-11 11:58:32 +04:00
Kir Kolyshkin
41fb6b3f6b show_unixsk(): avoid buffer overflow
Say in case of corrupted img file

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-11 11:58:23 +04:00
Kir Kolyshkin
bf1ca46d43 show_unixsk(): show backlog for real
This is probably a typo in commit 1a1979c

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-11 11:58:15 +04:00
Kir Kolyshkin
82e548ecca socket.c: use const whenever possible
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-10 18:07:19 +04:00
Kir Kolyshkin
d5fa75c004 sockets.c: Fix/unify some error messages
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-10 18:07:19 +04:00
Kir Kolyshkin
fb59be3c11 sockets.c cleanup: break long lines
No code change, pure cleanup

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-10 18:07:19 +04:00
Kir Kolyshkin
26a7056c26 sockets.c cleanup: no need for backslash when "calling" a define
Fix too long line while at it.
No code change, pure cleanup.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-10 18:07:19 +04:00
Pavel Emelyanov
54091c9b73 sockets: Fix dgram socketpair restore
These are connected, but don't have names. Thus the connect
job fails on them. Use fake ones.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-10 16:06:49 +04:00