Browse Source

Merge pull request #12879 from TDT-AG/pr/20200720-mwan3

mwan3: update to version 2.8.11
lilik-openwrt-22.03
Rosen Penev 4 years ago
committed by GitHub
parent
commit
567c620bdc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 11 deletions
  1. +1
    -1
      net/mwan3/Makefile
  2. +8
    -3
      net/mwan3/files/etc/init.d/mwan3
  3. +42
    -7
      net/mwan3/files/lib/mwan3/mwan3.sh

+ 1
- 1
net/mwan3/Makefile View File

@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=mwan3 PKG_NAME:=mwan3
PKG_VERSION:=2.8.10
PKG_VERSION:=2.8.11
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de> PKG_MAINTAINER:=Florian Eckert <fe@dev.tdt.de>
PKG_LICENSE:=GPL-2.0 PKG_LICENSE:=GPL-2.0


+ 8
- 3
net/mwan3/files/etc/init.d/mwan3 View File

@ -10,17 +10,22 @@ boot() {
rc_procd start_service rc_procd start_service
} }
# FIXME
# fd 1000 is an inherited lock file descriptor for preventing concurrent
# init script executions. Close it here to prevent the mwan3 daemon from
# inheriting it further to avoid holding the lock indefinitely.
reload_service() { reload_service() {
/usr/sbin/mwan3 restart
/usr/sbin/mwan3 restart 1000>&-
} }
start_service() { start_service() {
[ -n "${mwan3_boot}" ] && return 0 [ -n "${mwan3_boot}" ] && return 0
/usr/sbin/mwan3 start
/usr/sbin/mwan3 start 1000>&-
} }
stop_service() { stop_service() {
/usr/sbin/mwan3 stop
/usr/sbin/mwan3 stop 1000>&-
} }
service_triggers() { service_triggers() {


+ 42
- 7
net/mwan3/files/lib/mwan3/mwan3.sh View File

@ -1,5 +1,7 @@
#!/bin/sh #!/bin/sh
. /usr/share/libubox/jshn.sh
IP4="ip -4" IP4="ip -4"
IP6="ip -6" IP6="ip -6"
IPS="ipset" IPS="ipset"
@ -43,13 +45,20 @@ mwan3_rtmon_ipv4()
local ret=1 local ret=1
local tbl="" local tbl=""
local tid
local tid family enabled
mkdir -p /tmp/mwan3rtmon mkdir -p /tmp/mwan3rtmon
($IP4 route list table main | grep -v "^default\|linkdown" | sort -n; echo empty fixup) >/tmp/mwan3rtmon/ipv4.main ($IP4 route list table main | grep -v "^default\|linkdown" | sort -n; echo empty fixup) >/tmp/mwan3rtmon/ipv4.main
while uci get mwan3.@interface[$idx] >/dev/null 2>&1 ; do while uci get mwan3.@interface[$idx] >/dev/null 2>&1 ; do
tid=$((idx+1)) tid=$((idx+1))
[ "$(uci get mwan3.@interface[$idx].family)" = "ipv4" ] && {
family="$(uci -q get mwan3.@interface[$idx].family)"
[ -z "$family" ] && family="ipv4"
enabled="$(uci -q get mwan3.@interface[$idx].enabled)"
[ -z "$enabled" ] && enabled="0"
[ "$family" = "ipv4" ] && {
tbl=$($IP4 route list table $tid 2>/dev/null) tbl=$($IP4 route list table $tid 2>/dev/null)
if echo "$tbl" | grep -q ^default; then if echo "$tbl" | grep -q ^default; then
(echo "$tbl" | grep -v "^default\|linkdown" | sort -n; echo empty fixup) >/tmp/mwan3rtmon/ipv4.$tid (echo "$tbl" | grep -v "^default\|linkdown" | sort -n; echo empty fixup) >/tmp/mwan3rtmon/ipv4.$tid
@ -61,7 +70,7 @@ mwan3_rtmon_ipv4()
done done
fi fi
} }
if [ "$(uci get mwan3.@interface[$idx].enabled)" = "1" ]; then
if [ "$enabled" = "1" ]; then
ret=0 ret=0
fi fi
idx=$((idx+1)) idx=$((idx+1))
@ -78,13 +87,21 @@ mwan3_rtmon_ipv6()
local ret=1 local ret=1
local tbl="" local tbl=""
local tid
local tid family enabled
mkdir -p /tmp/mwan3rtmon mkdir -p /tmp/mwan3rtmon
($IP6 route list table main | grep -v "^default\|^::/0\|^fe80::/64\|^unreachable" | sort -n; echo empty fixup) >/tmp/mwan3rtmon/ipv6.main ($IP6 route list table main | grep -v "^default\|^::/0\|^fe80::/64\|^unreachable" | sort -n; echo empty fixup) >/tmp/mwan3rtmon/ipv6.main
while uci get mwan3.@interface[$idx] >/dev/null 2>&1 ; do while uci get mwan3.@interface[$idx] >/dev/null 2>&1 ; do
tid=$((idx+1)) tid=$((idx+1))
[ "$(uci get mwan3.@interface[$idx].family)" = "ipv6" ] && {
family="$(uci -q get mwan3.@interface[$idx].family)"
# Set default family to ipv4 that is no mistake
[ -z "$family" ] && family="ipv4"
enabled="$(uci -q get mwan3.@interface[$idx].enabled)"
[ -z "$enabled" ] && enabled="0"
[ "$family" = "ipv6" ] && {
tbl=$($IP6 route list table $tid 2>/dev/null) tbl=$($IP6 route list table $tid 2>/dev/null)
if echo "$tbl" | grep -q "^default\|^::/0"; then if echo "$tbl" | grep -q "^default\|^::/0"; then
(echo "$tbl" | grep -v "^default\|^::/0\|^unreachable" | sort -n; echo empty fixup) >/tmp/mwan3rtmon/ipv6.$tid (echo "$tbl" | grep -v "^default\|^::/0\|^unreachable" | sort -n; echo empty fixup) >/tmp/mwan3rtmon/ipv6.$tid
@ -96,7 +113,7 @@ mwan3_rtmon_ipv6()
done done
fi fi
} }
if [ "$(uci get mwan3.@interface[$idx].enabled)" = "1" ]; then
if [ "$enabled" = "1" ]; then
ret=0 ret=0
fi fi
idx=$((idx+1)) idx=$((idx+1))
@ -187,6 +204,13 @@ mwan3_unlock() {
} }
mwan3_lock_clean() { mwan3_lock_clean() {
for pid in $(pgrep -f "lock /var/run/mwan3.lock"); do
kill -TERM "$pid" > /dev/null 2>&1
done
sleep 1
for pid in $(pgrep -f "lock /var/run/mwan3.lock"); do
kill -KILL "$pid" > /dev/null 2>&1
done
rm -rf /var/run/mwan3.lock rm -rf /var/run/mwan3.lock
} }
@ -1044,7 +1068,18 @@ mwan3_report_iface_status()
[ -n "$($IP rule | awk '$1 == "'$(($id+2000)):'"')" ] && \ [ -n "$($IP rule | awk '$1 == "'$(($id+2000)):'"')" ] && \
[ -n "$($IPT -S mwan3_iface_in_$1 2> /dev/null)" ] && \ [ -n "$($IPT -S mwan3_iface_in_$1 2> /dev/null)" ] && \
[ -n "$($IP route list table $id default dev $device 2> /dev/null)" ]; then [ -n "$($IP route list table $id default dev $device 2> /dev/null)" ]; then
result="$(mwan3_get_iface_hotplug_state $1)"
json_init
json_add_string section interfaces
json_add_string interface "$1"
json_load "$(ubus call mwan3 status "$(json_dump)")"
json_select "interfaces"
json_select "$1"
json_get_vars online uptime
json_select ..
json_select ..
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)):'"')" ] || \ elif [ -n "$($IP rule | awk '$1 == "'$(($id+1000)):'"')" ] || \
[ -n "$($IP rule | awk '$1 == "'$(($id+2000)):'"')" ] || \ [ -n "$($IP rule | awk '$1 == "'$(($id+2000)):'"')" ] || \
[ -n "$($IPT -S mwan3_iface_in_$1 2> /dev/null)" ] || \ [ -n "$($IPT -S mwan3_iface_in_$1 2> /dev/null)" ] || \


Loading…
Cancel
Save