diff --git a/criu/sk-tcp.c b/criu/sk-tcp.c index f80a4cb9c..9c8bad1c3 100644 --- a/criu/sk-tcp.c +++ b/criu/sk-tcp.c @@ -229,33 +229,21 @@ int dump_tcp_opts(int fd, TcpOptsEntry *toe) ret |= dump_opt(fd, SOL_TCP, TCP_NODELAY, &toe->nodelay); ret |= dump_opt(fd, SOL_TCP, TCP_CORK, &toe->cork); + ret |= dump_opt(fd, SOL_TCP, TCP_KEEPCNT, &toe->keepcnt); + ret |= dump_opt(fd, SOL_TCP, TCP_KEEPIDLE, &toe->keepidle); + ret |= dump_opt(fd, SOL_TCP, TCP_KEEPINTVL, &toe->keepintvl); toe->has_nodelay = !!toe->nodelay; toe->has_cork = !!toe->cork; + toe->has_keepcnt = !!toe->keepcnt; + toe->has_keepidle = !!toe->keepidle; + toe->has_keepintvl = !!toe->keepintvl; return ret; } int dump_one_tcp(int fd, struct inet_sk_desc *sk, SkOptsEntry *soe) { - soe->has_tcp_keepcnt = true; - if (dump_opt(fd, SOL_TCP, TCP_KEEPCNT, &soe->tcp_keepcnt)) { - pr_perror("Can't read TCP_KEEPCNT"); - return -1; - } - - soe->has_tcp_keepidle = true; - if (dump_opt(fd, SOL_TCP, TCP_KEEPIDLE, &soe->tcp_keepidle)) { - pr_perror("Can't read TCP_KEEPIDLE"); - return -1; - } - - soe->has_tcp_keepintvl = true; - if (dump_opt(fd, SOL_TCP, TCP_KEEPINTVL, &soe->tcp_keepintvl)) { - pr_perror("Can't read TCP_KEEPINTVL"); - return -1; - } - if (sk->dst_port == 0) return 0; @@ -457,6 +445,12 @@ int restore_tcp_opts(int sk, TcpOptsEntry *toe) ret |= restore_opt(sk, SOL_TCP, TCP_NODELAY, &toe->nodelay); if (toe->has_cork) ret |= restore_opt(sk, SOL_TCP, TCP_CORK, &toe->cork); + if (toe->has_keepcnt) + ret |= restore_opt(sk, SOL_TCP, TCP_KEEPCNT, &toe->keepcnt); + if (toe->has_keepidle) + ret |= restore_opt(sk, SOL_TCP, TCP_KEEPIDLE, &toe->keepidle); + if (toe->has_keepintvl) + ret |= restore_opt(sk, SOL_TCP, TCP_KEEPINTVL, &toe->keepintvl); return ret; } diff --git a/criu/sockets.c b/criu/sockets.c index 560c76517..f9ce999be 100644 --- a/criu/sockets.c +++ b/criu/sockets.c @@ -585,6 +585,12 @@ int restore_socket_opts(int sk, SkOptsEntry *soe) pr_debug("\tset keepalive for socket\n"); ret |= restore_opt(sk, SOL_SOCKET, SO_KEEPALIVE, &val); } + + /* + * Restoring TCP socket options in SkOptsEntry is + * for backward compatibility only, newer versions + * of CRIU use TcpOptsEntry. + */ if (soe->has_tcp_keepcnt) { pr_debug("\tset keepcnt for socket\n"); ret |= restore_opt(sk, SOL_TCP, TCP_KEEPCNT, &soe->tcp_keepcnt); diff --git a/images/sk-opts.proto b/images/sk-opts.proto index 1d24d47cc..2f9d4e5c3 100644 --- a/images/sk-opts.proto +++ b/images/sk-opts.proto @@ -26,9 +26,12 @@ message sk_opts_entry { optional bool so_reuseport = 17; optional bool so_broadcast = 18; optional bool so_keepalive = 19; + + /* These three are deprecated, use tcp_opts_entry instead */ optional uint32 tcp_keepcnt = 20; optional uint32 tcp_keepidle = 21; optional uint32 tcp_keepintvl = 22; + optional uint32 so_oobinline = 23; optional uint32 so_linger = 24; diff --git a/images/tcp-stream.proto b/images/tcp-stream.proto index 4f85282e2..3d834159f 100644 --- a/images/tcp-stream.proto +++ b/images/tcp-stream.proto @@ -7,6 +7,9 @@ import "opts.proto"; message tcp_opts_entry { optional bool cork = 1; optional bool nodelay = 2; + optional uint32 keepcnt = 3; + optional uint32 keepidle = 4; + optional uint32 keepintvl = 5; } message tcp_stream_entry {