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
ec78a81c
Unverified
Commit
ec78a81c
authored
Mar 04, 2019
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
confile_utils: lxc_config_net_is_hwaddr()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
7e5a72cb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
30 deletions
+30
-30
confile.c
src/lxc/confile.c
+1
-1
confile_utils.c
src/lxc/confile_utils.c
+22
-22
confile_utils.h
src/lxc/confile_utils.h
+1
-1
lxc-test-utils.c
src/tests/lxc-test-utils.c
+6
-6
No files found.
src/lxc/confile.c
View file @
ec78a81c
...
@@ -2812,7 +2812,7 @@ bool network_new_hwaddrs(struct lxc_conf *conf)
...
@@ -2812,7 +2812,7 @@ bool network_new_hwaddrs(struct lxc_conf *conf)
else
else
lend
++
;
lend
++
;
if
(
!
lxc_config_net_hwaddr
(
lstart
))
{
if
(
!
lxc_config_net_
is_
hwaddr
(
lstart
))
{
lstart
=
lend
;
lstart
=
lend
;
continue
;
continue
;
}
}
...
...
src/lxc/confile_utils.c
View file @
ec78a81c
...
@@ -548,6 +548,27 @@ int network_ifname(char *valuep, const char *value, size_t size)
...
@@ -548,6 +548,27 @@ int network_ifname(char *valuep, const char *value, size_t size)
return
0
;
return
0
;
}
}
bool
lxc_config_net_is_hwaddr
(
const
char
*
line
)
{
unsigned
index
;
char
tmp
[
7
];
if
(
strncmp
(
line
,
"lxc.net"
,
7
)
!=
0
)
return
false
;
if
(
strncmp
(
line
,
"lxc.net.hwaddr"
,
14
)
==
0
)
return
true
;
if
(
strncmp
(
line
,
"lxc.network.hwaddr"
,
18
)
==
0
)
return
true
;
if
(
sscanf
(
line
,
"lxc.net.%u.%6s"
,
&
index
,
tmp
)
==
2
||
sscanf
(
line
,
"lxc.network.%u.%6s"
,
&
index
,
tmp
)
==
2
)
return
strncmp
(
tmp
,
"hwaddr"
,
6
)
==
0
;
return
false
;
}
void
rand_complete_hwaddr
(
char
*
hwaddr
)
void
rand_complete_hwaddr
(
char
*
hwaddr
)
{
{
const
char
hex
[]
=
"0123456789abcdef"
;
const
char
hex
[]
=
"0123456789abcdef"
;
...
@@ -580,27 +601,6 @@ void rand_complete_hwaddr(char *hwaddr)
...
@@ -580,27 +601,6 @@ void rand_complete_hwaddr(char *hwaddr)
}
}
}
}
bool
lxc_config_net_hwaddr
(
const
char
*
line
)
{
unsigned
index
;
char
tmp
[
7
];
if
(
strncmp
(
line
,
"lxc.net"
,
7
)
!=
0
)
return
false
;
if
(
strncmp
(
line
,
"lxc.net.hwaddr"
,
14
)
==
0
)
return
true
;
if
(
strncmp
(
line
,
"lxc.network.hwaddr"
,
18
)
==
0
)
return
true
;
if
(
sscanf
(
line
,
"lxc.net.%u.%6s"
,
&
index
,
tmp
)
==
2
||
sscanf
(
line
,
"lxc.network.%u.%6s"
,
&
index
,
tmp
)
==
2
)
return
strncmp
(
tmp
,
"hwaddr"
,
6
)
==
0
;
return
false
;
}
/*
/*
* If we find a lxc.net.[i].hwaddr or lxc.network.hwaddr in the original config
* If we find a lxc.net.[i].hwaddr or lxc.network.hwaddr in the original config
* file, we expand it in the unexpanded_config, so that after a save_config we
* file, we expand it in the unexpanded_config, so that after a save_config we
...
@@ -617,7 +617,7 @@ void update_hwaddr(const char *line)
...
@@ -617,7 +617,7 @@ void update_hwaddr(const char *line)
if
(
line
[
0
]
==
'#'
)
if
(
line
[
0
]
==
'#'
)
return
;
return
;
if
(
!
lxc_config_net_hwaddr
(
line
))
if
(
!
lxc_config_net_
is_
hwaddr
(
line
))
return
;
return
;
/* Let config_net_hwaddr raise the error. */
/* Let config_net_hwaddr raise the error. */
...
...
src/lxc/confile_utils.h
View file @
ec78a81c
...
@@ -66,7 +66,7 @@ extern int set_config_path_item(char **conf_item, const char *value);
...
@@ -66,7 +66,7 @@ extern int set_config_path_item(char **conf_item, const char *value);
extern
int
config_ip_prefix
(
struct
in_addr
*
addr
);
extern
int
config_ip_prefix
(
struct
in_addr
*
addr
);
extern
int
network_ifname
(
char
*
valuep
,
const
char
*
value
,
size_t
size
);
extern
int
network_ifname
(
char
*
valuep
,
const
char
*
value
,
size_t
size
);
extern
void
rand_complete_hwaddr
(
char
*
hwaddr
);
extern
void
rand_complete_hwaddr
(
char
*
hwaddr
);
extern
bool
lxc_config_net_hwaddr
(
const
char
*
line
);
extern
bool
lxc_config_net_
is_
hwaddr
(
const
char
*
line
);
extern
void
update_hwaddr
(
const
char
*
line
);
extern
void
update_hwaddr
(
const
char
*
line
);
extern
bool
new_hwaddr
(
char
*
hwaddr
);
extern
bool
new_hwaddr
(
char
*
hwaddr
);
extern
int
lxc_get_conf_str
(
char
*
retv
,
int
inlen
,
const
char
*
value
);
extern
int
lxc_get_conf_str
(
char
*
retv
,
int
inlen
,
const
char
*
value
);
...
...
src/tests/lxc-test-utils.c
View file @
ec78a81c
...
@@ -518,18 +518,18 @@ void test_parse_byte_size_string(void)
...
@@ -518,18 +518,18 @@ void test_parse_byte_size_string(void)
}
}
}
}
void
test_lxc_config_net_hwaddr
(
void
)
void
test_lxc_config_net_
is_
hwaddr
(
void
)
{
{
if
(
!
lxc_config_net_hwaddr
(
"lxc.net.0.hwaddr = 00:16:3e:04:65:b8
\n
"
))
if
(
!
lxc_config_net_
is_
hwaddr
(
"lxc.net.0.hwaddr = 00:16:3e:04:65:b8
\n
"
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
if
(
lxc_config_net_hwaddr
(
"lxc.net"
))
if
(
lxc_config_net_
is_
hwaddr
(
"lxc.net"
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
if
(
lxc_config_net_hwaddr
(
"lxc.net."
))
if
(
lxc_config_net_
is_
hwaddr
(
"lxc.net."
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
if
(
lxc_config_net_hwaddr
(
"lxc.net.0."
))
if
(
lxc_config_net_
is_
hwaddr
(
"lxc.net.0."
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
...
@@ -604,7 +604,7 @@ int main(int argc, char *argv[])
...
@@ -604,7 +604,7 @@ int main(int argc, char *argv[])
test_lxc_safe_int
();
test_lxc_safe_int
();
test_lxc_safe_long
();
test_lxc_safe_long
();
test_parse_byte_size_string
();
test_parse_byte_size_string
();
test_lxc_config_net_hwaddr
();
test_lxc_config_net_
is_
hwaddr
();
test_task_blocks_signal
();
test_task_blocks_signal
();
exit
(
EXIT_SUCCESS
);
exit
(
EXIT_SUCCESS
);
...
...
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