aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--net/mwan3/Makefile2
-rw-r--r--net/mwan3/files/lib/mwan3/mwan3.sh12
-rwxr-xr-xnet/mwan3/files/usr/libexec/rpcd/mwan318
-rwxr-xr-xnet/mwan3/files/usr/sbin/mwan315
-rwxr-xr-xnet/mwan3/files/usr/sbin/mwan3track8
5 files changed, 47 insertions, 8 deletions
diff --git a/net/mwan3/Makefile b/net/mwan3/Makefile
index 6633765d8..d9a085a37 100644
--- a/net/mwan3/Makefile
+++ b/net/mwan3/Makefile
@@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mwan3
-PKG_VERSION:=2.7.3
+PKG_VERSION:=2.7.4
PKG_RELEASE:=1
PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de>
PKG_LICENSE:=GPLv2
diff --git a/net/mwan3/files/lib/mwan3/mwan3.sh b/net/mwan3/files/lib/mwan3/mwan3.sh
index 2b92a1253..d0a47a523 100644
--- a/net/mwan3/files/lib/mwan3/mwan3.sh
+++ b/net/mwan3/files/lib/mwan3/mwan3.sh
@@ -346,7 +346,7 @@ mwan3_delete_iface_iptables()
mwan3_create_iface_route()
{
- local id route_args
+ local id route_args metric
config_get family $1 family ipv4
mwan3_get_iface_id id $1
@@ -366,6 +366,11 @@ mwan3_create_iface_route()
route_args=""
fi
+ network_get_metric metric $1
+ if [ -n "$metric" -a "$metric" != "0" ]; then
+ route_args="$route_args metric $metric"
+ fi
+
$IP4 route flush table $id
$IP4 route add table $id default $route_args dev $2
mwan3_rtmon_ipv4
@@ -384,6 +389,11 @@ mwan3_create_iface_route()
route_args=""
fi
+ network_get_metric metric $1
+ if [ -n "$metric" -a "$metric" != "0" ]; then
+ route_args="$route_args metric $metric"
+ fi
+
$IP6 route flush table $id
$IP6 route add table $id default $route_args dev $2
mwan3_rtmon_ipv6
diff --git a/net/mwan3/files/usr/libexec/rpcd/mwan3 b/net/mwan3/files/usr/libexec/rpcd/mwan3
index eb5f98ce5..a9b31f222 100755
--- a/net/mwan3/files/usr/libexec/rpcd/mwan3
+++ b/net/mwan3/files/usr/libexec/rpcd/mwan3
@@ -36,7 +36,9 @@ get_mwan3_status() {
local iface_select="${2}"
local running="0"
local age=0
- local pid device time_p time_n
+ local uptime=0
+ local downtime=0
+ local pid device time_p time_n time_u time_d
network_get_device device $1
@@ -52,8 +54,22 @@ get_mwan3_status() {
let age=time_n-time_p
}
+ time_u="$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/UPTIME")"
+ [ -z "${time_u}" ] || [ "${time_u}" = "0" ] || {
+ time_n="$(get_uptime)"
+ let uptime=time_n-time_u
+ }
+
+ time_d="$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/DOWNTIME")"
+ [ -z "${time_d}" ] || [ "${time_d}" = "0" ] || {
+ time_n="$(get_uptime)"
+ let downtime=time_n-time_d
+ }
+
json_add_object "${iface}"
json_add_int age "$age"
+ json_add_int uptime "${uptime}"
+ json_add_int downtime "${downtime}"
json_add_int "score" "$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/SCORE")"
json_add_int "lost" "$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/LOST")"
json_add_int "turn" "$(cat "$MWAN3TRACK_STATUS_DIR/${iface}/TURN")"
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
}
diff --git a/net/mwan3/files/usr/sbin/mwan3track b/net/mwan3/files/usr/sbin/mwan3track
index c2ebb3e9f..420878472 100755
--- a/net/mwan3/files/usr/sbin/mwan3track
+++ b/net/mwan3/files/usr/sbin/mwan3track
@@ -108,9 +108,13 @@ main() {
if [ "$STATUS" = "unknown" ]; then
echo "unknown" > /var/run/mwan3track/$1/STATUS
+ echo "0" > /var/run/mwan3track/$1/UPTIME
+ echo "$(get_uptime)" > /var/run/mwan3track/$1/DOWNTIME
score=0
else
echo "online" > /var/run/mwan3track/$1/STATUS
+ echo "0" > /var/run/mwan3track/$1/DOWNTIME
+ echo "$(get_uptime)" > /var/run/mwan3track/$1/UPTIME
env -i ACTION="connected" INTERFACE="$1" DEVICE="$2" /sbin/hotplug-call iface
fi
while true; do
@@ -199,6 +203,8 @@ main() {
if [ $score -eq $up ]; then
echo "offline" > /var/run/mwan3track/$1/STATUS
+ echo "0" > /var/run/mwan3track/$1/UPTIME
+ echo "$(get_uptime)" > /var/run/mwan3track/$1/DOWNTIME
$LOG notice "Interface $1 ($2) is offline"
env -i ACTION=ifdown INTERFACE=$1 DEVICE=$2 /sbin/hotplug-call iface
env -i ACTION="disconnected" INTERFACE="$1" DEVICE="$2" /sbin/hotplug-call iface
@@ -240,6 +246,8 @@ main() {
if [ "${IFDOWN_EVENT}" -eq 1 ]; then
echo "offline" > /var/run/mwan3track/$1/STATUS
+ echo "$(get_uptime)" > /var/run/mwan3track/$1/DOWNTIME
+ echo "0" > /var/run/mwan3track/$1/UPTIME
$LOG notice "Interface $1 ($2) is offline"
env -i ACTION="disconnected" INTERFACE="$1" DEVICE="$2" /sbin/hotplug-call iface
score=0