Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
criu
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhul
criu
Commits
35ad233f
Commit
35ad233f
authored
Feb 15, 2018
by
Andrei Vagin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/zdtm/static/netns_sub_veth.c
parent
98b5542c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
55 deletions
+0
-55
netns_sub_veth.c
test/zdtm/static/netns_sub_veth.c
+0
-55
No files found.
test/zdtm/static/netns_sub_veth.c
View file @
35ad233f
#define _GNU_SOURCE
#include <sched.h>
#include <errno.h>
#include <stdlib.h>
...
...
@@ -23,39 +22,6 @@
const
char
*
test_doc
=
"Check dump and restore a few network namespaces"
;
#define ID_MAP "0 0 1"
static
int
init_proc_id_maps
(
pid_t
pid
)
{
char
path
[
128
];
int
fd
;
snprintf
(
path
,
sizeof
(
path
),
"/proc/%d/uid_map"
,
pid
);
fd
=
open
(
path
,
O_WRONLY
);
if
(
fd
<
0
)
{
pr_perror
(
"Unable to open %s"
,
path
);
return
-
1
;
}
if
(
write
(
fd
,
ID_MAP
,
sizeof
(
ID_MAP
))
!=
sizeof
(
ID_MAP
))
{
pr_perror
(
"Unable to write into %s"
,
path
);
return
-
1
;
}
close
(
fd
);
snprintf
(
path
,
sizeof
(
path
),
"/proc/%d/gid_map"
,
pid
);
fd
=
open
(
path
,
O_WRONLY
);
if
(
fd
<
0
)
{
pr_perror
(
"Unable to open %s"
,
path
);
return
-
1
;
}
if
(
write
(
fd
,
ID_MAP
,
sizeof
(
ID_MAP
))
!=
sizeof
(
ID_MAP
))
{
pr_perror
(
"Unable to write into %s"
,
path
);
return
-
1
;
}
close
(
fd
);
return
0
;
}
#ifndef NSIO
#define NSIO 0xb7
#define NS_GET_USERNS _IO(NSIO, 0x1)
...
...
@@ -70,27 +36,10 @@ int main(int argc, char **argv)
struct
rtnl_link
*
link
=
NULL
,
*
new
;
struct
nl_sock
*
sk
;
int
has_index
=
1
;
bool
userns
;
test_init
(
argc
,
argv
);
task_waiter_init
(
&
lock
);
userns
=
getenv
(
"ZDTM_USERNS"
)
!=
NULL
;
if
(
userns
)
{
int
fd
,
ufd
;
fd
=
open
(
"/proc/self/ns/net"
,
O_RDONLY
);
if
(
fd
<
0
)
{
pr_perror
(
"Unable to open /proc/self/ns/net"
);
return
1
;
}
ufd
=
ioctl
(
fd
,
NS_GET_USERNS
);
if
(
ufd
<
0
)
{
userns
=
false
;
}
else
close
(
ufd
);
close
(
fd
);
}
for
(
i
=
0
;
i
<
2
;
i
++
)
{
pid
[
i
]
=
fork
();
if
(
pid
[
i
]
<
0
)
{
...
...
@@ -98,8 +47,6 @@ int main(int argc, char **argv)
return
-
1
;
}
if
(
pid
[
i
]
==
0
)
{
if
(
userns
&&
unshare
(
CLONE_NEWUSER
))
return
1
;
if
(
unshare
(
CLONE_NEWNET
))
return
1
;
...
...
@@ -109,8 +56,6 @@ int main(int argc, char **argv)
return
0
;
}
task_waiter_wait4
(
&
lock
,
i
);
if
(
userns
&&
init_proc_id_maps
(
pid
[
i
]))
return
1
;
}
sk
=
nl_socket_alloc
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment