X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fnetwork%2Fnetworkd-network.c;h=1606042264b584758f9a7cd7b80076d17c1acc4b;hp=3cbc9aba2634d3424121f0e0983d8fee9295be8e;hb=2ad8416dd057e7e3185169609ca3006e7649f576;hpb=477e73b5312094f2d34de8e40ccbe61e6d4d81e9 diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 3cbc9aba2..160604226 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -29,6 +29,8 @@ static int network_load_one(Manager *manager, const char *filename) { _cleanup_network_free_ Network *network = NULL; _cleanup_fclose_ FILE *file = NULL; + Route *route; + Address *address; int r; assert(manager); @@ -71,6 +73,29 @@ static int network_load_one(Manager *manager, const char *filename) { } LIST_PREPEND(networks, manager->networks, network); + + LIST_FOREACH(static_routes, route, network->static_routes) { + if (!route->family) { + log_warning("Route section without Gateway field configured in %s. " + "Ignoring", filename); + return 0; + } + + if (route->dst_family && route->family != route->dst_family) { + log_warning("Route section with conflicting Gateway and Destination address " + "family configured in %s. Ignoring", filename); + return 0; + } + } + + LIST_FOREACH(static_addresses, address, network->static_addresses) { + if (!address->family) { + log_warning("Address section without Address field configured in %s. " + "Ignoring", filename); + return 0; + } + } + network = NULL; return 0; @@ -87,7 +112,7 @@ int network_load(Manager *manager) { while ((network = manager->networks)) network_free(network); - r = conf_files_list_strv(&files, ".network", NULL, (const char **)manager->network_dirs); + r = conf_files_list_strv(&files, ".network", NULL, network_dirs); if (r < 0) { log_error("Failed to enumerate network files: %s", strerror(-r)); return r; @@ -109,8 +134,6 @@ void network_free(Network *network) { if (!network) return; - assert(network->manager); - free(network->filename); free(network->match_mac); @@ -130,7 +153,7 @@ void network_free(Network *network) { hashmap_free(network->addresses_by_section); hashmap_free(network->routes_by_section); - if (network->manager->networks) + if (network->manager && network->manager->networks) LIST_REMOVE(networks, network->manager->networks, network); free(network);