]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: add test case for issue #35047 35099/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 8 Nov 2024 13:55:20 +0000 (22:55 +0900)
committerLuca Boccassi <bluca@debian.org>
Mon, 11 Nov 2024 13:59:41 +0000 (13:59 +0000)
test/test-network/conf/25-route-static-issue-35047.network [new file with mode: 0644]
test/test-network/conf/25-route-static-issue-35047.network.d/step1.conf [new file with mode: 0644]
test/test-network/conf/25-route-static-issue-35047.network.d/step2.conf [new file with mode: 0644]
test/test-network/systemd-networkd-tests.py

diff --git a/test/test-network/conf/25-route-static-issue-35047.network b/test/test-network/conf/25-route-static-issue-35047.network
new file mode 100644 (file)
index 0000000..0d65b4b
--- /dev/null
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Match]
+Name=dummy98
+
+[Network]
+IPv6AcceptRA=no
+
+[Route]
+Destination=198.51.100.0/24
+Gateway=192.0.2.2
diff --git a/test/test-network/conf/25-route-static-issue-35047.network.d/step1.conf b/test/test-network/conf/25-route-static-issue-35047.network.d/step1.conf
new file mode 100644 (file)
index 0000000..e728e97
--- /dev/null
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Address]
+Address=192.0.2.1/32
+Peer=192.0.2.2/32
diff --git a/test/test-network/conf/25-route-static-issue-35047.network.d/step2.conf b/test/test-network/conf/25-route-static-issue-35047.network.d/step2.conf
new file mode 100644 (file)
index 0000000..b65399f
--- /dev/null
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Address]
+Address=192.0.2.1/32
+
+[Route]
+Destination=192.0.2.2/32
index 6b19a8a9388455826dc13633f8c94aeff9fbf8f8..39449968683f077ae4aecf025f58e8c765721d16 100755 (executable)
@@ -4050,6 +4050,46 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
             with self.subTest(manage_foreign_routes=manage_foreign_routes):
                 self._test_route_static(manage_foreign_routes)
 
+    def test_route_static_issue_35047(self):
+        copy_network_unit(
+            '25-route-static-issue-35047.network',
+            '25-route-static-issue-35047.network.d/step1.conf',
+            '12-dummy.netdev',
+            copy_dropins=False)
+        start_networkd()
+        self.wait_online('dummy98:routable')
+
+        print('### ip -4 route show table all dev dummy98')
+        output = check_output('ip -4 route show table all dev dummy98')
+        print(output)
+        self.assertIn('192.0.2.2 proto kernel scope link src 192.0.2.1', output)
+        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)
+
+        check_output('ip link set dev dummy98 down')
+        self.wait_route_dropped('dummy98', '192.0.2.2 proto kernel scope link src 192.0.2.1', ipv='-4', table='all', timeout_sec=10)
+        self.wait_route_dropped('dummy98', 'local 192.0.2.1 table local proto kernel scope host src 192.0.2.1', ipv='-4', table='all', timeout_sec=10)
+        self.wait_route_dropped('dummy98', '198.51.100.0/24 via 192.0.2.2 proto static', ipv='-4', table='all', timeout_sec=10)
+
+        print('### ip -4 route show table all dev dummy98')
+        output = check_output('ip -4 route show table all dev dummy98')
+        print(output)
+        self.assertNotIn('192.0.2.2', output)
+        self.assertNotIn('192.0.2.1', output)
+        self.assertNotIn('198.51.100.0/24', output)
+
+        remove_network_unit('25-route-static-issue-35047.network.d/step1.conf')
+        copy_network_unit('25-route-static-issue-35047.network.d/step2.conf')
+        networkctl_reload()
+        self.wait_online('dummy98:routable')
+
+        print('### ip -4 route show table all dev dummy98')
+        output = check_output('ip -4 route show table all dev dummy98')
+        print(output)
+        self.assertIn('192.0.2.2 proto static scope link', output)
+        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)
+
     @expectedFailureIfRTA_VIAIsNotSupported()
     def test_route_via_ipv6(self):
         copy_network_unit('25-route-via-ipv6.network', '12-dummy.netdev')