From f9b5c276458cae63d7587a1ad691a84078ef0fb3 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 15 Jan 2024 19:48:48 +0900 Subject: [PATCH] test-network: add test case for removal of nexthop that is a member of a group nexthop --- .../conf/25-nexthop-test1.network | 12 +++++++++ test/test-network/systemd-networkd-tests.py | 27 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 test/test-network/conf/25-nexthop-test1.network diff --git a/test/test-network/conf/25-nexthop-test1.network b/test/test-network/conf/25-nexthop-test1.network new file mode 100644 index 00000000000..5a4c596d3aa --- /dev/null +++ b/test/test-network/conf/25-nexthop-test1.network @@ -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 diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index edf09b81204..6d074e67ff5 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -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)