2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 05:48:05 +00:00

59 Commits

Author SHA1 Message Date
Cyrill Gorcunov
27582e3272 inet: Restore SO_REUSEADDR in case of rollback
tcp_repair_off implicitly modifies SO_REUSEADDR option
inside the kernel (thanks avagin@ for pointing this
feature out) thus if we are to rollback and restore
the former settings of socket -- don't forget to
repair this particular one.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-16 14:48:24 +04:00
Pavel Emelyanov
d020ebb36d files: Compact the code by removing per-file dump helpers
Since *all* of them just call do_dump_gen_file with proper ops,
just call one directly. Compacts the code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-06-14 00:11:08 +04:00
Pavel Emelyanov
add21b75c9 show: Remove options args from ->show callback
This thing is global, we can address one explicitly.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-08 00:23:42 +04:00
Kir Kolyshkin
d90d4b1b88 Fix typos in log messages
Someone has to do it, right?..

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-15 12:46:25 +04:00
Pavel Emelyanov
2ab06c9c5a tcp: Schedule tcp socket for repair-off with proper fd
The fd in -> open callback is temporary (the files restoring
engine will re-open one under some other fd). But since we
add this fd to future repair off, this off will fail working
on wrong fd.

Move scheduling for repair-off into port-open where the corrent
fd is known.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-11 21:10:37 +04:00
Andrey Vagin
aaad8054ee sk-inet: drop proto from struct inet_sk_desc
It isn't required anymore

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-28 18:23:20 +04:00
Andrey Vagin
d2b1d6f2aa socket: prevent dumping of sockets if they are not collected
The idea is simple. If the collection of given type of sockets failed,
crtools can't be sure, that it's able to dump such sockets correctly.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-28 18:23:18 +04:00
Andrey Vagin
f9b3dd7ad5 sk-inet: fix error handling
Currently do_dump_one_inet_fd returns ret, but this variable is
overwritten a few times and it can be zero on error paths.

Use a separate variable for the function exit code. By default it is -1
and it is set to zero at the end. It's not changed anywere anywhere
except these two places.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-28 18:21:24 +04:00
Alexander Kartashov
2d70f89664 protobuf: cast the result of the macro pb_repeated_size to size_t
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 11:41:43 +04:00
Andrey Vagin
b1abc3b21c restore: don't desable tcp repair mode twice
TCP repair mode should be disabled after unlocking connections.
Disabling of repair mode drops SO_REUSEADDR, so it should be restored.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-14 18:47:19 +04:00
Andrey Vagin
0fc129a121 files: pass a file descriptor on an fdinfo image instead of cr_fdset
Currently fdinfo dumps for each task, so CR_FD_FDINFO is in cr_fdset.
A few tasks can share one fd table and the set of descriptors will be
dumped once and a image name will contain files_id instead of pid.
In this case CR_FD_FDINFO will go away from cr_fdset.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-11 14:47:09 +04:00
Alexander Kartashov
6f61488f21 x86: moved x86-specific files into the directory arch/x86.
* The following files goes into the directory arch/x86/include/asm unmodified:
  - include/atomic.h,
  - include/linkage.h,
  - include/memcpy_64.h,
  - include/types.h,
  - include/bitops.h,
  - pie/parasite-head-x86-64.S,
  - include/processor-flags.h,
  - include/syscall-x86-64.def.

* Changed include directives in the source files that include the headers
  listed above.

* Modified build scripts to reflect the source moves.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-09 17:02:47 +04:00
Andrey Vagin
08ffa65ed5 socket: don't fail if DIAG_SHUTDOWN is absent
A error message is printed.

We want to save ability to try crtools on non C/R kernel.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-11-29 17:43:32 +04:00
Pavel Emelyanov
a6a476ff23 skopts: Prepare for xmalloc-able entries on SkOptsEntry 2012-11-01 17:53:57 +03:00
Pavel Emelyanov
60d382f990 inet: Make tcp_connection inline fn
Now it's used for images only.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 22:30:00 +03:00
Pavel Emelyanov
bf8b7c4f89 inet: Reshuffle proto-level socket dumping
We'll support other tcp states and udp-specific info eventually.
This introduced switch() looks more friendly to this future.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 22:25:57 +03:00
Pavel Emelyanov
8abab0dae7 udp: Warn when read queue is dropped on dump
It's not blocking dump, dgram sockets can lose data. Just emit
a warning in log.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 22:06:45 +03:00
Pavel Emelyanov
6de7b7b395 udp: Don't dump dgram socket with corked data in it
We can't dump application that put some data in write queue and is
about to add more, as there's currently no way to fetch this data
back, and just dropping it means breaking the app-level protocol.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 22:04:46 +03:00
Cyrill Gorcunov
0678ea2e15 sk-inet: More detailed error parsing on unconnected socket
errno is no guaranteed to be clear if call exit with
success. Thus make sure we've ret negative here and
test for errno then.

http://bugzilla.openvz.org/show_bug.cgi?id=2412

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 20:54:20 +04:00
Cyrill Gorcunov
b110af6eec sk-inet: No need for 128 byte address
The SO_PEERNAME sockopt reports -EINVAL if the len passed is greater
than the real one, and copies part of the address otherwise. Need to
pass there "good" optlen not to get -EINVAL falsely. On the other
hand, since we only need to check for connected/not-connected it's
enough to push there 1 byte.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-30 20:53:49 +04:00
Pavel Emelyanov
93d41b1a83 inet: Disable dumping of shutdown sockets
This requires more work than for unix sockets. For now
report that we cannot do it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-10-24 18:39:54 +04:00
Andrey Vagin
458cb41f57 restore: disable repair mode in post_open()
A disabling repair mode drops SO_REUSEADDR.

