route_nexthop_free);
static size_t route_n_nexthops(const Route *route) {
- if (route->nexthop_id != 0 || route_type_is_reject(route))
+ if (route->nexthop_id != 0 || route_is_reject(route))
return 0;
if (ordered_set_isempty(route->nexthops))
assert(src);
assert(dest);
- if (src->nexthop_id != 0 || route_type_is_reject(src))
+ if (src->nexthop_id != 0 || route_is_reject(src))
return 0;
if (nh)
* Hence, we cannot know if the nexthop is blackhole or not. */
return route->type != RTN_BLACKHOLE;
- if (route_type_is_reject(route))
+ if (route_is_reject(route))
return false;
if (ordered_set_isempty(route->nexthops))
return true; /* updated */
}
- if (route_type_is_reject(route))
+ if (route_is_reject(route))
return false;
if (ordered_set_isempty(route->nexthops))
return true;
}
- if (route_type_is_reject(route))
+ if (route_is_reject(route))
return true;
if (ordered_set_isempty(route->nexthops))
return 0;
}
- if (route_type_is_reject(route)) {
+ if (route_is_reject(route)) {
buf = strdup("gw: n/a");
if (!buf)
return -ENOMEM;
if (route->nexthop_id != 0)
return sd_netlink_message_append_u32(message, RTA_NH_ID, route->nexthop_id);
- if (route_type_is_reject(route))
+ if (route_is_reject(route))
return 0;
/* We request IPv6 multipath routes separately. Even though, if weight is non-zero, we need to use
if (r < 0 && r != -ENODATA)
return log_warning_errno(r, "rtnl: received route message with invalid nexthop id, ignoring: %m");
- if (route->nexthop_id != 0 || route_type_is_reject(route))
+ if (route->nexthop_id != 0 || route_is_reject(route))
/* IPv6 routes with reject type are always assigned to the loopback interface. See kernel's
* fib6_nh_init() in net/ipv6/route.c. However, we'd like to make it consistent with IPv4
* routes. Hence, skip reading of RTA_OIF. */
"Ignoring [Route] section from line %u.",
route->section->filename, route->section->line);
- if (route_type_is_reject(route) &&
+ if (route_is_reject(route) &&
(route->gateway_from_dhcp_or_ra ||
in_addr_is_set(route->nexthop.family, &route->nexthop.gw) ||
!ordered_set_isempty(route->nexthops)))
return cached;
}
-bool route_type_is_reject(const Route *route) {
- assert(route);
+bool route_type_is_reject(uint8_t type) {
+ return IN_SET(type, RTN_UNREACHABLE, RTN_PROHIBIT, RTN_BLACKHOLE, RTN_THROW);
+}
- return IN_SET(route->type, RTN_UNREACHABLE, RTN_PROHIBIT, RTN_BLACKHOLE, RTN_THROW);
+bool route_is_reject(const Route *route) {
+ return route_type_is_reject(ASSERT_PTR(route)->type);
}
static bool route_lifetime_is_valid(const Route *route) {