summaryrefslogtreecommitdiff
path: root/src/network/networkd-manager.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-09-23 01:53:29 +0200
committerTom Gundersen <teg@jklm.no>2015-10-11 15:04:16 +0200
commitcf1d700da3fe04cd4c27980a292301694be3b05f (patch)
tree1637158da3463b4f94a6522818fd941c95e6cfc4 /src/network/networkd-manager.c
parent200a0868fcdf7b95f3d8d1fda3aa2aef48d84fdd (diff)
networkd: address - store active addresses in a Set rather than a List
We need to be able to look these things up quickly as we will be updating them continuously and there can in principle be many of them.
Diffstat (limited to 'src/network/networkd-manager.c')
-rw-r--r--src/network/networkd-manager.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index 3a733dc3c3..30cb502bed 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -283,7 +283,7 @@ int manager_rtnl_process_address(sd_netlink *rtnl, sd_netlink_message *message,
uint16_t type;
_cleanup_address_free_ Address *address = NULL;
unsigned char flags;
- Address *existing;
+ Address *existing = NULL;
char buf[INET6_ADDRSTRLEN], valid_buf[FORMAT_TIMESPAN_MAX];
const char *valid_str = NULL;
int r, ifindex;
@@ -394,7 +394,7 @@ int manager_rtnl_process_address(sd_netlink *rtnl, sd_netlink_message *message,
USEC_PER_SEC);
}
- existing = link_get_equal_address(link, address);
+ address_get(link, address->family, &address->in_addr, address->prefixlen, &existing);
switch (type) {
case RTM_NEWADDR:
@@ -407,9 +407,14 @@ int manager_rtnl_process_address(sd_netlink *rtnl, sd_netlink_message *message,
existing->cinfo = address->cinfo;
} else {
- log_link_debug(link, "Adding address: %s/%u (valid for %s)", buf, address->prefixlen, valid_str);
+ r = address_add(link, address);
+ if (r < 0) {
+ log_link_warning_errno(link, r, "Failed to add address %s/%u: %m", buf, address->prefixlen);
+ return 0;
+ } else
+ log_link_debug(link, "Adding address: %s/%u (valid for %s)", buf, address->prefixlen, valid_str);
+
- LIST_PREPEND(addresses, link->addresses, address);
address_establish(address, link);
address = NULL;
@@ -424,7 +429,6 @@ int manager_rtnl_process_address(sd_netlink *rtnl, sd_netlink_message *message,
if (existing) {
log_link_debug(link, "Removing address: %s/%u (valid for %s)", buf, address->prefixlen, valid_str);
address_release(existing, link);
- LIST_REMOVE(addresses, link->addresses, existing);
address_free(existing);
} else
log_link_warning(link, "Removing non-existent address: %s/%u (valid for %s)", buf, address->prefixlen, valid_str);