mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 13:58:34 +00:00
cr-dump: lock network before dump and unlock in case of errors
Signed-off-by: Andrey Vagin <avagin@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
fbea445df4
commit
3957a9a69a
@@ -48,6 +48,7 @@
|
||||
#include "pstree.h"
|
||||
#include "mount.h"
|
||||
#include "tty.h"
|
||||
#include "net.h"
|
||||
|
||||
#include "protobuf.h"
|
||||
#include "protobuf/fdinfo.pb-c.h"
|
||||
@@ -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("========================================\n");
|
||||
|
||||
if (network_lock())
|
||||
goto err;
|
||||
|
||||
if (write_img_inventory())
|
||||
goto err;
|
||||
|
||||
@@ -1636,7 +1640,7 @@ err:
|
||||
* don't, just close them silently.
|
||||
*/
|
||||
if (ret)
|
||||
tcp_unlock_all();
|
||||
network_unlock();
|
||||
pstree_switch_state(root_item,
|
||||
ret ? TASK_ALIVE : opts->final_state);
|
||||
free_pstree(root_item);
|
||||
|
@@ -16,4 +16,7 @@ struct veth_pair {
|
||||
char *inside;
|
||||
char *outside;
|
||||
};
|
||||
|
||||
extern int network_lock(void);
|
||||
extern void network_unlock(void);
|
||||
#endif
|
||||
|
26
net.c
26
net.c
@@ -11,6 +11,7 @@
|
||||
#include "net.h"
|
||||
#include "libnetlink.h"
|
||||
#include "crtools.h"
|
||||
#include "sk-inet.h"
|
||||
|
||||
#include "protobuf.h"
|
||||
#include "protobuf/netdev.pb-c.h"
|
||||
@@ -405,3 +406,28 @@ int netns_pre_create(void)
|
||||
pr_info("Saved netns fd for links restore\n");
|
||||
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");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user