[CRIU] [PATCH 05/21] inet: dump actual states of tcp sockets

Andrei Vagin avagin at openvz.org
Thu Dec 1 00:32:23 PST 2016


From: Andrei Vagin <avagin at virtuozzo.com>

We get sockets from task_diag, then we block network and dump sockets.

A socket state can be changed between first two steps, so lets get
a socket state on the third step and dump it.

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

diff --git a/criu/sk-inet.c b/criu/sk-inet.c
index 924cf8c..084eee7 100644
--- a/criu/sk-inet.c
+++ b/criu/sk-inet.c
@@ -304,7 +304,6 @@ static int do_dump_one_inet_fd(int lfd, u32 id, const struct fd_parms *p, int fa
 	ie.family	= family;
 	ie.proto	= proto;
 	ie.type		= sk->type;
-	ie.state	= sk->state;
 	ie.src_port	= sk->src_port;
 	ie.dst_port	= sk->dst_port;
 	ie.backlog	= sk->wqlen;
@@ -365,9 +364,6 @@ static int do_dump_one_inet_fd(int lfd, u32 id, const struct fd_parms *p, int fa
 	if (dump_socket_opts(lfd, &skopts))
 		goto err;
 
-	if (pb_write_one(img_from_set(glob_imgset, CR_FD_INETSK), &ie, PB_INET_SK))
-		goto err;
-
 	pr_info("Dumping inet socket at %d\n", p->fd);
 	show_one_inet("Dumping", sk);
 	show_one_inet_img("Dumped", &ie);
@@ -382,6 +378,11 @@ static int do_dump_one_inet_fd(int lfd, u32 id, const struct fd_parms *p, int fa
 		err = 0;
 		break;
 	}
+
+	ie.state = sk->state;
+
+	if (pb_write_one(img_from_set(glob_imgset, CR_FD_INETSK), &ie, PB_INET_SK))
+		goto err;
 err:
 	release_skopts(&skopts);
 	xfree(ie.src_addr);
diff --git a/criu/sk-tcp.c b/criu/sk-tcp.c
index a702abc..bd3b0da 100644
--- a/criu/sk-tcp.c
+++ b/criu/sk-tcp.c
@@ -132,6 +132,8 @@ static int dump_tcp_conn_state(struct inet_sk_desc *sk)
 		goto err_r;
 	}
 
+	sk->state = data.state;
+
 	tse.inq_len = data.inq_len;
 	tse.inq_seq = data.inq_seq;
 	tse.outq_len = data.outq_len;
-- 
2.7.4



More information about the CRIU mailing list