From: Yu Watanabe Date: Sun, 8 Oct 2023 04:28:32 +0000 (+0900) Subject: test-network: test for NTP servers by DHCPv6 protocol X-Git-Tag: v255-rc1~293^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=34290c6aa9e90d57a63f3c8f3cf7f4892f524e48;p=thirdparty%2Fsystemd.git test-network: test for NTP servers by DHCPv6 protocol For issue #29148. --- diff --git a/test/test-network/conf/25-dhcp-client-ipv6-only.network b/test/test-network/conf/25-dhcp-client-ipv6-only.network index eb5bd027ff1..017f76f4d58 100644 --- a/test/test-network/conf/25-dhcp-client-ipv6-only.network +++ b/test/test-network/conf/25-dhcp-client-ipv6-only.network @@ -9,3 +9,7 @@ IPv6Token=::1a:2b:3c:4d [Route] Gateway=_ipv6ra Destination=2001:1234:5:9fff:ff:ff:ff:ff/128 + +[IPv6AcceptRA] +# To check DNS and NTP servers are really obtained by DHCPv6 +UseDNS=no diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 9edbeb4ab1f..007a6425dd2 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -534,6 +534,10 @@ def read_link_attr(*args): with open(os.path.join('/sys/class/net', *args), encoding='utf-8') as f: return f.readline().strip() +def read_manager_state_file(): + with open('/run/systemd/netif/state', encoding='utf-8') as f: + return f.read() + def read_link_state_file(link): ifindex = read_link_attr(link, 'ifindex') path = os.path.join('/run/systemd/netif/links', ifindex) @@ -5099,7 +5103,8 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): start_networkd() self.wait_online(['veth-peer:carrier']) - start_dnsmasq() + start_dnsmasq('--dhcp-option=option6:dns-server,[2600::ee]', + '--dhcp-option=option6:ntp-server,[2600::ff]') self.wait_online(['veth99:routable', 'veth-peer:routable']) # checking address @@ -5118,6 +5123,20 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): print(output) self.assertRegex(output, 'token :: dev veth99') + # Check link state file + print('## link state file') + output = read_link_state_file('veth99') + print(output) + self.assertIn('DNS=2600::ee', output) + self.assertIn('NTP=2600::ff', output) + + # Check manager state file + print('## manager state file') + output = read_manager_state_file() + print(output) + self.assertRegex(output, 'DNS=.*2600::ee') + self.assertRegex(output, 'NTP=.*2600::ff') + print('## dnsmasq log') output = read_dnsmasq_log_file() print(output) @@ -5131,7 +5150,8 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): f.write('\n[DHCPv6]\nRapidCommit=no\n') stop_dnsmasq() - start_dnsmasq() + start_dnsmasq('--dhcp-option=option6:dns-server,[2600::ee]', + '--dhcp-option=option6:ntp-server,[2600::ff]') networkctl_reload() self.wait_online(['veth99:routable', 'veth-peer:routable']) @@ -5147,6 +5167,20 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities): print(output) self.assertRegex(output, 'via fe80::1034:56ff:fe78:9abd') + # Check link state file + print('## link state file') + output = read_link_state_file('veth99') + print(output) + self.assertIn('DNS=2600::ee', output) + self.assertIn('NTP=2600::ff', output) + + # Check manager state file + print('## manager state file') + output = read_manager_state_file() + print(output) + self.assertRegex(output, 'DNS=.*2600::ee') + self.assertRegex(output, 'NTP=.*2600::ff') + print('## dnsmasq log') output = read_dnsmasq_log_file() print(output)