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
48a97f16
Unverified
Commit
48a97f16
authored
Oct 01, 2017
by
Christian Brauner
Committed by
Stéphane Graber
Oct 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: use single helper to delete networks
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
b1eee4e4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
34 deletions
+20
-34
network.c
src/lxc/network.c
+16
-13
network.h
src/lxc/network.h
+1
-2
start.c
src/lxc/start.c
+3
-19
No files found.
src/lxc/network.c
View file @
48a97f16
...
...
@@ -2299,10 +2299,6 @@ bool lxc_delete_network_unpriv(struct lxc_handler *handler)
* \0
*/
char
netns_path
[
6
+
LXC_NUMSTRLEN64
+
4
+
LXC_NUMSTRLEN64
+
1
];
bool
deleted_all
=
true
;
if
(
handler
->
am_root
)
return
true
;
*
netns_path
=
'\0'
;
...
...
@@ -2362,7 +2358,6 @@ bool lxc_delete_network_unpriv(struct lxc_handler *handler)
handler
->
name
,
netdev
,
netns_path
);
if
(
ret
<
0
)
{
deleted_all
=
false
;
WARN
(
"Failed to remove port
\"
%s
\"
from openvswitch "
"bridge
\"
%s
\"
"
,
hostveth
,
netdev
->
link
);
continue
;
...
...
@@ -2371,7 +2366,7 @@ bool lxc_delete_network_unpriv(struct lxc_handler *handler)
netdev
->
link
);
}
return
deleted_all
;
return
true
;
}
int
lxc_create_network_priv
(
struct
lxc_handler
*
handler
)
...
...
@@ -2479,10 +2474,6 @@ bool lxc_delete_network_priv(struct lxc_handler *handler)
int
ret
;
struct
lxc_list
*
iterator
;
struct
lxc_list
*
network
=
&
handler
->
conf
->
network
;
bool
deleted_all
=
true
;
if
(
!
handler
->
am_root
)
return
true
;
lxc_list_for_each
(
iterator
,
network
)
{
char
*
hostveth
=
NULL
;
...
...
@@ -2524,7 +2515,6 @@ bool lxc_delete_network_priv(struct lxc_handler *handler)
netdev
->
name
[
0
]
!=
'\0'
?
netdev
->
name
:
"(null)"
,
netdev
->
ifindex
);
}
else
if
(
ret
<
0
)
{
deleted_all
=
false
;
WARN
(
"Failed to remove interface
\"
%s
\"
with "
"index %d: %s"
,
netdev
->
name
[
0
]
!=
'\0'
?
netdev
->
name
:
"(null)"
,
...
...
@@ -2550,7 +2540,6 @@ bool lxc_delete_network_priv(struct lxc_handler *handler)
ret
=
lxc_netdev_delete_by_name
(
hostveth
);
if
(
ret
<
0
)
{
deleted_all
=
false
;
WARN
(
"Failed to remove interface
\"
%s
\"
from
\"
%s
\"
: %s"
,
hostveth
,
netdev
->
link
,
strerror
(
-
ret
));
continue
;
...
...
@@ -2574,7 +2563,7 @@ bool lxc_delete_network_priv(struct lxc_handler *handler)
netdev
->
priv
.
veth_attr
.
veth1
[
0
]
=
'\0'
;
}
return
deleted_all
;
return
true
;
}
int
lxc_requests_empty_network
(
struct
lxc_handler
*
handler
)
...
...
@@ -3094,3 +3083,17 @@ int lxc_network_recv_name_and_ifindex_from_child(struct lxc_handler *handler)
return
0
;
}
void
lxc_delete_network
(
struct
lxc_handler
*
handler
)
{
bool
bret
;
if
(
handler
->
am_root
)
bret
=
lxc_delete_network_priv
(
handler
);
else
bret
=
lxc_delete_network_unpriv
(
handler
);
if
(
!
bret
)
DEBUG
(
"Failed to delete network devices"
);
else
DEBUG
(
"Deleted network devices"
);
}
src/lxc/network.h
View file @
48a97f16
...
...
@@ -266,8 +266,7 @@ extern int lxc_network_move_created_netdev_priv(const char *lxcpath,
char
*
lxcname
,
struct
lxc_list
*
network
,
pid_t
pid
);
extern
bool
lxc_delete_network_priv
(
struct
lxc_handler
*
handler
);
extern
bool
lxc_delete_network_unpriv
(
struct
lxc_handler
*
handler
);
extern
void
lxc_delete_network
(
struct
lxc_handler
*
handler
);
extern
int
lxc_find_gateway_addresses
(
struct
lxc_handler
*
handler
);
extern
int
lxc_create_network_unpriv
(
const
char
*
lxcpath
,
char
*
lxcname
,
struct
lxc_list
*
network
,
pid_t
pid
);
...
...
src/lxc/start.c
View file @
48a97f16
...
...
@@ -1395,14 +1395,8 @@ out_delete_net:
if
(
cgroups_connected
)
cgroup_disconnect
();
if
(
handler
->
clone_flags
&
CLONE_NEWNET
)
{
DEBUG
(
"Tearing down network devices"
);
if
(
!
lxc_delete_network_priv
(
handler
))
DEBUG
(
"Failed tearing down network devices"
);
if
(
!
lxc_delete_network_unpriv
(
handler
))
DEBUG
(
"Failed tearing down network devices"
);
}
if
(
handler
->
clone_flags
&
CLONE_NEWNET
)
lxc_delete_network
(
handler
);
out_abort:
lxc_abort
(
name
,
handler
);
...
...
@@ -1513,17 +1507,7 @@ int __lxc_start(const char *name, struct lxc_handler *handler,
err
=
lxc_error_set_and_log
(
handler
->
pid
,
status
);
out_fini:
DEBUG
(
"Tearing down network devices"
);
if
(
!
lxc_delete_network_priv
(
handler
))
DEBUG
(
"Failed tearing down network devices"
);
if
(
!
lxc_delete_network_unpriv
(
handler
))
DEBUG
(
"Failed tearing down network devices"
);
if
(
handler
->
netnsfd
>=
0
)
{
close
(
handler
->
netnsfd
);
handler
->
netnsfd
=
-
1
;
}
lxc_delete_network
(
handler
);
out_detach_blockdev:
detach_block_device
(
handler
->
conf
);
...
...
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