summaryrefslogtreecommitdiffstats
path: root/discover/device-handler.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2014-07-21 15:51:58 +0800
committerJeremy Kerr <jk@ozlabs.org>2014-07-21 17:20:08 +0800
commit0adfe11dc0738321cdd529f30773899cc8f79855 (patch)
treef456887c66a18679f27940d34082bde40e9c3857 /discover/device-handler.c
parent20889c61bc0e6712c1cac5a0a6e9e8e9dff7cf84 (diff)
downloadtalos-petitboot-0adfe11dc0738321cdd529f30773899cc8f79855.tar.gz
talos-petitboot-0adfe11dc0738321cdd529f30773899cc8f79855.zip
discover: allow separate lifetimes for network interfaces and discover devices
We want the network code's network interfaces to (potentially) persist remove events. For example, discover devices may be removed by a user event (this happens during a udhcpc deconfig). In this case, we want the boot options to be removed, but the struct interface needs to stay present. This change adds network_(un)_register_device functions, to allow the device handler to detach from and attach to interfaces. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover/device-handler.c')
-rw-r--r--discover/device-handler.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index c21eb28..7f7081d 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -344,6 +344,11 @@ void device_handler_remove(struct device_handler *handler,
talloc_free(opt);
}
+ /* if this is a network device, we have to unregister it from the
+ * network code */
+ if (device->device->type == DEVICE_TYPE_NETWORK)
+ network_unregister_device(handler->network, device);
+
handler->n_devices--;
memmove(&handler->devices[i], &handler->devices[i + 1],
(handler->n_devices - i) * sizeof(handler->devices[0]));
@@ -646,6 +651,8 @@ void device_handler_add_device(struct device_handler *handler,
struct discover_device *, handler->n_devices);
handler->devices[handler->n_devices - 1] = device;
+ if (device->device->type == DEVICE_TYPE_NETWORK)
+ network_register_device(handler->network, device);
}
/* Start discovery on a hotplugged device. The device will be in our devices
OpenPOWER on IntegriCloud