diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 5db118e77e..6b6f772c88 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -2412,15 +2412,13 @@ int link_initialized(Link *link, sd_device *device) { } 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); @@ -2432,14 +2430,14 @@ static int link_load(Link *link) { 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); @@ -2447,12 +2445,6 @@ static int link_load(Link *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; } @@ -3130,12 +3122,6 @@ int link_save(Link *link) { 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); diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 4c3704b328..2408981b6b 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -1591,84 +1591,6 @@ int manager_rtnl_process_route(sd_netlink *rtnl, sd_netlink_message *message, Ma 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; diff --git a/src/network/networkd-route.h b/src/network/networkd-route.h index e896719e13..b5193383c0 100644 --- a/src/network/networkd-route.h +++ b/src/network/networkd-route.h @@ -75,8 +75,6 @@ int route_remove(const Route *route, Manager *manager, Link *link, link_netlink_ 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);