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
942b2d31
Unverified
Commit
942b2d31
authored
Mar 29, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
confile: clear netdev on network type change
Link:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32584
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
24ca9420
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
10 deletions
+27
-10
confile.c
src/lxc/confile.c
+3
-2
confile_utils.c
src/lxc/confile_utils.c
+23
-8
confile_utils.h
src/lxc/confile_utils.h
+1
-0
No files found.
src/lxc/confile.c
View file @
942b2d31
...
...
@@ -316,8 +316,9 @@ static int set_config_net_type(const char *key, const char *value,
if
(
!
netdev
)
return
ret_errno
(
EINVAL
);
clr_config_net_type
(
key
,
lxc_conf
,
data
);
if
(
lxc_config_value_empty
(
value
))
return
clr_config_net_type
(
key
,
lxc_conf
,
data
)
;
return
0
;
if
(
strequal
(
value
,
"veth"
))
{
netdev
->
type
=
LXC_NET_VETH
;
...
...
@@ -4871,7 +4872,7 @@ static int clr_config_net_type(const char *key, struct lxc_conf *lxc_conf,
if
(
!
netdev
)
return
ret_errno
(
EINVAL
);
netdev
->
type
=
-
1
;
lxc_clear_netdev
(
netdev
)
;
return
0
;
}
...
...
src/lxc/confile_utils.c
View file @
942b2d31
...
...
@@ -403,26 +403,29 @@ void lxc_log_configured_netdevs(const struct lxc_conf *conf)
}
}
static
void
lxc_free
_netdev
(
struct
lxc_netdev
*
netdev
)
void
lxc_clear
_netdev
(
struct
lxc_netdev
*
netdev
)
{
struct
lxc_list
*
cur
,
*
next
;
ssize_t
idx
;
if
(
!
netdev
)
return
;
free
(
netdev
->
upscript
);
free
(
netdev
->
downscript
);
free
(
netdev
->
hwaddr
);
free
(
netdev
->
mtu
);
idx
=
netdev
->
idx
;
free_disarm
(
netdev
->
upscript
);
free_disarm
(
netdev
->
downscript
);
free_disarm
(
netdev
->
hwaddr
);
free_disarm
(
netdev
->
mtu
);
free
(
netdev
->
ipv4_gateway
);
free
_disarm
(
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
);
free
_disarm
(
netdev
->
ipv6_gateway
);
lxc_list_for_each_safe
(
cur
,
&
netdev
->
ipv6
,
next
)
{
lxc_list_del
(
cur
);
free
(
cur
->
elem
);
...
...
@@ -448,7 +451,19 @@ static void lxc_free_netdev(struct lxc_netdev *netdev)
}
}
free
(
netdev
);
memset
(
netdev
,
0
,
sizeof
(
struct
lxc_netdev
));
lxc_list_init
(
&
netdev
->
ipv4
);
lxc_list_init
(
&
netdev
->
ipv6
);
netdev
->
type
=
-
1
;
netdev
->
idx
=
idx
;
}
static
void
lxc_free_netdev
(
struct
lxc_netdev
*
netdev
)
{
if
(
netdev
)
{
lxc_clear_netdev
(
netdev
);
free
(
netdev
);
}
}
bool
lxc_remove_nic_by_idx
(
struct
lxc_conf
*
conf
,
unsigned
int
idx
)
...
...
src/lxc/confile_utils.h
View file @
942b2d31
...
...
@@ -37,6 +37,7 @@ __hidden extern struct lxc_netdev *lxc_get_netdev_by_idx(struct lxc_conf *conf,
__hidden
extern
void
lxc_log_configured_netdevs
(
const
struct
lxc_conf
*
conf
);
__hidden
extern
bool
lxc_remove_nic_by_idx
(
struct
lxc_conf
*
conf
,
unsigned
int
idx
);
__hidden
extern
void
lxc_free_networks
(
struct
lxc_list
*
networks
);
__hidden
extern
void
lxc_clear_netdev
(
struct
lxc_netdev
*
netdev
);
__hidden
extern
int
lxc_veth_mode_to_flag
(
int
*
mode
,
const
char
*
value
);
__hidden
extern
char
*
lxc_veth_flag_to_mode
(
int
mode
);
__hidden
extern
int
lxc_macvlan_mode_to_flag
(
int
*
mode
,
const
char
*
value
);
...
...
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