Commit 2fdef836 authored by Adrian Reber's avatar Adrian Reber Committed by Pavel Emelyanov

criu: add an option to skip in-flight connections

Trying to migrate containers with tomcat and running ab as a test client
(ab -n 1000000 -c 20 http://url/to/test) criu sometimes exited with an
error if in-flight connections were detected. Criu can handle sockets
listening and with established connection. In-flight connections can
happen on sockets which do not yet have a full established connection
(SYN, SYN-ACK, and the last ACK is missing).

This adds a new option to criu:

 --skip-in-flight  this option skips in-flight TCP connections.
                   if TCP connections are found which are not yet completely
                   established, criu will ignore these connections in favor
                   of erroring out.

With this option criu will skip sockets in this state and let's the client
handle the re-connection.
Signed-off-by: 's avatarAdrian Reber <areber@redhat.com>
Acked-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 85578bd5
...@@ -279,6 +279,7 @@ int main(int argc, char *argv[], char *envp[]) ...@@ -279,6 +279,7 @@ int main(int argc, char *argv[], char *envp[])
{ "cgroup-props", required_argument, 0, 1080 }, { "cgroup-props", required_argument, 0, 1080 },
{ "cgroup-props-file", required_argument, 0, 1081 }, { "cgroup-props-file", required_argument, 0, 1081 },
{ "cgroup-dump-controller", required_argument, 0, 1082 }, { "cgroup-dump-controller", required_argument, 0, 1082 },
{ SK_INFLIGHT_PARAM, no_argument, 0, 1083 },
{ }, { },
}; };
...@@ -583,6 +584,10 @@ int main(int argc, char *argv[], char *envp[]) ...@@ -583,6 +584,10 @@ int main(int argc, char *argv[], char *envp[])
if (!cgp_add_dump_controller(optarg)) if (!cgp_add_dump_controller(optarg))
return 1; return 1;
break; break;
case 1083:
pr_msg("Will skip in-flight TCP connections\n");
opts.tcp_skip_in_flight = true;
break;
case 'V': case 'V':
pr_msg("Version: %s\n", CRIU_VERSION); pr_msg("Version: %s\n", CRIU_VERSION);
if (strcmp(CRIU_GITID, "0")) if (strcmp(CRIU_GITID, "0"))
...@@ -791,6 +796,10 @@ usage: ...@@ -791,6 +796,10 @@ usage:
"* Special resources support:\n" "* Special resources support:\n"
" -x|--" USK_EXT_PARAM "inode,.." " allow external unix connections (optionally can be assign socket's inode that allows one-sided dump)\n" " -x|--" USK_EXT_PARAM "inode,.." " allow external unix connections (optionally can be assign socket's inode that allows one-sided dump)\n"
" --" SK_EST_PARAM " checkpoint/restore established TCP connections\n" " --" SK_EST_PARAM " checkpoint/restore established TCP connections\n"
" --" SK_INFLIGHT_PARAM " this option skips in-flight TCP connections.\n"
" if TCP connections are found which are not yet completely\n"
" established, criu will ignore these connections in favor\n"
" of erroring out.\n"
" -r|--root PATH change the root filesystem (when run in mount namespace)\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" " --evasive-devices use any path to a device file if the original one\n"
" is inaccessible\n" " is inaccessible\n"
......
...@@ -109,6 +109,7 @@ struct cr_options { ...@@ -109,6 +109,7 @@ struct cr_options {
char *lsm_profile; char *lsm_profile;
unsigned int timeout; unsigned int timeout;
unsigned int empty_ns; unsigned int empty_ns;
bool tcp_skip_in_flight;
}; };
extern struct cr_options opts; extern struct cr_options opts;
......
...@@ -72,6 +72,7 @@ extern int dump_one_tcp(int sk, struct inet_sk_desc *sd); ...@@ -72,6 +72,7 @@ extern int dump_one_tcp(int sk, struct inet_sk_desc *sd);
extern int restore_one_tcp(int sk, struct inet_sk_info *si); extern int restore_one_tcp(int sk, struct inet_sk_info *si);
#define SK_EST_PARAM "tcp-established" #define SK_EST_PARAM "tcp-established"
#define SK_INFLIGHT_PARAM "skip-in-flight"
extern int check_tcp(void); extern int check_tcp(void);
......
...@@ -144,6 +144,11 @@ static int can_dump_inet_sk(const struct inet_sk_desc *sk) ...@@ -144,6 +144,11 @@ static int can_dump_inet_sk(const struct inet_sk_desc *sk)
switch (sk->state) { switch (sk->state) {
case TCP_LISTEN: case TCP_LISTEN:
if (sk->rqlen != 0) { if (sk->rqlen != 0) {
if (opts.tcp_skip_in_flight) {
pr_info("Skipping in-flight connection (l) for %x\n",
sk->sd.ino);
break;
}
/* /*
* Currently the ICONS nla reports the conn * Currently the ICONS nla reports the conn
* requests for listen sockets. Need to pick * requests for listen sockets. Need to pick
...@@ -151,6 +156,8 @@ static int can_dump_inet_sk(const struct inet_sk_desc *sk) ...@@ -151,6 +156,8 @@ static int can_dump_inet_sk(const struct inet_sk_desc *sk)
*/ */
pr_err("In-flight connection (l) for %x\n", pr_err("In-flight connection (l) for %x\n",
sk->sd.ino); sk->sd.ino);
pr_err("In-flight connections can be ignored with the"
"--%s option.\n", SK_INFLIGHT_PARAM);
return 0; return 0;
} }
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment