From 117a55c755a526f48b9c7501ec78d2232d4a0661 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 5 May 2019 17:42:05 +0200 Subject: [PATCH] test-network: add one more test for LinkLocalAddressing=fallback --- ...-ipv4ll-fallback-with-dhcp-server.network} | 0 ...pv4ll-fallback-without-dhcp-server.network | 10 +++++++ test/test-network/systemd-networkd-tests.py | 26 ++++++++++++++++--- 3 files changed, 33 insertions(+), 3 deletions(-) rename test/test-network/conf/{dhcp-client-with-ipv4ll-fallback.network => dhcp-client-with-ipv4ll-fallback-with-dhcp-server.network} (100%) create mode 100644 test/test-network/conf/dhcp-client-with-ipv4ll-fallback-without-dhcp-server.network diff --git a/test/test-network/conf/dhcp-client-with-ipv4ll-fallback.network b/test/test-network/conf/dhcp-client-with-ipv4ll-fallback-with-dhcp-server.network similarity index 100% rename from test/test-network/conf/dhcp-client-with-ipv4ll-fallback.network rename to test/test-network/conf/dhcp-client-with-ipv4ll-fallback-with-dhcp-server.network diff --git a/test/test-network/conf/dhcp-client-with-ipv4ll-fallback-without-dhcp-server.network b/test/test-network/conf/dhcp-client-with-ipv4ll-fallback-without-dhcp-server.network new file mode 100644 index 00000000000..7faff5f9e57 --- /dev/null +++ b/test/test-network/conf/dhcp-client-with-ipv4ll-fallback-without-dhcp-server.network @@ -0,0 +1,10 @@ +[Match] +Name=veth99 + +[Network] +DHCP=ipv4 +LinkLocalAddressing=fallback +IPv6AcceptRA=no + +[DHCP] +MaxAttempts=1 diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 184ab2d03a3..4301f8c5dc7 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -1880,7 +1880,8 @@ class NetworkdNetworkDHCPClientTests(unittest.TestCase, Utilities): 'dhcp-client-route-metric.network', 'dhcp-client-route-table.network', 'dhcp-client-vrf.network', - 'dhcp-client-with-ipv4ll-fallback.network', + 'dhcp-client-with-ipv4ll-fallback-with-dhcp-server.network', + 'dhcp-client-with-ipv4ll-fallback-without-dhcp-server.network', 'dhcp-client.network', 'dhcp-server-veth-peer.network', 'dhcp-v4-server-veth-peer.network', @@ -2177,10 +2178,11 @@ class NetworkdNetworkDHCPClientTests(unittest.TestCase, Utilities): print(output) self.assertRegex(output, 'onlink') - def test_dhcp_client_with_ipv4ll_fallback(self): + def test_dhcp_client_with_ipv4ll_fallback_with_dhcp_server(self): self.copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', - 'dhcp-client-with-ipv4ll-fallback.network') + 'dhcp-client-with-ipv4ll-fallback-with-dhcp-server.network') self.start_networkd(0) + self.wait_online(['veth-peer:carrier']) self.start_dnsmasq(lease_time='2m') self.wait_online(['veth99:routable', 'veth-peer:routable']) @@ -2213,6 +2215,24 @@ class NetworkdNetworkDHCPClientTests(unittest.TestCase, Utilities): self.search_words_in_dnsmasq_log('DHCPOFFER', show_all=True) + def test_dhcp_client_with_ipv4ll_fallback_without_dhcp_server(self): + self.copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-veth-peer.network', + 'dhcp-client-with-ipv4ll-fallback-without-dhcp-server.network') + self.start_networkd(0) + self.wait_online(['veth99:degraded', 'veth-peer:routable']) + + output = subprocess.check_output(['ip', 'address', 'show', 'dev', 'veth99']).rstrip().decode('utf-8') + print(output) + + output = subprocess.check_output(['ip', '-6', 'address', 'show', 'dev', 'veth99', 'scope', 'global', 'dynamic']).rstrip().decode('utf-8') + self.assertNotRegex(output, 'inet6 2600::[0-9a-f]*/128 scope global dynamic') + output = subprocess.check_output(['ip', '-6', 'address', 'show', 'dev', 'veth99', 'scope', 'link']).rstrip().decode('utf-8') + self.assertRegex(output, 'inet6 .* scope link') + output = subprocess.check_output(['ip', '-4', 'address', 'show', 'dev', 'veth99', 'scope', 'global', 'dynamic']).rstrip().decode('utf-8') + self.assertNotRegex(output, 'inet 192.168.5.[0-9]*/24 brd 192.168.5.255 scope global dynamic veth99') + output = subprocess.check_output(['ip', '-4', 'address', 'show', 'dev', 'veth99', 'scope', 'link']).rstrip().decode('utf-8') + self.assertRegex(output, 'inet .* scope link') + if __name__ == '__main__': unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout, verbosity=3)) -- 2.39.2