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
0070b1c4
Unverified
Commit
0070b1c4
authored
Jun 16, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: switch to single find + allocation fun
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
ecbb3790
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
32 deletions
+17
-32
confile.c
src/lxc/confile.c
+0
-0
confile_utils.c
src/lxc/confile_utils.c
+15
-28
confile_utils.h
src/lxc/confile_utils.h
+2
-4
No files found.
src/lxc/confile.c
View file @
0070b1c4
This diff is collapsed.
Click to expand it.
src/lxc/confile_utils.c
View file @
0070b1c4
...
@@ -166,35 +166,11 @@ bool lxc_config_value_empty(const char *value)
...
@@ -166,35 +166,11 @@ bool lxc_config_value_empty(const char *value)
return
true
;
return
true
;
}
}
struct
lxc_netdev
*
lxc_find_netdev_by_idx
(
struct
lxc_conf
*
conf
,
unsigned
int
idx
)
{
struct
lxc_netdev
*
netdev
=
NULL
;
struct
lxc_list
*
networks
=
&
conf
->
network
;
struct
lxc_list
*
insert
=
networks
;
/* lookup network */
if
(
lxc_list_empty
(
networks
))
return
NULL
;
lxc_list_for_each
(
insert
,
networks
)
{
netdev
=
insert
->
elem
;
if
(
netdev
->
idx
>=
idx
)
break
;
}
/* network already exists */
if
(
netdev
->
idx
==
idx
)
return
netdev
;
return
NULL
;
}
/* Takes care of finding the correct netdev struct in the networks list or
/* Takes care of finding the correct netdev struct in the networks list or
* allocates a new one if it couldn't be found.
* allocates a new one if it couldn't be found.
*/
*/
struct
lxc_netdev
*
lxc_get_netdev_by_idx
(
struct
lxc_conf
*
conf
,
struct
lxc_netdev
*
lxc_get_netdev_by_idx
(
struct
lxc_conf
*
conf
,
unsigned
int
idx
)
unsigned
int
idx
,
bool
allocate
)
{
{
struct
lxc_list
*
newlist
;
struct
lxc_list
*
newlist
;
struct
lxc_netdev
*
netdev
=
NULL
;
struct
lxc_netdev
*
netdev
=
NULL
;
...
@@ -202,9 +178,20 @@ struct lxc_netdev *lxc_get_netdev_by_idx(struct lxc_conf *conf,
...
@@ -202,9 +178,20 @@ struct lxc_netdev *lxc_get_netdev_by_idx(struct lxc_conf *conf,
struct
lxc_list
*
insert
=
networks
;
struct
lxc_list
*
insert
=
networks
;
/* lookup network */
/* lookup network */
netdev
=
lxc_find_netdev_by_idx
(
conf
,
idx
);
if
(
!
lxc_list_empty
(
networks
))
{
if
(
netdev
)
lxc_list_for_each
(
insert
,
networks
)
{
return
netdev
;
netdev
=
insert
->
elem
;
if
(
netdev
->
idx
>=
idx
)
break
;
}
/* network already exists */
if
(
netdev
->
idx
==
idx
)
return
netdev
;
}
if
(
!
allocate
)
return
NULL
;
/* network does not exist */
/* network does not exist */
netdev
=
malloc
(
sizeof
(
*
netdev
));
netdev
=
malloc
(
sizeof
(
*
netdev
));
...
...
src/lxc/confile_utils.h
View file @
0070b1c4
...
@@ -28,10 +28,8 @@ extern int parse_idmaps(const char *idmap, char *type, unsigned long *nsid,
...
@@ -28,10 +28,8 @@ extern int parse_idmaps(const char *idmap, char *type, unsigned long *nsid,
unsigned
long
*
hostid
,
unsigned
long
*
range
);
unsigned
long
*
hostid
,
unsigned
long
*
range
);
extern
bool
lxc_config_value_empty
(
const
char
*
value
);
extern
bool
lxc_config_value_empty
(
const
char
*
value
);
extern
struct
lxc_netdev
*
lxc_find_netdev_by_idx
(
struct
lxc_conf
*
conf
,
extern
struct
lxc_netdev
*
unsigned
int
idx
);
lxc_get_netdev_by_idx
(
struct
lxc_conf
*
conf
,
unsigned
int
idx
,
bool
allocate
);
extern
struct
lxc_netdev
*
lxc_get_netdev_by_idx
(
struct
lxc_conf
*
conf
,
unsigned
int
idx
);
extern
void
lxc_log_configured_netdevs
(
const
struct
lxc_conf
*
conf
);
extern
void
lxc_log_configured_netdevs
(
const
struct
lxc_conf
*
conf
);
extern
bool
lxc_remove_nic_by_idx
(
struct
lxc_conf
*
conf
,
unsigned
int
idx
);
extern
bool
lxc_remove_nic_by_idx
(
struct
lxc_conf
*
conf
,
unsigned
int
idx
);
extern
void
lxc_free_networks
(
struct
lxc_conf
*
conf
);
extern
void
lxc_free_networks
(
struct
lxc_conf
*
conf
);
...
...
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