Commit a6439860 authored by Pavel Emelyanov's avatar Pavel Emelyanov

net: Routes dump and restore

Same here -- run ip tool and that's it.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent fc1eb967
......@@ -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 *);
......
......@@ -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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment