From e649a10f07210cabd4be2c6beafbf019d9c2e28b Mon Sep 17 00:00:00 2001 From: "Craig M. Coffee" Date: Mon, 10 May 2010 02:04:52 +0000 Subject: [PATCH] multiwan: Changed failover probabilities for MultiWanLoadBalancer SVN-Revision: 21414 --- net/multiwan/Makefile | 2 +- net/multiwan/files/usr/bin/multiwan | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/net/multiwan/Makefile b/net/multiwan/Makefile index fc17cbce2..9948753b2 100644 --- a/net/multiwan/Makefile +++ b/net/multiwan/Makefile @@ -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 diff --git a/net/multiwan/files/usr/bin/multiwan b/net/multiwan/files/usr/bin/multiwan index 6f48108eb..78eb86c2b 100755 --- a/net/multiwan/files/usr/bin/multiwan +++ b/net/multiwan/files/usr/bin/multiwan @@ -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 -- 2.30.2