Browse Source

mwan3: fix rtmon routing table function generation

If the uci option family is not set in the interface section, then there
is no default value set as in the `config_load / config_get` API.
The problem here is that if the family is not set, the default value ipv4
is normaly assumed. But the comparison fails here because the value is empty
and therefore the dedicated routing table for this interface is not compared
with the other routes from the main table and so not updated.

To fix this set the default value for this config option which is`false`
for enabled and `ipv4` for family.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
lilik-openwrt-22.03
Florian Eckert 4 years ago
parent
commit
bcd13ba95c
1 changed files with 21 additions and 6 deletions
  1. +21
    -6
      net/mwan3/files/lib/mwan3/mwan3.sh

+ 21
- 6
net/mwan3/files/lib/mwan3/mwan3.sh View File

@ -43,13 +43,20 @@ mwan3_rtmon_ipv4()
local ret=1
local tbl=""
local tid
local tid family enabled
mkdir -p /tmp/mwan3rtmon
($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
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)
if echo "$tbl" | grep -q ^default; then
(echo "$tbl" | grep -v "^default\|linkdown" | sort -n; echo empty fixup) >/tmp/mwan3rtmon/ipv4.$tid
@ -61,7 +68,7 @@ mwan3_rtmon_ipv4()
done
fi
}
if [ "$(uci get mwan3.@interface[$idx].enabled)" = "1" ]; then
if [ "$enabled" = "1" ]; then
ret=0
fi
idx=$((idx+1))
@ -78,13 +85,21 @@ mwan3_rtmon_ipv6()
local ret=1
local tbl=""
local tid
local tid family enabled
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
while uci get mwan3.@interface[$idx] >/dev/null 2>&1 ; do
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)
if echo "$tbl" | grep -q "^default\|^::/0"; then
(echo "$tbl" | grep -v "^default\|^::/0\|^unreachable" | sort -n; echo empty fixup) >/tmp/mwan3rtmon/ipv6.$tid
@ -96,7 +111,7 @@ mwan3_rtmon_ipv6()
done
fi
}
if [ "$(uci get mwan3.@interface[$idx].enabled)" = "1" ]; then
if [ "$enabled" = "1" ]; then
ret=0
fi
idx=$((idx+1))


Loading…
Cancel
Save