[3/8] net_ns: Make net_ns check in do_restore_task_net_ns more universal

Submitted by Kirill Tkhai on June 28, 2017, 11:48 a.m.

Details

Message ID 149865053879.12218.5692206956633568522.stgit@localhost.localdomain
State New
Series "One-level leaked net_ns support"
Headers show

Commit Message

Kirill Tkhai June 28, 2017, 11:48 a.m.
setns() on the same net_ns is OK (just a noop),
while the task has permissions to do that.
But if the namespace is inherited from parent task,
we can't do that.

So, 1)speedup existing cases, and 2)support "inherited ns" case.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/net.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/criu/net.c b/criu/net.c
index 15aae2be4..18c13e4ae 100644
--- a/criu/net.c
+++ b/criu/net.c
@@ -2162,7 +2162,7 @@  static int do_restore_task_net_ns(struct ns_id *nsid, struct pstree_item *curren
 {
 	int fd;
 
-	if (!(root_ns_mask & CLONE_NEWNET))
+	if (current->net_ns == nsid)
 		return 0;
 
 	fd = fdstore_get(nsid->net.nsfd_id);