Difference between revisions of "Sockets"

From CRIU
Jump to navigation Jump to search
(Created page with "== 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 th...")
 
Line 2: Line 2:
  
 
Currently it can only work with stream sockets, which have no skbs in queues
 
Currently it can only work with stream sockets, which have no skbs in queues
(listening or established -- both work OK).
+
(listening or established -- both work OK). If there are skbs in queue the dumping
 +
procedure will fail.
  
 
The cpt part uses the sock_diag engine that was merged to Dave recently to
 
The cpt part uses the sock_diag engine that was merged to Dave recently to
Line 9: Line 10:
 
such tricks with opens through proc) against SOCKFS_TYPE.
 
such tricks with opens through proc) against SOCKFS_TYPE.
  
The rst part is more tricky. Listen sockets are just restored, this is simple.
+
The restore part is more tricky. Listen sockets are just restored, this is simple.
 
Connected sockets are restored like this:
 
Connected sockets are restored like this:
  
Line 34: Line 35:
 
* Implement support for UDP sockets (quite simple)
 
* Implement support for UDP sockets (quite simple)
 
* Implement support for listening TCP sockets (also not very complex)
 
* Implement support for listening TCP sockets (also not very complex)
* Implement support for connected TCP scokets (hard one, Tejun's patches are not very good for this from my POV)
+
* Implement support for connected TCP scokets (hard one)

Revision as of 19:44, 27 December 2011

Unix sockets initial support

Currently it can only work with stream sockets, which have no skbs in queues (listening or established -- both work OK). If there are skbs in queue the dumping procedure will fail.

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 restore 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

  • 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 :(

  • Need to add support for DGRAM sockets -- I wrote comment how to do it in the can_dump_unix_sk()
  • Need to add support for in-flight connections
  • Implement support for UDP sockets (quite simple)
  • Implement support for listening TCP sockets (also not very complex)
  • Implement support for connected TCP scokets (hard one)