summaryrefslogtreecommitdiffstats
path: root/src/network/networkd-dhcp6.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-02-17 18:23:42 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-02-17 19:48:07 +0100
commit275468c033ab4a5da4c6a6d32baa3268b3f46d09 (patch)
tree57b6406d3f248cc2380352be796c73d4721e4b6f /src/network/networkd-dhcp6.c
parentin-addr-util: introduce in6_addr_equal() (diff)
downloadsystemd-275468c033ab4a5da4c6a6d32baa3268b3f46d09.tar.xz
systemd-275468c033ab4a5da4c6a6d32baa3268b3f46d09.zip
network: assign values after all checks are passed
Diffstat (limited to 'src/network/networkd-dhcp6.c')
-rw-r--r--src/network/networkd-dhcp6.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c
index 326c9f3fcf..eb9fabb2ae 100644
--- a/src/network/networkd-dhcp6.c
+++ b/src/network/networkd-dhcp6.c
@@ -1613,6 +1613,8 @@ int config_parse_dhcp6_pd_hint(
void *userdata) {
Network *network = data;
+ union in_addr_union u;
+ unsigned char prefixlen;
int r;
assert(filename);
@@ -1620,18 +1622,22 @@ int config_parse_dhcp6_pd_hint(
assert(rvalue);
assert(data);
- r = in_addr_prefix_from_string(rvalue, AF_INET6, (union in_addr_union *) &network->dhcp6_pd_address, &network->dhcp6_pd_length);
+ r = in_addr_prefix_from_string(rvalue, AF_INET6, &u, &prefixlen);
if (r < 0) {
- log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse PrefixDelegationHint=%s, ignoring assignment", rvalue);
+ log_syntax(unit, LOG_WARNING, filename, line, r,
+ "Failed to parse %s=%s, ignoring assignment.", lvalue, rvalue);
return 0;
}
- if (network->dhcp6_pd_length < 1 || network->dhcp6_pd_length > 128) {
- log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid prefix length='%d', ignoring assignment", network->dhcp6_pd_length);
- network->dhcp6_pd_length = 0;
+ if (prefixlen < 1 || prefixlen > 128) {
+ log_syntax(unit, LOG_WARNING, filename, line, 0,
+ "Invalid prefix length in %s=%s, ignoring assignment.", lvalue, rvalue);
return 0;
}
+ network->dhcp6_pd_address = u.in6;
+ network->dhcp6_pd_length = prefixlen;
+
return 0;
}