Commit a155afda authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

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: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 4f3927a6
...@@ -122,12 +122,6 @@ static int can_dump_inet_sk(const struct inet_sk_desc *sk) ...@@ -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)); BUG_ON((sk->sd.family != AF_INET) && (sk->sd.family != AF_INET6));
if (sk->type == SOCK_DGRAM) { 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) { if (sk->wqlen != 0) {
pr_err("Can't dump corked dgram socket %x\n", pr_err("Can't dump corked dgram socket %x\n",
sk->sd.ino); 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 ...@@ -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: case IPPROTO_TCP:
err = dump_one_tcp(lfd, sk); err = dump_one_tcp(lfd, sk);
break; break;
case IPPROTO_UDP:
case IPPROTO_UDPLITE:
sk_encode_shutdown(&ie, sk->shutdown);
/* Fallthrough! */
default: default:
err = 0; err = 0;
break; break;
...@@ -704,6 +702,16 @@ done: ...@@ -704,6 +702,16 @@ done:
if (restore_socket_opts(sk, ie->opts)) if (restore_socket_opts(sk, ie->opts))
goto err; 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; *new_fd = sk;
return 1; return 1;
err: err:
......
...@@ -39,4 +39,5 @@ message inet_sk_entry { ...@@ -39,4 +39,5 @@ message inet_sk_entry {
/* for ipv6, we need to send the ifindex to bind(); we keep the ifname /* for ipv6, we need to send the ifindex to bind(); we keep the ifname
* here and convert it on restore */ * here and convert it on restore */
optional string ifname = 17; optional string ifname = 17;
optional sk_shutdown shutdown = 19;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment