diff --git a/cr-check.c b/cr-check.c index bfe40a150..8cec6d87f 100644 --- a/cr-check.c +++ b/cr-check.c @@ -8,6 +8,8 @@ #include "log.h" #include "util-net.h" #include "syscall.h" +#include "files.h" +#include "sk-inet.h" static int check_map_files(void) { @@ -150,6 +152,7 @@ int cr_check(void) ret |= check_prctl(); ret |= check_fcntl(); ret |= check_proc_stat(); + ret |= check_tcp_repair(); if (!ret) pr_msg("Looks good.\n"); diff --git a/include/sk-inet.h b/include/sk-inet.h index 0bb3620f3..7c0566c4d 100644 --- a/include/sk-inet.h +++ b/include/sk-inet.h @@ -39,4 +39,6 @@ int restore_one_tcp(int sk, struct inet_sk_info *si); struct cr_options; void show_tcp_stream(int fd, struct cr_options *); + +int check_tcp_repair(void); #endif diff --git a/sk-tcp.c b/sk-tcp.c index 7edc1ec63..8b7977d13 100644 --- a/sk-tcp.c +++ b/sk-tcp.c @@ -46,7 +46,7 @@ static int tcp_repair_on(int fd) ret = setsockopt(fd, SOL_TCP, TCP_REPAIR, &aux, sizeof(aux)); if (ret < 0) - pr_perror("Can't turn repair ON"); + pr_perror("Can't turn TCP repair mode ON"); return ret; } @@ -537,3 +537,19 @@ void show_tcp_stream(int fd, struct cr_options *opt) 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; +}