diff options
author | Kyson Lok <kysonlok@gmail.com> | 2018-06-06 19:07:20 +0800 |
---|---|---|
committer | Florian Eckert <fe@dev.tdt.de> | 2018-10-12 08:13:42 +0200 |
commit | 8c0ed00c397febfdcbb40e901f77a7a15bfc1d9e (patch) | |
tree | ec787b73d624a2e75da2e9ce1ac482894eb08cd0 /net | |
parent | ac2e6dfc0c0a87461441fed21a02fb019c000d17 (diff) |
net/mwan3: fixup parse json_load an null message
If a interface is down, call ubus will return an null message which is
used to json_load, it causes json_get_vars gets value from last load and
l3_device various is nonzero.
Signed-off-by: Kyson Lok <kysonlok@gmail.com>
Diffstat (limited to 'net')
-rwxr-xr-x | net/mwan3/files/usr/sbin/mwan3 | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/net/mwan3/files/usr/sbin/mwan3 b/net/mwan3/files/usr/sbin/mwan3 index 406804b30..4ad3bc391 100755 --- a/net/mwan3/files/usr/sbin/mwan3 +++ b/net/mwan3/files/usr/sbin/mwan3 @@ -43,7 +43,7 @@ ifdown() ifup() { - local device enabled up l3_device + local device enabled up l3_device status config_load mwan3 config_get_bool enabled globals 'enabled' 0 @@ -67,13 +67,18 @@ ifup() exit 0 } - json_load $(ubus -S call network.interface.$1 status) - json_get_vars up l3_device + status=$(ubus -S call network.interface.$1 status) + [ -n "$status" ] && { + json_load $status + json_get_vars up l3_device + } + config_get enabled "$1" enabled 0 - if [ "$up" -eq 1 ] \ + + if [ "$up" = "1" ] \ && [ -n "$l3_device" ] \ - && [ "$enabled" -eq 1 ]; then + && [ "$enabled" = "1" ]; then ACTION=ifup INTERFACE=$1 DEVICE=$l3_device /sbin/hotplug-call iface fi } |