From ce5a54ed9b01514547272daa214e8a349e6e6005 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 15 Jun 2025 03:41:31 +0900 Subject: [PATCH] test-network: add test case for issue #37714 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. --- .../conf/25-route-static-issue-37714.network | 72 +++++++++++++++++++ test/test-network/systemd-networkd-tests.py | 36 ++++++++++ 2 files changed, 108 insertions(+) create mode 100644 test/test-network/conf/25-route-static-issue-37714.network 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 index 00000000000..abb997ecca9 --- /dev/null +++ b/test/test-network/conf/25-route-static-issue-37714.network @@ -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 diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 7d8a7c8f3fa..4a418859020 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -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') -- 2.47.3