[CRIU] [PATCH 01/12] kerndat: Shuffle tcp check/kdat a little bit

Pavel Emelyanov xemul at virtuozzo.com
Mon Apr 24 13:06:34 PDT 2017


This patch fixes a misprint, changes naming and splits
the kerndat_ routines.

This is prereq for kdat.config set.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/cr-check.c        | 14 +++++++-------
 criu/include/kerndat.h |  2 +-
 criu/kerndat.c         | 21 +++++++++++++++++----
 3 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/criu/cr-check.c b/criu/cr-check.c
index ec0020d..c5fba9c 100644
--- a/criu/cr-check.c
+++ b/criu/cr-check.c
@@ -951,15 +951,15 @@ out:
 	return ret;
 }
 
-static int check_tcp_halt_closed(void)
+static int check_tcp_half_closed(void)
 {
 	int ret;
 
-	ret = kerndat_tcp_repair();
+	ret = kerndat_tcp_half_closed();
 	if (ret < 0)
 		return -1;
 
-	if (!kdat.has_tcp_half_closed) {
+	if (ret == 0) {
 		pr_err("TCP_REPAIR can't be enabled for half-closed sockets\n");
 		return -1;
 	}
@@ -967,7 +967,7 @@ static int check_tcp_halt_closed(void)
 	return 0;
 }
 
-static int kerndat_tcp_repair_window(void)
+static int do_check_tcp_repair_window(void)
 {
 	struct tcp_repair_window opt;
 	socklen_t optlen = sizeof(opt);
@@ -1011,7 +1011,7 @@ static int check_tcp_window(void)
 {
 	int ret;
 
-	ret = kerndat_tcp_repair_window();
+	ret = do_check_tcp_repair_window();
 	if (ret < 0)
 		return -1;
 
@@ -1197,7 +1197,7 @@ int cr_check(void)
 		ret |= check_clone_parent_vs_pid();
 		ret |= check_cgroupns();
 		ret |= check_tcp_window();
-		ret |= check_tcp_halt_closed();
+		ret |= check_tcp_half_closed();
 		ret |= check_userns();
 		ret |= check_loginuid();
 		ret |= check_sk_netns();
@@ -1275,7 +1275,7 @@ static struct feature_list feature_list[] = {
 	{ "loginuid", check_loginuid },
 	{ "cgroupns", check_cgroupns },
 	{ "autofs", check_autofs },
-	{ "tcp_half_closed", check_tcp_halt_closed },
+	{ "tcp_half_closed", check_tcp_half_closed },
 	{ "compat_cr", check_compat_cr },
 	{ "lazy_pages", check_uffd },
 	{ "sk_ns", check_sk_netns },
diff --git a/criu/include/kerndat.h b/criu/include/kerndat.h
index ccb89bb..722fad3 100644
--- a/criu/include/kerndat.h
+++ b/criu/include/kerndat.h
@@ -62,7 +62,7 @@ enum {
  */
 extern int kerndat_fs_virtualized(unsigned int which, u32 kdev);
 
-extern int kerndat_tcp_repair();
+extern int kerndat_tcp_half_closed();
 extern int kerndat_uffd(bool need_uffd);
 
 #endif /* __CR_KERNDAT_H__ */
diff --git a/criu/kerndat.c b/criu/kerndat.c
index 604e631..cd7bc7d 100644
--- a/criu/kerndat.c
+++ b/criu/kerndat.c
@@ -495,7 +495,7 @@ static int kerndat_iptables_has_xtlocks(void)
 	return 0;
 }
 
-int kerndat_tcp_repair(void)
+int kerndat_tcp_half_closed(void)
 {
 	int sock, clnt = -1, yes = 1, exit_code = -1;
 	struct sockaddr_in addr;
@@ -546,11 +546,11 @@ int kerndat_tcp_repair(void)
 	if (setsockopt(clnt, SOL_TCP, TCP_REPAIR, &yes, sizeof(yes))) {
 		if (errno != EPERM)
 			goto err;
-		kdat.has_tcp_half_closed = false;
+
+		exit_code = 0;
 	} else
-		kdat.has_tcp_half_closed = true;
+		exit_code = 1;
 
-	exit_code = 0;
 err:
 	close_safe(&clnt);
 	close(sock);
@@ -558,6 +558,19 @@ err:
 	return exit_code;
 }
 
+static int kerndat_tcp_repair(void)
+{
+	int ret;
+
+	ret = kerndat_tcp_half_closed();
+	if (ret == 1) {
+		kdat.has_tcp_half_closed = true;
+		ret = 0;
+	}
+
+	return ret;
+}
+
 int kerndat_nsid(void)
 {
 	int nsid, sk;
-- 
2.5.5



More information about the CRIU mailing list