Commit acf73093 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

sk-inet: save the socket option IPV6_V6ONLY (v2)

Most part of services (ssh, httpd, ...) create two separate sockets
one for ipv4 and one for ipv6. If IPV6_V6ONLY isn't dumped, bind() returns
EADDRINUSE

v2: use do_dump_opt and initialize yes = 1
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 6afafb12
......@@ -18,4 +18,5 @@ message inet_sk_entry {
required fown_entry fown = 13;
required sk_opts_entry opts = 14;
optional bool v6only = 15;
}
......@@ -204,8 +204,17 @@ static int dump_one_inet_fd(int lfd, u32 id, const struct fd_parms *p)
ie.n_src_addr = PB_ALEN_INET;
ie.n_dst_addr = PB_ALEN_INET;
if (ie.family == AF_INET6) {
int val;
ie.n_src_addr = PB_ALEN_INET6;
ie.n_dst_addr = PB_ALEN_INET6;
ret = dump_opt(lfd, SOL_IPV6, IPV6_V6ONLY, &val);
if (ret < 0)
goto err;
ie.v6only = val ? true : false;
ie.has_v6only = true;
}
ie.src_addr = xmalloc(pb_repeated_size(&ie, src_addr));
......@@ -359,6 +368,13 @@ static int open_inet_sk(struct file_desc *d)
return -1;
}
if (ii->ie->v6only) {
int yes = 1;
if (restore_opt(sk, SOL_IPV6, IPV6_V6ONLY, &yes) == -1)
return -1;
}
if (tcp_connection(ii->ie)) {
if (!opts.tcp_established_ok) {
pr_err("Connected TCP socket in image\n");
......
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