[CRIU] [PATCH 1/2] sk-inet: handle the IP_FREEBIND option
Andrey Vagin
avagin at openvz.org
Wed Nov 18 07:58:09 PST 2015
From: Andrew Vagin <avagin at virtuozzo.com>
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
protobuf/sk-inet.proto | 5 +++++
sk-inet.c | 25 +++++++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/protobuf/sk-inet.proto b/protobuf/sk-inet.proto
index bd8f074..ad49928 100644
--- a/protobuf/sk-inet.proto
+++ b/protobuf/sk-inet.proto
@@ -2,6 +2,10 @@ import "opts.proto";
import "fown.proto";
import "sk-opts.proto";
+message ip_opts_entry {
+ optional bool freebind = 1;
+}
+
message inet_sk_entry {
/*
* We have two IDs here -- id and ino. The first one
@@ -28,4 +32,5 @@ message inet_sk_entry {
required fown_entry fown = 13;
required sk_opts_entry opts = 14;
optional bool v6only = 15;
+ optional ip_opts_entry ip_opts = 16;
}
diff --git a/sk-inet.c b/sk-inet.c
index dd9efed..779a1bd 100644
--- a/sk-inet.c
+++ b/sk-inet.c
@@ -230,10 +230,19 @@ err:
return NULL;
}
+static int dump_ip_opts(int sk, IpOptsEntry *ioe)
+{
+ int ret = 0;
+
+ ret |= dump_opt(sk, SOL_IP, IP_FREEBIND, &ioe->freebind);
+
+ return ret;
+}
static int do_dump_one_inet_fd(int lfd, u32 id, const struct fd_parms *p, int family)
{
struct inet_sk_desc *sk;
InetSkEntry ie = INET_SK_ENTRY__INIT;
+ IpOptsEntry ipopts = IP_OPTS_ENTRY__INIT;
SkOptsEntry skopts = SK_OPTS_ENTRY__INIT;
int ret = -1, err = -1, proto;
@@ -272,6 +281,7 @@ static int do_dump_one_inet_fd(int lfd, u32 id, const struct fd_parms *p, int fa
ie.fown = (FownEntry *)&p->fown;
ie.opts = &skopts;
+ ie.ip_opts = &ipopts;
ie.n_src_addr = PB_ALEN_INET;
ie.n_dst_addr = PB_ALEN_INET;
@@ -298,6 +308,9 @@ static int do_dump_one_inet_fd(int lfd, u32 id, const struct fd_parms *p, int fa
memcpy(ie.src_addr, sk->src_addr, pb_repeated_size(&ie, src_addr));
memcpy(ie.dst_addr, sk->dst_addr, pb_repeated_size(&ie, dst_addr));
+ if (dump_ip_opts(lfd, &ipopts))
+ goto err;
+
if (dump_socket_opts(lfd, &skopts))
goto err;
@@ -477,6 +490,15 @@ static int post_open_inet_sk(struct file_desc *d, int sk)
return 0;
}
+int restore_ip_opts(int sk, IpOptsEntry *ioe)
+{
+ int ret = 0;
+
+ if (ioe->has_freebind)
+ ret |= restore_opt(sk, SOL_SOCKET, SO_PRIORITY, &ioe->freebind);
+
+ return ret;
+}
static int open_inet_sk(struct file_desc *d)
{
struct inet_sk_info *ii;
@@ -565,6 +587,9 @@ done:
if (rst_file_params(sk, ie->fown, ie->flags))
goto err;
+ if (ie->ip_opts && restore_ip_opts(sk, ie->ip_opts))
+ goto err;
+
if (restore_socket_opts(sk, ie->opts))
goto err;
--
2.4.3
More information about the CRIU
mailing list