aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorChen Minqiang <ptpt52@gmail.com>2018-09-10 20:07:03 +0800
committerChen Minqiang <ptpt52@gmail.com>2018-09-21 15:35:39 +0800
commit6a5836db326abb3c0efe0794fc67dcd7ce1dad15 (patch)
treecb150bf3df082a3c51c396c2991b32438ac0b362 /net
parent428f65bee80793dfc23f69d73908145d7ce06ec6 (diff)
mwan3: optimize the process of copying routing tables
- The original copy process is to delete all routing tables first, then add new routing table. This process is too slow and very dirty. - We use grep to identify the changes and apply them. - ignore ipv6 unreachable routes - update version number Signed-off-by: Chen Minqiang <ptpt52@gmail.com>
Diffstat (limited to 'net')
-rw-r--r--net/mwan3/Makefile2
-rw-r--r--net/mwan3/files/lib/mwan3/mwan3.sh42
2 files changed, 22 insertions, 22 deletions
diff --git a/net/mwan3/Makefile b/net/mwan3/Makefile
index 741c92ce7..0ed7488a7 100644
--- a/net/mwan3/Makefile
+++ b/net/mwan3/Makefile
@@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mwan3
-PKG_VERSION:=2.7.0
+PKG_VERSION:=2.7.1
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 f252cb26b..541e64d24 100644
--- a/net/mwan3/files/lib/mwan3/mwan3.sh
+++ b/net/mwan3/files/lib/mwan3/mwan3.sh
@@ -25,27 +25,27 @@ mwan3_rtmon_ipv4()
local tid=1
local idx=0
local ret=1
- main_tbsum=$($IP4 route list table main | grep -v ^default | md5sum | head -c32)
+ mkdir -p /tmp/mwan3rtmon
+ ($IP4 route list table main | grep -v ^default | sort -n; echo empty fixup) >/tmp/mwan3rtmon/ipv4.main
while uci get mwan3.@interface[$idx] >/dev/null 2>&1 ; do
idx=$((idx+1))
tid=$idx
[ "$(uci get mwan3.@interface[$((idx-1))].family)" = "ipv4" ] && {
if $IP4 route list table $tid | grep -q ^default; then
- tbsum=$($IP4 route list table $tid | grep -v ^default | md5sum | head -c32)
- if [ "$tbsum" != "$main_tbsum" ]; then
- $IP4 route list table $tid | grep -v ^default | while read line; do
- $IP4 route del table $tid $line
- done
- $IP4 route list table main | grep -v ^default | while read line; do
- $IP4 route add table $tid $line
- done
- fi
+ ($IP4 route list table $tid | grep -v ^default | sort -n; echo empty fixup) >/tmp/mwan3rtmon/ipv4.$tid
+ cat /tmp/mwan3rtmon/ipv4.$tid | grep -v -x -F -f /tmp/mwan3rtmon/ipv4.main | while read line; do
+ $IP4 route del table $tid $line
+ done
+ cat /tmp/mwan3rtmon/ipv4.main | grep -v -x -F -f /tmp/mwan3rtmon/ipv4.$tid | while read line; do
+ $IP4 route add table $tid $line
+ done
fi
}
if [ "$(uci get mwan3.@interface[$((idx-1))].enabled)" = "1" ]; then
ret=0
fi
done
+ rm -f /tmp/mwan3rtmon/ipv4.*
return $ret
}
@@ -54,27 +54,27 @@ mwan3_rtmon_ipv6()
local tid=1
local idx=0
local ret=1
- main_tbsum=$($IP6 route list table main | grep -v "^default\|^::/" | md5sum | head -c32)
+ mkdir -p /tmp/mwan3rtmon
+ ($IP6 route list table main | grep -v "^default\|^::/0\|^unreachable" | sort -n; echo empty fixup) >/tmp/mwan3rtmon/ipv6.main
while uci get mwan3.@interface[$idx] >/dev/null 2>&1 ; do
idx=$((idx+1))
tid=$idx
[ "$(uci get mwan3.@interface[$((idx-1))].family)" = "ipv6" ] && {
- if $IP6 route list table $tid | grep -q ^::/0; then
- tbsum=$($IP6 route list table $tid | grep -v "^default\|^::/" | md5sum | head -c32)
- if [ "$tbsum" != "$main_tbsum" ]; then
- $IP6 route list table $tid | grep -v "^default\|^::/" | while read line; do
- $IP6 route del table $tid $line
- done
- $IP6 route list table main | grep -v "^default\|^::/" | while read line; do
- $IP6 route add table $tid $line
- done
- fi
+ if $IP6 route list table $tid | grep -q "^default\|^::/0"; then
+ ($IP6 route list table $tid | grep -v "^default\|^::/0\|^unreachable" | sort -n; echo empty fixup) >/tmp/mwan3rtmon/ipv6.$tid
+ cat /tmp/mwan3rtmon/ipv6.$tid | grep -v -x -F -f /tmp/mwan3rtmon/ipv6.main | while read line; do
+ $IP6 route del table $tid $line
+ done
+ cat /tmp/mwan3rtmon/ipv6.main | grep -v -x -F -f /tmp/mwan3rtmon/ipv6.$tid | while read line; do
+ $IP6 route add table $tid $line
+ done
fi
}
if [ "$(uci get mwan3.@interface[$((idx-1))].enabled)" = "1" ]; then
ret=0
fi
done
+ rm -f /tmp/mwan3rtmon/ipv6.*
return $ret
}