summaryrefslogtreecommitdiffstats
path: root/discover
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-09-19 21:55:06 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-09-19 21:55:06 +0800
commit4400b62c78526cf744d2aec3fba86911da936f7a (patch)
tree0ed3611e2528b0535d4559ed28f3a93f35ff1faf /discover
parent3325aa09f31b4cc145ab8abfed44ab5f3b6a7b96 (diff)
downloadtalos-petitboot-4400b62c78526cf744d2aec3fba86911da936f7a.tar.gz
talos-petitboot-4400b62c78526cf744d2aec3fba86911da936f7a.zip
discover/network: Manage network->interfaces with {add,remove}_interface
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover')
-rw-r--r--discover/network.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/discover/network.c b/discover/network.c
index 2d606e4..eaf6d1b 100644
--- a/discover/network.c
+++ b/discover/network.c
@@ -138,6 +138,18 @@ static int network_send_link_query(struct network *network)
return 0;
}
+static void add_interface(struct network *network,
+ struct interface *interface)
+{
+ list_add(&network->interfaces, &interface->list);
+}
+
+static void remove_interface(struct interface *interface)
+{
+ list_remove(&interface->list);
+ talloc_free(interface);
+}
+
static int interface_change(struct interface *interface, bool up)
{
const char *statestr = up ? "up" : "down";
@@ -371,8 +383,7 @@ static int network_handle_nlmsg(struct network *network, struct nlmsghdr *nlmsg)
if (!interface)
return 0;
pb_log("network: interface %s removed\n", interface->name);
- list_remove(&interface->list);
- talloc_free(interface);
+ remove_interface(interface);
return 0;
}
@@ -384,6 +395,7 @@ static int network_handle_nlmsg(struct network *network, struct nlmsghdr *nlmsg)
interface->state = IFSTATE_NEW;
memcpy(interface->hwaddr, ifaddr, sizeof(interface->hwaddr));
strncpy(interface->name, ifname, sizeof(interface->name) - 1);
+ add_interface(network, interface);
}
configure_interface(network, interface,
OpenPOWER on IntegriCloud