mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-01 06:45:35 +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(MOUNTPOINTS, "mountpoints-%d", show_mountpoints),
|
||||||
FD_ENTRY(NETDEV, "netdev-%d", show_netdevices),
|
FD_ENTRY(NETDEV, "netdev-%d", show_netdevices),
|
||||||
FD_ENTRY(IFADDR, "ifaddr-%d", show_ifaddrs),
|
FD_ENTRY(IFADDR, "ifaddr-%d", show_ifaddrs),
|
||||||
|
FD_ENTRY(ROUTE, "route-%d", show_routes),
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct cr_fdset *alloc_cr_fdset(int nr)
|
static struct cr_fdset *alloc_cr_fdset(int nr)
|
||||||
|
@@ -48,6 +48,7 @@ enum {
|
|||||||
CR_FD_MOUNTPOINTS,
|
CR_FD_MOUNTPOINTS,
|
||||||
CR_FD_NETDEV,
|
CR_FD_NETDEV,
|
||||||
CR_FD_IFADDR,
|
CR_FD_IFADDR,
|
||||||
|
CR_FD_ROUTE,
|
||||||
_CR_FD_NS_TO,
|
_CR_FD_NS_TO,
|
||||||
|
|
||||||
CR_FD_PSTREE,
|
CR_FD_PSTREE,
|
||||||
|
@@ -59,6 +59,7 @@
|
|||||||
#define NETDEV_MAGIC 0x57373951 /* Yaroslavl */
|
#define NETDEV_MAGIC 0x57373951 /* Yaroslavl */
|
||||||
|
|
||||||
#define IFADDR_MAGIC RAW_IMAGE_MAGIC
|
#define IFADDR_MAGIC RAW_IMAGE_MAGIC
|
||||||
|
#define ROUTE_MAGIC RAW_IMAGE_MAGIC
|
||||||
|
|
||||||
#define PAGE_IMAGE_SIZE 4096
|
#define PAGE_IMAGE_SIZE 4096
|
||||||
#define PAGE_RSS 1
|
#define PAGE_RSS 1
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
struct cr_options;
|
struct cr_options;
|
||||||
void show_netdevices(int fd, struct cr_options *);
|
void show_netdevices(int fd, struct cr_options *);
|
||||||
void show_ifaddrs(int fd, struct cr_options *);
|
void show_ifaddrs(int fd, struct cr_options *);
|
||||||
|
void show_routes(int fd, struct cr_options *);
|
||||||
|
|
||||||
struct cr_fdset;
|
struct cr_fdset;
|
||||||
int dump_net_ns(int pid, 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));
|
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)
|
static int restore_ip_dump(int type, int pid, char *cmd)
|
||||||
{
|
{
|
||||||
int fd, ret;
|
int fd, ret;
|
||||||
@@ -250,11 +255,20 @@ static inline int restore_ifaddr(int pid)
|
|||||||
return restore_ip_dump(CR_FD_IFADDR, pid, "addr");
|
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)
|
void show_ifaddrs(int fd, struct cr_options *o)
|
||||||
{
|
{
|
||||||
BUG_ON(1);
|
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)
|
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);
|
ret = dump_links(fds);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = dump_ifaddr(fds);
|
ret = dump_ifaddr(fds);
|
||||||
|
if (!ret)
|
||||||
|
ret = dump_route(fds);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -276,6 +292,8 @@ int prepare_net_ns(int pid)
|
|||||||
ret = restore_links(pid);
|
ret = restore_links(pid);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = restore_ifaddr(pid);
|
ret = restore_ifaddr(pid);
|
||||||
|
if (!ret)
|
||||||
|
ret = restore_route(pid);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user