network/route: use NetDev object assigned to Link

This commit is contained in:
Yu Watanabe
2024-09-10 16:38:07 +09:00
parent 1788c34628
commit 72fd133dca
+2 -6
View File
@@ -1008,19 +1008,15 @@ static int static_route_handler(sd_netlink *rtnl, sd_netlink_message *m, Request
}
static int link_request_wireguard_routes(Link *link, bool only_ipv4) {
NetDev *netdev;
Route *route;
int r;
assert(link);
if (!streq_ptr(link->kind, "wireguard"))
if (!link->netdev || link->netdev->kind != NETDEV_KIND_WIREGUARD)
return 0;
if (netdev_get(link->manager, link->ifname, &netdev) < 0)
return 0;
Wireguard *w = WIREGUARD(netdev);
Wireguard *w = WIREGUARD(link->netdev);
SET_FOREACH(route, w->routes) {
if (only_ipv4 && route->family != AF_INET)