From 9ad294efd03662d98523144b3aac1c406239435a Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 20 Nov 2024 22:30:55 +0900 Subject: [PATCH 1/2] network: update state files before replying bus method Follow-up for 2b07a3211ba8b1b81d6cebb9650d5cb24554b08a. --- src/network/networkd-link.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 4b341a96c7..3c042e6c18 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1443,6 +1443,7 @@ int link_reconfigure_impl(Link *link, LinkReconfigurationFlag flags) { } typedef struct LinkReconfigurationData { + Manager *manager; Link *link; LinkReconfigurationFlag flags; sd_bus_message *message; @@ -1473,6 +1474,12 @@ static void link_reconfiguration_data_destroy_callback(LinkReconfigurationData * } if (!data->counter || *data->counter <= 0) { + /* Update the state files before replying the bus method. Otherwise, + * systemd-networkd-wait-online following networkctl reload/reconfigure may read an + * outdated state file and wrongly handle an interface is already in the configured + * state. */ + (void) manager_clean_all(data->manager); + r = sd_bus_reply_method_return(data->message, NULL); if (r < 0) log_warning_errno(r, "Failed to reply for DBus method, ignoring: %m"); @@ -1521,6 +1528,7 @@ int link_reconfigure_full(Link *link, LinkReconfigurationFlag flags, sd_bus_mess } *data = (LinkReconfigurationData) { + .manager = link->manager, .link = link_ref(link), .flags = flags, .message = sd_bus_message_ref(message), /* message may be NULL, but _ref() works fine. */ From 2b397d43ab0fac0ec745bee128b6f352b8f44029 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 21 Nov 2024 03:43:32 +0900 Subject: [PATCH 2/2] test-network: actually check metric and preference Otherwise, nexthop ID may contain e.g. 300, then === AssertionError: '300' unexpectedly found in 'default nhid 3860882700 via fe80::1034:56ff:fe78:9a99 proto ra metric 512 expires 1798sec pref high\n default nhid 2639230080 via fe80::1034:56ff:fe78:9a98 proto ra metric 2048 expires 1798sec pref low' === --- test/test-network/systemd-networkd-tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 462d40d839..215f3cb1cc 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -6406,11 +6406,11 @@ class NetworkdRATests(unittest.TestCase, Utilities): for i in [100, 200, 300, 512, 1024, 2048]: if i not in [metric_1, metric_2]: - self.assertNotIn(f'{i}', output) + self.assertNotIn(f'metric {i} ', output) for i in ['low', 'medium', 'high']: if i not in [preference_1, preference_2]: - self.assertNotIn(f'{i}', output) + self.assertNotIn(f'pref {i}', output) def test_router_preference(self): copy_network_unit('25-veth-client.netdev',