The same as the previous commit. These are not used.
}
static int link_load(Link *link) {
- _cleanup_free_ char *network_file = NULL,
- *routes = NULL;
+ _cleanup_free_ char *network_file = NULL;
int r;
assert(link);
r = parse_env_file(NULL, link->state_file,
- "NETWORK_FILE", &network_file,
- "ROUTES", &routes);
+ "NETWORK_FILE", &network_file);
if (r < 0 && r != -ENOENT)
return log_link_error_errno(link, r, "Failed to read %s: %m", link->state_file);
suffix = strrchr(network_file, '.');
if (!suffix) {
log_link_debug(link, "Failed to get network name from %s", network_file);
- goto network_file_fail;
+ return 0;
}
*suffix = '\0';
r = network_get_by_name(link->manager, basename(network_file), &network);
if (r < 0) {
log_link_debug_errno(link, r, "Failed to get network %s: %m", basename(network_file));
- goto network_file_fail;
+ return 0;
}
r = network_apply(network, link);
return log_link_error_errno(link, r, "Failed to apply network %s: %m", basename(network_file));
}
-network_file_fail:
-
- r = link_deserialize_routes(link, routes);
- if (r < 0)
- log_link_warning_errno(link, r, "Failed to load routes from %s, ignoring: %m", link->state_file);
-
return 0;
}
fputs_with_space(f, n, NULL, &space);
fputc('\n', f);
}
-
- /************************************************************/
-
- r = link_serialize_routes(link, f);
- if (r < 0)
- goto fail;
}
print_link_hashmap(f, "CARRIER_BOUND_TO=", link->bound_to_links);
return 1;
}
-int link_serialize_routes(const Link *link, FILE *f) {
- bool space = false;
- Route *route;
-
- assert(link);
- assert(link->network);
- assert(f);
-
- fputs("ROUTES=", f);
- SET_FOREACH(route, link->routes) {
- _cleanup_free_ char *route_str = NULL;
-
- if (in_addr_to_string(route->family, &route->dst, &route_str) < 0)
- continue;
-
- fprintf(f, "%s%s/%hhu/%hhu/%"PRIu32"/%"PRIu32"/"USEC_FMT,
- space ? " " : "", route_str,
- route->dst_prefixlen, route->tos, route->priority, route->table, route->lifetime);
- space = true;
- }
- fputc('\n', f);
-
- return 0;
-}
-
-int link_deserialize_routes(Link *link, const char *routes) {
- int r;
-
- assert(link);
-
- for (const char *p = routes;; ) {
- _cleanup_(route_freep) Route *tmp = NULL;
- _cleanup_free_ char *route_str = NULL;
- char *prefixlen_str;
-
- r = extract_first_word(&p, &route_str, NULL, 0);
- if (r < 0)
- return log_link_debug_errno(link, r, "Failed to parse ROUTES=: %m");
- if (r == 0)
- return 0;
-
- prefixlen_str = strchr(route_str, '/');
- if (!prefixlen_str) {
- log_link_debug(link, "Failed to parse route, ignoring: %s", route_str);
- continue;
- }
- *prefixlen_str++ = '\0';
-
- r = route_new(&tmp);
- if (r < 0)
- return log_oom();
-
- r = sscanf(prefixlen_str,
- "%hhu/%hhu/%"SCNu32"/%"PRIu32"/"USEC_FMT,
- &tmp->dst_prefixlen,
- &tmp->tos,
- &tmp->priority,
- &tmp->table,
- &tmp->lifetime);
- if (r != 5) {
- log_link_debug(link,
- "Failed to parse destination prefix length, tos, priority, table or expiration: %s",
- prefixlen_str);
- continue;
- }
-
- r = in_addr_from_string_auto(route_str, &tmp->family, &tmp->dst);
- if (r < 0) {
- log_link_debug_errno(link, r, "Failed to parse route destination %s: %m", route_str);
- continue;
- }
-
- r = route_add_and_setup_timer(link, tmp, NULL, NULL);
- if (r < 0)
- return log_link_debug_errno(link, r, "Failed to add route: %m");
- }
-}
-
int network_add_ipv4ll_route(Network *network) {
_cleanup_(route_free_or_set_invalidp) Route *n = NULL;
unsigned section_line;
int link_set_routes(Link *link);
int link_drop_routes(Link *link);
int link_drop_foreign_routes(Link *link);
-int link_serialize_routes(const Link *link, FILE *f);
-int link_deserialize_routes(Link *link, const char *routes);
uint32_t link_get_dhcp_route_table(const Link *link);
uint32_t link_get_ipv6_accept_ra_route_table(const Link *link);