summaryrefslogtreecommitdiffstats
path: root/test/test-network
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-11-08 14:55:20 +0100
committerLuca Boccassi <bluca@debian.org>2024-11-11 14:59:41 +0100
commit7f1b36a82afd114f0bdc7dc8ccef0a5febf2ae8e (patch)
treee50f2d1193a264b46430899bd655f8f9ecf47c3b /test/test-network
parentnetwork/nexthop: also forget IPv4 nexthops when an interface went down (diff)
downloadsystemd-7f1b36a82afd114f0bdc7dc8ccef0a5febf2ae8e.tar.xz
systemd-7f1b36a82afd114f0bdc7dc8ccef0a5febf2ae8e.zip
test-network: add test case for issue #35047
Diffstat (limited to 'test/test-network')
-rw-r--r--test/test-network/conf/25-route-static-issue-35047.network10
-rw-r--r--test/test-network/conf/25-route-static-issue-35047.network.d/step1.conf4
-rw-r--r--test/test-network/conf/25-route-static-issue-35047.network.d/step2.conf6
-rwxr-xr-xtest/test-network/systemd-networkd-tests.py40
4 files changed, 60 insertions, 0 deletions
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
index 0000000000..0d65b4b77c
--- /dev/null
+++ b/test/test-network/conf/25-route-static-issue-35047.network
@@ -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
index 0000000000..e728e97f57
--- /dev/null
+++ b/test/test-network/conf/25-route-static-issue-35047.network.d/step1.conf
@@ -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
index 0000000000..b65399fb76
--- /dev/null
+++ b/test/test-network/conf/25-route-static-issue-35047.network.d/step2.conf
@@ -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
diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py
index 6b19a8a938..3944996868 100755
--- a/test/test-network/systemd-networkd-tests.py
+++ b/test/test-network/systemd-networkd-tests.py
@@ -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')