diff options
author | Florian Eckert <fe@dev.tdt.de> | 2020-07-16 14:02:57 +0200 |
---|---|---|
committer | Florian Eckert <fe@dev.tdt.de> | 2020-07-20 08:11:20 +0200 |
commit | bcd13ba95cd5b96d04e490b576faab54404cbf69 (patch) | |
tree | f7349c228d96cc1a36a3e8a99edb1db6c6a5af58 /net/mwan3/files | |
parent | bcd914e6658aed571eae554dfb8bfaac87e3fa41 (diff) |
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>
Diffstat (limited to 'net/mwan3/files')
-rw-r--r-- | net/mwan3/files/lib/mwan3/mwan3.sh | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/net/mwan3/files/lib/mwan3/mwan3.sh b/net/mwan3/files/lib/mwan3/mwan3.sh index 3ce880fd2..652cbfd42 100644 --- a/net/mwan3/files/lib/mwan3/mwan3.sh +++ b/net/mwan3/files/lib/mwan3/mwan3.sh @@ -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)) |