aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Ambardar <itugrok@yahoo.com>2018-06-08 04:34:00 -0700
committerHans Dedecker <dedeckeh@gmail.com>2018-06-28 16:41:45 +0200
commitb701d78105a3f233f993dddde12d16973ba88972 (patch)
tree6d6f86eadefd0633d4f18601133856e2637bc6ae
parent7b74b40fe927ae5d2f88dfab8e26b75207878c9d (diff)
downloadupstream-b701d78105a3f233f993dddde12d16973ba88972.tar.gz
upstream-b701d78105a3f233f993dddde12d16973ba88972.tar.bz2
upstream-b701d78105a3f233f993dddde12d16973ba88972.zip
qos-scripts: fix uci callback handling
The previous callback code was fragile, dependent on some UCI callback bugs and side-effects now fixed in master commit 73d8a6ab. Update scripts to use callbacks where appropriate and necessary, while using normal UCI config parsing for all else. This results in smaller, simpler, more robust code. Use callbacks in generate.sh to only process 'interface' defaults and the varying entries for 'reclassify', 'default' and 'classify' sections. Also switch qos-stat to use non-callback UCI handling. The current changes work independently of 73d8a6ab (i.e. both before and after), and are consistent with UCI config parsing documentation. Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
-rw-r--r--package/network/config/qos-scripts/Makefile2
-rwxr-xr-xpackage/network/config/qos-scripts/files/usr/bin/qos-stat11
-rwxr-xr-xpackage/network/config/qos-scripts/files/usr/lib/qos/generate.sh45
3 files changed, 29 insertions, 29 deletions
diff --git a/package/network/config/qos-scripts/Makefile b/package/network/config/qos-scripts/Makefile
index 07e68835c7..abaeaeb981 100644
--- a/package/network/config/qos-scripts/Makefile
+++ b/package/network/config/qos-scripts/Makefile
@@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=qos-scripts
-PKG_VERSION:=1.3.0
+PKG_VERSION:=1.3.1
PKG_RELEASE:=1
PKG_LICENSE:=GPL-2.0
diff --git a/package/network/config/qos-scripts/files/usr/bin/qos-stat b/package/network/config/qos-scripts/files/usr/bin/qos-stat
index cbbf8e8de8..03b737c89d 100755
--- a/package/network/config/qos-scripts/files/usr/bin/qos-stat
+++ b/package/network/config/qos-scripts/files/usr/bin/qos-stat
@@ -14,16 +14,17 @@ get_ifname() {
[ "$cfgt" = "interface" ] && config_get "$interface" ifname
}
-config_cb() {
- config_get TYPE "$CONFIG_SECTION" TYPE
+qos_set_device() {
+ config_get TYPE "$1" TYPE
[ "interface" = "$TYPE" ] && {
- config_get device "$CONFIG_SECTION" ifname
- [ -z "$device" ] && device="$(get_ifname ${CONFIG_SECTION})"
- config_set "$CONFIG_SECTION" device "$device"
+ config_get device "$1" ifname
+ [ -z "$device" ] && device="$(get_ifname $1)"
+ config_set "$1" device "$device"
}
}
config_load qos
+config_foreach qos_set_device
print_comments() {
echo ''
diff --git a/package/network/config/qos-scripts/files/usr/lib/qos/generate.sh b/package/network/config/qos-scripts/files/usr/lib/qos/generate.sh
index 9ce4eb41ef..48c9f4a9df 100755
--- a/package/network/config/qos-scripts/files/usr/lib/qos/generate.sh
+++ b/package/network/config/qos-scripts/files/usr/lib/qos/generate.sh
@@ -191,8 +191,6 @@ config_cb() {
option_cb() {
return 0
}
-
- # Section start
case "$1" in
interface)
config_set "$2" "classgroup" "Default"
@@ -200,43 +198,41 @@ config_cb() {
;;
classify|default|reclassify)
option_cb() {
- append options "$1"
+ append "CONFIG_${CONFIG_SECTION}_options" "$1"
}
;;
esac
+}
- # Section end
- config_get TYPE "$CONFIG_SECTION" TYPE
+qos_parse_config() {
+ config_get TYPE "$1" TYPE
case "$TYPE" in
interface)
- config_get_bool enabled "$CONFIG_SECTION" enabled 1
- [ 1 -eq "$enabled" ] || return 0
- config_get classgroup "$CONFIG_SECTION" classgroup
- config_set "$CONFIG_SECTION" ifbdev "$C"
- C=$(($C+1))
- append INTERFACES "$CONFIG_SECTION"
- config_set "$classgroup" enabled 1
- config_get device "$CONFIG_SECTION" device
- [ -z "$device" ] && {
- device="$(find_ifname ${CONFIG_SECTION})"
- config_set "$CONFIG_SECTION" device "$device"
+ config_get_bool enabled "$1" enabled 1
+ [ 1 -eq "$enabled" ] && {
+ config_get classgroup "$1" classgroup
+ config_set "$1" ifbdev "$C"
+ C=$(($C+1))
+ append INTERFACES "$1"
+ config_set "$classgroup" enabled 1
+ config_get device "$1" device
+ [ -z "$device" ] && {
+ device="$(find_ifname $1)"
+ config_set "$1" device "$device"
+ }
}
;;
- classgroup) append CG "$CONFIG_SECTION";;
+ classgroup) append CG "$1";;
classify|default|reclassify)
case "$TYPE" in
classify) var="ctrules";;
*) var="rules";;
esac
- config_get target "$CONFIG_SECTION" target
- config_set "$CONFIG_SECTION" options "$options"
- append "$var" "$CONFIG_SECTION"
- unset options
+ append "$var" "$1"
;;
esac
}
-
enum_classes() {
local c="0"
config_get classes "$1" classes
@@ -500,7 +496,10 @@ INTERFACES=""
[ -e ./qos.conf ] && {
. ./qos.conf
config_cb
-} || config_load qos
+} || {
+ config_load qos
+ config_foreach qos_parse_config
+}
C="0"
for iface in $INTERFACES; do