summaryrefslogtreecommitdiff
path: root/src/network/networkd-address.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-01-01 15:16:10 +0100
committerTom Gundersen <teg@jklm.no>2014-01-01 16:23:00 +0100
commitf048a16b464295a4e0a4f4c1210f06343ad31231 (patch)
tree93441872fc06bbc74d6528e0f52ee42715f84172 /src/network/networkd-address.c
parent407fe036a24834203aca6c1eec7d74d9ad3e9ee0 (diff)
networkd: distinguish between static and dynamic addresses/routes
Static addresses/routes are associated with a network. Dynamic addresses/routes are associtade with links (as the corresponding network may be shared by several links).
Diffstat (limited to 'src/network/networkd-address.c')
-rw-r--r--src/network/networkd-address.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c
index c0cc1287aa..8a71630051 100644
--- a/src/network/networkd-address.c
+++ b/src/network/networkd-address.c
@@ -28,7 +28,7 @@
#include "conf-parser.h"
#include "net-util.h"
-int address_new(Network *network, unsigned section, Address **ret) {
+int address_new_static(Network *network, unsigned section, Address **ret) {
_cleanup_address_free_ Address *address = NULL;
if (section) {
@@ -48,7 +48,7 @@ int address_new(Network *network, unsigned section, Address **ret) {
address->network = network;
- LIST_PREPEND(addresses, network->addresses, address);
+ LIST_PREPEND(static_addresses, network->static_addresses, address);
if (section) {
address->section = section;
@@ -61,15 +61,30 @@ int address_new(Network *network, unsigned section, Address **ret) {
return 0;
}
+int address_new_dynamic(Address **ret) {
+ _cleanup_address_free_ Address *address = NULL;
+
+ address = new0(Address, 1);
+ if (!address)
+ return -ENOMEM;
+
+ *ret = address;
+ address = NULL;
+
+ return 0;
+}
+
void address_free(Address *address) {
if (!address)
return;
- LIST_REMOVE(addresses, address->network->addresses, address);
+ if (address->network) {
+ LIST_REMOVE(static_addresses, address->network->static_addresses, address);
- if (address->section)
- hashmap_remove(address->network->addresses_by_section,
- &address->section);
+ if (address->section)
+ hashmap_remove(address->network->addresses_by_section,
+ &address->section);
+ }
free(address);
}
@@ -203,7 +218,7 @@ int config_parse_address(const char *unit,
section_line = 0;
}
- r = address_new(network, section_line, &n);
+ r = address_new_static(network, section_line, &n);
if (r < 0)
return r;
@@ -266,7 +281,7 @@ int config_parse_label(const char *unit,
assert(rvalue);
assert(data);
- r = address_new(network, section_line, &n);
+ r = address_new_static(network, section_line, &n);
if (r < 0)
return r;