[CRIU] [PATCH 2/2] tcp: Move TCP-repair checking code into cr-check.c
Pavel Emelyanov
xemul at virtuozzo.com
Thu Dec 29 04:14:47 PST 2016
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
criu/cr-check.c | 30 ++++++++++++++++++++++++++++++
criu/include/sk-inet.h | 2 --
criu/sk-tcp.c | 40 ----------------------------------------
3 files changed, 30 insertions(+), 42 deletions(-)
diff --git a/criu/cr-check.c b/criu/cr-check.c
index ce75ac5..852f3b7 100644
--- a/criu/cr-check.c
+++ b/criu/cr-check.c
@@ -924,6 +924,36 @@ static int check_cgroupns(void)
return 0;
}
+static int check_tcp(void)
+{
+ socklen_t optlen;
+ int sk, ret;
+ int val;
+
+ sk = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (sk < 0) {
+ pr_perror("Can't create TCP socket :(");
+ return -1;
+ }
+
+ val = 1;
+ ret = setsockopt(sk, SOL_TCP, TCP_REPAIR, &val, sizeof(val));
+ if (ret < 0) {
+ pr_perror("Can't turn TCP repair mode ON");
+ goto out;
+ }
+
+ optlen = sizeof(val);
+ ret = getsockopt(sk, SOL_TCP, TCP_TIMESTAMP, &val, &optlen);
+ if (ret)
+ pr_perror("Can't get TCP_TIMESTAMP");
+
+out:
+ close(sk);
+
+ return ret;
+}
+
static int check_tcp_halt_closed(void)
{
int ret;
diff --git a/criu/include/sk-inet.h b/criu/include/sk-inet.h
index db3317f..0b0fbf0 100644
--- a/criu/include/sk-inet.h
+++ b/criu/include/sk-inet.h
@@ -75,8 +75,6 @@ extern int restore_one_tcp(int sk, struct inet_sk_info *si);
#define SK_EST_PARAM "tcp-established"
#define SK_INFLIGHT_PARAM "skip-in-flight"
-extern int check_tcp(void);
-
struct task_restore_args;
int prepare_tcp_socks(struct task_restore_args *);
diff --git a/criu/sk-tcp.c b/criu/sk-tcp.c
index 057c035..3acc710 100644
--- a/criu/sk-tcp.c
+++ b/criu/sk-tcp.c
@@ -8,7 +8,6 @@
#include "../soccr/soccr.h"
-#include "cr_options.h"
#include "util.h"
#include "common/list.h"
#include "log.h"
@@ -31,17 +30,6 @@
static LIST_HEAD(cpt_tcp_repair_sockets);
static LIST_HEAD(rst_tcp_repair_sockets);
-static int tcp_repair_on(int fd)
-{
- int ret, aux = 1;
-
- ret = setsockopt(fd, SOL_TCP, TCP_REPAIR, &aux, sizeof(aux));
- if (ret < 0)
- pr_perror("Can't turn TCP repair mode ON");
-
- return ret;
-}
-
static int tcp_repair_establised(int fd, struct inet_sk_desc *sk)
{
int ret;
@@ -446,31 +434,3 @@ void rst_unlock_tcp_connections(void)
list_for_each_entry(ii, &rst_tcp_repair_sockets, rlist)
nf_unlock_connection_info(ii);
}
-
-int check_tcp(void)
-{
- socklen_t optlen;
- int sk, ret;
- int val;
-
- sk = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (sk < 0) {
- pr_perror("Can't create TCP socket :(");
- return -1;
- }
-
- ret = tcp_repair_on(sk);
- if (ret)
- goto out;
-
- optlen = sizeof(val);
- ret = getsockopt(sk, SOL_TCP, TCP_TIMESTAMP, &val, &optlen);
- if (ret)
- pr_perror("Can't get TCP_TIMESTAMP");
-
-out:
- close(sk);
-
- return ret;
-}
-
--
2.5.0
More information about the CRIU
mailing list