1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-02 13:47:27 +03:00

test-network: add test case for issue #35047

This commit is contained in:
Yu Watanabe 2024-11-08 22:55:20 +09:00 committed by Luca Boccassi
parent 688f166972
commit 7f1b36a82a
4 changed files with 60 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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')