mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 22:35:33 +00:00
net: Routes dump and restore
Same here -- run ip tool and that's it. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
1
image.c
1
image.c
@@ -120,6 +120,7 @@ struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX] = {
|
||||
FD_ENTRY(MOUNTPOINTS, "mountpoints-%d", show_mountpoints),
|
||||
FD_ENTRY(NETDEV, "netdev-%d", show_netdevices),
|
||||
FD_ENTRY(IFADDR, "ifaddr-%d", show_ifaddrs),
|
||||
FD_ENTRY(ROUTE, "route-%d", show_routes),
|
||||
};
|
||||
|
||||
static struct cr_fdset *alloc_cr_fdset(int nr)
|
||||
|
@@ -48,6 +48,7 @@ enum {
|
||||
CR_FD_MOUNTPOINTS,
|
||||
CR_FD_NETDEV,
|
||||
CR_FD_IFADDR,
|
||||
CR_FD_ROUTE,
|
||||
_CR_FD_NS_TO,
|
||||
|
||||
CR_FD_PSTREE,
|
||||
|
@@ -59,6 +59,7 @@
|
||||
#define NETDEV_MAGIC 0x57373951 /* Yaroslavl */
|
||||
|
||||
#define IFADDR_MAGIC RAW_IMAGE_MAGIC
|
||||
#define ROUTE_MAGIC RAW_IMAGE_MAGIC
|
||||
|
||||
#define PAGE_IMAGE_SIZE 4096
|
||||
#define PAGE_RSS 1
|
||||
|
@@ -3,6 +3,7 @@
|
||||
struct cr_options;
|
||||
void show_netdevices(int fd, struct cr_options *);
|
||||
void show_ifaddrs(int fd, struct cr_options *);
|
||||
void show_routes(int fd, struct cr_options *);
|
||||
|
||||
struct cr_fdset;
|
||||
int dump_net_ns(int pid, struct cr_fdset *);
|
||||
|
18
net.c
18
net.c
@@ -232,6 +232,11 @@ static inline int dump_ifaddr(struct cr_fdset *fds)
|
||||
return run_ip_tool("addr", "save", -1, fdset_fd(fds, CR_FD_IFADDR));
|
||||
}
|
||||
|
||||
static inline int dump_route(struct cr_fdset *fds)
|
||||
{
|
||||
return run_ip_tool("route", "save", -1, fdset_fd(fds, CR_FD_ROUTE));
|
||||
}
|
||||
|
||||
static int restore_ip_dump(int type, int pid, char *cmd)
|
||||
{
|
||||
int fd, ret;
|
||||
@@ -250,11 +255,20 @@ static inline int restore_ifaddr(int pid)
|
||||
return restore_ip_dump(CR_FD_IFADDR, pid, "addr");
|
||||
}
|
||||
|
||||
static inline int restore_route(int pid)
|
||||
{
|
||||
return restore_ip_dump(CR_FD_ROUTE, pid, "route");
|
||||
}
|
||||
|
||||
void show_ifaddrs(int fd, struct cr_options *o)
|
||||
{
|
||||
BUG_ON(1);
|
||||
}
|
||||
|
||||
void show_routes(int fd, struct cr_options *o)
|
||||
{
|
||||
BUG_ON(1);
|
||||
}
|
||||
|
||||
int dump_net_ns(int pid, struct cr_fdset *fds)
|
||||
{
|
||||
@@ -265,6 +279,8 @@ int dump_net_ns(int pid, struct cr_fdset *fds)
|
||||
ret = dump_links(fds);
|
||||
if (!ret)
|
||||
ret = dump_ifaddr(fds);
|
||||
if (!ret)
|
||||
ret = dump_route(fds);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -276,6 +292,8 @@ int prepare_net_ns(int pid)
|
||||
ret = restore_links(pid);
|
||||
if (!ret)
|
||||
ret = restore_ifaddr(pid);
|
||||
if (!ret)
|
||||
ret = restore_route(pid);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user