[CRIU] [PATCH 12/28] net: Fixup net ns_id of sockets on old dumps
Kirill Tkhai
ktkhai at virtuozzo.com
Mon Jun 5 20:25:13 MSK 2017
Set them equal to top_net_ns.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/include/sockets.h | 1 +
criu/sk-inet.c | 1 +
criu/sk-netlink.c | 1 +
criu/sk-packet.c | 1 +
criu/sk-unix.c | 1 +
criu/sockets.c | 8 ++++++++
6 files changed, 13 insertions(+)
diff --git a/criu/include/sockets.h b/criu/include/sockets.h
index 93f9ca3cd..ad503a472 100644
--- a/criu/include/sockets.h
+++ b/criu/include/sockets.h
@@ -41,6 +41,7 @@ extern int fix_external_unix_sockets(void);
extern struct collect_image_info netlink_sk_cinfo;
extern struct socket_desc *lookup_socket(unsigned ino, int family, int proto);
+extern void fixup_sock_net_ns_id(uint32_t *ns_id, protobuf_c_boolean *has_ns_id);
extern const struct fdtype_ops unix_dump_ops;
extern const struct fdtype_ops inet_dump_ops;
diff --git a/criu/sk-inet.c b/criu/sk-inet.c
index 934867335..6499d52c0 100644
--- a/criu/sk-inet.c
+++ b/criu/sk-inet.c
@@ -523,6 +523,7 @@ static int collect_one_inetsk(void *o, ProtobufCMessage *base, struct cr_img *i)
ii->port = port_add(ii, ii->ie->src_port);
if (ii->port == NULL)
return -1;
+ fixup_sock_net_ns_id(&ii->ie->ns_id, &ii->ie->has_ns_id);
return file_desc_add(&ii->d, ii->ie->id, &inet_desc_ops);
}
diff --git a/criu/sk-netlink.c b/criu/sk-netlink.c
index 82f77aea2..ae3a4d231 100644
--- a/criu/sk-netlink.c
+++ b/criu/sk-netlink.c
@@ -238,6 +238,7 @@ static int collect_one_netlink_sk(void *o, ProtobufCMessage *base, struct cr_img
struct netlink_sock_info *si = o;
si->nse = pb_msg(base, NetlinkSkEntry);
+ fixup_sock_net_ns_id(&si->nse->ns_id, &si->nse->has_ns_id);
return file_desc_add(&si->d, si->nse->id, &netlink_sock_desc_ops);
}
diff --git a/criu/sk-packet.c b/criu/sk-packet.c
index b97270fc7..f2deddb82 100644
--- a/criu/sk-packet.c
+++ b/criu/sk-packet.c
@@ -564,6 +564,7 @@ static int collect_one_packet_sk(void *o, ProtobufCMessage *base, struct cr_img
struct packet_sock_info *si = o;
si->pse = pb_msg(base, PacketSockEntry);
+ fixup_sock_net_ns_id(&si->pse->ns_id, &si->pse->has_ns_id);
return file_desc_add(&si->d, si->pse->id, &packet_sock_desc_ops);
}
diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index 44a850067..6a5a0bc73 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -1411,6 +1411,7 @@ static int collect_one_unixsk(void *o, ProtobufCMessage *base, struct cr_img *i)
INIT_LIST_HEAD(&ui->connected);
INIT_LIST_HEAD(&ui->node);
ui->flags = 0;
+ fixup_sock_net_ns_id(&ui->ue->ns_id, &ui->ue->has_ns_id);
uname = ui->name;
ulen = ui->ue->name.len;
diff --git a/criu/sockets.c b/criu/sockets.c
index 5d006a3b7..d6e5fce61 100644
--- a/criu/sockets.c
+++ b/criu/sockets.c
@@ -778,3 +778,11 @@ int set_netns(uint32_t ns_id)
return 0;
}
+
+void fixup_sock_net_ns_id(uint32_t *ns_id, protobuf_c_boolean *has_ns_id)
+{
+ if (*has_ns_id)
+ return;
+ *has_ns_id = true;
+ *ns_id = top_net_ns->id;
+}
More information about the CRIU
mailing list