[07/12] soccr/tcp: Prepare connection info for restore (v2)

Submitted by Pavel Emelianov on Aug. 5, 2016, 3:01 p.m.

Details

Message ID 57A4AA3F.60101@virtuozzo.com
State Accepted
Series "Introduce library for socket C/R"
Commit f29e3549e5fc6d7d0e57a599f198bb20105cb346
Headers show

Commit Message

Pavel Emelianov Aug. 5, 2016, 3:01 p.m.
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
---
 criu/sk-tcp.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/sk-tcp.c b/criu/sk-tcp.c
index e1181dc..eaaf165 100644
--- a/criu/sk-tcp.c
+++ b/criu/sk-tcp.c
@@ -497,6 +497,7 @@  static int restore_tcp_conn_state(int sk, struct libsoccr_sk *socr, struct inet_
 	int aux;
 	struct cr_img *img;
 	TcpStreamEntry *tse;
+	struct libsoccr_sk_data data = {};
 
 	pr_info("Restoring TCP connection id %x ino %x\n", ii->ie->id, ii->ie->ino);
 
@@ -507,6 +508,47 @@  static int restore_tcp_conn_state(int sk, struct libsoccr_sk *socr, struct inet_
 	if (pb_read_one(img, &tse, PB_TCP_STREAM) < 0)
 		goto err_c;
 
+	if (!tse->has_unsq_len) {
+		pr_err("No unsq len in the image\n");
+		goto err_c;
+	}
+
+	data.inq_len = tse->inq_len;
+	data.inq_seq = tse->inq_seq;
+	data.outq_len = tse->outq_len;
+	data.outq_seq = tse->outq_seq;
+	data.unsq_len = tse->unsq_len;
+	data.mss_clamp = tse->mss_clamp;
+	data.opt_mask = tse->opt_mask;
+	if (tse->opt_mask & TCPI_OPT_WSCALE) {
+		if (!tse->has_rcv_wscale) {
+			pr_err("No rcv wscale in the image\n");
+			goto err_c;
+		}
+
+		data.snd_wscale = tse->snd_wscale;
+		data.rcv_wscale = tse->rcv_wscale;
+	}
+	if (tse->opt_mask & TCPI_OPT_TIMESTAMPS) {
+		if (!tse->has_timestamp) {
+			pr_err("No timestamp in the image\n");
+			goto err_c;
+		}
+
+		data.timestamp = tse->timestamp;
+	}
+
+	if (tse->has_snd_wnd) {
+		data.flags |= SOCCR_FLAGS_WINDOW;
+		data.snd_wl1 = tse->snd_wl1;
+		data.snd_wnd = tse->snd_wnd;
+		data.max_window = tse->max_window;
+		data.rcv_wnd = tse->rcv_wnd;
+		data.rcv_wup = tse->rcv_wup;
+	}
+
+	(void)data;
+
 	if (restore_tcp_seqs(sk, tse))
 		goto err_c;