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
e5d2fd7c
Unverified
Commit
e5d2fd7c
authored
Jun 16, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: final cleanup
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
9d4bf22d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
116 deletions
+49
-116
conf.c
src/lxc/conf.c
+1
-93
conf.h
src/lxc/conf.h
+0
-2
confile.c
src/lxc/confile.c
+0
-0
confile_utils.c
src/lxc/confile_utils.c
+47
-21
confile_utils.h
src/lxc/confile_utils.h
+1
-0
No files found.
src/lxc/conf.c
View file @
e5d2fd7c
...
@@ -4282,98 +4282,6 @@ int run_lxc_hooks(const char *name, char *hook, struct lxc_conf *conf,
...
@@ -4282,98 +4282,6 @@ int run_lxc_hooks(const char *name, char *hook, struct lxc_conf *conf,
return
0
;
return
0
;
}
}
static
void
lxc_remove_nic
(
struct
lxc_list
*
it
)
{
struct
lxc_netdev
*
netdev
=
it
->
elem
;
struct
lxc_list
*
it2
,
*
next
;
lxc_list_del
(
it
);
free
(
netdev
->
link
);
free
(
netdev
->
name
);
if
(
netdev
->
type
==
LXC_NET_VETH
)
free
(
netdev
->
priv
.
veth_attr
.
pair
);
free
(
netdev
->
upscript
);
free
(
netdev
->
hwaddr
);
free
(
netdev
->
mtu
);
free
(
netdev
->
ipv4_gateway
);
free
(
netdev
->
ipv6_gateway
);
lxc_list_for_each_safe
(
it2
,
&
netdev
->
ipv4
,
next
)
{
lxc_list_del
(
it2
);
free
(
it2
->
elem
);
free
(
it2
);
}
lxc_list_for_each_safe
(
it2
,
&
netdev
->
ipv6
,
next
)
{
lxc_list_del
(
it2
);
free
(
it2
->
elem
);
free
(
it2
);
}
free
(
netdev
);
free
(
it
);
}
/* we get passed in something like '0', '0.ipv4' or '1.ipv6' */
int
lxc_clear_nic
(
struct
lxc_conf
*
c
,
const
char
*
key
)
{
char
*
p1
;
int
ret
,
idx
,
i
;
struct
lxc_list
*
it
;
struct
lxc_netdev
*
netdev
;
p1
=
strchr
(
key
,
'.'
);
if
(
!
p1
||
*
(
p1
+
1
)
==
'\0'
)
p1
=
NULL
;
ret
=
sscanf
(
key
,
"%d"
,
&
idx
);
if
(
ret
!=
1
)
return
-
1
;
if
(
idx
<
0
)
return
-
1
;
i
=
0
;
lxc_list_for_each
(
it
,
&
c
->
network
)
{
if
(
i
==
idx
)
break
;
i
++
;
}
if
(
i
<
idx
)
// we don't have that many nics defined
return
-
1
;
if
(
!
it
||
!
it
->
elem
)
return
-
1
;
netdev
=
it
->
elem
;
if
(
!
p1
)
{
lxc_remove_nic
(
it
);
}
else
if
(
strcmp
(
p1
,
".ipv4"
)
==
0
)
{
struct
lxc_list
*
it2
,
*
next
;
lxc_list_for_each_safe
(
it2
,
&
netdev
->
ipv4
,
next
)
{
lxc_list_del
(
it2
);
free
(
it2
->
elem
);
free
(
it2
);
}
}
else
if
(
strcmp
(
p1
,
".ipv6"
)
==
0
)
{
struct
lxc_list
*
it2
,
*
next
;
lxc_list_for_each_safe
(
it2
,
&
netdev
->
ipv6
,
next
)
{
lxc_list_del
(
it2
);
free
(
it2
->
elem
);
free
(
it2
);
}
}
else
return
-
1
;
return
0
;
}
int
lxc_clear_config_network
(
struct
lxc_conf
*
c
)
{
struct
lxc_list
*
it
,
*
next
;
lxc_list_for_each_safe
(
it
,
&
c
->
network
,
next
)
{
lxc_remove_nic
(
it
);
}
return
0
;
}
int
lxc_clear_config_caps
(
struct
lxc_conf
*
c
)
int
lxc_clear_config_caps
(
struct
lxc_conf
*
c
)
{
{
struct
lxc_list
*
it
,
*
next
;
struct
lxc_list
*
it
,
*
next
;
...
@@ -4596,7 +4504,7 @@ void lxc_conf_free(struct lxc_conf *conf)
...
@@ -4596,7 +4504,7 @@ void lxc_conf_free(struct lxc_conf *conf)
free
(
conf
->
unexpanded_config
);
free
(
conf
->
unexpanded_config
);
free
(
conf
->
pty_names
);
free
(
conf
->
pty_names
);
free
(
conf
->
syslog
);
free
(
conf
->
syslog
);
lxc_
clear_config_network
(
conf
);
lxc_
free_networks
(
conf
);
free
(
conf
->
lsm_aa_profile
);
free
(
conf
->
lsm_aa_profile
);
free
(
conf
->
lsm_se_context
);
free
(
conf
->
lsm_se_context
);
lxc_seccomp_free
(
conf
);
lxc_seccomp_free
(
conf
);
...
...
src/lxc/conf.h
View file @
e5d2fd7c
...
@@ -442,8 +442,6 @@ extern int lxc_find_gateway_addresses(struct lxc_handler *handler);
...
@@ -442,8 +442,6 @@ extern int lxc_find_gateway_addresses(struct lxc_handler *handler);
extern
int
lxc_create_tty
(
const
char
*
name
,
struct
lxc_conf
*
conf
);
extern
int
lxc_create_tty
(
const
char
*
name
,
struct
lxc_conf
*
conf
);
extern
void
lxc_delete_tty
(
struct
lxc_tty_info
*
tty_info
);
extern
void
lxc_delete_tty
(
struct
lxc_tty_info
*
tty_info
);
extern
int
lxc_clear_config_network
(
struct
lxc_conf
*
c
);
extern
int
lxc_clear_nic
(
struct
lxc_conf
*
c
,
const
char
*
key
);
extern
int
lxc_clear_config_caps
(
struct
lxc_conf
*
c
);
extern
int
lxc_clear_config_caps
(
struct
lxc_conf
*
c
);
extern
int
lxc_clear_config_keepcaps
(
struct
lxc_conf
*
c
);
extern
int
lxc_clear_config_keepcaps
(
struct
lxc_conf
*
c
);
extern
int
lxc_clear_cgroups
(
struct
lxc_conf
*
c
,
const
char
*
key
);
extern
int
lxc_clear_cgroups
(
struct
lxc_conf
*
c
,
const
char
*
key
);
...
...
src/lxc/confile.c
View file @
e5d2fd7c
This diff is collapsed.
Click to expand it.
src/lxc/confile_utils.c
View file @
e5d2fd7c
...
@@ -294,9 +294,39 @@ void lxc_log_configured_netdevs(const struct lxc_conf *conf)
...
@@ -294,9 +294,39 @@ void lxc_log_configured_netdevs(const struct lxc_conf *conf)
}
}
}
}
static
void
lxc_free_netdev
(
struct
lxc_netdev
*
netdev
)
{
struct
lxc_list
*
cur
,
*
next
;
free
(
netdev
->
link
);
free
(
netdev
->
name
);
if
(
netdev
->
type
==
LXC_NET_VETH
)
free
(
netdev
->
priv
.
veth_attr
.
pair
);
free
(
netdev
->
upscript
);
free
(
netdev
->
downscript
);
free
(
netdev
->
hwaddr
);
free
(
netdev
->
mtu
);
free
(
netdev
->
ipv4_gateway
);
lxc_list_for_each_safe
(
cur
,
&
netdev
->
ipv4
,
next
)
{
lxc_list_del
(
cur
);
free
(
cur
->
elem
);
free
(
cur
);
}
free
(
netdev
->
ipv6_gateway
);
lxc_list_for_each_safe
(
cur
,
&
netdev
->
ipv6
,
next
)
{
lxc_list_del
(
cur
);
free
(
cur
->
elem
);
free
(
cur
);
}
free
(
netdev
);
}
bool
lxc_remove_nic_by_idx
(
struct
lxc_conf
*
conf
,
unsigned
int
idx
)
bool
lxc_remove_nic_by_idx
(
struct
lxc_conf
*
conf
,
unsigned
int
idx
)
{
{
struct
lxc_list
*
cur
,
*
it
,
*
next
;
struct
lxc_list
*
cur
,
*
next
;
struct
lxc_netdev
*
netdev
;
struct
lxc_netdev
*
netdev
;
bool
found
=
false
;
bool
found
=
false
;
...
@@ -313,27 +343,23 @@ bool lxc_remove_nic_by_idx(struct lxc_conf *conf, unsigned int idx)
...
@@ -313,27 +343,23 @@ bool lxc_remove_nic_by_idx(struct lxc_conf *conf, unsigned int idx)
if
(
!
found
)
if
(
!
found
)
return
false
;
return
false
;
free
(
netdev
->
link
);
lxc_free_netdev
(
netdev
);
free
(
netdev
->
name
);
if
(
netdev
->
type
==
LXC_NET_VETH
)
free
(
netdev
->
priv
.
veth_attr
.
pair
);
free
(
netdev
->
upscript
);
free
(
netdev
->
hwaddr
);
free
(
netdev
->
mtu
);
free
(
netdev
->
ipv4_gateway
);
free
(
netdev
->
ipv6_gateway
);
lxc_list_for_each_safe
(
it
,
&
netdev
->
ipv4
,
next
)
{
lxc_list_del
(
it
);
free
(
it
->
elem
);
free
(
it
);
}
lxc_list_for_each_safe
(
it
,
&
netdev
->
ipv6
,
next
)
{
lxc_list_del
(
it
);
free
(
it
->
elem
);
free
(
it
);
}
free
(
netdev
);
free
(
cur
);
free
(
cur
);
return
true
;
return
true
;
}
}
void
lxc_free_networks
(
struct
lxc_conf
*
conf
)
{
struct
lxc_list
*
cur
,
*
next
;
struct
lxc_netdev
*
netdev
;
lxc_list_for_each_safe
(
cur
,
&
conf
->
network
,
next
)
{
netdev
=
cur
->
elem
;
lxc_free_netdev
(
netdev
);
free
(
cur
);
}
/* prevent segfaults */
lxc_list_init
(
&
conf
->
network
);
}
src/lxc/confile_utils.h
View file @
e5d2fd7c
...
@@ -34,5 +34,6 @@ extern struct lxc_netdev *lxc_get_netdev_by_idx(struct lxc_conf *conf,
...
@@ -34,5 +34,6 @@ extern struct lxc_netdev *lxc_get_netdev_by_idx(struct lxc_conf *conf,
unsigned
int
idx
);
unsigned
int
idx
);
extern
void
lxc_log_configured_netdevs
(
const
struct
lxc_conf
*
conf
);
extern
void
lxc_log_configured_netdevs
(
const
struct
lxc_conf
*
conf
);
extern
bool
lxc_remove_nic_by_idx
(
struct
lxc_conf
*
conf
,
unsigned
int
idx
);
extern
bool
lxc_remove_nic_by_idx
(
struct
lxc_conf
*
conf
,
unsigned
int
idx
);
extern
void
lxc_free_networks
(
struct
lxc_conf
*
conf
);
#endif
/* __LXC_CONFILE_UTILS_H */
#endif
/* __LXC_CONFILE_UTILS_H */
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