We can set SO_REUSEADDR after disabling repair mode, but
a small race window exists in this case.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-27 23:16:50 +04:00
Pavel Emelyanov
3dd03b6e27 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>
2012-08-20 18:16:33 +04:00
Pavel Emelyanov
6fd87cd98b 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>
2012-08-20 18:14:02 +04:00
Pavel Emelyanov
a8e056bfc8 inet: Factor out sockaddr-s preparations
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-20 18:11:35 +04:00
Andrey Vagin
a74605a78d 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>
2012-08-20 17:50:08 +04:00
Pavel Emelyanov
fb5a5671c8 sock: Do strict socket family checks when looking up collected socket
We hash socket with inode and family, but search only by inode. Well,
yes, family should match, since all sockets are in one sockfs in kernel,
but let's make sure _we_ did things right by checking the family as well.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-15 19:16:12 +04:00
Stanislav Kinsbursky
96b62808ff protobuf: use pretty output for inet sockets
v4:
1) Only address specificator ('A') left

New custom specificators:

'A': output as socket address

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-14 14:50:48 +04:00
Andrey Vagin
acf73093df 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>
2012-08-14 12:46:43 +04:00
Andrey Vagin
6afafb12ca 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>
2012-08-14 12:39:23 +04:00
Pavel Emelyanov
51133437c9 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>
2012-08-11 22:41:29 +04:00
Pavel Emelyanov
d10ee39f28 code: Fix checkpatch.pl warnings since v0.1
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-11 22:03:11 +04:00
Pavel Emelyanov
321a71fd82 sk-inet: Fix for inet address checks validation
Bug introduced by 27d62237e5e2. Sorry about it :(

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-10 10:17:18 +04:00
Pavel Emelyanov
27d62237e5 inet: Sanitize addresses size handling
We use repeated u32 field for IPv* address. For ipv4 there's 1 element
in it, for ipv6 -- 4. Validate these sizes in image and check that
sockaddr_in* elements sizes match.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-10 07:58:19 +04:00
Stanislav Kinsbursky
9e03fd584b sk: optimize dump size a bit
Let's carry only on uint_32 for IPv4 address.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-10 07:40:54 +04:00
Pavel Emelyanov
216a3a6521 sk: Add level to socket option dump/restore helpers
Packet socket need SOL_PACKET one.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-09 17:25:11 +04:00
Pavel Emelyanov
b91445701b img: Introduce generic routine for collecting image entries
On restore we typically read an image and put the entries into
some hash/list/whatever to work on them later. It's handy to have
a generic routine for doing so.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-09 13:16:46 +04:00
Stanislav Kinsbursky
8de0434788 restore: don't BUG_ON() if inet address image size is wrong
This aptch replaces BUG_ON's by return of error code.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-07 19:27:38 +04:00
Pavel Emelyanov
b1b0a39a58 pb: Rewrite object reading to use pb-descs
The pb_read thing is no longer a macros. This will allow to
factor out objects collecting on restore.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-07 19:22:00 +04:00
Pavel Emelyanov
2398c55e41 pb: Rewrite object writing to use pb-descs
The pb_write thing is no longer a macros.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-07 19:21:59 +04:00
Pavel Emelyanov
cffe1ea172 netlink: Remove handmade rtnl macros/definitions
All we need is (should be) in rtnetlink.h

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 07:36:12 +04:00
Cyrill Gorcunov
ba85bf30bd sk-inet: Init addr_size variable
Since we've BUG_ON(1) here so this is
not a problem, but lets make compiler happy.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-31 14:09:39 +04:00
Pavel Emelyanov
9fc1d6bbeb fdinfo: Make fdinfo.type be an enum
This types specifies a strict set of what is hidden behind
the fd. Thus these numbers should be in the description of
the fdinfo message.

Plus protobuf makes shure nothing else will be there.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 10:18:37 +04:00
Cyrill Gorcunov
0cf04ac781 protobuf: Drop old sk_opts_entry structure
We've switched to SkOptsEntry, no need to carry this
obsolete one.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 09:44:41 +04:00
Cyrill Gorcunov
0468355c12 protobuf: Drop fown_t type
We are ready to use FownEntry everywhere,
so drop fown_t type and clean up source code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 09:39:00 +04:00
Cyrill Gorcunov
8d92c2c3b2 protobuf: Convert inet sockets to PB engine
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 09:33:33 +04:00
Cyrill Gorcunov
65570d9559 sockets, inet: Use inet_sk_entry as a reference in inet_sk_info
For PB transition.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-16 07:03:59 +04:00
Pavel Emelyanov
e23c9e0cda inet: Report error if inet socket collect failed
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-10 12:56:54 +04:00
Cyrill Gorcunov
37131e51b1 sockets: Restore unbound inet sockets v5
v2:
 - Use do_dump_opt in dump_socket to not call
   lookup_socket redundantly

v3:
 - use getsockopt to check that unconnected
   socket has no peername and it's not listening
 - do test only socket protocol since family and
   type will be called in dump_one_inet_fd.

v4:
 - Move proto tests to can_dump_inet_sk
 - Use SOL_TCP/TCP_INFO to gather info about tcp sockets

v5:
 - hash unconnected sockets to run BUG_ON(already-dumped) logic
 - no default value for sk->wqlen, use zero from xzalloc
 - drop bogus xfree on error

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-01 14:42:42 +04:00
Cyrill Gorcunov
424a4adb6f sockets, inet: Use general machnism for checkpoint/restore v2
Use fdtype_ops facility to c/r inet sockets.

v2:
 - Use BUG_ON if socket is attempted to be dumped
   several times

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-30 12:56:04 +04:00