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.
This commit is contained in:
Yu Watanabe
2019-02-28 10:01:56 +09:00
parent 9cb8c55934
commit 4bec2f237b
+19 -14
View 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_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;
}