]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: do not serialize/deserialize routes
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 28 Oct 2020 06:41:33 +0000 (15:41 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 28 Oct 2020 09:16:01 +0000 (18:16 +0900)
The same as the previous commit. These are not used.

src/network/networkd-link.c
src/network/networkd-route.c
src/network/networkd-route.h

index 5db118e77eb34b2e7cef296c3e01971b2df3bfbd..6b6f772c889f5a4300aac4b2ada00b743751da2a 100644 (file)
@@ -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);
index 4c3704b328fd345af7f887809ad5b35b6c090a53..2408981b6b9d584a0bfd4b64fc44c743336d9ad2 100644 (file)
@@ -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;
index e896719e13b794526b6cad099aab5a82069607d8..b5193383c09ae037fbde81f20423af14d52f76cc 100644 (file)
@@ -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);