Commit 3957a9a6 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

cr-dump: lock network before dump and unlock in case of errors

Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent fbea445d
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "pstree.h" #include "pstree.h"
#include "mount.h" #include "mount.h"
#include "tty.h" #include "tty.h"
#include "net.h"
#include "protobuf.h" #include "protobuf.h"
#include "protobuf/fdinfo.pb-c.h" #include "protobuf/fdinfo.pb-c.h"
...@@ -1579,6 +1580,9 @@ int cr_dump_tasks(pid_t pid, const struct cr_options *opts) ...@@ -1579,6 +1580,9 @@ int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
pr_info("Dumping processes (pid: %d)\n", pid); pr_info("Dumping processes (pid: %d)\n", pid);
pr_info("========================================\n"); pr_info("========================================\n");
if (network_lock())
goto err;
if (write_img_inventory()) if (write_img_inventory())
goto err; goto err;
...@@ -1636,7 +1640,7 @@ err: ...@@ -1636,7 +1640,7 @@ err:
* don't, just close them silently. * don't, just close them silently.
*/ */
if (ret) if (ret)
tcp_unlock_all(); network_unlock();
pstree_switch_state(root_item, pstree_switch_state(root_item,
ret ? TASK_ALIVE : opts->final_state); ret ? TASK_ALIVE : opts->final_state);
free_pstree(root_item); free_pstree(root_item);
......
...@@ -16,4 +16,7 @@ struct veth_pair { ...@@ -16,4 +16,7 @@ struct veth_pair {
char *inside; char *inside;
char *outside; char *outside;
}; };
extern int network_lock(void);
extern void network_unlock(void);
#endif #endif
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "net.h" #include "net.h"
#include "libnetlink.h" #include "libnetlink.h"
#include "crtools.h" #include "crtools.h"
#include "sk-inet.h"
#include "protobuf.h" #include "protobuf.h"
#include "protobuf/netdev.pb-c.h" #include "protobuf/netdev.pb-c.h"
...@@ -405,3 +406,28 @@ int netns_pre_create(void) ...@@ -405,3 +406,28 @@ int netns_pre_create(void)
pr_info("Saved netns fd for links restore\n"); pr_info("Saved netns fd for links restore\n");
return 0; return 0;
} }
int network_lock(void)
{
pr_info("Lock network\n");
/* Each connection will be locked on dump */
if (!(opts.namespaces_flags & CLONE_NEWNET))
return 0;
return run_scripts("network-lock");
}
void network_unlock(void)
{
pr_info("Unlock network\n");
if (!(opts.namespaces_flags & CLONE_NEWNET)) {
tcp_unlock_all();
return;
}
run_scripts("network-unlock");
}
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