Browse Source

Merge pull request #7191 from TDT-AG/pr/20181012-mwan3

mwan3: improvments
lilik-openwrt-22.03
Hannu Nyman 6 years ago
committed by GitHub
parent
commit
bb6f3564bc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 8 deletions
  1. +1
    -1
      net/mwan3/Makefile
  2. +11
    -1
      net/mwan3/files/lib/mwan3/mwan3.sh
  3. +17
    -1
      net/mwan3/files/usr/libexec/rpcd/mwan3
  4. +10
    -5
      net/mwan3/files/usr/sbin/mwan3
  5. +8
    -0
      net/mwan3/files/usr/sbin/mwan3track

+ 1
- 1
net/mwan3/Makefile View File

@ -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


+ 11
- 1
net/mwan3/files/lib/mwan3/mwan3.sh View File

@ -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


+ 17
- 1
net/mwan3/files/usr/libexec/rpcd/mwan3 View File

@ -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")"


+ 10
- 5
net/mwan3/files/usr/sbin/mwan3 View File

@ -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
}


+ 8
- 0
net/mwan3/files/usr/sbin/mwan3track View File

@ -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


Loading…
Cancel
Save