From d7769b4d8ea5ed601b79d8708d360f5c83bd39e9 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 17 May 2024 06:40:40 +0900 Subject: [PATCH 1/2] network/route: fix unexpected removal of routes for wireguard Fixes a bug introduced by 8d01e44c1f0e00b414d36bd1b46ecff548242208. If a .netdev file for a wireguard interface requests to configure routes for the interface, the routes were removed during configuring another interface. Fixes #32859. --- src/network/networkd-route.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index a4c56f1bbd..3e0b25ff3d 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -1430,16 +1430,16 @@ static int link_mark_routes(Link *link, bool foreign) { } } } - } - /* Also unmark routes requested in .netdev file. */ - if (foreign && link->netdev && link->netdev->kind == NETDEV_KIND_WIREGUARD) { - Wireguard *w = WIREGUARD(link->netdev); + /* Also unmark routes requested in .netdev file. */ + if (other->netdev && other->netdev->kind == NETDEV_KIND_WIREGUARD) { + Wireguard *w = WIREGUARD(other->netdev); - SET_FOREACH(route, w->routes) { - r = link_unmark_route(link, route, NULL); - if (r < 0) - return r; + SET_FOREACH(route, w->routes) { + r = link_unmark_route(other, route, NULL); + if (r < 0) + return r; + } } } From cd6507538a5bd233c94b46c3aba328abc216154c Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 17 May 2024 09:28:46 +0900 Subject: [PATCH 2/2] test-network: use different destination from gateway Previously, one of the test route has the same address in destination and gateway. Even it is a test case, that's super spurious. Let's use a different address. --- test/test-network/conf/25-route-static.network | 2 +- test/test-network/systemd-networkd-tests.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test-network/conf/25-route-static.network b/test/test-network/conf/25-route-static.network index 7ef211d410..5ddd7de61a 100644 --- a/test/test-network/conf/25-route-static.network +++ b/test/test-network/conf/25-route-static.network @@ -96,7 +96,7 @@ MultiPathRoute=149.10.124.59 10 MultiPathRoute=149.10.124.60 5 [Route] -Destination=2001:1234:5:7fff:ff:ff:ff:ff/128 +Destination=2001:1234:5:bfff:ff:ff:ff:ff/128 MultiPathRoute=2001:1234:5:6fff:ff:ff:ff:ff@test1 20 MultiPathRoute=2001:1234:5:7fff:ff:ff:ff:ff@test1 30 MultiPathRoute=2001:1234:5:8fff:ff:ff:ff:ff@dummy98 10 diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 6e7ce7cbd8..6b1633a961 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -3445,11 +3445,11 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities): self.assertIn('dev dummy98 weight 10', output) self.assertIn('dev dummy98 weight 5', output) - print('### ip -6 route show 2001:1234:5:7fff:ff:ff:ff:ff') - output = check_output('ip -6 route show 2001:1234:5:7fff:ff:ff:ff:ff') + print('### ip -6 route show 2001:1234:5:bfff:ff:ff:ff:ff') + output = check_output('ip -6 route show 2001:1234:5:bfff:ff:ff:ff:ff') print(output) # old ip command does not show 'nexthop' keyword and weight... - self.assertIn('2001:1234:5:7fff:ff:ff:ff:ff', output) + self.assertIn('2001:1234:5:bfff:ff:ff:ff:ff', output) self.assertIn('via 2001:1234:5:6fff:ff:ff:ff:ff dev test1', output) self.assertIn('via 2001:1234:5:7fff:ff:ff:ff:ff dev test1', output) self.assertIn('via 2001:1234:5:8fff:ff:ff:ff:ff dev dummy98', output)