diff --git a/criu/image.c b/criu/image.c index 56c6f787c..d4ad7a79e 100644 --- a/criu/image.c +++ b/criu/image.c @@ -81,6 +81,11 @@ int check_img_inventory(void) goto out_err; } + if (he->tcp_close && !opts.tcp_close) { + pr_err("Need to set the --tcp-close option."); + goto out_err; + } + ret = 0; out_err: @@ -212,6 +217,12 @@ int prepare_inventory(InventoryEntry *he) he->root_ids = crt.i.ids; + /* tcp_close has to be set on restore if it has been set on dump. */ + if (opts.tcp_close) { + he->tcp_close = true; + he->has_tcp_close = true; + } + return 0; } diff --git a/criu/sk-inet.c b/criu/sk-inet.c index dc1ee8144..42bae9454 100644 --- a/criu/sk-inet.c +++ b/criu/sk-inet.c @@ -194,7 +194,7 @@ static int can_dump_inet_sk(const struct inet_sk_desc *sk) case TCP_LAST_ACK: case TCP_CLOSING: case TCP_SYN_SENT: - if (!opts.tcp_established_ok) { + if (!opts.tcp_established_ok && !opts.tcp_close) { pr_err("Connected TCP socket, consider using --%s option.\n", SK_EST_PARAM); return 0; @@ -787,6 +787,7 @@ int restore_ip_opts(int sk, int family, int proto, IpOptsEntry *ioe) ret |= restore_ip_raw_opts(sk, family, proto, ioe->raw); return ret; } + static int open_inet_sk(struct file_desc *d, int *new_fd) { struct fdinfo_list_entry *fle = file_master(d); diff --git a/criu/sk-tcp.c b/criu/sk-tcp.c index 8c982e5a4..0409e22c3 100644 --- a/criu/sk-tcp.c +++ b/criu/sk-tcp.c @@ -241,6 +241,10 @@ int dump_one_tcp(int fd, struct inet_sk_desc *sk, SkOptsEntry *soe) if (sk->dst_port == 0) return 0; + if (opts.tcp_close) { + return 0; + } + pr_info("Dumping TCP connection\n"); if (tcp_repair_established(fd, sk)) @@ -461,6 +465,9 @@ void rst_unlock_tcp_connections(void) { struct inet_sk_info *ii; + if (opts.tcp_close) + return; + /* Network will be unlocked by network-unlock scripts */ if (root_ns_mask & CLONE_NEWNET) return; diff --git a/images/inventory.proto b/images/inventory.proto index d1438e8c8..d7d0622c4 100644 --- a/images/inventory.proto +++ b/images/inventory.proto @@ -17,4 +17,5 @@ message inventory_entry { optional lsmtype lsmtype = 6; optional uint64 dump_uptime = 8; optional uint32 pre_dump_mode = 9; + optional bool tcp_close = 10; } diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile index ae23e78aa..ee9b57abe 100644 --- a/test/zdtm/static/Makefile +++ b/test/zdtm/static/Makefile @@ -102,6 +102,7 @@ TST_NOFILE := \ socket-tcp4v6-closed \ socket-tcp-close0 \ socket-tcp-close1 \ + socket-dump-tcp-close \ socket-tcp-unconn \ socket-tcp6-unconn \ socket-tcp-syn-sent \ diff --git a/test/zdtm/static/socket-dump-tcp-close.c b/test/zdtm/static/socket-dump-tcp-close.c new file mode 120000 index 000000000..5e3c85c91 --- /dev/null +++ b/test/zdtm/static/socket-dump-tcp-close.c @@ -0,0 +1 @@ +socket-tcp-close0.c \ No newline at end of file diff --git a/test/zdtm/static/socket-dump-tcp-close.desc b/test/zdtm/static/socket-dump-tcp-close.desc new file mode 100644 index 000000000..c53a1f315 --- /dev/null +++ b/test/zdtm/static/socket-dump-tcp-close.desc @@ -0,0 +1 @@ +{'opts': '--tcp-close', 'flags': 'reqrst '}