From e4948bb2cdd1c8d1b6fc357e5b817170612aae33 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 3 Jul 2023 16:04:30 +0900 Subject: [PATCH] test-network: add test for static route with preferred source This adds possible reproducer for issue #28009 (though, the issue is highly racy, hence this may not trigger the issue reliably). --- .../conf/25-route-preferred-source.network | 12 ++++++++++++ test/test-network/systemd-networkd-tests.py | 15 +++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 test/test-network/conf/25-route-preferred-source.network diff --git a/test/test-network/conf/25-route-preferred-source.network b/test/test-network/conf/25-route-preferred-source.network new file mode 100644 index 00000000000..5a55460349b --- /dev/null +++ b/test/test-network/conf/25-route-preferred-source.network @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +[Match] +Name=dummy98 + +[Network] +Address=2001:1234:56:8f63::1/64 +IPv6AcceptRA=no + +[Route] +Destination=abcd::/16 +Gateway=2001:1234:56:8f63::1:1 +PreferredSource=2001:1234:56:8f63::1 diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 1d426ee9798..902614712e8 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -2975,6 +2975,21 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): print(output) self.assertIn('abcd::/16 via 2001:1234:56:8f63::1:1 proto static src 2001:1234:56:8f63::2', output) + def test_route_preferred_source_with_existing_address(self): + # See issue #28009. + copy_network_unit('25-route-preferred-source.network', '12-dummy.netdev') + start_networkd() + + for i in range(3): + if i != 0: + networkctl_reconfigure('dummy98') + + self.wait_online(['dummy98:routable']) + + output = check_output('ip -6 route list dev dummy98') + print(output) + self.assertIn('abcd::/16 via 2001:1234:56:8f63::1:1 proto static src 2001:1234:56:8f63::1', output) + def test_ip_link_mac_address(self): copy_network_unit('25-address-link-section.network', '12-dummy.netdev') start_networkd() -- 2.47.3