]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: introduce network_verify_routes()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 2 Oct 2020 01:08:39 +0000 (10:08 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 6 Oct 2020 17:44:42 +0000 (02:44 +0900)
src/network/networkd-network.c
src/network/networkd-route.c
src/network/networkd-route.h

index b9b3ed24d24e319cb1b36ce822f3e56b60e78466..db192cb475c123cdad194e3f5c86a97fe2f1137b 100644 (file)
@@ -156,7 +156,6 @@ static int network_resolve_stacked_netdevs(Network *network) {
 
 int network_verify(Network *network) {
         Address *address, *address_next;
-        Route *route, *route_next;
         TrafficControl *tc;
         SRIOV *sr_iov;
 
@@ -219,6 +218,8 @@ int network_verify(Network *network) {
                                 address_free(address);
                 }
                 if (network->n_static_routes > 0) {
+                        Route *route;
+
                         log_warning("%s: Cannot set routes when Bond= is specified, ignoring routes.",
                                     network->filename);
                         while ((route = network->static_routes))
@@ -298,10 +299,7 @@ int network_verify(Network *network) {
                 if (address_section_verify(address) < 0)
                         address_free(address);
 
-        LIST_FOREACH_SAFE(routes, route, route_next, network->static_routes)
-                if (route_section_verify(route, network) < 0)
-                        route_free(route);
-
+        network_verify_routes(network);
         network_verify_nexthops(network);
         network_verify_fdb_entries(network);
         network_verify_mdb_entries(network);
index ad837099c8e21fedd50f9900ef7fccdbf124bfe8..65ab7f46c121c2ccbd26d3f09d801f1a9a437ebc 100644 (file)
@@ -2162,7 +2162,7 @@ int config_parse_multipath_route(
         return 0;
 }
 
-int route_section_verify(Route *route, Network *network) {
+static int route_section_verify(Route *route, Network *network) {
         if (section_is_invalid(route->section))
                 return -EINVAL;
 
@@ -2202,3 +2202,13 @@ int route_section_verify(Route *route, Network *network) {
 
         return 0;
 }
+
+void network_verify_routes(Network *network) {
+        Route *route, *route_next;
+
+        assert(network);
+
+        LIST_FOREACH_SAFE(routes, route, route_next, network->static_routes)
+                if (route_section_verify(route, network) < 0)
+                        route_free(route);
+}
index 3cff8bba4117fd73ded78a2d5c0ca441a84a711e..42eda8e7621eaefbbd0164d5758b26b6f3fe9291 100644 (file)
@@ -85,12 +85,12 @@ int route_add_foreign(Link *link, Route *in, Route **ret);
 bool route_equal(Route *r1, Route *r2);
 
 int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata);
-int route_section_verify(Route *route, Network *network);
 
 DEFINE_NETWORK_SECTION_FUNCTIONS(Route, route_free);
 
 int network_add_ipv4ll_route(Network *network);
 int network_add_default_route_on_device(Network *network);
+void network_verify_routes(Network *network);
 
 const char* route_type_to_string(int t) _const_;
 int route_type_from_string(const char *s) _pure_;