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
872e772d
Unverified
Commit
872e772d
authored
Jun 21, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: return negative idx for legacy networks
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
01aebbc3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
confile_network_legacy.c
src/lxc/confile_network_legacy.c
+14
-11
No files found.
src/lxc/confile_network_legacy.c
View file @
872e772d
...
...
@@ -229,13 +229,18 @@ static int get_network_netdev_idx(const char *key)
int
ret
,
idx
;
if
(
*
key
<
'0'
||
*
key
>
'9'
)
return
-
1
;
return
EINVAL
;
ret
=
sscanf
(
key
,
"%d"
,
&
idx
);
if
(
ret
!=
1
)
return
-
1
;
return
EINVAL
;
return
idx
;
/* Since we've implemented the new network parser legacy networks are
* recorded using a negative index starting from -1. To preserve the old
* behavior we need this function to return the appropriate negative
* index.
*/
return
-
(
++
idx
);
}
/*
...
...
@@ -247,21 +252,19 @@ static struct lxc_netdev *get_netdev_from_key(const char *key,
{
int
idx
;
struct
lxc_list
*
it
;
int
i
=
0
;
struct
lxc_netdev
*
netdev
=
NULL
;
idx
=
get_network_netdev_idx
(
key
);
if
(
idx
==
-
1
)
if
(
idx
==
EINVAL
)
return
NULL
;
lxc_list_for_each
(
it
,
network
)
{
if
(
idx
==
i
++
)
{
netdev
=
it
->
elem
;
break
;
}
netdev
=
it
->
elem
;
if
(
idx
==
netdev
->
idx
)
return
netdev
;
}
return
netdev
;
return
NULL
;
}
int
lxc_list_nicconfigs_legacy
(
struct
lxc_conf
*
c
,
const
char
*
key
,
char
*
retv
,
...
...
@@ -323,7 +326,7 @@ static struct lxc_netdev *network_netdev(const char *key, const char *value,
return
NULL
;
}
if
(
get_network_netdev_idx
(
key
+
12
)
==
-
1
)
if
(
get_network_netdev_idx
(
key
+
12
)
==
EINVAL
)
netdev
=
lxc_list_last_elem
(
network
);
else
netdev
=
get_netdev_from_key
(
key
+
12
,
network
);
...
...
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