_cleanup_(route_unrefp) Route *route = NULL;
struct in_addr gw;
- if (!rt->gateway_from_dhcp_or_ra)
- continue;
-
- if (rt->nexthop.family != AF_INET)
+ if (rt->source != NETWORK_CONFIG_SOURCE_DHCP4)
continue;
assert(rt->family == AF_INET);
+ assert(rt->nexthop.family == AF_INET);
r = dhcp4_find_gateway_for_destination(link, &rt->dst.in, rt->dst_prefixlen, &gw);
if (r == -EHOSTUNREACH) {
HASHMAP_FOREACH(route_gw, link->network->routes_by_section) {
_cleanup_(route_unrefp) Route *tmp = NULL;
- if (!route_gw->gateway_from_dhcp_or_ra)
+ if (route_gw->source != NETWORK_CONFIG_SOURCE_NDISC)
continue;
- if (route_gw->nexthop.family != AF_INET6)
- continue;
+ assert(route_gw->nexthop.family == AF_INET6);
r = route_dup(route_gw, NULL, &tmp);
if (r < 0)
HASHMAP_FOREACH(route_gw, link->network->routes_by_section) {
_cleanup_(route_unrefp) Route *route = NULL;
- if (!route_gw->gateway_from_dhcp_or_ra)
+ if (route_gw->source != NETWORK_CONFIG_SOURCE_NDISC)
continue;
- if (route_gw->nexthop.family != AF_INET6)
- continue;
+ assert(route_gw->nexthop.family == AF_INET6);
r = route_dup(route_gw, NULL, &route);
if (r < 0)
return log_route_section(route, "Invalid route family.");
}
- if (route->nexthop.family == AF_INET && !FLAGS_SET(route->network->dhcp, ADDRESS_FAMILY_IPV4))
- return log_route_section(route, "Gateway=\"_dhcp4\" is specified but DHCPv4 client is disabled.");
+ switch (route->nexthop.family) {
+ case AF_INET:
+ if (!FLAGS_SET(route->network->dhcp, ADDRESS_FAMILY_IPV4))
+ return log_route_section(route, "Gateway=\"_dhcp4\" is specified but DHCPv4 client is disabled.");
- if (route->nexthop.family == AF_INET6 && route->network->ndisc == 0)
- return log_route_section(route, "Gateway=\"_ipv6ra\" is specified but IPv6AcceptRA= is disabled.");
+ route->source = NETWORK_CONFIG_SOURCE_DHCP4;
+ break;
+
+ case AF_INET6:
+ if (route->network->ndisc == 0)
+ return log_route_section(route, "Gateway=\"_ipv6ra\" is specified but IPv6AcceptRA= is disabled.");
+
+ route->source = NETWORK_CONFIG_SOURCE_NDISC;
+ break;
+
+ default:
+ assert_not_reached();
+ }
}
/* When only Gateway= is specified, assume the route family based on the Gateway address. */
link->static_routes_configured = false;
HASHMAP_FOREACH(route, link->network->routes_by_section) {
- if (route->gateway_from_dhcp_or_ra)
+ if (route->source != NETWORK_CONFIG_SOURCE_STATIC)
continue;
if (only_ipv4 && route->family != AF_INET)
continue;
HASHMAP_FOREACH(route, other->network->routes_by_section) {
+ if (route->source != NETWORK_CONFIG_SOURCE_STATIC)
+ continue;
+
if (route->family == AF_INET || ordered_set_isempty(route->nexthops)) {
r = link_unmark_route(other, route, NULL);
if (r < 0)