From 452d86a53246806feb92a4863e02668f079edafc Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 3 Dec 2020 19:09:55 +0900 Subject: [PATCH] test-network: add tests for IPv6 routes with reject type --- .../test-network/conf/25-route-static.network | 12 ++++ test/test-network/systemd-networkd-tests.py | 60 +++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/test/test-network/conf/25-route-static.network b/test/test-network/conf/25-route-static.network index bb485eb6b0..ea47a0c03b 100644 --- a/test/test-network/conf/25-route-static.network +++ b/test/test-network/conf/25-route-static.network @@ -48,6 +48,18 @@ Destination=202.54.1.3 Type=prohibit Destination=202.54.1.4 +[Route] +Type=blackhole +Destination=2001:1234:5678::2 + +[Route] +Type=unreachable +Destination=2001:1234:5678::3 + +[Route] +Type=prohibit +Destination=2001:1234:5678::4 + [Route] Type=local Destination=149.10.123.1 diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index f759840d23..0a33ce7779 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -2216,6 +2216,21 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): print(output) self.assertRegex(output, 'prohibit 202.54.1.4 proto static') + print('### ip -6 route show type blackhole') + output = check_output('ip -6 route show type blackhole') + print(output) + self.assertIn('blackhole 2001:1234:5678::2 dev lo proto static', output) + + print('### ip -6 route show type unreachable') + output = check_output('ip -6 route show type unreachable') + print(output) + self.assertIn('unreachable 2001:1234:5678::3 dev lo proto static', output) + + print('### ip -6 route show type prohibit') + output = check_output('ip -6 route show type prohibit') + print(output) + self.assertIn('prohibit 2001:1234:5678::4 dev lo proto static', output) + print('### ip route show 192.168.10.1') output = check_output('ip route show 192.168.10.1') print(output) @@ -2261,6 +2276,21 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): print(output) self.assertEqual(output, '') + print('### ip -6 route show type blackhole') + output = check_output('ip -6 route show type blackhole') + print(output) + self.assertEqual(output, '') + + print('### ip -6 route show type unreachable') + output = check_output('ip -6 route show type unreachable') + print(output) + self.assertEqual(output, '') + + print('### ip -6 route show type prohibit') + output = check_output('ip -6 route show type prohibit') + print(output) + self.assertEqual(output, '') + remove_unit_from_networkd_path(['25-address-static.network']) check_output(*networkctl_cmd, 'reload', env=env) time.sleep(1) @@ -2282,6 +2312,21 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): print(output) self.assertRegex(output, 'prohibit 202.54.1.4 proto static') + print('### ip -6 route show type blackhole') + output = check_output('ip -6 route show type blackhole') + print(output) + self.assertIn('blackhole 2001:1234:5678::2 dev lo proto static', output) + + print('### ip -6 route show type unreachable') + output = check_output('ip -6 route show type unreachable') + print(output) + self.assertIn('unreachable 2001:1234:5678::3 dev lo proto static', output) + + print('### ip -6 route show type prohibit') + output = check_output('ip -6 route show type prohibit') + print(output) + self.assertIn('prohibit 2001:1234:5678::4 dev lo proto static', output) + rc = call("ip link del dummy98") self.assertEqual(rc, 0) time.sleep(2) @@ -2302,6 +2347,21 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): print(output) self.assertEqual(output, '') + print('### ip -6 route show type blackhole') + output = check_output('ip -6 route show type blackhole') + print(output) + self.assertEqual(output, '') + + print('### ip -6 route show type unreachable') + output = check_output('ip -6 route show type unreachable') + print(output) + self.assertEqual(output, '') + + print('### ip -6 route show type prohibit') + output = check_output('ip -6 route show type prohibit') + print(output) + self.assertEqual(output, '') + @expectedFailureIfRTA_VIAIsNotSupported() def test_route_via_ipv6(self): copy_unit_to_networkd_unit_path('25-route-via-ipv6.network', '12-dummy.netdev')