diff --git a/protobuf/sk-inet.proto b/protobuf/sk-inet.proto index 340582f4f..36787b609 100644 --- a/protobuf/sk-inet.proto +++ b/protobuf/sk-inet.proto @@ -18,4 +18,5 @@ message inet_sk_entry { required fown_entry fown = 13; required sk_opts_entry opts = 14; + optional bool v6only = 15; } diff --git a/sk-inet.c b/sk-inet.c index 4e20a4706..edcafc7f4 100644 --- a/sk-inet.c +++ b/sk-inet.c @@ -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");