network/route: fix unexpected removal of routes for wireguard

Fixes a bug introduced by 8d01e44c1f.

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.
This commit is contained in:
Yu Watanabe 2024-05-17 06:40:40 +09:00
parent 1cd53a1f91
commit d7769b4d8e

View File

@ -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;
}
}
}