From b9f29e9f52e24b8200220b4f9c79a65266475c3c Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 13 Jan 2024 10:05:29 +0900 Subject: [PATCH] network/route: relocate route_type_is_reject() and friends No functional change, preparation for later commits. --- src/network/networkd-route-util.c | 6 ++++++ src/network/networkd-route-util.h | 2 ++ src/network/networkd-route.c | 18 ++++++------------ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/network/networkd-route-util.c b/src/network/networkd-route-util.c index d49a0b9512..00c267e692 100644 --- a/src/network/networkd-route-util.c +++ b/src/network/networkd-route-util.c @@ -39,6 +39,12 @@ unsigned routes_max(void) { return cached; } +bool route_type_is_reject(const Route *route) { + assert(route); + + return IN_SET(route->type, RTN_UNREACHABLE, RTN_PROHIBIT, RTN_BLACKHOLE, RTN_THROW); +} + static bool route_lifetime_is_valid(const Route *route) { assert(route); diff --git a/src/network/networkd-route-util.h b/src/network/networkd-route-util.h index f326888c93..eba823a2d0 100644 --- a/src/network/networkd-route-util.h +++ b/src/network/networkd-route-util.h @@ -13,6 +13,8 @@ typedef struct Route Route; unsigned routes_max(void); +bool route_type_is_reject(const Route *route); + bool link_find_default_gateway(Link *link, int family, Route **gw); static inline bool link_has_default_gateway(Link *link, int family) { return link_find_default_gateway(link, family, NULL); diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index e5d1baf945..e890d0a2e9 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -235,18 +235,6 @@ DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR( route_compare_func, route_free); -static bool route_type_is_reject(const Route *route) { - assert(route); - - return IN_SET(route->type, RTN_UNREACHABLE, RTN_PROHIBIT, RTN_BLACKHOLE, RTN_THROW); -} - -static bool route_needs_convert(const Route *route) { - assert(route); - - return route->nexthop_id > 0 || !ordered_set_isempty(route->multipath_routes); -} - static int route_add(Manager *manager, Link *link, Route *route) { int r; @@ -427,6 +415,12 @@ static int converted_routes_new(size_t n, ConvertedRoutes **ret) { return 0; } +static bool route_needs_convert(const Route *route) { + assert(route); + + return route->nexthop_id > 0 || !ordered_set_isempty(route->multipath_routes); +} + static int route_convert(Manager *manager, const Route *route, ConvertedRoutes **ret) { _cleanup_(converted_routes_freep) ConvertedRoutes *c = NULL; int r; -- 2.25.1