summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-11-11 18:03:44 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-11-12 10:08:25 +0100
commit2437ebee20ed9ce1e789c866728a73f244f80318 (patch)
treeefd71cec06b7a1b48645411ac69918d8cdba99f5 /src/network
parentman/systemd-keyutil: fix rendering typo (diff)
downloadsystemd-2437ebee20ed9ce1e789c866728a73f244f80318.tar.xz
systemd-2437ebee20ed9ce1e789c866728a73f244f80318.zip
network/ndisc: introduce route_is_bound_to_link() helper function and use it where applicable
No functional change, and preparation for later commits.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/networkd-ndisc.c8
-rw-r--r--src/network/networkd-route.c12
-rw-r--r--src/network/networkd-route.h1
3 files changed, 17 insertions, 4 deletions
diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c
index c1d2373f65..3b130ee4cc 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 5104223396..b85d2a037a 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 f391d95714..b9d2dbf9a6 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);