]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/ndisc: introduce route_is_bound_to_link() helper function and use it where...
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 11 Nov 2024 17:03:44 +0000 (02:03 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 12 Nov 2024 09:08:25 +0000 (18:08 +0900)
No functional change, and preparation for later commits.

src/network/networkd-ndisc.c
src/network/networkd-route.c
src/network/networkd-route.h

index c1d2373f657139be3e93b5af02d2b094fb157924..3b130ee4ccf4d1629ed87fdafef460d3c55bed14 100644 (file)
@@ -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)
index 5104223396bc48670ebd5bfb0bb93ac4076a0f62..b85d2a037a65e62327cba2538cc91d819aabd0eb 100644 (file)
@@ -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;
 
index f391d957140b5e9eff61a0eff383ecfae84af3a2..b9d2dbf9a6f91adb0812dd8fad335aa7695c8931 100644 (file)
@@ -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);