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
299d022d
Unverified
Commit
299d022d
authored
Jul 26, 2019
by
Stéphane Graber
Committed by
GitHub
Jul 26, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3106 from brauner/2019-07-25/bugfixes
network: restore ability to move nl80211 devices
parents
d0b95044
3dd78294
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
14 deletions
+17
-14
network.c
src/lxc/network.c
+17
-14
No files found.
src/lxc/network.c
View file @
299d022d
...
@@ -1248,22 +1248,21 @@ static int lxc_netdev_rename_by_name_in_netns(pid_t pid, const char *old,
...
@@ -1248,22 +1248,21 @@ static int lxc_netdev_rename_by_name_in_netns(pid_t pid, const char *old,
static
int
lxc_netdev_move_wlan
(
char
*
physname
,
const
char
*
ifname
,
pid_t
pid
,
static
int
lxc_netdev_move_wlan
(
char
*
physname
,
const
char
*
ifname
,
pid_t
pid
,
const
char
*
newname
)
const
char
*
newname
)
{
{
char
*
cmd
;
__do_free
char
*
cmd
=
NULL
;
pid_t
fpid
;
pid_t
fpid
;
int
err
=
-
1
;
/* Move phyN into the container. TODO - do this using netlink.
/* Move phyN into the container. TODO - do this using netlink.
* However, IIUC this involves a bit more complicated work to talk to
* However, IIUC this involves a bit more complicated work to talk to
* the 80211 module, so for now just call out to iw.
* the 80211 module, so for now just call out to iw.
*/
*/
cmd
=
on_path
(
"iw"
,
NULL
);
cmd
=
on_path
(
"iw"
,
NULL
);
if
(
!
cmd
)
if
(
!
cmd
)
{
goto
out
1
;
return
-
1
;
free
(
cmd
);
}
fpid
=
fork
();
fpid
=
fork
();
if
(
fpid
<
0
)
if
(
fpid
<
0
)
goto
out
1
;
return
-
1
;
if
(
fpid
==
0
)
{
if
(
fpid
==
0
)
{
char
pidstr
[
30
];
char
pidstr
[
30
];
...
@@ -1274,21 +1273,18 @@ static int lxc_netdev_move_wlan(char *physname, const char *ifname, pid_t pid,
...
@@ -1274,21 +1273,18 @@ static int lxc_netdev_move_wlan(char *physname, const char *ifname, pid_t pid,
}
}
if
(
wait_for_pid
(
fpid
))
if
(
wait_for_pid
(
fpid
))
goto
out
1
;
return
-
1
;
err
=
0
;
if
(
newname
)
if
(
newname
)
err
=
lxc_netdev_rename_by_name_in_netns
(
pid
,
ifname
,
newname
);
return
lxc_netdev_rename_by_name_in_netns
(
pid
,
ifname
,
newname
);
out1:
return
0
;
free
(
physname
);
return
err
;
}
}
int
lxc_netdev_move_by_name
(
const
char
*
ifname
,
pid_t
pid
,
const
char
*
newname
)
int
lxc_netdev_move_by_name
(
const
char
*
ifname
,
pid_t
pid
,
const
char
*
newname
)
{
{
__do_free
char
*
physname
=
NULL
;
int
index
;
int
index
;
char
*
physname
;
if
(
!
ifname
)
if
(
!
ifname
)
return
-
EINVAL
;
return
-
EINVAL
;
...
@@ -3279,13 +3275,20 @@ int lxc_network_move_created_netdev_priv(struct lxc_handler *handler)
...
@@ -3279,13 +3275,20 @@ int lxc_network_move_created_netdev_priv(struct lxc_handler *handler)
return
0
;
return
0
;
lxc_list_for_each
(
iterator
,
network
)
{
lxc_list_for_each
(
iterator
,
network
)
{
__do_free
char
*
physname
=
NULL
;
int
ret
;
int
ret
;
struct
lxc_netdev
*
netdev
=
iterator
->
elem
;
struct
lxc_netdev
*
netdev
=
iterator
->
elem
;
if
(
!
netdev
->
ifindex
)
if
(
!
netdev
->
ifindex
)
continue
;
continue
;
ret
=
lxc_netdev_move_by_index
(
netdev
->
ifindex
,
pid
,
NULL
);
if
(
netdev
->
type
==
LXC_NET_PHYS
)
physname
=
is_wlan
(
netdev
->
link
);
if
(
physname
)
ret
=
lxc_netdev_move_wlan
(
physname
,
netdev
->
link
,
pid
,
NULL
);
else
ret
=
lxc_netdev_move_by_index
(
netdev
->
ifindex
,
pid
,
NULL
);
if
(
ret
)
{
if
(
ret
)
{
errno
=
-
ret
;
errno
=
-
ret
;
SYSERROR
(
"Failed to move network device
\"
%s
\"
with ifindex %d to network namespace %d"
,
SYSERROR
(
"Failed to move network device
\"
%s
\"
with ifindex %d to network namespace %d"
,
...
...
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