summaryrefslogtreecommitdiff
path: root/ubus.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-11-04 01:47:13 +0100
committerFelix Fietkau <nbd@openwrt.org>2011-11-04 01:47:13 +0100
commitb6d7a8bc9822667cb851bec465c3ad7cd6714e90 (patch)
treeaa678109a8dc43e36f77a5a3f5610681e1037370 /ubus.c
parentbb12877893467f7f7f7540e9f9fa7b3bc59e7748 (diff)
downloadnetifd-b6d7a8bc9822667cb851bec465c3ad7cd6714e90.tar.gz
add a hotplug op for preparing an interface bridge so that it's ready when an external process adds interfaces
Diffstat (limited to 'ubus.c')
-rw-r--r--ubus.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/ubus.c b/ubus.c
index ce82a52..af5ba68 100644
--- a/ubus.c
+++ b/ubus.c
@@ -380,10 +380,32 @@ netifd_iface_remove(struct ubus_context *ctx, struct ubus_object *obj,
return 0;
}
+static int
+netifd_handle_iface_prepare(struct ubus_context *ctx, struct ubus_object *obj,
+ struct ubus_request_data *req, const char *method,
+ struct blob_attr *msg)
+{
+ struct interface *iface;
+ struct device *dev;
+ const struct device_hotplug_ops *ops;
+
+ iface = container_of(obj, struct interface, ubus);
+ dev = iface->main_dev.dev;
+ if (!dev)
+ return 0;
+
+ ops = dev->hotplug_ops;
+ if (!ops)
+ return 0;
+
+ return ops->prepare(dev);
+}
+
static struct ubus_method iface_object_methods[] = {
{ .name = "up", .handler = netifd_handle_up },
{ .name = "down", .handler = netifd_handle_down },
{ .name = "status", .handler = netifd_handle_status },
+ { .name = "prepare", .handler = netifd_handle_iface_prepare },
UBUS_METHOD("add_device", netifd_iface_handle_device, dev_policy ),
UBUS_METHOD("remove_device", netifd_iface_handle_device, dev_policy ),
{ .name = "notify_proto", .handler = netifd_iface_notify_proto },