[packages] multiwan: Changed failover probabilities for
authorCraig M. Coffee <cmcoffee@gmail.com>
Mon, 10 May 2010 02:04:52 +0000 (02:04 +0000)
committerCraig M. Coffee <cmcoffee@gmail.com>
Mon, 10 May 2010 02:04:52 +0000 (02:04 +0000)
MultiWanLoadBalancer

SVN-Revision: 21414

net/multiwan/Makefile
net/multiwan/files/usr/bin/multiwan

index fc17cbce2a186d17acbb41d9bbc4b0d80de8f286..9948753b252b2b4686f750cdc3d5119f211b9cd4 100644 (file)
@@ -8,7 +8,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=multiwan
-PKG_VERSION:=1.0.5
+PKG_VERSION:=1.0.6
 PKG_RELEASE:=1
 
 include $(INCLUDE_DIR)/package.mk
index 6f48108ebfcfe3b81b8c9cbad5c363072779aa5c..78eb86c2b5142b235863bc6ebc143c0b3b3eb4e2 100755 (executable)
@@ -664,8 +664,13 @@ i=0
 while [ $i -lt $wancount ]; do 
 i=`expr $i + 1` 
 group=$(query_config group $i)
+failchk=$(query_config failchk $group)
+gateway=$(query_config gateway $group)
+ifname=$(query_config ifname $group)
 weight=`uci -q -P /var/state get multiwan.${group}.weight`
-total_weight=$(expr $total_weight + $weight)
+        if [ "$gateway" != "x" -a "$ifname" != "x" -a "$failchk" != "x" -a "$weight" != "disable" ]; then
+                total_weight=$(expr $total_weight + $weight)
+        fi
 done
 
 i=0
@@ -682,11 +687,13 @@ if [ "$gateway" != "x" -a "$ifname" != "x" -a "$failchk" != "x" -a "$weight" !=
 nexthop="$nexthop nexthop via $gateway dev $ifname weight $weight"
 rand_probability=$(expr $(expr $weight \* 100) / $total_weight)
 
-       if [ $rand_probability -lt 10 ]; then
-               rand_probability="0.0${rand_probability}"
-       else 
-               rand_probability="0.${rand_probability}"
-       fi
+        if [ $rand_probability -lt 10 ]; then
+                rand_probability="0.0${rand_probability}"
+        elif [ $rand_probability -lt 100 ]; then
+                rand_probability="0.${rand_probability}"
+        else
+                rand_probability="1.0"
+        fi
 
        if [ -z "$CHKFORMODULE" ]; then
                iptables -A MultiWanLoadBalancer -t mangle -m mark --mark 0x123 -m statistic --mode random --probability $rand_probability -j FW${i}MARK