Commit 4ec76b28 authored by Pavel Emelyanov's avatar Pavel Emelyanov

tcp: Add code for "check"-ing TCP repair support

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 1dc8527d
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include "log.h" #include "log.h"
#include "util-net.h" #include "util-net.h"
#include "syscall.h" #include "syscall.h"
#include "files.h"
#include "sk-inet.h"
static int check_map_files(void) static int check_map_files(void)
{ {
...@@ -150,6 +152,7 @@ int cr_check(void) ...@@ -150,6 +152,7 @@ int cr_check(void)
ret |= check_prctl(); ret |= check_prctl();
ret |= check_fcntl(); ret |= check_fcntl();
ret |= check_proc_stat(); ret |= check_proc_stat();
ret |= check_tcp_repair();
if (!ret) if (!ret)
pr_msg("Looks good.\n"); pr_msg("Looks good.\n");
......
...@@ -39,4 +39,6 @@ int restore_one_tcp(int sk, struct inet_sk_info *si); ...@@ -39,4 +39,6 @@ int restore_one_tcp(int sk, struct inet_sk_info *si);
struct cr_options; struct cr_options;
void show_tcp_stream(int fd, struct cr_options *); void show_tcp_stream(int fd, struct cr_options *);
int check_tcp_repair(void);
#endif #endif
...@@ -46,7 +46,7 @@ static int tcp_repair_on(int fd) ...@@ -46,7 +46,7 @@ static int tcp_repair_on(int fd)
ret = setsockopt(fd, SOL_TCP, TCP_REPAIR, &aux, sizeof(aux)); ret = setsockopt(fd, SOL_TCP, TCP_REPAIR, &aux, sizeof(aux));
if (ret < 0) if (ret < 0)
pr_perror("Can't turn repair ON"); pr_perror("Can't turn TCP repair mode ON");
return ret; return ret;
} }
...@@ -537,3 +537,19 @@ void show_tcp_stream(int fd, struct cr_options *opt) ...@@ -537,3 +537,19 @@ void show_tcp_stream(int fd, struct cr_options *opt)
pr_img_tail(CR_FD_TCP_STREAM); pr_img_tail(CR_FD_TCP_STREAM);
} }
int check_tcp_repair(void)
{
int sk, ret;
sk = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sk < 0) {
pr_perror("Can't create TCP socket :(\n");
return -1;
}
ret = tcp_repair_on(sk);
close(sk);
return ret;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment