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
6bed0fb6
Unverified
Commit
6bed0fb6
authored
Jun 16, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: allow to unset by passing empty value
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
cccd2219
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
5 deletions
+47
-5
confile.c
src/lxc/confile.c
+47
-5
No files found.
src/lxc/confile.c
View file @
6bed0fb6
...
@@ -662,11 +662,8 @@ static int set_config_network_type(const char *key, const char *value,
...
@@ -662,11 +662,8 @@ static int set_config_network_type(const char *key, const char *value,
{
{
struct
lxc_netdev
*
netdev
;
struct
lxc_netdev
*
netdev
;
/* If value is empty e.g. "lxc.network.type=", then clear the network
* from the config.
*/
if
(
lxc_config_value_empty
(
value
))
if
(
lxc_config_value_empty
(
value
))
return
lxc_clear_config_network
(
lxc_conf
);
return
clr_config_network_type
(
key
,
lxc_conf
,
data
);
/* lxc.network.* without an index */
/* lxc.network.* without an index */
if
(
!
data
)
if
(
!
data
)
...
@@ -902,6 +899,9 @@ static int set_network_link(const char *key, const char *value,
...
@@ -902,6 +899,9 @@ static int set_network_link(const char *key, const char *value,
{
{
struct
lxc_netdev
*
netdev
;
struct
lxc_netdev
*
netdev
;
if
(
lxc_config_value_empty
(
value
))
return
clr_config_network_flags
(
key
,
lxc_conf
,
data
);
/* lxc.network.* without an index */
/* lxc.network.* without an index */
if
(
!
data
)
if
(
!
data
)
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
...
@@ -963,6 +963,9 @@ static int set_config_network_link(const char *key, const char *value,
...
@@ -963,6 +963,9 @@ static int set_config_network_link(const char *key, const char *value,
struct
lxc_list
*
it
;
struct
lxc_list
*
it
;
int
ret
=
0
;
int
ret
=
0
;
if
(
lxc_config_value_empty
(
value
))
return
clr_config_network_link
(
key
,
lxc_conf
,
data
);
/* lxc.network.* without an index */
/* lxc.network.* without an index */
if
(
!
data
)
if
(
!
data
)
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
...
@@ -995,6 +998,9 @@ static int set_config_network_name(const char *key, const char *value,
...
@@ -995,6 +998,9 @@ static int set_config_network_name(const char *key, const char *value,
{
{
struct
lxc_netdev
*
netdev
;
struct
lxc_netdev
*
netdev
;
if
(
lxc_config_value_empty
(
value
))
return
clr_config_network_script_down
(
key
,
lxc_conf
,
data
);
/* lxc.network.* without an index */
/* lxc.network.* without an index */
if
(
!
data
)
if
(
!
data
)
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
...
@@ -1011,6 +1017,9 @@ static int set_config_network_veth_pair(const char *key, const char *value,
...
@@ -1011,6 +1017,9 @@ static int set_config_network_veth_pair(const char *key, const char *value,
{
{
struct
lxc_netdev
*
netdev
;
struct
lxc_netdev
*
netdev
;
if
(
lxc_config_value_empty
(
value
))
return
clr_config_network_veth_pair
(
key
,
lxc_conf
,
data
);
/* lxc.network.* without an index */
/* lxc.network.* without an index */
if
(
!
data
)
if
(
!
data
)
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
...
@@ -1028,6 +1037,9 @@ static int set_config_network_macvlan_mode(const char *key, const char *value,
...
@@ -1028,6 +1037,9 @@ static int set_config_network_macvlan_mode(const char *key, const char *value,
{
{
struct
lxc_netdev
*
netdev
;
struct
lxc_netdev
*
netdev
;
if
(
lxc_config_value_empty
(
value
))
return
clr_config_network_name
(
key
,
lxc_conf
,
data
);
/* lxc.network.* without an index */
/* lxc.network.* without an index */
if
(
!
data
)
if
(
!
data
)
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
...
@@ -1045,6 +1057,9 @@ static int set_config_network_hwaddr(const char *key, const char *value,
...
@@ -1045,6 +1057,9 @@ static int set_config_network_hwaddr(const char *key, const char *value,
struct
lxc_netdev
*
netdev
;
struct
lxc_netdev
*
netdev
;
char
*
new_value
;
char
*
new_value
;
if
(
lxc_config_value_empty
(
value
))
return
clr_config_network_hwaddr
(
key
,
lxc_conf
,
data
);
new_value
=
strdup
(
value
);
new_value
=
strdup
(
value
);
if
(
!
new_value
)
{
if
(
!
new_value
)
{
SYSERROR
(
"failed to strdup
\"
%s
\"
"
,
value
);
SYSERROR
(
"failed to strdup
\"
%s
\"
"
,
value
);
...
@@ -1077,6 +1092,9 @@ static int set_config_network_vlan_id(const char *key, const char *value,
...
@@ -1077,6 +1092,9 @@ static int set_config_network_vlan_id(const char *key, const char *value,
{
{
struct
lxc_netdev
*
netdev
;
struct
lxc_netdev
*
netdev
;
if
(
lxc_config_value_empty
(
value
))
return
clr_config_network_macvlan_mode
(
key
,
lxc_conf
,
data
);
/* lxc.network.* without an index */
/* lxc.network.* without an index */
if
(
!
data
)
if
(
!
data
)
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
...
@@ -1096,6 +1114,9 @@ static int set_config_network_mtu(const char *key, const char *value,
...
@@ -1096,6 +1114,9 @@ static int set_config_network_mtu(const char *key, const char *value,
{
{
struct
lxc_netdev
*
netdev
;
struct
lxc_netdev
*
netdev
;
if
(
lxc_config_value_empty
(
value
))
return
clr_config_network_vlan_id
(
key
,
lxc_conf
,
data
);
/* lxc.network.* without an index */
/* lxc.network.* without an index */
if
(
!
data
)
if
(
!
data
)
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
...
@@ -1117,7 +1138,7 @@ static int set_config_network_ipv4(const char *key, const char *value,
...
@@ -1117,7 +1138,7 @@ static int set_config_network_ipv4(const char *key, const char *value,
char
*
addr
=
NULL
,
*
bcast
=
NULL
,
*
prefix
=
NULL
;
char
*
addr
=
NULL
,
*
bcast
=
NULL
,
*
prefix
=
NULL
;
if
(
lxc_config_value_empty
(
value
))
if
(
lxc_config_value_empty
(
value
))
return
clr_config_network_ipv4
(
key
,
lxc_conf
,
NULL
);
return
clr_config_network_ipv4
(
key
,
lxc_conf
,
data
);
/* lxc.network.* without an index */
/* lxc.network.* without an index */
if
(
!
data
)
if
(
!
data
)
...
@@ -1209,6 +1230,9 @@ static int set_config_network_ipv4_gateway(const char *key, const char *value,
...
@@ -1209,6 +1230,9 @@ static int set_config_network_ipv4_gateway(const char *key, const char *value,
{
{
struct
lxc_netdev
*
netdev
;
struct
lxc_netdev
*
netdev
;
if
(
lxc_config_value_empty
(
value
))
return
clr_config_network_mtu
(
key
,
lxc_conf
,
data
);
/* lxc.network.* without an index */
/* lxc.network.* without an index */
if
(
!
data
)
if
(
!
data
)
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
...
@@ -1254,6 +1278,9 @@ static int set_config_network_ipv6(const char *key, const char *value,
...
@@ -1254,6 +1278,9 @@ static int set_config_network_ipv6(const char *key, const char *value,
struct
lxc_list
*
list
;
struct
lxc_list
*
list
;
char
*
slash
,
*
valdup
,
*
netmask
;
char
*
slash
,
*
valdup
,
*
netmask
;
if
(
lxc_config_value_empty
(
value
))
return
clr_config_network_ipv6
(
key
,
lxc_conf
,
data
);
/* lxc.network.* without an index */
/* lxc.network.* without an index */
if
(
!
data
)
if
(
!
data
)
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
...
@@ -1316,6 +1343,9 @@ static int set_config_network_ipv6_gateway(const char *key, const char *value,
...
@@ -1316,6 +1343,9 @@ static int set_config_network_ipv6_gateway(const char *key, const char *value,
{
{
struct
lxc_netdev
*
netdev
;
struct
lxc_netdev
*
netdev
;
if
(
lxc_config_value_empty
(
value
))
return
clr_config_network_ipv4_gateway
(
key
,
lxc_conf
,
data
);
/* lxc.network.* without an index */
/* lxc.network.* without an index */
if
(
!
data
)
if
(
!
data
)
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
...
@@ -1358,6 +1388,9 @@ static int set_config_network_script_up(const char *key, const char *value,
...
@@ -1358,6 +1388,9 @@ static int set_config_network_script_up(const char *key, const char *value,
{
{
struct
lxc_netdev
*
netdev
;
struct
lxc_netdev
*
netdev
;
if
(
lxc_config_value_empty
(
value
))
return
clr_config_network_ipv6_gateway
(
key
,
lxc_conf
,
data
);
/* lxc.network.* without an index */
/* lxc.network.* without an index */
if
(
!
data
)
if
(
!
data
)
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
...
@@ -1374,6 +1407,9 @@ static int set_config_network_script_down(const char *key, const char *value,
...
@@ -1374,6 +1407,9 @@ static int set_config_network_script_down(const char *key, const char *value,
{
{
struct
lxc_netdev
*
netdev
;
struct
lxc_netdev
*
netdev
;
if
(
lxc_config_value_empty
(
value
))
return
clr_config_network_script_up
(
key
,
lxc_conf
,
data
);
/* lxc.network.* without an index */
/* lxc.network.* without an index */
if
(
!
data
)
if
(
!
data
)
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
netdev
=
lxc_get_netdev_by_idx
(
lxc_conf
,
0
);
...
@@ -4367,6 +4403,9 @@ static int set_config_network_nic(const char *key, const char *value,
...
@@ -4367,6 +4403,9 @@ static int set_config_network_nic(const char *key, const char *value,
struct
lxc_netdev
*
netdev
;
struct
lxc_netdev
*
netdev
;
ssize_t
idx
=
-
1
;
ssize_t
idx
=
-
1
;
if
(
lxc_config_value_empty
(
value
))
return
clr_config_network_nic
(
key
,
lxc_conf
,
data
);
config
=
get_network_config_ops
(
key
,
lxc_conf
,
&
idx
);
config
=
get_network_config_ops
(
key
,
lxc_conf
,
&
idx
);
if
(
!
config
||
idx
<
0
)
if
(
!
config
||
idx
<
0
)
return
-
1
;
return
-
1
;
...
@@ -4512,6 +4551,9 @@ static int clr_config_network_macvlan_mode(const char *key,
...
@@ -4512,6 +4551,9 @@ static int clr_config_network_macvlan_mode(const char *key,
if
(
!
netdev
)
if
(
!
netdev
)
return
-
1
;
return
-
1
;
if
(
netdev
->
type
!=
LXC_NET_MACVLAN
)
return
0
;
netdev
->
priv
.
macvlan_attr
.
mode
=
-
1
;
netdev
->
priv
.
macvlan_attr
.
mode
=
-
1
;
return
0
;
return
0
;
...
...
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