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);
if (!network->filename)
return log_oom();
- r = config_parse(NULL, filename, file, "Match\0Network\0Address\0Route\0", config_item_perf_lookup,
+ network->dhcp_dns = true;
+
+ r = config_parse(NULL, filename, file, "Match\0Network\0Address\0Route\0DHCPv4\0", config_item_perf_lookup,
(void*) network_gperf_lookup, false, false, network);
if (r < 0) {
log_warning("Could not parse config file %s: %s", filename, strerror(-r));
}
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;
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;
if (!network)
return;
- assert(network->manager);
-
free(network->filename);
free(network->match_mac);
free(network->description);
+ address_free(network->dns);
+
while ((route = network->static_routes))
route_free(route);
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);
assert(device);
assert(ret);
- if (manager_should_reload(manager))
- manager_load_config(manager);
-
LIST_FOREACH(networks, network, manager->networks) {
if (net_match_config(network->match_mac, network->match_path,
network->match_driver, network->match_type,
if (r < 0)
return r;
+ if (network->dns) {
+ r = manager_update_resolv_conf(manager);
+ if (r < 0)
+ return r;
+ }
+
return 0;
}