]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: add test case for issue #37714
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 14 Jun 2025 18:41:31 +0000 (03:41 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 15 Jun 2025 00:33:23 +0000 (09:33 +0900)
I cannot reproduce the issue with the current git HEAD.
Let's add a test case that is used by the reporter of the issue.

test/test-network/conf/25-route-static-issue-37714.network [new file with mode: 0644]
test/test-network/systemd-networkd-tests.py

diff --git a/test/test-network/conf/25-route-static-issue-37714.network b/test/test-network/conf/25-route-static-issue-37714.network
new file mode 100644 (file)
index 0000000..abb997e
--- /dev/null
@@ -0,0 +1,72 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Match]
+Name=dummy98
+
+[Network]
+IPv6AcceptRA=no
+ConfigureWithoutCarrier=false
+
+[Link]
+RequiredForOnline=false
+ActivationPolicy=up
+
+[Address]
+Address=2000:f00::227/64
+AddPrefixRoute=false
+
+[Route]
+Destination=2000:f00::/64
+PreferredSource=2000:f00::227
+Metric=128
+Table=249
+
+[Route]
+Gateway=2000:f00::1
+GatewayOnLink=true
+PreferredSource=2000:f00::227
+Metric=128
+Table=249
+
+[RoutingPolicyRule]
+From=2000:f00::227
+Table=249
+
+[Address]
+Address=192.168.0.227/26
+AddPrefixRoute=false
+
+[Route]
+Destination=192.168.0.192/26
+PreferredSource=192.168.0.227
+Metric=128
+Table=249
+
+[Route]
+Gateway=192.168.0.193
+GatewayOnLink=true
+PreferredSource=192.168.0.227
+Metric=128
+Table=249
+
+[RoutingPolicyRule]
+From=192.168.0.227
+Table=249
+
+[Route]
+Destination=192.168.0.193
+PreferredSource=192.168.0.227
+Metric=128
+
+[Route]
+Destination=192.168.0.72
+PreferredSource=192.168.0.227
+Gateway=192.168.0.193
+GatewayOnLink=true
+Metric=128
+
+[Route]
+Destination=10.1.2.2
+PreferredSource=192.168.0.227
+Gateway=192.168.0.193
+GatewayOnLink=true
+Metric=128
index 7d8a7c8f3fa2d095060a0efbb4a27c9840271808..4a418859020bcf34b3adab65a88a02242728db8e 100755 (executable)
@@ -4404,6 +4404,42 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
         self.assertIn('local 192.0.2.1 table local proto kernel scope host src 192.0.2.1', output)
         self.assertIn('198.51.100.0/24 via 192.0.2.2 proto static', output)
 
+    def test_route_static_issue_37714(self):
+        copy_network_unit('12-dummy.netdev', '25-route-static-issue-37714.network')
+        start_networkd()
+        self.wait_online('dummy98:routable')
+
+        print('### ip -4 rule list table 249')
+        output = check_output('ip -4 rule list table 249')
+        print(output)
+        self.assertIn('32765:  from 192.168.0.227 lookup 249 proto static', output)
+
+        print('### ip -6 rule list table 249')
+        output = check_output('ip -6 rule list table 249')
+        print(output)
+        self.assertIn('32765:  from 2000:f00::227 lookup 249 proto static', output)
+
+        print('### ip -4 route show table all dev dummy98')
+        output = check_output('ip -4 route show table all dev dummy98')
+        print(output)
+        self.assertIn('default via 192.168.0.193 table 249 proto static src 192.168.0.227 metric 128 onlink', output)
+        self.assertIn('192.168.0.192/26 table 249 proto static scope link src 192.168.0.227 metric 128', output)
+        self.assertIn('10.1.2.2 via 192.168.0.193 proto static src 192.168.0.227 metric 128 onlink', output)
+        self.assertIn('192.168.0.72 via 192.168.0.193 proto static src 192.168.0.227 metric 128 onlink', output)
+        self.assertIn('192.168.0.193 proto static scope link src 192.168.0.227 metric 128', output)
+        self.assertIn('local 192.168.0.227 table local proto kernel scope host src 192.168.0.227', output)
+        self.assertIn('broadcast 192.168.0.255 table local proto kernel scope link src 192.168.0.227', output)
+
+        print('### ip -6 route show table all dev dummy98')
+        output = check_output('ip -6 route show table all dev dummy98')
+        print(output)
+        self.assertIn('2000:f00::/64 table 249 proto static src 2000:f00::227 metric 128 pref medium', output)
+        self.assertIn('default via 2000:f00::1 table 249 proto static src 2000:f00::227 metric 128 onlink pref medium', output)
+        self.assertIn('fe80::/64 proto kernel metric 256 pref medium', output)
+        self.assertIn('local 2000:f00::227 table local proto kernel metric 0 pref medium', output)
+        self.assertRegex(output, 'local fe80:[a-f0-9:]* table local proto kernel metric 0 pref medium', output)
+        self.assertIn('multicast ff00::/8 table local proto kernel metric 256 pref medium', output)
+
     @expectedFailureIfRTA_VIAIsNotSupported()
     def test_route_via_ipv6(self):
         copy_network_unit('25-route-via-ipv6.network', '12-dummy.netdev')