From 5a2ccd7b750162b0d6ee13609f7e1ed5ea827d9d Mon Sep 17 00:00:00 2001 From: Luka Perkov Date: Fri, 12 Jul 2013 00:20:59 +0200 Subject: [PATCH] bridge: add bridge_empty option which allows creation of empty bridges Signed-off-by: Luka Perkov --- bridge.c | 14 ++++++++++++++ system.h | 1 + 2 files changed, 15 insertions(+) diff --git a/bridge.c b/bridge.c index 9aa26f2..05f2ad6 100644 --- a/bridge.c +++ b/bridge.c @@ -31,6 +31,7 @@ enum { BRIDGE_ATTR_AGEING_TIME, BRIDGE_ATTR_HELLO_TIME, BRIDGE_ATTR_MAX_AGE, + BRIDGE_ATTR_BRIDGE_EMPTY, __BRIDGE_ATTR_MAX }; @@ -43,6 +44,7 @@ static const struct blobmsg_policy bridge_attrs[__BRIDGE_ATTR_MAX] = { [BRIDGE_ATTR_HELLO_TIME] = { "hello_time", BLOBMSG_TYPE_INT32 }, [BRIDGE_ATTR_MAX_AGE] = { "max_age", BLOBMSG_TYPE_INT32 }, [BRIDGE_ATTR_IGMP_SNOOP] = { "igmp_snooping", BLOBMSG_TYPE_BOOL }, + [BRIDGE_ATTR_BRIDGE_EMPTY] = { "bridge_empty", BLOBMSG_TYPE_BOOL }, }; static const struct uci_blob_param_info bridge_attr_info[__BRIDGE_ATTR_MAX] = { @@ -185,6 +187,9 @@ bridge_remove_member(struct bridge_member *bm) bm->present = false; bm->bst->n_present--; + if (bst->config.bridge_empty) + return; + bst->force_active = false; if (bst->n_present == 0) device_set_present(&bst->dev, false); @@ -444,6 +449,11 @@ bridge_config_init(struct device *dev) bst = container_of(dev, struct bridge_state, dev); + if (bst->config.bridge_empty) { + bst->force_active = true; + device_set_present(&bst->dev, true); + } + if (!bst->ifnames) return; @@ -464,6 +474,7 @@ bridge_apply_settings(struct bridge_state *bst, struct blob_attr **tb) cfg->stp = false; cfg->forward_delay = 2; cfg->igmp_snoop = false; + cfg->bridge_empty = false; cfg->priority = 0x7FFF; if ((cur = tb[BRIDGE_ATTR_STP])) @@ -492,6 +503,9 @@ bridge_apply_settings(struct bridge_state *bst, struct blob_attr **tb) cfg->max_age = blobmsg_get_u32(cur); cfg->flags |= BRIDGE_OPT_MAX_AGE; } + + if ((cur = tb[BRIDGE_ATTR_BRIDGE_EMPTY])) + cfg->bridge_empty = blobmsg_get_bool(cur); } enum dev_change_type diff --git a/system.h b/system.h index f1f32cb..e50201a 100644 --- a/system.h +++ b/system.h @@ -47,6 +47,7 @@ struct bridge_config { bool igmp_snoop; unsigned short priority; int forward_delay; + bool bridge_empty; int ageing_time; int hello_time; -- 2.11.0