[CRIU] [PATCH 13/21] tcp: add support for synsent

Andrei Vagin avagin at openvz.org
Mon Nov 28 11:27:48 PST 2016


From: Andrei Vagin <avagin at virtuozzo.com>

libsoccr knows how to restore these sockets.

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 criu/sk-inet.c | 1 +
 criu/sk-tcp.c  | 8 ++++++--
 criu/sockets.c | 4 ++--
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/criu/sk-inet.c b/criu/sk-inet.c
index 6fafa26..131810a 100644
--- a/criu/sk-inet.c
+++ b/criu/sk-inet.c
@@ -168,6 +168,7 @@ static int can_dump_inet_sk(const struct inet_sk_desc *sk)
 	case TCP_CLOSE_WAIT:
 	case TCP_LAST_ACK:
 	case TCP_CLOSING:
+	case TCP_SYN_SENT:
 		if (!opts.tcp_established_ok) {
 			pr_err("Connected TCP socket, consider using --%s option.\n",
 					SK_EST_PARAM);
diff --git a/criu/sk-tcp.c b/criu/sk-tcp.c
index 2637d83..e994a3c 100644
--- a/criu/sk-tcp.c
+++ b/criu/sk-tcp.c
@@ -355,10 +355,14 @@ static int restore_tcp_conn_state(int sk, struct libsoccr_sk *socr, struct inet_
 
 	(void)data;
 
-	if (libsoccr_set_sk_data_noq(socr, &data, sizeof(data)))
+	/*
+	 * O_NONBLOCK has to be set before libsoccr_set_sk_data_noq(),
+	 * it is required to restore syn-sent sockets.
+	 */
+	if (restore_prepare_socket(sk))
 		goto err_c;
 
-	if (restore_prepare_socket(sk))
+	if (libsoccr_set_sk_data_noq(socr, &data, sizeof(data)))
 		goto err_c;
 
 	if (restore_tcp_queues(socr, &data, img))
diff --git a/criu/sockets.c b/criu/sockets.c
index 51927bf..a783be8 100644
--- a/criu/sockets.c
+++ b/criu/sockets.c
@@ -648,7 +648,7 @@ int collect_sockets(struct ns_id *ns)
 	req.r.i.idiag_states	= (1 << TCP_LISTEN) | (1 << TCP_ESTABLISHED) |
 					(1 << TCP_FIN_WAIT1) | (1 << TCP_FIN_WAIT2) |
 					(1 << TCP_CLOSE_WAIT) | (1 << TCP_LAST_ACK) |
-					(1 << TCP_CLOSING);
+					(1 << TCP_CLOSING) | (1 << TCP_SYN_SENT);
 	tmp = do_collect_req(nl, &req, sizeof(req), inet_receive_one, &req.r.i);
 	if (tmp)
 		err = tmp;
@@ -679,7 +679,7 @@ int collect_sockets(struct ns_id *ns)
 	req.r.i.idiag_states	= (1 << TCP_LISTEN) | (1 << TCP_ESTABLISHED) |
 					(1 << TCP_FIN_WAIT1) | (1 << TCP_FIN_WAIT2) |
 					(1 << TCP_CLOSE_WAIT) | (1 << TCP_LAST_ACK) |
-					(1 << TCP_CLOSING);
+					(1 << TCP_CLOSING) | (1 << TCP_SYN_SENT);
 	tmp = do_collect_req(nl, &req, sizeof(req), inet_receive_one, &req.r.i);
 	if (tmp)
 		err = tmp;
-- 
2.7.4



More information about the CRIU mailing list