01c54c
From ed8fecd12d7ce37d7ebdc35837e184caba7a14b4 Mon Sep 17 00:00:00 2001
01c54c
From: Adrian Reber <areber@redhat.com>
01c54c
Date: Mon, 20 Jun 2016 23:15:00 +0300
01c54c
Subject: [PATCH] criu: add RPC interface for skip in-flight connections
01c54c
01c54c
For the previously added option to skip in-flight connections this adds
01c54c
that option to the RPC interface. The skip in-flight connections is also
01c54c
described in criu.txt.
01c54c
01c54c
Signed-off-by: Adrian Reber <areber@redhat.com>
01c54c
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
01c54c
---
01c54c
 Documentation/criu.txt |  7 +++++++
01c54c
 criu/cr-service.c      |  3 +++
01c54c
 images/rpc.proto       |  1 +
01c54c
 lib/c/criu.c           | 11 +++++++++++
01c54c
 lib/c/criu.h           |  2 ++
01c54c
 5 files changed, 24 insertions(+)
01c54c
01c54c
diff --git a/Documentation/criu.txt b/Documentation/criu.txt
01c54c
index 55f05c0..39a6685 100644
01c54c
--- a/Documentation/criu.txt
01c54c
+++ b/Documentation/criu.txt
01c54c
@@ -199,6 +199,13 @@ Thus for command line argument the example above will look like:
01c54c
 *--tcp-established*::
01c54c
     Checkpoint established TCP connections.
01c54c
 
01c54c
+*--skip-in-flight*::
01c54c
+    This option skips in-flight TCP connections. If TCP connections
01c54c
+    are found which are not yet completely established, criu will
01c54c
+    ignore these connections in favor of erroring out.
01c54c
+    The TCP stack on the client side is expected to handle the
01c54c
+    re-connect gracefully.
01c54c
+
01c54c
 *--veth-pair* '<IN>'*=*'<OUT>'::
01c54c
     Correspondence between outside and inside names of veth devices.
01c54c
 
01c54c
diff --git a/criu/cr-service.c b/criu/cr-service.c
01c54c
index 0dc9c0c..0672a83 100644
01c54c
--- a/criu/cr-service.c
01c54c
+++ b/criu/cr-service.c
01c54c
@@ -322,6 +322,9 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
01c54c
 	if (req->has_tcp_established)
01c54c
 		opts.tcp_established_ok = req->tcp_established;
01c54c
 
01c54c
+	if (req->has_tcp_skip_in_flight)
01c54c
+		opts.tcp_skip_in_flight = req->tcp_skip_in_flight;
01c54c
+
01c54c
 	if (req->has_evasive_devices)
01c54c
 		opts.evasive_devices = req->evasive_devices;
01c54c
 
01c54c
diff --git a/images/rpc.proto b/images/rpc.proto
01c54c
index 1f74dcf..27583c1 100644
01c54c
--- a/images/rpc.proto
01c54c
+++ b/images/rpc.proto
01c54c
@@ -104,6 +104,7 @@ message criu_opts {
01c54c
 	repeated string			external	= 37;
01c54c
 	optional uint32			empty_ns	= 38;
01c54c
 	repeated join_namespace		join_ns		= 39;
01c54c
+	optional bool			tcp_skip_in_flight	= 46;
01c54c
 }
01c54c
 
01c54c
 message criu_dump_resp {
01c54c
diff --git a/lib/c/criu.c b/lib/c/criu.c
01c54c
index 05425a3..e75268c 100644
01c54c
--- a/lib/c/criu.c
01c54c
+++ b/lib/c/criu.c
01c54c
@@ -309,6 +309,17 @@ void criu_set_tcp_established(bool tcp_established)
01c54c
 	criu_local_set_tcp_established(global_opts, tcp_established);
01c54c
 }
01c54c
 
01c54c
+void criu_local_set_tcp_skip_in_flight(criu_opts *opts, bool tcp_skip_in_flight)
01c54c
+{
01c54c
+	opts->rpc->has_tcp_skip_in_flight	= true;
01c54c
+	opts->rpc->tcp_skip_in_flight		= tcp_skip_in_flight;
01c54c
+}
01c54c
+
01c54c
+void criu_set_tcp_skip_in_flight(bool tcp_skip_in_flight)
01c54c
+{
01c54c
+	criu_local_set_tcp_skip_in_flight(global_opts, tcp_skip_in_flight);
01c54c
+}
01c54c
+
01c54c
 void criu_local_set_evasive_devices(criu_opts *opts, bool evasive_devices)
01c54c
 {
01c54c
 	opts->rpc->has_evasive_devices	= true;
01c54c
diff --git a/lib/c/criu.h b/lib/c/criu.h
01c54c
index 7ed1750..c28369f 100644
01c54c
--- a/lib/c/criu.h
01c54c
+++ b/lib/c/criu.h
01c54c
@@ -65,6 +65,7 @@ void criu_set_leave_running(bool leave_running);
01c54c
 void criu_set_ext_unix_sk(bool ext_unix_sk);
01c54c
 int criu_add_unix_sk(unsigned int inode);
01c54c
 void criu_set_tcp_established(bool tcp_established);
01c54c
+void criu_set_tcp_skip_in_flight(bool tcp_skip_in_flight);
01c54c
 void criu_set_evasive_devices(bool evasive_devices);
01c54c
 void criu_set_shell_job(bool shell_job);
01c54c
 void criu_set_file_locks(bool file_locks);
01c54c
@@ -169,6 +170,7 @@ void criu_local_set_leave_running(criu_opts *opts, bool leave_running);
01c54c
 void criu_local_set_ext_unix_sk(criu_opts *opts, bool ext_unix_sk);
01c54c
 int criu_local_add_unix_sk(criu_opts *opts, unsigned int inode);
01c54c
 void criu_local_set_tcp_established(criu_opts *opts, bool tcp_established);
01c54c
+void criu_local_set_tcp_skip_in_flight(criu_opts *opts, bool tcp_skip_in_flight);
01c54c
 void criu_local_set_evasive_devices(criu_opts *opts, bool evasive_devices);
01c54c
 void criu_local_set_shell_job(criu_opts *opts, bool shell_job);
01c54c
 void criu_local_set_file_locks(criu_opts *opts, bool file_locks);