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
af24b9e5
Unverified
Commit
af24b9e5
authored
Mar 19, 2020
by
Stéphane Graber
Committed by
GitHub
Mar 19, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3307 from brauner/2020-03-19/fixes
network: fixes
parents
74d40612
f7591785
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
22 deletions
+20
-22
conf.c
src/lxc/conf.c
+3
-6
network.c
src/lxc/network.c
+12
-16
string_utils.h
src/lxc/string_utils.h
+5
-0
No files found.
src/lxc/conf.c
View file @
af24b9e5
...
@@ -1847,17 +1847,15 @@ static int mount_entry(const char *fsname, const char *target,
...
@@ -1847,17 +1847,15 @@ static int mount_entry(const char *fsname, const char *target,
}
}
if
((
mountflags
&
MS_REMOUNT
)
||
(
mountflags
&
MS_BIND
))
{
if
((
mountflags
&
MS_REMOUNT
)
||
(
mountflags
&
MS_BIND
))
{
unsigned
long
r
q
d_flags
=
0
;
unsigned
long
r
equire
d_flags
=
0
;
DEBUG
(
"Remounting
\"
%s
\"
on
\"
%s
\"
to respect bind or remount options"
,
DEBUG
(
"Remounting
\"
%s
\"
on
\"
%s
\"
to respect bind or remount options"
,
srcpath
?
srcpath
:
"(none)"
,
target
?
target
:
"(none)"
);
srcpath
?
srcpath
:
"(none)"
,
target
?
target
:
"(none)"
);
if
(
mountflags
&
MS_RDONLY
)
if
(
mountflags
&
MS_RDONLY
)
r
q
d_flags
|=
MS_RDONLY
;
r
equire
d_flags
|=
MS_RDONLY
;
#ifdef HAVE_STATVFS
#ifdef HAVE_STATVFS
if
(
srcpath
&&
statvfs
(
srcpath
,
&
sb
)
==
0
)
{
if
(
srcpath
&&
statvfs
(
srcpath
,
&
sb
)
==
0
)
{
unsigned
long
required_flags
=
rqd_flags
;
if
(
sb
.
f_flag
&
MS_NOSUID
)
if
(
sb
.
f_flag
&
MS_NOSUID
)
required_flags
|=
MS_NOSUID
;
required_flags
|=
MS_NOSUID
;
...
@@ -1878,8 +1876,7 @@ static int mount_entry(const char *fsname, const char *target,
...
@@ -1878,8 +1876,7 @@ static int mount_entry(const char *fsname, const char *target,
* mountflags, then skip the remount.
* mountflags, then skip the remount.
*/
*/
if
(
!
(
mountflags
&
MS_REMOUNT
))
{
if
(
!
(
mountflags
&
MS_REMOUNT
))
{
if
(
!
(
required_flags
&
~
mountflags
)
&&
if
(
!
(
required_flags
&
~
mountflags
))
{
rqd_flags
==
0
)
{
DEBUG
(
"Mountflags already were %lu, skipping remount"
,
mountflags
);
DEBUG
(
"Mountflags already were %lu, skipping remount"
,
mountflags
);
goto
skipremount
;
goto
skipremount
;
}
}
...
...
src/lxc/network.c
View file @
af24b9e5
...
@@ -504,7 +504,7 @@ static int instantiate_macvlan(struct lxc_handler *handler, struct lxc_netdev *n
...
@@ -504,7 +504,7 @@ static int instantiate_macvlan(struct lxc_handler *handler, struct lxc_netdev *n
}
}
strlcpy
(
netdev
->
created_name
,
peer
,
IFNAMSIZ
);
strlcpy
(
netdev
->
created_name
,
peer
,
IFNAMSIZ
);
if
(
netdev
->
name
[
0
]
==
'\0'
)
if
(
is_empty_string
(
netdev
->
name
)
)
(
void
)
strlcpy
(
netdev
->
name
,
peer
,
IFNAMSIZ
);
(
void
)
strlcpy
(
netdev
->
name
,
peer
,
IFNAMSIZ
);
netdev
->
ifindex
=
if_nametoindex
(
peer
);
netdev
->
ifindex
=
if_nametoindex
(
peer
);
...
@@ -668,7 +668,7 @@ static int instantiate_ipvlan(struct lxc_handler *handler, struct lxc_netdev *ne
...
@@ -668,7 +668,7 @@ static int instantiate_ipvlan(struct lxc_handler *handler, struct lxc_netdev *ne
}
}
strlcpy
(
netdev
->
created_name
,
peer
,
IFNAMSIZ
);
strlcpy
(
netdev
->
created_name
,
peer
,
IFNAMSIZ
);
if
(
netdev
->
name
[
0
]
==
'\0'
)
if
(
is_empty_string
(
netdev
->
name
)
)
(
void
)
strlcpy
(
netdev
->
name
,
peer
,
IFNAMSIZ
);
(
void
)
strlcpy
(
netdev
->
name
,
peer
,
IFNAMSIZ
);
netdev
->
ifindex
=
if_nametoindex
(
peer
);
netdev
->
ifindex
=
if_nametoindex
(
peer
);
...
@@ -743,7 +743,7 @@ static int instantiate_vlan(struct lxc_handler *handler, struct lxc_netdev *netd
...
@@ -743,7 +743,7 @@ static int instantiate_vlan(struct lxc_handler *handler, struct lxc_netdev *netd
}
}
strlcpy
(
netdev
->
created_name
,
peer
,
IFNAMSIZ
);
strlcpy
(
netdev
->
created_name
,
peer
,
IFNAMSIZ
);
if
(
netdev
->
name
[
0
]
==
'\0'
)
if
(
is_empty_string
(
netdev
->
name
)
)
(
void
)
strlcpy
(
netdev
->
name
,
peer
,
IFNAMSIZ
);
(
void
)
strlcpy
(
netdev
->
name
,
peer
,
IFNAMSIZ
);
netdev
->
ifindex
=
if_nametoindex
(
peer
);
netdev
->
ifindex
=
if_nametoindex
(
peer
);
...
@@ -818,7 +818,7 @@ static int instantiate_phys(struct lxc_handler *handler, struct lxc_netdev *netd
...
@@ -818,7 +818,7 @@ static int instantiate_phys(struct lxc_handler *handler, struct lxc_netdev *netd
}
}
strlcpy
(
netdev
->
created_name
,
netdev
->
link
,
IFNAMSIZ
);
strlcpy
(
netdev
->
created_name
,
netdev
->
link
,
IFNAMSIZ
);
if
(
netdev
->
name
[
0
]
==
'\0'
)
if
(
is_empty_string
(
netdev
->
name
)
)
(
void
)
strlcpy
(
netdev
->
name
,
netdev
->
link
,
IFNAMSIZ
);
(
void
)
strlcpy
(
netdev
->
name
,
netdev
->
link
,
IFNAMSIZ
);
/*
/*
...
@@ -924,7 +924,7 @@ static int instantiate_ns_veth(struct lxc_netdev *netdev)
...
@@ -924,7 +924,7 @@ static int instantiate_ns_veth(struct lxc_netdev *netdev)
errno
,
"Failed to retrieve ifindex for network device with name %s"
,
errno
,
"Failed to retrieve ifindex for network device with name %s"
,
netdev
->
created_name
);
netdev
->
created_name
);
if
(
netdev
->
name
[
0
]
==
'\0'
)
if
(
is_empty_string
(
netdev
->
name
)
)
(
void
)
strlcpy
(
netdev
->
name
,
"eth%d"
,
IFNAMSIZ
);
(
void
)
strlcpy
(
netdev
->
name
,
"eth%d"
,
IFNAMSIZ
);
if
(
strcmp
(
netdev
->
created_name
,
netdev
->
name
)
!=
0
)
{
if
(
strcmp
(
netdev
->
created_name
,
netdev
->
name
)
!=
0
)
{
...
@@ -1179,10 +1179,8 @@ static int lxc_netdev_move_by_index_fd(int ifindex, int fd, const char *ifname)
...
@@ -1179,10 +1179,8 @@ static int lxc_netdev_move_by_index_fd(int ifindex, int fd, const char *ifname)
if
(
nla_put_u32
(
nlmsg
,
IFLA_NET_NS_FD
,
fd
))
if
(
nla_put_u32
(
nlmsg
,
IFLA_NET_NS_FD
,
fd
))
goto
out
;
goto
out
;
if
(
ifname
!=
NULL
)
{
if
(
!
is_empty_string
(
ifname
)
&&
nla_put_string
(
nlmsg
,
IFLA_IFNAME
,
ifname
))
if
(
nla_put_string
(
nlmsg
,
IFLA_IFNAME
,
ifname
))
goto
out
;
goto
out
;
}
err
=
netlink_transaction
(
&
nlh
,
nlmsg
,
nlmsg
);
err
=
netlink_transaction
(
&
nlh
,
nlmsg
,
nlmsg
);
out:
out:
...
@@ -1219,10 +1217,8 @@ int lxc_netdev_move_by_index(int ifindex, pid_t pid, const char *ifname)
...
@@ -1219,10 +1217,8 @@ int lxc_netdev_move_by_index(int ifindex, pid_t pid, const char *ifname)
if
(
nla_put_u32
(
nlmsg
,
IFLA_NET_NS_PID
,
pid
))
if
(
nla_put_u32
(
nlmsg
,
IFLA_NET_NS_PID
,
pid
))
goto
out
;
goto
out
;
if
(
ifname
!=
NULL
)
{
if
(
!
is_empty_string
(
ifname
)
&&
nla_put_string
(
nlmsg
,
IFLA_IFNAME
,
ifname
))
if
(
nla_put_string
(
nlmsg
,
IFLA_IFNAME
,
ifname
))
goto
out
;
goto
out
;
}
err
=
netlink_transaction
(
&
nlh
,
nlmsg
,
nlmsg
);
err
=
netlink_transaction
(
&
nlh
,
nlmsg
,
nlmsg
);
out:
out:
...
@@ -2812,8 +2808,8 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
...
@@ -2812,8 +2808,8 @@ static int lxc_create_network_unpriv_exec(const char *lxcpath, const char *lxcna
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
,
netdev
->
name
[
0
]
!=
'\0'
?
netdev
->
name
:
"(null)"
);
!
is_empty_string
(
netdev
->
name
)
?
netdev
->
name
:
"(null)"
);
if
(
netdev
->
name
[
0
]
!=
'\0'
)
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
,
netdev
->
name
,
(
char
*
)
NULL
);
netdev
->
name
,
(
char
*
)
NULL
);
...
@@ -3363,7 +3359,7 @@ int lxc_network_move_created_netdev_priv(struct lxc_handler *handler)
...
@@ -3363,7 +3359,7 @@ int lxc_network_move_created_netdev_priv(struct lxc_handler *handler)
physname
=
is_wlan
(
netdev
->
link
);
physname
=
is_wlan
(
netdev
->
link
);
if
(
physname
)
if
(
physname
)
ret
=
lxc_netdev_move_wlan
(
physname
,
netdev
->
link
,
pid
,
NULL
);
ret
=
lxc_netdev_move_wlan
(
physname
,
netdev
->
link
,
pid
,
netdev
->
name
);
else
else
ret
=
lxc_netdev_move_by_index
(
netdev
->
ifindex
,
pid
,
netdev
->
name
);
ret
=
lxc_netdev_move_by_index
(
netdev
->
ifindex
,
pid
,
netdev
->
name
);
if
(
ret
)
{
if
(
ret
)
{
...
...
src/lxc/string_utils.h
View file @
af24b9e5
...
@@ -98,4 +98,9 @@ extern char *lxc_trim_whitespace_in_place(char *buffer);
...
@@ -98,4 +98,9 @@ extern char *lxc_trim_whitespace_in_place(char *buffer);
extern
int
lxc_is_line_empty
(
const
char
*
line
);
extern
int
lxc_is_line_empty
(
const
char
*
line
);
extern
void
remove_trailing_slashes
(
char
*
p
);
extern
void
remove_trailing_slashes
(
char
*
p
);
static
inline
bool
is_empty_string
(
const
char
*
s
)
{
return
!
s
||
strcmp
(
s
,
""
)
==
0
;
}
#endif
/* __LXC_STRING_UTILS_H */
#endif
/* __LXC_STRING_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