2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-27 04:18:27 +00:00

167 Commits

Author SHA1 Message Date
Cyrill Gorcunov
196ce521a8 sockets: unix -- Retrieve backlog length for stream sockets
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 17:26:51 +04:00
Cyrill Gorcunov
942355c166 sockets: Nitpick for dgram dumping
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 17:26:50 +04:00
Cyrill Gorcunov
054bf4ada2 sockets: Allow to dump dgram sockets
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 17:26:50 +04:00
Cyrill Gorcunov
04ec43a5d5 sockets: Split open_unix_sk to stream and dgram versions
And add some comments.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-01-10 17:26:50 +04:00
Cyrill Gorcunov
f3ed69a339 sockets: Print socket id as well
Also make output a bit more fancy, as

CR_FD_UNIXSK: unixsk-2440.img
----------------------------------------
fd    3 type  1 state  1 namelen    0 id  19406 peer  19407
fd    4 type  1 state  1 namelen    0 id  19407 peer  19406
fd    5 type  2 state  7 namelen    7 id  19408 peer      0	---> [tst-sk]
fd    6 type  2 state  7 namelen    0 id  19409 peer      0
fd    7 type  2 state  7 namelen    0 id  19410 peer  19411
fd    8 type  2 state  7 namelen    8 id  19411 peer      0	---> [tst-sk1]
----------------------------------------

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-30 18:24:55 +04:00
Cyrill Gorcunov
2967bb9c37 sockets: Use reopen_fd_as helper
It also tests for possible dup() call error.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-30 15:34:05 +04:00
Pavel Emelyanov
96f92ee612 crtools: Cleanup open_image_ro
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-29 19:56:34 +04:00
Cyrill Gorcunov
935c8e75f0 net: sockets -- Use read_ptr_safe for magic number test
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-28 12:17:02 +04:00
Cyrill Gorcunov
4432c6447e net: sockets -- A few style tuneups
To follow rest of code

 - use !x for xalloc result tests
 - structure members are tab aligned
 - multiline assignments over structure members are aligned as well

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-28 12:16:51 +04:00
Cyrill Gorcunov
bc3370fc47 net: sockets -- Dont use multiline for() without braces
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-28 12:16:36 +04:00
Cyrill Gorcunov
c53408d6b7 net: sockets -- Make sure ue->namelen < UNIX_PATH_MAX
UNIX_PATH_MAX is a size of path, so max length
should never be equal to such size.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-27 23:32:17 +04:00
Cyrill Gorcunov
2ae99d73b9 net: Define named constant for nlmsg_seq
For better readability.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-27 20:13:18 +04:00
Cyrill Gorcunov
843747de55 net: A few changes in headres to follow c99
Since we're not system library

 - no underscopes in functions name until really needed
   and known to not clash with posix namespace
 - empty line between system headers and own headers
   for readability
 - extern for function prototypes

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-27 14:26:13 +04:00
Cyrill Gorcunov
f532e9fed2 net: sockets -- Use dprintk helper
Drop USK_DEBUG, we have dprintk which is active
if compiled with make DEBUG=1

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-27 14:26:02 +04:00
Cyrill Gorcunov
ccd5e2295f net: sockets -- Replace __u32 with u32
We provide such type in types.h.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-27 12:41:42 +04:00
Cyrill Gorcunov
4a015bba33 sockets: Use safe snprintf
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-27 00:17:24 +04:00
Pavel Emelyanov
c5eb61e866 Unix sockets initial support
Currently it can only work with stream sockets, which have no skbs in queues
(listening or established -- both work OK).

The cpt part uses the sock_diag engine that was merged to Dave recently to
collect sockets. Then it dumps sockets by checking the filesystem ID of a
failed-to-open through /proc/pid/fd descriptors (sockets do not allow for
such tricks with opens through proc) against SOCKFS_TYPE.

The rst part is more tricky. Listen sockets are just restored, this is simple.
Connected sockets are restored like this:

1. One end establishes a listening anon socket at the desired descriptor;
2. The other end just creates a socket at the desired descriptor;
3. All sockets, that are to be connect()-ed call connect. Unix sockets
   do not block connect() till the accept() time and thus we continue with...
4. ... all listening sockets call accept() and ... dup2 the new fd into the
   accepting end.

There's a problem with this approach -- socket names are not preserved, but
looking into our OpenVZ implementation I think this is OK for existing apps.

What should be done next is:

1. Need to merge the file IDs patches in our tree and make Andrey to
   support files sharing. This will solve the

	sk = socket();
	fork();

   case. Currently it simply doesn't work :(

2. Need to add support for DGRAM sockets -- I wrote comment how to do it
   in the can_dump_unix_sk()

3. Need to add support for in-flight connections

4. Implement support for UDP sockets (quite simple)

5. Implement support for listening TCP sockets (also not very complex)

6. Implement support for connected TCP scokets (hard one, Tejun's patches are not
   very good for this from my POV)

Cyrill, plz, apply this patch and put the above descriptions onto wiki docs (do we
have the plans page yet?).

Andrey, plz, take care of unix sockets tests in zdtm. Most likely it won't work till
you do the shared files support for sockets.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-26 23:25:04 +04:00