1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-08 21:17:47 +03:00

network: neighbor: accept an empty string assignment

This commit is contained in:
Yu Watanabe 2021-11-11 09:24:56 +09:00
parent 17193d767d
commit 13b7b8bd73

View File

@ -611,20 +611,27 @@ int config_parse_neighbor_address(
void *data, void *data,
void *userdata) { void *userdata) {
Network *network = userdata;
_cleanup_(neighbor_free_or_set_invalidp) Neighbor *n = NULL; _cleanup_(neighbor_free_or_set_invalidp) Neighbor *n = NULL;
Network *network = userdata;
int r; int r;
assert(filename); assert(filename);
assert(section); assert(section);
assert(lvalue); assert(lvalue);
assert(rvalue); assert(rvalue);
assert(data); assert(userdata);
r = neighbor_new_static(network, filename, section_line, &n); r = neighbor_new_static(network, filename, section_line, &n);
if (r < 0) if (r < 0)
return log_oom(); return log_oom();
if (isempty(rvalue)) {
n->family = AF_UNSPEC;
n->in_addr = IN_ADDR_NULL;
TAKE_PTR(n);
return 0;
}
r = in_addr_from_string_auto(rvalue, &n->family, &n->in_addr); r = in_addr_from_string_auto(rvalue, &n->family, &n->in_addr);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
@ -633,7 +640,6 @@ int config_parse_neighbor_address(
} }
TAKE_PTR(n); TAKE_PTR(n);
return 0; return 0;
} }
@ -649,20 +655,26 @@ int config_parse_neighbor_lladdr(
void *data, void *data,
void *userdata) { void *userdata) {
Network *network = userdata;
_cleanup_(neighbor_free_or_set_invalidp) Neighbor *n = NULL; _cleanup_(neighbor_free_or_set_invalidp) Neighbor *n = NULL;
Network *network = userdata;
int r; int r;
assert(filename); assert(filename);
assert(section); assert(section);
assert(lvalue); assert(lvalue);
assert(rvalue); assert(rvalue);
assert(data); assert(userdata);
r = neighbor_new_static(network, filename, section_line, &n); r = neighbor_new_static(network, filename, section_line, &n);
if (r < 0) if (r < 0)
return log_oom(); return log_oom();
if (isempty(rvalue)) {
n->ll_addr = HW_ADDR_NULL;
TAKE_PTR(n);
return 0;
}
r = parse_hw_addr(rvalue, &n->ll_addr); r = parse_hw_addr(rvalue, &n->ll_addr);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,