Compare commits

...

4 Commits

Author SHA1 Message Date
Yu Watanabe a0be538616 Merge pull request #14836 from yuwata/network-fix-ipv6-token-parser
network: fix IPv6Token= parser
2020-02-10 15:16:31 +09:00
Yu Watanabe f7ada4b8ec test-network: tentatively stops .socket units for udevd
To suppress the following warning:
---
Warning: Stopping systemd-udevd.service, but it can still be activated by:
  systemd-udevd-control.socket
  systemd-udevd-kernel.socket
2020-02-10 00:51:00 +09:00
Kevin P. Fleming b241fa00e9 network: Add test for explicit 'static' IPv6Token
Add a test case for an explicitly-specified 'static' IPv6Token.

Signed-off-by: Kevin P. Fleming <kevin@km6g.us>
2020-02-10 00:41:34 +09:00
Yu Watanabe b751c3e747 network fix parser for IPv6Token=
extract_first_word() drops multiple ':'. So, it is not suitable for
parsing 'static' case.
2020-02-10 00:40:18 +09:00
3 changed files with 23 additions and 21 deletions

View File

@ -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,

View File

@ -0,0 +1,6 @@
[Match]
Name=veth99
[Network]
IPv6AcceptRA=true
IPv6Token=static:::1a:2b:3c:4d

View File

@ -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()