]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: relax the .network file check
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 27 Feb 2019 09:22:40 +0000 (18:22 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 28 Feb 2019 01:01:56 +0000 (10:01 +0900)
Previously, if a .networ file contains invalid [Address] or [Route]
section, then the file is completely dropped. This makes networkd
just drops invalid sections.

src/network/networkd-network.c

index d20f27691d3e3639cfa68e7f164340198b9f8f65..0eda5b1373a63a91afafafb3c1e61212edb2a3c7 100644 (file)
@@ -196,8 +196,8 @@ static uint32_t network_get_stacked_netdevs_mtu(Network *network) {
 }
 
 static int network_verify(Network *network) {
-        Address *address;
-        Route *route;
+        Address *address, *address_next;
+        Route *route, *route_next;
         uint32_t mtu;
 
         assert(network);
@@ -284,19 +284,24 @@ static int network_verify(Network *network) {
                 network->dhcp_use_mtu = false;
         }
 
-        LIST_FOREACH(routes, route, network->static_routes)
-                if (!route->family)
-                        return log_warning_errno(SYNTHETIC_ERRNO(EINVAL),
-                                                 "%s: Route section without Gateway field configured. "
-                                                 "Ignoring %s.",
-                                                 network->filename, network->filename);
-
-        LIST_FOREACH(addresses, address, network->static_addresses)
-                if (!address->family)
-                        return log_warning_errno(SYNTHETIC_ERRNO(EINVAL),
-                                                 "%s: Address section without Address field configured. "
-                                                 "Ignoring %s.",
-                                                 network->filename, network->filename);
+        LIST_FOREACH_SAFE(addresses, address, address_next, network->static_addresses)
+                if (address->family == AF_UNSPEC) {
+                        log_warning("%s: Address section without Address= field configured. "
+                                    "Ignoring [Address] section from line %u.",
+                                    network->filename, address->section->line);
+
+                        address_free(address);
+                }
+
+        LIST_FOREACH_SAFE(routes, route, route_next, network->static_routes)
+                if (route->family == AF_UNSPEC) {
+                        log_warning("%s: Route section without Gateway=, Destination=, Source=, "
+                                    "or PreferredSource= field configured. "
+                                    "Ignoring [Route] section from line %u.",
+                                    network->filename, route->section->line);
+
+                        route_free(route);
+                }
 
         return 0;
 }