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
3c09b97c
Unverified
Commit
3c09b97c
authored
Jul 03, 2019
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: send names for all non-trivial network types
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
61302ef7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
15 deletions
+23
-15
network.c
src/lxc/network.c
+17
-9
network.h
src/lxc/network.h
+2
-2
start.c
src/lxc/start.c
+4
-4
No files found.
src/lxc/network.c
View file @
3c09b97c
...
...
@@ -3174,6 +3174,17 @@ int lxc_network_move_created_netdev_priv(struct lxc_handler *handler)
return
0
;
}
static
int
network_requires_advanced_setup
(
int
type
)
{
if
(
type
==
LXC_NET_EMPTY
)
return
false
;
if
(
type
==
LXC_NET_NONE
)
return
false
;
return
true
;
}
static
int
lxc_create_network_unpriv
(
struct
lxc_handler
*
handler
)
{
int
hooks_version
=
handler
->
conf
->
hooks_version
;
...
...
@@ -3186,10 +3197,7 @@ static int lxc_create_network_unpriv(struct lxc_handler *handler)
lxc_list_for_each
(
iterator
,
network
)
{
struct
lxc_netdev
*
netdev
=
iterator
->
elem
;
if
(
netdev
->
type
==
LXC_NET_EMPTY
)
continue
;
if
(
netdev
->
type
==
LXC_NET_NONE
)
if
(
!
network_requires_advanced_setup
(
netdev
->
type
))
continue
;
if
(
netdev
->
type
!=
LXC_NET_VETH
)
{
...
...
@@ -3528,7 +3536,7 @@ static int lxc_setup_netdev_in_child_namespaces(struct lxc_netdev *netdev)
netdev
->
ifindex
=
if_nametoindex
(
netdev
->
created_name
);
if
(
!
netdev
->
ifindex
)
SYSERROR
(
"Failed to retrieve ifindex for network device with name %s"
,
netdev
->
name
?:
"(null)"
);
netdev
->
created_
name
?:
"(null)"
);
}
/* get the new ifindex in case of physical netdev */
...
...
@@ -3763,7 +3771,7 @@ int lxc_setup_network_in_child_namespaces(const struct lxc_conf *conf,
return
0
;
}
int
lxc_network_send_
veth_names_
to_child
(
struct
lxc_handler
*
handler
)
int
lxc_network_send_to_child
(
struct
lxc_handler
*
handler
)
{
struct
lxc_list
*
iterator
;
struct
lxc_list
*
network
=
&
handler
->
conf
->
network
;
...
...
@@ -3773,7 +3781,7 @@ int lxc_network_send_veth_names_to_child(struct lxc_handler *handler)
int
ret
;
struct
lxc_netdev
*
netdev
=
iterator
->
elem
;
if
(
netdev
->
type
!=
LXC_NET_VETH
)
if
(
!
network_requires_advanced_setup
(
netdev
->
type
)
)
continue
;
ret
=
lxc_send_nointr
(
data_sock
,
netdev
->
name
,
IFNAMSIZ
,
MSG_NOSIGNAL
);
...
...
@@ -3790,7 +3798,7 @@ int lxc_network_send_veth_names_to_child(struct lxc_handler *handler)
return
0
;
}
int
lxc_network_recv_
veth_names_
from_parent
(
struct
lxc_handler
*
handler
)
int
lxc_network_recv_from_parent
(
struct
lxc_handler
*
handler
)
{
struct
lxc_list
*
iterator
;
struct
lxc_list
*
network
=
&
handler
->
conf
->
network
;
...
...
@@ -3800,7 +3808,7 @@ int lxc_network_recv_veth_names_from_parent(struct lxc_handler *handler)
int
ret
;
struct
lxc_netdev
*
netdev
=
iterator
->
elem
;
if
(
netdev
->
type
!=
LXC_NET_VETH
)
if
(
!
network_requires_advanced_setup
(
netdev
->
type
)
)
continue
;
ret
=
lxc_recv_nointr
(
data_sock
,
netdev
->
name
,
IFNAMSIZ
,
0
);
...
...
src/lxc/network.h
View file @
3c09b97c
...
...
@@ -278,8 +278,8 @@ extern int lxc_requests_empty_network(struct lxc_handler *handler);
extern
int
lxc_restore_phys_nics_to_netns
(
struct
lxc_handler
*
handler
);
extern
int
lxc_setup_network_in_child_namespaces
(
const
struct
lxc_conf
*
conf
,
struct
lxc_list
*
network
);
extern
int
lxc_network_send_
veth_names_
to_child
(
struct
lxc_handler
*
handler
);
extern
int
lxc_network_recv_
veth_names_
from_parent
(
struct
lxc_handler
*
handler
);
extern
int
lxc_network_send_to_child
(
struct
lxc_handler
*
handler
);
extern
int
lxc_network_recv_from_parent
(
struct
lxc_handler
*
handler
);
extern
int
lxc_network_send_name_and_ifindex_to_parent
(
struct
lxc_handler
*
handler
);
extern
int
lxc_network_recv_name_and_ifindex_from_child
(
struct
lxc_handler
*
handler
);
extern
int
lxc_netns_set_nsid
(
int
netns_fd
);
...
...
src/lxc/start.c
View file @
3c09b97c
...
...
@@ -1194,7 +1194,7 @@ static int do_start(void *data)
goto
out_error
;
if
(
handler
->
ns_clone_flags
&
CLONE_NEWNET
)
{
ret
=
lxc_network_recv_
veth_names_
from_parent
(
handler
);
ret
=
lxc_network_recv_from_parent
(
handler
);
if
(
ret
<
0
)
{
ERROR
(
"Failed to receive veth names from parent"
);
goto
out_warn_father
;
...
...
@@ -1252,12 +1252,12 @@ static int do_start(void *data)
*/
if
(
handler
->
daemonize
&&
!
handler
->
conf
->
autodev
)
{
char
path
[
PATH_MAX
];
ret
=
snprintf
(
path
,
sizeof
(
path
),
"%s/dev/null"
,
handler
->
conf
->
rootfs
.
mount
);
if
(
ret
<
0
||
ret
>=
sizeof
(
path
))
goto
out_warn_father
;
ret
=
access
(
path
,
F_OK
);
if
(
ret
!=
0
)
{
devnull_fd
=
open_devnull
();
...
...
@@ -1839,7 +1839,7 @@ static int lxc_spawn(struct lxc_handler *handler)
goto
out_delete_net
;
}
ret
=
lxc_network_send_
veth_names_
to_child
(
handler
);
ret
=
lxc_network_send_to_child
(
handler
);
if
(
ret
<
0
)
{
ERROR
(
"Failed to send veth names to child"
);
goto
out_delete_net
;
...
...
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