summaryrefslogtreecommitdiff
path: root/src/network/networkd-network.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2013-11-19 16:54:42 +0100
committerTom Gundersen <teg@jklm.no>2013-11-25 19:35:44 +0100
commit6ae115c1fe95611b39d2f20cfcea3d385429f59e (patch)
tree98b548db167fa6afda6635310d944c6406d7226c /src/network/networkd-network.c
parent71a6151083d842b2f5bf04e50239f0bf85d34d2e (diff)
networkd: add support for [Address] sections
This will allow specifying more options per address than the simple Address= entry in the [Network] section. Preliminary support for the same functionality for [Route] sections are added, but not yet hooked up, as more testing is needed.
Diffstat (limited to 'src/network/networkd-network.c')
-rw-r--r--src/network/networkd-network.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 7be9645d59..dc2af9dd24 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -45,8 +45,21 @@ static int network_load_one(Manager *manager, const char *filename) {
network->manager = manager;
LIST_HEAD_INIT(network->addresses);
+ LIST_HEAD_INIT(network->routes);
- r = config_parse(NULL, filename, file, "Match\0Network\0", config_item_perf_lookup,
+ network->addresses_by_section = hashmap_new(uint64_hash_func, uint64_compare_func);
+ if (!network->addresses_by_section)
+ return log_oom();
+
+ network->routes_by_section = hashmap_new(uint64_hash_func, uint64_compare_func);
+ if (!network->routes_by_section)
+ return log_oom();
+
+ network->filename = strdup(filename);
+ if (!network->filename)
+ return log_oom();
+
+ r = config_parse(NULL, filename, file, "Match\0Network\0Address\0Route\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));
@@ -54,10 +67,6 @@ static int network_load_one(Manager *manager, const char *filename) {
} else
log_debug("Parsed configuration file %s", filename);
- network->filename = strdup(filename);
- if (!network->filename)
- return log_oom();
-
LIST_PREPEND(networks, manager->networks, network);
network = NULL;
@@ -121,6 +130,9 @@ void network_free(Network *network) {
while ((address = network->addresses))
address_free(address);
+ hashmap_free(network->addresses_by_section);
+ hashmap_free(network->routes_by_section);
+
LIST_REMOVE(networks, network->manager->networks, network);
free(network);