mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-17 16:47:50 +00:00
tcp: Add tcp-close option to restore connected TCP sockets in closed state
New restore option 'tcp-close' was introduced. It restores all connected TCP sockets in TCP_CLOSE state. Here we consider tcp sockets in TCP_ESTABLISHED, TCP_FIN_WAIT2, TCP_FIN_WAIT1, TCP_CLOSE_WAIT, TCP_LAST_ACK, TCP_CLOSING, TCP_SYN_SENT states as connected sockets. This is consistent with current CRIU usage of these states. Thus this option doesn't affect sockets with original states of TCP_LISTEN and TCP_CLOSE. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Eugene Batalov <eabatalov89@gmail.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
4c332970bd
commit
2c37042821
6 changed files with 17 additions and 1 deletions
|
|
@ -264,6 +264,9 @@ For example, the command line for the above example should look like this:
|
|||
The TCP stack on the client side is expected to handle the
|
||||
re-connect gracefully.
|
||||
|
||||
*--tcp-close*::
|
||||
Restore connected TCP sockets in closed state.
|
||||
|
||||
*--evasive-devices*::
|
||||
Use any path to a device file if the original one is inaccessible.
|
||||
|
||||
|
|
|
|||
|
|
@ -290,6 +290,7 @@ int main(int argc, char *argv[], char *envp[])
|
|||
BOOL_OPT("display-stats", &opts.display_stats),
|
||||
BOOL_OPT("weak-sysctls", &opts.weak_sysctls),
|
||||
{ "status-fd", required_argument, 0, 1088 },
|
||||
{ SK_CLOSE_PARAM, no_argument, 0, 1089 },
|
||||
{ },
|
||||
};
|
||||
|
||||
|
|
@ -568,6 +569,9 @@ int main(int argc, char *argv[], char *envp[])
|
|||
return 1;
|
||||
}
|
||||
break;
|
||||
case 1089:
|
||||
opts.tcp_close = true;
|
||||
break;
|
||||
case 'V':
|
||||
pr_msg("Version: %s\n", CRIU_VERSION);
|
||||
if (strcmp(CRIU_GITID, "0"))
|
||||
|
|
@ -826,6 +830,7 @@ usage:
|
|||
"* Special resources support:\n"
|
||||
" --" SK_EST_PARAM " checkpoint/restore established TCP connections\n"
|
||||
" --" SK_INFLIGHT_PARAM " skip (ignore) in-flight TCP connections\n"
|
||||
" --" SK_CLOSE_PARAM " restore connected TCP sockets in closed state\n"
|
||||
" -r|--root PATH change the root filesystem (when run in mount namespace)\n"
|
||||
" --evasive-devices use any path to a device file if the original one\n"
|
||||
" is inaccessible\n"
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ struct cr_options {
|
|||
int shell_job;
|
||||
int handle_file_locks;
|
||||
int tcp_established_ok;
|
||||
bool tcp_close;
|
||||
int evasive_devices;
|
||||
int link_remap_ok;
|
||||
int log_file_per_pid;
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ extern int restore_one_tcp(int sk, struct inet_sk_info *si);
|
|||
|
||||
#define SK_EST_PARAM "tcp-established"
|
||||
#define SK_INFLIGHT_PARAM "skip-in-flight"
|
||||
#define SK_CLOSE_PARAM "tcp-close"
|
||||
|
||||
struct task_restore_args;
|
||||
int prepare_tcp_socks(struct task_restore_args *);
|
||||
|
|
|
|||
|
|
@ -648,7 +648,7 @@ static int open_inet_sk(struct file_desc *d, int *new_fd)
|
|||
goto err;
|
||||
|
||||
if (tcp_connection(ie)) {
|
||||
if (!opts.tcp_established_ok) {
|
||||
if (!opts.tcp_established_ok && !opts.tcp_close) {
|
||||
pr_err("Connected TCP socket in image\n");
|
||||
goto err;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "../soccr/soccr.h"
|
||||
|
||||
#include "cr_options.h"
|
||||
#include "util.h"
|
||||
#include "common/list.h"
|
||||
#include "log.h"
|
||||
|
|
@ -407,6 +408,11 @@ int restore_one_tcp(int fd, struct inet_sk_info *ii)
|
|||
|
||||
pr_info("Restoring TCP connection\n");
|
||||
|
||||
if (opts.tcp_close &&
|
||||
ii->ie->state != TCP_LISTEN && ii->ie->state != TCP_CLOSE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
sk = libsoccr_pause(fd);
|
||||
if (!sk)
|
||||
return -1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue