Commit 336b9909 authored by Pavel Emelyanov's avatar Pavel Emelyanov

net: Add flags to run_ip_tool

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 18d91708
...@@ -588,7 +588,7 @@ exit: ...@@ -588,7 +588,7 @@ exit:
return ret; return ret;
} }
static int run_ip_tool(char *arg1, char *arg2, char *arg3, int fdin, int fdout) static int run_ip_tool(char *arg1, char *arg2, char *arg3, int fdin, int fdout, unsigned flags)
{ {
char *ip_tool_cmd; char *ip_tool_cmd;
int ret; int ret;
...@@ -600,7 +600,7 @@ static int run_ip_tool(char *arg1, char *arg2, char *arg3, int fdin, int fdout) ...@@ -600,7 +600,7 @@ static int run_ip_tool(char *arg1, char *arg2, char *arg3, int fdin, int fdout)
ip_tool_cmd = "ip"; ip_tool_cmd = "ip";
ret = cr_system(fdin, fdout, -1, ip_tool_cmd, ret = cr_system(fdin, fdout, -1, ip_tool_cmd,
(char *[]) { "ip", arg1, arg2, arg3, NULL }, 0); (char *[]) { "ip", arg1, arg2, arg3, NULL }, flags);
if (ret) { if (ret) {
pr_err("IP tool failed on %s %s\n", arg1, arg2); pr_err("IP tool failed on %s %s\n", arg1, arg2);
return -1; return -1;
...@@ -628,7 +628,7 @@ static int run_iptables_tool(char *def_cmd, int fdin, int fdout) ...@@ -628,7 +628,7 @@ static int run_iptables_tool(char *def_cmd, int fdin, int fdout)
static inline int dump_ifaddr(struct cr_imgset *fds) static inline int dump_ifaddr(struct cr_imgset *fds)
{ {
struct cr_img *img = img_from_set(fds, CR_FD_IFADDR); struct cr_img *img = img_from_set(fds, CR_FD_IFADDR);
return run_ip_tool("addr", "save", NULL, -1, img_raw_fd(img)); return run_ip_tool("addr", "save", NULL, -1, img_raw_fd(img), 0);
} }
static inline int dump_route(struct cr_imgset *fds) static inline int dump_route(struct cr_imgset *fds)
...@@ -636,7 +636,7 @@ static inline int dump_route(struct cr_imgset *fds) ...@@ -636,7 +636,7 @@ static inline int dump_route(struct cr_imgset *fds)
struct cr_img *img; struct cr_img *img;
img = img_from_set(fds, CR_FD_ROUTE); img = img_from_set(fds, CR_FD_ROUTE);
if (run_ip_tool("route", "save", NULL, -1, img_raw_fd(img))) if (run_ip_tool("route", "save", NULL, -1, img_raw_fd(img), 0))
return -1; return -1;
/* If ipv6 is disabled, "ip -6 route dump" dumps all routes */ /* If ipv6 is disabled, "ip -6 route dump" dumps all routes */
...@@ -646,7 +646,7 @@ static inline int dump_route(struct cr_imgset *fds) ...@@ -646,7 +646,7 @@ static inline int dump_route(struct cr_imgset *fds)
} }
img = img_from_set(fds, CR_FD_ROUTE6); img = img_from_set(fds, CR_FD_ROUTE6);
if (run_ip_tool("-6", "route", "save", -1, img_raw_fd(img))) if (run_ip_tool("-6", "route", "save", -1, img_raw_fd(img), 0))
return -1; return -1;
return 0; return 0;
...@@ -663,7 +663,7 @@ static inline int dump_rule(struct cr_imgset *fds) ...@@ -663,7 +663,7 @@ static inline int dump_rule(struct cr_imgset *fds)
if (!path) if (!path)
return -1; return -1;
if (run_ip_tool("rule", "save", NULL, -1, img_raw_fd(img))) { if (run_ip_tool("rule", "save", NULL, -1, img_raw_fd(img), 0)) {
pr_warn("Check if \"ip rule save\" is supported!\n"); pr_warn("Check if \"ip rule save\" is supported!\n");
unlinkat(get_service_fd(IMG_FD_OFF), path, 0); unlinkat(get_service_fd(IMG_FD_OFF), path, 0);
} }
...@@ -719,7 +719,7 @@ static int restore_ip_dump(int type, int pid, char *cmd) ...@@ -719,7 +719,7 @@ static int restore_ip_dump(int type, int pid, char *cmd)
if (empty_image(img)) if (empty_image(img))
return 0; return 0;
if (img) { if (img) {
ret = run_ip_tool(cmd, "restore", NULL, img_raw_fd(img), -1); ret = run_ip_tool(cmd, "restore", NULL, img_raw_fd(img), -1, 0);
close_image(img); close_image(img);
} }
...@@ -760,9 +760,9 @@ static inline int restore_rule(int pid) ...@@ -760,9 +760,9 @@ static inline int restore_rule(int pid)
* Delete 3 default rules to prevent duplicates. See kernel's * Delete 3 default rules to prevent duplicates. See kernel's
* function fib_default_rules_init() for the details. * function fib_default_rules_init() for the details.
*/ */
run_ip_tool("rule", "delete", NULL, -1, -1); run_ip_tool("rule", "delete", NULL, -1, -1, 0);
run_ip_tool("rule", "delete", NULL, -1, -1); run_ip_tool("rule", "delete", NULL, -1, -1, 0);
run_ip_tool("rule", "delete", NULL, -1, -1); run_ip_tool("rule", "delete", NULL, -1, -1, 0);
if (restore_ip_dump(CR_FD_RULE, pid, "rule")) if (restore_ip_dump(CR_FD_RULE, pid, "rule"))
ret = -1; ret = -1;
......
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