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

208 Commits

Author SHA1 Message Date
Pavel Emelyanov
fc7071d05e net: Packet sockets basic support
Support only basic packet socket functionality -- create and bind.
This should be enough to start testing dhclient inside container.
Other stuff (filter, mmaps, fanouts, etc.) will come later.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-09 16:17:41 +04:00
Pavel Emelyanov
b0cf603b18 netlink: Pass argument through do_rtnl_req engine
Will need it int netns dumping callbacks later.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 07:36:12 +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
Pavel Emelyanov
b7b5bfdd28 libnetlink: Move the rtnl req routine into libnetlink.c
The function that does socket collecting is actually a rtnl
request sending one. It will be usefull for netns dump/restore,
so move it to generic place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-08-02 07:36:12 +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
eb0f81bc6f protobuf: Convert sk_opts_entry to PB format
This patch prepares the ground for further patches.
sk_opts_entry get converted to PB format but not
yet used anywhere in code. Also a few additional
pb_ helpers are added.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-07-19 09:31:00 +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
Pavel Emelyanov
60bd133e53 sk: Do not lookup a socket twice
The socket_desc is being looked up in dump_unix/dump_inet. In
the dump_socket this desc is only required to obtain a family,
which in turn can be done with a getsockopt.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-06-20 19:24:49 +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
Cyrill Gorcunov
c26b68dce8 sockets, unix: Use general machnism for checkpoint/restore v2
Use fdtype_ops facility to c/r unix sockets.

v2
 - BUG_ON added in dump_one_unix_fd if socket
   is already dumped since we never should dump
   same socket several times
 - The order of restore remains as it was before,
   the lookup is done via socket inode numbers

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-30 12:54:31 +04:00
Stanislav Kinsbursky
41195598cf parasite: remove excessive header deps from parasite.h and friends
The task is not complete - this is just a part of what have to be done. I.e.
looks like a lot of excessive deps can be fixed.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-30 12:50:18 +04:00
Andrey Vagin
066ec066a0 crtools: remove unused variables (v3)
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-18 19:01:21 +04:00
Pavel Emelyanov
33051cd3b3 sockopt: Add basic options dump/restore
Only snd and rcv bufs and timeouts. Just as an example, others will be adder
sequentially.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-10 14:29:57 +04:00
Pavel Emelyanov
7f82ae1133 sockets: Prepare for dumping/restoring/showing socket options
Those sitting on the SOL_SOCKET level are common to different
socket families and will be handled in a generic code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-05-10 14:29:57 +04:00
Pavel Emelyanov
051b0a1f02 tcp: Prepare sk-inet for dumping and restoring tcp connections
First of all -- to make crtools dump/restore established tcp sockets
you have to specify the --tcp-established options. By doing so you
inform crtools that

a) you know, that after dump there will be a netfilter rules blocking
   the dumped connections

b) you guarantee, that before restore this netfilter block is still
   there

What else this patch does is simple -- collects establised sockets and
calls the dump/restore tcp function (now empty) where appropriate.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-28 17:59:21 +04:00
Pavel Emelyanov
52cb8d43b9 sk: Move unix socket code to separate file
Funny, but after this git thinks, that I've renamed the sockets.c
file into sk-unix.c one and fixed it a little bit %)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-26 15:30:39 +04:00
Pavel Emelyanov
709bbc7f41 sk: Opencode sk_hash_lookup fns
For simpler unix socket code move.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-26 15:30:36 +04:00
Pavel Emelyanov
be6630bf27 sk: Opencode sk_hash_link
For simpler unix socket code move.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-26 15:30:35 +04:00
Pavel Emelyanov
518361dcaa sk: Move inet socket code to separate file
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-26 15:30:31 +04:00
Pavel Emelyanov
8cd64c5ae7 unix: Cleanup ext socket check
Rename the fn and fix indentation.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-26 15:30:30 +04:00
Pavel Emelyanov
fbcb43bd4b unix: Fix external socket dumping
Collect all unix sockets in a list while dumping to check
whether we've missed something early (at the restore time
it can be already late for roll-back).

Plus, fix the checks for external stream sockets.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-26 15:30:28 +04:00
Pavel Emelyanov
3b0a8e7c81 file: Factor out fowners and flags restore
This is common, that opened fd fix its fowner and flags. Make
a cuntion for this. Those that obtain fd with open() don't need
to restore flags though.

A thought -- do we need yet another abstraction between fdinfo and
type-d files?

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-26 15:30:26 +04:00
Pavel Emelyanov
1f94837afb sk: Sanitize socket's fowner and flags restore
The conn job misses fowner restoratio. Other places are ok, but toss
the code for easier next patching.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-26 15:30:25 +04:00
Konstantin Khlebnikov
bef7092834 Replace printf format "0x%x" with "%#x"
printf() has standard flag for adding "0x" prefix before hexadecimal integer.

MOD='[-+]\?[0-9]*.\?[0-9]*[lL]*'
git grep -l "0x%${MOD}x" | xargs -n1 sed -e "s/0x%\(${MOD}\)x/%#\1x/g" -i

Signed-off-by:    Konstantin Khlebnikov <khlebnikov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-24 15:20:24 +04:00
Cyrill Gorcunov
f737cb441f sockets: Move packet queue handling into sk-queue.h
Easier to read.

[ xemul: There's a silent change in how sk buffer is read in -- before
  the patch there was a static buffer for data, now this thing is
  xrealloc-ed ]

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-23 14:23:40 +04:00
Cyrill Gorcunov
94657b6be1 sockets: Add support for IPv6 sockets
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-23 14:10:44 +04:00
Cyrill Gorcunov
cd29ec489b sockets: Use socket family in show_inetsk
Needed for IPv6.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-23 14:07:58 +04:00
Cyrill Gorcunov
702ab17e16 sockets: Show uncollected socket ino in hex
To be in same form as collected sockets.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-23 14:07:28 +04:00
Cyrill Gorcunov
9634153dfc sockets: Align output in collected unix/inet sockets debug printing
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-23 14:06:55 +04:00
Cyrill Gorcunov
84cc188b24 sockets: Use socket family for inet_ntop
Will need it for IPv6

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-23 14:06:11 +04:00
Cyrill Gorcunov
19c1de828b sockets: Restore unconnected dgram sockets v7
In case if dgram socket peer is not connected back
we can try to resolve peer by name.

For security reason this happens only if '-x' option
is passed at checkpoint and restore time.

In particular this is needed for programs which do
use dgram socket to send messages to /dev/log.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-19 12:04:58 +04:00
Pavel Emelyanov
0e57ce29be files: Put fdinfo entry on fdinfo_list_entry
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-18 16:03:14 +04:00
Pavel Emelyanov
04800b6ed1 files: Rename fdinfo_list_entry's list to desc_list
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-18 15:46:04 +04:00
Kinsbursky Stanislav
231db3f80d output: add "0x" to hex prints manually
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-16 12:34:01 +04:00
Kinsbursky Stanislav
35eedb5f1f output: add "0x" to hex prints using sed
Command below was executed several times:

sed 's/\(pr_.*[^%,x,X]\)\(\%[0-9,l,L]*x\)/\10x\2/g' -i *.c

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-16 12:33:35 +04:00
Cyrill Gorcunov
62094fa851 sockets: Drop one-line alignment block
Make sense in multiline cases only.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-16 10:03:03 +04:00
Cyrill Gorcunov
6b391522df sockets: Print sockets ino and peer with %x format
Some ino/peers are printed with %d, some with %x,
get rid of it and print all in %x.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-13 18:01:16 +04:00
Pavel Emelyanov
09d9598074 sock: Add udp-lite sockets support
This is trivial. Just copy-n-paste pieces from the udp dumping
and restoring code. The zdtm test is also a compy of the _udp
test with respecitve changes.

Reuired for httpd, this one uses udplite sockets.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-13 10:42:30 +04:00
Cyrill Gorcunov
b9104ebc97 sockets: Fix potential NULL dereference
In case if unix socket was not found don't call for container_of.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-13 00:03:35 +04:00
Pavel Emelyanov
0e51036d16 show: Move extern print_data declaration from sockets.c to header
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 15:33:09 +04:00
Pavel Emelyanov
c96b201700 sockets: Mark open_unix_sk static
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2012-04-12 15:32:16 +04:00
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