mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-24 21:34:08 +03:00
Merge pull request #14836 from yuwata/network-fix-ipv6-token-parser
network: fix IPv6Token= parser
This commit is contained in:
commit
a0be538616
@ -962,7 +962,6 @@ int config_parse_address_generation_type(
|
||||
void *userdata) {
|
||||
|
||||
_cleanup_free_ IPv6Token *token = NULL;
|
||||
_cleanup_free_ char *word = NULL;
|
||||
union in_addr_union buffer;
|
||||
Network *network = data;
|
||||
const char *p;
|
||||
@ -978,35 +977,19 @@ int config_parse_address_generation_type(
|
||||
return 0;
|
||||
}
|
||||
|
||||
p = rvalue;
|
||||
r = extract_first_word(&p, &word, ":", 0);
|
||||
if (r == -ENOMEM)
|
||||
return log_oom();
|
||||
if (r <= 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r,
|
||||
"Invalid IPv6Token= , ignoring assignment: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = ipv6token_new(&token);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
if (streq(word, "static"))
|
||||
if ((p = startswith(rvalue, "static:")))
|
||||
token->address_generation_type = IPV6_TOKEN_ADDRESS_GENERATION_STATIC;
|
||||
else if (streq(word, "prefixstable"))
|
||||
else if ((p = startswith(rvalue, "prefixstable:")))
|
||||
token->address_generation_type = IPV6_TOKEN_ADDRESS_GENERATION_PREFIXSTABLE;
|
||||
else {
|
||||
token->address_generation_type = IPV6_TOKEN_ADDRESS_GENERATION_STATIC;
|
||||
p = rvalue;
|
||||
}
|
||||
|
||||
if (isempty(p)) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0,
|
||||
"Invalid IPv6Token= , ignoring assignment: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = in_addr_from_string(AF_INET6, p, &buffer);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r,
|
||||
|
@ -0,0 +1,6 @@
|
||||
[Match]
|
||||
Name=veth99
|
||||
|
||||
[Network]
|
||||
IPv6AcceptRA=true
|
||||
IPv6Token=static:::1a:2b:3c:4d
|
@ -165,7 +165,9 @@ def setUpModule():
|
||||
shutil.rmtree(networkd_ci_path)
|
||||
copytree(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'conf'), networkd_ci_path)
|
||||
|
||||
for u in ['systemd-networkd.socket', 'systemd-networkd.service', 'systemd-resolved.service', 'systemd-udevd.service', 'firewalld.service']:
|
||||
for u in ['systemd-networkd.socket', 'systemd-networkd.service', 'systemd-resolved.service',
|
||||
'systemd-udevd-kernel.socket', 'systemd-udevd-control.socket', 'systemd-udevd.service',
|
||||
'firewalld.service']:
|
||||
if call(f'systemctl is-active --quiet {u}') == 0:
|
||||
check_output(f'systemctl stop {u}')
|
||||
running_units.append(u)
|
||||
@ -249,13 +251,14 @@ def tearDownModule():
|
||||
|
||||
shutil.rmtree(networkd_ci_path)
|
||||
|
||||
for u in ['systemd-networkd.service', 'systemd-resolved.service', 'systemd-udevd.service']:
|
||||
for u in ['systemd-networkd.service', 'systemd-resolved.service']:
|
||||
check_output(f'systemctl stop {u}')
|
||||
|
||||
shutil.rmtree('/run/systemd/system/systemd-networkd.service.d')
|
||||
shutil.rmtree('/run/systemd/system/systemd-resolved.service.d')
|
||||
shutil.rmtree('/run/systemd/system/systemd-udevd.service.d')
|
||||
check_output('systemctl daemon-reload')
|
||||
check_output('systemctl restart systemd-udevd.service')
|
||||
|
||||
for u in running_units:
|
||||
check_output(f'systemctl start {u}')
|
||||
@ -2681,6 +2684,7 @@ class NetworkdRATests(unittest.TestCase, Utilities):
|
||||
'ipv6-prefix.network',
|
||||
'ipv6-prefix-veth.network',
|
||||
'ipv6-prefix-veth-token-static.network',
|
||||
'ipv6-prefix-veth-token-static-explicit.network',
|
||||
'ipv6-prefix-veth-token-prefixstable.network']
|
||||
|
||||
def setUp(self):
|
||||
@ -2715,6 +2719,15 @@ class NetworkdRATests(unittest.TestCase, Utilities):
|
||||
print(output)
|
||||
self.assertRegex(output, '2002:da8:1:0:1a:2b:3c:4d')
|
||||
|
||||
def test_ipv6_token_static_explicit(self):
|
||||
copy_unit_to_networkd_unit_path('25-veth.netdev', 'ipv6-prefix.network', 'ipv6-prefix-veth-token-static-explicit.network')
|
||||
start_networkd()
|
||||
self.wait_online(['veth99:routable', 'veth-peer:degraded'])
|
||||
|
||||
output = check_output(*networkctl_cmd, '-n', '0', 'status', 'veth99', env=env)
|
||||
print(output)
|
||||
self.assertRegex(output, '2002:da8:1:0:1a:2b:3c:4d')
|
||||
|
||||
def test_ipv6_token_prefixstable(self):
|
||||
copy_unit_to_networkd_unit_path('25-veth.netdev', 'ipv6-prefix.network', 'ipv6-prefix-veth-token-prefixstable.network')
|
||||
start_networkd()
|
||||
|
Loading…
Reference in New Issue
Block a user