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
3646ffd9
Unverified
Commit
3646ffd9
authored
Mar 21, 2020
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: introduce lxc_ifname_alnum_case_sensitive()
Right now we have 36^n unique network device names. Let's make it 62^n. Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
0c241537
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
11 deletions
+13
-11
lxc_user_nic.c
src/lxc/cmd/lxc_user_nic.c
+1
-1
criu.c
src/lxc/criu.c
+1
-1
network.c
src/lxc/network.c
+6
-6
network.h
src/lxc/network.h
+5
-3
No files found.
src/lxc/cmd/lxc_user_nic.c
View file @
3646ffd9
...
@@ -735,7 +735,7 @@ static char *get_nic_if_avail(int fd, struct alloted_s *names, int pid,
...
@@ -735,7 +735,7 @@ static char *get_nic_if_avail(int fd, struct alloted_s *names, int pid,
if
(
ret
<
0
||
(
size_t
)
ret
>=
sizeof
(
nicname
))
if
(
ret
<
0
||
(
size_t
)
ret
>=
sizeof
(
nicname
))
return
NULL
;
return
NULL
;
if
(
!
lxc_
mkifnam
e
(
nicname
))
if
(
!
lxc_
ifname_alnum_case_sensitiv
e
(
nicname
))
return
NULL
;
return
NULL
;
ret
=
create_nic
(
nicname
,
br
,
pid
,
cnic
);
ret
=
create_nic
(
nicname
,
br
,
pid
,
cnic
);
...
...
src/lxc/criu.c
View file @
3646ffd9
...
@@ -903,7 +903,7 @@ static bool restore_net_info(struct lxc_container *c)
...
@@ -903,7 +903,7 @@ static bool restore_net_info(struct lxc_container *c)
if
(
netdev
->
priv
.
veth_attr
.
pair
[
0
]
==
'\0'
&&
if
(
netdev
->
priv
.
veth_attr
.
pair
[
0
]
==
'\0'
&&
netdev
->
priv
.
veth_attr
.
veth1
[
0
]
==
'\0'
)
{
netdev
->
priv
.
veth_attr
.
veth1
[
0
]
==
'\0'
)
{
if
(
!
lxc_
mkifnam
e
(
template
))
if
(
!
lxc_
ifname_alnum_case_sensitiv
e
(
template
))
goto
out_unlock
;
goto
out_unlock
;
(
void
)
strlcpy
(
netdev
->
priv
.
veth_attr
.
veth1
,
template
,
IFNAMSIZ
);
(
void
)
strlcpy
(
netdev
->
priv
.
veth_attr
.
veth1
,
template
,
IFNAMSIZ
);
...
...
src/lxc/network.c
View file @
3646ffd9
...
@@ -261,7 +261,7 @@ static int instantiate_veth(struct lxc_handler *handler, struct lxc_netdev *netd
...
@@ -261,7 +261,7 @@ static int instantiate_veth(struct lxc_handler *handler, struct lxc_netdev *netd
if
(
err
<
0
||
(
size_t
)
err
>=
sizeof
(
veth1buf
))
if
(
err
<
0
||
(
size_t
)
err
>=
sizeof
(
veth1buf
))
return
-
1
;
return
-
1
;
veth1
=
lxc_
mkifnam
e
(
veth1buf
);
veth1
=
lxc_
ifname_alnum_case_sensitiv
e
(
veth1buf
);
if
(
!
veth1
)
if
(
!
veth1
)
return
-
1
;
return
-
1
;
...
@@ -273,7 +273,7 @@ static int instantiate_veth(struct lxc_handler *handler, struct lxc_netdev *netd
...
@@ -273,7 +273,7 @@ static int instantiate_veth(struct lxc_handler *handler, struct lxc_netdev *netd
if
(
err
<
0
||
(
size_t
)
err
>=
sizeof
(
veth2buf
))
if
(
err
<
0
||
(
size_t
)
err
>=
sizeof
(
veth2buf
))
return
-
1
;
return
-
1
;
veth2
=
lxc_
mkifnam
e
(
veth2buf
);
veth2
=
lxc_
ifname_alnum_case_sensitiv
e
(
veth2buf
);
if
(
!
veth2
)
if
(
!
veth2
)
return
-
1
;
return
-
1
;
...
@@ -470,7 +470,7 @@ static int instantiate_macvlan(struct lxc_handler *handler, struct lxc_netdev *n
...
@@ -470,7 +470,7 @@ static int instantiate_macvlan(struct lxc_handler *handler, struct lxc_netdev *n
if
(
err
<
0
||
(
size_t
)
err
>=
sizeof
(
peer
))
if
(
err
<
0
||
(
size_t
)
err
>=
sizeof
(
peer
))
return
-
1
;
return
-
1
;
if
(
!
lxc_
mkifnam
e
(
peer
))
if
(
!
lxc_
ifname_alnum_case_sensitiv
e
(
peer
))
return
-
1
;
return
-
1
;
err
=
lxc_macvlan_create
(
netdev
->
link
,
peer
,
err
=
lxc_macvlan_create
(
netdev
->
link
,
peer
,
...
@@ -625,7 +625,7 @@ static int instantiate_ipvlan(struct lxc_handler *handler, struct lxc_netdev *ne
...
@@ -625,7 +625,7 @@ static int instantiate_ipvlan(struct lxc_handler *handler, struct lxc_netdev *ne
if
(
err
<
0
||
(
size_t
)
err
>=
sizeof
(
peer
))
if
(
err
<
0
||
(
size_t
)
err
>=
sizeof
(
peer
))
return
-
1
;
return
-
1
;
if
(
!
lxc_
mkifnam
e
(
peer
))
if
(
!
lxc_
ifname_alnum_case_sensitiv
e
(
peer
))
return
-
1
;
return
-
1
;
err
=
lxc_ipvlan_create
(
netdev
->
link
,
peer
,
netdev
->
priv
.
ipvlan_attr
.
mode
,
err
=
lxc_ipvlan_create
(
netdev
->
link
,
peer
,
netdev
->
priv
.
ipvlan_attr
.
mode
,
...
@@ -2446,9 +2446,9 @@ const char *lxc_net_type_to_str(int type)
...
@@ -2446,9 +2446,9 @@ const char *lxc_net_type_to_str(int type)
return
lxc_network_types
[
type
];
return
lxc_network_types
[
type
];
}
}
static
const
char
padchar
[]
=
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
static
const
char
padchar
[]
=
"0123456789
abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
char
*
lxc_
mkifnam
e
(
char
*
template
)
char
*
lxc_
ifname_alnum_case_sensitiv
e
(
char
*
template
)
{
{
int
ret
;
int
ret
;
struct
netns_ifaddrs
*
ifa
,
*
ifaddr
;
struct
netns_ifaddrs
*
ifa
,
*
ifaddr
;
...
...
src/lxc/network.h
View file @
3646ffd9
...
@@ -251,10 +251,12 @@ extern int lxc_ip_forwarding_on(const char *name, int family);
...
@@ -251,10 +251,12 @@ extern int lxc_ip_forwarding_on(const char *name, int family);
/* Disable IP forwarding. */
/* Disable IP forwarding. */
extern
int
lxc_ip_forwarding_off
(
const
char
*
name
,
int
family
);
extern
int
lxc_ip_forwarding_off
(
const
char
*
name
,
int
family
);
/* Generate a new unique network interface name.
/*
* Allocated memory must be freed by caller.
* Generate a new unique network interface name.
*
* Allows for 62^n unique combinations.
*/
*/
extern
char
*
lxc_
mkifnam
e
(
char
*
template
);
extern
char
*
lxc_
ifname_alnum_case_sensitiv
e
(
char
*
template
);
extern
const
char
*
lxc_net_type_to_str
(
int
type
);
extern
const
char
*
lxc_net_type_to_str
(
int
type
);
extern
int
setup_private_host_hw_addr
(
char
*
veth1
);
extern
int
setup_private_host_hw_addr
(
char
*
veth1
);
...
...
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