aboutsummaryrefslogtreecommitdiff
path: root/net/mwan3
diff options
context:
space:
mode:
authorAaron Goodman <aaronjg@stanford.edu>2020-11-10 08:51:07 -0500
committerAaron Goodman <aaronjg@stanford.edu>2020-11-10 08:51:07 -0500
commitebfb7fb9d2737e18d09009a6ce2c10bb835c0b22 (patch)
tree7ad09d3edb01978188def6f4a69e8158abdb2ff7 /net/mwan3
parentc336e5d682cf672d48247e83712ddb0203ec2288 (diff)
mwan3: report an error code on status failure
Signed-off-by: Aaron Goodman <aaronjg@stanford.edu>
Diffstat (limited to 'net/mwan3')
-rw-r--r--net/mwan3/files/lib/mwan3/mwan3.sh32
1 files changed, 20 insertions, 12 deletions
diff --git a/net/mwan3/files/lib/mwan3/mwan3.sh b/net/mwan3/files/lib/mwan3/mwan3.sh
index 5d200071a..fcfda5b89 100644
--- a/net/mwan3/files/lib/mwan3/mwan3.sh
+++ b/net/mwan3/files/lib/mwan3/mwan3.sh
@@ -1017,7 +1017,7 @@ mwan3_get_iface_hotplug_state() {
mwan3_report_iface_status()
{
- local device result tracking IP IPT
+ local device result tracking IP IPT error
mwan3_get_iface_id id "$1"
network_get_device device "$1"
@@ -1036,11 +1036,23 @@ mwan3_report_iface_status()
if [ -z "$id" ] || [ -z "$device" ]; then
result="offline"
- elif [ -n "$($IP rule | awk '$1 == "'$((id+1000)):'"')" ] && \
- [ -n "$($IP rule | awk '$1 == "'$((id+2000)):'"')" ] && \
- [ -n "$($IP rule | awk '$1 == "'$((id+3000)):'"')" ] && \
- [ -n "$($IPT -S mwan3_iface_in_$1 2> /dev/null)" ] && \
- [ -n "$($IP route list table $id default dev $device 2> /dev/null)" ]; then
+ else
+ error=0
+ [ -n "$($IP rule | awk '$1 == "'$((id+1000)):'"')" ] ||
+ error=$((error+1))
+ [ -n "$($IP rule | awk '$1 == "'$((id+2000)):'"')" ] ||
+ error=$((error+2))
+ [ -n "$($IP rule | awk '$1 == "'$((id+3000)):'"')" ] ||
+ error=$((error+4))
+ [ -n "$($IPT -S mwan3_iface_in_$1 2> /dev/null)" ] ||
+ error=$((error+8))
+ [ -n "$($IP route list table $id default dev $device 2> /dev/null)" ] ||
+ error=$((error+16))
+ fi
+
+ if [ "$result" = "offline" ]; then
+ :
+ elif [ $error -eq 0 ]; then
json_init
json_add_string section interfaces
json_add_string interface "$1"
@@ -1053,12 +1065,8 @@ mwan3_report_iface_status()
online="$(printf '%02dh:%02dm:%02ds\n' $((online/3600)) $((online%3600/60)) $((online%60)))"
uptime="$(printf '%02dh:%02dm:%02ds\n' $((uptime/3600)) $((uptime%3600/60)) $((uptime%60)))"
result="$(mwan3_get_iface_hotplug_state $1) $online, uptime $uptime"
- elif [ -n "$($IP rule | awk '$1 == "'$((id+1000)):'"')" ] || \
- [ -n "$($IP rule | awk '$1 == "'$((id+2000)):'"')" ] || \
- [ -n "$($IP rule | awk '$1 == "'$((id+3000)):'"')" ] || \
- [ -n "$($IPT -S mwan3_iface_in_$1 2> /dev/null)" ] || \
- [ -n "$($IP route list table $id default dev $device 2> /dev/null)" ]; then
- result="error"
+ elif [ $error -gt 0 ] && [ $error -ne 31 ]; then
+ result="error (${error})"
elif [ "$enabled" = "1" ]; then
result="offline"
else