diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-06-04 06:21:02 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-07-28 18:50:54 +0200 |
commit | c9d223e803092ea6ba1899f44fa48a01f5ba0bd3 (patch) | |
tree | eb3beab6949c25d405927774253941f2283033e8 /test | |
parent | network: add debug log for configuring address (diff) | |
download | systemd-c9d223e803092ea6ba1899f44fa48a01f5ba0bd3.tar.xz systemd-c9d223e803092ea6ba1899f44fa48a01f5ba0bd3.zip |
test-network: add tests for prefix routes
Diffstat (limited to 'test')
-rw-r--r-- | test/test-network/conf/25-prefix-route-with-vrf.network | 26 | ||||
-rw-r--r-- | test/test-network/conf/25-prefix-route-without-vrf.network | 25 | ||||
-rwxr-xr-x | test/test-network/systemd-networkd-tests.py | 74 |
3 files changed, 125 insertions, 0 deletions
diff --git a/test/test-network/conf/25-prefix-route-with-vrf.network b/test/test-network/conf/25-prefix-route-with-vrf.network new file mode 100644 index 0000000000..fdc1e11c5e --- /dev/null +++ b/test/test-network/conf/25-prefix-route-with-vrf.network @@ -0,0 +1,26 @@ +[Match] +Name=dummy98 + +[Network] +IPv6AcceptRA=no +VRF=vrf99 +Address=fdde:11:22::1/128 +Address=fdde:11:33::1/64 +Address=10.20.22.1/32 +Address=10.20.33.1/24 + +[Address] +Address=fdde:11:44::1/128 +AddPrefixRoute=no + +[Address] +Address=fdde:11:55::1/64 +AddPrefixRoute=no + +[Address] +Address=10.20.44.1/32 +AddPrefixRoute=no + +[Address] +Address=10.20.55.1/24 +AddPrefixRoute=no diff --git a/test/test-network/conf/25-prefix-route-without-vrf.network b/test/test-network/conf/25-prefix-route-without-vrf.network new file mode 100644 index 0000000000..9354b55d5c --- /dev/null +++ b/test/test-network/conf/25-prefix-route-without-vrf.network @@ -0,0 +1,25 @@ +[Match] +Name=test1 + +[Network] +IPv6AcceptRA=no +Address=fdde:12:22::1/128 +Address=fdde:12:33::1/64 +Address=10.21.22.1/32 +Address=10.21.33.1/24 + +[Address] +Address=fdde:12:44::1/128 +AddPrefixRoute=no + +[Address] +Address=fdde:12:55::1/64 +AddPrefixRoute=no + +[Address] +Address=10.21.44.1/32 +AddPrefixRoute=no + +[Address] +Address=10.21.55.1/24 +AddPrefixRoute=no diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index efd3db8f44..0ca1fb3bf9 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -1717,6 +1717,8 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): '25-qdisc-ingress-netem-compat.network', '25-qdisc-pie.network', '25-qdisc-qfq.network', + '25-prefix-route-with-vrf.network', + '25-prefix-route-without-vrf.network', '25-route-ipv6-src.network', '25-route-static.network', '25-route-vrf.network', @@ -1729,6 +1731,7 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): '25-veth-peer.network', '25-veth.netdev', '25-vrf.netdev', + '25-vrf.network', '26-link-local-addressing-ipv6.network', 'routing-policy-rule-dummy98.network', 'routing-policy-rule-test1.network'] @@ -1815,6 +1818,77 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): print(output) self.assertNotRegex(output, '192.168.100.10/24') + @expectedFailureIfModuleIsNotAvailable('vrf') + def test_prefix_route(self): + copy_unit_to_networkd_unit_path('25-prefix-route-with-vrf.network', '12-dummy.netdev', + '25-prefix-route-without-vrf.network', '11-dummy.netdev', + '25-vrf.netdev', '25-vrf.network') + for trial in range(2): + if trial == 0: + start_networkd() + else: + restart_networkd(3) + + self.wait_online(['dummy98:routable', 'test1:routable', 'vrf99:carrier']) + + output = check_output('ip route show table 42 dev dummy98') + print('### ip route show table 42 dev dummy98') + print(output) + self.assertRegex(output, 'local 10.20.22.1 proto kernel scope host src 10.20.22.1') + self.assertRegex(output, 'broadcast 10.20.33.0 proto kernel scope link src 10.20.33.1') + self.assertRegex(output, '10.20.33.0/24 proto kernel scope link src 10.20.33.1') + self.assertRegex(output, 'local 10.20.33.1 proto kernel scope host src 10.20.33.1') + self.assertRegex(output, 'broadcast 10.20.33.255 proto kernel scope link src 10.20.33.1') + self.assertRegex(output, 'local 10.20.44.1 proto kernel scope host src 10.20.44.1') + self.assertRegex(output, 'broadcast 10.20.55.0 proto kernel scope link src 10.20.55.1') + self.assertRegex(output, 'local 10.20.55.1 proto kernel scope host src 10.20.55.1') + self.assertRegex(output, 'broadcast 10.20.55.255 proto kernel scope link src 10.20.55.1') + output = check_output('ip -6 route show table 42 dev dummy98') + print('### ip -6 route show table 42 dev dummy98') + print(output) + if trial == 0: + # Kernel's bug? + self.assertRegex(output, 'local fdde:11:22::1 proto kernel metric 0 pref medium') + #self.assertRegex(output, 'fdde:11:22::1 proto kernel metric 256 pref medium') + self.assertRegex(output, 'local fdde:11:33::1 proto kernel metric 0 pref medium') + self.assertRegex(output, 'fdde:11:33::/64 proto kernel metric 256 pref medium') + self.assertRegex(output, 'local fdde:11:44::1 proto kernel metric 0 pref medium') + self.assertRegex(output, 'local fdde:11:55::1 proto kernel metric 0 pref medium') + self.assertRegex(output, 'fe80::/64 proto kernel metric 256 pref medium') + self.assertRegex(output, 'ff00::/8 metric 256 pref medium') + + print() + + output = check_output('ip route show dev test1') + print('### ip route show dev test1') + print(output) + self.assertRegex(output, '10.21.33.0/24 proto kernel scope link src 10.21.33.1') + output = check_output('ip route show table local dev test1') + print('### ip route show table local dev test1') + print(output) + self.assertRegex(output, 'local 10.21.22.1 proto kernel scope host src 10.21.22.1') + self.assertRegex(output, 'broadcast 10.21.33.0 proto kernel scope link src 10.21.33.1') + self.assertRegex(output, 'local 10.21.33.1 proto kernel scope host src 10.21.33.1') + self.assertRegex(output, 'broadcast 10.21.33.255 proto kernel scope link src 10.21.33.1') + self.assertRegex(output, 'local 10.21.44.1 proto kernel scope host src 10.21.44.1') + self.assertRegex(output, 'broadcast 10.21.55.0 proto kernel scope link src 10.21.55.1') + self.assertRegex(output, 'local 10.21.55.1 proto kernel scope host src 10.21.55.1') + self.assertRegex(output, 'broadcast 10.21.55.255 proto kernel scope link src 10.21.55.1') + output = check_output('ip -6 route show dev test1') + print('### ip -6 route show dev test1') + print(output) + self.assertRegex(output, 'fdde:12:22::1 proto kernel metric 256 pref medium') + self.assertRegex(output, 'fdde:12:33::/64 proto kernel metric 256 pref medium') + self.assertRegex(output, 'fe80::/64 proto kernel metric 256 pref medium') + output = check_output('ip -6 route show table local dev test1') + print('### ip -6 route show table local dev test1') + print(output) + self.assertRegex(output, 'local fdde:12:22::1 proto kernel metric 0 pref medium') + self.assertRegex(output, 'local fdde:12:33::1 proto kernel metric 0 pref medium') + self.assertRegex(output, 'local fdde:12:44::1 proto kernel metric 0 pref medium') + self.assertRegex(output, 'local fdde:12:55::1 proto kernel metric 0 pref medium') + self.assertRegex(output, 'ff00::/8 metric 256 pref medium') + def test_configure_without_carrier(self): copy_unit_to_networkd_unit_path('11-dummy.netdev') start_networkd() |