mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +00:00
net: Dump tun device net id in img
This adds new tunfile_entry::ns_id field and populates it in standard socket way. Restore uses this ns_id to choose correct namespace. Note, we could completelly skip set_netns() on restore in case of !has_ns_id, but using top_net_ns invents some definite behaviour. Signed-off-by: Andrew Vagin <avagin@virtuozzo.com> ktkhai: comment written/code movings Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
This commit is contained in:
committed by
Andrei Vagin
parent
2e5d5a399d
commit
80eaf6c90a
@@ -20,6 +20,7 @@
|
||||
#include "namespaces.h"
|
||||
#include "xmalloc.h"
|
||||
#include "kerndat.h"
|
||||
#include "sockets.h"
|
||||
|
||||
#include "images/tun.pb-c.h"
|
||||
|
||||
@@ -304,6 +305,8 @@ static int dump_tunfile(int lfd, u32 id, const struct fd_parms *p)
|
||||
pr_err("No net_ns for tun device\n");
|
||||
return -1;
|
||||
}
|
||||
tfe.has_ns_id = true;
|
||||
tfe.ns_id = ns->id;
|
||||
}
|
||||
|
||||
if (dump_one_reg_file(lfd, id, p))
|
||||
@@ -356,7 +359,7 @@ struct tunfile_info {
|
||||
|
||||
static int tunfile_open(struct file_desc *d, int *new_fd)
|
||||
{
|
||||
int fd;
|
||||
int fd, ns_id;
|
||||
struct tunfile_info *ti;
|
||||
struct ifreq ifr;
|
||||
struct tun_link *tl;
|
||||
@@ -366,6 +369,10 @@ static int tunfile_open(struct file_desc *d, int *new_fd)
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
|
||||
ns_id = ti->tfe->has_ns_id ? ti->tfe->ns_id : top_net_ns->id;
|
||||
if (set_netns(ns_id))
|
||||
return -1;
|
||||
|
||||
if (!ti->tfe->netdev)
|
||||
/* just-opened tun file */
|
||||
goto ok;;
|
||||
|
@@ -6,6 +6,7 @@ message tunfile_entry {
|
||||
required uint32 id = 1;
|
||||
optional string netdev = 2;
|
||||
optional bool detached = 3;
|
||||
optional uint32 ns_id = 4;
|
||||
};
|
||||
|
||||
message tun_link_entry {
|
||||
|
Reference in New Issue
Block a user