From 4bec2f237bb714b160cd27edf28764fae658b110 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 27 Feb 2019 18:22:40 +0900 Subject: [PATCH] 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. --- src/network/networkd-network.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index d20f27691d..0eda5b1373 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_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); - 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); + 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; }