2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 01:51:51 +00:00

tcp: allow to specify --tcp-close on dump

In this case, states of established tcp connections will not be dumped
and they will not be blocked. This will be useful in case of snapshots,
when we don't need to restore tcp connections.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
This commit is contained in:
Andrei Vagin 2020-09-09 19:39:53 +03:00
parent 4f7c480413
commit e42f5e032e
7 changed files with 24 additions and 1 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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;
}

View File

@ -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 \

View File

@ -0,0 +1 @@
socket-tcp-close0.c

View File

@ -0,0 +1 @@
{'opts': '--tcp-close', 'flags': 'reqrst '}