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
071d0934
Unverified
Commit
071d0934
authored
Feb 26, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: fix coding style in lxc_create_network_unpriv_exec()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
bad2f913
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
11 deletions
+19
-11
network.c
src/lxc/network.c
+19
-11
No files found.
src/lxc/network.c
View file @
071d0934
...
@@ -2861,8 +2861,10 @@ int lxc_find_gateway_addresses(struct lxc_handler *handler)
...
@@ -2861,8 +2861,10 @@ int lxc_find_gateway_addresses(struct lxc_handler *handler)
}
}
#define LXC_USERNIC_PATH LIBEXECDIR "/lxc/lxc-user-nic"
#define LXC_USERNIC_PATH LIBEXECDIR "/lxc/lxc-user-nic"
static
int
lxc_create_network_unpriv_exec
(
const
char
*
lxcpath
,
const
char
*
lxcname
,
static
int
lxc_create_network_unpriv_exec
(
const
char
*
lxcpath
,
struct
lxc_netdev
*
netdev
,
pid_t
pid
,
unsigned
int
hooks_version
)
const
char
*
lxcname
,
struct
lxc_netdev
*
netdev
,
pid_t
pid
,
unsigned
int
hooks_version
)
{
{
int
ret
;
int
ret
;
pid_t
child
;
pid_t
child
;
...
@@ -2873,7 +2875,9 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
...
@@ -2873,7 +2875,9 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
size_t
retlen
;
size_t
retlen
;
if
(
netdev
->
type
!=
LXC_NET_VETH
)
if
(
netdev
->
type
!=
LXC_NET_VETH
)
return
log_error_errno
(
-
1
,
errno
,
"Network type %d not support for unprivileged use"
,
netdev
->
type
);
return
log_error_errno
(
-
1
,
errno
,
"Network type %d not support for unprivileged use"
,
netdev
->
type
);
ret
=
pipe
(
pipefd
);
ret
=
pipe
(
pipefd
);
if
(
ret
<
0
)
if
(
ret
<
0
)
...
@@ -2915,8 +2919,7 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
...
@@ -2915,8 +2919,7 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
pidstr
[
sizeof
(
pidstr
)
-
1
]
=
'\0'
;
pidstr
[
sizeof
(
pidstr
)
-
1
]
=
'\0'
;
INFO
(
"Execing lxc-user-nic create %s %s %s veth %s %s"
,
lxcpath
,
INFO
(
"Execing lxc-user-nic create %s %s %s veth %s %s"
,
lxcpath
,
lxcname
,
pidstr
,
netdev_link
,
lxcname
,
pidstr
,
netdev_link
,
!
is_empty_string
(
netdev
->
name
)
?
netdev
->
name
:
"(null)"
);
!
is_empty_string
(
netdev
->
name
)
?
netdev
->
name
:
"(null)"
);
if
(
!
is_empty_string
(
netdev
->
name
))
if
(
!
is_empty_string
(
netdev
->
name
))
execlp
(
LXC_USERNIC_PATH
,
LXC_USERNIC_PATH
,
"create"
,
execlp
(
LXC_USERNIC_PATH
,
LXC_USERNIC_PATH
,
"create"
,
lxcpath
,
lxcname
,
pidstr
,
"veth"
,
netdev_link
,
lxcpath
,
lxcname
,
pidstr
,
"veth"
,
netdev_link
,
...
@@ -2943,7 +2946,8 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
...
@@ -2943,7 +2946,8 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
ret
=
wait_for_pid
(
child
);
ret
=
wait_for_pid
(
child
);
close
(
pipefd
[
0
]);
close
(
pipefd
[
0
]);
if
(
ret
!=
0
||
bytes
<
0
)
if
(
ret
!=
0
||
bytes
<
0
)
return
log_error
(
-
1
,
"lxc-user-nic failed to configure requested network: %s"
,
buffer
[
0
]
!=
'\0'
?
buffer
:
"(null)"
);
return
log_error
(
-
1
,
"lxc-user-nic failed to configure requested network: %s"
,
buffer
[
0
]
!=
'\0'
?
buffer
:
"(null)"
);
TRACE
(
"Received output
\"
%s
\"
from lxc-user-nic"
,
buffer
);
TRACE
(
"Received output
\"
%s
\"
from lxc-user-nic"
,
buffer
);
/* netdev->name */
/* netdev->name */
...
@@ -2960,7 +2964,8 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
...
@@ -2960,7 +2964,8 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
if
(
retlen
<
IFNAMSIZ
)
if
(
retlen
<
IFNAMSIZ
)
retlen
=
strlcpy
(
netdev
->
created_name
,
token
,
IFNAMSIZ
);
retlen
=
strlcpy
(
netdev
->
created_name
,
token
,
IFNAMSIZ
);
if
(
retlen
>=
IFNAMSIZ
)
if
(
retlen
>=
IFNAMSIZ
)
return
log_error_errno
(
-
1
,
E2BIG
,
"Container side veth device name returned by lxc-user-nic is too long"
);
return
log_error_errno
(
-
1
,
E2BIG
,
"Container side veth device name returned by lxc-user-nic is too long"
);
/* netdev->ifindex */
/* netdev->ifindex */
token
=
strtok_r
(
NULL
,
":"
,
&
saveptr
);
token
=
strtok_r
(
NULL
,
":"
,
&
saveptr
);
...
@@ -2969,7 +2974,8 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
...
@@ -2969,7 +2974,8 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
ret
=
lxc_safe_int
(
token
,
&
netdev
->
ifindex
);
ret
=
lxc_safe_int
(
token
,
&
netdev
->
ifindex
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
log_error_errno
(
-
1
,
-
ret
,
"Failed to convert string
\"
%s
\"
to integer"
,
token
);
return
log_error_errno
(
-
1
,
-
ret
,
"Failed to convert string
\"
%s
\"
to integer"
,
token
);
/* netdev->priv.veth_attr.veth1 */
/* netdev->priv.veth_attr.veth1 */
token
=
strtok_r
(
NULL
,
":"
,
&
saveptr
);
token
=
strtok_r
(
NULL
,
":"
,
&
saveptr
);
...
@@ -2978,7 +2984,8 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
...
@@ -2978,7 +2984,8 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
retlen
=
strlcpy
(
netdev
->
priv
.
veth_attr
.
veth1
,
token
,
IFNAMSIZ
);
retlen
=
strlcpy
(
netdev
->
priv
.
veth_attr
.
veth1
,
token
,
IFNAMSIZ
);
if
(
retlen
>=
IFNAMSIZ
)
if
(
retlen
>=
IFNAMSIZ
)
return
log_error_errno
(
-
1
,
E2BIG
,
"Host side veth device name returned by lxc-user-nic is too long"
);
return
log_error_errno
(
-
1
,
E2BIG
,
"Host side veth device name returned by lxc-user-nic is too long"
);
/* netdev->priv.veth_attr.ifindex */
/* netdev->priv.veth_attr.ifindex */
token
=
strtok_r
(
NULL
,
":"
,
&
saveptr
);
token
=
strtok_r
(
NULL
,
":"
,
&
saveptr
);
...
@@ -2987,7 +2994,8 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
...
@@ -2987,7 +2994,8 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
ret
=
lxc_safe_int
(
token
,
&
netdev
->
priv
.
veth_attr
.
ifindex
);
ret
=
lxc_safe_int
(
token
,
&
netdev
->
priv
.
veth_attr
.
ifindex
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
log_error_errno
(
-
1
,
-
ret
,
"Failed to convert string
\"
%s
\"
to integer"
,
token
);
return
log_error_errno
(
-
1
,
-
ret
,
"Failed to convert string
\"
%s
\"
to integer"
,
token
);
if
(
netdev
->
upscript
)
{
if
(
netdev
->
upscript
)
{
char
*
argv
[]
=
{
char
*
argv
[]
=
{
...
@@ -3001,7 +3009,7 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
...
@@ -3001,7 +3009,7 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
netdev
->
upscript
,
"up"
,
argv
);
netdev
->
upscript
,
"up"
,
argv
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
-
1
;
return
-
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