From: Yu Watanabe Date: Mon, 11 Nov 2024 17:03:44 +0000 (+0900) Subject: network/ndisc: introduce route_is_bound_to_link() helper function and use it where... X-Git-Tag: v257-rc2~25^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2437ebee20ed9ce1e789c866728a73f244f80318;p=thirdparty%2Fsystemd.git network/ndisc: introduce route_is_bound_to_link() helper function and use it where applicable No functional change, and preparation for later commits. --- diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index c1d2373f657..3b130ee4ccf 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -2062,7 +2062,7 @@ static int ndisc_drop_outdated(Link *link, const struct in6_addr *router, usec_t if (route->source != NETWORK_CONFIG_SOURCE_NDISC) continue; - if (route->nexthop.ifindex != link->ifindex) + if (!route_is_bound_to_link(route, link)) continue; if (route->protocol == RTPROT_REDIRECT) @@ -2198,7 +2198,7 @@ static int ndisc_setup_expire(Link *link) { if (route->source != NETWORK_CONFIG_SOURCE_NDISC) continue; - if (route->nexthop.ifindex != link->ifindex) + if (!route_is_bound_to_link(route, link)) continue; if (!route_exists(route)) @@ -2436,7 +2436,7 @@ static int ndisc_neighbor_handle_router_message(Link *link, sd_ndisc_neighbor *n if (route->source != NETWORK_CONFIG_SOURCE_NDISC) continue; - if (route->nexthop.ifindex != link->ifindex) + if (!route_is_bound_to_link(route, link)) continue; if (!in6_addr_equal(&route->provider.in6, &original_address)) @@ -2729,7 +2729,7 @@ int link_drop_ndisc_config(Link *link, Network *network) { if (route->source != NETWORK_CONFIG_SOURCE_NDISC) continue; - if (route->nexthop.ifindex != link->ifindex) + if (!route_is_bound_to_link(route, link)) continue; if (route->protocol == RTPROT_REDIRECT) diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 5104223396b..b85d2a037a6 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -352,6 +352,18 @@ static int route_get_link(Manager *manager, const Route *route, Link **ret) { return route_nexthop_get_link(manager, &route->nexthop, ret); } +bool route_is_bound_to_link(const Route *route, Link *link) { + assert(route); + assert(link); + assert(link->manager); + + Link *route_link; + if (route_get_link(link->manager, route, &route_link) < 0) + return false; + + return route_link->ifindex == link->ifindex; +} + int route_get_request(Manager *manager, const Route *route, Request **ret) { Request *req; diff --git a/src/network/networkd-route.h b/src/network/networkd-route.h index f391d957140..b9d2dbf9a6f 100644 --- a/src/network/networkd-route.h +++ b/src/network/networkd-route.h @@ -100,6 +100,7 @@ int route_remove(Route *route, Manager *manager); int route_remove_and_cancel(Route *route, Manager *manager); int route_get(Manager *manager, const Route *route, Route **ret); +bool route_is_bound_to_link(const Route *route, Link *link); int route_get_request(Manager *manager, const Route *route, Request **ret); bool route_can_update(const Route *existing, const Route *requesting);