]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-network: add test case for removal of nexthop that is a member of a group nexthop 30953/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 15 Jan 2024 10:48:48 +0000 (19:48 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 16 Jan 2024 03:48:50 +0000 (12:48 +0900)
test/test-network/conf/25-nexthop-test1.network [new file with mode: 0644]
test/test-network/systemd-networkd-tests.py

diff --git a/test/test-network/conf/25-nexthop-test1.network b/test/test-network/conf/25-nexthop-test1.network
new file mode 100644 (file)
index 0000000..5a4c596
--- /dev/null
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Match]
+Name=test1
+
+[Network]
+Address=192.168.20.21/24
+IPv6AcceptRA=no
+
+[Route]
+Destination=10.10.11.10
+# Nexthop 21 is configured as a group nexthop of 1 and 20
+NextHop=21
index edf09b81204f390125f92d5726e064855c16846d..6d074e67ff53af986c0d032c375837303985381c 100755 (executable)
@@ -4033,6 +4033,33 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
 
         self.check_nexthop(manage_foreign_nexthops, first=True)
 
+        # Remove nexthop with ID 20
+        check_output('ip nexthop del id 20')
+        copy_network_unit('11-dummy.netdev', '25-nexthop-test1.network')
+        networkctl_reload()
+
+        # 25-nexthop-test1.network requests a route with nexthop ID 21,
+        # which is silently removed by the kernel when nexthop with ID 20 is removed in the above,
+        # hence test1 should be stuck in the configuring state.
+        self.wait_operstate('test1', operstate='routable', setup_state='configuring')
+
+        # Wait for a while, and check if the interface is still in the configuring state.
+        time.sleep(1)
+        output = networkctl_status('test1')
+        self.assertIn('State: routable (configuring)', output)
+
+        # Reconfigure the interface that has nexthop with ID 20 and 21,
+        # then the route requested by test1 can be configured.
+        networkctl_reconfigure('dummy98')
+        self.wait_online(['test1:routable'])
+
+        # Check if the requested route actually configured.
+        output = check_output('ip route show 10.10.11.10')
+        print(output)
+        self.assertIn('10.10.11.10 nhid 21 proto static', output)
+        self.assertIn('nexthop via 192.168.5.1 dev veth99 weight 3', output)
+        self.assertIn('nexthop via 192.168.20.1 dev dummy98 weight 1', output)
+
         remove_link('veth99')
         time.sleep(2)