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
d5aba460
Unverified
Commit
d5aba460
authored
Aug 22, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
confile: non-functional changes
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
71acf5d0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
21 deletions
+25
-21
confile.c
src/lxc/confile.c
+25
-21
No files found.
src/lxc/confile.c
View file @
d5aba460
...
@@ -419,7 +419,7 @@ static int set_config_net_flags(const char *key, const char *value,
...
@@ -419,7 +419,7 @@ static int set_config_net_flags(const char *key, const char *value,
}
}
static
int
create_matched_ifnames
(
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
,
static
int
create_matched_ifnames
(
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
,
struct
lxc_netdev
*
netdev
)
struct
lxc_netdev
*
netdev
)
{
{
struct
ifaddrs
*
ifaddr
,
*
ifa
;
struct
ifaddrs
*
ifaddr
,
*
ifa
;
int
n
;
int
n
;
...
@@ -557,10 +557,9 @@ static int set_config_net_hwaddr(const char *key, const char *value,
...
@@ -557,10 +557,9 @@ static int set_config_net_hwaddr(const char *key, const char *value,
return
-
1
;
return
-
1
;
new_value
=
strdup
(
value
);
new_value
=
strdup
(
value
);
if
(
!
new_value
)
{
if
(
!
new_value
)
SYSERROR
(
"failed to strdup
\"
%s
\"
"
,
value
);
return
-
1
;
return
-
1
;
}
rand_complete_hwaddr
(
new_value
);
rand_complete_hwaddr
(
new_value
);
if
(
lxc_config_value_empty
(
new_value
))
{
if
(
lxc_config_value_empty
(
new_value
))
{
...
@@ -576,6 +575,7 @@ static int set_config_net_hwaddr(const char *key, const char *value,
...
@@ -576,6 +575,7 @@ static int set_config_net_hwaddr(const char *key, const char *value,
static
int
set_config_net_vlan_id
(
const
char
*
key
,
const
char
*
value
,
static
int
set_config_net_vlan_id
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
{
{
int
ret
;
struct
lxc_netdev
*
netdev
;
struct
lxc_netdev
*
netdev
;
if
(
lxc_config_value_empty
(
value
))
if
(
lxc_config_value_empty
(
value
))
...
@@ -588,7 +588,8 @@ static int set_config_net_vlan_id(const char *key, const char *value,
...
@@ -588,7 +588,8 @@ static int set_config_net_vlan_id(const char *key, const char *value,
if
(
!
netdev
)
if
(
!
netdev
)
return
-
1
;
return
-
1
;
if
(
get_u16
(
&
netdev
->
priv
.
vlan_attr
.
vid
,
value
,
0
))
ret
=
get_u16
(
&
netdev
->
priv
.
vlan_attr
.
vid
,
value
,
0
);
if
(
ret
<
0
)
return
-
1
;
return
-
1
;
return
0
;
return
0
;
...
@@ -615,6 +616,7 @@ static int set_config_net_mtu(const char *key, const char *value,
...
@@ -615,6 +616,7 @@ static int set_config_net_mtu(const char *key, const char *value,
static
int
set_config_net_ipv4_address
(
const
char
*
key
,
const
char
*
value
,
static
int
set_config_net_ipv4_address
(
const
char
*
key
,
const
char
*
value
,
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
struct
lxc_conf
*
lxc_conf
,
void
*
data
)
{
{
int
ret
;
struct
lxc_netdev
*
netdev
;
struct
lxc_netdev
*
netdev
;
struct
lxc_inetdev
*
inetdev
;
struct
lxc_inetdev
*
inetdev
;
struct
lxc_list
*
list
;
struct
lxc_list
*
list
;
...
@@ -632,15 +634,13 @@ static int set_config_net_ipv4_address(const char *key, const char *value,
...
@@ -632,15 +634,13 @@ static int set_config_net_ipv4_address(const char *key, const char *value,
return
-
1
;
return
-
1
;
inetdev
=
malloc
(
sizeof
(
*
inetdev
));
inetdev
=
malloc
(
sizeof
(
*
inetdev
));
if
(
!
inetdev
)
{
if
(
!
inetdev
)
SYSERROR
(
"failed to allocate ipv4 address"
);
return
-
1
;
return
-
1
;
}
memset
(
inetdev
,
0
,
sizeof
(
*
inetdev
));
memset
(
inetdev
,
0
,
sizeof
(
*
inetdev
));
list
=
malloc
(
sizeof
(
*
list
));
list
=
malloc
(
sizeof
(
*
list
));
if
(
!
list
)
{
if
(
!
list
)
{
SYSERROR
(
"failed to allocate memory"
);
free
(
inetdev
);
free
(
inetdev
);
return
-
1
;
return
-
1
;
}
}
...
@@ -650,7 +650,6 @@ static int set_config_net_ipv4_address(const char *key, const char *value,
...
@@ -650,7 +650,6 @@ static int set_config_net_ipv4_address(const char *key, const char *value,
addr
=
strdup
(
value
);
addr
=
strdup
(
value
);
if
(
!
addr
)
{
if
(
!
addr
)
{
ERROR
(
"no address specified"
);
free
(
inetdev
);
free
(
inetdev
);
free
(
list
);
free
(
list
);
return
-
1
;
return
-
1
;
...
@@ -668,25 +667,31 @@ static int set_config_net_ipv4_address(const char *key, const char *value,
...
@@ -668,25 +667,31 @@ static int set_config_net_ipv4_address(const char *key, const char *value,
prefix
=
slash
+
1
;
prefix
=
slash
+
1
;
}
}
if
(
!
inet_pton
(
AF_INET
,
addr
,
&
inetdev
->
addr
))
{
ret
=
inet_pton
(
AF_INET
,
addr
,
&
inetdev
->
addr
);
SYSERROR
(
"invalid ipv4 address: %s"
,
value
);
if
(
!
ret
||
ret
<
0
)
{
SYSERROR
(
"Invalid ipv4 address
\"
%s
\"
"
,
value
);
free
(
inetdev
);
free
(
inetdev
);
free
(
addr
);
free
(
addr
);
free
(
list
);
free
(
list
);
return
-
1
;
return
-
1
;
}
}
if
(
bcast
&&
!
inet_pton
(
AF_INET
,
bcast
,
&
inetdev
->
bcast
))
{
if
(
bcast
)
{
SYSERROR
(
"invalid ipv4 broadcast address: %s"
,
value
);
ret
=
inet_pton
(
AF_INET
,
bcast
,
&
inetdev
->
bcast
);
free
(
inetdev
);
if
(
!
ret
||
ret
<
0
)
{
free
(
list
);
SYSERROR
(
"Invalid ipv4 broadcast address
\"
%s
\"
"
,
value
);
free
(
addr
);
free
(
inetdev
);
return
-
1
;
free
(
list
);
free
(
addr
);
return
-
1
;
}
}
}
/* No prefix specified, determine it from the network class. */
/* No prefix specified, determine it from the network class. */
if
(
prefix
)
{
if
(
prefix
)
{
if
(
lxc_safe_uint
(
prefix
,
&
inetdev
->
prefix
)
<
0
)
ret
=
lxc_safe_uint
(
prefix
,
&
inetdev
->
prefix
);
if
(
ret
<
0
)
return
-
1
;
return
-
1
;
}
else
{
}
else
{
inetdev
->
prefix
=
config_ip_prefix
(
&
inetdev
->
addr
);
inetdev
->
prefix
=
config_ip_prefix
(
&
inetdev
->
addr
);
...
@@ -697,8 +702,7 @@ static int set_config_net_ipv4_address(const char *key, const char *value,
...
@@ -697,8 +702,7 @@ static int set_config_net_ipv4_address(const char *key, const char *value,
*/
*/
if
(
!
bcast
)
{
if
(
!
bcast
)
{
inetdev
->
bcast
.
s_addr
=
inetdev
->
addr
.
s_addr
;
inetdev
->
bcast
.
s_addr
=
inetdev
->
addr
.
s_addr
;
inetdev
->
bcast
.
s_addr
|=
inetdev
->
bcast
.
s_addr
|=
htonl
(
INADDR_BROADCAST
>>
inetdev
->
prefix
);
htonl
(
INADDR_BROADCAST
>>
inetdev
->
prefix
);
}
}
lxc_list_add_tail
(
&
netdev
->
ipv4
,
list
);
lxc_list_add_tail
(
&
netdev
->
ipv4
,
list
);
...
...
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