Browse Source

mwan3: update to version 1.5-4

Fix issue #219: Policy status output returns arithmetic syntax error

Signed-off-by: Jeroen Louwes <jeroen.louwes@gmail.com>
Adze1502 10 years ago
parent
commit
a018080060
2 changed files with 8 additions and 10 deletions
  1. 1
    1
      net/mwan3/Makefile
  2. 7
    9
      net/mwan3/files/usr/sbin/mwan3

+ 1
- 1
net/mwan3/Makefile View File

@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
9 9
 
10 10
 PKG_NAME:=mwan3
11 11
 PKG_VERSION:=1.5
12
-PKG_RELEASE:=3
12
+PKG_RELEASE:=4
13 13
 PKG_MAINTAINER:=Jeroen Louwes <jeroen.louwes@gmail.com>
14 14
 PKG_LICENSE:=GPLv2
15 15
 

+ 7
- 9
net/mwan3/files/usr/sbin/mwan3 View File

@@ -86,19 +86,19 @@ interfaces()
86 86
 		config_get enabled "$1" enabled 0
87 87
 		let iface_id++
88 88
 
89
-		if [ -n "$(ps -w | grep mwan3track | grep -v grep | sed '/.*\/usr\/sbin\/mwan3track \([^ ]*\) .*$/!d;s//\1/' | awk '$1 == ("'$1'")')" ]; then
89
+		if [ -n "$(ps -w | grep mwan3track | grep -v grep | sed '/.*\/usr\/sbin\/mwan3track \([^ ]*\) .*$/!d;s//\1/' | awk '$1 == "'$1'"')" ]; then
90 90
 			tracking="active"
91 91
 		else
92 92
 			tracking="down"
93 93
 		fi
94 94
 
95
-		if [ -n "$($IP rule | awk '$5 == ("'$device'")')" -a -n "$($IPT -S mwan3_iface_$1 2> /dev/null)" -a -n "$($IP route list table $iface_id default dev $device 2> /dev/null)" ]; then
95
+		if [ -n "$($IP rule | awk '$5 == "'$device'"')" -a -n "$($IPT -S mwan3_iface_$1 2> /dev/null)" -a -n "$($IP route list table $iface_id default dev $device 2> /dev/null)" ]; then
96 96
 			if [ -n "$(uci get -p /var/state mwan3.$1.track_ip 2> /dev/null)" ]; then
97 97
 				echo "Interface $1 is online (tracking $tracking)"
98 98
 			else
99 99
 				echo "Interface $1 is online"
100 100
 			fi
101
-		elif [ -n "$($IP rule | awk '$5 == ("'$device'")')" -o -n "$($IPT -S mwan3_iface_$1 2> /dev/null)" -o -n "$($IP route list table $iface_id default dev $device 2> /dev/null)" ]; then
101
+		elif [ -n "$($IP rule | awk '$5 == "'$device'"')" -o -n "$($IPT -S mwan3_iface_$1 2> /dev/null)" -o -n "$($IP route list table $iface_id default dev $device 2> /dev/null)" ]; then
102 102
 			echo "Interface $1 error"
103 103
 		else
104 104
 			if [ "$enabled" -eq 1 ]; then
@@ -123,13 +123,11 @@ policies()
123 123
 	for policy in $($IPT -S | awk '{print $2}' | grep mwan3_policy_ | sort -u); do
124 124
 		echo "Policy $policy:" | sed 's/mwan3_policy_//g'
125 125
 
126
-		for iface in $($IPT -S $policy | cut -s -d'"' -f2 | awk '{print $1}'); do
127
-			[ -n "$total_weight" ] || total_weight=$($IPT -S $policy | grep "$iface " | cut -s -d'"' -f2 | awk '{print $3}')
128
-		done
126
+		[ -n "$total_weight" ] || total_weight=$($IPT -S $policy | cut -s -d'"' -f2 | head -1 | awk '{print $3}')
129 127
 
130 128
 		if [ ! -z "${total_weight##*[!0-9]*}" ]; then
131 129
 			for iface in $($IPT -S $policy | cut -s -d'"' -f2 | awk '{print $1}'); do
132
-				weight=$($IPT -S $policy | grep "$iface " | cut -s -d'"' -f2 | awk '{print $2}')
130
+				weight=$($IPT -S $policy | cut -s -d'"' -f2 | awk '$1 == "'$iface'"' | awk '{print $2}')
133 131
 				percent=$(($weight*100/$total_weight))
134 132
 				echo " $iface ($percent%)"
135 133
 			done
@@ -148,14 +146,14 @@ rules()
148 146
 	if [ -n "$($IPT -S mwan3_connected 2> /dev/null)" ]; then
149 147
 		echo "Known networks:"
150 148
 		echo "destination policy hits" | awk '{ printf "%-19s%-19s%-9s%s\n",$1,$2,$3}' | awk '1; {gsub(".","-")}1'
151
-		$IPT -L mwan3_connected -n -v 2> /dev/null | tail -n+3 | sed 's/mark.*//' | sed 's/mwan3_policy_//g' | awk '{printf "%-19s%-19s%-9s%s\n",$9,"default",$1}'
149
+		$IPT -L mwan3_connected -n -v 2> /dev/null | tail -n+3 | sed 's/mark.*//' | sed 's/mwan3_policy_//' | awk '{printf "%-19s%-19s%-9s%s\n",$9,"default",$1}'
152 150
 		echo -e
153 151
 	fi
154 152
 
155 153
 	if [ -n "$($IPT -S mwan3_rules 2> /dev/null)" ]; then
156 154
 		echo "Active rules:"
157 155
 		echo "source destination proto src-port dest-port policy hits" | awk '{ printf "%-19s%-19s%-7s%-14s%-14s%-16s%-9s%s\n",$1,$2,$3,$4,$5,$6,$7}' | awk '1; {gsub(".","-")}1'
158
-		$IPT -L mwan3_rules -n -v 2> /dev/null | tail -n+3 | sed 's/mark.*//' | sed 's/mwan3_policy_//g' | awk '{ printf "%-19s%-19s%-7s%-14s%-14s%-16s%-9s%s\n",$8,$9,$4,$12,$15,$3,$1}'
156
+		$IPT -L mwan3_rules -n -v 2> /dev/null | tail -n+3 | sed 's/mark.*//' | sed 's/mwan3_policy_//' | awk '{ printf "%-19s%-19s%-7s%-14s%-14s%-16s%-9s%s\n",$8,$9,$4,$12,$15,$3,$1}'
159 157
 		echo -e
160 158
 	fi
161 159
 }