summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-06-23 07:37:01 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-06-24 20:17:21 +0200
commit62fb079a3b4a6553d87d06a3004d21b4e322a4e5 (patch)
tree90fe40dfdfbddd06eb117d12dfb3bc50f6f7aff9 /test
parentnetwork/ndisc: do not remove static routes when received RA with zero lifetime (diff)
downloadsystemd-62fb079a3b4a6553d87d06a3004d21b4e322a4e5.tar.xz
systemd-62fb079a3b4a6553d87d06a3004d21b4e322a4e5.zip
test-network: check if static routes not overridden by NDisc routes
Diffstat (limited to 'test')
-rw-r--r--test/test-network/conf/25-ipv6-prefix-veth-static-route.network14
-rwxr-xr-xtest/test-network/systemd-networkd-tests.py24
2 files changed, 38 insertions, 0 deletions
diff --git a/test/test-network/conf/25-ipv6-prefix-veth-static-route.network b/test/test-network/conf/25-ipv6-prefix-veth-static-route.network
new file mode 100644
index 0000000000..a2ea7bff2c
--- /dev/null
+++ b/test/test-network/conf/25-ipv6-prefix-veth-static-route.network
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Match]
+Name=veth99
+
+[Network]
+IPv6AcceptRA=true
+
+[Route]
+Gateway=fe80::1034:56ff:fe78:9abd
+GatewayOnLink=no
+Metric=256
+
+[IPv6AcceptRA]
+RouteMetric=256
diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py
index 0355c7aca1..7c336ba9e2 100755
--- a/test/test-network/systemd-networkd-tests.py
+++ b/test/test-network/systemd-networkd-tests.py
@@ -5824,6 +5824,30 @@ class NetworkdRATests(unittest.TestCase, Utilities):
self.assertIn('pref high', output)
self.assertNotIn('pref low', output)
+ def test_ndisc_vs_static_route(self):
+ copy_network_unit('25-veth.netdev', '25-ipv6-prefix.network', '25-ipv6-prefix-veth-static-route.network')
+ start_networkd()
+ self.wait_online('veth99:routable', 'veth-peer:degraded')
+
+ output = check_output('ip -6 route show dev veth99 table all')
+ print(output)
+
+ # If a conflicting static route is already configured, do not override the static route.
+ output = check_output('ip -6 route show dev veth99 default via fe80::1034:56ff:fe78:9abd')
+ print(output)
+ self.assertIn('default proto static metric 256 pref medium', output)
+ self.assertNotIn('proto ra', output)
+
+ if not os.path.exists(test_ndisc_send):
+ self.skipTest(f"{test_ndisc_send} does not exist.")
+
+ # Also check if the static route is protected from RA with zero lifetime
+ check_output(f'{test_ndisc_send} --interface veth-peer --type router-advertisement --lifetime 0')
+ time.sleep(2)
+ output = check_output('ip -6 route show dev veth99 default via fe80::1034:56ff:fe78:9abd')
+ print(output)
+ self.assertIn('default proto static metric 256 pref medium', output)
+
# radvd supports captive portal since v2.20.
# https://github.com/radvd-project/radvd/commit/791179a7f730decbddb2290ef0e34aa85d71b1bc
@unittest.skipUnless(radvd_check_config('captive-portal.conf'), "Installed radvd doesn't support captive portals")