Blob Blame History Raw
From de3a7112b8e44993e077ffe03e4e4aa38bd20325 Mon Sep 17 00:00:00 2001
From: Bui Quang Minh <minhquangbui99@gmail.com>
Date: Thu, 12 Aug 2021 11:05:09 +0000
Subject: [PATCH 008/120] tcp: Skip restoring TCP state when dumping with
 --tcp-close

Since commit e42f5e0 ("tcp: allow to specify --tcp-close on dump"),
--tcp-close option can be used when checkpointing. This option skips
checkpointing established socket's state (including once established
but now closed socket). However, when restoring, we still try to
restore closed socket's state. As a result, a non-existent protobuf
image is opened.

This commit skips TCP_CLOSE socket when restoring established TCP
connection and removes the redundant check for TCP_LISTEN socket as
TCP_LISTEN socket cannot reach this function.

Suggested-by: Andrei Vagin <avagin@gmail.com>
Suggested-by: Radostin Stoyanov <radostin@redhat.com>
Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
---
 criu/sk-tcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/criu/sk-tcp.c b/criu/sk-tcp.c
index 0afecd2d6..96d5d13bf 100644
--- a/criu/sk-tcp.c
+++ b/criu/sk-tcp.c
@@ -451,7 +451,7 @@ int restore_one_tcp(int fd, struct inet_sk_info *ii)
 
 	pr_info("Restoring TCP connection\n");
 
-	if (opts.tcp_close && ii->ie->state != TCP_LISTEN && ii->ie->state != TCP_CLOSE) {
+	if (opts.tcp_close) {
 		if (shutdown(fd, SHUT_RDWR) && errno != ENOTCONN) {
 			pr_perror("Unable to shutdown the socket id %x ino %x", ii->ie->id, ii->ie->ino);
 		}
-- 
2.34.1