qos-scripts: fix interface resolving
authorJo-Philipp Wich <jo@mein.io>
Fri, 29 May 2020 08:34:58 +0000 (10:34 +0200)
committerJo-Philipp Wich <jo@mein.io>
Fri, 29 May 2020 08:34:58 +0000 (10:34 +0200)
Also ensure that the error message is actually printed to stderr and that
the rule generation is aborted if an interface cannot be resolved.

Ref: https://github.com/openwrt/luci/issues/3975
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
package/network/config/qos-scripts/Makefile
package/network/config/qos-scripts/files/usr/lib/qos/generate.sh

index abaeaeb9813f409d79491d39ca3e4cc944b5370c..7d282b2db56d66db106296be5ac97c6ef45f1dda 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=qos-scripts
 PKG_VERSION:=1.3.1
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 PKG_LICENSE:=GPL-2.0
 
 PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
index 3ec7f80e531eb434b7c1b52292a96e16c98d64b0..024be0c1704a1297442a4106123e8529956a5a44 100755 (executable)
@@ -22,15 +22,20 @@ add_insmod() {
 [ -e /etc/config/network ] && {
        # only try to parse network config on openwrt
 
-       find_ifname() {(
-               reset_cb
-               include /lib/network
-               scan_interfaces
-               config_get "$1" ifname
-       )}
+       . /lib/functions/network.sh
+
+       find_ifname() {
+               local ifname
+               if network_get_device ifname "$1"; then
+                       echo "$ifname"
+               else
+                       echo "Device for interface $1 not found." >&2
+                       exit 1
+               fi
+       }
 } || {
        find_ifname() {
-               echo "Interface not found."
+               echo "Interface not found." >&2
                exit 1
        }
 }
@@ -218,6 +223,7 @@ qos_parse_config() {
                                config_get device "$1" device
                                [ -z "$device" ] && {
                                        device="$(find_ifname $1)"
+                                       [ -z "$device" ] && exit 1
                                        config_set "$1" device "$device"
                                }
                        }