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

sk-inet: Add support for shutdown'ed UDP/UDPlite sockets

Supporting shutdown for dgram sockets (udp and udplite)
is simple -- just fetch the state from diag module and
record it in the image, then upon socket creation restore
this state.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Cyrill Gorcunov 2017-03-03 18:39:15 +03:00 committed by Pavel Emelyanov
parent 4f3927a638
commit a155afda0b
2 changed files with 15 additions and 6 deletions

View File

@ -122,12 +122,6 @@ static int can_dump_inet_sk(const struct inet_sk_desc *sk)
BUG_ON((sk->sd.family != AF_INET) && (sk->sd.family != AF_INET6));
if (sk->type == SOCK_DGRAM) {
if (sk->shutdown) {
pr_err("Can't dump shutdown inet socket %x\n",
sk->sd.ino);
return 0;
}
if (sk->wqlen != 0) {
pr_err("Can't dump corked dgram socket %x\n",
sk->sd.ino);
@ -414,6 +408,10 @@ static int do_dump_one_inet_fd(int lfd, u32 id, const struct fd_parms *p, int fa
case IPPROTO_TCP:
err = dump_one_tcp(lfd, sk);
break;
case IPPROTO_UDP:
case IPPROTO_UDPLITE:
sk_encode_shutdown(&ie, sk->shutdown);
/* Fallthrough! */
default:
err = 0;
break;
@ -704,6 +702,16 @@ done:
if (restore_socket_opts(sk, ie->opts))
goto err;
if (ie->has_shutdown &&
(ie->proto == IPPROTO_UDP ||
ie->proto == IPPROTO_UDPLITE)) {
if (shutdown(sk, sk_decode_shutdown(ie->shutdown))) {
pr_perror("Can't shutdown socket into %d",
sk_decode_shutdown(ie->shutdown));
goto err;
}
}
*new_fd = sk;
return 1;
err:

View File

@ -39,4 +39,5 @@ message inet_sk_entry {
/* for ipv6, we need to send the ifindex to bind(); we keep the ifname
* here and convert it on restore */
optional string ifname = 17;
optional sk_shutdown shutdown = 19;
}