2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00

restore: Defer new net-namespace creation until forked

Some kernel modules such as pktgen runs kthred upon
new-net creation taking last_pid we were requested.
Lets workaround this problem using clone + unshare
bundle.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Cyrill Gorcunov
2014-10-27 18:31:11 +03:00
committed by Pavel Emelyanov
parent 4cb9eaf39f
commit 7688fbc1cf

View File

@@ -1086,8 +1086,16 @@ static inline int fork_with_pid(struct pstree_item *item)
if (netns_pre_create())
goto err_unlock;
/*
* Some kernel modules, such as netwrok packet generator
* run kernel thread upon net-namespace creattion taking
* the @pid we've been requeting via LAST_PID_PATH interface
* so that we can't restore a take with pid needed.
*
* Here is an idea -- unhare net namespace in callee instead.
*/
ret = clone(restore_task_with_children, ca.stack_ptr,
ca.clone_flags | SIGCHLD, &ca);
(ca.clone_flags & ~CLONE_NEWNET) | SIGCHLD, &ca);
if (ret < 0) {
pr_perror("Can't fork for %d", pid);
@@ -1411,6 +1419,14 @@ static int restore_task_with_children(void *_arg)
if (ret < 0)
goto err;
if (ca->clone_flags & CLONE_NEWNET) {
ret = unshare(CLONE_NEWNET);
if (ret) {
pr_perror("Can't unshare net-namespace");
goto err;
}
}
/* Restore root task */
if (current->parent == NULL) {
if (restore_finish_stage(CR_STATE_RESTORE_NS) < 0)