From: Yu Watanabe Date: Wed, 27 Feb 2019 09:22:40 +0000 (+0900) Subject: network: relax the .network file check X-Git-Tag: v242-rc1~229^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4bec2f237bb714b160cd27edf28764fae658b110;p=thirdparty%2Fsystemd.git network: relax the .network file check Previously, if a .networ file contains invalid [Address] or [Route] section, then the file is completely dropped. This makes networkd just drops invalid sections. --- diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index d20f27691d3..0eda5b1373a 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -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; }