summaryrefslogtreecommitdiff
path: root/src/network/networkd-link.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-link.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-link.c')
-rw-r--r--src/network/networkd-link.c37
1 files changed, 13 insertions, 24 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index fe701d8c84..eb03d72907 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -23,15 +23,16 @@
#include <linux/if.h>
#include <unistd.h>
-#include "util.h"
-#include "virt.h"
-#include "fileio.h"
-#include "socket-util.h"
#include "bus-util.h"
-#include "udev-util.h"
-#include "netlink-util.h"
#include "dhcp-lease-internal.h"
+#include "fileio.h"
+#include "netlink-util.h"
#include "network-internal.h"
+#include "set.h"
+#include "socket-util.h"
+#include "udev-util.h"
+#include "util.h"
+#include "virt.h"
#include "networkd-link.h"
#include "networkd-netdev.h"
@@ -291,10 +292,10 @@ static void link_free(Link *link) {
if (!link)
return;
- while ((address = link->addresses)) {
- LIST_REMOVE(addresses, link->addresses, address);
- address_free(address);
- }
+ while (!set_isempty(link->addresses))
+ address_free(set_first(link->addresses));
+
+ set_free(link->addresses);
while ((address = link->pool_addresses)) {
LIST_REMOVE(addresses, link->pool_addresses, address);
@@ -2024,19 +2025,6 @@ int link_initialized(Link *link, struct udev_device *device) {
return 0;
}
-Address* link_get_equal_address(Link *link, Address *needle) {
- Address *i;
-
- assert(link);
- assert(needle);
-
- LIST_FOREACH(addresses, i, link->addresses)
- if (address_equal(i, needle))
- return i;
-
- return NULL;
-}
-
int link_add(Manager *m, sd_netlink_message *message, Link **ret) {
Link *link;
_cleanup_udev_device_unref_ struct udev_device *device = NULL;
@@ -2283,9 +2271,10 @@ static void link_update_operstate(Link *link) {
else if (link_has_carrier(link)) {
Address *address;
uint8_t scope = RT_SCOPE_NOWHERE;
+ Iterator i;
/* if we have carrier, check what addresses we have */
- LIST_FOREACH(addresses, address, link->addresses) {
+ SET_FOREACH(address, link->addresses, i) {
if (address->flags & (IFA_F_TENTATIVE | IFA_F_DEPRECATED))
continue;