network_apply_anonymize_if_set(network);
+ r = network_add_ipv4ll_route(network);
+ if (r < 0)
+ log_warning_errno(r, "%s: Failed to add IPv4LL route, ignoring: %m", network->filename);
+
LIST_PREPEND(networks, manager->networks, network);
network->manager = manager;
}
int network_apply(Network *network, Link *link) {
- int r;
-
assert(network);
assert(link);
link->network = network;
- if (network->ipv4ll_route) {
- Route *route;
-
- r = route_new_static(network, NULL, 0, &route);
- if (r < 0)
- return r;
-
- r = inet_pton(AF_INET, "169.254.0.0", &route->dst.in);
- if (r == 0)
- return -EINVAL;
- if (r < 0)
- return -errno;
-
- route->family = AF_INET;
- route->dst_prefixlen = 16;
- route->scope = RT_SCOPE_LINK;
- route->priority = IPV4LL_ROUTE_METRIC;
- route->protocol = RTPROT_STATIC;
- }
-
if (network->n_dns > 0 ||
!strv_isempty(network->ntp) ||
!ordered_set_isempty(network->search_domains) ||
return 0;
}
+int network_add_ipv4ll_route(Network *network) {
+ _cleanup_(route_freep) Route *n = NULL;
+ int r;
+
+ assert(network);
+
+ if (!network->ipv4ll_route)
+ return 0;
+
+ /* IPv4LLRoute= is in [Network] section. */
+ r = route_new_static(network, NULL, 0, &n);
+ if (r < 0)
+ return r;
+
+ r = in_addr_from_string(AF_INET, "169.254.0.0", &n->dst);
+ if (r < 0)
+ return r;
+
+ n->family = AF_INET;
+ n->dst_prefixlen = 16;
+ n->scope = RT_SCOPE_LINK;
+ n->priority = IPV4LL_ROUTE_METRIC;
+ n->protocol = RTPROT_STATIC;
+
+ TAKE_PTR(n);
+ return 0;
+}
+
int config_parse_gateway(
const char *unit,
const char *filename,
DEFINE_TRIVIAL_CLEANUP_FUNC(Route*, route_free);
+int network_add_ipv4ll_route(Network *network);
+
CONFIG_PARSER_PROTOTYPE(config_parse_gateway);
CONFIG_PARSER_PROTOTYPE(config_parse_preferred_src);
CONFIG_PARSER_PROTOTYPE(config_parse_destination);