Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
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
Chen Yisong
lxc
Commits
671c3c49
Commit
671c3c49
authored
Oct 28, 2016
by
Christian Brauner
Committed by
Stéphane Graber
Nov 21, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lxc_user_nic: use lxc_preserve_ns()
Signed-off-by:
Christian Brauner
<
christian.brauner@canonical.com
>
parent
377d0119
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
12 deletions
+8
-12
lxc_user_nic.c
src/lxc/lxc_user_nic.c
+8
-12
No files found.
src/lxc/lxc_user_nic.c
View file @
671c3c49
...
@@ -673,25 +673,21 @@ again:
...
@@ -673,25 +673,21 @@ again:
static
int
rename_in_ns
(
int
pid
,
char
*
oldname
,
char
**
newnamep
)
static
int
rename_in_ns
(
int
pid
,
char
*
oldname
,
char
**
newnamep
)
{
{
char
nspath
[
MAXPATHLEN
];
int
fd
=
-
1
,
ofd
=
-
1
,
ret
,
ifindex
=
-
1
;
int
fd
=
-
1
,
ofd
=
-
1
,
ret
,
ifindex
=
-
1
;
bool
grab_newname
=
false
;
bool
grab_newname
=
false
;
ret
=
snprintf
(
nspath
,
MAXPATHLEN
,
"/proc/%d/ns/net"
,
getpid
());
ofd
=
lxc_preserve_ns
(
getpid
(),
"net"
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
if
(
ofd
<
0
)
{
return
-
1
;
fprintf
(
stderr
,
"Failed opening network namespace path for '%d'."
,
getpid
());
if
((
ofd
=
open
(
nspath
,
O_RDONLY
))
<
0
)
{
fprintf
(
stderr
,
"Opening %s
\n
"
,
nspath
);
return
-
1
;
return
-
1
;
}
}
ret
=
snprintf
(
nspath
,
MAXPATHLEN
,
"/proc/%d/ns/net"
,
pid
);
if
(
ret
<
0
||
ret
>=
MAXPATHLEN
)
goto
out_err
;
if
((
fd
=
open
(
nspath
,
O_RDONLY
))
<
0
)
{
fd
=
lxc_preserve_ns
(
pid
,
"net"
);
fprintf
(
stderr
,
"Opening %s
\n
"
,
nspath
);
if
(
fd
<
0
)
{
goto
out_err
;
fprintf
(
stderr
,
"Failed opening network namespace path for '%d'."
,
pid
);
return
-
1
;
}
}
if
(
setns
(
fd
,
0
)
<
0
)
{
if
(
setns
(
fd
,
0
)
<
0
)
{
fprintf
(
stderr
,
"setns to container network namespace
\n
"
);
fprintf
(
stderr
,
"setns to container network namespace
\n
"
);
goto
out_err
;
goto
out_err
;
...
...
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