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
 
9
 
10
 PKG_NAME:=mwan3
10
 PKG_NAME:=mwan3
11
 PKG_VERSION:=1.5
11
 PKG_VERSION:=1.5
12
-PKG_RELEASE:=3
12
+PKG_RELEASE:=4
13
 PKG_MAINTAINER:=Jeroen Louwes <jeroen.louwes@gmail.com>
13
 PKG_MAINTAINER:=Jeroen Louwes <jeroen.louwes@gmail.com>
14
 PKG_LICENSE:=GPLv2
14
 PKG_LICENSE:=GPLv2
15
 
15
 

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

86
 		config_get enabled "$1" enabled 0
86
 		config_get enabled "$1" enabled 0
87
 		let iface_id++
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
 			tracking="active"
90
 			tracking="active"
91
 		else
91
 		else
92
 			tracking="down"
92
 			tracking="down"
93
 		fi
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
 			if [ -n "$(uci get -p /var/state mwan3.$1.track_ip 2> /dev/null)" ]; then
96
 			if [ -n "$(uci get -p /var/state mwan3.$1.track_ip 2> /dev/null)" ]; then
97
 				echo "Interface $1 is online (tracking $tracking)"
97
 				echo "Interface $1 is online (tracking $tracking)"
98
 			else
98
 			else
99
 				echo "Interface $1 is online"
99
 				echo "Interface $1 is online"
100
 			fi
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
 			echo "Interface $1 error"
102
 			echo "Interface $1 error"
103
 		else
103
 		else
104
 			if [ "$enabled" -eq 1 ]; then
104
 			if [ "$enabled" -eq 1 ]; then
123
 	for policy in $($IPT -S | awk '{print $2}' | grep mwan3_policy_ | sort -u); do
123
 	for policy in $($IPT -S | awk '{print $2}' | grep mwan3_policy_ | sort -u); do
124
 		echo "Policy $policy:" | sed 's/mwan3_policy_//g'
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
 		if [ ! -z "${total_weight##*[!0-9]*}" ]; then
128
 		if [ ! -z "${total_weight##*[!0-9]*}" ]; then
131
 			for iface in $($IPT -S $policy | cut -s -d'"' -f2 | awk '{print $1}'); do
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
 				percent=$(($weight*100/$total_weight))
131
 				percent=$(($weight*100/$total_weight))
134
 				echo " $iface ($percent%)"
132
 				echo " $iface ($percent%)"
135
 			done
133
 			done
148
 	if [ -n "$($IPT -S mwan3_connected 2> /dev/null)" ]; then
146
 	if [ -n "$($IPT -S mwan3_connected 2> /dev/null)" ]; then
149
 		echo "Known networks:"
147
 		echo "Known networks:"
150
 		echo "destination policy hits" | awk '{ printf "%-19s%-19s%-9s%s\n",$1,$2,$3}' | awk '1; {gsub(".","-")}1'
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
 		echo -e
150
 		echo -e
153
 	fi
151
 	fi
154
 
152
 
155
 	if [ -n "$($IPT -S mwan3_rules 2> /dev/null)" ]; then
153
 	if [ -n "$($IPT -S mwan3_rules 2> /dev/null)" ]; then
156
 		echo "Active rules:"
154
 		echo "Active rules:"
157
 		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'
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
 		echo -e
157
 		echo -e
160
 	fi
158
 	fi
161
 }
159
 }