summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2010-01-18 00:38:04 +0000
committerFelix Fietkau <nbd@openwrt.org>2010-01-18 00:38:04 +0000
commit54bbc306875d7eb7dc3b86016242580004a9644b (patch)
tree0c911058c8255e9746eb54bdbc8c0de04cd524a0
parent2670e906b6f9c500b87ece595825e88aa5157ff4 (diff)
downloadmtk-20170518-54bbc306875d7eb7dc3b86016242580004a9644b.zip
mtk-20170518-54bbc306875d7eb7dc3b86016242580004a9644b.tar.gz
mtk-20170518-54bbc306875d7eb7dc3b86016242580004a9644b.tar.bz2
swconfig: support providing the switch device name in an option instead of the section name - necessary to support switches that contain characters such as "-"
SVN-Revision: 19208
-rw-r--r--package/swconfig/Makefile2
-rw-r--r--package/swconfig/files/switch.sh6
-rw-r--r--package/swconfig/src/uci.c18
3 files changed, 23 insertions, 3 deletions
diff --git a/package/swconfig/Makefile b/package/swconfig/Makefile
index a7bed73..72af8c7 100644
--- a/package/swconfig/Makefile
+++ b/package/swconfig/Makefile
@@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=swconfig
-PKG_RELEASE:=3
+PKG_RELEASE:=4
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/kernel.mk
diff --git a/package/swconfig/files/switch.sh b/package/swconfig/files/switch.sh
index 7078b2e..18d5fbd 100644
--- a/package/swconfig/files/switch.sh
+++ b/package/swconfig/files/switch.sh
@@ -2,8 +2,10 @@
# Copyright (C) 2009 OpenWrt.org
setup_switch_dev() {
- ifconfig "$1" 0.0.0.0
- swconfig dev "$1" load network
+ config_get name "$1" name
+ name="${name:-$1}"
+ [ -d "/sys/class/net/$name" ] && ifconfig "$name" up
+ swconfig dev "$name" load network
}
setup_switch() {
diff --git a/package/swconfig/src/uci.c b/package/swconfig/src/uci.c
index 2df837d..e597ace 100644
--- a/package/swconfig/src/uci.c
+++ b/package/swconfig/src/uci.c
@@ -107,6 +107,7 @@ int swlib_apply_from_uci(struct switch_dev *dev, struct uci_package *p)
struct uci_element *e;
struct uci_section *s;
struct uci_option *o;
+ struct uci_ptr ptr;
struct switch_val val;
int i;
@@ -114,11 +115,28 @@ int swlib_apply_from_uci(struct switch_dev *dev, struct uci_package *p)
head = &settings;
uci_foreach_element(&p->sections, e) {
+ struct uci_element *n;
+
s = uci_to_section(e);
if (strcmp(s->type, "switch") != 0)
continue;
+ uci_foreach_element(&s->options, n) {
+ struct uci_option *o = uci_to_option(n);
+
+ if (strcmp(n->name, "name") != 0)
+ continue;
+
+ if (o->type != UCI_TYPE_STRING)
+ continue;
+
+ if (!strcmp(o->v.string, dev->dev_name))
+ goto found;
+
+ break;
+ }
+
if (strcmp(e->name, dev->dev_name) != 0)
continue;