summaryrefslogtreecommitdiffhomepage
path: root/bridge.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 /bridge.c
parentbb12877893467f7f7f7540e9f9fa7b3bc59e7748 (diff)
add a hotplug op for preparing an interface bridge so that it's ready when an external process adds interfaces
Diffstat (limited to 'bridge.c')
-rw-r--r--bridge.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/bridge.c b/bridge.c
index 5ff7081..5337e3a 100644
--- a/bridge.c
+++ b/bridge.c
@@ -65,6 +65,7 @@ struct bridge_state {
struct bridge_config config;
struct blob_attr *ifnames;
bool active;
+ bool force_active;
struct list_head members;
int n_present;
@@ -131,6 +132,7 @@ bridge_remove_member(struct bridge_member *bm)
if (bst->dev.active)
bridge_disable_member(bm);
+ bst->force_active = false;
if (bst->n_present == 0)
device_set_present(&bst->dev, false);
}
@@ -190,7 +192,7 @@ bridge_set_up(struct bridge_state *bst)
struct bridge_member *bm;
int ret;
- if (!bst->n_present)
+ if (!bst->force_active && !bst->n_present)
return -ENOENT;
ret = system_bridge_addbr(&bst->dev, &bst->config);
@@ -200,7 +202,7 @@ bridge_set_up(struct bridge_state *bst)
list_for_each_entry(bm, &bst->members, list)
bridge_enable_member(bm);
- if (!bst->n_present) {
+ if (!bst->force_active && !bst->n_present) {
/* initialization of all member interfaces failed */
system_bridge_delbr(&bst->dev);
device_set_present(&bst->dev, false);
@@ -289,10 +291,23 @@ bridge_hotplug_del(struct device *dev, struct device *member)
return 0;
}
- return -ENOENT;
+ return UBUS_STATUS_NOT_FOUND;
+}
+
+static int
+bridge_hotplug_prepare(struct device *dev)
+{
+ struct bridge_state *bst;
+
+ bst = container_of(dev, struct bridge_state, dev);
+ bst->force_active = true;
+ device_set_present(&bst->dev, true);
+
+ return 0;
}
static const struct device_hotplug_ops bridge_ops = {
+ .prepare = bridge_hotplug_prepare,
.add = bridge_hotplug_add,
.del = bridge_hotplug_del
};